From 4ad47752f1f89654993efc45e59c6f4ea8dcbb07 Mon Sep 17 00:00:00 2001 From: christos Date: Thu, 25 Jan 2018 03:54:57 +0000 Subject: [PATCH] Add locking. --- sys/net/agr/if_agr.c | 6 ++++-- sys/net/agr/if_agrsubr.c | 14 +++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/sys/net/agr/if_agr.c b/sys/net/agr/if_agr.c index ba51db58f529..92ea1fa73d87 100644 --- a/sys/net/agr/if_agr.c +++ b/sys/net/agr/if_agr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_agr.c,v 1.45 2018/01/16 07:34:12 knakahara Exp $ */ +/* $NetBSD: if_agr.c,v 1.46 2018/01/25 03:54:57 christos Exp $ */ /*- * Copyright (c)2005 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.45 2018/01/16 07:34:12 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.46 2018/01/25 03:54:57 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -611,7 +611,9 @@ agr_addport(struct ifnet *ifp, struct ifnet *ifp_port) * of each port to that of the first port. No need for arps * since there are no inet addresses assigned to the ports. */ + IFNET_LOCK(ifp_port); error = if_addr_init(ifp_port, ifp->if_dl, true); + IFNET_UNLOCK(ifp_port); if (error) { printf("%s: if_addr_init error %d\n", __func__, error); diff --git a/sys/net/agr/if_agrsubr.c b/sys/net/agr/if_agrsubr.c index e4e63a33daec..b50f7fb21fe7 100644 --- a/sys/net/agr/if_agrsubr.c +++ b/sys/net/agr/if_agrsubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_agrsubr.c,v 1.11 2017/12/06 04:37:00 ozaki-r Exp $ */ +/* $NetBSD: if_agrsubr.c,v 1.12 2018/01/25 03:54:57 christos Exp $ */ /*- * Copyright (c)2005 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_agrsubr.c,v 1.11 2017/12/06 04:37:00 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_agrsubr.c,v 1.12 2018/01/25 03:54:57 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -294,7 +294,9 @@ agr_vlan_add(struct agr_port *port, void *arg) */ ec_port->ec_capenable |= ETHERCAP_VLAN_MTU; if (p->if_flags & IFF_UP) { + IFNET_LOCK(p); error = if_flags_set(p, p->if_flags); + IFNET_UNLOCK(p); if (error) { if (ec_port->ec_nvlans-- == 1) ec_port->ec_capenable &= @@ -321,15 +323,17 @@ agr_vlan_del(struct agr_port *port, void *arg) /* Disable vlan support */ if ((*force_zero && ec_port->ec_nvlans > 0) || ec_port->ec_nvlans-- == 1) { + struct ifnet *p = port->port_ifp; if (*force_zero) ec_port->ec_nvlans = 0; /* * Disable Tx/Rx of VLAN-sized frames. */ ec_port->ec_capenable &= ~ETHERCAP_VLAN_MTU; - if (port->port_ifp->if_flags & IFF_UP) { - (void)if_flags_set(port->port_ifp, - port->port_ifp->if_flags); + if (p->if_flags & IFF_UP) { + IFNET_LOCK(p); + (void)if_flags_set(p, p->if_flags); + IFNET_UNLOCK(p); } }