On Fri, Aug 19, 2022 at 10:45:20AM +0200, Claudio Jeker wrote:
> When implementing knexthop_true_nexthop() to do the lookup from BGP
> nexthop to the true nexthop used by the FIB I forgot to handle connected
> networks properly.
> 
> For connected networks and connected nexthops the BGP exit nexthop is
> equal to the true nexthop used by the FIB since the nexthop is directly
> reachable. kroutes which have F_CONNECTED set do not have a nexthop so
> the code should not try to fill the gateway. Since the input nexthop
> is already the right value the code can just return success (1).
> 
> Problem noticed by Daniel Jakots. Fix tested by me.

That makes sense

ok

> -- 
> :wq Claudio
> 
> Index: kroute.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/kroute.c,v
> retrieving revision 1.294
> diff -u -p -r1.294 kroute.c
> --- kroute.c  18 Aug 2022 17:02:42 -0000      1.294
> +++ kroute.c  19 Aug 2022 06:45:55 -0000
> @@ -2152,11 +2152,15 @@ knexthop_true_nexthop(struct ktable *kt,
>       switch (kn->nexthop.aid) {
>       case AID_INET:
>               kr = kn->kroute;
> +             if (kr->flags & F_CONNECTED)
> +                     return 1;
>               gateway.aid = AID_INET;
>               gateway.v4.s_addr = kr->nexthop.s_addr;
>               break;
>       case AID_INET6:
>               kr6 = kn->kroute;
> +             if (kr6->flags & F_CONNECTED)
> +                     return 1;
>               gateway.aid = AID_INET6;
>               gateway.v6 = kr6->nexthop;
>               gateway.scope_id = kr6->nexthop_scope_id;
> 

Reply via email to