Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Fix to check whether the address has been added befo...
details: https://anonhg.NetBSD.org/src/rev/72cb4ca4034d
branches: trunk
changeset: 319860:72cb4ca4034d
user: yamaguchi <yamaguchi%NetBSD.org@localhost>
date: Thu Jun 14 08:33:18 2018 +0000
description:
Fix to check whether the address has been added before delete
The list named ifv_mc_listhead saves multicast addresses that
are added through SIOCADDMULTI. Each nodes added to the list
are used for deleting the related address from a parent I/F
when remove the configuration of parent I/F.
In carp(4) and OpenBSD's vlan(4), the lists is used to check
a parameter of SIOCDELMULTI in addition to the use.
Based on them, the check is added to vlan(4)
ok ozaki-r@
diffstat:
sys/net/if_vlan.c | 31 ++++++++++++++++++-------------
1 files changed, 18 insertions(+), 13 deletions(-)
diffs (67 lines):
diff -r 1806cc60901c -r 72cb4ca4034d sys/net/if_vlan.c
--- a/sys/net/if_vlan.c Thu Jun 14 08:27:10 2018 +0000
+++ b/sys/net/if_vlan.c Thu Jun 14 08:33:18 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vlan.c,v 1.128 2018/06/14 08:06:07 yamaguchi Exp $ */
+/* $NetBSD: if_vlan.c,v 1.129 2018/06/14 08:33:18 yamaguchi Exp $ */
/*
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.128 2018/06/14 08:06:07 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.129 2018/06/14 08:33:18 yamaguchi Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1229,6 +1229,17 @@
ETHER_LOCK(&ifv->ifv_ec);
enm = ether_lookup_multi(addrlo, addrhi, &ifv->ifv_ec);
ETHER_UNLOCK(&ifv->ifv_ec);
+ if (enm == NULL)
+ return EINVAL;
+
+ LIST_FOREACH(mc, &ifv->ifv_mc_listhead, mc_entries) {
+ if (mc->mc_enm == enm)
+ break;
+ }
+
+ /* We woun't delete entries we didn't add */
+ if (mc == NULL)
+ return EINVAL;
error = ether_delmulti(sa, &ifv->ifv_ec);
if (error != ENETRESET)
@@ -1242,17 +1253,11 @@
if (error == 0) {
/* And forget about this address. */
- for (mc = LIST_FIRST(&ifv->ifv_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);
- } else
+ LIST_REMOVE(mc, mc_entries);
+ free(mc, M_DEVBUF);
+ } else {
(void)ether_addmulti(sa, &ifv->ifv_ec);
+ }
return error;
}
@@ -1276,7 +1281,7 @@
while ((mc = LIST_FIRST(&ifv->ifv_mc_listhead)) != NULL) {
IFNET_LOCK(mib->ifvm_p);
(void)if_mcast_op(mib->ifvm_p, SIOCDELMULTI,
- (const struct sockaddr *)&mc->mc_addr);
+ sstocsa(&mc->mc_addr));
IFNET_UNLOCK(mib->ifvm_p);
LIST_REMOVE(mc, mc_entries);
free(mc, M_DEVBUF);
Home |
Main Index |
Thread Index |
Old Index