svn commit: r277261 - projects/ifnet/sys/netgraph

Gleb Smirnoff glebius at FreeBSD.org
Fri Jan 16 19:07:13 UTC 2015


Author: glebius
Date: Fri Jan 16 19:07:13 2015
New Revision: 277261
URL: https://svnweb.freebsd.org/changeset/base/277261

Log:
  Obtain the interface index via SIOCGIFINDEX.  This allows us to
  stop including if_var.h and become 100% opaque ifnet user.
  
  Sponsored by:	Nginx, Inc.

Modified:
  projects/ifnet/sys/netgraph/ng_iface.c

Modified: projects/ifnet/sys/netgraph/ng_iface.c
==============================================================================
--- projects/ifnet/sys/netgraph/ng_iface.c	Fri Jan 16 19:05:15 2015	(r277260)
+++ projects/ifnet/sys/netgraph/ng_iface.c	Fri Jan 16 19:07:13 2015	(r277261)
@@ -71,7 +71,6 @@
 
 #include <net/bpf.h>
 #include <net/if.h>
-#include <net/if_var.h>		/* XXXGL: for if_transmit() and if_index. */
 #include <net/if_types.h>
 #include <net/netisr.h>
 #include <net/route.h>
@@ -555,14 +554,18 @@ ng_iface_rcvmsg(node_p node, item_p item
 		    }
 
 		case NGM_IFACE_GET_IFINDEX:
+		    {
+			struct ifreq ifr;
+
 			NG_MKRESPONSE(resp, msg, sizeof(uint32_t), M_NOWAIT);
 			if (resp == NULL) {
 				error = ENOMEM;
 				break;
 			}
-			*((uint32_t *)resp->data) = ifp->if_index;
+			if_drvioctl(SIOCGIFINDEX, ifp, &ifr, curthread);
+			*((uint32_t *)resp->data) = ifr.ifr_index;
 			break;
-
+		    }
 		default:
 			error = EINVAL;
 			break;


More information about the svn-src-projects mailing list