From 5b72559c14c13cdf414720cb17cddb73ad07ded9 Mon Sep 17 00:00:00 2001 From: Mohammed Javid Date: Thu, 16 Jul 2015 22:43:04 +0530 Subject: [PATCH] net: Changes to support Shortcut Forward Engine Shortcut forward Engine (SFE) is a software packet accelerator which works on packet tuple entires (SFE entry) based on conntrack information. net:core has changes to invoke SFE module during packet traversal. net:netfilter has changes to remove SFE Entries when conntrack is deleted or expires. Also has changes to avoid tcp window check for incoming packets. Change-Id: I1622677e472870f8100c72221d9b1fab7fa768be Signed-off-by: Mohammed Javid --- include/linux/skbuff.h | 4 ++++ include/net/netfilter/nf_conntrack.h | 4 ++++ include/net/netfilter/nf_conntrack_core.h | 6 ++++++ net/core/dev.c | 18 ++++++++++++++++++ net/netfilter/nf_conntrack_core.c | 16 ++++++++++++++++ 5 files changed, 48 insertions(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 89301656f985..3dcfab36c11f 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -811,6 +811,10 @@ struct sk_buff { __u8 ipvs_property:1; __u8 inner_protocol_type:1; + +#ifdef CONFIG_ENABLE_SFE + __u8 fast_forwarded:1; +#endif __u8 remcsum_offload:1; #ifdef CONFIG_NET_SWITCHDEV __u8 offload_fwd_mark:1; diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index 159bc1934679..258297204a9c 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h @@ -112,6 +112,10 @@ struct nf_conn { unsigned long nattype_entry; #endif +#ifdef CONFIG_ENABLE_SFE + void *sfe_entry; +#endif + /* Storage reserved for other modules, must be the last member */ union nf_conntrack_proto proto; }; diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h index 96dc4b9d6373..7787b4774414 100644 --- a/include/net/netfilter/nf_conntrack_core.h +++ b/include/net/netfilter/nf_conntrack_core.h @@ -43,11 +43,17 @@ void nf_conntrack_cleanup_end(void); bool nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, const struct nf_conntrack_tuple *orig); + extern bool (*nattype_refresh_timer) (unsigned long nattype, unsigned long timeout_value) __rcu __read_mostly; + +#ifdef CONFIG_ENABLE_SFE +extern void (*delete_sfe_entry)(struct nf_conn *ct); +#endif + /* Find a connection corresponding to a tuple. */ struct nf_conntrack_tuple_hash * nf_conntrack_find_get(struct net *net, diff --git a/net/core/dev.c b/net/core/dev.c index 82d77b446c13..1802dd4aa605 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4730,6 +4730,11 @@ void process_embms_receive_skb(struct sk_buff *skb) embms_recv(skb); } +#ifdef CONFIG_ENABLE_SFE +int (*athrs_fast_nat_recv)(struct sk_buff *skb) __rcu __read_mostly; +EXPORT_SYMBOL(athrs_fast_nat_recv); +#endif + static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc, struct packet_type **ppt_prev) { @@ -4740,6 +4745,9 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc, bool deliver_exact = false; int ret = NET_RX_DROP; __be16 type; +#ifdef CONFIG_ENABLE_SFE + int (*fast_recv)(struct sk_buff *skb); +#endif net_timestamp_check(!netdev_tstamp_prequeue, skb); @@ -4813,6 +4821,16 @@ skip_taps: process_embms_receive_skb(skb); skip_classify: +#ifdef CONFIG_ENABLE_SFE + fast_recv = rcu_dereference(athrs_fast_nat_recv); + if (fast_recv) { + if (fast_recv(skb)) { + ret = NET_RX_SUCCESS; + goto out; + } + } +#endif + if (pfmemalloc && !skb_pfmemalloc_protocol(skb)) goto drop; diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 953c408db2a5..7592953ecb53 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -598,10 +598,18 @@ static void destroy_gre_conntrack(struct nf_conn *ct) #endif } +#ifdef CONFIG_ENABLE_SFE +void (*delete_sfe_entry)(struct nf_conn *ct) __rcu __read_mostly; +EXPORT_SYMBOL(delete_sfe_entry); +#endif + static void destroy_conntrack(struct nf_conntrack *nfct) { struct nf_conn *ct = (struct nf_conn *)nfct; +#ifdef CONFIG_ENABLE_SFE + void (*delete_entry)(struct nf_conn *ct); +#endif pr_debug("destroy_conntrack(%p)\n", ct); WARN_ON(atomic_read(&nfct->use) != 0); @@ -614,6 +622,14 @@ destroy_conntrack(struct nf_conntrack *nfct) if (unlikely(nf_ct_protonum(ct) == IPPROTO_GRE)) destroy_gre_conntrack(ct); +#ifdef CONFIG_ENABLE_SFE + if (ct->sfe_entry) { + delete_entry = rcu_dereference(delete_sfe_entry); + if (delete_entry) + delete_entry(ct); + } +#endif + local_bh_disable(); /* Expectations will have been removed in clean_from_lists, * except TFTP can create an expectation on the first packet,