Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
Re: bgpd: compare scopeid for nexthops -- aka I hate IPv6
To:
Theo Buehler <tb@theobuehler.org>
Cc:
tech@openbsd.org
Date:
Wed, 13 May 2026 16:05:03 +0200

Download raw body.

Thread
On Wed, May 13, 2026 at 04:03:39PM +0200, Theo Buehler wrote:
> On Wed, May 13, 2026 at 03:59:11PM +0200, Claudio Jeker wrote:
> > I hate IPv6 and especially scope ids.
> > 
> > Add missing scope_id checks in nexthop_cmp() since we now do allow
> > link-local nexthops in some cases.
> > 
> > There is probably more missing but this is one step.
> 
> almost ok.
> 
> > -- 
> > :wq Claudio
> > 
> > Index: rde_rib.c
> > ===================================================================
> > RCS file: /cvs/src/usr.sbin/bgpd/rde_rib.c,v
> > diff -u -p -r1.292 rde_rib.c
> > --- rde_rib.c	7 May 2026 11:21:24 -0000	1.292
> > +++ rde_rib.c	13 May 2026 13:55:32 -0000
> > @@ -1469,6 +1469,7 @@ static inline int
> >  nexthop_cmp(struct nexthop *na, struct nexthop *nb)
> >  {
> >  	struct bgpd_addr	*a, *b;
> > +	int r;
> >  
> >  	if (na == nb)
> >  		return (0);
> > @@ -1491,7 +1492,16 @@ nexthop_cmp(struct nexthop *na, struct n
> >  			return (-1);
> >  		return (0);
> >  	case AID_INET6:
> > -		return (memcmp(&a->v6, &b->v6, sizeof(struct in6_addr)));
> > +		r = memcmp(&a->v6, &b->v6, sizeof(struct in6_addr));
> > +		if (r != 0)
> > +			return r;
> > +		if (IN6_IS_ADDR_LINKLOCAL(&a->v6)) {
> > +			if (a->scope_id > b->scope_id)
> > +				return (1);
> > +			if (a->scope_id < b->scope_id)
> > +				return (1);
> 
> This wants to be
> 				return (-1);
 
Oups. Thanks for catching that.
 
> > +		}
> > +		return (0);
> >  	default:
> >  		fatalx("nexthop_cmp: %s is unsupported", aid2str(a->aid));
> >  	}
> > 
> 

-- 
:wq Claudio