On Thu, Jun 23, 2022 at 09:56:19AM +0200, Claudio Jeker wrote: > IPv6 is such a lovley protocol. Add the scope_id for link local addresses > in kr6_tofull() because IPv6 just has to be "special". > > Maybe we should add a scope_id to struct kroute6 but heck it is mostly the > interface index except for non link local addresses because there it has > to be 0. So this works for now.
ok tb > > With this link local routes show properly in bgpctl show fib output: > flags: * = valid, B = BGP, C = Connected, S = Static > N = BGP Nexthop reachable via this route > r = reject route, b = blackhole route > > flags prio destination gateway > *C 1 ::1/128 link#3 > *C 4 fe80::%re0/64 link#1 > *C 1 fe80::1%lo0/128 link#3 > *C 1 fe80::1%lo1/128 link#4 > *C 4 ff01::%re0/32 link#1 > *C 4 ff01::%lo0/32 link#3 > *C 4 ff01::%lo1/32 link#4 > *C 4 ff02::%re0/32 link#1 > > -- > :wq Claudio > > Index: kroute.c > =================================================================== > RCS file: /cvs/src/usr.sbin/bgpd/kroute.c,v > retrieving revision 1.265 > diff -u -p -r1.265 kroute.c > --- kroute.c 23 Jun 2022 07:43:37 -0000 1.265 > +++ kroute.c 23 Jun 2022 07:44:53 -0000 > @@ -1602,8 +1602,17 @@ kr6_tofull(struct kroute6 *kr6) > > kf.prefix.aid = AID_INET6; > memcpy(&kf.prefix.v6, &kr6->prefix, sizeof(struct in6_addr)); > + /* only set scope_id for link-local addresses because IPv6 */ > + if (IN6_IS_ADDR_LINKLOCAL(&kr6->prefix) || > + IN6_IS_ADDR_MC_LINKLOCAL(&kr6->prefix) || > + IN6_IS_ADDR_MC_INTFACELOCAL(&kr6->prefix)) > + kf.prefix.scope_id = kr6->ifindex; > kf.nexthop.aid = AID_INET6; > memcpy(&kf.nexthop.v6, &kr6->nexthop, sizeof(struct in6_addr)); > + if (IN6_IS_ADDR_LINKLOCAL(&kr6->nexthop) || > + IN6_IS_ADDR_MC_LINKLOCAL(&kr6->nexthop) || > + IN6_IS_ADDR_MC_INTFACELOCAL(&kr6->nexthop)) > + kf.nexthop.scope_id = kr6->ifindex; > strlcpy(kf.label, rtlabel_id2name(kr6->labelid), sizeof(kf.label)); > kf.flags = kr6->flags; > kf.ifindex = kr6->ifindex; >
