netfilter: updates for net-next
Subsystems (6)
Florian Westphal
maintainercover netfilter: updates for net-next
Hi,
The following patchset contains Netfilter fixes for *net-next*, including IPVS updates from and via Julian Anastasov.
First updates for IPVS. From Julians cover-letter:
* Convert the global __ip_vs_mutex to per-net service_mutex and switch the service tables to be per-net, cowork by Jiejian Wu and Dust Li
* Convert some code that walks the service lists to use RCU instead of the service_mutex
* We used two tables for services (non-fwmark and fwmark), merge them into single svc_table
* The list for unavailable destinations (dest_trash) holds dsts and thus dev references causing extra work for the ip_vs_dst_event() dev notifier handler. Change this by dropping the reference when dest is removed and saved into dest_trash. The dest_trash will need more changes to make it light for lookups. TODO.
* On new connection we can do multiple lookups for services by trying different fallback options. Add more counters for service types, so that we can avoid unneeded lookups for services.
* The no_cport and dropentry counters can be per-net and also we can avoid extra conn lookups
Then, a few cleanups for nf_tables:
* keep BH enabled during nft_set_rbtree inserts, this is possible because the root lock is now only taken from control plane.
* toss a few EXPORT_SYMBOLs from nf_tables; these were historic leftovers from back in the day when e.g. set backends were still residing in their own modules.
* remove the register tracking infra from nftables. It was disabled years ago in 5.18 and there are no plans to salvage this work; the idea was good (remove redundant register stores), but there is just one too many pitfalls, and better rule structuring (verdict maps) largely avoids the scenarios where this would have helped.
Florian Westphal (3):
netfilter: nft_set_rbtree: don't disable bh when acquiring tree lock
netfilter: nf_tables: drop obsolete EXPORT_SYMBOLs
netfilter: nf_tables: remove register tracking infrastructure
Jiejian Wu (1):
ipvs: make ip_vs_svc_table and ip_vs_svc_fwm_table per netns
Julian Anastasov (5):
ipvs: some service readers can use RCU
ipvs: use single svc table
ipvs: do not keep dest_dst after dest is removed
ipvs: use more counters to avoid service lookups
ipvs: no_cport and dropentry counters can be per-net
include/net/ip_vs.h | 39 ++- include/net/netfilter/nf_tables.h | 32 -- include/net/netfilter/nft_fib.h | 2 - include/net/netfilter/nft_meta.h | 3 - net/bridge/netfilter/nft_meta_bridge.c | 20 -- net/bridge/netfilter/nft_reject_bridge.c | 1 - net/ipv4/netfilter/nft_dup_ipv4.c | 1 - net/ipv4/netfilter/nft_fib_ipv4.c | 2 - net/ipv4/netfilter/nft_reject_ipv4.c | 1 - net/ipv6/netfilter/nft_dup_ipv6.c | 1 - net/ipv6/netfilter/nft_fib_ipv6.c | 2 - net/ipv6/netfilter/nft_reject_ipv6.c | 1 - net/netfilter/ipvs/ip_vs_conn.c | 64 ++-- net/netfilter/ipvs/ip_vs_core.c | 2 +- net/netfilter/ipvs/ip_vs_ctl.c | 368 ++++++++--------------- net/netfilter/ipvs/ip_vs_est.c | 18 +- net/netfilter/ipvs/ip_vs_xmit.c | 12 +- net/netfilter/nf_tables_api.c | 78 ----- net/netfilter/nft_bitwise.c | 104 ------- net/netfilter/nft_byteorder.c | 11 - net/netfilter/nft_cmp.c | 3 - net/netfilter/nft_compat.c | 10 - net/netfilter/nft_connlimit.c | 1 - net/netfilter/nft_counter.c | 1 - net/netfilter/nft_ct.c | 46 --- net/netfilter/nft_dup_netdev.c | 1 - net/netfilter/nft_dynset.c | 1 - net/netfilter/nft_exthdr.c | 34 --- net/netfilter/nft_fib.c | 42 --- net/netfilter/nft_fib_inet.c | 1 - net/netfilter/nft_fib_netdev.c | 1 - net/netfilter/nft_flow_offload.c | 1 - net/netfilter/nft_fwd_netdev.c | 2 - net/netfilter/nft_hash.c | 36 --- net/netfilter/nft_immediate.c | 12 - net/netfilter/nft_last.c | 1 - net/netfilter/nft_limit.c | 2 - net/netfilter/nft_log.c | 1 - net/netfilter/nft_lookup.c | 12 - net/netfilter/nft_masq.c | 3 - net/netfilter/nft_meta.c | 45 --- net/netfilter/nft_nat.c | 2 - net/netfilter/nft_numgen.c | 22 -- net/netfilter/nft_objref.c | 2 - net/netfilter/nft_osf.c | 25 -- net/netfilter/nft_payload.c | 47 --- net/netfilter/nft_queue.c | 2 - net/netfilter/nft_quota.c | 1 - net/netfilter/nft_range.c | 1 - net/netfilter/nft_redir.c | 3 - net/netfilter/nft_reject_inet.c | 1 - net/netfilter/nft_reject_netdev.c | 1 - net/netfilter/nft_rt.c | 1 - net/netfilter/nft_set_rbtree.c | 23 +- net/netfilter/nft_socket.c | 26 -- net/netfilter/nft_synproxy.c | 1 - net/netfilter/nft_tproxy.c | 1 - net/netfilter/nft_tunnel.c | 26 -- net/netfilter/nft_xfrm.c | 27 -- 59 files changed, 221 insertions(+), 1009 deletions(-)
Signature · 1 line
2.52.0
Florian Westphal
maintainerPATCH 1/9 ipvs: make ip_vs_svc_table and ip_vs_svc_fwm_table per netns
From: Jiejian Wu <[email protected]>
Current ipvs uses one global mutex "__ip_vs_mutex" to keep the global "ip_vs_svc_table" and "ip_vs_svc_fwm_table" safe. But when there are tens of thousands of services from different netns in the table, it takes a long time to look up the table, for example, using "ipvsadm -ln" from different netns simultaneously.
We make "ip_vs_svc_table" and "ip_vs_svc_fwm_table" per netns, and we add "service_mutex" per netns to keep these two tables safe instead of the global "__ip_vs_mutex" in current version. To this end, looking up services from different netns simultaneously will not get stuck, shortening the time consumption in large-scale deployment. It can be reproduced using the simple scripts below.
init.sh: #!/bin/bash
for((i=1;i<=4;i++));do
ip netns add ns$i
ip netns exec ns$i ip link set dev lo up
ip netns exec ns$i sh add-services.sh
done
add-services.sh: #!/bin/bash
for((i=0;i<30000;i++)); do
ipvsadm -A -t 10.10.10.10:$((80+$i)) -s rr
done
runtest.sh: #!/bin/bash for((i=1;i<4;i++));do
ip netns exec ns$i ipvsadm -ln > /dev/null &
done
ip netns exec ns4 ipvsadm -ln > /dev/null
Run "sh init.sh" to initiate the network environment. Then run "time ./runtest.sh" to evaluate the time consumption. Our testbed is a 4-core Intel Xeon ECS. The result of the original version is around 8 seconds, while the result of the modified version is only 0.8 seconds.
--- include/net/ip_vs.h | 13 +++ net/netfilter/ipvs/ip_vs_ctl.c | 167 ++++++++++++++------------------- net/netfilter/ipvs/ip_vs_est.c | 18 ++-- 3 files changed, 94 insertions(+), 104 deletions(-)
include/net/ip_vs.h +13 -0
@@ -33,6 +33,12 @@#define IP_VS_HDR_INVERSE 1#define IP_VS_HDR_ICMP 2 +/* +* Hash table: for virtual service lookups +*/ +#define IP_VS_SVC_TAB_BITS 8 +#define IP_VS_SVC_TAB_SIZE BIT(IP_VS_SVC_TAB_BITS) +#define IP_VS_SVC_TAB_MASK (IP_VS_SVC_TAB_SIZE - 1)/* Generic access of ipvs struct */ static inline struct netns_ipvs *net_ipvs (struct net * net)
@@ -1041,6 +1047,13 @@ struct netns_ipvs {*/ unsigned int mixed_address_family_dests;unsigned int hooks_afmask;/* &1=AF_INET, &2=AF_INET6 */ + +/* the service mutex that protect svc_table and svc_fwm_table */ +struct mutex service_mutex; +/* the service table hashed by <protocol, addr, port> */ +struct hlist_head svc_table[IP_VS_SVC_TAB_SIZE ]; +/* the service table hashed by fwmark */ +struct hlist_head svc_fwm_table[IP_VS_SVC_TAB_SIZE ]; };#define DEFAULT_SYNC_THRESHOLD 3
net/netfilter/ipvs/ip_vs_ctl.c +72 -95
423 lines not on this page · raw message
net/netfilter/ipvs/ip_vs_est.c +9 -9
@@ -602,7 +602,7 @@ static void ip_vs_est_drain_temp_list(struct netns_ipvs *ipvs)while (1 ) {int max =16 ; -mutex_lock (&__ip_vs_mutex); +mutex_lock (&ipvs->service_mutex);while (max-- >0 ) { est = hlist_entry_safe(ipvs->est_temp_list.first,
@@ -622,12 +622,12 @@ static void ip_vs_est_drain_temp_list(struct netns_ipvs *ipvs) } goto unlock; } -mutex_unlock (&__ip_vs_mutex); +mutex_unlock (&ipvs->service_mutex);cond_resched (); } unlock: -mutex_unlock (&__ip_vs_mutex); +mutex_unlock (&ipvs->service_mutex); }/* Calculate limits for all kthreads */
@@ -647,9 +647,9 @@ static int ip_vs_est_calc_limits(struct netns_ipvs *ipvs, int *chain_max)u64 val;INIT_HLIST_HEAD (&chain); -mutex_lock (&__ip_vs_mutex); +mutex_lock (&ipvs->service_mutex); kd = ipvs->est_kt_arr[0 ]; -mutex_unlock (&__ip_vs_mutex); +mutex_unlock (&ipvs->service_mutex); s = kd ? kd->calc_stats :NULL ;if (!s) goto out;
@@ -748,7 +748,7 @@ static void ip_vs_est_calc_phase(struct netns_ipvs *ipvs)if (!ip_vs_est_calc_limits (ipvs, &chain_max))return ; -mutex_lock (&__ip_vs_mutex); +mutex_lock (&ipvs->service_mutex);/* Stop all other tasks, so that we can immediately move the * estimators to est_temp_list without RCU grace period
@@ -815,9 +815,9 @@ static void ip_vs_est_calc_phase(struct netns_ipvs *ipvs)/* Give chance estimators to be added (to est_temp_list) * and deleted (releasing kthread contexts) */ -mutex_unlock (&__ip_vs_mutex); +mutex_unlock (&ipvs->service_mutex);cond_resched (); -mutex_lock (&__ip_vs_mutex); +mutex_lock (&ipvs->service_mutex);/* Current kt released ? */ if (id >= ipvs->est_kt_count)
@@ -893,7 +893,7 @@ static void ip_vs_est_calc_phase(struct netns_ipvs *ipvs)mutex_unlock (&ipvs->est_mutex); unlock: -mutex_unlock (&__ip_vs_mutex); +mutex_unlock (&ipvs->service_mutex); }void ip_vs_zero_estimator (struct ip_vs_stats *stats)
Signature · 1 line
2.52.0
Florian Westphal
maintainerPATCH 2/9 ipvs: some service readers can use RCU
In reply to Florian WestphalFrom: Julian Anastasov <[email protected]>
Some places walk the services under mutex but they can just use RCU:
* ip_vs_dst_event() uses ip_vs_forget_dev() which uses its own lock to modify dest
* ip_vs_genl_dump_services(): ip_vs_genl_fill_service() just fills skb
* ip_vs_genl_parse_service(): move RCU lock to callers ip_vs_genl_set_cmd(), ip_vs_genl_dump_dests() and ip_vs_genl_get_cmd()
* ip_vs_genl_dump_dests(): just fill skb
--- net/netfilter/ipvs/ip_vs_ctl.c | 47 +++++++++++++++++----------------- 1 file changed, 23 insertions(+), 24 deletions(-)
net/netfilter/ipvs/ip_vs_ctl.c +23 -24
@@ -1758,23 +1758,21 @@ static int ip_vs_dst_event(struct notifier_block *this, unsigned long event,if (event !=NETDEV_DOWN || !ipvs)return NOTIFY_DONE ;IP_VS_DBG (3 ,"%s() dev=%s\n" , __func__, dev->name); -mutex_lock (&ipvs->service_mutex); +rcu_read_lock ();for (idx =0 ; idx <IP_VS_SVC_TAB_SIZE ; idx++) { -hlist_for_each_entry (svc, &ipvs->svc_table[idx], s_list) { -list_for_each_entry (dest, &svc->destinations, - n_list) { +hlist_for_each_entry_rcu (svc, &ipvs->svc_table[idx], s_list) +list_for_each_entry_rcu (dest, &svc->destinations, + n_list)ip_vs_forget_dev (dest, dev); - } - } -hlist_for_each_entry (svc, &ipvs->svc_fwm_table[idx], f_list) { -list_for_each_entry (dest, &svc->destinations, - n_list) { +hlist_for_each_entry_rcu (svc, &ipvs->svc_fwm_table[idx], f_list) +list_for_each_entry_rcu (dest, &svc->destinations, + n_list)ip_vs_forget_dev (dest, dev); - } - } } +rcu_read_unlock (); +mutex_lock (&ipvs->service_mutex);spin_lock_bh (&ipvs->dest_trash_lock);list_for_each_entry (dest, &ipvs->dest_trash, t_list) {ip_vs_forget_dev (dest, dev);
@@ -3317,9 +3315,9 @@ static int ip_vs_genl_fill_service(struct sk_buff *skb, goto nla_put_failure; } - sched =rcu_dereference_protected (svc->scheduler,1 ); + sched =rcu_dereference (svc->scheduler); sched_name = sched ? sched->name :"none" ; - pe =rcu_dereference_protected (svc->pe,1 ); + pe =rcu_dereference (svc->pe); if (nla_put_string(skb, IPVS_SVC_ATTR_SCHED_NAME, sched_name) || (pe && nla_put_string(skb, IPVS_SVC_ATTR_PE_NAME, pe->name)) || nla_put(skb, IPVS_SVC_ATTR_FLAGS, sizeof(flags), &flags) ||
@@ -3373,9 +3371,9 @@ static int ip_vs_genl_dump_services(struct sk_buff *skb,struct net *net =sock_net (skb->sk);struct netns_ipvs *ipvs =net_ipvs (net); -mutex_lock (&ipvs->service_mutex); +rcu_read_lock ();for (i =0 ; i <IP_VS_SVC_TAB_SIZE ; i++) { -hlist_for_each_entry (svc, &ipvs->svc_table[i], s_list) { +hlist_for_each_entry_rcu (svc, &ipvs->svc_table[i], s_list) {if (++idx <= start)continue ;if (ip_vs_genl_dump_service (skb, svc, cb) <0 ) {
@@ -3386,7 +3384,7 @@ static int ip_vs_genl_dump_services(struct sk_buff *skb, }for (i =0 ; i <IP_VS_SVC_TAB_SIZE ; i++) { -hlist_for_each_entry (svc, &ipvs->svc_fwm_table[i], f_list) { +hlist_for_each_entry_rcu (svc, &ipvs->svc_fwm_table[i], f_list) {if (++idx <= start)continue ;if (ip_vs_genl_dump_service (skb, svc, cb) <0 ) {
@@ -3397,7 +3395,7 @@ static int ip_vs_genl_dump_services(struct sk_buff *skb, } nla_put_failure: -mutex_unlock (&ipvs->service_mutex); +rcu_read_unlock (); cb->args[0 ] = idx;return skb->len;
@@ -3453,13 +3451,11 @@ static int ip_vs_genl_parse_service(struct netns_ipvs *ipvs, usvc->fwmark =0 ; } -rcu_read_lock ();if (usvc->fwmark) svc =__ip_vs_svc_fwm_find (ipvs, usvc->af, usvc->fwmark);else svc =__ip_vs_service_find (ipvs, usvc->af, usvc->protocol, &usvc->addr, usvc->port); -rcu_read_unlock (); *ret_svc = svc;/* If a full entry was requested, check for the additional fields */
@@ -3586,7 +3582,7 @@ static int ip_vs_genl_dump_dests(struct sk_buff *skb,struct net *net =sock_net (skb->sk);struct netns_ipvs *ipvs =net_ipvs (net); -mutex_lock (&ipvs->service_mutex); +rcu_read_lock ();/* Try to find the service for which to dump destinations */ if (nlmsg_parse_deprecated (cb->nlh,GENL_HDRLEN , attrs,IPVS_CMD_ATTR_MAX , ip_vs_cmd_policy, cb->extack))
@@ -3598,7 +3594,7 @@ static int ip_vs_genl_dump_dests(struct sk_buff *skb, goto out_err;/* Dump the destinations */ -list_for_each_entry (dest, &svc->destinations, n_list) { +list_for_each_entry_rcu (dest, &svc->destinations, n_list) {if (++idx <= start)continue ;if (ip_vs_genl_dump_dest (skb, dest, cb) <0 ) {
@@ -3611,7 +3607,7 @@ static int ip_vs_genl_dump_dests(struct sk_buff *skb, cb->args[0 ] = idx; out_err: -mutex_unlock (&ipvs->service_mutex); +rcu_read_unlock ();return skb->len; }
@@ -3914,9 +3910,12 @@ static int ip_vs_genl_set_cmd(struct sk_buff *skb, struct genl_info *info)if (cmd ==IPVS_CMD_NEW_SERVICE || cmd ==IPVS_CMD_SET_SERVICE ) need_full_svc = true; +/* We use function that requires RCU lock (hlist_bl) */ +rcu_read_lock (); ret =ip_vs_genl_parse_service (ipvs, &usvc, info->attrs[IPVS_CMD_ATTR_SERVICE ], need_full_svc, &svc); +rcu_read_unlock ();if (ret) goto out;
@@ -4036,7 +4035,7 @@ static int ip_vs_genl_get_cmd(struct sk_buff *skb, struct genl_info *info)if (!msg)return -ENOMEM ; -mutex_lock (&ipvs->service_mutex); +rcu_read_lock (); reply =genlmsg_put_reply (msg, info, &ip_vs_genl_family,0 , reply_cmd);if (reply ==NULL )
@@ -4104,7 +4103,7 @@ static int ip_vs_genl_get_cmd(struct sk_buff *skb, struct genl_info *info) out_err:nlmsg_free (msg); out: -mutex_unlock (&ipvs->service_mutex); +rcu_read_unlock ();return ret; }
Signature · 1 line
2.52.0
Florian Westphal
maintainerPATCH 3/9 ipvs: use single svc table
In reply to Florian WestphalFrom: Julian Anastasov <[email protected]>
fwmark based services and non-fwmark based services can be hashed in same service table. This reduces the burden of working with two tables.
--- include/net/ip_vs.h | 8 +- net/netfilter/ipvs/ip_vs_ctl.c | 146 +++++---------------------------- 2 files changed, 22 insertions(+), 132 deletions(-)
include/net/ip_vs.h +2 -6
@@ -679,8 +679,7 @@ struct ip_vs_dest_user_kern {* forwarding entries. */ struct ip_vs_service { -struct hlist_node s_list;/* for normal service table */ -struct hlist_node f_list;/* for fwmark-based service table */ +struct hlist_node s_list;/* node in service table */ atomic_t refcnt;/* reference counter */ u16 af;/* address family */
@@ -1050,10 +1049,7 @@ struct netns_ipvs {/* the service mutex that protect svc_table and svc_fwm_table */ struct mutex service_mutex; -/* the service table hashed by <protocol, addr, port> */ -struct hlist_head svc_table[IP_VS_SVC_TAB_SIZE ]; -/* the service table hashed by fwmark */ -struct hlist_head svc_fwm_table[IP_VS_SVC_TAB_SIZE ]; +struct hlist_head svc_table[IP_VS_SVC_TAB_SIZE ];/* Services */ };#define DEFAULT_SYNC_THRESHOLD 3
net/netfilter/ipvs/ip_vs_ctl.c +20 -126
282 lines not on this page · raw message
Signature · 1 line
2.52.0
Florian Westphal
maintainerPATCH 4/9 ipvs: do not keep dest_dst after dest is removed
In reply to Florian WestphalFrom: Julian Anastasov <[email protected]>
Before now dest->dest_dst is not released when server is moved into dest_trash list after removal. As result, we can keep dst/dev references for long time without actively using them.
It is better to avoid walking the dest_trash list when ip_vs_dst_event() receives dev events. So, make sure we do not hold dev references in dest_trash list. As packets can be flying while server is being removed, check the IP_VS_DEST_F_AVAILABLE flag in slow path to ensure we do not save new dev references to removed servers.
--- net/netfilter/ipvs/ip_vs_ctl.c | 20 ++++++++------------ net/netfilter/ipvs/ip_vs_xmit.c | 12 ++++++++---- 2 files changed, 16 insertions(+), 16 deletions(-)
net/netfilter/ipvs/ip_vs_ctl.c +8 -12
@@ -809,7 +809,6 @@ static void ip_vs_dest_free(struct ip_vs_dest *dest) {struct ip_vs_service *svc =rcu_dereference_protected (dest->svc,1 ); -__ip_vs_dst_cache_reset (dest);__ip_vs_svc_put (svc);call_rcu (&dest->rcu_head, ip_vs_dest_rcu_free); }
@@ -1012,10 +1011,6 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest, dest->af = udest->af; -spin_lock_bh (&dest->dst_lock); -__ip_vs_dst_cache_reset (dest); -spin_unlock_bh (&dest->dst_lock); -if (add) {list_add_rcu (&dest->n_list, &svc->destinations); svc->num_dests++;
@@ -1023,6 +1018,10 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,if (sched && sched->add_dest) sched->add_dest (svc, dest); }else { +spin_lock_bh (&dest->dst_lock); +__ip_vs_dst_cache_reset (dest); +spin_unlock_bh (&dest->dst_lock); + sched =rcu_dereference_protected (svc->scheduler,1 );if (sched && sched->upd_dest) sched->upd_dest (svc, dest);
@@ -1257,6 +1256,10 @@ static void __ip_vs_unlink_dest(struct ip_vs_service *svc, { dest->flags &= ~IP_VS_DEST_F_AVAILABLE ; +spin_lock_bh (&dest->dst_lock); +__ip_vs_dst_cache_reset (dest); +spin_unlock_bh (&dest->dst_lock); +/* * Remove it from the d-linked destination list. */
@@ -1747,13 +1750,6 @@ static int ip_vs_dst_event(struct notifier_block *this, unsigned long event, }rcu_read_unlock (); -mutex_lock (&ipvs->service_mutex); -spin_lock_bh (&ipvs->dest_trash_lock); -list_for_each_entry (dest, &ipvs->dest_trash, t_list) { -ip_vs_forget_dev (dest, dev); - } -spin_unlock_bh (&ipvs->dest_trash_lock); -mutex_unlock (&ipvs->service_mutex);return NOTIFY_DONE ; }
net/netfilter/ipvs/ip_vs_xmit.c +8 -4
@@ -336,9 +336,11 @@ __ip_vs_get_out_rt(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb, goto err_unreach; }/* It is forbidden to attach dest->dest_dst if -* device is going down. +* device is going down or if server is removed and +* stored in dest_trash. */ -if (!rt_dev_is_down (dst_dev_rcu (&rt->dst))) +if (!rt_dev_is_down (dst_dev_rcu (&rt->dst)) && + dest->flags &IP_VS_DEST_F_AVAILABLE )__ip_vs_dst_set (dest, dest_dst, &rt->dst,0 );else noref =0 ;
@@ -513,9 +515,11 @@ __ip_vs_get_out_rt_v6(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb, rt =dst_rt6_info (dst); cookie =rt6_get_cookie (rt);/* It is forbidden to attach dest->dest_dst if -* device is going down. +* device is going down or if server is removed and +* stored in dest_trash. */ -if (!rt_dev_is_down (dst_dev_rcu (&rt->dst))) +if (!rt_dev_is_down (dst_dev_rcu (&rt->dst)) && + dest->flags &IP_VS_DEST_F_AVAILABLE )__ip_vs_dst_set (dest, dest_dst, &rt->dst, cookie);else noref =0 ;
Signature · 1 line
2.52.0
Florian Westphal
maintainerPATCH 5/9 ipvs: use more counters to avoid service lookups
In reply to Florian WestphalFrom: Julian Anastasov <[email protected]>
When new connection is created we can lookup for services multiple times to support fallback options. We already have some counters to skip specific lookups because it costs CPU cycles for hash calculation, etc.
Add more counters for fwmark/non-fwmark services (fwm_services and nonfwm_services) and make all counters per address family.
--- include/net/ip_vs.h | 24 ++++++--- net/netfilter/ipvs/ip_vs_core.c | 2 +- net/netfilter/ipvs/ip_vs_ctl.c | 86 +++++++++++++++++++-------------- 3 files changed, 69 insertions(+), 43 deletions(-)
include/net/ip_vs.h +18 -6
@@ -271,6 +271,18 @@ static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len, pr_err(msg, ##__VA_ARGS__); \ }while (0 ) +/* For arrays per family */ +enum { +IP_VS_AF_INET , +IP_VS_AF_INET6 , + IP_VS_AF_MAX +}; + +static inline int ip_vs_af_index (int af) +{ +return af ==AF_INET6 ?IP_VS_AF_INET6 :IP_VS_AF_INET ; +} +/* The port number of FTP service (in network order). */ #define FTPPORT cpu_to_be16(21)#define FTPDATA cpu_to_be16(20)
@@ -940,17 +952,17 @@ struct netns_ipvs {/* ip_vs_ctl */ struct ip_vs_stats_rcu *tot_stats;/* Statistics & est. */ -int num_services;/* no of virtual services */ -int num_services6;/* IPv6 virtual services */ -/* Trash for destinations */ struct list_head dest_trash;spinlock_t dest_trash_lock;struct timer_list dest_trash_timer;/* expiration timer */ /* Service counters */ -atomic_t ftpsvc_counter; -atomic_t nullsvc_counter; -atomic_t conn_out_counter; +atomic_t num_services[IP_VS_AF_MAX ];/* Services */ +atomic_t fwm_services[IP_VS_AF_MAX ];/* Services */ +atomic_t nonfwm_services[IP_VS_AF_MAX ];/* Services */ +atomic_t ftpsvc_counter[IP_VS_AF_MAX ];/* FTPPORT */ +atomic_t nullsvc_counter[IP_VS_AF_MAX ];/* Zero port */ +atomic_t conn_out_counter[IP_VS_AF_MAX ];/* out conn */ #ifdef CONFIG_SYSCTL /* delayed work for expiring no dest connections */
net/netfilter/ipvs/ip_vs_core.c +1 -1
@@ -1400,7 +1400,7 @@ ip_vs_out_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *statreturn handle_response (af, skb, pd, cp, &iph, hooknum);/* Check for real-server-started requests */ -if (atomic_read (&ipvs->conn_out_counter)) { +if (atomic_read (&ipvs->conn_out_counter[ip_vs_af_index (af)])) {/* Currently only for UDP: * connection oriented protocols typically use * ephemeral ports for outgoing connections, so
net/netfilter/ipvs/ip_vs_ctl.c +50 -36
183 lines not on this page · raw message
Signature · 1 line
2.52.0
Florian Westphal
maintainerPATCH 6/9 ipvs: no_cport and dropentry counters can be per-net
In reply to Florian WestphalFrom: Julian Anastasov <[email protected]>
Change the no_cport counters to be per-net and address family. This should reduce the extra conn lookups done during present NO_CPORT connections.
By changing from global to per-net dropentry counters, one net will not affect the drop rate of another net.
--- include/net/ip_vs.h | 2 ++ net/netfilter/ipvs/ip_vs_conn.c | 64 ++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 25 deletions(-)
include/net/ip_vs.h +2 -0
@@ -948,6 +948,7 @@ struct netns_ipvs {#endif /* ip_vs_conn */ atomic_t conn_count;/* connection counter */ +atomic_t no_cport_conns[IP_VS_AF_MAX ];/* ip_vs_ctl */ struct ip_vs_stats_rcu *tot_stats;/* Statistics & est. */
@@ -973,6 +974,7 @@ struct netns_ipvs {int drop_counter;int old_secure_tcp;atomic_t dropentry; +s8 dropentry_counters[8 ];/* locks in ctl.c */ spinlock_t dropentry_lock;/* drop entry handling */ spinlock_t droppacket_lock;/* drop packet handling */
net/netfilter/ipvs/ip_vs_conn.c +39 -25
130 lines not on this page · raw message
Signature · 1 line
2.52.0
Florian Westphal
maintainerPATCH 7/9 netfilter: nft_set_rbtree: don't disable bh when acquiring tree lock
In reply to Florian WestphalAs of commit 7e43e0a1141d
("netfilter: nft_set_rbtree: translate rbtree to array for binary search") the lock is only taken from control plane, no need to disable BH anymore.
--- net/netfilter/nft_set_rbtree.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
net/netfilter/nft_set_rbtree.c +9 -14
@@ -684,9 +684,9 @@ static int nft_rbtree_insert(const struct net *net, const struct nft_set *set,cond_resched (); -write_lock_bh (&priv->lock); +write_lock (&priv->lock); err =__nft_rbtree_insert (net, set, rbe, elem_priv, tstamp, last); -write_unlock_bh (&priv->lock); +write_unlock (&priv->lock);if (nft_rbtree_interval_end (rbe)) priv->start_rbe_cookie =0 ;
@@ -696,13 +696,6 @@ static int nft_rbtree_insert(const struct net *net, const struct nft_set *set,return err; } -static void nft_rbtree_erase (struct nft_rbtree *priv,struct nft_rbtree_elem *rbe) -{ -write_lock_bh (&priv->lock); -rb_erase (&rbe->node, &priv->root); -write_unlock_bh (&priv->lock); -} -static void nft_rbtree_remove (const struct net *net,const struct nft_set *set,struct nft_elem_priv *elem_priv)
@@ -710,7 +703,9 @@ static void nft_rbtree_remove(const struct net *net,struct nft_rbtree_elem *rbe =nft_elem_priv_cast (elem_priv);struct nft_rbtree *priv =nft_set_priv (set); -nft_rbtree_erase (priv, rbe); +write_lock (&priv->lock); +rb_erase (&rbe->node, &priv->root); +write_unlock (&priv->lock); } static void nft_rbtree_activate(const struct net *net,
@@ -871,9 +866,9 @@ static void nft_rbtree_walk(const struct nft_ctx *ctx,nft_rbtree_do_walk (ctx, set, iter);break ;case NFT_ITER_READ : -read_lock_bh (&priv->lock); +read_lock (&priv->lock);nft_rbtree_do_walk (ctx, set, iter); -read_unlock_bh (&priv->lock); +read_unlock (&priv->lock);break ;default : iter->err = -EINVAL ;
@@ -909,14 +904,14 @@ static void nft_rbtree_gc_scan(struct nft_set *set)/* end element needs to be removed first, it has * no timeout extension. */ -write_lock_bh (&priv->lock); +write_lock (&priv->lock);if (rbe_end) {nft_rbtree_gc_elem_move (net, set, priv, rbe_end); rbe_end =NULL ; }nft_rbtree_gc_elem_move (net, set, priv, rbe); -write_unlock_bh (&priv->lock); +write_unlock (&priv->lock); } priv->last_gc = jiffies;
Signature · 1 line
2.52.0
Florian Westphal
maintainerPATCH 8/9 netfilter: nf_tables: drop obsolete EXPORT_SYMBOLs
In reply to Florian WestphalThese are no longer required, calling objects are nowadays baked into nf_tables.ko itself.
--- net/netfilter/nf_tables_api.c | 11 ----------- 1 file changed, 11 deletions(-)
net/netfilter/nf_tables_api.c +0 -11
@@ -4128,7 +4128,6 @@ int nft_chain_validate(const struct nft_ctx *ctx, struct nft_chain *chain)nft_chain_vstate_update (ctx, chain);return 0 ; } -EXPORT_SYMBOL_GPL (nft_chain_validate);static int nft_table_validate (struct net *net,const struct nft_table *table) {
@@ -4745,7 +4744,6 @@ struct nft_set *nft_set_lookup_global(const struct net *net, }return set; } -EXPORT_SYMBOL_GPL (nft_set_lookup_global);static int nf_tables_set_alloc_name (struct nft_ctx *ctx,struct nft_set *set,const char *name)
@@ -5818,7 +5816,6 @@ int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set,return 0 ; } -EXPORT_SYMBOL_GPL (nf_tables_bind_set);static void nf_tables_unbind_set (const struct nft_ctx *ctx,struct nft_set *set,struct nft_set_binding *binding,bool event)
@@ -5898,7 +5895,6 @@ void nf_tables_activate_set(const struct nft_ctx *ctx, struct nft_set *set)nft_use_inc_restore (&set->use); } -EXPORT_SYMBOL_GPL (nf_tables_activate_set); void nf_tables_deactivate_set(const struct nft_ctx *ctx, struct nft_set *set, struct nft_set_binding *binding,
@@ -5938,14 +5934,12 @@ void nf_tables_deactivate_set(const struct nft_ctx *ctx, struct nft_set *set, phase == NFT_TRANS_COMMIT); } } -EXPORT_SYMBOL_GPL (nf_tables_deactivate_set);void nf_tables_destroy_set (const struct nft_ctx *ctx,struct nft_set *set) {if (list_empty (&set->bindings) &&nft_set_is_anonymous (set))nft_set_destroy (ctx, set); } -EXPORT_SYMBOL_GPL (nf_tables_destroy_set);const struct nft_set_ext_type nft_set_ext_types[] = { [NFT_SET_EXT_KEY ] = {
@@ -6783,7 +6777,6 @@ void nft_set_elem_destroy(const struct nft_set *set,__nft_set_elem_destroy (&ctx, set, elem_priv, destroy_expr); } -EXPORT_SYMBOL_GPL (nft_set_elem_destroy);/* Drop references and destroy. Called from abort path. */ static void nft_trans_set_elem_destroy (const struct nft_ctx *ctx,struct nft_trans_elem *te)
@@ -6910,7 +6903,6 @@ struct nft_set_ext *nft_set_catchall_lookup(const struct net *net,return NULL ; } -EXPORT_SYMBOL_GPL (nft_set_catchall_lookup); static int nft_setelem_catchall_insert(const struct net *net, struct nft_set *set,
@@ -8038,7 +8030,6 @@ struct nft_object *nft_obj_lookup(const struct net *net,rcu_read_unlock ();return ERR_PTR (-ENOENT ); } -EXPORT_SYMBOL_GPL (nft_obj_lookup); static struct nft_object *nft_obj_lookup_byhandle(const struct nft_table *table, const struct nlattr *nla,
@@ -11860,7 +11851,6 @@ void nft_data_release(const struct nft_data *data, enum nft_data_types type)WARN_ON (1 ); } } -EXPORT_SYMBOL_GPL (nft_data_release);int nft_data_dump (struct sk_buff *skb,int attr,const struct nft_data *data,enum nft_data_types type,unsigned int len)
@@ -11887,7 +11877,6 @@ int nft_data_dump(struct sk_buff *skb, int attr, const struct nft_data *data,nla_nest_end (skb, nest);return err; } -EXPORT_SYMBOL_GPL (nft_data_dump);static void __nft_release_hook (struct net *net,struct nft_table *table) {
Signature · 1 line
2.52.0
Florian Westphal
maintainerPATCH 9/9 netfilter: nf_tables: remove register tracking infrastructure
In reply to Florian WestphalThis facility was disabled in commit9e539c5b6d9c ("netfilter: nf_tables: disable expression reduction infra"), because not all nft_exprs guarantee they will update the destination
register: some may set NFT_BREAK instead to cancel evaluation of the rule.
This has been dead code ever since.
There are no plans to salvage this at this time, so remove this.
--- include/net/netfilter/nf_tables.h | 32 ------- include/net/netfilter/nft_fib.h | 2 - include/net/netfilter/nft_meta.h | 3 - net/bridge/netfilter/nft_meta_bridge.c | 20 ----- net/bridge/netfilter/nft_reject_bridge.c | 1 - net/ipv4/netfilter/nft_dup_ipv4.c | 1 - net/ipv4/netfilter/nft_fib_ipv4.c | 2 - net/ipv4/netfilter/nft_reject_ipv4.c | 1 - net/ipv6/netfilter/nft_dup_ipv6.c | 1 - net/ipv6/netfilter/nft_fib_ipv6.c | 2 - net/ipv6/netfilter/nft_reject_ipv6.c | 1 - net/netfilter/nf_tables_api.c | 67 --------------- net/netfilter/nft_bitwise.c | 104 ----------------------- net/netfilter/nft_byteorder.c | 11 --- net/netfilter/nft_cmp.c | 3 - net/netfilter/nft_compat.c | 10 --- net/netfilter/nft_connlimit.c | 1 - net/netfilter/nft_counter.c | 1 - net/netfilter/nft_ct.c | 46 ---------- net/netfilter/nft_dup_netdev.c | 1 - net/netfilter/nft_dynset.c | 1 - net/netfilter/nft_exthdr.c | 34 -------- net/netfilter/nft_fib.c | 42 --------- net/netfilter/nft_fib_inet.c | 1 - net/netfilter/nft_fib_netdev.c | 1 - net/netfilter/nft_flow_offload.c | 1 - net/netfilter/nft_fwd_netdev.c | 2 - net/netfilter/nft_hash.c | 36 -------- net/netfilter/nft_immediate.c | 12 --- net/netfilter/nft_last.c | 1 - net/netfilter/nft_limit.c | 2 - net/netfilter/nft_log.c | 1 - net/netfilter/nft_lookup.c | 12 --- net/netfilter/nft_masq.c | 3 - net/netfilter/nft_meta.c | 45 ---------- net/netfilter/nft_nat.c | 2 - net/netfilter/nft_numgen.c | 22 ----- net/netfilter/nft_objref.c | 2 - net/netfilter/nft_osf.c | 25 ------ net/netfilter/nft_payload.c | 47 ---------- net/netfilter/nft_queue.c | 2 - net/netfilter/nft_quota.c | 1 - net/netfilter/nft_range.c | 1 - net/netfilter/nft_redir.c | 3 - net/netfilter/nft_reject_inet.c | 1 - net/netfilter/nft_reject_netdev.c | 1 - net/netfilter/nft_rt.c | 1 - net/netfilter/nft_socket.c | 26 ------ net/netfilter/nft_synproxy.c | 1 - net/netfilter/nft_tproxy.c | 1 - net/netfilter/nft_tunnel.c | 26 ------ net/netfilter/nft_xfrm.c | 27 ------ 52 files changed, 693 deletions(-)
include/net/netfilter/nf_tables.h +0 -32
@@ -122,17 +122,6 @@ struct nft_regs { }; }; -struct nft_regs_track { -struct { -const struct nft_expr *selector; -const struct nft_expr *bitwise; -u8 num_reg; - } regs[NFT_REG32_NUM ]; - -const struct nft_expr *cur; -const struct nft_expr *last; -}; -/* Store/load an u8, u16 or u64 integer to/from the u32 data register. * * Note, when using concatenations, register allocation happens at 32-bit
@@ -427,8 +416,6 @@ int nft_expr_clone(struct nft_expr *dst, struct nft_expr *src, gfp_t gfp);void nft_expr_destroy (const struct nft_ctx *ctx,struct nft_expr *expr);int nft_expr_dump (struct sk_buff *skb,unsigned int attr,const struct nft_expr *expr,bool reset); -bool nft_expr_reduce_bitwise (struct nft_regs_track *track, -const struct nft_expr *expr);struct nft_set_ext ;
@@ -941,7 +928,6 @@ struct nft_offload_ctx;* @destroy_clone: destruction clone function * @dump: function to dump parameters * @validate: validate expression, called during loop detection -* @reduce: reduce expression * @gc: garbage collection expression * @offload: hardware offload expression * @offload_action: function to report true/false to allocate one slot or not in the flow
@@ -975,8 +961,6 @@ struct nft_expr_ops { bool reset);int (*validate)(const struct nft_ctx *ctx,const struct nft_expr *expr); -bool (*reduce)(struct nft_regs_track *track, -const struct nft_expr *expr);bool (*gc)(struct net *net,const struct nft_expr *expr); int (*offload)(struct nft_offload_ctx *ctx,
@@ -1954,20 +1938,4 @@ static inline u64 nft_net_tstamp(const struct net *net) return nft_pernet(net)->tstamp; } -#define __NFT_REDUCE_READONLY 1UL -#define NFT_REDUCE_READONLY (void *)__NFT_REDUCE_READONLY - -void nft_reg_track_update (struct nft_regs_track *track, -const struct nft_expr *expr,u8 dreg,u8 len); -void nft_reg_track_cancel (struct nft_regs_track *track,u8 dreg,u8 len); -void __nft_reg_track_cancel (struct nft_regs_track *track,u8 dreg); - -static inline bool nft_reg_track_cmp (struct nft_regs_track *track, -const struct nft_expr *expr,u8 dreg) -{ -return track->regs[dreg].selector && - track->regs[dreg].selector->ops == expr->ops && - track->regs[dreg].num_reg ==0 ; -} -#endif /* _NET_NF_TABLES_H */
include/net/netfilter/nft_fib.h +0 -2
@@ -66,6 +66,4 @@ void nft_fib6_eval(const struct nft_expr *expr, struct nft_regs *regs,void nft_fib_store_result (void *reg,const struct nft_fib *priv,const struct net_device *dev); -bool nft_fib_reduce (struct nft_regs_track *track, -const struct nft_expr *expr);#endif
include/net/netfilter/nft_meta.h +0 -3
@@ -43,9 +43,6 @@ void nft_meta_set_destroy(const struct nft_ctx *ctx,int nft_meta_set_validate (const struct nft_ctx *ctx,const struct nft_expr *expr); -bool nft_meta_get_reduce (struct nft_regs_track *track, -const struct nft_expr *expr); -struct nft_inner_tun_ctx ; void nft_meta_inner_eval(const struct nft_expr *expr, struct nft_regs *regs, const struct nft_pktinfo *pkt,
net/bridge/netfilter/nft_meta_bridge.c +0 -20
@@ -112,7 +112,6 @@ static const struct nft_expr_ops nft_meta_bridge_get_ops = { .eval = nft_meta_bridge_get_eval, .init = nft_meta_bridge_get_init, .dump = nft_meta_get_dump, - .reduce = nft_meta_get_reduce, }; static void nft_meta_bridge_set_eval(const struct nft_expr *expr,
@@ -159,24 +158,6 @@ static int nft_meta_bridge_set_init(const struct nft_ctx *ctx,return 0 ; } -static bool nft_meta_bridge_set_reduce (struct nft_regs_track *track, -const struct nft_expr *expr) -{ -int i; - -for (i =0 ; i <NFT_REG32_NUM ; i++) { -if (!track->regs[i].selector) -continue ; - -if (track->regs[i].selector->ops != &nft_meta_bridge_get_ops) -continue ; - -__nft_reg_track_cancel (track, i); - } - -return false; -} -static int nft_meta_bridge_set_validate (const struct nft_ctx *ctx,const struct nft_expr *expr) {
@@ -202,7 +183,6 @@ static const struct nft_expr_ops nft_meta_bridge_set_ops = { .init = nft_meta_bridge_set_init, .destroy = nft_meta_set_destroy, .dump = nft_meta_set_dump, - .reduce = nft_meta_bridge_set_reduce, .validate = nft_meta_bridge_set_validate, };
net/bridge/netfilter/nft_reject_bridge.c +0 -1
@@ -184,7 +184,6 @@ static const struct nft_expr_ops nft_reject_bridge_ops = { .init = nft_reject_init, .dump = nft_reject_dump, .validate = nft_reject_bridge_validate, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_reject_bridge_type__read_mostly = {
net/ipv4/netfilter/nft_dup_ipv4.c +0 -1
@@ -76,7 +76,6 @@ static const struct nft_expr_ops nft_dup_ipv4_ops = { .eval = nft_dup_ipv4_eval, .init = nft_dup_ipv4_init, .dump = nft_dup_ipv4_dump, - .reduce = NFT_REDUCE_READONLY, };static const struct nla_policy nft_dup_ipv4_policy[NFTA_DUP_MAX +1 ] = {
net/ipv4/netfilter/nft_fib_ipv4.c +0 -2
@@ -163,7 +163,6 @@ static const struct nft_expr_ops nft_fib4_type_ops = { .init = nft_fib_init, .dump = nft_fib_dump, .validate = nft_fib_validate, - .reduce = nft_fib_reduce, };static const struct nft_expr_ops nft_fib4_ops = {
@@ -173,7 +172,6 @@ static const struct nft_expr_ops nft_fib4_ops = { .init = nft_fib_init, .dump = nft_fib_dump, .validate = nft_fib_validate, - .reduce = nft_fib_reduce, }; static const struct nft_expr_ops *
net/ipv4/netfilter/nft_reject_ipv4.c +0 -1
@@ -45,7 +45,6 @@ static const struct nft_expr_ops nft_reject_ipv4_ops = { .init = nft_reject_init, .dump = nft_reject_dump, .validate = nft_reject_validate, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_reject_ipv4_type__read_mostly = {
net/ipv6/netfilter/nft_dup_ipv6.c +0 -1
@@ -74,7 +74,6 @@ static const struct nft_expr_ops nft_dup_ipv6_ops = { .eval = nft_dup_ipv6_eval, .init = nft_dup_ipv6_init, .dump = nft_dup_ipv6_dump, - .reduce = NFT_REDUCE_READONLY, };static const struct nla_policy nft_dup_ipv6_policy[NFTA_DUP_MAX +1 ] = {
net/ipv6/netfilter/nft_fib_ipv6.c +0 -2
@@ -225,7 +225,6 @@ static const struct nft_expr_ops nft_fib6_type_ops = { .init = nft_fib_init, .dump = nft_fib_dump, .validate = nft_fib_validate, - .reduce = nft_fib_reduce, };static const struct nft_expr_ops nft_fib6_ops = {
@@ -235,7 +234,6 @@ static const struct nft_expr_ops nft_fib6_ops = { .init = nft_fib_init, .dump = nft_fib_dump, .validate = nft_fib_validate, - .reduce = nft_fib_reduce, }; static const struct nft_expr_ops *
net/ipv6/netfilter/nft_reject_ipv6.c +0 -1
@@ -46,7 +46,6 @@ static const struct nft_expr_ops nft_reject_ipv6_ops = { .init = nft_reject_init, .dump = nft_reject_dump, .validate = nft_reject_validate, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_reject_ipv6_type__read_mostly = {
net/netfilter/nf_tables_api.c +0 -67
89 lines not on this page · raw message
net/netfilter/nft_bitwise.c +0 -104
131 lines not on this page · raw message
net/netfilter/nft_byteorder.c +0 -11
@@ -170,23 +170,12 @@ static int nft_byteorder_dump(struct sk_buff *skb,return -1 ; } -static bool nft_byteorder_reduce (struct nft_regs_track *track, -const struct nft_expr *expr) -{ -struct nft_byteorder *priv =nft_expr_priv (expr); - -nft_reg_track_cancel (track, priv->dreg, priv->len); - -return false; -} -static const struct nft_expr_ops nft_byteorder_ops = { .type = &nft_byteorder_type, .size =NFT_EXPR_SIZE (sizeof (struct nft_byteorder )), .eval = nft_byteorder_eval, .init = nft_byteorder_init, .dump = nft_byteorder_dump, - .reduce = nft_byteorder_reduce, };struct nft_expr_type nft_byteorder_type__read_mostly = {
net/netfilter/nft_cmp.c +0 -3
@@ -190,7 +190,6 @@ static const struct nft_expr_ops nft_cmp_ops = { .eval = nft_cmp_eval, .init = nft_cmp_init, .dump = nft_cmp_dump, - .reduce = NFT_REDUCE_READONLY, .offload = nft_cmp_offload, };
@@ -282,7 +281,6 @@ const struct nft_expr_ops nft_cmp_fast_ops = { .eval = NULL, /* inlined */ .init = nft_cmp_fast_init, .dump = nft_cmp_fast_dump, - .reduce = NFT_REDUCE_READONLY, .offload = nft_cmp_fast_offload, };
@@ -376,7 +374,6 @@ const struct nft_expr_ops nft_cmp16_fast_ops = { .eval = NULL, /* inlined */ .init = nft_cmp16_fast_init, .dump = nft_cmp16_fast_dump, - .reduce = NFT_REDUCE_READONLY, .offload = nft_cmp16_fast_offload, };
net/netfilter/nft_compat.c +0 -10
@@ -778,14 +778,6 @@ static const struct nfnetlink_subsystem nfnl_compat_subsys = {static struct nft_expr_type nft_match_type; -static bool nft_match_reduce (struct nft_regs_track *track, -const struct nft_expr *expr) -{ -const struct xt_match *match = expr->ops->data; - -return strcmp (match->name,"comment" ) ==0 ; -} -static const struct nft_expr_ops *nft_match_select_ops (const struct nft_ctx *ctx,const struct nlattr *const tb[])
@@ -828,7 +820,6 @@ nft_match_select_ops(const struct nft_ctx *ctx, ops->dump = nft_match_dump; ops->validate = nft_match_validate; ops->data = match; - ops->reduce = nft_match_reduce; matchsize =NFT_EXPR_SIZE (XT_ALIGN (match->matchsize));if (matchsize >NFT_MATCH_LARGE_THRESH ) {
@@ -918,7 +909,6 @@ nft_target_select_ops(const struct nft_ctx *ctx, ops->dump = nft_target_dump; ops->validate = nft_target_validate; ops->data = target; - ops->reduce =NFT_REDUCE_READONLY ;if (family ==NFPROTO_BRIDGE ) ops->eval = nft_target_eval_bridge;
net/netfilter/nft_connlimit.c +0 -1
@@ -258,7 +258,6 @@ static const struct nft_expr_ops nft_connlimit_ops = { .destroy_clone = nft_connlimit_destroy_clone, .dump = nft_connlimit_dump, .gc = nft_connlimit_gc, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_connlimit_type__read_mostly = {
net/netfilter/nft_counter.c +0 -1
@@ -313,7 +313,6 @@ static const struct nft_expr_ops nft_counter_ops = { .destroy_clone = nft_counter_destroy, .dump = nft_counter_dump, .clone = nft_counter_clone, - .reduce = NFT_REDUCE_READONLY, .offload = nft_counter_offload, .offload_stats = nft_counter_offload_stats, };
net/netfilter/nft_ct.c +0 -46
84 lines not on this page · raw message
net/netfilter/nft_dup_netdev.c +0 -1
@@ -80,7 +80,6 @@ static const struct nft_expr_ops nft_dup_netdev_ops = { .eval = nft_dup_netdev_eval, .init = nft_dup_netdev_init, .dump = nft_dup_netdev_dump, - .reduce = NFT_REDUCE_READONLY, .offload = nft_dup_netdev_offload, .offload_action = nft_dup_netdev_offload_action, };
net/netfilter/nft_dynset.c +0 -1
@@ -421,7 +421,6 @@ static const struct nft_expr_ops nft_dynset_ops = { .activate = nft_dynset_activate, .deactivate = nft_dynset_deactivate, .dump = nft_dynset_dump, - .reduce = NFT_REDUCE_READONLY, };struct nft_expr_type nft_dynset_type__read_mostly = {
net/netfilter/nft_exthdr.c +0 -34
@@ -702,40 +702,12 @@ static int nft_exthdr_dump_strip(struct sk_buff *skb,return nft_exthdr_dump_common (skb, priv); } -static bool nft_exthdr_reduce (struct nft_regs_track *track, -const struct nft_expr *expr) -{ -const struct nft_exthdr *priv =nft_expr_priv (expr); -const struct nft_exthdr *exthdr; - -if (!nft_reg_track_cmp (track, expr, priv->dreg)) { -nft_reg_track_update (track, expr, priv->dreg, priv->len); -return false; - } - - exthdr =nft_expr_priv (track->regs[priv->dreg].selector); -if (priv->type != exthdr->type || - priv->op != exthdr->op || - priv->flags != exthdr->flags || - priv->offset != exthdr->offset || - priv->len != exthdr->len) { -nft_reg_track_update (track, expr, priv->dreg, priv->len); -return false; - } - -if (!track->regs[priv->dreg].bitwise) -return true; - -return nft_expr_reduce_bitwise (track, expr); -} -static const struct nft_expr_ops nft_exthdr_ipv6_ops = { .type = &nft_exthdr_type, .size =NFT_EXPR_SIZE (sizeof (struct nft_exthdr )), .eval = nft_exthdr_ipv6_eval, .init = nft_exthdr_init, .dump = nft_exthdr_dump, - .reduce = nft_exthdr_reduce, };static const struct nft_expr_ops nft_exthdr_ipv4_ops = {
@@ -744,7 +716,6 @@ static const struct nft_expr_ops nft_exthdr_ipv4_ops = { .eval = nft_exthdr_ipv4_eval, .init = nft_exthdr_ipv4_init, .dump = nft_exthdr_dump, - .reduce = nft_exthdr_reduce, };static const struct nft_expr_ops nft_exthdr_tcp_ops = {
@@ -753,7 +724,6 @@ static const struct nft_expr_ops nft_exthdr_tcp_ops = { .eval = nft_exthdr_tcp_eval, .init = nft_exthdr_init, .dump = nft_exthdr_dump, - .reduce = nft_exthdr_reduce, };static const struct nft_expr_ops nft_exthdr_tcp_set_ops = {
@@ -762,7 +732,6 @@ static const struct nft_expr_ops nft_exthdr_tcp_set_ops = { .eval = nft_exthdr_tcp_set_eval, .init = nft_exthdr_tcp_set_init, .dump = nft_exthdr_dump_set, - .reduce = NFT_REDUCE_READONLY, };static const struct nft_expr_ops nft_exthdr_tcp_strip_ops = {
@@ -771,7 +740,6 @@ static const struct nft_expr_ops nft_exthdr_tcp_strip_ops = { .eval = nft_exthdr_tcp_strip_eval, .init = nft_exthdr_tcp_strip_init, .dump = nft_exthdr_dump_strip, - .reduce = NFT_REDUCE_READONLY, };static const struct nft_expr_ops nft_exthdr_sctp_ops = {
@@ -780,7 +748,6 @@ static const struct nft_expr_ops nft_exthdr_sctp_ops = { .eval = nft_exthdr_sctp_eval, .init = nft_exthdr_init, .dump = nft_exthdr_dump, - .reduce = nft_exthdr_reduce, };#ifdef CONFIG_NFT_EXTHDR_DCCP
@@ -790,7 +757,6 @@ static const struct nft_expr_ops nft_exthdr_dccp_ops = { .eval = nft_exthdr_dccp_eval, .init = nft_exthdr_dccp_init, .dump = nft_exthdr_dump, - .reduce = nft_exthdr_reduce, };#endif
net/netfilter/nft_fib.c +0 -42
48 lines not on this page · raw message
net/netfilter/nft_fib_inet.c +0 -1
@@ -49,7 +49,6 @@ static const struct nft_expr_ops nft_fib_inet_ops = { .init = nft_fib_init, .dump = nft_fib_dump, .validate = nft_fib_validate, - .reduce = nft_fib_reduce, };static struct nft_expr_type nft_fib_inet_type__read_mostly = {
net/netfilter/nft_fib_netdev.c +0 -1
@@ -58,7 +58,6 @@ static const struct nft_expr_ops nft_fib_netdev_ops = { .init = nft_fib_init, .dump = nft_fib_dump, .validate = nft_fib_validate, - .reduce = nft_fib_reduce, };static struct nft_expr_type nft_fib_netdev_type__read_mostly = {
net/netfilter/nft_flow_offload.c +0 -1
@@ -225,7 +225,6 @@ static const struct nft_expr_ops nft_flow_offload_ops = { .destroy = nft_flow_offload_destroy, .validate = nft_flow_offload_validate, .dump = nft_flow_offload_dump, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_flow_offload_type__read_mostly = {
net/netfilter/nft_fwd_netdev.c +0 -2
@@ -218,7 +218,6 @@ static const struct nft_expr_ops nft_fwd_neigh_netdev_ops = { .init = nft_fwd_neigh_init, .dump = nft_fwd_neigh_dump, .validate = nft_fwd_validate, - .reduce = NFT_REDUCE_READONLY, };static const struct nft_expr_ops nft_fwd_netdev_ops = {
@@ -228,7 +227,6 @@ static const struct nft_expr_ops nft_fwd_netdev_ops = { .init = nft_fwd_netdev_init, .dump = nft_fwd_netdev_dump, .validate = nft_fwd_validate, - .reduce = NFT_REDUCE_READONLY, .offload = nft_fwd_netdev_offload, .offload_action = nft_fwd_netdev_offload_action, };
net/netfilter/nft_hash.c +0 -36
@@ -166,16 +166,6 @@ static int nft_jhash_dump(struct sk_buff *skb,return -1 ; } -static bool nft_jhash_reduce (struct nft_regs_track *track, -const struct nft_expr *expr) -{ -const struct nft_jhash *priv =nft_expr_priv (expr); - -nft_reg_track_cancel (track, priv->dreg,sizeof (u32)); - -return false; -} -static int nft_symhash_dump (struct sk_buff *skb,const struct nft_expr *expr,bool reset) {
@@ -196,30 +186,6 @@ static int nft_symhash_dump(struct sk_buff *skb,return -1 ; } -static bool nft_symhash_reduce (struct nft_regs_track *track, -const struct nft_expr *expr) -{ -struct nft_symhash *priv =nft_expr_priv (expr); -struct nft_symhash *symhash; - -if (!nft_reg_track_cmp (track, expr, priv->dreg)) { -nft_reg_track_update (track, expr, priv->dreg,sizeof (u32)); -return false; - } - - symhash =nft_expr_priv (track->regs[priv->dreg].selector); -if (priv->offset != symhash->offset || - priv->modulus != symhash->modulus) { -nft_reg_track_update (track, expr, priv->dreg,sizeof (u32)); -return false; - } - -if (!track->regs[priv->dreg].bitwise) -return true; - -return false; -} -static struct nft_expr_type nft_hash_type;static const struct nft_expr_ops nft_jhash_ops = { .type = &nft_hash_type,
@@ -227,7 +193,6 @@ static const struct nft_expr_ops nft_jhash_ops = { .eval = nft_jhash_eval, .init = nft_jhash_init, .dump = nft_jhash_dump, - .reduce = nft_jhash_reduce, };static const struct nft_expr_ops nft_symhash_ops = {
@@ -236,7 +201,6 @@ static const struct nft_expr_ops nft_symhash_ops = { .eval = nft_symhash_eval, .init = nft_symhash_init, .dump = nft_symhash_dump, - .reduce = nft_symhash_reduce, }; static const struct nft_expr_ops *
net/netfilter/nft_immediate.c +0 -12
@@ -320,17 +320,6 @@ static bool nft_immediate_offload_action(const struct nft_expr *expr)return false; } -static bool nft_immediate_reduce (struct nft_regs_track *track, -const struct nft_expr *expr) -{ -const struct nft_immediate_expr *priv =nft_expr_priv (expr); - -if (priv->dreg !=NFT_REG_VERDICT ) -nft_reg_track_cancel (track, priv->dreg, priv->dlen); - -return false; -} -static const struct nft_expr_ops nft_imm_ops = { .type = &nft_imm_type, .size =NFT_EXPR_SIZE (sizeof (struct nft_immediate_expr )),
@@ -341,7 +330,6 @@ static const struct nft_expr_ops nft_imm_ops = { .destroy = nft_immediate_destroy, .dump = nft_immediate_dump, .validate = nft_immediate_validate, - .reduce = nft_immediate_reduce, .offload = nft_immediate_offload, .offload_action = nft_immediate_offload_action, };
net/netfilter/nft_last.c +0 -1
@@ -125,7 +125,6 @@ static const struct nft_expr_ops nft_last_ops = { .destroy = nft_last_destroy, .clone = nft_last_clone, .dump = nft_last_dump, - .reduce = NFT_REDUCE_READONLY, };struct nft_expr_type nft_last_type__read_mostly = {
net/netfilter/nft_limit.c +0 -2
@@ -243,7 +243,6 @@ static const struct nft_expr_ops nft_limit_pkts_ops = { .destroy = nft_limit_pkts_destroy, .clone = nft_limit_pkts_clone, .dump = nft_limit_pkts_dump, - .reduce = NFT_REDUCE_READONLY, }; static void nft_limit_bytes_eval(const struct nft_expr *expr,
@@ -299,7 +298,6 @@ static const struct nft_expr_ops nft_limit_bytes_ops = { .dump = nft_limit_bytes_dump, .clone = nft_limit_bytes_clone, .destroy = nft_limit_bytes_destroy, - .reduce = NFT_REDUCE_READONLY, }; static const struct nft_expr_ops *
net/netfilter/nft_log.c +0 -1
@@ -235,7 +235,6 @@ static const struct nft_expr_ops nft_log_ops = { .init = nft_log_init, .destroy = nft_log_destroy, .dump = nft_log_dump, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_log_type__read_mostly = {
net/netfilter/nft_lookup.c +0 -12
@@ -266,17 +266,6 @@ static int nft_lookup_validate(const struct nft_ctx *ctx,return 0 ; } -static bool nft_lookup_reduce (struct nft_regs_track *track, -const struct nft_expr *expr) -{ -const struct nft_lookup *priv =nft_expr_priv (expr); - -if (priv->set->flags &NFT_SET_MAP ) -nft_reg_track_cancel (track, priv->dreg, priv->set->dlen); - -return false; -} -static const struct nft_expr_ops nft_lookup_ops = { .type = &nft_lookup_type, .size =NFT_EXPR_SIZE (sizeof (struct nft_lookup )),
@@ -287,7 +276,6 @@ static const struct nft_expr_ops nft_lookup_ops = { .destroy = nft_lookup_destroy, .dump = nft_lookup_dump, .validate = nft_lookup_validate, - .reduce = nft_lookup_reduce, };struct nft_expr_type nft_lookup_type__read_mostly = {
net/netfilter/nft_masq.c +0 -3
@@ -143,7 +143,6 @@ static const struct nft_expr_ops nft_masq_ipv4_ops = { .destroy = nft_masq_ipv4_destroy, .dump = nft_masq_dump, .validate = nft_masq_validate, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_masq_ipv4_type__read_mostly = {
@@ -171,7 +170,6 @@ static const struct nft_expr_ops nft_masq_ipv6_ops = { .destroy = nft_masq_ipv6_destroy, .dump = nft_masq_dump, .validate = nft_masq_validate, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_masq_ipv6_type__read_mostly = {
@@ -213,7 +211,6 @@ static const struct nft_expr_ops nft_masq_inet_ops = { .destroy = nft_masq_inet_destroy, .dump = nft_masq_dump, .validate = nft_masq_validate, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_masq_inet_type__read_mostly = {
net/netfilter/nft_meta.c +0 -45
67 lines not on this page · raw message
net/netfilter/nft_nat.c +0 -2
@@ -320,7 +320,6 @@ static const struct nft_expr_ops nft_nat_ops = { .destroy = nft_nat_destroy, .dump = nft_nat_dump, .validate = nft_nat_validate, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_nat_type__read_mostly = {
@@ -351,7 +350,6 @@ static const struct nft_expr_ops nft_nat_inet_ops = { .destroy = nft_nat_destroy, .dump = nft_nat_dump, .validate = nft_nat_validate, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_inet_nat_type__read_mostly = {
net/netfilter/nft_numgen.c +0 -22
@@ -84,16 +84,6 @@ static int nft_ng_inc_init(const struct nft_ctx *ctx,return err; } -static bool nft_ng_inc_reduce (struct nft_regs_track *track, -const struct nft_expr *expr) -{ -const struct nft_ng_inc *priv =nft_expr_priv (expr); - -nft_reg_track_cancel (track, priv->dreg,NFT_REG32_SIZE ); - -return false; -} -static int nft_ng_dump (struct sk_buff *skb,enum nft_registers dreg,u32 modulus,enum nft_ng_types type,u32 offset) {
@@ -178,16 +168,6 @@ static int nft_ng_random_dump(struct sk_buff *skb, priv->offset); } -static bool nft_ng_random_reduce (struct nft_regs_track *track, -const struct nft_expr *expr) -{ -const struct nft_ng_random *priv =nft_expr_priv (expr); - -nft_reg_track_cancel (track, priv->dreg,NFT_REG32_SIZE ); - -return false; -} -static struct nft_expr_type nft_ng_type;static const struct nft_expr_ops nft_ng_inc_ops = { .type = &nft_ng_type,
@@ -196,7 +176,6 @@ static const struct nft_expr_ops nft_ng_inc_ops = { .init = nft_ng_inc_init, .destroy = nft_ng_inc_destroy, .dump = nft_ng_inc_dump, - .reduce = nft_ng_inc_reduce, };static const struct nft_expr_ops nft_ng_random_ops = {
@@ -205,7 +184,6 @@ static const struct nft_expr_ops nft_ng_random_ops = { .eval = nft_ng_random_eval, .init = nft_ng_random_init, .dump = nft_ng_random_dump, - .reduce = nft_ng_random_reduce, }; static const struct nft_expr_ops *
net/netfilter/nft_objref.c +0 -2
@@ -123,7 +123,6 @@ static const struct nft_expr_ops nft_objref_ops = { .deactivate = nft_objref_deactivate, .dump = nft_objref_dump, .validate = nft_objref_validate, - .reduce = NFT_REDUCE_READONLY, };struct nft_objref_map {
@@ -245,7 +244,6 @@ static const struct nft_expr_ops nft_objref_map_ops = { .destroy = nft_objref_map_destroy, .dump = nft_objref_map_dump, .validate = nft_objref_map_validate, - .reduce = NFT_REDUCE_READONLY, }; static const struct nft_expr_ops *
net/netfilter/nft_osf.c +0 -25
@@ -127,30 +127,6 @@ static int nft_osf_validate(const struct nft_ctx *ctx,return nft_chain_validate_hooks (ctx->chain, hooks); } -static bool nft_osf_reduce (struct nft_regs_track *track, -const struct nft_expr *expr) -{ -struct nft_osf *priv =nft_expr_priv (expr); -struct nft_osf *osf; - -if (!nft_reg_track_cmp (track, expr, priv->dreg)) { -nft_reg_track_update (track, expr, priv->dreg,NFT_OSF_MAXGENRELEN ); -return false; - } - - osf =nft_expr_priv (track->regs[priv->dreg].selector); -if (priv->flags != osf->flags || - priv->ttl != osf->ttl) { -nft_reg_track_update (track, expr, priv->dreg,NFT_OSF_MAXGENRELEN ); -return false; - } - -if (!track->regs[priv->dreg].bitwise) -return true; - -return false; -} -static struct nft_expr_type nft_osf_type;static const struct nft_expr_ops nft_osf_op = { .eval = nft_osf_eval,
@@ -159,7 +135,6 @@ static const struct nft_expr_ops nft_osf_op = { .dump = nft_osf_dump, .type = &nft_osf_type, .validate = nft_osf_validate, - .reduce = nft_osf_reduce, };static struct nft_expr_type nft_osf_type__read_mostly = {
net/netfilter/nft_payload.c +0 -47
77 lines not on this page · raw message
net/netfilter/nft_queue.c +0 -2
@@ -191,7 +191,6 @@ static const struct nft_expr_ops nft_queue_ops = { .init = nft_queue_init, .dump = nft_queue_dump, .validate = nft_queue_validate, - .reduce = NFT_REDUCE_READONLY, };static const struct nft_expr_ops nft_queue_sreg_ops = {
@@ -201,7 +200,6 @@ static const struct nft_expr_ops nft_queue_sreg_ops = { .init = nft_queue_sreg_init, .dump = nft_queue_sreg_dump, .validate = nft_queue_validate, - .reduce = NFT_REDUCE_READONLY, }; static const struct nft_expr_ops *
net/netfilter/nft_quota.c +0 -1
@@ -266,7 +266,6 @@ static const struct nft_expr_ops nft_quota_ops = { .destroy = nft_quota_destroy, .clone = nft_quota_clone, .dump = nft_quota_dump, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_quota_type__read_mostly = {
net/netfilter/nft_range.c +0 -1
@@ -138,7 +138,6 @@ static const struct nft_expr_ops nft_range_ops = { .eval = nft_range_eval, .init = nft_range_init, .dump = nft_range_dump, - .reduce = NFT_REDUCE_READONLY, };struct nft_expr_type nft_range_type__read_mostly = {
net/netfilter/nft_redir.c +0 -3
@@ -146,7 +146,6 @@ static const struct nft_expr_ops nft_redir_ipv4_ops = { .destroy = nft_redir_ipv4_destroy, .dump = nft_redir_dump, .validate = nft_redir_validate, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_redir_ipv4_type__read_mostly = {
@@ -174,7 +173,6 @@ static const struct nft_expr_ops nft_redir_ipv6_ops = { .destroy = nft_redir_ipv6_destroy, .dump = nft_redir_dump, .validate = nft_redir_validate, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_redir_ipv6_type__read_mostly = {
@@ -203,7 +201,6 @@ static const struct nft_expr_ops nft_redir_inet_ops = { .destroy = nft_redir_inet_destroy, .dump = nft_redir_dump, .validate = nft_redir_validate, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_redir_inet_type__read_mostly = {
net/netfilter/nft_reject_inet.c +0 -1
@@ -79,7 +79,6 @@ static const struct nft_expr_ops nft_reject_inet_ops = { .init = nft_reject_init, .dump = nft_reject_dump, .validate = nft_reject_inet_validate, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_reject_inet_type__read_mostly = {
net/netfilter/nft_reject_netdev.c +0 -1
@@ -158,7 +158,6 @@ static const struct nft_expr_ops nft_reject_netdev_ops = { .init = nft_reject_init, .dump = nft_reject_dump, .validate = nft_reject_netdev_validate, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_reject_netdev_type__read_mostly = {
net/netfilter/nft_rt.c +0 -1
@@ -195,7 +195,6 @@ static const struct nft_expr_ops nft_rt_get_ops = { .init = nft_rt_get_init, .dump = nft_rt_get_dump, .validate = nft_rt_validate, - .reduce = NFT_REDUCE_READONLY, };struct nft_expr_type nft_rt_type__read_mostly = {
net/netfilter/nft_socket.c +0 -26
@@ -249,31 +249,6 @@ static int nft_socket_dump(struct sk_buff *skb,return 0 ; } -static bool nft_socket_reduce (struct nft_regs_track *track, -const struct nft_expr *expr) -{ -const struct nft_socket *priv =nft_expr_priv (expr); -const struct nft_socket *socket; - -if (!nft_reg_track_cmp (track, expr, priv->dreg)) { -nft_reg_track_update (track, expr, priv->dreg, priv->len); -return false; - } - - socket =nft_expr_priv (track->regs[priv->dreg].selector); -if (priv->key != socket->key || - priv->dreg != socket->dreg || - priv->level != socket->level) { -nft_reg_track_update (track, expr, priv->dreg, priv->len); -return false; - } - -if (!track->regs[priv->dreg].bitwise) -return true; - -return nft_expr_reduce_bitwise (track, expr); -} -static int nft_socket_validate (const struct nft_ctx *ctx,const struct nft_expr *expr) {
@@ -296,7 +271,6 @@ static const struct nft_expr_ops nft_socket_ops = { .init = nft_socket_init, .dump = nft_socket_dump, .validate = nft_socket_validate, - .reduce = nft_socket_reduce, };static struct nft_expr_type nft_socket_type__read_mostly = {
net/netfilter/nft_synproxy.c +0 -1
@@ -292,7 +292,6 @@ static const struct nft_expr_ops nft_synproxy_ops = { .dump = nft_synproxy_dump, .type = &nft_synproxy_type, .validate = nft_synproxy_validate, - .reduce = NFT_REDUCE_READONLY, };static struct nft_expr_type nft_synproxy_type__read_mostly = {
net/netfilter/nft_tproxy.c +0 -1
@@ -331,7 +331,6 @@ static const struct nft_expr_ops nft_tproxy_ops = { .init = nft_tproxy_init, .destroy = nft_tproxy_destroy, .dump = nft_tproxy_dump, - .reduce = NFT_REDUCE_READONLY, .validate = nft_tproxy_validate, };
net/netfilter/nft_tunnel.c +0 -26
@@ -124,31 +124,6 @@ static int nft_tunnel_get_dump(struct sk_buff *skb,return -1 ; } -static bool nft_tunnel_get_reduce (struct nft_regs_track *track, -const struct nft_expr *expr) -{ -const struct nft_tunnel *priv =nft_expr_priv (expr); -const struct nft_tunnel *tunnel; - -if (!nft_reg_track_cmp (track, expr, priv->dreg)) { -nft_reg_track_update (track, expr, priv->dreg, priv->len); -return false; - } - - tunnel =nft_expr_priv (track->regs[priv->dreg].selector); -if (priv->key != tunnel->key || - priv->dreg != tunnel->dreg || - priv->mode != tunnel->mode) { -nft_reg_track_update (track, expr, priv->dreg, priv->len); -return false; - } - -if (!track->regs[priv->dreg].bitwise) -return true; - -return false; -} -static struct nft_expr_type nft_tunnel_type;static const struct nft_expr_ops nft_tunnel_get_ops = { .type = &nft_tunnel_type,
@@ -156,7 +131,6 @@ static const struct nft_expr_ops nft_tunnel_get_ops = { .eval = nft_tunnel_get_eval, .init = nft_tunnel_get_init, .dump = nft_tunnel_get_dump, - .reduce = nft_tunnel_get_reduce, };static struct nft_expr_type nft_tunnel_type__read_mostly = {
net/netfilter/nft_xfrm.c +0 -27
@@ -259,32 +259,6 @@ static int nft_xfrm_validate(const struct nft_ctx *ctx, const struct nft_expr *ereturn nft_chain_validate_hooks (ctx->chain, hooks); } -static bool nft_xfrm_reduce (struct nft_regs_track *track, -const struct nft_expr *expr) -{ -const struct nft_xfrm *priv =nft_expr_priv (expr); -const struct nft_xfrm *xfrm; - -if (!nft_reg_track_cmp (track, expr, priv->dreg)) { -nft_reg_track_update (track, expr, priv->dreg, priv->len); -return false; - } - - xfrm =nft_expr_priv (track->regs[priv->dreg].selector); -if (priv->key != xfrm->key || - priv->dreg != xfrm->dreg || - priv->dir != xfrm->dir || - priv->spnum != xfrm->spnum) { -nft_reg_track_update (track, expr, priv->dreg, priv->len); -return false; - } - -if (!track->regs[priv->dreg].bitwise) -return true; - -return nft_expr_reduce_bitwise (track, expr); -} -static struct nft_expr_type nft_xfrm_type;static const struct nft_expr_ops nft_xfrm_get_ops = { .type = &nft_xfrm_type,
@@ -293,7 +267,6 @@ static const struct nft_expr_ops nft_xfrm_get_ops = { .init = nft_xfrm_get_init, .dump = nft_xfrm_get_dump, .validate = nft_xfrm_validate, - .reduce = nft_xfrm_reduce, };static struct nft_expr_type nft_xfrm_type__read_mostly = {
Signature · 1 line
2.52.0
Jakub Kicinski
maintainerRe: [net-next,1/9] ipvs: make ip_vs_svc_table and ip_vs_svc_fwm_table per netns
In reply to Florian WestphalThis is an AI-generated review of your patch. The human sending this email says "FYI"
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
ipvs: make ip_vs_svc_table and ip_vs_svc_fwm_table per netns
This commit converts the global IPVS service tables and their associated mutex from global to per-netns, improving lookup performance in large-scale deployments with multiple network namespaces.
Quoted 5 lines
include/net/ip_vs.h +0
-0
include/net/ip_vs.h line 41
Quoted 9 lines
include/net/ip_vs.h +6
-0@@ -33,6 +33,12 @@#define IP_VS_HDR_INVERSE 1#define IP_VS_HDR_ICMP 2 +/* +* Hash table: for virtual service lookups +*/ +#define IP_VS_SVC_TAB_BITS 8 +#define IP_VS_SVC_TAB_SIZE BIT(IP_VS_SVC_TAB_BITS) +#define IP_VS_SVC_TAB_MASK (IP_VS_SVC_TAB_SIZE - 1)
The patch removes the global mutex definition DEFINE_MUTEX(__ip_vs_mutex) from net/netfilter/ipvs/ip_vs_ctl.c and replaces all usage sites with the per-netns ipvs->service_mutex. However, the extern declaration at line 52 of include/net/ip_vs.h is still present:
extern struct mutex __ip_vs_mutex;
Since no in-tree code references __ip_vs_mutex after this conversion, should this declaration be removed for consistency?
[ ... ]
Quoted 4 lines
net/netfilter/ipvs/ip_vs_ctl.c +0
-0
[ ... ]
Quoted 27 lines
net/netfilter/ipvs/ip_vs_ctl.c +6
-6@@ -2306,9 +2282,9 @@ static struct ip_vs_service *ip_vs_info_array(struct seq_file *seq, loff_t pos)/* look in hash by protocol */ for (idx =0 ; idx <IP_VS_SVC_TAB_SIZE ; idx++) { -hlist_for_each_entry_rcu (svc, &ip_vs_svc_table[idx], s_list) { -if ((svc->ipvs == ipvs) && pos-- ==0 ) { - iter->table = ip_vs_svc_table; +hlist_for_each_entry_rcu (svc, &ipvs->svc_table[idx], s_list) { +if (pos-- ==0 ) { + iter->table = ipvs->svc_table; iter->bucket = idx;return svc; }@@ -2317,10 +2293,10 @@ static struct ip_vs_service *ip_vs_info_array(struct seq_file *seq, loff_t pos)/* keep looking in fwmark */ for (idx =0 ; idx <IP_VS_SVC_TAB_SIZE ; idx++) { -hlist_for_each_entry_rcu (svc, &ip_vs_svc_fwm_table[idx], +hlist_for_each_entry_rcu (svc, &ipvs->svc_fwm_table[idx], f_list) { -if ((svc->ipvs == ipvs) && pos-- ==0 ) { - iter->table = ip_vs_svc_fwm_table; +if (pos-- ==0 ) { + iter->table = ipvs->svc_fwm_table; iter->bucket = idx;return svc; }
[ ... ]
net/netfilter/ipvs/ip_vs_ctl.c static int ip_vs_info_seq_show(struct seq_file *seq, void *v) · line 2398
Quoted 9 lines
net/netfilter/ipvs/ip_vs_ctl.c +1
-1@@ -2414,7 +2392,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)if (svc->ipvs != ipvs)return 0 ; -if (iter->table == ip_vs_svc_table) { +if (iter->table == ipvs->svc_table) {#ifdef CONFIG_IP_VS_IPV6 if (svc->af ==AF_INET6 ) seq_printf(seq, "%s [%pI6]:%04X %s ",
The conversion to per-netns tables makes 'svc->ipvs != ipvs' always false here in ip_vs_info_seq_show(). Every service in ipvs->svc_table belongs to that netns by construction.
Looking at the patch, similar checks were removed everywhere else:
- ip_vs_flush(): removed 'svc->ipvs == ipvs' check
- ip_vs_dst_event(): removed 'svc->ipvs == ipvs' check
- ip_vs_zero_all(): removed 'svc->ipvs == ipvs' check
- __ip_vs_service_find(): removed 'svc->ipvs == ipvs' check
- __ip_vs_svc_fwm_find(): removed 'svc->ipvs == ipvs' check
- ip_vs_genl_dump_services(): removed 'svc->ipvs != ipvs' check
- __ip_vs_get_service_entries(): removed 'svc->ipvs != ipvs' check
- ip_vs_info_array(): removed 'svc->ipvs == ipvs' check
But this one in ip_vs_info_seq_show() was left behind. Should it also be removed for consistency?
Jakub Kicinski
maintainerRe: [net-next,3/9] ipvs: use single svc table
In reply to Florian WestphalThis is an AI-generated review of your patch. The human sending this email says "FYI"
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
ipvs: use single svc table
This patch merges fwmark based services and non-fwmark based services into a single service table, eliminating the separate svc_fwm_table and reducing the complexity of managing two hash tables.
Quoted 4 lines
include/net/ip_vs.h +0
-0
[ ... ]
include/net/ip_vs.h struct netns_ipvs { · line 1050
Quoted 3 lines
include/net/ip_vs.h +0
-0@@ -1050,10 +1049,7 @@ struct netns_ipvs {/* the service mutex that protect svc_table and svc_fwm_table */
^^^^^^^^^^^^^^
include/net/ip_vs.h struct netns_ipvs { · line 1052
Quoted 6 lines
include/net/ip_vs.h +1
-4struct mutex service_mutex; -/* the service table hashed by <protocol, addr, port> */ -struct hlist_head svc_table[IP_VS_SVC_TAB_SIZE ]; -/* the service table hashed by fwmark */ -struct hlist_head svc_fwm_table[IP_VS_SVC_TAB_SIZE ]; +struct hlist_head svc_table[IP_VS_SVC_TAB_SIZE ];/* Services */
Should this comment be updated to reflect the removal of svc_fwm_table? The comment still references both svc_table and svc_fwm_table, but this patch removes svc_fwm_table entirely. Perhaps it should read "protect svc_table" instead.
[ ... ]
Jakub Kicinski
maintainerRe: [net-next,4/9] ipvs: do not keep dest_dst after dest is removed
In reply to Florian WestphalThis is an AI-generated review of your patch. The human sending this email says "FYI"
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
ipvs: do not keep dest_dst after dest is removed
Before now dest->dest_dst is not released when server is moved into dest_trash list after removal. As result, we can keep dst/dev references for long time without actively using them. It is better to avoid walking the dest_trash list when ip_vs_dst_event() receives dev events. So, make sure we do not hold dev references in dest_trash list. As packets can be flying while server is being removed, check the IP_VS_DEST_F_AVAILABLE flag in slow path to ensure we do not save new dev references to removed servers.
Quoted 4 lines
net/netfilter/ipvs/ip_vs_ctl.c +0
-0
[ ... ]
Quoted 6 lines
net/netfilter/ipvs/ip_vs_xmit.c +0
-0@@ -336,9 +336,11 @@ __ip_vs_get_out_rt(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb, goto err_unreach;
net/netfilter/ipvs/ip_vs_xmit.c __ip_vs_get_out_rt(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb, · line 344
Quoted 10 lines
net/netfilter/ipvs/ip_vs_xmit.c +4
-2}/* It is forbidden to attach dest->dest_dst if -* device is going down. +* device is going down or if server is removed and +* stored in dest_trash. */ -if (!rt_dev_is_down (dst_dev_rcu (&rt->dst))) +if (!rt_dev_is_down (dst_dev_rcu (&rt->dst)) && + dest->flags &IP_VS_DEST_F_AVAILABLE )__ip_vs_dst_set (dest, dest_dst, &rt->dst,0 );
Should this be wrapped in parentheses?
In C operator precedence, the logical AND (&&) binds more tightly than the bitwise AND (&). The expression here parses as:
(!rt_dev_is_down(...) && dest->flags) & IP_VS_DEST_F_AVAILABLE
This works correctly only because IP_VS_DEST_F_AVAILABLE is 0x0001, and the logical AND produces 0 or 1, so the bitwise AND with 0x0001 still produces the expected result.
Every other check of IP_VS_DEST_F_AVAILABLE in the IPVS codebase wraps the bitwise operation in parentheses. For example:
net/netfilter/ipvs/ip_vs_core.c:ip_vs_out():
if (likely(dest && (dest->flags & IP_VS_DEST_F_AVAILABLE))) {
...
}net/netfilter/ipvs/ip_vs_conn.c:ip_vs_conn_fill_param_sync():
if (unlikely(dest && !(dest->flags & IP_VS_DEST_F_AVAILABLE))) {
...
}Would it be clearer to write this as:
if (!rt_dev_is_down(dst_dev_rcu(&rt->dst)) &&
(dest->flags & IP_VS_DEST_F_AVAILABLE))Quoted 2 lines
net/netfilter/ipvs/ip_vs_xmit.c +0
-0else noref =0 ;
[ ... ]
net/netfilter/ipvs/ip_vs_xmit.c __ip_vs_get_out_rt_v6(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb, · line 523
Quoted 12 lines
net/netfilter/ipvs/ip_vs_xmit.c +4
-2@@ -513,9 +515,11 @@ __ip_vs_get_out_rt_v6(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb, rt =dst_rt6_info (dst); cookie =rt6_get_cookie (rt);/* It is forbidden to attach dest->dest_dst if -* device is going down. +* device is going down or if server is removed and +* stored in dest_trash. */ -if (!rt_dev_is_down (dst_dev_rcu (&rt->dst))) +if (!rt_dev_is_down (dst_dev_rcu (&rt->dst)) && + dest->flags &IP_VS_DEST_F_AVAILABLE )__ip_vs_dst_set (dest, dest_dst, &rt->dst, cookie);
Same question here in __ip_vs_get_out_rt_v6().
Jakub Kicinski
maintainerRe: [net-next,4/9] ipvs: do not keep dest_dst after dest is removed
Quoted 7 lines · On Wed, 25 Feb 2026 19:41:24 -0800 Jakub Kicinski wrote:
net/netfilter/ipvs/ip_vs_xmit.c __ip_vs_get_out_rt(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb, · line 344
Quoted 4 lines
net/netfilter/ipvs/ip_vs_xmit.c +2
-1-if (!rt_dev_is_down (dst_dev_rcu (&rt->dst))) +if (!rt_dev_is_down (dst_dev_rcu (&rt->dst)) && + dest->flags &IP_VS_DEST_F_AVAILABLE )__ip_vs_dst_set (dest, dest_dst, &rt->dst,0 );Should this be wrapped in parentheses?
Quoted 8 lines
In C operator precedence, the logical AND (&&) binds more tightly than the bitwise AND (&). The expression here parses as:
(!rt_dev_is_down(...) && dest->flags) & IP_VS_DEST_F_AVAILABLEThis works correctly only because
IP_VS_DEST_F_AVAILABLEis0x0001, and the logical AND produces 0 or 1, so the bitwise AND with0x0001still produces the expected result.
Ah, should have skipped this one. It is of course bs. Chris reported it to the developers of the model.
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Tue, 24 Feb 2026 21:50:39 +0100 you wrote:
Hi,
The following patchset contains Netfilter fixes for *net-next*, including IPVS updates from and via Julian Anastasov.
First updates for IPVS. From Julians cover-letter:
[...]
Here is the summary with links:
- [net-next,1/9] ipvs: make ip_vs_svc_table and ip_vs_svc_fwm_table per netns
https://git.kernel.org/netdev/net-next/c/74455a5b4326 - [net-next,2/9] ipvs: some service readers can use RCU https://git.kernel.org/netdev/net-next/c/3de0ec2873ea - [net-next,3/9] ipvs: use single svc table https://git.kernel.org/netdev/net-next/c/b24ae1a387e4 - [net-next,4/9] ipvs: do not keep dest_dst after dest is removed https://git.kernel.org/netdev/net-next/c/40fb72209fd8 - [net-next,5/9] ipvs: use more counters to avoid service lookups https://git.kernel.org/netdev/net-next/c/c59bd9e62e06 - [net-next,6/9] ipvs: no_cport and dropentry counters can be per-net https://git.kernel.org/netdev/net-next/c/09b71fb45946 - [net-next,7/9] netfilter: nft_set_rbtree: don't disable bh when acquiring tree lock https://git.kernel.org/netdev/net-next/c/3aea466a4399 - [net-next,8/9] netfilter: nf_tables: drop obsolete EXPORT_SYMBOLs https://git.kernel.org/netdev/net-next/c/b6461103e01a - [net-next,9/9] netfilter: nf_tables: remove register tracking infrastructure https://git.kernel.org/netdev/net-next/c/6b94d081f81d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Julian Anastasov
maintainerRe: [net-next,1/9] ipvs: make ip_vs_svc_table and ip_vs_svc_fwm_table per netns
In reply to Jakub KicinskiHello,
Quoted 32 lines · Jakub Kicinski
This is an AI-generated review of your patch. The human sending this email says "FYI"
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
ipvs: makeip_vs_svc_tableandip_vs_svc_fwm_tableper netnsThis commit converts the global IPVS service tables and their associated mutex from global to per-netns, improving lookup performance in large-scale deployments with multiple network namespaces.
Quoted 5 lines
include/net/ip_vs.h +0
-0include/net/ip_vs.h line 41
Quoted 9 lines
include/net/ip_vs.h +6
-0@@ -33,6 +33,12 @@#define IP_VS_HDR_INVERSE 1#define IP_VS_HDR_ICMP 2 +/* +* Hash table: for virtual service lookups +*/ +#define IP_VS_SVC_TAB_BITS 8 +#define IP_VS_SVC_TAB_SIZE BIT(IP_VS_SVC_TAB_BITS) +#define IP_VS_SVC_TAB_MASK (IP_VS_SVC_TAB_SIZE - 1)The patch removes the global mutex definition
DEFINE_MUTEX(__ip_vs_mutex)fromnet/netfilter/ipvs/ip_vs_ctl.cand replaces all usage sites with the per-netnsipvs->service_mutex. However, the extern declaration at line 52 ofinclude/net/ip_vs.his still present:
Quoted 1 line
extern struct mutex __ip_vs_mutex;
I have fixes for all these issues in a followup
patches. Sorry that I forgot to push them to the right patch.
Quoted 2 lines
Since no in-tree code references
__ip_vs_mutexafter this conversion, should this declaration be removed for consistency?
It will be removed in a followup patchset, in its patch 3/5.
Quoted 64 lines
[ ... ]
Quoted 4 lines
net/netfilter/ipvs/ip_vs_ctl.c +0
-0[ ... ]
Quoted 27 lines
net/netfilter/ipvs/ip_vs_ctl.c +6
-6@@ -2306,9 +2282,9 @@ static struct ip_vs_service *ip_vs_info_array(struct seq_file *seq, loff_t pos)/* look in hash by protocol */ for (idx =0 ; idx <IP_VS_SVC_TAB_SIZE ; idx++) { -hlist_for_each_entry_rcu (svc, &ip_vs_svc_table[idx], s_list) { -if ((svc->ipvs == ipvs) && pos-- ==0 ) { - iter->table = ip_vs_svc_table; +hlist_for_each_entry_rcu (svc, &ipvs->svc_table[idx], s_list) { +if (pos-- ==0 ) { + iter->table = ipvs->svc_table; iter->bucket = idx;return svc; }@@ -2317,10 +2293,10 @@ static struct ip_vs_service *ip_vs_info_array(struct seq_file *seq, loff_t pos)/* keep looking in fwmark */ for (idx =0 ; idx <IP_VS_SVC_TAB_SIZE ; idx++) { -hlist_for_each_entry_rcu (svc, &ip_vs_svc_fwm_table[idx], +hlist_for_each_entry_rcu (svc, &ipvs->svc_fwm_table[idx], f_list) { -if ((svc->ipvs == ipvs) && pos-- ==0 ) { - iter->table = ip_vs_svc_fwm_table; +if (pos-- ==0 ) { + iter->table = ipvs->svc_fwm_table; iter->bucket = idx;return svc; }[ ... ]
net/netfilter/ipvs/ip_vs_ctl.c static int ip_vs_info_seq_show(struct seq_file *seq, void *v) · line 2398
Quoted 9 lines
net/netfilter/ipvs/ip_vs_ctl.c +1
-1@@ -2414,7 +2392,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)if (svc->ipvs != ipvs)return 0 ; -if (iter->table == ip_vs_svc_table) { +if (iter->table == ipvs->svc_table) {#ifdef CONFIG_IP_VS_IPV6 if (svc->af ==AF_INET6 ) seq_printf(seq, "%s [%pI6]:%04X %s ",The conversion to per-netns tables makes '
svc->ipvs!= ipvs' always false here inip_vs_info_seq_show(). Every service inipvs->svc_tablebelongs to that netns by construction.Looking at the patch, similar checks were removed everywhere else:
-ip_vs_flush(): removed 'svc->ipvs== ipvs' check
-ip_vs_dst_event(): removed 'svc->ipvs== ipvs' check
-ip_vs_zero_all(): removed 'svc->ipvs== ipvs' check
-__ip_vs_service_find(): removed 'svc->ipvs== ipvs' check
-__ip_vs_svc_fwm_find(): removed 'svc->ipvs== ipvs' check
-ip_vs_genl_dump_services(): removed 'svc->ipvs!= ipvs' check
-__ip_vs_get_service_entries(): removed 'svc->ipvs!= ipvs' check
-ip_vs_info_array(): removed 'svc->ipvs== ipvs' check
Quoted 2 lines
But this one in
ip_vs_info_seq_show()was left behind. Should it also be removed for consistency?
It was removed later in patch 3 ("ipvs: use single svc table").
Comments about patch 3/9:
- svc_fwm_table in comments will be removed in a followup patchset, in its patch 3/5.
Comments about patch 4/9:
- bitwise ops have precedence over the logical ops but as the series is already applied we can make it less confusing later
Regards
--
Julian Anastasov <[email protected]>