Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Make sure to not change if_hwdl once set
details: https://anonhg.NetBSD.org/src/rev/2d01519f6e63
branches: trunk
changeset: 319496:2d01519f6e63
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Fri Jun 01 07:14:13 2018 +0000
description:
Make sure to not change if_hwdl once set
diffstat:
sys/net/if.c | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
diffs (83 lines):
diff -r cb40fa46b98d -r 2d01519f6e63 sys/net/if.c
--- a/sys/net/if.c Fri Jun 01 07:13:35 2018 +0000
+++ b/sys/net/if.c Fri Jun 01 07:14:13 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.425 2018/05/31 02:10:23 ozaki-r Exp $ */
+/* $NetBSD: if.c,v 1.426 2018/06/01 07:14:13 ozaki-r Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.425 2018/05/31 02:10:23 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.426 2018/06/01 07:14:13 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -202,7 +202,7 @@
static void sysctl_sndq_setup(struct sysctllog **, const char *,
struct ifaltq *);
static void if_slowtimo(void *);
-static void if_free_sadl(struct ifnet *);
+static void if_free_sadl(struct ifnet *, int);
static void if_attachdomain1(struct ifnet *);
static int ifconf(u_long, void *);
static int if_transmit(struct ifnet *, struct mbuf *);
@@ -425,6 +425,7 @@
(void)sockaddr_dl_setaddr(sdl, sdl->sdl_len, lla, ifp->if_addrlen);
if (factory) {
+ KASSERT(ifp->if_hwdl == NULL);
ifp->if_hwdl = ifp->if_dl;
ifaref(ifp->if_hwdl);
}
@@ -492,7 +493,7 @@
* link types, and thus switch link names often.
*/
if (ifp->if_sadl != NULL)
- if_free_sadl(ifp);
+ if_free_sadl(ifp, 0);
ifa = if_dl_create(ifp, &sdl);
@@ -568,11 +569,17 @@
* a detach helper. This is called from if_detach().
*/
static void
-if_free_sadl(struct ifnet *ifp)
+if_free_sadl(struct ifnet *ifp, int factory)
{
struct ifaddr *ifa;
int s;
+ if (factory && ifp->if_hwdl != NULL) {
+ ifa = ifp->if_hwdl;
+ ifp->if_hwdl = NULL;
+ ifafree(ifa);
+ }
+
ifa = ifp->if_dl;
if (ifa == NULL) {
KASSERT(ifp->if_sadl == NULL);
@@ -585,10 +592,6 @@
rtinit(ifa, RTM_DELETE, 0);
ifa_remove(ifp, ifa);
if_deactivate_sadl(ifp);
- if (ifp->if_hwdl == ifa) {
- ifafree(ifa);
- ifp->if_hwdl = NULL;
- }
splx(s);
}
@@ -1400,7 +1403,7 @@
goto again;
}
- if_free_sadl(ifp);
+ if_free_sadl(ifp, 1);
/* Delete stray routes from the routing table. */
for (i = 0; i <= AF_MAX; i++)
Home |
Main Index |
Thread Index |
Old Index