diff options
-rw-r--r-- | sys/net/if_trunk.c | 21 | ||||
-rw-r--r-- | sys/net/if_vlan.c | 23 |
2 files changed, 26 insertions, 18 deletions
diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c index 79b9b6c568c..5e84069799c 100644 --- a/sys/net/if_trunk.c +++ b/sys/net/if_trunk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_trunk.c,v 1.9 2005/10/09 18:45:27 reyk Exp $ */ +/* $OpenBSD: if_trunk.c,v 1.10 2005/10/23 14:07:11 mpf Exp $ */ /* * Copyright (c) 2005 Reyk Floeter <reyk@vantronix.net> @@ -757,6 +757,16 @@ trunk_ether_delmulti(struct trunk_softc *tr, struct ifreq *ifr) if ((error = ether_multiaddr(&ifr->ifr_addr, addrlo, addrhi)) != 0) return (error); ETHER_LOOKUP_MULTI(addrlo, addrhi, &tr->tr_ac, enm); + if (enm == NULL) + return (EINVAL); + + SLIST_FOREACH(mc, &tr->tr_mc_head, mc_entries) + if (mc->mc_enm == enm) + break; + + /* We won't delete entries we didn't add */ + if (mc == NULL) + return (EINVAL); if ((error = ether_delmulti(ifr, &tr->tr_ac)) != ENETRESET) return (error); @@ -770,13 +780,8 @@ trunk_ether_delmulti(struct trunk_softc *tr, struct ifreq *ifr) } } - SLIST_FOREACH(mc, &tr->tr_mc_head, mc_entries) { - if (mc->mc_enm == enm) { - SLIST_REMOVE(&tr->tr_mc_head, mc, trunk_mc, mc_entries); - free(mc, M_DEVBUF); - break; - } - } + SLIST_REMOVE(&tr->tr_mc_head, mc, trunk_mc, mc_entries); + free(mc, M_DEVBUF); return (0); } diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 579128b1456..e164aee9599 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan.c,v 1.59 2005/07/31 03:52:18 pascoe Exp $ */ +/* $OpenBSD: if_vlan.c,v 1.60 2005/10/23 14:07:11 mpf Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology @@ -677,6 +677,16 @@ vlan_ether_delmulti(struct ifvlan *ifv, struct ifreq *ifr) if ((error = ether_multiaddr(&ifr->ifr_addr, addrlo, addrhi)) != 0) return (error); ETHER_LOOKUP_MULTI(addrlo, addrhi, &ifv->ifv_ac, enm); + if (enm == NULL) + return (EINVAL); + + LIST_FOREACH(mc, &ifv->vlan_mc_listhead, mc_entries) + if (mc->mc_enm == enm) + break; + + /* We won't delete entries we didn't add */ + if (mc == NULL) + return (EINVAL); error = ether_delmulti(ifr, (struct arpcom *)&ifv->ifv_ac); if (error != ENETRESET) @@ -686,15 +696,8 @@ vlan_ether_delmulti(struct ifvlan *ifv, struct ifreq *ifr) error = (*ifp->if_ioctl)(ifp, SIOCDELMULTI, (caddr_t)ifr); if (error == 0) { /* And forget about this address. */ - for (mc = LIST_FIRST(&ifv->vlan_mc_listhead); mc != NULL; - mc = LIST_NEXT(mc, mc_entries)) { - if (mc->mc_enm == enm) { - LIST_REMOVE(mc, mc_entries); - FREE(mc, M_DEVBUF); - break; - } - } - KASSERT(mc != NULL); + LIST_REMOVE(mc, mc_entries); + FREE(mc, M_DEVBUF); } else (void)ether_addmulti(ifr, (struct arpcom *)&ifv->ifv_ac); return (error); |