From 35853c2c60c16a8dbef3640d7f4f26c4558f02a9 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Thu, 18 Sep 2014 14:38:28 +0000 Subject: [PATCH] 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. --- sys/net/if.c | 7 +++++++ sys/net/if_var.h | 1 + sys/netgraph/ng_ppp.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/sys/net/if.c b/sys/net/if.c index dfd30d33d700..77fa82b32070 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -4095,6 +4095,13 @@ void if_setqflushfn(if_t ifp, if_qflush_fn_t flush_fn) } +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) diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 0ec1322a13fb..03b04f09dac1 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -609,6 +609,7 @@ void if_setioctlfn(if_t ifp, int (*)(if_t, u_long, caddr_t)); 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); diff --git a/sys/netgraph/ng_ppp.c b/sys/netgraph/ng_ppp.c index 9db1a2fb1eb5..89ab617788db 100644 --- a/sys/netgraph/ng_ppp.c +++ b/sys/netgraph/ng_ppp.c @@ -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; @@ -792,6 +793,19 @@ ng_ppp_rcvdata_inet(hook_p hook, item_p item) return (ng_ppp_hcomp_xmit(NG_HOOK_NODE(hook), item, PROT_IP)); } +/* + * 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. */ @@ -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); + } } /*