We have this sequence in bridge(4) ioctl(2) path:
authormvs <mvs@openbsd.org>
Mon, 25 Jan 2021 19:47:16 +0000 (19:47 +0000)
committermvs <mvs@openbsd.org>
Mon, 25 Jan 2021 19:47:16 +0000 (19:47 +0000)
commit044aaac6d42ec1f1777a52f2fa98b542d731d25c
tree56434ca1dd6831d94bb976bfd425c231bb38b9c3
parent4503e56da8f5cf33f087536eae49056ce910da58
We have this sequence in bridge(4) ioctl(2) path:

ifs = ifunit(req->ifbr_ifsname);
if (ifs == NULL) {
error = ENOENT;
break;
}
if (ifs->if_bridgeidx != ifp->if_index) {
error = ESRCH;
break;
}
bif = bridge_getbif(ifs);

This sequence repeats 8 times. Also we don't check value returned by
bridge_getbig() before use. Newly introduced bridge_getbig() function
replaces this sequence. This not only reduces duplicated code but also
makes `bif' dereference safe.

ok bluhm@
sys/net/bridgectl.c
sys/net/bridgestp.c
sys/net/if_bridge.c
sys/net/if_bridge.h