svn commit: r277224 - in projects/ifnet/sys: dev/bge dev/msk dev/virtio/network dev/xl net netgraph netinet netinet6

Gleb Smirnoff glebius at FreeBSD.org
Thu Jan 15 23:03:28 UTC 2015


Author: glebius
Date: Thu Jan 15 23:03:24 2015
New Revision: 277224
URL: https://svnweb.freebsd.org/changeset/base/277224

Log:
  - Pass thread to if_ioctl methods.
  - Rename ifhwioctl() to if_drvioctl() and make it public. Drivers are now
    allowed to call it on theirselves.
  
  Sponsored by:	Nginx, Inc.

Modified:
  projects/ifnet/sys/dev/bge/if_bge.c
  projects/ifnet/sys/dev/msk/if_msk.c
  projects/ifnet/sys/dev/virtio/network/if_vtnet.c
  projects/ifnet/sys/dev/xl/if_xl.c
  projects/ifnet/sys/net/bpf.c
  projects/ifnet/sys/net/if.c
  projects/ifnet/sys/net/if.h
  projects/ifnet/sys/net/if_ethersubr.c
  projects/ifnet/sys/net/if_loop.c
  projects/ifnet/sys/net/if_var.h
  projects/ifnet/sys/netgraph/ng_iface.c
  projects/ifnet/sys/netinet/in.c
  projects/ifnet/sys/netinet6/in6.c

Modified: projects/ifnet/sys/dev/bge/if_bge.c
==============================================================================
--- projects/ifnet/sys/dev/bge/if_bge.c	Thu Jan 15 22:32:03 2015	(r277223)
+++ projects/ifnet/sys/dev/bge/if_bge.c	Thu Jan 15 23:03:24 2015	(r277224)
@@ -419,7 +419,7 @@ static int bge_msi_intr(void *);
 static void bge_intr_task(void *, int);
 static int bge_start_locked(struct bge_softc *);
 static int bge_transmit(if_t, struct mbuf *);
-static int bge_ioctl(if_t, u_long, caddr_t);
+static int bge_ioctl(if_t, u_long, void *, struct thread *);
 static void bge_init_locked(struct bge_softc *);
 static void bge_init(void *);
 static void bge_stop_block(struct bge_softc *, bus_size_t, uint32_t);
@@ -5745,7 +5745,7 @@ bge_ifmedia_sts(if_t ifp, struct ifmedia
 }
 
 static int
-bge_ioctl(if_t ifp, u_long command, caddr_t data)
+bge_ioctl(if_t ifp, u_long command, void *data, struct thread *td)
 {
 	struct bge_softc *sc = if_getsoftc(ifp, IF_DRIVER_SOFTC);
 	struct ifreq *ifr = (struct ifreq *) data;

Modified: projects/ifnet/sys/dev/msk/if_msk.c
==============================================================================
--- projects/ifnet/sys/dev/msk/if_msk.c	Thu Jan 15 22:32:03 2015	(r277223)
+++ projects/ifnet/sys/dev/msk/if_msk.c	Thu Jan 15 23:03:24 2015	(r277224)
@@ -280,7 +280,7 @@ static void msk_txeof(struct msk_if_soft
 static int msk_encap(struct msk_if_softc *, struct mbuf **);
 static int msk_transmit(if_t, struct mbuf *);
 static int msk_start(struct msk_if_softc *);
-static int msk_ioctl(if_t, u_long, caddr_t);
+static int msk_ioctl(if_t, u_long, void *, struct thread *);
 static void msk_set_prefetch(struct msk_softc *, int, bus_addr_t, uint32_t);
 static void msk_set_rambuffer(struct msk_if_softc *);
 static void msk_set_tx_stfwd(struct msk_if_softc *);
@@ -1066,7 +1066,7 @@ msk_mediastatus(if_t ifp, struct ifmedia
 }
 
 static int
-msk_ioctl(if_t ifp, u_long command, caddr_t data)
+msk_ioctl(if_t ifp, u_long command, void  *data, struct thread *td)
 {
 	struct msk_if_softc *sc_if;
 	struct ifreq *ifr;

Modified: projects/ifnet/sys/dev/virtio/network/if_vtnet.c
==============================================================================
--- projects/ifnet/sys/dev/virtio/network/if_vtnet.c	Thu Jan 15 22:32:03 2015	(r277223)
+++ projects/ifnet/sys/dev/virtio/network/if_vtnet.c	Thu Jan 15 23:03:24 2015	(r277224)
@@ -108,7 +108,7 @@ static void	vtnet_free_rx_filters(struct
 static int	vtnet_alloc_virtqueues(struct vtnet_softc *);
 static void	vtnet_setup_interface(struct vtnet_softc *);
 static int	vtnet_change_mtu(struct vtnet_softc *, int);
-static int	vtnet_ioctl(if_t, u_long, caddr_t);
+static int	vtnet_ioctl(if_t, u_long, void *, struct thread *);
 static uint64_t	vtnet_get_counter(if_t, ift_counter);
 
 static int	vtnet_rxq_populate(struct vtnet_rxq *);
@@ -1013,7 +1013,7 @@ vtnet_change_mtu(struct vtnet_softc *sc,
 }
 
 static int
-vtnet_ioctl(if_t ifp, u_long cmd, caddr_t data)
+vtnet_ioctl(if_t ifp, u_long cmd, void *data, struct thread *td)
 {
 	struct vtnet_softc *sc;
 	struct ifreq *ifr;

Modified: projects/ifnet/sys/dev/xl/if_xl.c
==============================================================================
--- projects/ifnet/sys/dev/xl/if_xl.c	Thu Jan 15 22:32:03 2015	(r277223)
+++ projects/ifnet/sys/dev/xl/if_xl.c	Thu Jan 15 23:03:24 2015	(r277224)
@@ -237,7 +237,7 @@ static void xl_intr(void *);
 static int xl_transmit(if_t, struct mbuf *);
 static void xl_start_locked(struct xl_softc *);
 static void xl_start_90xB_locked(struct xl_softc *);
-static int xl_ioctl(if_t, u_long, caddr_t);
+static int xl_ioctl(if_t, u_long, void *, struct thread *);
 static void xl_init(void *);
 static void xl_init_locked(struct xl_softc *);
 static void xl_stop(struct xl_softc *);
@@ -2978,7 +2978,7 @@ xl_ifmedia_sts(if_t ifp, struct ifmediar
 }
 
 static int
-xl_ioctl(if_t ifp, u_long command, caddr_t data)
+xl_ioctl(if_t ifp, u_long command, void *data, struct thread *td)
 {
 	struct xl_softc		*sc;
 	struct ifreq		*ifr = (struct ifreq *) data;

Modified: projects/ifnet/sys/net/bpf.c
==============================================================================
--- projects/ifnet/sys/net/bpf.c	Thu Jan 15 22:32:03 2015	(r277223)
+++ projects/ifnet/sys/net/bpf.c	Thu Jan 15 23:03:24 2015	(r277224)
@@ -1330,7 +1330,7 @@ bpfioctl(struct cdev *dev, u_long cmd, c
 				error = EINVAL;
 			else {
 				ifp = d->bd_bif->bif_ifp;
-				error = if_ioctl(ifp, cmd, addr);
+				error = if_ioctl(ifp, cmd, addr, td);
 			}
 			break;
 		}

Modified: projects/ifnet/sys/net/if.c
==============================================================================
--- projects/ifnet/sys/net/if.c	Thu Jan 15 22:32:03 2015	(r277223)
+++ projects/ifnet/sys/net/if.c	Thu Jan 15 23:03:24 2015	(r277224)
@@ -166,7 +166,6 @@ static int	if_setflag(struct ifnet *, in
 static void	if_unroute(struct ifnet *, int flag, int fam);
 static void	link_rtrequest(int, struct rtentry *, struct rt_addrinfo *);
 static int	if_rtdel(struct radix_node *, void *);
-static int	ifhwioctl(u_long, struct ifnet *, caddr_t, struct thread *);
 static int	if_delmulti_locked(struct ifnet *, struct ifmultiaddr *, int);
 static void	do_link_state_change(void *, int);
 static int	if_getgroup(struct ifgroupreq *, struct ifnet *);
@@ -2403,8 +2402,8 @@ ifunit(const char *name)
 /*
  * Hardware specific interface ioctls.
  */
-static int
-ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
+int
+if_drvioctl(u_long cmd, struct ifnet *ifp, void *data, struct thread *td)
 {
 	struct ifreq *ifr;
 	int error = 0;
@@ -2548,7 +2547,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp,
 		}
 		ifp->if_flags = (ifp->if_flags & IFF_CANTCHANGE) |
 			(new_flags &~ IFF_CANTCHANGE);
-		if_ioctl(ifp, cmd, data);
+		if_ioctl(ifp, cmd, data, td);
 		getmicrotime(&ifp->if_lastchange);
 		break;
 
@@ -2558,7 +2557,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp,
 			return (error);
 		if (ifr->ifr_reqcap & ~ifp->if_capabilities)
 			return (EINVAL);
-		error = if_ioctl(ifp, cmd, data);
+		error = if_ioctl(ifp, cmd, data, td);
 		if (error == 0)
 			getmicrotime(&ifp->if_lastchange);
 		break;
@@ -2647,7 +2646,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp,
 		error = priv_check(td, PRIV_NET_SETIFPHYS);
 		if (error)
 			return (error);
-		error = if_ioctl(ifp, cmd, data);
+		error = if_ioctl(ifp, cmd, data, td);
 		if (error == 0)
 			getmicrotime(&ifp->if_lastchange);
 		break;
@@ -2661,7 +2660,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp,
 			return (error);
 		if (ifr->ifr_mtu < IF_MINMTU || ifr->ifr_mtu > IF_MAXMTU)
 			return (EINVAL);
-		error = if_ioctl(ifp, cmd, data);
+		error = if_ioctl(ifp, cmd, data, td);
 		if (error == 0) {
 			getmicrotime(&ifp->if_lastchange);
 			rt_ifmsg(ifp);
@@ -2729,7 +2728,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp,
 		error = priv_check(td, PRIV_NET_HWIOCTL);
 		if (error)
 			return (error);
-		error = if_ioctl(ifp, cmd, data);
+		error = if_ioctl(ifp, cmd, data, td);
 		if (error == 0)
 			getmicrotime(&ifp->if_lastchange);
 		break;
@@ -2739,7 +2738,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp,
 	case SIOCGIFPDSTADDR:
 	case SIOCGIFMEDIA:
 	case SIOCGIFGENERIC:
-		error = if_ioctl(ifp, cmd, data);
+		error = if_ioctl(ifp, cmd, data, td);
 		break;
 
 	case SIOCSIFLLADDR:
@@ -2888,7 +2887,7 @@ ifioctl(struct socket *so, u_long cmd, c
 		return (ENXIO);
 	}
 
-	error = ifhwioctl(cmd, ifp, data, td);
+	error = if_drvioctl(cmd, ifp, data, td);
 	if (error != ENOIOCTL) {
 		if_rele(ifp);
 		CURVNET_RESTORE();
@@ -2916,7 +2915,7 @@ ifioctl(struct socket *so, u_long cmd, c
 	if (error == EOPNOTSUPP && ifp != NULL &&
 	    cmd != SIOCSIFADDR && cmd != SIOCSIFBRDADDR &&
 	    cmd != SIOCSIFDSTADDR && cmd != SIOCSIFNETMASK)
-		error = if_ioctl(ifp, cmd, data);
+		error = if_ioctl(ifp, cmd, data, td);
 
 	if ((oif_flags ^ ifp->if_flags) & IFF_UP) {
 #ifdef INET6
@@ -2980,7 +2979,7 @@ if_setflag(struct ifnet *ifp, int flag, 
 	/* Call down the driver since we've changed interface flags */
 	ifr.ifr_flags = ifp->if_flags & 0xffff;
 	ifr.ifr_flagshigh = ifp->if_flags >> 16;
-	error = if_ioctl(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
+	error = if_ioctl(ifp, SIOCSIFFLAGS, (caddr_t)&ifr, curthread);
 	if (error)
 		goto recover;
 	/* Notify userland that interface flags have changed */
@@ -3327,7 +3326,7 @@ if_addmulti(struct ifnet *ifp, struct so
 	 * We are certain we have added something, so call down to the
 	 * interface to let them know about it.
 	 */
-	if_ioctl(ifp, SIOCADDMULTI, 0);
+	if_ioctl(ifp, SIOCADDMULTI, 0, curthread);
 
 	if ((llsa != NULL) && (llsa != (struct sockaddr *)&sdl))
 		link_free_sdl(llsa);
@@ -3384,7 +3383,7 @@ if_delmulti(struct ifnet *ifp, struct so
 		return (ENOENT);
 
 	if (lastref)
-		if_ioctl(ifp, SIOCDELMULTI, 0);
+		if_ioctl(ifp, SIOCDELMULTI, 0, curthread);
 
 	return (0);
 }
@@ -3451,7 +3450,7 @@ if_delmulti_ifma(struct ifmultiaddr *ifm
 		 */
 		IF_ADDR_WUNLOCK(ifp);
 		if (lastref)
-			if_ioctl(ifp, SIOCDELMULTI, 0);
+			if_ioctl(ifp, SIOCDELMULTI, 0, curthread);
 	}
 }
 
@@ -3587,11 +3586,11 @@ if_setlladdr(struct ifnet *ifp, const u_
 		ifp->if_flags &= ~IFF_UP;
 		ifr.ifr_flags = ifp->if_flags & 0xffff;
 		ifr.ifr_flagshigh = ifp->if_flags >> 16;
-		if_ioctl(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
+		if_ioctl(ifp, SIOCSIFFLAGS, &ifr, curthread);
 		ifp->if_flags |= IFF_UP;
 		ifr.ifr_flags = ifp->if_flags & 0xffff;
 		ifr.ifr_flagshigh = ifp->if_flags >> 16;
-		if_ioctl(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
+		if_ioctl(ifp, SIOCSIFFLAGS, &ifr, curthread);
 #ifdef INET
 		/*
 		 * Also send gratuitous ARPs to notify other nodes about

Modified: projects/ifnet/sys/net/if.h
==============================================================================
--- projects/ifnet/sys/net/if.h	Thu Jan 15 22:32:03 2015	(r277223)
+++ projects/ifnet/sys/net/if.h	Thu Jan 15 23:03:24 2015	(r277224)
@@ -591,7 +591,7 @@ typedef void	(*if_input_t)(if_t, struct 
 typedef int	(*if_transmit_t)(if_t, struct mbuf *);
 typedef int	(*if_output_t)(if_t, struct mbuf *, const struct sockaddr *,
     struct route *);
-typedef int	(*if_ioctl_t)(if_t, u_long, caddr_t);
+typedef int	(*if_ioctl_t)(if_t, u_long, void *, struct thread *);
 typedef uint64_t (*if_get_counter_t)(if_t, ift_counter);
 typedef void	(*if_qflush_t)(if_t);
 typedef int	(*if_resolvemulti_t)(if_t, struct sockaddr **,
@@ -715,6 +715,7 @@ void	if_link_state_change(if_t, int);
 void	if_set(if_t, ift_feature, uint64_t);
 void *	if_getsoftc(if_t, ift_feature);
 int	if_printf(if_t, const char *, ...) __printflike(2, 3);
+int	if_drvioctl(u_long, struct ifnet *, void *, struct thread *);
 uint64_t if_get(if_t, ift_feature);
 uint64_t if_flagbits(if_t, ift_feature, uint64_t, uint64_t, uint64_t);
 uint64_t if_get_counter_default(if_t, ift_counter);

Modified: projects/ifnet/sys/net/if_ethersubr.c
==============================================================================
--- projects/ifnet/sys/net/if_ethersubr.c	Thu Jan 15 22:32:03 2015	(r277223)
+++ projects/ifnet/sys/net/if_ethersubr.c	Thu Jan 15 23:03:24 2015	(r277224)
@@ -941,7 +941,7 @@ ether_crc32_be(const uint8_t *buf, size_
 }
 
 static int
-ether_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
+ether_ioctl(struct ifnet *ifp, u_long command, void *data, struct thread *td)
 {
 	struct ifaddr *ifa = (struct ifaddr *) data;
 	struct ifreq *ifr = (struct ifreq *) data;

Modified: projects/ifnet/sys/net/if_loop.c
==============================================================================
--- projects/ifnet/sys/net/if_loop.c	Thu Jan 15 22:32:03 2015	(r277223)
+++ projects/ifnet/sys/net/if_loop.c	Thu Jan 15 23:03:24 2015	(r277224)
@@ -84,7 +84,7 @@
 				    CSUM_IP_CHECKED | CSUM_IP_VALID | \
 				    CSUM_SCTP_VALID)
 int		if_simloop(if_t, struct mbuf *, int, int);
-static int	loioctl(if_t, u_long, caddr_t);
+static int	loioctl(if_t, u_long, void *, struct thread *);
 static int	looutput(if_t, struct mbuf *,
 		    const struct sockaddr *, struct route *);
 static int	lo_clone_create(struct if_clone *, int, caddr_t);
@@ -359,7 +359,7 @@ if_simloop(if_t ifp, struct mbuf *m, int
  */
 /* ARGSUSED */
 int
-loioctl(if_t ifp, u_long cmd, caddr_t data)
+loioctl(if_t ifp, u_long cmd, void  *data, struct thread *td)
 {
 	struct ifreq *ifr = (struct ifreq *)data;
 	int error = 0, mask;

Modified: projects/ifnet/sys/net/if_var.h
==============================================================================
--- projects/ifnet/sys/net/if_var.h	Thu Jan 15 22:32:03 2015	(r277223)
+++ projects/ifnet/sys/net/if_var.h	Thu Jan 15 23:03:24 2015	(r277224)
@@ -468,16 +468,16 @@ if_output(if_t ifp, struct mbuf *m, cons
 }
 
 static inline int
-if_ioctl(if_t ifp, u_long cmd, caddr_t data)
+if_ioctl(if_t ifp, u_long cmd, void *data, struct thread *td)
 {
 	struct iftype *ift = ifp->if_type;
 	int error = EOPNOTSUPP;
 
 	if (ifp->if_ops->ifop_ioctl != NULL)
-		error = ifp->if_ops->ifop_ioctl(ifp, cmd, data);
+		error = ifp->if_ops->ifop_ioctl(ifp, cmd, data, td);
 
 	if (error == EOPNOTSUPP && ift->ift_ops.ifop_ioctl != NULL)
-		error = ift->ift_ops.ifop_ioctl(ifp, cmd, data);
+		error = ift->ift_ops.ifop_ioctl(ifp, cmd, data, td);
 
 	return (error);
 }

Modified: projects/ifnet/sys/netgraph/ng_iface.c
==============================================================================
--- projects/ifnet/sys/netgraph/ng_iface.c	Thu Jan 15 22:32:03 2015	(r277223)
+++ projects/ifnet/sys/netgraph/ng_iface.c	Thu Jan 15 23:03:24 2015	(r277224)
@@ -117,7 +117,7 @@ typedef struct ng_iface_private *priv_p;
 
 /* Interface methods */
 static int	ng_iface_transmit(if_t, struct mbuf *);
-static int	ng_iface_ioctl(if_t, u_long cmd, caddr_t data);
+static int	ng_iface_ioctl(if_t, u_long, void *, struct thread *);
 static int	ng_iface_output(if_t, struct mbuf *m0,
     			const struct sockaddr *dst, struct route *ro);
 static int	ng_iface_send(if_t, struct mbuf *m, sa_family_t sa);
@@ -274,7 +274,7 @@ get_iffam_from_name(const char *name)
  * Process an ioctl for the virtual interface
  */
 static int
-ng_iface_ioctl(if_t ifp, u_long command, caddr_t data)
+ng_iface_ioctl(if_t ifp, u_long command, void *data, struct thread *td)
 {
 	struct ifreq *const ifr = (struct ifreq *) data;
 	int error = 0;

Modified: projects/ifnet/sys/netinet/in.c
==============================================================================
--- projects/ifnet/sys/netinet/in.c	Thu Jan 15 22:32:03 2015	(r277223)
+++ projects/ifnet/sys/netinet/in.c	Thu Jan 15 23:03:24 2015	(r277224)
@@ -232,7 +232,7 @@ in_control(struct socket *so, u_long cmd
 		/* We no longer support that old commands. */
 		return (EINVAL);
 	default:
-		return if_ioctl(ifp, cmd, data);
+		return (if_ioctl(ifp, cmd, data, td));
 	}
 
 	if (addr->sin_addr.s_addr != INADDR_ANY &&
@@ -434,7 +434,7 @@ in_aifaddr_ioctl(u_long cmd, caddr_t dat
 	 * if this is its first address,
 	 * and to validate the address if necessary.
 	 */
-	error = if_ioctl(ifp, SIOCSIFADDR, (caddr_t)ia);
+	error = if_ioctl(ifp, SIOCSIFADDR, ia, td);
 	if (error != 0 && error != EOPNOTSUPP)
 		goto fail1;
 

Modified: projects/ifnet/sys/netinet6/in6.c
==============================================================================
--- projects/ifnet/sys/netinet6/in6.c	Thu Jan 15 22:32:03 2015	(r277223)
+++ projects/ifnet/sys/netinet6/in6.c	Thu Jan 15 23:03:24 2015	(r277224)
@@ -753,7 +753,7 @@ aifaddr_out:
 	}
 
 	default:
-		error = if_ioctl(ifp, cmd, data);
+		error = if_ioctl(ifp, cmd, data, td);
 		goto out;
 	}
 
@@ -1399,7 +1399,7 @@ in6_notify_ifa(struct ifnet *ifp, struct
 	}
 
 	if (ifacount <= 1) {
-		error = if_ioctl(ifp, SIOCSIFADDR, (caddr_t)ia);
+		error = if_ioctl(ifp, SIOCSIFADDR, ia, curthread);
 		if (error != 0 && error != EOPNOTSUPP)
 			return (error);
 	}


More information about the svn-src-projects mailing list