Module Name:    src
Committed By:   pooka
Date:           Sat Apr 26 11:16:22 UTC 2014

Modified Files:
        src/sys/kern: sys_socket.c
        src/sys/net: if.c if.h

Log Message:
Decouple sockets linkage from interface code by making ifioctl() a pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/kern/sys_socket.c
cvs rdiff -u -r1.272 -r1.273 src/sys/net/if.c
cvs rdiff -u -r1.162 -r1.163 src/sys/net/if.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/sys_socket.c
diff -u src/sys/kern/sys_socket.c:1.66 src/sys/kern/sys_socket.c:1.67
--- src/sys/kern/sys_socket.c:1.66	Sat Apr 26 11:10:10 2014
+++ src/sys/kern/sys_socket.c	Sat Apr 26 11:16:22 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_socket.c,v 1.66 2014/04/26 11:10:10 pooka Exp $	*/
+/*	$NetBSD: sys_socket.c,v 1.67 2014/04/26 11:16:22 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.66 2014/04/26 11:10:10 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.67 2014/04/26 11:16:22 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -92,6 +92,8 @@ const struct fileops socketops = {
 	.fo_restart = soo_restart,
 };
 
+int (*ifioctl)(struct socket *, u_long, void *, struct lwp *) = (void *)eopnotsupp;
+
 /* ARGSUSED */
 int
 soo_read(file_t *fp, off_t *offset, struct uio *uio, kauth_cred_t cred,

Index: src/sys/net/if.c
diff -u src/sys/net/if.c:1.272 src/sys/net/if.c:1.273
--- src/sys/net/if.c:1.272	Tue Feb 25 18:30:12 2014
+++ src/sys/net/if.c	Sat Apr 26 11:16:22 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.272 2014/02/25 18:30:12 pooka Exp $	*/
+/*	$NetBSD: if.c,v 1.273 2014/04/26 11:16:22 pooka 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.272 2014/02/25 18:30:12 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.273 2014/04/26 11:16:22 pooka Exp $");
 
 #include "opt_inet.h"
 
@@ -168,6 +168,7 @@ pfil_head_t *	if_pfil;
 
 static kauth_listener_t if_listener;
 
+static int doifioctl(struct socket *, u_long, void *, struct lwp *);
 static int ifioctl_attach(struct ifnet *);
 static void ifioctl_detach(struct ifnet *);
 static void ifnet_lock_enter(struct ifnet_lock *);
@@ -226,6 +227,9 @@ ifinit(void)
 
 	if_listener = kauth_listen_scope(KAUTH_SCOPE_NETWORK,
 	    if_listener_cb, NULL);
+
+	/* interfaces are available, inform socket code */
+	ifioctl = doifioctl;
 }
 
 /*
@@ -1788,8 +1792,8 @@ ifnet_lock_exit(struct ifnet_lock *il)
 /*
  * Interface ioctls.
  */
-int
-ifioctl(struct socket *so, u_long cmd, void *data, struct lwp *l)
+static int
+doifioctl(struct socket *so, u_long cmd, void *data, struct lwp *l)
 {
 	struct ifnet *ifp;
 	struct ifreq *ifr;

Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.162 src/sys/net/if.h:1.163
--- src/sys/net/if.h:1.162	Thu Apr 17 15:45:39 2014
+++ src/sys/net/if.h	Sat Apr 26 11:16:22 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.162 2014/04/17 15:45:39 christos Exp $	*/
+/*	$NetBSD: if.h,v 1.163 2014/04/26 11:16:22 pooka Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -885,7 +885,7 @@ void	ifinit(void);
 void	ifinit1(void);
 int	ifaddrpref_ioctl(struct socket *, u_long, void *, struct ifnet *,
     lwp_t *);
-int	ifioctl(struct socket *, u_long, void *, struct lwp *);
+extern int (*ifioctl)(struct socket *, u_long, void *, struct lwp *);
 int	ifioctl_common(struct ifnet *, u_long, void *);
 int	ifpromisc(struct ifnet *, int);
 struct	ifnet *ifunit(const char *);

Reply via email to