Index: bpf.c =================================================================== RCS file: /cvs/src/sys/net/bpf.c,v diff -u -p -r1.227 bpf.c --- bpf.c 19 Nov 2024 23:26:35 -0000 1.227 +++ bpf.c 19 Nov 2024 23:29:03 -0000 @@ -1180,22 +1180,19 @@ bpf_setf(struct bpf_d *d, struct bpf_pro int bpf_setif(struct bpf_d *d, struct ifreq *ifr) { - struct bpf_if *bp, *candidate = NULL; + struct bpf_if *bp; int error = 0; /* * Look through attached interfaces for the named one. */ TAILQ_FOREACH(bp, &bpf_iflist, bif_next) { - if (strcmp(bp->bif_name, ifr->ifr_name) != 0) - continue; - - if (candidate == NULL || candidate->bif_dlt > bp->bif_dlt) - candidate = bp; + if (strcmp(bp->bif_name, ifr->ifr_name) == 0) + break; } /* Not found. */ - if (candidate == NULL) + if (bp == NULL) return (ENXIO); /* @@ -1208,12 +1205,12 @@ bpf_setif(struct bpf_d *d, struct ifreq if ((error = bpf_allocbufs(d))) goto out; } - if (candidate != d->bd_bif) { + if (bp != d->bd_bif) { /* * Detach if attached to something else. */ bpf_detachd(d); - bpf_attachd(d, candidate); + bpf_attachd(d, bp); } bpf_resetd(d); out: