netfilter: flowtable: additional checks for outdated flows
Subsystems (2)
PATCH 1/1 netfilter: flowtable: additional checks for outdated flows
Current nf_flow_is_outdated() implementation considers any flow table flow which state diverged from its underlying CT connection status for teardown which can be problematic in the following cases:
- Flow has never been offloaded to hardware in the first place either because flow table has hardware offload disabled (flag NF_FLOWTABLE_HW_OFFLOAD is not set) or because it is still pending on 'add' workqueue to be offloaded for the first time. The former is incorrect, the later generates excessive deletions and additions of flows.
- Flow is already pending to be updated on the workqueue. Tearing down such flows will also generate excessive removals from the flow table, especially on highly loaded system where the latency to re-offload a flow via 'add' workqueue can be quite high.
When considering a flow for teardown as outdated verify that it is both offloaded to hardware and doesn't have any pending updates.
--- net/netfilter/nf_flow_table_core.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nf_flow_table_core.c +2 -0
@@ -319,6 +319,8 @@ EXPORT_SYMBOL_GPL(flow_offload_refresh);static bool nf_flow_is_outdated (const struct flow_offload *flow) {return test_bit (IPS_SEEN_REPLY_BIT , &flow->ct->status) && +test_bit (IPS_HW_OFFLOAD_BIT , &flow->ct->status) && + !test_bit (NF_FLOW_HW_PENDING , &flow->flags) && !test_bit (NF_FLOW_HW_ESTABLISHED , &flow->flags); }
Signature · 1 line
2.39.2
Pablo Neira Ayuso
maintainerHi Vlad,
Quoted 10 lines · Vlad Buslov
Current
nf_flow_is_outdated()implementation considers any flow table flow which state diverged from its underlying CT connection status for teardown which can be problematic in the following cases:- Flow has never been offloaded to hardware in the first place either because flow table has hardware offload disabled (flag
NF_FLOWTABLE_HW_OFFLOADis not set) or because it is still pending on 'add' workqueue to be offloaded for the first time. The former is incorrect, the later generates excessive deletions and additions of flows.
Quoted 7 lines
- Flow is already pending to be updated on the workqueue. Tearing down such flows will also generate excessive removals from the flow table, especially on highly loaded system where the latency to re-offload a flow via 'add' workqueue can be quite high.
When considering a flow for teardown as outdated verify that it is both offloaded to hardware and doesn't have any pending updates.
Thanks.
I have posted an alternative patch to move the handling of NF_FLOW_HW_ESTABLISHED, which is specific for sched/act_ct:
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
it is a bit more code, but it makes it easier to understand for the code reader that this bit is net/sched specific.
Quoted 23 lines
Fixes 41f2c7c342d3 ("net/sched: act_ct: Fix promotion of offloaded unreplied tuple")Reviewed-by Paul Blakey <[email protected]>Signed-off-by Vlad Buslov <[email protected]>--- net/netfilter/nf_flow_table_core.c | 2 ++ 1 file changed, 2 insertions(+)net/netfilter/nf_flow_table_core.c +2
-0@@ -319,6 +319,8 @@ EXPORT_SYMBOL_GPL(flow_offload_refresh);static bool nf_flow_is_outdated (const struct flow_offload *flow) {return test_bit (IPS_SEEN_REPLY_BIT , &flow->ct->status) && +test_bit (IPS_HW_OFFLOAD_BIT , &flow->ct->status) && + !test_bit (NF_FLOW_HW_PENDING , &flow->flags) && !test_bit (NF_FLOW_HW_ESTABLISHED , &flow->flags); }Signature · 1 line
2.39.2
Quoted 23 lines · Pablo Neira Ayuso
Hi Vlad,
Quoted 10 lines · Vlad Buslov
Current
nf_flow_is_outdated()implementation considers any flow table flow which state diverged from its underlying CT connection status for teardown which can be problematic in the following cases:- Flow has never been offloaded to hardware in the first place either because flow table has hardware offload disabled (flag
NF_FLOWTABLE_HW_OFFLOADis not set) or because it is still pending on 'add' workqueue to be offloaded for the first time. The former is incorrect, the later generates excessive deletions and additions of flows.Quoted 7 lines
- Flow is already pending to be updated on the workqueue. Tearing down such flows will also generate excessive removals from the flow table, especially on highly loaded system where the latency to re-offload a flow via 'add' workqueue can be quite high.
When considering a flow for teardown as outdated verify that it is both offloaded to hardware and doesn't have any pending updates.
Thanks.
Quoted 8 lines
I have posted an alternative patch to move the handling of
NF_FLOW_HW_ESTABLISHED, which is specific for sched/act_ct:https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
it is a bit more code, but it makes it easier to understand for the code reader that this bit is net/sched specific.
Thanks for refactoring this, I agree that separating the act_ct-specific check makes it more obvious.
How would you prefer to solve the conflict with my fix? Should I wait for your patch to be accepted to net, rebase my fix on top and submit V2? Or you can incorporate the checks from my fix together with my signoff and submit it as a single change?
Quoted 23 lines
Quoted 23 lines
Fixes 41f2c7c342d3 ("net/sched: act_ct: Fix promotion of offloaded unreplied tuple")Reviewed-by Paul Blakey <[email protected]>Signed-off-by Vlad Buslov <[email protected]>--- net/netfilter/nf_flow_table_core.c | 2 ++ 1 file changed, 2 insertions(+)net/netfilter/nf_flow_table_core.c +2
-0@@ -319,6 +319,8 @@ EXPORT_SYMBOL_GPL(flow_offload_refresh);static bool nf_flow_is_outdated (const struct flow_offload *flow) {return test_bit (IPS_SEEN_REPLY_BIT , &flow->ct->status) && +test_bit (IPS_HW_OFFLOAD_BIT , &flow->ct->status) && + !test_bit (NF_FLOW_HW_PENDING , &flow->flags) && !test_bit (NF_FLOW_HW_ESTABLISHED , &flow->flags); }Signature · 1 line
2.39.2
Pablo Neira Ayuso
maintainerQuoted 33 lines · Vlad Buslov
Quoted 23 lines · Pablo Neira Ayuso
Hi Vlad,
Quoted 10 lines · Vlad Buslov
Current
nf_flow_is_outdated()implementation considers any flow table flow which state diverged from its underlying CT connection status for teardown which can be problematic in the following cases:- Flow has never been offloaded to hardware in the first place either because flow table has hardware offload disabled (flag
NF_FLOWTABLE_HW_OFFLOADis not set) or because it is still pending on 'add' workqueue to be offloaded for the first time. The former is incorrect, the later generates excessive deletions and additions of flows.Quoted 7 lines
- Flow is already pending to be updated on the workqueue. Tearing down such flows will also generate excessive removals from the flow table, especially on highly loaded system where the latency to re-offload a flow via 'add' workqueue can be quite high.
When considering a flow for teardown as outdated verify that it is both offloaded to hardware and doesn't have any pending updates.
Thanks.
Quoted 8 lines
I have posted an alternative patch to move the handling of
NF_FLOW_HW_ESTABLISHED, which is specific for sched/act_ct:https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
it is a bit more code, but it makes it easier to understand for the code reader that this bit is net/sched specific.
Quoted 7 lines
Thanks for refactoring this, I agree that separating the act_ct-specific check makes it more obvious.
How would you prefer to solve the conflict with my fix? Should I wait for your patch to be accepted to net, rebase my fix on top and submit V2? Or you can incorporate the checks from my fix together with my signoff and submit it as a single change?
Rebased here as per your request:
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
I took the freedom to take your Signed-off-by: and Paul's Reviewed-by:
which is not the best way to go, but please acknowledge this is fine in this exceptional case.
We can handle this via nf.git tree, there were no plans to send a PR to netdev, but I think these fixes are worth to (try to) get them there in time for the 6.6 release.
Thanks.
Quoted 42 lines · Pablo Neira Ayuso
Quoted 33 lines · Vlad Buslov
Quoted 23 lines · Pablo Neira Ayuso
Hi Vlad,
Quoted 10 lines · Vlad Buslov
Current
nf_flow_is_outdated()implementation considers any flow table flow which state diverged from its underlying CT connection status for teardown which can be problematic in the following cases:- Flow has never been offloaded to hardware in the first place either because flow table has hardware offload disabled (flag
NF_FLOWTABLE_HW_OFFLOADis not set) or because it is still pending on 'add' workqueue to be offloaded for the first time. The former is incorrect, the later generates excessive deletions and additions of flows.Quoted 7 lines
- Flow is already pending to be updated on the workqueue. Tearing down such flows will also generate excessive removals from the flow table, especially on highly loaded system where the latency to re-offload a flow via 'add' workqueue can be quite high.
When considering a flow for teardown as outdated verify that it is both offloaded to hardware and doesn't have any pending updates.
Thanks.
Quoted 8 lines
I have posted an alternative patch to move the handling of
NF_FLOW_HW_ESTABLISHED, which is specific for sched/act_ct:https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
it is a bit more code, but it makes it easier to understand for the code reader that this bit is net/sched specific.
Quoted 7 lines
Thanks for refactoring this, I agree that separating the act_ct-specific check makes it more obvious.
How would you prefer to solve the conflict with my fix? Should I wait for your patch to be accepted to net, rebase my fix on top and submit V2? Or you can incorporate the checks from my fix together with my signoff and submit it as a single change?
Quoted 7 lines
Rebased here as per your request:
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
I took the freedom to take your Signed-off-by: and Paul's Reviewed-by:
which is not the best way to go, but please acknowledge this is fine in this exceptional case.
Ack. Replied to the patch with my signed-off-by. Thanks!
Quoted 6 lines
We can handle this via nf.git tree, there were no plans to send a PR to netdev, but I think these fixes are worth to (try to) get them there in time for the 6.6 release.
Thanks.