From 6ec5f5c4279c887ea4b464839e8cc3a2160599b3 Mon Sep 17 00:00:00 2001 From: Vladislav Grishenko Date: Mon, 24 Apr 2017 22:34:45 +0100 Subject: [PATCH] Extend --ra-param mtu: field to allow an interface name. --- CHANGELOG | 7 ++++++- man/dnsmasq.8 | 6 +++++- man/fr/dnsmasq.8 | 2 +- src/dnsmasq.h | 1 + src/option.c | 7 +++++-- src/radv.c | 3 ++- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 27586d7..e9112e1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -103,7 +103,12 @@ version 2.77 presence of the --bogus-priv flag. Thanks to Vladislav Grishenko for the patch. - + Extend --ra-param mtu: field to allow an interface name. + This allows the MTU of a WAN interface to be advertised on + the internal interfaces of a router. Thanks to + Vladislav Grishenko for the patch. + + version 2.76 Include 0.0.0.0/8 in DNS rebind checks. This range translates to hosts on the local network, or, at diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 index 6c9ebaf..38858f5 100644 --- a/man/dnsmasq.8 +++ b/man/dnsmasq.8 @@ -1776,7 +1776,7 @@ the relevant link-local address of the machine running dnsmasq is sent as recursive DNS server. If provided, the DHCPv6 options dns-server and domain-search are used for the DNS server (RDNSS) and the domain search list (DNSSL). .TP -.B --ra-param=,[mtu:|off,][high,|low,][,] +.B --ra-param=,[mtu:||off,][high,|low,][,] Set non-default values for router advertisements sent via an interface. The priority field for the router may be altered from the default of medium with eg @@ -1788,7 +1788,11 @@ a router to advertise prefixes but not a route via itself. .B --ra-parm=eth0,0,0 (A value of zero for the interval means the default value.) All four parameters may be set at once. .B --ra-param=eth0,mtu:1280,low,60,1200 + The interface field may include a wildcard. + +The mtu: parameter may be an arbitrary interface name, in which case the MTU value for that interface is used. This is useful +for (eg) advertising the MTU of a WAN interface on the other interfaces of a router. .TP .B --dhcp-reply-delay=[tag:,] Delays sending DHCPOFFER and proxydhcp replies for at least the specified number of seconds. diff --git a/man/fr/dnsmasq.8 b/man/fr/dnsmasq.8 index 080ffe3..80cef39 100644 --- a/man/fr/dnsmasq.8 +++ b/man/fr/dnsmasq.8 @@ -1756,7 +1756,7 @@ dnsmasq est spécifiée comme DNS récursif. Si elles sont fournies, les options dns-server et domain-search sont utilisées respectivement pour RDNSS et DNSSL. .TP -.B --ra-param=,[mtu:|off,][high,|low,][,] +.B --ra-param=,[mtu:||off,][high,|low,][,] Configure pour une interface donnée des valeurs pour les annonces routeurs différentes des valeurs par défaut. La valeur par défaut du champ priorité pour le routeur peut-être changée de "medium" (moyen) à "high" (haute) ou diff --git a/src/dnsmasq.h b/src/dnsmasq.h index c75ff2e..ace6b1e 100644 --- a/src/dnsmasq.h +++ b/src/dnsmasq.h @@ -841,6 +841,7 @@ struct prefix_class { struct ra_interface { char *name; + char *mtu_name; int interval, lifetime, prio, mtu; struct ra_interface *next; }; diff --git a/src/option.c b/src/option.c index 30c6d4c..81c2ae6 100644 --- a/src/option.c +++ b/src/option.c @@ -488,7 +488,7 @@ static struct { #ifdef OPTION6_PREFIX_CLASS { LOPT_PREF_CLSS, ARG_DUP, "set:tag,", gettext_noop("Specify DHCPv6 prefix class"), NULL }, #endif - { LOPT_RA_PARAM, ARG_DUP, ",[mtu:|off,][,][,]", gettext_noop("Set MTU, priority, resend-interval and router-lifetime"), NULL }, + { LOPT_RA_PARAM, ARG_DUP, ",[mtu:||off,][,][,]", 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) diff --git a/src/radv.c b/src/radv.c index 70211c5..07cf972 100644 --- a/src/radv.c +++ b/src/radv.c @@ -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))