Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net fix panic when do ifconfig -vlanif and ifconfig vlan...



details:   https://anonhg.NetBSD.org/src/rev/d1f825eef56c
branches:  trunk
changeset: 445220:d1f825eef56c
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Thu Oct 18 11:34:54 2018 +0000

description:
fix panic when do ifconfig -vlanif and ifconfig vlanif again. advised by ozaki-r@.

e.g. do the following commands.
    ====================
    # ifconfig vlan0 create
    # ifconfig vlan0 vlan 100 vlanif wm0
    # ifconfig vlan0 -vlanif wm0
    # ifconfig vlan0 vlan 100 vlanif wm0
    ====================

ATF net/if_vlan do this type of test, however it cannot detect this bug.
Because the shmif(4)'s ifp->if_hwdl is always NULL as shmif(4)'s ethernet
address is set U/L bit.
See: https://nxr.netbsd.org/xref/src/sys/net/if_ethersubr.c#997

diffstat:

 sys/net/if.c      |  7 +++----
 sys/net/if.h      |  3 ++-
 sys/net/if_vlan.c |  7 +++++--
 3 files changed, 10 insertions(+), 7 deletions(-)

diffs (80 lines):

diff -r e7e2e174652b -r d1f825eef56c sys/net/if.c
--- a/sys/net/if.c      Thu Oct 18 09:01:51 2018 +0000
+++ b/sys/net/if.c      Thu Oct 18 11:34:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.436 2018/09/07 13:24:14 christos Exp $        */
+/*     $NetBSD: if.c,v 1.437 2018/10/18 11:34:54 knakahara 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.436 2018/09/07 13:24:14 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.437 2018/10/18 11:34:54 knakahara Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -201,7 +201,6 @@
 static void sysctl_sndq_setup(struct sysctllog **, const char *,
     struct ifaltq *);
 static void if_slowtimo(void *);
-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 *);
@@ -573,7 +572,7 @@
  * Free the link level name for the specified interface.  This is
  * a detach helper.  This is called from if_detach().
  */
-static void
+void
 if_free_sadl(struct ifnet *ifp, int factory)
 {
        struct ifaddr *ifa;
diff -r e7e2e174652b -r d1f825eef56c sys/net/if.h
--- a/sys/net/if.h      Thu Oct 18 09:01:51 2018 +0000
+++ b/sys/net/if.h      Thu Oct 18 11:34:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.h,v 1.265 2018/08/22 01:05:24 msaitoh Exp $ */
+/*     $NetBSD: if.h,v 1.266 2018/10/18 11:34:54 knakahara Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -1075,6 +1075,7 @@
     const struct sockaddr_dl *);
 void   if_set_sadl(struct ifnet *, const void *, u_char, bool);
 void   if_alloc_sadl(struct ifnet *);
+void   if_free_sadl(struct ifnet *, int);
 int    if_initialize(struct ifnet *);
 void   if_register(struct ifnet *);
 int    if_attach(struct ifnet *); /* Deprecated. Use if_initialize and if_register */
diff -r e7e2e174652b -r d1f825eef56c sys/net/if_vlan.c
--- a/sys/net/if_vlan.c Thu Oct 18 09:01:51 2018 +0000
+++ b/sys/net/if_vlan.c Thu Oct 18 11:34:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_vlan.c,v 1.131 2018/08/03 11:24:19 jmcneill Exp $   */
+/*     $NetBSD: if_vlan.c,v 1.132 2018/10/18 11:34:54 knakahara 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.131 2018/08/03 11:24:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.132 2018/10/18 11:34:54 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -634,6 +634,9 @@
                IFNET_LOCK(ifp);
                mutex_enter(&ifv->ifv_lock);
 
+               /* if_free_sadl must be called with IFNET_LOCK */
+               if_free_sadl(ifp, 1);
+
                /* Restore vlan_ioctl overwritten by ether_ifdetach */
                ifp->if_ioctl = vlan_ioctl;
                vlan_reset_linkname(ifp);



Home | Main Index | Thread Index | Old Index