Netfilter updates for net-next
Subsystems (3)
Pablo Neira Ayuso
maintainercover Netfilter updates for net-next
Hi,
The following batch contains Netfilter updates for net-next:
1) Split flowtable workqueues per events, from Oz Shlomo.
2) fall-through warnings for clang, from Gustavo A. R. Silva
3) Remove unused declaration in conntrack, from YueHaibing.
4) Consolidate skb_try_make_writable() in flowtable datapath, simplify some of the existing codebase.
5) Call dst_check() to fall back to static classic forwarding path.
6) Update table flags from commit phase.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git
Thanks!
----------------------------------------------------------------
The following changes since commit ebfbc46b35cb70b9fbd88f376d7a33b79f60adff:
openvswitch: Warn over-mtu packets only if iface is UP. (2021-03-16 16:28:30 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git HEAD
for you to fetch changes up to 0ce7cf4127f14078ca598ba9700d813178a59409:
netfilter: nftables: update table flags from the commit phase (2021-03-18 01:35:39 +0100)
----------------------------------------------------------------
Gustavo A. R. Silva (1):
netfilter: Fix fall-through warnings for Clang
Oz Shlomo (1):
netfilter: flowtable: separate replace, destroy and stats to different workqueues
Pablo Neira Ayuso (7):
netfilter: flowtable: consolidate skb_try_make_writable() call
netfilter: flowtable: move skb_try_make_writable() before NAT in IPv4
netfilter: flowtable: move FLOW_OFFLOAD_DIR_MAX away from enumeration
netfilter: flowtable: fast NAT functions never fail
netfilter: flowtable: call dst_check() to fall back to classic forwarding
netfilter: flowtable: refresh timeout after dst and writable checks
netfilter: nftables: update table flags from the commit phase
YueHaibing (1):
netfilter: conntrack: Remove unused variable declaration
include/net/netfilter/ipv6/nf_conntrack_ipv6.h | 3 - include/net/netfilter/nf_flow_table.h | 14 +- include/net/netfilter/nf_tables.h | 9 +- net/netfilter/nf_conntrack_proto_dccp.c | 1 + net/netfilter/nf_flow_table_core.c | 57 ++---- net/netfilter/nf_flow_table_ip.c | 231 ++++++++++--------------- net/netfilter/nf_flow_table_offload.c | 44 ++++- net/netfilter/nf_tables_api.c | 32 ++-- net/netfilter/nft_ct.c | 1 + 9 files changed, 174 insertions(+), 218 deletions(-)
Pablo Neira Ayuso
maintainerPATCH 1/10 netfilter: flowtable: separate replace, destroy and stats to different workqueues
From: Oz Shlomo <[email protected]>
Currently the flow table offload replace, destroy and stats work items are executed on a single workqueue. As such, DESTROY and STATS commands may be backloged after a burst of REPLACE work items. This scenario can bloat up memory and may cause active connections to age.
Instatiate add, del and stats workqueues to avoid backlogs of non-dependent actions. Provide sysfs control over the workqueue attributes, allowing userspace applications to control the workqueue cpumask.
--- net/netfilter/nf_flow_table_offload.c | 44 ++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 8 deletions(-)
net/netfilter/nf_flow_table_offload.c +36 -8
@@ -13,7 +13,9 @@#include <net/netfilter/nf_conntrack_core.h> #include <net/netfilter/nf_conntrack_tuple.h> -static struct workqueue_struct *nf_flow_offload_wq; +static struct workqueue_struct *nf_flow_offload_add_wq; +static struct workqueue_struct *nf_flow_offload_del_wq; +static struct workqueue_struct *nf_flow_offload_stats_wq;struct flow_offload_work {struct list_head list;
@@ -826,7 +828,12 @@ static void flow_offload_work_handler(struct work_struct *work)static void flow_offload_queue_work (struct flow_offload_work *offload) { -queue_work (nf_flow_offload_wq, &offload->work); +if (offload->cmd ==FLOW_CLS_REPLACE ) +queue_work (nf_flow_offload_add_wq, &offload->work); +else if (offload->cmd ==FLOW_CLS_DESTROY ) +queue_work (nf_flow_offload_del_wq, &offload->work); +else +queue_work (nf_flow_offload_stats_wq, &offload->work); } static struct flow_offload_work *
@@ -898,8 +905,11 @@ void nf_flow_offload_stats(struct nf_flowtable *flowtable,void nf_flow_table_offload_flush (struct nf_flowtable *flowtable) { -if (nf_flowtable_hw_offload (flowtable)) -flush_workqueue (nf_flow_offload_wq); +if (nf_flowtable_hw_offload (flowtable)) { +flush_workqueue (nf_flow_offload_add_wq); +flush_workqueue (nf_flow_offload_del_wq); +flush_workqueue (nf_flow_offload_stats_wq); + } } static int nf_flow_table_block_setup(struct nf_flowtable *flowtable,
@@ -1011,15 +1021,33 @@ EXPORT_SYMBOL_GPL(nf_flow_table_offload_setup);int nf_flow_table_offload_init (void ) { - nf_flow_offload_wq =alloc_workqueue ("nf_flow_table_offload" , -WQ_UNBOUND ,0 ); -if (!nf_flow_offload_wq) + nf_flow_offload_add_wq =alloc_workqueue ("nf_ft_offload_add" , +WQ_UNBOUND |WQ_SYSFS ,0 ); +if (!nf_flow_offload_add_wq)return -ENOMEM ; + nf_flow_offload_del_wq =alloc_workqueue ("nf_ft_offload_del" , +WQ_UNBOUND |WQ_SYSFS ,0 ); +if (!nf_flow_offload_del_wq) + goto err_del_wq; + + nf_flow_offload_stats_wq =alloc_workqueue ("nf_ft_offload_stats" , +WQ_UNBOUND |WQ_SYSFS ,0 ); +if (!nf_flow_offload_stats_wq) + goto err_stats_wq; +return 0 ; + +err_stats_wq: +destroy_workqueue (nf_flow_offload_del_wq); +err_del_wq: +destroy_workqueue (nf_flow_offload_add_wq); +return -ENOMEM ; }void nf_flow_table_offload_exit (void ) { -destroy_workqueue (nf_flow_offload_wq); +destroy_workqueue (nf_flow_offload_add_wq); +destroy_workqueue (nf_flow_offload_del_wq); +destroy_workqueue (nf_flow_offload_stats_wq); }
Signature · 1 line
2.20.1
Re: [PATCH net-next 01/10] netfilter: flowtable: separate replace, destroy and stats to different workqueues
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Tue, 23 Mar 2021 00:56:19 +0100 you wrote:
From: Oz Shlomo <[email protected]>
Currently the flow table offload replace, destroy and stats work items are executed on a single workqueue. As such, DESTROY and STATS commands may be backloged after a burst of REPLACE work items. This scenario can bloat up memory and may cause active connections to age.
[...]
Here is the summary with links:
- [net-next,01/10] netfilter: flowtable: separate replace, destroy and stats to different workqueues
https://git.kernel.org/netdev/net-next/c/2ed37183abb7 - [net-next,02/10] netfilter: Fix fall-through warnings for Clang https://git.kernel.org/netdev/net-next/c/c2168e6bd7ec - [net-next,03/10] netfilter: conntrack: Remove unused variable declaration https://git.kernel.org/netdev/net-next/c/d4a96be65423 - [net-next,04/10] netfilter: flowtable: consolidate skb_try_make_writable() call https://git.kernel.org/netdev/net-next/c/2fc11745c3ff - [net-next,05/10] netfilter: flowtable: move skb_try_make_writable() before NAT in IPv4 https://git.kernel.org/netdev/net-next/c/2babb46c8c82 - [net-next,06/10] netfilter: flowtable: move FLOW_OFFLOAD_DIR_MAX away from enumeration https://git.kernel.org/netdev/net-next/c/4f08f173d08c - [net-next,07/10] netfilter: flowtable: fast NAT functions never fail https://git.kernel.org/netdev/net-next/c/f4401262b927 - [net-next,08/10] netfilter: flowtable: call dst_check() to fall back to classic forwarding https://git.kernel.org/netdev/net-next/c/e5075c0badaa - [net-next,09/10] netfilter: flowtable: refresh timeout after dst and writable checks https://git.kernel.org/netdev/net-next/c/1b9cd7690a1e - [net-next,10/10] netfilter: nftables: update table flags from the commit phase https://git.kernel.org/netdev/net-next/c/0ce7cf4127f1
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Pablo Neira Ayuso
maintainerPATCH 2/10 netfilter: Fix fall-through warnings for Clang
In reply to Pablo Neira AyusoFrom: "Gustavo A. R. Silva" <[email protected]>
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple break statements instead of just letting the code fall through to the next case.
--- net/netfilter/nf_conntrack_proto_dccp.c | 1 + net/netfilter/nf_tables_api.c | 1 + net/netfilter/nft_ct.c | 1 + 3 files changed, 3 insertions(+)
net/netfilter/nf_conntrack_proto_dccp.c +1 -0
@@ -397,6 +397,7 @@ dccp_new(struct nf_conn *ct, const struct sk_buff *skb, msg ="not picking up existing connection " ; goto out_invalid; } +break ;case CT_DCCP_REQUEST :break ;case CT_DCCP_INVALID :
net/netfilter/nf_tables_api.c +1 -0
@@ -8557,6 +8557,7 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx, data->verdict.chain);if (err <0 )return err; +break ;default :break ; }
net/netfilter/nft_ct.c +1 -0
@@ -527,6 +527,7 @@ static void __nft_ct_set_destroy(const struct nft_ctx *ctx, struct nft_ct *priv)case NFT_CT_ZONE :if (--nft_ct_pcpu_template_refcnt ==0 )nft_ct_tmpl_put_pcpu (); +break ;#endif default :break ;
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 3/10 netfilter: conntrack: Remove unused variable declaration
In reply to Pablo Neira AyusoFrom: YueHaibing <[email protected]>
commit e97c3e278e95 ("tproxy: split off ipv6 defragmentation to a separate module") left behind this.
--- include/net/netfilter/ipv6/nf_conntrack_ipv6.h | 3 --- 1 file changed, 3 deletions(-)
include/net/netfilter/ipv6/nf_conntrack_ipv6.h +0 -3
@@ -4,7 +4,4 @@extern const struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6; -#include <linux/sysctl.h> -extern struct ctl_table nf_ct_ipv6_sysctl_table[]; -#endif /* _NF_CONNTRACK_IPV6_H*/
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 4/10 netfilter: flowtable: consolidate skb_try_make_writable() call
In reply to Pablo Neira AyusoFetch the layer 4 header size to be mangled by NAT when building the tuple, then use it to make writable the network and the transport headers. After this update, the NAT routines now assumes that the skbuff area is writable. Do the pointer refetch only after the single skb_try_make_writable() call.
--- net/netfilter/nf_flow_table_core.c | 12 ----- net/netfilter/nf_flow_table_ip.c | 74 +++++++++++++----------------- 2 files changed, 31 insertions(+), 55 deletions(-)
net/netfilter/nf_flow_table_core.c +0 -12
@@ -395,9 +395,6 @@ static int nf_flow_nat_port_tcp(struct sk_buff *skb, unsigned int thoff, {struct tcphdr *tcph; -if (skb_try_make_writable (skb, thoff +sizeof (*tcph))) -return -1 ; - tcph = (void *)(skb_network_header (skb) + thoff);inet_proto_csum_replace2 (&tcph->check, skb, port, new_port, false);
@@ -409,9 +406,6 @@ static int nf_flow_nat_port_udp(struct sk_buff *skb, unsigned int thoff, {struct udphdr *udph; -if (skb_try_make_writable (skb, thoff +sizeof (*udph))) -return -1 ; - udph = (void *)(skb_network_header (skb) + thoff);if (udph->check || skb->ip_summed ==CHECKSUM_PARTIAL ) { inet_proto_csum_replace2(&udph->check, skb, port,
@@ -447,9 +441,6 @@ int nf_flow_snat_port(const struct flow_offload *flow,struct flow_ports *hdr;__be16 port, new_port; -if (skb_try_make_writable (skb, thoff +sizeof (*hdr))) -return -1 ; - hdr = (void *)(skb_network_header (skb) + thoff);switch (dir) {
@@ -478,9 +469,6 @@ int nf_flow_dnat_port(const struct flow_offload *flow,struct flow_ports *hdr;__be16 port, new_port; -if (skb_try_make_writable (skb, thoff +sizeof (*hdr))) -return -1 ; - hdr = (void *)(skb_network_header (skb) + thoff);switch (dir) {
net/netfilter/nf_flow_table_ip.c +31 -43
217 lines not on this page · raw message
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 5/10 netfilter: flowtable: move skb_try_make_writable() before NAT in IPv4
In reply to Pablo Neira AyusoFor consistency with the IPv6 flowtable datapath and to make sure the skbuff is writable right before the NAT header updates.
--- net/netfilter/nf_flow_table_ip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/netfilter/nf_flow_table_ip.c +4 -4
@@ -266,10 +266,6 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb, iph =ip_hdr (skb); thoff = iph->ihl *4 ; -if (skb_try_make_writable (skb, thoff + hdrsize)) -return NF_DROP ; - - iph =ip_hdr (skb);if (nf_flow_state_check (flow, iph->protocol, skb, thoff))return NF_ACCEPT ;
@@ -280,6 +276,10 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb,return NF_ACCEPT ; } +if (skb_try_make_writable (skb, thoff + hdrsize)) +return NF_DROP ; + + iph =ip_hdr (skb);if (nf_flow_nat_ip (flow, skb, thoff, dir, iph) <0 )return NF_DROP ;
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 6/10 netfilter: flowtable: move FLOW_OFFLOAD_DIR_MAX away from enumeration
In reply to Pablo Neira AyusoThis allows to remove the default case which should not ever happen and that was added to avoid gcc warnings on unhandled FLOW_OFFLOAD_DIR_MAX enumeration case.
--- include/net/netfilter/nf_flow_table.h | 2 +- net/netfilter/nf_flow_table_core.c | 4 ---- net/netfilter/nf_flow_table_ip.c | 8 -------- 3 files changed, 1 insertion(+), 13 deletions(-)
include/net/netfilter/nf_flow_table.h +1 -1
@@ -86,8 +86,8 @@ static inline bool nf_flowtable_hw_offload(struct nf_flowtable *flowtable)enum flow_offload_tuple_dir {FLOW_OFFLOAD_DIR_ORIGINAL =IP_CT_DIR_ORIGINAL ,FLOW_OFFLOAD_DIR_REPLY =IP_CT_DIR_REPLY , -FLOW_OFFLOAD_DIR_MAX =IP_CT_DIR_MAX }; +#define FLOW_OFFLOAD_DIR_MAX IP_CT_DIR_MAX struct flow_offload_tuple { union {
net/netfilter/nf_flow_table_core.c +0 -4
@@ -454,8 +454,6 @@ int nf_flow_snat_port(const struct flow_offload *flow, new_port = flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL ].tuple.src_port; hdr->dest = new_port;break ; -default : -return -1 ; }return nf_flow_nat_port (skb, thoff, protocol, port, new_port);
@@ -482,8 +480,6 @@ int nf_flow_dnat_port(const struct flow_offload *flow, new_port = flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL ].tuple.dst_port; hdr->source = new_port;break ; -default : -return -1 ; }return nf_flow_nat_port (skb, thoff, protocol, port, new_port);
net/netfilter/nf_flow_table_ip.c +0 -8
@@ -96,8 +96,6 @@ static int nf_flow_snat_ip(const struct flow_offload *flow, struct sk_buff *skb, new_addr = flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL ].tuple.src_v4.s_addr; iph->daddr = new_addr;break ; -default : -return -1 ; }csum_replace4 (&iph->check, addr, new_addr);
@@ -121,8 +119,6 @@ static int nf_flow_dnat_ip(const struct flow_offload *flow, struct sk_buff *skb, new_addr = flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL ].tuple.dst_v4.s_addr; iph->saddr = new_addr;break ; -default : -return -1 ; }csum_replace4 (&iph->check, addr, new_addr);
@@ -371,8 +367,6 @@ static int nf_flow_snat_ipv6(const struct flow_offload *flow, new_addr = flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL ].tuple.src_v6; ip6h->daddr = new_addr;break ; -default : -return -1 ; }return nf_flow_nat_ipv6_l4proto (skb, ip6h, thoff, &addr, &new_addr);
@@ -396,8 +390,6 @@ static int nf_flow_dnat_ipv6(const struct flow_offload *flow, new_addr = flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL ].tuple.dst_v6; ip6h->saddr = new_addr;break ; -default : -return -1 ; }return nf_flow_nat_ipv6_l4proto (skb, ip6h, thoff, &addr, &new_addr);
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 7/10 netfilter: flowtable: fast NAT functions never fail
In reply to Pablo Neira AyusoSimplify existing fast NAT routines by returning void. After the skb_try_make_writable() call consolidation, these routines cannot ever fail.
--- include/net/netfilter/nf_flow_table.h | 12 +-- net/netfilter/nf_flow_table_core.c | 41 +++---- net/netfilter/nf_flow_table_ip.c | 147 +++++++++++--------------- 3 files changed, 84 insertions(+), 116 deletions(-)
include/net/netfilter/nf_flow_table.h +6 -6
@@ -229,12 +229,12 @@ void nf_flow_table_free(struct nf_flowtable *flow_table);void flow_offload_teardown (struct flow_offload *flow); -int nf_flow_snat_port (const struct flow_offload *flow, -struct sk_buff *skb,unsigned int thoff, -u8 protocol,enum flow_offload_tuple_dir dir); -int nf_flow_dnat_port (const struct flow_offload *flow, -struct sk_buff *skb,unsigned int thoff, -u8 protocol,enum flow_offload_tuple_dir dir); +void nf_flow_snat_port (const struct flow_offload *flow, +struct sk_buff *skb,unsigned int thoff, +u8 protocol,enum flow_offload_tuple_dir dir); +void nf_flow_dnat_port (const struct flow_offload *flow, +struct sk_buff *skb,unsigned int thoff, +u8 protocol,enum flow_offload_tuple_dir dir);struct flow_ports {__be16 source, dest;
net/netfilter/nf_flow_table_core.c +16 -25
86 lines not on this page · raw message
net/netfilter/nf_flow_table_ip.c +62 -85
258 lines not on this page · raw message
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 8/10 netfilter: flowtable: call dst_check() to fall back to classic forwarding
In reply to Pablo Neira AyusoIn case the route is stale, pass up the packet to the classic forwarding path for re-evaluation and schedule this flow entry for removal.
--- net/netfilter/nf_flow_table_ip.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
net/netfilter/nf_flow_table_ip.c +2 -10
@@ -197,14 +197,6 @@ static bool nf_flow_exceeds_mtu(const struct sk_buff *skb, unsigned int mtu)return true; } -static int nf_flow_offload_dst_check (struct dst_entry *dst) -{ -if (unlikely (dst_xfrm (dst))) -return dst_check (dst,0 ) ?0 :-1 ; - -return 0 ; -} -static unsigned int nf_flow_xmit_xfrm (struct sk_buff *skb,const struct nf_hook_state *state,struct dst_entry *dst)
@@ -256,7 +248,7 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb,flow_offload_refresh (flow_table, flow); -if (nf_flow_offload_dst_check (&rt->dst)) { +if (!dst_check (&rt->dst,0 )) {flow_offload_teardown (flow);return NF_ACCEPT ; }
@@ -476,7 +468,7 @@ nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb,flow_offload_refresh (flow_table, flow); -if (nf_flow_offload_dst_check (&rt->dst)) { +if (!dst_check (&rt->dst,0 )) {flow_offload_teardown (flow);return NF_ACCEPT ; }
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 9/10 netfilter: flowtable: refresh timeout after dst and writable checks
In reply to Pablo Neira AyusoRefresh the timeout (and retry hardware offload) once the skbuff dst is confirmed to be current and after the skbuff is made writable.
--- net/netfilter/nf_flow_table_ip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/netfilter/nf_flow_table_ip.c +4 -4
@@ -246,8 +246,6 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb,if (nf_flow_state_check (flow, iph->protocol, skb, thoff))return NF_ACCEPT ; -flow_offload_refresh (flow_table, flow); -if (!dst_check (&rt->dst,0 )) {flow_offload_teardown (flow);return NF_ACCEPT ;
@@ -256,6 +254,8 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb,if (skb_try_make_writable (skb, thoff + hdrsize))return NF_DROP ; +flow_offload_refresh (flow_table, flow); + iph =ip_hdr (skb);nf_flow_nat_ip (flow, skb, thoff, dir, iph);
@@ -466,8 +466,6 @@ nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb, sizeof(*ip6h)))return NF_ACCEPT ; -flow_offload_refresh (flow_table, flow); -if (!dst_check (&rt->dst,0 )) {flow_offload_teardown (flow);return NF_ACCEPT ;
@@ -476,6 +474,8 @@ nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb,if (skb_try_make_writable (skb,sizeof (*ip6h) + hdrsize))return NF_DROP ; +flow_offload_refresh (flow_table, flow); + ip6h =ipv6_hdr (skb);nf_flow_nat_ipv6 (flow, skb, dir, ip6h);
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 10/10 netfilter: nftables: update table flags from the commit phase
In reply to Pablo Neira AyusoDo not update table flags from the preparation phase. Store the flags update into the transaction, then update the flags from the commit phase.
--- include/net/netfilter/nf_tables.h | 9 ++++++--- net/netfilter/nf_tables_api.c | 31 ++++++++++++++++--------------- 2 files changed, 22 insertions(+), 18 deletions(-)
include/net/netfilter/nf_tables.h +6 -3
@@ -1498,13 +1498,16 @@ struct nft_trans_chain {struct nft_trans_table {bool update; -bool enable; +u8 state; +u32 flags; };#define nft_trans_table_update (trans) \ (((struct nft_trans_table *)trans->data)->update) -#define nft_trans_table_enable (trans) \ - (((struct nft_trans_table *)trans->data)->enable) +#define nft_trans_table_state (trans) \ + (((struct nft_trans_table *)trans->data)->state) +#define nft_trans_table_flags (trans) \ + (((struct nft_trans_table *)trans->data)->flags)struct nft_trans_elem {struct nft_set *set;
net/netfilter/nf_tables_api.c +16 -15
@@ -900,6 +900,12 @@ static void nf_tables_table_disable(struct net *net, struct nft_table *table)nft_table_disable (net, table,0 ); } +enum { +NFT_TABLE_STATE_UNCHANGED =0 , +NFT_TABLE_STATE_DORMANT , +NFT_TABLE_STATE_WAKEUP +}; +static int nf_tables_updtable (struct nft_ctx *ctx) {struct nft_trans *trans;
@@ -929,19 +935,17 @@ static int nf_tables_updtable(struct nft_ctx *ctx)if ((flags &NFT_TABLE_F_DORMANT ) && !(ctx->table->flags &NFT_TABLE_F_DORMANT )) { -nft_trans_table_enable (trans) = false; +nft_trans_table_state (trans) =NFT_TABLE_STATE_DORMANT ; }else if (!(flags &NFT_TABLE_F_DORMANT ) && ctx->table->flags &NFT_TABLE_F_DORMANT ) { - ctx->table->flags &= ~NFT_TABLE_F_DORMANT ; ret =nf_tables_table_enable (ctx->net, ctx->table);if (ret >=0 ) -nft_trans_table_enable (trans) = true; -else - ctx->table->flags |=NFT_TABLE_F_DORMANT ; +nft_trans_table_state (trans) =NFT_TABLE_STATE_WAKEUP ; }if (ret <0 ) goto err; +nft_trans_table_flags (trans) = flags;nft_trans_table_update (trans) = true;list_add_tail (&trans->list, &ctx->net->nft.commit_list);return 0 ;
@@ -8068,11 +8072,10 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)switch (trans->msg_type) {case NFT_MSG_NEWTABLE :if (nft_trans_table_update (trans)) { -if (!nft_trans_table_enable (trans)) { -nf_tables_table_disable (net, - trans->ctx.table); - trans->ctx.table->flags |=NFT_TABLE_F_DORMANT ; - } +if (nft_trans_table_state (trans) ==NFT_TABLE_STATE_DORMANT ) +nf_tables_table_disable (net, trans->ctx.table); + + trans->ctx.table->flags =nft_trans_table_flags (trans); }else {nft_clear (net, trans->ctx.table); }
@@ -8283,11 +8286,9 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)switch (trans->msg_type) {case NFT_MSG_NEWTABLE :if (nft_trans_table_update (trans)) { -if (nft_trans_table_enable (trans)) { -nf_tables_table_disable (net, - trans->ctx.table); - trans->ctx.table->flags |=NFT_TABLE_F_DORMANT ; - } +if (nft_trans_table_state (trans) ==NFT_TABLE_STATE_WAKEUP ) +nf_tables_table_disable (net, trans->ctx.table); +nft_trans_destroy (trans); }else {list_del_rcu (&trans->ctx.table->list);
Signature · 1 line
2.20.1