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/i386 | |
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/i386')
-rw-r--r-- | sys/i386/isa/if_ed.c | 39 | ||||
-rw-r--r-- | sys/i386/isa/if_fe.c | 45 | ||||
-rw-r--r-- | sys/i386/isa/if_ie.c | 44 | ||||
-rw-r--r-- | sys/i386/isa/if_le.c | 45 | ||||
-rw-r--r-- | sys/i386/isa/if_lnc.c | 33 |
5 files changed, 66 insertions, 140 deletions
diff --git a/sys/i386/isa/if_ed.c b/sys/i386/isa/if_ed.c index 95a4859..e0b59b4 100644 --- a/sys/i386/isa/if_ed.c +++ b/sys/i386/isa/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/i386/isa/if_fe.c b/sys/i386/isa/if_fe.c index 9c2cf8e..c714734 100644 --- a/sys/i386/isa/if_fe.c +++ b/sys/i386/isa/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/i386/isa/if_ie.c b/sys/i386/isa/if_ie.c index 4c8cf8d..6795bf1 100644 --- a/sys/i386/isa/if_ie.c +++ b/sys/i386/isa/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/i386/isa/if_le.c b/sys/i386/isa/if_le.c index ccad397..91946d1 100644 --- a/sys/i386/isa/if_le.c +++ b/sys/i386/isa/if_le.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_le.c,v 1.33 1996/06/18 01:22:23 bde Exp $ + * $Id: if_le.c,v 1.34 1996/09/06 23:07:40 phk Exp $ */ /* @@ -590,22 +590,13 @@ le_ioctl( } case SIOCADDMULTI: - case SIOCDELMULTI: { + case SIOCDELMULTI: /* * Update multicast listeners */ - if (cmd == SIOCADDMULTI) - error = ether_addmulti((struct ifreq *)data, &sc->le_ac); - else - error = ether_delmulti((struct ifreq *)data, &sc->le_ac); - - if (error == ENETRESET) { - /* reset multicast filtering */ (*sc->if_init)(ifp->if_unit); error = 0; - } - break; - } + break; default: { error = EINVAL; @@ -682,11 +673,7 @@ static void le_multi_filter( le_softc_t *sc) { - struct ether_multistep step; - struct ether_multi *enm; -#ifdef ISO - extern char all_es_snpa[]; -#endif + struct ifmultiaddr *ifma; MEMSET(sc->le_mctbl, 0, (sc->le_mcmask + 1) / 8); @@ -699,23 +686,17 @@ le_multi_filter( le_multi_op(sc, etherbroadcastaddr, TRUE); sc->le_flags |= LE_BRDCSTONLY|IFF_MULTICAST; /* } */ -#ifdef ISO - le_multi_op(sc, all_es_snpa, TRUE); -#endif - ETHER_FIRST_MULTI(step, &sc->le_ac, enm); - if (enm != NULL) - sc->le_flags |= IFF_MULTICAST; - while (enm != NULL) { - if (MEMCMP(enm->enm_addrlo, enm->enm_addrhi, 6) != 0) { - sc->le_flags |= IFF_ALLMULTI; - return; - } - le_multi_op(sc, enm->enm_addrlo, TRUE); - ETHER_NEXT_MULTI(step, enm); - sc->le_flags &= ~LE_BRDCSTONLY; + sc->le_flags |= IFF_MULTICAST; + + for (ifma = sc->le_ac.ac_if.if_multiaddrs.lh_first; ifma; + ifma = ifma->ifma_link.le_next) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; + + le_multi_op(sc, LLADDR((struct sockaddr_dl *)ifma->ifma_addr), 1); + sc->le_flags &= ~LE_BRDCSTONLY; } - sc->le_flags &= ~IFF_ALLMULTI; } static void diff --git a/sys/i386/isa/if_lnc.c b/sys/i386/isa/if_lnc.c index 0df6bbe..51d77b1 100644 --- a/sys/i386/isa/if_lnc.c +++ b/sys/i386/isa/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: |