netfilter: flowtable: refresh flow if hardware offload fails
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH 1/1 netfilter: flowtable: refresh flow if hardware offload fails
If nf_flow_offload_add() fails to add the flow to hardware, then the NF_FLOW_HW flag bit is unset and the flow remains in the flowtable software path.
If flowtable hardware offload is enabled, this patch enqueues a new request to offload this flow to hardware.
--- net/netfilter/nf_flow_table_core.c | 4 +++- net/netfilter/nf_flow_table_ip.c | 10 ++++++++++ net/netfilter/nf_flow_table_offload.c | 3 +-- 3 files changed, 14 insertions(+), 3 deletions(-)
net/netfilter/nf_flow_table_core.c +3 -1
@@ -243,8 +243,10 @@ int flow_offload_add(struct nf_flowtable *flow_table, struct flow_offload *flow)return err; } -if (flow_table->flags &NF_FLOWTABLE_HW_OFFLOAD ) +if (flow_table->flags &NF_FLOWTABLE_HW_OFFLOAD ) { +__set_bit (NF_FLOW_HW , &flow->flags);nf_flow_offload_add (flow_table, flow); + }return 0 ; }
net/netfilter/nf_flow_table_ip.c +10 -0
@@ -259,6 +259,11 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb, dir = tuplehash->tuple.dir; flow = container_of(tuplehash, struct flow_offload, tuplehash[dir]); + +if (unlikely ((flow_table->flags &NF_FLOWTABLE_HW_OFFLOAD ) && + !test_and_set_bit (NF_FLOW_HW , &flow->flags))) +nf_flow_offload_add (flow_table, flow); + rt = (struct rtable *)flow->tuplehash[dir].tuple.dst_cache; outdev = rt->dst.dev;
@@ -488,6 +493,11 @@ nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb, dir = tuplehash->tuple.dir; flow = container_of(tuplehash, struct flow_offload, tuplehash[dir]); + +if (unlikely ((flow_table->flags &NF_FLOWTABLE_HW_OFFLOAD ) && + !test_and_set_bit (NF_FLOW_HW , &flow->flags))) +nf_flow_offload_add (flow_table, flow); + rt = (struct rt6_info *)flow->tuplehash[dir].tuple.dst_cache; outdev = rt->dst.dev;
net/netfilter/nf_flow_table_offload.c +1 -2
@@ -723,7 +723,7 @@ static void flow_offload_work_handler(struct work_struct *work)case FLOW_CLS_REPLACE : ret =flow_offload_work_add (offload);if (ret <0 ) -__clear_bit (NF_FLOW_HW , &offload->flow->flags); +clear_bit (NF_FLOW_HW , &offload->flow->flags);break ;case FLOW_CLS_DESTROY :flow_offload_work_del (offload);
@@ -776,7 +776,6 @@ void nf_flow_offload_add(struct nf_flowtable *flowtable,if (!offload)return ; -__set_bit (NF_FLOW_HW , &flow->flags);flow_offload_queue_work (offload); }
Signature · 1 line
2.11.0
Quoted 35 lines · Pablo Neira Ayuso
If
nf_flow_offload_add()fails to add the flow to hardware, then theNF_FLOW_HWflag bit is unset and the flow remains in the flowtable software path.If flowtable hardware offload is enabled, this patch enqueues a new request to offload this flow to hardware.
Signed-off-by Pablo Neira Ayuso <[email protected]>--- net/netfilter/nf_flow_table_core.c | 4 +++- net/netfilter/nf_flow_table_ip.c | 10 ++++++++++ net/netfilter/nf_flow_table_offload.c | 3 +-- 3 files changed, 14 insertions(+), 3 deletions(-)net/netfilter/nf_flow_table_core.c +3
-1@@ -243,8 +243,10 @@ int flow_offload_add(struct nf_flowtable *flow_table, struct flow_offload *flow)return err; } -if (flow_table->flags &NF_FLOWTABLE_HW_OFFLOAD ) +if (flow_table->flags &NF_FLOWTABLE_HW_OFFLOAD ) { +__set_bit (NF_FLOW_HW , &flow->flags);nf_flow_offload_add (flow_table, flow); + }return 0 ; }net/netfilter/nf_flow_table_ip.c +0
-0
net/netfilter/nf_flow_table_ip.c nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb, · line 266
Quoted 8 lines
net/netfilter/nf_flow_table_ip.c +5
-0@@ -259,6 +259,11 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb, dir = tuplehash->tuple.dir; flow = container_of(tuplehash, struct flow_offload, tuplehash[dir]); + +if (unlikely ((flow_table->flags &NF_FLOWTABLE_HW_OFFLOAD ) && + !test_and_set_bit (NF_FLOW_HW , &flow->flags))) +nf_flow_offload_add (flow_table, flow); +
Maybe put the refresh operation ather the nf_flow_state_check to aviod
the RST/FIN packets do the this?
Quoted 36 lines
net/netfilter/nf_flow_table_ip.c +5
-0rt = (struct rtable *)flow->tuplehash[dir].tuple.dst_cache; outdev = rt->dst.dev;@@ -488,6 +493,11 @@ nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb, dir = tuplehash->tuple.dir; flow = container_of(tuplehash, struct flow_offload, tuplehash[dir]); + +if (unlikely ((flow_table->flags &NF_FLOWTABLE_HW_OFFLOAD ) && + !test_and_set_bit (NF_FLOW_HW , &flow->flags))) +nf_flow_offload_add (flow_table, flow); + rt = (struct rt6_info *)flow->tuplehash[dir].tuple.dst_cache; outdev = rt->dst.dev;net/netfilter/nf_flow_table_offload.c +1
-2@@ -723,7 +723,7 @@ static void flow_offload_work_handler(struct work_struct *work)case FLOW_CLS_REPLACE : ret =flow_offload_work_add (offload);if (ret <0 ) -__clear_bit (NF_FLOW_HW , &offload->flow->flags); +clear_bit (NF_FLOW_HW , &offload->flow->flags);break ;case FLOW_CLS_DESTROY :flow_offload_work_del (offload);@@ -776,7 +776,6 @@ void nf_flow_offload_add(struct nf_flowtable *flowtable,if (!offload)return ; -__set_bit (NF_FLOW_HW , &flow->flags);flow_offload_queue_work (offload); }