diff options
author | wollman <wollman@FreeBSD.org> | 1997-01-13 21:26:53 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1997-01-13 21:26:53 +0000 |
commit | 19e2ac904f46e8d37d7cd3d2b1186258b4e8f73b (patch) | |
tree | 910b1426d4c193f9ebe781e273cdb61d4b1ee1fd /sys/dev | |
parent | 52ec48faa0c0c800965bfbe06fa3f8869f922d41 (diff) | |
download | FreeBSD-src-19e2ac904f46e8d37d7cd3d2b1186258b4e8f73b.zip FreeBSD-src-19e2ac904f46e8d37d7cd3d2b1186258b4e8f73b.tar.gz |
Use the new if_multiaddrs list for multicast addresses rather than the
previous hackery involving struct in_ifaddr and arpcom. Get rid of the
abominable multi_kludge. Update all network interfaces to use the
new machanism. Distressingly few Ethernet drivers program the multicast
filter properly (assuming the hardware has one, which it usually does).
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/de/if_de.c | 110 | ||||
-rw-r--r-- | sys/dev/ed/if_ed.c | 39 | ||||
-rw-r--r-- | sys/dev/fe/if_fe.c | 45 | ||||
-rw-r--r-- | sys/dev/fxp/if_fxp.c | 20 | ||||
-rw-r--r-- | sys/dev/ie/if_ie.c | 44 | ||||
-rw-r--r-- | sys/dev/lnc/if_lnc.c | 33 | ||||
-rw-r--r-- | sys/dev/vx/if_vx.c | 24 |
7 files changed, 119 insertions, 196 deletions
diff --git a/sys/dev/de/if_de.c b/sys/dev/de/if_de.c index c5d7f5a..95bc095 100644 --- a/sys/dev/de/if_de.c +++ b/sys/dev/de/if_de.c @@ -21,7 +21,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: if_de.c,v 1.55 1996/11/10 13:36:46 davidg Exp $ + * $Id: if_de.c,v 1.56 1996/12/01 06:01:00 rgrimes Exp $ * */ @@ -3287,62 +3287,63 @@ tulip_addr_filter( tulip_softc_t * const sc) { u_int32_t *sp = sc->tulip_setupdata; - struct ether_multistep step; - struct ether_multi *enm; + struct ifmultiaddr *ifma; int i = 0; + u_char *addrp; + unsigned hash; + + ifma = sc->tulip_if.if_multiaddrs.lh_first; sc->tulip_flags &= ~TULIP_WANTHASH; sc->tulip_flags |= TULIP_WANTSETUP; sc->tulip_cmdmode &= ~TULIP_CMD_RXRUN; sc->tulip_intrmask &= ~TULIP_STS_RXSTOPPED; - if (sc->tulip_ac.ac_multicnt > 14) { - unsigned hash; - /* - * If we have more than 14 multicasts, we have - * go into hash perfect mode (512 bit multicast - * hash and one perfect hardware). - */ - bzero(sc->tulip_setupdata, sizeof(sc->tulip_setupdata)); - hash = tulip_mchash(etherbroadcastaddr); - sp[hash >> 4] |= 1 << (hash & 0xF); - ETHER_FIRST_MULTI(step, &sc->tulip_ac, enm); - while (enm != NULL) { - hash = tulip_mchash(enm->enm_addrlo); - sp[hash >> 4] |= 1 << (hash & 0xF); - ETHER_NEXT_MULTI(step, enm); - } - sc->tulip_flags |= TULIP_WANTHASH; - sp[39] = ((u_int16_t *) sc->tulip_ac.ac_enaddr)[0]; - sp[40] = ((u_int16_t *) sc->tulip_ac.ac_enaddr)[1]; - sp[41] = ((u_int16_t *) sc->tulip_ac.ac_enaddr)[2]; - } else { - /* - * Else can get perfect filtering for 16 addresses. - */ - ETHER_FIRST_MULTI(step, &sc->tulip_ac, enm); - for (; enm != NULL; i++) { - *sp++ = ((u_int16_t *) enm->enm_addrlo)[0]; - *sp++ = ((u_int16_t *) enm->enm_addrlo)[1]; - *sp++ = ((u_int16_t *) enm->enm_addrlo)[2]; - ETHER_NEXT_MULTI(step, enm); - } - /* - * Add the broadcast address. - */ - i++; - *sp++ = 0xFFFF; - *sp++ = 0xFFFF; - *sp++ = 0xFFFF; - /* - * Pad the rest with our hardware address - */ - for (; i < 16; i++) { + for (ifma = sc->tulip_if.if_multiaddrs.lh_first; ifma; + ifma = ifma->ifma_link.le_next) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; + if (i > 14) + goto musthash; + addrp = LLADDR((struct sockaddr_dl *)ifma->ifma_addr); + *sp++ = ((u_int16_t *) addrp)[0]; + *sp++ = ((u_int16_t *) addrp)[1]; + *sp++ = ((u_int16_t *) addrp)[2]; + i++; + } + /* + * Add the broadcast address. + */ + i++; + *sp++ = 0xFFFF; + *sp++ = 0xFFFF; + *sp++ = 0xFFFF; + /* + * Pad the rest with our hardware address + */ + for (; i < 16; i++) { *sp++ = ((u_int16_t *) sc->tulip_ac.ac_enaddr)[0]; *sp++ = ((u_int16_t *) sc->tulip_ac.ac_enaddr)[1]; *sp++ = ((u_int16_t *) sc->tulip_ac.ac_enaddr)[2]; - } } + return; + +musthash: + bzero(sc->tulip_setupdata, sizeof(sc->tulip_setupdata)); + hash = tulip_mchash(etherbroadcastaddr); + sp[hash >> 4] |= 1 << (hash & 0xF); + for (ifma = sc->tulip_if.if_multiaddrs.lh_first; ifma; + ifma = ifma->ifma_link.le_next) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; + + hash = tulip_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); + sp[hash >> 4] |= 1 << (hash & 0xF); + } + sc->tulip_flags |= TULIP_WANTHASH; + sp[39] = ((u_int16_t *) sc->tulip_ac.ac_enaddr)[0]; + sp[40] = ((u_int16_t *) sc->tulip_ac.ac_enaddr)[1]; + sp[41] = ((u_int16_t *) sc->tulip_ac.ac_enaddr)[2]; } /* @@ -3395,22 +3396,15 @@ tulip_ifioctl( } case SIOCADDMULTI: - case SIOCDELMULTI: { + case SIOCDELMULTI: /* * Update multicast listeners */ - if (cmd == SIOCADDMULTI) - error = ether_addmulti(ifr, &sc->tulip_ac); - else - error = ether_delmulti(ifr, &sc->tulip_ac); - - if (error == ENETRESET) { - tulip_addr_filter(sc); /* reset multicast filtering */ - tulip_init(sc); - error = 0; - } + tulip_addr_filter(sc); /* reset multicast filtering */ + tulip_init(sc); + error = 0; break; - } + #if defined(SIOCSIFMTU) #if !defined(ifr_mtu) #define ifr_mtu ifr_metric diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c index 95a4859..e0b59b4 100644 --- a/sys/dev/ed/if_ed.c +++ b/sys/dev/ed/if_ed.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_ed.c,v 1.110 1996/12/10 07:29:39 davidg Exp $ + * $Id: if_ed.c,v 1.111 1996/12/13 21:28:19 wollman Exp $ */ /* @@ -2673,21 +2673,11 @@ ed_ioctl(ifp, command, data) case SIOCADDMULTI: case SIOCDELMULTI: /* - * Update out multicast list. + * Multicast list has changed; set the hardware filter + * accordingly. */ - error = (command == SIOCADDMULTI) ? - ether_addmulti(ifr, &sc->arpcom) : - ether_delmulti(ifr, &sc->arpcom); - - if (error == ENETRESET) { - - /* - * Multicast list has changed; set the hardware filter - * accordingly. - */ - ed_setrcr(sc); - error = 0; - } + ed_setrcr(sc); + error = 0; break; default: @@ -3420,22 +3410,17 @@ ds_getmcaf(sc, mcaf) { register u_int index; register u_char *af = (u_char *) mcaf; - register struct ether_multi *enm; - register struct ether_multistep step; + struct ifmultiaddr *ifma; mcaf[0] = 0; mcaf[1] = 0; - ETHER_FIRST_MULTI(step, &sc->arpcom, enm); - while (enm != NULL) { - if (bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) != 0) { - mcaf[0] = 0xffffffff; - mcaf[1] = 0xffffffff; - return; - } - index = ds_crc(enm->enm_addrlo) >> 26; + for (ifma = sc->arpcom.ac_if.if_multiaddrs.lh_first; ifma; + ifma = ifma->ifma_link.le_next) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; + index = ds_crc(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)) + >> 26; af[index >> 3] |= 1 << (index & 7); - - ETHER_NEXT_MULTI(step, enm); } } diff --git a/sys/dev/fe/if_fe.c b/sys/dev/fe/if_fe.c index 9c2cf8e..c714734 100644 --- a/sys/dev/fe/if_fe.c +++ b/sys/dev/fe/if_fe.c @@ -21,7 +21,7 @@ */ /* - * $Id: if_fe.c,v 1.21 1996/11/15 16:15:56 wollman Exp $ + * $Id: if_fe.c,v 1.22 1996/12/13 21:28:22 wollman Exp $ * * Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards. * To be used with FreeBSD 2.x @@ -2623,27 +2623,13 @@ fe_ioctl ( struct ifnet * ifp, int command, caddr_t data ) #ifdef SIOCADDMULTI case SIOCADDMULTI: case SIOCDELMULTI: - { - /* - * Update out multicast list. - */ - struct ifreq * ifr = ( struct ifreq * )data; - - error = ( command == SIOCADDMULTI ) - ? ether_addmulti( ifr, &sc->arpcom ) - : ether_delmulti( ifr, &sc->arpcom ); - - if ( error == ENETRESET ) { - /* - * Multicast list has changed; set the hardware filter - * accordingly. - */ - fe_setmode( sc ); - error = 0; - } - - break; - } + /* + * Multicast list has changed; set the hardware filter + * accordingly. + */ + fe_setmode( sc ); + error = 0; + break; #endif #ifdef SIOCSIFMTU @@ -2955,23 +2941,20 @@ fe_mcaf ( struct fe_softc *sc ) { int index; struct fe_filter filter; - struct ether_multi *enm; - struct ether_multistep step; + struct ifmultiaddr *ifma; filter = fe_filter_nothing; - ETHER_FIRST_MULTI(step, &sc->arpcom, enm); - while ( enm != NULL) { - if ( bcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN) ) { - return ( fe_filter_all ); - } - index = fe_hash( enm->enm_addrlo ); + for (ifma = sc->arpcom.ac_if.if_multiaddrs.lh_first; ifma; + ifma = ifma->ifma_link.le_next) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; + index = fe_hash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); #if FE_DEBUG >= 4 log( LOG_INFO, "fe%d: hash(%6D) == %d\n", sc->sc_unit, enm->enm_addrlo , ":", index ); #endif filter.data[index >> 3] |= 1 << (index & 7); - ETHER_NEXT_MULTI(step, enm); } return ( filter ); } diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c index 61cb065..eed4623 100644 --- a/sys/dev/fxp/if_fxp.c +++ b/sys/dev/fxp/if_fxp.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_fxp.c,v 1.22 1996/11/18 02:45:46 davidg Exp $ + * $Id: if_fxp.c,v 1.23 1996/12/10 07:29:50 davidg Exp $ */ /* @@ -1055,21 +1055,11 @@ fxp_ioctl(ifp, command, data) case SIOCADDMULTI: case SIOCDELMULTI: /* - * Update out multicast list. + * Multicast list has changed; set the hardware filter + * accordingly. */ - error = (command == SIOCADDMULTI) ? - ether_addmulti(ifr, &sc->arpcom) : - ether_delmulti(ifr, &sc->arpcom); - - if (error == ENETRESET) { - /* - * Multicast list has changed; set the hardware filter - * accordingly. - */ - fxp_init(sc); - - error = 0; - } + fxp_init(sc); + error = 0; break; default: diff --git a/sys/dev/ie/if_ie.c b/sys/dev/ie/if_ie.c index 4c8cf8d..6795bf1 100644 --- a/sys/dev/ie/if_ie.c +++ b/sys/dev/ie/if_ie.c @@ -43,7 +43,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_ie.c,v 1.35 1996/06/25 20:30:13 bde Exp $ + * $Id: if_ie.c,v 1.36 1996/09/06 23:07:36 phk Exp $ */ /* @@ -1932,15 +1932,9 @@ ieioctl(ifp, command, data) /* * Update multicast listeners */ - error = ((command == SIOCADDMULTI) - ? ether_addmulti(ifr, &ie->arpcom) - : ether_delmulti(ifr, &ie->arpcom)); - - if(error == ENETRESET) { - /* reset multicast filtering */ - ie_mc_reset(ifp->if_unit); - error = 0; - } + /* reset multicast filtering */ + ie_mc_reset(ifp->if_unit); + error = 0; break; case SIOCSIFMTU: @@ -1964,25 +1958,27 @@ ieioctl(ifp, command, data) static void ie_mc_reset(int unit) { struct ie_softc *ie = &ie_softc[unit]; - struct ether_multi *enm; - struct ether_multistep step; + struct ifmultiaddr *ifma; /* * Step through the list of addresses. */ ie->mcast_count = 0; - ETHER_FIRST_MULTI(step, &ie->arpcom, enm); - while(enm) { - if(ie->mcast_count >= MAXMCAST - || bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) != 0) { - ie->arpcom.ac_if.if_flags |= IFF_ALLMULTI; - ieioctl(&ie->arpcom.ac_if, SIOCSIFFLAGS, (void *)0); - goto setflag; - } - - bcopy(enm->enm_addrlo, &(ie->mcast_addrs[ie->mcast_count]), 6); - ie->mcast_count++; - ETHER_NEXT_MULTI(step, enm); + for (ifma = ie->arpcom.ac_if.if_multiaddrs.lh_first; ifma; + ifma = ifma->ifma_link.le_next) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; + + /* XXX - this is broken... */ + if(ie->mcast_count >= MAXMCAST) { + ie->arpcom.ac_if.if_flags |= IFF_ALLMULTI; + ieioctl(&ie->arpcom.ac_if, SIOCSIFFLAGS, (void *)0); + goto setflag; + } + + bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr), + &(ie->mcast_addrs[ie->mcast_count]), 6); + ie->mcast_count++; } setflag: diff --git a/sys/dev/lnc/if_lnc.c b/sys/dev/lnc/if_lnc.c index 0df6bbe..51d77b1 100644 --- a/sys/dev/lnc/if_lnc.c +++ b/sys/dev/lnc/if_lnc.c @@ -226,8 +226,7 @@ static void lnc_setladrf(struct lnc_softc *sc) { struct ifnet *ifp = &sc->arpcom.ac_if; - struct ether_multistep step; - struct ether_multi *enm; + struct ifmultiaddr *ifma; u_long index; int i; @@ -247,24 +246,12 @@ lnc_setladrf(struct lnc_softc *sc) */ bzero(sc->init_block->ladrf, MULTICAST_FILTER_LEN); - ETHER_FIRST_MULTI(step, &sc->arpcom, enm); - while (enm != NULL) { - if (bcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN) != 0) { - /* - * A range of multicast addresses should be accepted but - * but for now just accept all multicasts. Only currently - * used by multicast routing where the range would require - * all bits to be set anyway. - */ - ifp->if_flags |= IFF_ALLMULTI; - for (i = 0; i < MULTICAST_FILTER_LEN; i++) - sc->init_block->ladrf[i] = 0xff; - return; - } - + for (ifma = ifp->if_multiaddrs.lh_first; ifma; + ifma = ifma->ifma_link.le_next) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; index = ether_crc(enm->enm_addrlo) >> 26; sc->init_block->ladrf[index >> 3] |= 1 << (index & 7); - ETHER_NEXT_MULTI(step, enm); } } #endif /* LNC_MULTICAST */ @@ -1735,14 +1722,8 @@ lnc_ioctl(struct ifnet * ifp, int command, caddr_t data) #ifdef LNC_MULTICAST case SIOCADDMULTI: case SIOCDELMULTI: - error = (command == SIOCADDMULTI) ? - ether_addmulti(ifr, &sc->arpcom) : - ether_delmulti(ifr, &sc->arpcom); - - if (error == ENETRESET) { - lnc_setladrf(sc); - error = 0; - } + lnc_setladrf(sc); + error = 0; break; #endif case SIOCSIFMTU: diff --git a/sys/dev/vx/if_vx.c b/sys/dev/vx/if_vx.c index 6125ff8..a4a29cd 100644 --- a/sys/dev/vx/if_vx.c +++ b/sys/dev/vx/if_vx.c @@ -311,11 +311,11 @@ vxsetfilter(sc) struct vx_softc *sc; { register struct ifnet *ifp = &sc->arpcom.ac_if; - + GO_WINDOW(1); /* Window 1 is operating window */ outw(BASE + VX_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL | FIL_BRDCST | - ((sc->arpcom.ac_multicnt > 0) ? FIL_MULTICAST : 0 ) | - ((ifp->if_flags & IFF_PROMISC) ? FIL_PROMISC : 0 )); + FIL_MULTICAST | + ((ifp->if_flags & IFF_PROMISC) ? FIL_PROMISC : 0 )); } static void @@ -967,18 +967,12 @@ vxioctl(ifp, cmd, data) case SIOCADDMULTI: case SIOCDELMULTI: - error = ((u_int) cmd == SIOCADDMULTI) ? - ether_addmulti(ifr, &sc->arpcom) : - ether_delmulti(ifr, &sc->arpcom); - - if (error == ENETRESET) { - /* - * Multicast list has changed; set the hardware filter - * accordingly. - */ - vxreset(sc); - error = 0; - } + /* + * Multicast list has changed; set the hardware filter + * accordingly. + */ + vxreset(sc); + error = 0; break; |