Add locking.

This commit is contained in:
christos 2018-01-25 03:54:57 +00:00
parent 26ca7efe45
commit 4ad47752f1
2 changed files with 13 additions and 7 deletions

View File

@ -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 <sys/cdefs.h>
__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);

View File

@ -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 <sys/cdefs.h>
__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);
}
}