Re: How do I publish default router preferences using rad?
I want to enable a scenario similar to what's described in https://tools.ietf.org/html/rfc4191#section-5.1 I run local network services for which I want a stable, publicly routed prefix, but my ISP's delegated prefix isn't static. I've setup a Hurricane Electric IPv6 tunnel to get a static prefix along side the dynamic, ISP-delegated prefix; https://github.com/cqcallaw/openbsd-router has details. Everything is functionally correct with the source-based routing configuration described in the docs, but the HE tunnel is necessarily slow because of the overhead incurred by the 6in4 tunnel. Connections are faster if my multihomed hosts prefer the native route for traffic that doesn't require use of the tunnel. I had patched rad to experiment with route preferences as a solution to this performance issue, but my local hosts don't seem to honor the advertised route preferences. I'm still researching what's required on the client side for route preferences to be honored. On Sun, Aug 18, 2019 at 4:28 AM Florian Obser wrote: > I'm curious, how are you using the router preference, could you tell > us a bit more about your network topology? > Also, what clients pay attention to it and how are they using it? > > Same goes for the route option, are you aware of clients using it? > > Thanks, > Florian > > On Sat, Aug 17, 2019 at 08:09:54PM -0700, Caleb Callaway wrote: > > If it interests anyone, I've also implemented the route option > > described in https://tools.ietf.org/html/rfc4191#section-2.3 > > > > I find sharing patches via this mailing list particularly unwieldy, > > so I've pushed my work to a git branch at > > https://github.com/cqcallaw/src/tree/rfc-4191 > > > > On Wed, Aug 7, 2019 at 11:27 PM Caleb > wrote: > > > > > > Thank you for the code and review! I've synthesized the existing patch > > > and review into something that successfully advertises router > > > preferences in local testing (verified w/ rdisc6). This patch does not > > > implement the route information option specified in RFC 4191 section > > > 2.3. > > > > > > diff --git a/usr.sbin/rad/frontend.c b/usr.sbin/rad/frontend.c > > > index 8178b058629..4031da6b99d 100644 > > > --- a/usr.sbin/rad/frontend.c > > > +++ b/usr.sbin/rad/frontend.c > > > @@ -411,7 +411,7 @@ frontend_dispatch_main(int fd, short event, void > *bula) > > > ra_prefix_conf)) > > >fatalx("%s: IMSG_RECONF_RA_PREFIX wrong " > > > "length: %lu", __func__, > > > -IMSG_DATA_SIZE(imsg)); > > > +IMSG_DATA_SIZE(imsg)); > > >if ((ra_prefix_conf = malloc(sizeof(struct > > > ra_prefix_conf))) == NULL) > > >fatal(NULL); > > > @@ -1023,6 +1023,18 @@ build_packet(struct ra_iface *ra_iface) > > >ra->nd_ra_router_lifetime = > > > htons(ra_options_conf->router_lifetime); > > >} > > > + > > > + /* add router preference flags */ > > > + if (ra_options_conf->preference == ND_RA_FLAG_RTPREF_RSV) { > > > + fatalx("Invalid router preference found during RA packet > > > construction."); > > > + } > > > + > > > + if (ra_options_conf->router_lifetime == 0) { > > > + log_debug("Router lifetime set to zero; ignoring router > > > preference per https://tools.ietf.org/html/rfc4191#section-2.2;); > > > + } else { > > > + ra->nd_ra_flags_reserved |= ra_options_conf->preference; > > > + } > > > + > > >ra->nd_ra_reachable = htonl(ra_options_conf->reachable_time); > > >ra->nd_ra_retransmit = htonl(ra_options_conf->retrans_timer); > > >p += sizeof(*ra); > > > diff --git a/usr.sbin/rad/parse.y b/usr.sbin/rad/parse.y > > > index 004e5e22f92..74480148246 100644 > > > --- a/usr.sbin/rad/parse.y > > > +++ b/usr.sbin/rad/parse.y > > > @@ -32,6 +32,7 @@ > > > #include > > > #include > > > +#include > > > #include > > > #include > > > @@ -117,10 +118,12 @@ typedef struct { > > > %token CONFIGURATION OTHER LIFETIME REACHABLE TIME RETRANS TIMER > > > %token AUTO PREFIX VALID PREFERRED LIFETIME ONLINK AUTONOMOUS > > > %token ADDRESS_CONFIGURATION DNS NAMESERVER SEARCH MTU > > > +%token PREFERENCE LOW MEDIUM HIGH > > > %token STRING > > > %token NUMBER > > > %typeyesno > > > +%typepreference > > > %typestring > > > %% > > > @@ -166,6 +169,11 @@ yesno : YES { $$ = 1; } > > >| NO{ $$ = 0; } > > >; > > > +preference : LOW { $$ = ND_RA_FLAG_RTPREF_LOW; } > > > + | MEDIUM { $$ = ND_RA_FLAG_RTPREF_MEDIUM; } > > > + | HIGH { $$ = ND_RA_FLAG_RTPREF_HIGH; } > > > + ; > > > + > > > varset : STRING '=' string { > > >char *s = $1; > > >if (cmd_opts & OPT_VERBOSE) > > > @@ -213,6 +221,9 @@ ra_opt_block: DEFAULT ROUTER yesno { > > >| MTU NUMBER { > > >ra_options->mtu = $2; > > >} > > > + | PREFERENCE preference { > > > + ra_options->preference = $2; > > > + } > > >| DNS dns_block > > >; >
Re: How do I publish default router preferences using rad?
I'm curious, how are you using the router preference, could you tell us a bit more about your network topology? Also, what clients pay attention to it and how are they using it? Same goes for the route option, are you aware of clients using it? Thanks, Florian On Sat, Aug 17, 2019 at 08:09:54PM -0700, Caleb Callaway wrote: > If it interests anyone, I've also implemented the route option > described in https://tools.ietf.org/html/rfc4191#section-2.3 > > I find sharing patches via this mailing list particularly unwieldy, > so I've pushed my work to a git branch at > https://github.com/cqcallaw/src/tree/rfc-4191 > > On Wed, Aug 7, 2019 at 11:27 PM Caleb wrote: > > > > Thank you for the code and review! I've synthesized the existing patch > > and review into something that successfully advertises router > > preferences in local testing (verified w/ rdisc6). This patch does not > > implement the route information option specified in RFC 4191 section > > 2.3. > > > > diff --git a/usr.sbin/rad/frontend.c b/usr.sbin/rad/frontend.c > > index 8178b058629..4031da6b99d 100644 > > --- a/usr.sbin/rad/frontend.c > > +++ b/usr.sbin/rad/frontend.c > > @@ -411,7 +411,7 @@ frontend_dispatch_main(int fd, short event, void *bula) > > ra_prefix_conf)) > >fatalx("%s: IMSG_RECONF_RA_PREFIX wrong " > > "length: %lu", __func__, > > -IMSG_DATA_SIZE(imsg)); > > +IMSG_DATA_SIZE(imsg)); > >if ((ra_prefix_conf = malloc(sizeof(struct > > ra_prefix_conf))) == NULL) > >fatal(NULL); > > @@ -1023,6 +1023,18 @@ build_packet(struct ra_iface *ra_iface) > >ra->nd_ra_router_lifetime = > > htons(ra_options_conf->router_lifetime); > >} > > + > > + /* add router preference flags */ > > + if (ra_options_conf->preference == ND_RA_FLAG_RTPREF_RSV) { > > + fatalx("Invalid router preference found during RA packet > > construction."); > > + } > > + > > + if (ra_options_conf->router_lifetime == 0) { > > + log_debug("Router lifetime set to zero; ignoring router > > preference per https://tools.ietf.org/html/rfc4191#section-2.2;); > > + } else { > > + ra->nd_ra_flags_reserved |= ra_options_conf->preference; > > + } > > + > >ra->nd_ra_reachable = htonl(ra_options_conf->reachable_time); > >ra->nd_ra_retransmit = htonl(ra_options_conf->retrans_timer); > >p += sizeof(*ra); > > diff --git a/usr.sbin/rad/parse.y b/usr.sbin/rad/parse.y > > index 004e5e22f92..74480148246 100644 > > --- a/usr.sbin/rad/parse.y > > +++ b/usr.sbin/rad/parse.y > > @@ -32,6 +32,7 @@ > > #include > > #include > > +#include > > #include > > #include > > @@ -117,10 +118,12 @@ typedef struct { > > %token CONFIGURATION OTHER LIFETIME REACHABLE TIME RETRANS TIMER > > %token AUTO PREFIX VALID PREFERRED LIFETIME ONLINK AUTONOMOUS > > %token ADDRESS_CONFIGURATION DNS NAMESERVER SEARCH MTU > > +%token PREFERENCE LOW MEDIUM HIGH > > %token STRING > > %token NUMBER > > %typeyesno > > +%typepreference > > %typestring > > %% > > @@ -166,6 +169,11 @@ yesno : YES { $$ = 1; } > >| NO{ $$ = 0; } > >; > > +preference : LOW { $$ = ND_RA_FLAG_RTPREF_LOW; } > > + | MEDIUM { $$ = ND_RA_FLAG_RTPREF_MEDIUM; } > > + | HIGH { $$ = ND_RA_FLAG_RTPREF_HIGH; } > > + ; > > + > > varset : STRING '=' string { > >char *s = $1; > >if (cmd_opts & OPT_VERBOSE) > > @@ -213,6 +221,9 @@ ra_opt_block: DEFAULT ROUTER yesno { > >| MTU NUMBER { > >ra_options->mtu = $2; > >} > > + | PREFERENCE preference { > > + ra_options->preference = $2; > > + } > >| DNS dns_block > >; > > @@ -426,16 +437,20 @@ lookup(char *s) > >{"default", DEFAULT}, > >{"dns", DNS}, > >{"hop", HOP}, > > + {"high",HIGH}, > >{"include", INCLUDE}, > >{"interface", RA_IFACE}, > >{"lifetime",LIFETIME}, > >{"limit", LIMIT}, > > + {"low", LOW}, > >{"managed", MANAGED}, > > + {"medium", MEDIUM}, > >{"mtu", MTU}, > >{"nameserver", NAMESERVER}, > >{"no", NO}, > >{"on-link", ONLINK}, > >{"other", OTHER}, > > + {"preference", PREFERENCE}, > >{"preferred", PREFERRED}, > >{"prefix", PREFIX}, > >{"reachable", REACHABLE}, > > diff --git a/usr.sbin/rad/printconf.c b/usr.sbin/rad/printconf.c > > index d42890da518..c2173d2142f 100644 > > --- a/usr.sbin/rad/printconf.c > > +++ b/usr.sbin/rad/printconf.c > > @@ -26,6 +26,7 @@ > > #include > > #include > > +#include > > #include > > #include > > @@ -34,6 +35,7 @@ > > #include "rad.h" > > const char*yesno(int); > > +const char*preference(int); > > void print_ra_options(const char*, const struct
Re: How do I publish default router preferences using rad?
If it interests anyone, I've also implemented the route option described in https://tools.ietf.org/html/rfc4191#section-2.3 I find sharing patches via this mailing list particularly unwieldy, so I've pushed my work to a git branch at https://github.com/cqcallaw/src/tree/rfc-4191 On Wed, Aug 7, 2019 at 11:27 PM Caleb wrote: > > Thank you for the code and review! I've synthesized the existing patch > and review into something that successfully advertises router > preferences in local testing (verified w/ rdisc6). This patch does not > implement the route information option specified in RFC 4191 section > 2.3. > > diff --git a/usr.sbin/rad/frontend.c b/usr.sbin/rad/frontend.c > index 8178b058629..4031da6b99d 100644 > --- a/usr.sbin/rad/frontend.c > +++ b/usr.sbin/rad/frontend.c > @@ -411,7 +411,7 @@ frontend_dispatch_main(int fd, short event, void *bula) > ra_prefix_conf)) >fatalx("%s: IMSG_RECONF_RA_PREFIX wrong " > "length: %lu", __func__, > -IMSG_DATA_SIZE(imsg)); > +IMSG_DATA_SIZE(imsg)); >if ((ra_prefix_conf = malloc(sizeof(struct > ra_prefix_conf))) == NULL) >fatal(NULL); > @@ -1023,6 +1023,18 @@ build_packet(struct ra_iface *ra_iface) >ra->nd_ra_router_lifetime = > htons(ra_options_conf->router_lifetime); >} > + > + /* add router preference flags */ > + if (ra_options_conf->preference == ND_RA_FLAG_RTPREF_RSV) { > + fatalx("Invalid router preference found during RA packet > construction."); > + } > + > + if (ra_options_conf->router_lifetime == 0) { > + log_debug("Router lifetime set to zero; ignoring router > preference per https://tools.ietf.org/html/rfc4191#section-2.2;); > + } else { > + ra->nd_ra_flags_reserved |= ra_options_conf->preference; > + } > + >ra->nd_ra_reachable = htonl(ra_options_conf->reachable_time); >ra->nd_ra_retransmit = htonl(ra_options_conf->retrans_timer); >p += sizeof(*ra); > diff --git a/usr.sbin/rad/parse.y b/usr.sbin/rad/parse.y > index 004e5e22f92..74480148246 100644 > --- a/usr.sbin/rad/parse.y > +++ b/usr.sbin/rad/parse.y > @@ -32,6 +32,7 @@ > #include > #include > +#include > #include > #include > @@ -117,10 +118,12 @@ typedef struct { > %token CONFIGURATION OTHER LIFETIME REACHABLE TIME RETRANS TIMER > %token AUTO PREFIX VALID PREFERRED LIFETIME ONLINK AUTONOMOUS > %token ADDRESS_CONFIGURATION DNS NAMESERVER SEARCH MTU > +%token PREFERENCE LOW MEDIUM HIGH > %token STRING > %token NUMBER > %typeyesno > +%typepreference > %typestring > %% > @@ -166,6 +169,11 @@ yesno : YES { $$ = 1; } >| NO{ $$ = 0; } >; > +preference : LOW { $$ = ND_RA_FLAG_RTPREF_LOW; } > + | MEDIUM { $$ = ND_RA_FLAG_RTPREF_MEDIUM; } > + | HIGH { $$ = ND_RA_FLAG_RTPREF_HIGH; } > + ; > + > varset : STRING '=' string { >char *s = $1; >if (cmd_opts & OPT_VERBOSE) > @@ -213,6 +221,9 @@ ra_opt_block: DEFAULT ROUTER yesno { >| MTU NUMBER { >ra_options->mtu = $2; >} > + | PREFERENCE preference { > + ra_options->preference = $2; > + } >| DNS dns_block >; > @@ -426,16 +437,20 @@ lookup(char *s) >{"default", DEFAULT}, >{"dns", DNS}, >{"hop", HOP}, > + {"high",HIGH}, >{"include", INCLUDE}, >{"interface", RA_IFACE}, >{"lifetime",LIFETIME}, >{"limit", LIMIT}, > + {"low", LOW}, >{"managed", MANAGED}, > + {"medium", MEDIUM}, >{"mtu", MTU}, >{"nameserver", NAMESERVER}, >{"no", NO}, >{"on-link", ONLINK}, >{"other", OTHER}, > + {"preference", PREFERENCE}, >{"preferred", PREFERRED}, >{"prefix", PREFIX}, >{"reachable", REACHABLE}, > diff --git a/usr.sbin/rad/printconf.c b/usr.sbin/rad/printconf.c > index d42890da518..c2173d2142f 100644 > --- a/usr.sbin/rad/printconf.c > +++ b/usr.sbin/rad/printconf.c > @@ -26,6 +26,7 @@ > #include > #include > +#include > #include > #include > @@ -34,6 +35,7 @@ > #include "rad.h" > const char*yesno(int); > +const char*preference(int); > void print_ra_options(const char*, const struct ra_options_conf*); > void print_prefix_options(const char*, const struct ra_prefix_conf*); > @@ -42,6 +44,20 @@ yesno(int flag) > { >return flag ? "yes" : "no"; > } > +const char* > +preference(int p) > +{ > + switch (p) { > + case ND_RA_FLAG_RTPREF_LOW: > + return "low"; > + case ND_RA_FLAG_RTPREF_MEDIUM: > + return "medium"; > + case ND_RA_FLAG_RTPREF_HIGH: > + return "high"; > + default: > + return "invalid"; > + } > +} > void > print_ra_options(const char *indent, const struct ra_options_conf
Re: How do I publish default router preferences using rad?
Thank you for the code and review! I've synthesized the existing patch and review into something that successfully advertises router preferences in local testing (verified w/ rdisc6). This patch does not implement the route information option specified in RFC 4191 section 2.3. diff --git a/usr.sbin/rad/frontend.c b/usr.sbin/rad/frontend.c index 8178b058629..4031da6b99d 100644 --- a/usr.sbin/rad/frontend.c +++ b/usr.sbin/rad/frontend.c @@ -411,7 +411,7 @@ frontend_dispatch_main(int fd, short event, void *bula) ra_prefix_conf)) fatalx("%s: IMSG_RECONF_RA_PREFIX wrong " "length: %lu", __func__, -IMSG_DATA_SIZE(imsg)); +IMSG_DATA_SIZE(imsg)); if ((ra_prefix_conf = malloc(sizeof(struct ra_prefix_conf))) == NULL) fatal(NULL); @@ -1023,6 +1023,18 @@ build_packet(struct ra_iface *ra_iface) ra->nd_ra_router_lifetime = htons(ra_options_conf->router_lifetime); } + + /* add router preference flags */ + if (ra_options_conf->preference == ND_RA_FLAG_RTPREF_RSV) { + fatalx("Invalid router preference found during RA packet construction."); + } + + if (ra_options_conf->router_lifetime == 0) { + log_debug("Router lifetime set to zero; ignoring router preference per https://tools.ietf.org/html/rfc4191#section-2.2;); + } else { + ra->nd_ra_flags_reserved |= ra_options_conf->preference; + } + ra->nd_ra_reachable = htonl(ra_options_conf->reachable_time); ra->nd_ra_retransmit = htonl(ra_options_conf->retrans_timer); p += sizeof(*ra); diff --git a/usr.sbin/rad/parse.y b/usr.sbin/rad/parse.y index 004e5e22f92..74480148246 100644 --- a/usr.sbin/rad/parse.y +++ b/usr.sbin/rad/parse.y @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -117,10 +118,12 @@ typedef struct { %token CONFIGURATION OTHER LIFETIME REACHABLE TIME RETRANS TIMER %token AUTO PREFIX VALID PREFERRED LIFETIME ONLINK AUTONOMOUS %token ADDRESS_CONFIGURATION DNS NAMESERVER SEARCH MTU +%token PREFERENCE LOW MEDIUM HIGH %token STRING %token NUMBER %typeyesno +%typepreference %typestring %% @@ -166,6 +169,11 @@ yesno : YES { $$ = 1; } | NO{ $$ = 0; } ; +preference : LOW { $$ = ND_RA_FLAG_RTPREF_LOW; } + | MEDIUM { $$ = ND_RA_FLAG_RTPREF_MEDIUM; } + | HIGH { $$ = ND_RA_FLAG_RTPREF_HIGH; } + ; + varset : STRING '=' string { char *s = $1; if (cmd_opts & OPT_VERBOSE) @@ -213,6 +221,9 @@ ra_opt_block: DEFAULT ROUTER yesno { | MTU NUMBER { ra_options->mtu = $2; } + | PREFERENCE preference { + ra_options->preference = $2; + } | DNS dns_block ; @@ -426,16 +437,20 @@ lookup(char *s) {"default", DEFAULT}, {"dns", DNS}, {"hop", HOP}, + {"high",HIGH}, {"include", INCLUDE}, {"interface", RA_IFACE}, {"lifetime",LIFETIME}, {"limit", LIMIT}, + {"low", LOW}, {"managed", MANAGED}, + {"medium", MEDIUM}, {"mtu", MTU}, {"nameserver", NAMESERVER}, {"no", NO}, {"on-link", ONLINK}, {"other", OTHER}, + {"preference", PREFERENCE}, {"preferred", PREFERRED}, {"prefix", PREFIX}, {"reachable", REACHABLE}, diff --git a/usr.sbin/rad/printconf.c b/usr.sbin/rad/printconf.c index d42890da518..c2173d2142f 100644 --- a/usr.sbin/rad/printconf.c +++ b/usr.sbin/rad/printconf.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -34,6 +35,7 @@ #include "rad.h" const char*yesno(int); +const char*preference(int); void print_ra_options(const char*, const struct ra_options_conf*); void print_prefix_options(const char*, const struct ra_prefix_conf*); @@ -42,6 +44,20 @@ yesno(int flag) { return flag ? "yes" : "no"; } +const char* +preference(int p) +{ + switch (p) { + case ND_RA_FLAG_RTPREF_LOW: + return "low"; + case ND_RA_FLAG_RTPREF_MEDIUM: + return "medium"; + case ND_RA_FLAG_RTPREF_HIGH: + return "high"; + default: + return "invalid"; + } +} void print_ra_options(const char *indent, const struct ra_options_conf *ra_options) @@ -60,6 +76,9 @@ print_ra_options(const char *indent, const struct ra_options_conf *ra_options) printf("%sretrans timer %u\n", indent, ra_options->retrans_timer); if (ra_options->mtu > 0) printf("%smtu %u\n", indent, ra_options->mtu); + if (ra_options->preference != ND_RA_FLAG_RTPREF_RSV) + printf("%spreference %s\n", indent, +preference(ra_options->preference)); if (!SIMPLEQ_EMPTY(_options->ra_rdnss_list) || !SIMPLEQ_EMPTY(_options->ra_dnssl_list)) { diff --git a/usr.sbin/rad/rad.c b/usr.sbin/rad/rad.c index 93675167b6b..cb0593f11ab 100644 ---
Re: How do I publish default router preferences using rad?
On Tue, Aug 06, 2019 at 11:17:04PM +0200, Sebastian Benoit wrote: > Caleb(enlightened.des...@gmail.com) on 2019.08.06 08:05:48 -0700: > > How do I publish default router preferences as defined in RFC 4191 > > (https://tools.ietf.org/html/rfc4191) using rad in OpenBSD 6.5? > > I've read the friendly rad.conf man page > > (https://man.openbsd.org/rad.conf.5) and scanned the source > > (https://github.com/openbsd/src/tree/master/usr.sbin/rad) with no > > success. > > You can't, because it was not implemented. > > That is, until now. > > I wrote a patch, which you can test if you like. It's completly untested > though. > needs more yak shaving > > diff --git usr.sbin/rad/frontend.c usr.sbin/rad/frontend.c > index 8178b058629..75723797fcf 100644 > --- usr.sbin/rad/frontend.c > +++ usr.sbin/rad/frontend.c > @@ -1016,6 +1016,8 @@ build_packet(struct ra_iface *ra_iface) > ra->nd_ra_flags_reserved |= ND_RA_FLAG_MANAGED; > if (ra_options_conf->o_flag) > ra->nd_ra_flags_reserved |= ND_RA_FLAG_OTHER; > + ra->nd_ra_flags_reserved |= > + ra_options_conf->preference; > if (ra_iface->removed) > /* tell clients that we are no longer a default router */ > ra->nd_ra_router_lifetime = 0; > @@ -1048,6 +1050,8 @@ build_packet(struct ra_iface *ra_iface) > if (ra_prefix_conf->aflag) > ndopt_pi->nd_opt_pi_flags_reserved |= > ND_OPT_PI_FLAG_AUTO; > + ndopt_pi->nd_opt_pi_flags_reserved |= > + ra_prefix_conf->preference; This is a prefix information option (type 3) not a route information option (type 24). Option 3 does not have a preference. > ndopt_pi->nd_opt_pi_valid_time = htonl(ra_prefix_conf->vltime); > ndopt_pi->nd_opt_pi_preferred_time = > htonl(ra_prefix_conf->pltime); > diff --git usr.sbin/rad/parse.y usr.sbin/rad/parse.y > index 004e5e22f92..b004ab37356 100644 > --- usr.sbin/rad/parse.y > +++ usr.sbin/rad/parse.y > @@ -106,6 +106,7 @@ typedef struct { > union { > int64_t number; > char*string; > + shortpref; eek, just treat it as a number? > } v; > int lineno; > } YYSTYPE; > @@ -117,11 +118,13 @@ typedef struct { > %token CONFIGURATION OTHER LIFETIME REACHABLE TIME RETRANS TIMER > %token AUTO PREFIX VALID PREFERRED LIFETIME ONLINK AUTONOMOUS > %token ADDRESS_CONFIGURATION DNS NAMESERVER SEARCH MTU > +%token PREFERENCE LOW MEDIUM HIGH > > %token STRING > %token NUMBER > %type yesno > %type string > +%typepreftype > > %% > > @@ -213,6 +216,9 @@ ra_opt_block : DEFAULT ROUTER yesno { > | MTU NUMBER { > ra_options->mtu = $2; > } > + | PREFERENCE preftype { > + ra_options->preference = $2; > + } > | DNS dns_block > ; > > @@ -298,6 +304,19 @@ ra_prefixoptsl : VALID LIFETIME NUMBER { > | AUTONOMOUS ADDRESS_CONFIGURATION yesno { > ra_prefix_conf->aflag = $3; > } > + | PREFERENCE preftype { > + ra_prefix_conf->preference = $2; > + } > + ; see above, we are announcing prefix information, not route information > +preftype : LOW { > + $$ = RA_PREFIXOPT_PREF_LOW; > + } > + | MEDIUM { > + $$ = RA_PREFIXOPT_PREF_MEDIUM; > + } > + | HIGH { > + $$ = RA_PREFIXOPT_PREF_HIGH; > + } please use the defines from icmp6.h: #define ND_RA_FLAG_RTPREF_HIGH 0x08/* 1000 */ #define ND_RA_FLAG_RTPREF_MEDIUM0x00/* */ #define ND_RA_FLAG_RTPREF_LOW 0x18/* 00011000 */ #define ND_RA_FLAG_RTPREF_RSV 0x10/* 0001 */ > ; > dns_block: '{' optnl dnsopts_l '}' > | '{' optnl '}' > @@ -425,17 +444,21 @@ lookup(char *s) > {"configuration", CONFIGURATION}, > {"default", DEFAULT}, > {"dns", DNS}, > + {"high",HIGH}, > {"hop", HOP}, > {"include", INCLUDE}, > {"interface", RA_IFACE}, > {"lifetime",LIFETIME}, > {"limit", LIMIT}, > + {"low", LOW}, > {"managed", MANAGED}, > + {"medium", MEDIUM}, > {"mtu", MTU}, > {"nameserver", NAMESERVER}, > {"no", NO}, > {"on-link", ONLINK}, >
Re: How do I publish default router preferences using rad?
Caleb(enlightened.des...@gmail.com) on 2019.08.06 08:05:48 -0700: > How do I publish default router preferences as defined in RFC 4191 > (https://tools.ietf.org/html/rfc4191) using rad in OpenBSD 6.5? > I've read the friendly rad.conf man page > (https://man.openbsd.org/rad.conf.5) and scanned the source > (https://github.com/openbsd/src/tree/master/usr.sbin/rad) with no > success. You can't, because it was not implemented. That is, until now. I wrote a patch, which you can test if you like. It's completly untested though. diff --git usr.sbin/rad/frontend.c usr.sbin/rad/frontend.c index 8178b058629..75723797fcf 100644 --- usr.sbin/rad/frontend.c +++ usr.sbin/rad/frontend.c @@ -1016,6 +1016,8 @@ build_packet(struct ra_iface *ra_iface) ra->nd_ra_flags_reserved |= ND_RA_FLAG_MANAGED; if (ra_options_conf->o_flag) ra->nd_ra_flags_reserved |= ND_RA_FLAG_OTHER; + ra->nd_ra_flags_reserved |= + ra_options_conf->preference; if (ra_iface->removed) /* tell clients that we are no longer a default router */ ra->nd_ra_router_lifetime = 0; @@ -1048,6 +1050,8 @@ build_packet(struct ra_iface *ra_iface) if (ra_prefix_conf->aflag) ndopt_pi->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_AUTO; + ndopt_pi->nd_opt_pi_flags_reserved |= + ra_prefix_conf->preference; ndopt_pi->nd_opt_pi_valid_time = htonl(ra_prefix_conf->vltime); ndopt_pi->nd_opt_pi_preferred_time = htonl(ra_prefix_conf->pltime); diff --git usr.sbin/rad/parse.y usr.sbin/rad/parse.y index 004e5e22f92..b004ab37356 100644 --- usr.sbin/rad/parse.y +++ usr.sbin/rad/parse.y @@ -106,6 +106,7 @@ typedef struct { union { int64_t number; char*string; + shortpref; } v; int lineno; } YYSTYPE; @@ -117,11 +118,13 @@ typedef struct { %token CONFIGURATION OTHER LIFETIME REACHABLE TIME RETRANS TIMER %token AUTO PREFIX VALID PREFERRED LIFETIME ONLINK AUTONOMOUS %token ADDRESS_CONFIGURATION DNS NAMESERVER SEARCH MTU +%token PREFERENCE LOW MEDIUM HIGH %token STRING %token NUMBER %typeyesno %typestring +%type preftype %% @@ -213,6 +216,9 @@ ra_opt_block: DEFAULT ROUTER yesno { | MTU NUMBER { ra_options->mtu = $2; } + | PREFERENCE preftype { + ra_options->preference = $2; + } | DNS dns_block ; @@ -298,6 +304,19 @@ ra_prefixoptsl : VALID LIFETIME NUMBER { | AUTONOMOUS ADDRESS_CONFIGURATION yesno { ra_prefix_conf->aflag = $3; } + | PREFERENCE preftype { + ra_prefix_conf->preference = $2; + } + ; +preftype : LOW { + $$ = RA_PREFIXOPT_PREF_LOW; + } + | MEDIUM { + $$ = RA_PREFIXOPT_PREF_MEDIUM; + } + | HIGH { + $$ = RA_PREFIXOPT_PREF_HIGH; + } ; dns_block : '{' optnl dnsopts_l '}' | '{' optnl '}' @@ -425,17 +444,21 @@ lookup(char *s) {"configuration", CONFIGURATION}, {"default", DEFAULT}, {"dns", DNS}, + {"high",HIGH}, {"hop", HOP}, {"include", INCLUDE}, {"interface", RA_IFACE}, {"lifetime",LIFETIME}, {"limit", LIMIT}, + {"low", LOW}, {"managed", MANAGED}, + {"medium", MEDIUM}, {"mtu", MTU}, {"nameserver", NAMESERVER}, {"no", NO}, {"on-link", ONLINK}, {"other", OTHER}, + {"preference", PREFERENCE}, {"preferred", PREFERRED}, {"prefix", PREFIX}, {"reachable", REACHABLE}, diff --git usr.sbin/rad/printconf.c usr.sbin/rad/printconf.c index d42890da518..e063daaa19f 100644 --- usr.sbin/rad/printconf.c +++ usr.sbin/rad/printconf.c @@ -34,6 +34,7 @@ #include "rad.h" const char*yesno(int); +const char*preference(short); void print_ra_options(const char*, const struct ra_options_conf*); void print_prefix_options(const char*, const struct ra_prefix_conf*); @@ -43,6 +44,21 @@ yesno(int flag) return flag ? "yes" : "no"; } +const
How do I publish default router preferences using rad?
How do I publish default router preferences as defined in RFC 4191 (https://tools.ietf.org/html/rfc4191) using rad in OpenBSD 6.5? I've read the friendly rad.conf man page (https://man.openbsd.org/rad.conf.5) and scanned the source (https://github.com/openbsd/src/tree/master/usr.sbin/rad) with no success. Thanks, -Caleb