svn commit: r271770 - in head/sys: net netgraph

Gleb Smirnoff glebius at FreeBSD.org
Thu Sep 18 14:38:29 UTC 2014


Author: glebius
Date: Thu Sep 18 14:38:28 2014
New Revision: 271770
URL: http://svnweb.freebsd.org/changeset/base/271770

Log:
  Add a function to set if_get_counter method for an ifnet. To be used
  in the drivers that are already converted to "Juniper drvapi". This
  can be revisited in future.

Modified:
  head/sys/net/if.c
  head/sys/net/if_var.h
  head/sys/netgraph/ng_ppp.c

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c	Thu Sep 18 14:38:18 2014	(r271769)
+++ head/sys/net/if.c	Thu Sep 18 14:38:28 2014	(r271770)
@@ -4095,6 +4095,13 @@ void if_setqflushfn(if_t ifp, if_qflush_
 	
 }
 
+void
+if_setgetcounterfn(if_t ifp, if_get_counter_t fn)
+{
+
+	ifp->if_get_counter = fn;
+}
+
 /* Revisit these - These are inline functions originally. */
 int
 drbr_inuse_drv(if_t ifh, struct buf_ring *br)

Modified: head/sys/net/if_var.h
==============================================================================
--- head/sys/net/if_var.h	Thu Sep 18 14:38:18 2014	(r271769)
+++ head/sys/net/if_var.h	Thu Sep 18 14:38:28 2014	(r271770)
@@ -609,6 +609,7 @@ void if_setioctlfn(if_t ifp, int (*)(if_
 void if_setstartfn(if_t ifp, void (*)(if_t));
 void if_settransmitfn(if_t ifp, if_transmit_fn_t);
 void if_setqflushfn(if_t ifp, if_qflush_fn_t);
+void if_setgetcounterfn(if_t ifp, if_get_counter_t);
  
 /* Revisit the below. These are inline functions originally */
 int drbr_inuse_drv(if_t ifp, struct buf_ring *br);

Modified: head/sys/netgraph/ng_ppp.c
==============================================================================
--- head/sys/netgraph/ng_ppp.c	Thu Sep 18 14:38:18 2014	(r271769)
+++ head/sys/netgraph/ng_ppp.c	Thu Sep 18 14:38:28 2014	(r271770)
@@ -237,6 +237,7 @@ static ng_rcvdata_t	ng_ppp_rcvdata;
 static ng_disconnect_t	ng_ppp_disconnect;
 
 static ng_rcvdata_t	ng_ppp_rcvdata_inet;
+static ng_rcvdata_t	ng_ppp_rcvdata_inet_fast;
 static ng_rcvdata_t	ng_ppp_rcvdata_ipv6;
 static ng_rcvdata_t	ng_ppp_rcvdata_ipx;
 static ng_rcvdata_t	ng_ppp_rcvdata_atalk;
@@ -793,6 +794,19 @@ ng_ppp_rcvdata_inet(hook_p hook, item_p 
 }
 
 /*
+ * Receive data on a hook inet and pass it directly to first link.
+ */
+static int
+ng_ppp_rcvdata_inet_fast(hook_p hook, item_p item)
+{
+	const node_p node = NG_HOOK_NODE(hook);
+	const priv_p priv = NG_NODE_PRIVATE(node);
+
+	return (ng_ppp_link_xmit(node, item, PROT_IP, priv->activeLinks[0],
+	    NGI_M(item)->m_pkthdr.len));
+}
+
+/*
  * Receive data on a hook ipv6.
  */
 static int
@@ -2530,6 +2544,20 @@ ng_ppp_update(node_p node, int newConf)
 			link->seq = MP_NOSEQ;
 		}
 	}
+
+	if (priv->hooks[HOOK_INDEX_INET] != NULL) {
+		if (priv->conf.enableIP == 1 &&
+		    priv->numActiveLinks == 1 &&
+		    priv->conf.enableMultilink == 0 &&
+		    priv->conf.enableCompression == 0 &&
+		    priv->conf.enableEncryption == 0 &&
+		    priv->conf.enableVJCompression == 0)
+			NG_HOOK_SET_RCVDATA(priv->hooks[HOOK_INDEX_INET],
+			    ng_ppp_rcvdata_inet_fast);
+		else
+			NG_HOOK_SET_RCVDATA(priv->hooks[HOOK_INDEX_INET],
+			    ng_ppp_rcvdata_inet);
+	}
 }
 
 /*


More information about the svn-src-all mailing list