Module Name: src Committed By: dyoung Date: Wed Oct 19 01:46:43 UTC 2011
Modified Files: src/sys/net: if.c Log Message: Extract subroutines ifioctl_enter() and ifioctl_exit(). To generate a diff of this commit: cvs rdiff -u -r1.252 -r1.253 src/sys/net/if.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.252 src/sys/net/if.c:1.253 --- src/sys/net/if.c:1.252 Wed Oct 19 01:34:37 2011 +++ src/sys/net/if.c Wed Oct 19 01:46:43 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.252 2011/10/19 01:34:37 dyoung Exp $ */ +/* $NetBSD: if.c,v 1.253 2011/10/19 01:46:43 dyoung 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.252 2011/10/19 01:34:37 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.253 2011/10/19 01:46:43 dyoung Exp $"); #include "opt_inet.h" @@ -170,6 +170,8 @@ static kauth_listener_t if_listener; static int ifioctl_attach(struct ifnet *); static void ifioctl_detach(struct ifnet *); +static void ifioctl_enter(struct ifnet *); +static void ifioctl_exit(struct ifnet *); static void if_detach_queues(struct ifnet *, struct ifqueue *); static void sysctl_sndq_setup(struct sysctllog **, const char *, struct ifaltq *); @@ -1694,6 +1696,22 @@ ifaddrpref_ioctl(struct socket *so, u_lo } } +static void +ifioctl_enter(struct ifnet *ifp) +{ + uint64_t *nenter = percpu_getref(ifp->if_ioctl_nenter); + (*nenter)++; + percpu_putref(ifp->if_ioctl_nenter); + mutex_enter(&ifp->if_ioctl_lock); +} + +static void +ifioctl_exit(struct ifnet *ifp) +{ + ifp->if_ioctl_nexit++; + mutex_exit(&ifp->if_ioctl_lock); +} + /* * Interface ioctls. */ @@ -1802,10 +1820,7 @@ ifioctl(struct socket *so, u_long cmd, v oif_flags = ifp->if_flags; - uint64_t *nenter = percpu_getref(ifp->if_ioctl_nenter); - (*nenter)++; - percpu_putref(ifp->if_ioctl_nenter); - mutex_enter(&ifp->if_ioctl_lock); + ifioctl_enter(ifp); error = (*ifp->if_ioctl)(ifp, cmd, data); if (error != ENOTTY) ; @@ -1835,8 +1850,7 @@ ifioctl(struct socket *so, u_long cmd, v ifreqn2o(oifr, ifr); #endif - ifp->if_ioctl_nexit++; - mutex_exit(&ifp->if_ioctl_lock); + ifioctl_exit(ifp); return error; }