From bbe88f4bc0087f25eb2608f9112d480ce92b33a5 Mon Sep 17 00:00:00 2001 From: Murat Sezgin Date: Wed, 11 Mar 2020 11:58:55 -0700 Subject: [PATCH 226/281] net: patch linux kernel to support shortcut-fe 1, add a new flag 'fast_forwarded' in skb structure. 2, put a hook in '__netif_receive_skb_core' to deliver packet to shortcut-fe. Change-Id: Icaa7c172a06df1c3bc89ff89814d1136772fe217 Signed-off-by: Murat Sezgin --- include/linux/skbuff.h | 2 ++ net/core/dev.c | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -984,6 +984,8 @@ struct sk_buff { #if IS_ENABLED(CONFIG_IP_SCTP) __u8 csum_not_inet:1; #endif + __u8 fast_forwarded:1; + /* 1 or 3 bit hole */ #if defined(CONFIG_NET_SCHED) || defined(CONFIG_NET_XGRESS) __u16 tc_index; /* traffic control index */ --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3625,8 +3625,13 @@ static int xmit_one(struct sk_buff *skb, unsigned int len; int rc; - if (dev_nit_active(dev)) - dev_queue_xmit_nit(skb, dev); + /* If this skb has been fast forwarded then we don't want it to + * go to any taps (by definition we're trying to bypass them). + */ + if (unlikely(!skb->fast_forwarded)) { + if (dev_nit_active(dev)) + dev_queue_xmit_nit(skb, dev); + } #ifdef CONFIG_ETHERNET_PACKET_MANGLE if (dev->eth_mangle_tx && !(skb = dev->eth_mangle_tx(dev, skb))) @@ -5396,6 +5401,9 @@ void netdev_rx_handler_unregister(struct } EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister); +int (*athrs_fast_nat_recv)(struct sk_buff *skb) __rcu __read_mostly; +EXPORT_SYMBOL_GPL(athrs_fast_nat_recv); + /* * Limit the use of PFMEMALLOC reserves to those protocols that implement * the special handling of PFMEMALLOC skbs. @@ -5443,6 +5451,7 @@ static int __netif_receive_skb_core(stru bool deliver_exact = false; int ret = NET_RX_DROP; __be16 type; + int (*fast_recv)(struct sk_buff *skb); net_timestamp_check(!READ_ONCE(netdev_tstamp_prequeue), skb); @@ -5481,6 +5490,14 @@ another_round: goto out; } + fast_recv = rcu_dereference(athrs_fast_nat_recv); + if (fast_recv) { + if (fast_recv(skb)) { + ret = NET_RX_SUCCESS; + goto out; + } + } + if (skb_skip_tc_classify(skb)) goto skip_classify;