On Fri, Jul 20, 2018 at 03:40:07PM +0200, Björn Ketelaars wrote: > New diff, which addresses all your comments except the "no mtu" bit in > the parser as I do not understand what you mean.
Never mind then :) I was thinking about something like this: ----8<---- mtu 1480 interface ix0 # gets mtu 1480 option from global default interface em0 { no mtu # do not send mtu option } ----8<---- but that seems rather obscure. And can be achieved like this: interface em0 { mtu 0 } one tweak inline: > > > diff --git frontend.c frontend.c > index b06fa43038c..0509d2b3efe 100644 > --- frontend.c > +++ frontend.c > @@ -887,6 +887,7 @@ void > build_packet(struct ra_iface *ra_iface) > { > struct nd_router_advert *ra; > + struct nd_opt_mtu *ndopt_mtu; > struct nd_opt_prefix_info *ndopt_pi; > struct ra_iface_conf *ra_iface_conf; > struct ra_options_conf *ra_options_conf; > @@ -904,6 +905,8 @@ build_packet(struct ra_iface *ra_iface) > ra_options_conf = &ra_iface_conf->ra_options; > > len = sizeof(*ra); > + if (ra_options_conf->mtu > 0) > + len += sizeof(*ndopt_mtu); > len += sizeof(*ndopt_pi) * ra_iface->prefix_count; > if (ra_iface_conf->rdnss_count > 0) > len += sizeof(*ndopt_rdnss) + ra_iface_conf->rdnss_count * > @@ -940,6 +943,15 @@ build_packet(struct ra_iface *ra_iface) > ra->nd_ra_retransmit = htonl(ra_options_conf->retrans_timer); > p += sizeof(*ra); > > + if (ra_options_conf->mtu > 0) { > + ndopt_mtu = (struct nd_opt_mtu *)p; > + ndopt_mtu->nd_opt_mtu_type = ND_OPT_MTU; > + ndopt_mtu->nd_opt_mtu_len = 1; > + ndopt_mtu->nd_opt_mtu_reserved = 0; > + ndopt_mtu->nd_opt_mtu_mtu = htonl(ra_options_conf->mtu); > + p += sizeof(*ndopt_mtu); > + } > + > SIMPLEQ_FOREACH(ra_prefix_conf, &ra_iface->prefixes, entry) { > ndopt_pi = (struct nd_opt_prefix_info *)p; > memset(ndopt_pi, 0, sizeof(*ndopt_pi)); > diff --git parse.y parse.y > index 582d165c7d6..6eb6990f97b 100644 > --- parse.y > +++ parse.y > @@ -115,7 +115,7 @@ typedef struct { > %token DEFAULT ROUTER HOP LIMIT MANAGED ADDRESS > %token CONFIGURATION OTHER LIFETIME REACHABLE TIME RETRANS TIMER > %token AUTO PREFIX VALID PREFERRED LIFETIME ONLINK AUTONOMOUS > -%token ADDRESS_CONFIGURATION DNS RESOLVER SEARCH > +%token ADDRESS_CONFIGURATION DNS RESOLVER SEARCH MTU > > %token <v.string> STRING > %token <v.number> NUMBER > @@ -209,6 +209,9 @@ ra_opt_block : DEFAULT ROUTER yesno { > | RETRANS TIMER NUMBER { > ra_options->retrans_timer = $3; > } > + | MTU NUMBER { > + ra_options->mtu = $2; > + } > ; > > optnl : '\n' optnl /* zero or more newlines */ > @@ -423,6 +426,7 @@ lookup(char *s) > {"lifetime", LIFETIME}, > {"limit", LIMIT}, > {"managed", MANAGED}, > + {"mtu", MTU}, > {"no", NO}, > {"on-link", ONLINK}, > {"other", OTHER}, > diff --git printconf.c printconf.c > index 1fc8cd4ca3f..b7864dbae6b 100644 > --- printconf.c > +++ printconf.c > @@ -54,6 +54,7 @@ print_ra_options(const char *indent, const struct > ra_options_conf *ra_options) > printf("%srouter lifetime %d\n", indent, ra_options->router_lifetime); > printf("%sreachable time %u\n", indent, ra_options->reachable_time); > printf("%sretrans timer %u\n", indent, ra_options->retrans_timer); please add if (ra_options->mtu) to print mtu only when it's set. Since mtu 0 means to not send the option at all. With that OK florian@ (note that I just caused a conflict for you in parse.y, sorry about that) > + printf("%smtu %u\n", indent, ra_options->mtu); > } > > void > diff --git rad.c rad.c > index 4652e1e0fb7..9f4be1b2190 100644 > --- rad.c > +++ rad.c > @@ -716,6 +716,7 @@ config_new_empty(void) > xconf->ra_options.router_lifetime = 1800; > xconf->ra_options.reachable_time = 0; > xconf->ra_options.retrans_timer = 0; > + xconf->ra_options.mtu = 0; > > return (xconf); > } > diff --git rad.conf.5 rad.conf.5 > index 6ca6b3ef956..486bec24769 100644 > --- rad.conf.5 > +++ rad.conf.5 > @@ -87,6 +87,11 @@ The default is 1800 seconds. > .\" XXX > .\" .It Ic retrans timer Ar number > .\" XXX > +.It Ic mtu Ar bytes > +The MTU option is used in Router Advertisement messages to ensure that all > +nodes on a link use the same MTU value in those cases where the link MTU > +is not well known. > +The default is 0, meaning unspecified by this router. > .El > .Sh INTERFACES > A list of interfaces to send advertisments on: > diff --git rad.h rad.h > index db80d7c772d..f9d26d66c9c 100644 > --- rad.h > +++ rad.h > @@ -76,7 +76,7 @@ enum imsg_type { > IMSG_SOCKET_IPC > }; > > -/* RFC 4861 Section 4.2 */ > +/* RFC 4861 Sections 4.2 and 4.6.4 */ > struct ra_options_conf { > int dfr; /* is default router? */ > int cur_hl; /* current hop limit */ > @@ -85,6 +85,7 @@ struct ra_options_conf { > int router_lifetime; /* default router lifetime */ > uint32_t reachable_time; > uint32_t retrans_timer; > + uint32_t mtu; > }; > > /* RFC 4861 Section 4.6.2 */ -- I'm not entirely sure you are real.