Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: bgpd: remove unnecessary checks
To:
tech@openbsd.org
Date:
Wed, 5 Nov 2025 15:04:39 +0100

Download raw body.

Thread
On Wed, Nov 05, 2025 at 02:57:41PM +0100, Claudio Jeker wrote:
> The asp passed to prefix_add() and prefix_move() must not be NULL.

And it is not NULL since path_getcache() can't fail.

> So there is no need to check for that before looking at asp->pftableid.

Agreed.

> I think this was needed some long time ago when that code was somewhere
> else.

Maybe. Or it was copied from elsewhere where asp can be NULL.
Be that as it may

ok tb

> Reported by CID 492349, 492350
> -- 
> :wq Claudio
> 
> Index: rde_rib.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/rde_rib.c,v
> diff -u -p -r1.273 rde_rib.c
> --- rde_rib.c	29 Oct 2025 10:34:23 -0000	1.273
> +++ rde_rib.c	5 Nov 2025 13:46:02 -0000
> @@ -1060,7 +1060,7 @@ prefix_add(struct bgpd_addr *prefix, int
>  		p->flags |= PREFIX_FLAG_FILTERED;
>  
>  	/* add possible pftable reference form aspath */
> -	if (asp && asp->pftableid)
> +	if (asp->pftableid)
>  		rde_pftable_add(asp->pftableid, p);
>  	/* make route decision */
>  	prefix_evaluate(re, p, NULL);
> @@ -1092,7 +1092,7 @@ prefix_move(struct prefix *p, struct rde
>  		np->flags |= PREFIX_FLAG_FILTERED;
>  
>  	/* add possible pftable reference from new aspath */
> -	if (asp && asp->pftableid)
> +	if (asp->pftableid)
>  		rde_pftable_add(asp->pftableid, np);
>  
>  	/*
>