generic: fix sfe patches

This commit is contained in:
AmadeusGhost 2020-07-04 11:36:02 +08:00
parent f27ff50d03
commit bdc7a1347a
3 changed files with 27 additions and 33 deletions

View File

@ -44,17 +44,17 @@
+ bool "Enables kernel network stack path for Shortcut Forwarding Engine
--- a/net/core/dev.c 2019-01-16 20:38:37.274933833 +0800
+++ b/net/core/dev.c 2019-01-16 20:44:07.773594898 +0800
@@ -3001,8 +3001,17 @@ static int xmit_one(struct sk_buff *skb,
unsigned int len;
int rc;
@@ -3005,8 +3005,17 @@ static int xmit_one(struct sk_buff *skb, struct net_device *dev,
!(skb->imq_flags & IMQ_F_ENQUEUE))
#else
if (!list_empty(&ptype_all) || !list_empty(&dev->ptype_all))
+#endif
+#ifdef CONFIG_SHORTCUT_FE
+ /* 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 (!skb->fast_forwarded) {
+#endif
if (!list_empty(&ptype_all) || !list_empty(&dev->ptype_all))
#endif
dev_queue_xmit_nit(skb, dev);
+#ifdef CONFIG_SHORTCUT_FE
+ }
@ -233,4 +233,4 @@
+#endif
if (likely(ret == 0 && !missed))
goto out_unlock;
goto out_unlock;

View File

@ -44,17 +44,17 @@
+ bool "Enables kernel network stack path for Shortcut Forwarding Engine
--- a/net/core/dev.c 2019-01-16 20:38:37.274933833 +0800
+++ b/net/core/dev.c 2019-01-16 20:44:07.773594898 +0800
@@ -3001,8 +3001,17 @@ static int xmit_one(struct sk_buff *skb,
unsigned int len;
int rc;
@@ -3256,8 +3256,17 @@ static int xmit_one(struct sk_buff *skb, struct net_device *dev,
!(skb->imq_flags & IMQ_F_ENQUEUE))
#else
if (!list_empty(&ptype_all) || !list_empty(&dev->ptype_all))
+#endif
+#ifdef CONFIG_SHORTCUT_FE
+ /* 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 (!skb->fast_forwarded) {
+#endif
if (!list_empty(&ptype_all) || !list_empty(&dev->ptype_all))
#endif
dev_queue_xmit_nit(skb, dev);
+#ifdef CONFIG_SHORTCUT_FE
+ }
@ -233,4 +233,4 @@
+#endif
if (likely(ret == 0 && !missed))
goto out_unlock;
goto out_unlock;

View File

@ -47,22 +47,15 @@ Signed-off-by: Murat Sezgin <msezgin@codeaurora.org>
+ bool "Enables kernel network stack path for Shortcut Forwarding Engine"
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2972,6 +2972,12 @@ static int xmit_one(struct sk_buff *skb,
unsigned int len;
int rc;
@@ -2974,7 +2974,15 @@ static int xmit_one(struct sk_buff *skb, struct net_device *dev,
#else
if (!list_empty(&ptype_all) || !list_empty(&dev->ptype_all))
#endif
+#ifdef CONFIG_SHORTCUT_FE
+ /* 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 (!skb->fast_forwarded) {
+#endif
#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
if ((!list_empty(&ptype_all) || !list_empty(&dev->ptype_all)) &&
!(skb->imq_flags & IMQ_F_ENQUEUE))
@@ -2979,6 +2985,9 @@ static int xmit_one(struct sk_buff *skb,
if (!list_empty(&ptype_all) || !list_empty(&dev->ptype_all))
#endif
dev_queue_xmit_nit(skb, dev);
+#ifdef CONFIG_SHORTCUT_FE
+ }
@ -70,34 +63,35 @@ Signed-off-by: Murat Sezgin <msezgin@codeaurora.org>
#ifdef CONFIG_ETHERNET_PACKET_MANGLE
if (!dev->eth_mangle_tx ||
@@ -4130,6 +4139,11 @@ void netdev_rx_handler_unregister(struct
@@ -4126,6 +4134,11 @@ void netdev_rx_handler_unregister(struct net_device *dev)
}
EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister);
+#ifdef CONFIG_SHORTCUT_FE
+int (*fast_nat_recv)(struct sk_buff *skb) __rcu __read_mostly;
+EXPORT_SYMBOL_GPL(fast_nat_recv);
+int (*athrs_fast_nat_recv)(struct sk_buff *skb) __rcu __read_mostly;
+EXPORT_SYMBOL_GPL(athrs_fast_nat_recv);
+#endif
+
/*
* Limit the use of PFMEMALLOC reserves to those protocols that implement
* the special handling of PFMEMALLOC skbs.
@@ -4177,6 +4191,9 @@ static int __netif_receive_skb_core(stru
bool deliver_exact = false;
@@ -4174,6 +4187,10 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
int ret = NET_RX_DROP;
__be16 type;
+#ifdef CONFIG_SHORTCUT_FE
+ int (*fast_recv)(struct sk_buff *skb);
+#endif
+
net_timestamp_check(!netdev_tstamp_prequeue, skb);
@@ -4203,6 +4220,14 @@ another_round:
trace_netif_receive_skb(skb);
@@ -4199,6 +4216,14 @@ another_round:
goto out;
}
+#ifdef CONFIG_SHORTCUT_FE
+ fast_recv = rcu_dereference(fast_nat_recv);
+ fast_recv = rcu_dereference(athrs_fast_nat_recv);
+ if (fast_recv && fast_recv(skb)) {
+ ret = NET_RX_SUCCESS;
+ goto out;