Module Name: src Committed By: martin Date: Mon Aug 19 16:10:35 UTC 2019
Modified Files: src/sys/net [netbsd-9]: if.c src/tests/net/if [netbsd-9]: t_ifconfig.sh Log Message: Pull up following revision(s) (requested by ozaki-r in ticket #98): sys/net/if.c: revision 1.458 tests/net/if/t_ifconfig.sh: revision 1.21 Restore if_ioctl on error of ifc_destroy Otherwise subsequence ioctls won't work. Patch from Harold Gutch on PR kern/54434 (tweaked a bit by me) tests: check if ifconfig (ioctl) works after a failure of ifconfig destroy This is a test for PR kern/54434. To generate a diff of this commit: cvs rdiff -u -r1.457 -r1.457.2.1 src/sys/net/if.c cvs rdiff -u -r1.20 -r1.20.2.1 src/tests/net/if/t_ifconfig.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/if.c diff -u src/sys/net/if.c:1.457 src/sys/net/if.c:1.457.2.1 --- src/sys/net/if.c:1.457 Thu Jul 25 07:45:57 2019 +++ src/sys/net/if.c Mon Aug 19 16:10:35 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.457 2019/07/25 07:45:57 knakahara Exp $ */ +/* $NetBSD: if.c,v 1.457.2.1 2019/08/19 16:10:35 martin 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.457 2019/07/25 07:45:57 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.457.2.1 2019/08/19 16:10:35 martin Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1611,6 +1611,8 @@ if_clone_destroy(const char *name) struct if_clone *ifc; struct ifnet *ifp; struct psref psref; + int error; + int (*if_ioctl)(struct ifnet *, u_long, void *); KASSERT(mutex_owned(&if_clone_mtx)); @@ -1627,6 +1629,7 @@ if_clone_destroy(const char *name) /* We have to disable ioctls here */ IFNET_LOCK(ifp); + if_ioctl = ifp->if_ioctl; ifp->if_ioctl = if_nullioctl; IFNET_UNLOCK(ifp); @@ -1636,7 +1639,16 @@ if_clone_destroy(const char *name) */ if_put(ifp, &psref); - return (*ifc->ifc_destroy)(ifp); + error = (*ifc->ifc_destroy)(ifp); + + if (error != 0) { + /* We have to restore if_ioctl on error */ + IFNET_LOCK(ifp); + ifp->if_ioctl = if_ioctl; + IFNET_UNLOCK(ifp); + } + + return error; } static bool Index: src/tests/net/if/t_ifconfig.sh diff -u src/tests/net/if/t_ifconfig.sh:1.20 src/tests/net/if/t_ifconfig.sh:1.20.2.1 --- src/tests/net/if/t_ifconfig.sh:1.20 Thu Jul 4 02:46:40 2019 +++ src/tests/net/if/t_ifconfig.sh Mon Aug 19 16:10:35 2019 @@ -1,4 +1,4 @@ -# $NetBSD: t_ifconfig.sh,v 1.20 2019/07/04 02:46:40 ozaki-r Exp $ +# $NetBSD: t_ifconfig.sh,v 1.20.2.1 2019/08/19 16:10:35 martin Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -69,6 +69,11 @@ ifconfig_create_destroy_body() atf_check -s exit:0 rump.ifconfig shmif0 up atf_check -s exit:0 rump.ifconfig shmif0 destroy + # Check if ifconfig (ioctl) works after a failure of ifconfig destroy + atf_check -s exit:0 -o ignore rump.ifconfig lo0 + atf_check -s not-exit:0 -e ignore rump.ifconfig lo0 destroy + atf_check -s exit:0 -o ignore rump.ifconfig lo0 + unset RUMP_SERVER }