On Thu, Aug 18, 2022 at 03:22:50PM +0200, Claudio Jeker wrote:
> Noticed while compling with gcc. In kroute_insert() the check for possible
> multipath routes is:
>       if (krm == NULL)
>               kr_redistribute(IMSG_NETWORK_ADD, kt, kf);
> 
> The problem is krm is only set in the IPv4 path but not in the IPv6 one.
> The diff below fixes this by using a new variable multipath which is set
> in the case where a multipath route is hit.

Ugh. Sorry for missing that. Yes, a new variable seems like the most
readable fix.

ok tb


> 
> -- 
> :wq Claudio
> 
> Index: kroute.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/kroute.c,v
> retrieving revision 1.293
> diff -u -p -r1.293 kroute.c
> --- kroute.c  18 Aug 2022 12:14:00 -0000      1.293
> +++ kroute.c  18 Aug 2022 13:22:06 -0000
> @@ -1607,6 +1607,7 @@ kroute_insert(struct ktable *kt, struct 
>       struct kroute6  *kr6, *kr6m;
>       struct knexthop *n;
>       uint32_t         mplslabel = 0;
> +     int              multipath = 0;
>  
>       if (kf->prefix.aid == AID_VPN_IPv4 ||
>           kf->prefix.aid == AID_VPN_IPv6) {
> @@ -1648,6 +1649,7 @@ kroute_insert(struct ktable *kt, struct 
>                       while (krm->next != NULL)
>                               krm = krm->next;
>                       krm->next = kr;
> +                     multipath = 1;
>               }
>  
>               if (kf->flags & F_BGPD)
> @@ -1684,6 +1686,7 @@ kroute_insert(struct ktable *kt, struct 
>                       while (kr6m->next != NULL)
>                               kr6m = kr6m->next;
>                       kr6m->next = kr6;
> +                     multipath = 1;
>               }
>  
>               if (kf->flags & F_BGPD)
> @@ -1699,8 +1702,8 @@ kroute_insert(struct ktable *kt, struct 
>                           kf->prefixlen) == 0)
>                               knexthop_validate(kt, n);
>  
> -             if (krm == NULL)
> -                     /* redistribute multipath routes only once */
> +             /* redistribute multipath routes only once */
> +             if (!multipath)
>                       kr_redistribute(IMSG_NETWORK_ADD, kt, kf);
>       }
>  
> 

Reply via email to