Message ID | 20230216203041.2203509-2-stijn@linux-ipv6.be |
---|---|
State | Accepted, archived |
Delegated to: | Stijn Tintel |
Headers | show |
Series | [odhcpd,v2,1/2] router: improve RA logging | expand |
On Thu, Feb 16, 2023 at 9:30 PM <stijn@linux-ipv6.be> wrote: > > We currently only check ra_default when an interface has valid > addresses. This results in ra_default being ignored in case we have an > interface with only link-local addresses. This effectively breaks the > use of value 2 for the ra_default parameter. > > Fix this by always checking ra_lifetime, regardless of the interface > having public addresses or not. > > Fixes: #11930 > Fixes: 83e14f455817 ("router: advertise removed addresses as invalid in 3 consecutive RAs") > Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be> Acked-by:Hans Dedecker <dedeckeh@gmail.com> > --- > src/router.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/src/router.c b/src/router.c > index 1c11849..7e66e3c 100644 > --- a/src/router.c > +++ b/src/router.c > @@ -488,6 +488,14 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr > valid_addr_cnt = (iface->timer_rs.cb /* if not shutdown */ ? iface->addr6_len : 0); > invalid_addr_cnt = iface->invalid_addr6_len; > > + // check ra_default > + if (iface->default_router) { > + default_route = true; > + > + if (iface->default_router > 1) > + valid_prefix = true; > + } > + > if (valid_addr_cnt + invalid_addr_cnt) { > addrs = alloca(sizeof(*addrs) * (valid_addr_cnt + invalid_addr_cnt)); > > @@ -495,12 +503,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr > memcpy(addrs, iface->addr6, sizeof(*addrs) * valid_addr_cnt); > > /* Check default route */ > - if (iface->default_router) { > - default_route = true; > - > - if (iface->default_router > 1) > - valid_prefix = true; > - } else if (parse_routes(addrs, valid_addr_cnt)) > + if (!default_route && parse_routes(addrs, valid_addr_cnt)) > default_route = true; > } > > -- > 2.39.1 >
diff --git a/src/router.c b/src/router.c index 1c11849..7e66e3c 100644 --- a/src/router.c +++ b/src/router.c @@ -488,6 +488,14 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr valid_addr_cnt = (iface->timer_rs.cb /* if not shutdown */ ? iface->addr6_len : 0); invalid_addr_cnt = iface->invalid_addr6_len; + // check ra_default + if (iface->default_router) { + default_route = true; + + if (iface->default_router > 1) + valid_prefix = true; + } + if (valid_addr_cnt + invalid_addr_cnt) { addrs = alloca(sizeof(*addrs) * (valid_addr_cnt + invalid_addr_cnt)); @@ -495,12 +503,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr memcpy(addrs, iface->addr6, sizeof(*addrs) * valid_addr_cnt); /* Check default route */ - if (iface->default_router) { - default_route = true; - - if (iface->default_router > 1) - valid_prefix = true; - } else if (parse_routes(addrs, valid_addr_cnt)) + if (!default_route && parse_routes(addrs, valid_addr_cnt)) default_route = true; }
We currently only check ra_default when an interface has valid addresses. This results in ra_default being ignored in case we have an interface with only link-local addresses. This effectively breaks the use of value 2 for the ra_default parameter. Fix this by always checking ra_lifetime, regardless of the interface having public addresses or not. Fixes: #11930 Fixes: 83e14f455817 ("router: advertise removed addresses as invalid in 3 consecutive RAs") Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be> --- src/router.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)