Extend --ra-param mtu: field to allow an interface name.

This commit is contained in:
Vladislav Grishenko
2017-04-24 22:34:45 +01:00
committed by Simon Kelley
parent 5a7212c70e
commit 6ec5f5c427
6 changed files with 20 additions and 6 deletions

View File

@@ -841,6 +841,7 @@ struct prefix_class {
struct ra_interface {
char *name;
char *mtu_name;
int interval, lifetime, prio, mtu;
struct ra_interface *next;
};

View File

@@ -488,7 +488,7 @@ static struct {
#ifdef OPTION6_PREFIX_CLASS
{ LOPT_PREF_CLSS, ARG_DUP, "set:tag,<class>", gettext_noop("Specify DHCPv6 prefix class"), NULL },
#endif
{ LOPT_RA_PARAM, ARG_DUP, "<iface>,[mtu:<value>|off,][<prio>,]<intval>[,<lifetime>]", gettext_noop("Set MTU, priority, resend-interval and router-lifetime"), NULL },
{ LOPT_RA_PARAM, ARG_DUP, "<iface>,[mtu:<value>|<interface>|off,][<prio>,]<intval>[,<lifetime>]", gettext_noop("Set MTU, priority, resend-interval and router-lifetime"), NULL },
{ LOPT_QUIET_DHCP, OPT_QUIET_DHCP, NULL, gettext_noop("Do not log routine DHCP."), NULL },
{ LOPT_QUIET_DHCP6, OPT_QUIET_DHCP6, NULL, gettext_noop("Do not log routine DHCPv6."), NULL },
{ LOPT_QUIET_RA, OPT_QUIET_RA, NULL, gettext_noop("Do not log RA."), NULL },
@@ -3707,6 +3707,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
new->lifetime = -1;
new->prio = 0;
new->mtu = 0;
new->mtu_name = NULL;
new->name = opt_string_alloc(arg);
if (strcasestr(comma, "mtu:") == comma)
{
@@ -3715,7 +3716,9 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
goto err;
if (!strcasecmp(arg, "off"))
new->mtu = -1;
else if (!atoi_check(arg, &new->mtu) || new->mtu < 1280)
else if (!atoi_check(arg, &new->mtu))
new->mtu_name = opt_string_alloc(arg);
else if (new->mtu < 1280)
goto err;
}
if (strcasestr(comma, "high") == comma || strcasestr(comma, "low") == comma)

View File

@@ -408,7 +408,8 @@ static void send_ra_alias(time_t now, int iface, char *iface_name, struct in6_ad
available from SIOCGIFMTU */
if (mtu == 0)
{
sprintf(daemon->namebuff, "/proc/sys/net/ipv6/conf/%s/mtu", iface_name);
char *mtu_name = ra_param ? ra_param->mtu_name : NULL;
sprintf(daemon->namebuff, "/proc/sys/net/ipv6/conf/%s/mtu", mtu_name ? : iface_name);
if ((f = fopen(daemon->namebuff, "r")))
{
if (fgets(daemon->namebuff, MAXDNAME, f))