Module Name: src Committed By: ozaki-r Date: Thu Dec 7 03:16:25 UTC 2017
Modified Files: src/sys/net: if.c if_spppsubr.c src/sys/rump/net/lib/libnetinet: netinet_component.c Log Message: Ensure to call if_addr_init with holding if_ioctl_lock To generate a diff of this commit: cvs rdiff -u -r1.407 -r1.408 src/sys/net/if.c cvs rdiff -u -r1.175 -r1.176 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.8 -r1.9 src/sys/rump/net/lib/libnetinet/netinet_component.c 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.407 src/sys/net/if.c:1.408 --- src/sys/net/if.c:1.407 Thu Dec 7 01:23:53 2017 +++ src/sys/net/if.c Thu Dec 7 03:16:24 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.407 2017/12/07 01:23:53 ozaki-r Exp $ */ +/* $NetBSD: if.c,v 1.408 2017/12/07 03:16:24 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.407 2017/12/07 01:23:53 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.408 2017/12/07 03:16:24 ozaki-r Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -3517,6 +3517,7 @@ if_addr_init(ifnet_t *ifp, struct ifaddr { int rc; + KASSERT(mutex_owned(ifp->if_ioctl_lock)); if (ifp->if_initaddr != NULL) rc = (*ifp->if_initaddr)(ifp, ifa, src); else if (src || Index: src/sys/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.175 src/sys/net/if_spppsubr.c:1.176 --- src/sys/net/if_spppsubr.c:1.175 Wed Nov 22 17:11:51 2017 +++ src/sys/net/if_spppsubr.c Thu Dec 7 03:16:24 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.175 2017/11/22 17:11:51 christos Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.176 2017/12/07 03:16:24 ozaki-r Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.175 2017/11/22 17:11:51 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.176 2017/12/07 03:16:24 ozaki-r Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -5271,6 +5271,8 @@ sppp_set_ip_addrs_work(struct work *wk, uint32_t myaddr = 0, hisaddr = 0; int s; + mutex_enter(ifp->if_ioctl_lock); + /* * Pick the first AF_INET address from the list, * aliases don't make any sense on a p2p link anyway. @@ -5334,6 +5336,8 @@ sppp_set_ip_addrs_work(struct work *wk, ifp->if_xname, ifp->if_mtu); } + mutex_exit(ifp->if_ioctl_lock); + sppp_notify_con(sp); } @@ -5365,6 +5369,8 @@ sppp_clear_ip_addrs_work(struct work *wk struct sockaddr_in *si, *dest; int s; + mutex_enter(ifp->if_ioctl_lock); + /* * Pick the first AF_INET address from the list, * aliases don't make any sense on a p2p link anyway. @@ -5414,6 +5420,8 @@ sppp_clear_ip_addrs_work(struct work *wk "%s: resetting MTU to %" PRIu64 " bytes\n", ifp->if_xname, ifp->if_mtu); } + + mutex_exit(ifp->if_ioctl_lock); } static void @@ -5531,6 +5539,8 @@ sppp_set_ip6_addr(struct sppp *sp, const int s; struct psref psref; + mutex_enter(ifp->if_ioctl_lock); + /* * Pick the first link-local AF_INET6 address from the list, * aliases don't make any sense on a p2p link anyway. @@ -5568,6 +5578,8 @@ sppp_set_ip6_addr(struct sppp *sp, const } ifa_release(ifa, &psref); } + + mutex_exit(ifp->if_ioctl_lock); } #endif Index: src/sys/rump/net/lib/libnetinet/netinet_component.c diff -u src/sys/rump/net/lib/libnetinet/netinet_component.c:1.8 src/sys/rump/net/lib/libnetinet/netinet_component.c:1.9 --- src/sys/rump/net/lib/libnetinet/netinet_component.c:1.8 Fri Jan 20 08:35:33 2017 +++ src/sys/rump/net/lib/libnetinet/netinet_component.c Thu Dec 7 03:16:25 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: netinet_component.c,v 1.8 2017/01/20 08:35:33 ozaki-r Exp $ */ +/* $NetBSD: netinet_component.c,v 1.9 2017/12/07 03:16:25 ozaki-r Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: netinet_component.c,v 1.8 2017/01/20 08:35:33 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netinet_component.c,v 1.9 2017/12/07 03:16:25 ozaki-r Exp $"); #include <sys/param.h> #include <sys/domain.h> @@ -94,7 +94,9 @@ RUMP_COMPONENT(RUMP_COMPONENT_NET_IFCFG) sin->sin_len = sizeof(struct sockaddr_in); sin->sin_addr.s_addr = inet_addr("127.255.255.255"); + mutex_enter(lo0ifp->if_ioctl_lock); in_control(so, SIOCAIFADDR, &ia, lo0ifp); + mutex_exit(lo0ifp->if_ioctl_lock); if_up(lo0ifp); soclose(so); }