netfilter/ipvs patches
Subsystems (4)
Pablo Neira Ayuso
maintainercover netfilter/ipvs patches
Hi David,
This patchset for -stable contains:
1) Fix a crash in IPVS when exitting from netns. This applies cleanly starting 3.2.
2) Perform garbage collection from process context in hashlimit, otherwise this match can hold the cpu for 500ms with large tables. Patch applies to 3.14 and 3.16.
3) Maintain all DSCP and ECN bits for ipv6 tun forwarding in ipvs. Patch applies starting 3.4.
4) The cgroup match rejects the id 0 for no good reason and Samsumg people needs this to get cgroup match working in previous kernels. This one-liner applies starting 3.14.
5) Fix wrong family in hook registration in ipvs, according to my scripts, this patch applies cleanly starting 3.10.
6) Fix crash in nf_tables when updating unset chain counters. Patch applies to 3.16 only.
I'm sending this batch for -stable submission to netdev in the way I interpreted from Documentation/networking/netdev-FAQ.txt.
Every patch contains the upstream commit and the tag that indicates the kernel version as specified by the tag:
Which is the tag I've been using in -stable submissions so far.
Let me know if the way I made is fine with you. Alternatively, I can make upcoming submissions for -stable in a better way. I can also submit netfilter/ipvs patches myself, including you, the netdev and the stable lists in the CC, so you can ack this if you consider they are OK and people can follow track of what is submitted to -stable from my side.
Thanks!
Pablo Neira Ayuso
maintainerPATCH 1/6 ipvs: avoid netns exit crash on ip_vs_conn_drop_conntrack
From: Julian Anastasov <[email protected]>
[ upstream commit 2627b7e15c5064ddd5e578e4efd948d48d531a3f ]
commit 8f4e0a18682d91 ("IPVS netns exit causes crash in conntrack") added second ip_vs_conn_drop_conntrack call instead of just adding the needed check. As result, the first call still can cause crash on netns exit. Remove it.
--- net/netfilter/ipvs/ip_vs_conn.c | 1 - 1 file changed, 1 deletion(-)
net/netfilter/ipvs/ip_vs_conn.c +0 -1
@@ -797,7 +797,6 @@ static void ip_vs_conn_expire(unsigned long data)ip_vs_control_del (cp);if (cp->flags &IP_VS_CONN_F_NFCT ) { -ip_vs_conn_drop_conntrack (cp);/* Do not access conntracks during subsys cleanup * because nf_conntrack_find_get can not be used after * conntrack cleanup for the net.
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 2/6 netfilter: xt_hashlimit: perform garbage collection from process context
In reply to Pablo Neira AyusoFrom: Eric Dumazet <[email protected]>
[ upstream commit 7bd8490eef9776ced7632345df5133384b6be0fe ]
xt_hashlimit cannot be used with large hash tables, because garbage collector is run from a timer. If table is really big, its possible to hold cpu for more than 500 msec, which is unacceptable.
Switch to a work queue, and use proper scheduling points to remove latencies spikes.
Later, we also could switch to a smoother garbage collection done at lookup time, one bucket at a time...
--- net/netfilter/xt_hashlimit.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
net/netfilter/xt_hashlimit.c +16 -15
@@ -104,7 +104,7 @@ struct xt_hashlimit_htable {spinlock_t lock;/* lock for list_head */ u_int32_t rnd;/* random seed for hash */ unsigned int count;/* number entries in table */ -struct timer_list timer;/* timer for gc */ +struct delayed_work gc_work;/* seq_file stuff */ struct proc_dir_entry *pde;
@@ -213,7 +213,7 @@ dsthash_free(struct xt_hashlimit_htable *ht, struct dsthash_ent *ent)call_rcu_bh (&ent->rcu, dsthash_free_rcu); ht->count--; } -static void htable_gc (unsigned long htlong); +static void htable_gc (struct work_struct *work);static int htable_create (struct net *net,struct xt_hashlimit_mtinfo1 *minfo,u_int8_t family)
@@ -273,9 +273,9 @@ static int htable_create(struct net *net, struct xt_hashlimit_mtinfo1 *minfo, } hinfo->net = net; -setup_timer (&hinfo->timer, htable_gc, (unsigned long )hinfo); - hinfo->timer.expires = jiffies +msecs_to_jiffies (hinfo->cfg.gc_interval); -add_timer (&hinfo->timer); +INIT_DEFERRABLE_WORK (&hinfo->gc_work, htable_gc); +queue_delayed_work (system_power_efficient_wq, &hinfo->gc_work, +msecs_to_jiffies (hinfo->cfg.gc_interval));hlist_add_head (&hinfo->node, &hashlimit_net->htables);
@@ -300,29 +300,30 @@ static void htable_selective_cleanup(struct xt_hashlimit_htable *ht, {unsigned int i; -/* lock hash table and iterate over it */ -spin_lock_bh (&ht->lock);for (i =0 ; i < ht->cfg.size; i++) {struct dsthash_ent *dh;struct hlist_node *n; + +spin_lock_bh (&ht->lock);hlist_for_each_entry_safe (dh, n, &ht->hash[i], node) {if ((*select)(ht, dh))dsthash_free (ht, dh); } +spin_unlock_bh (&ht->lock); +cond_resched (); } -spin_unlock_bh (&ht->lock); } -/* hash table garbage collector, run by timer */ -static void htable_gc (unsigned long htlong) +static void htable_gc (struct work_struct *work) { -struct xt_hashlimit_htable *ht = (struct xt_hashlimit_htable *)htlong; +struct xt_hashlimit_htable *ht; + + ht = container_of(work, struct xt_hashlimit_htable, gc_work.work);htable_selective_cleanup (ht, select_gc); -/* re-add the timer accordingly */ - ht->timer.expires = jiffies +msecs_to_jiffies (ht->cfg.gc_interval); -add_timer (&ht->timer); +queue_delayed_work (system_power_efficient_wq, + &ht->gc_work,msecs_to_jiffies (ht->cfg.gc_interval)); }static void htable_remove_proc_entry (struct xt_hashlimit_htable *hinfo)
@@ -341,7 +342,7 @@ static void htable_remove_proc_entry(struct xt_hashlimit_htable *hinfo)static void htable_destroy (struct xt_hashlimit_htable *hinfo) { -del_timer_sync (&hinfo->timer); +cancel_delayed_work_sync (&hinfo->gc_work);htable_remove_proc_entry (hinfo);htable_selective_cleanup (hinfo, select_all);kfree (hinfo->name);
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 3/6 ipvs: Maintain all DSCP and ECN bits for ipv6 tun forwarding
In reply to Pablo Neira AyusoFrom: Alex Gartrell <[email protected]>
[ upstream commit 76f084bc10004b3050b2cff9cfac29148f1f6088 ]
Previously, only the four high bits of the tclass were maintained in the ipv6 case. This matches the behavior of ipv4, though whether or not we should reflect ECN bits may be up for debate.
--- net/netfilter/ipvs/ip_vs_xmit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipvs/ip_vs_xmit.c +1 -1
@@ -967,8 +967,8 @@ ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp, iph->nexthdr =IPPROTO_IPV6 ; iph->payload_len = old_iph->payload_len;be16_add_cpu (&iph->payload_len,sizeof (*old_iph)); - iph->priority = old_iph->priority;memset (&iph->flow_lbl,0 ,sizeof (iph->flow_lbl)); +ipv6_change_dsfield (iph,0 ,ipv6_get_dsfield (old_iph)); iph->daddr = cp->daddr.in6; iph->saddr = saddr; iph->hop_limit = old_iph->hop_limit;
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 4/6 netfilter: x_tables: allow to use default cgroup match
In reply to Pablo Neira AyusoFrom: Daniel Borkmann <[email protected]>
[ upstream commit caa8ad94edf686d02b555c65a6162c0d1b434958 ]
There's actually no good reason why we cannot use cgroup id 0, so lets just remove this artificial barrier.
--- net/netfilter/xt_cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/xt_cgroup.c +1 -1
@@ -31,7 +31,7 @@ static int cgroup_mt_check(const struct xt_mtchk_param *par)if (info->invert & ~1 )return -EINVAL ; -return info->id ?0 : -EINVAL ; +return 0 ; } static bool
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 5/6 ipvs: fix ipv6 hook registration for local replies
In reply to Pablo Neira AyusoFrom: Julian Anastasov <[email protected]>
[ upstream commit eb90b0c734ad793d5f5bf230a9e9a4dcc48df8aa ]
commit fc604767613b6d2036cdc35b660bc39451040a47 ("ipvs: changes for local real server") from 2.6.37 introduced DNAT support to local real server but the IPv6 LOCAL_OUT handler ip_vs_local_reply6() is registered incorrectly as IPv4 hook causing any outgoing IPv4 traffic to be dropped depending on the IP header values.
Chris tracked down the problem to CONFIG_IP_VS_IPV6=y
Bug report: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1349768
--- net/netfilter/ipvs/ip_vs_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipvs/ip_vs_core.c +1 -1
@@ -1906,7 +1906,7 @@ static struct nf_hook_ops ip_vs_ops[] __read_mostly = { { .hook = ip_vs_local_reply6, .owner = THIS_MODULE, - .pf = NFPROTO_IPV4, + .pf = NFPROTO_IPV6, .hooknum = NF_INET_LOCAL_OUT, .priority = NF_IP6_PRI_NAT_DST + 1, },
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 6/6 netfilter: nf_tables: don't update chain with unset counters
In reply to Pablo Neira Ayuso[ upstream commit b88825de8545ad252c31543fef13cadf4de7a2bc ]
Fix possible replacement of the per-cpu chain counters by null pointer when updating an existing chain in the commit path.
--- net/netfilter/nf_tables_api.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/nf_tables_api.c +3 -0
@@ -899,6 +899,9 @@ static struct nft_stats __percpu *nft_stats_alloc(const struct nlattr *attr)static void nft_chain_stats_replace (struct nft_base_chain *chain,struct nft_stats __percpu *newstats) { +if (newstats ==NULL ) +return ; +if (chain->stats) {struct nft_stats __percpu *oldstats =nft_dereference (chain->stats);
Signature · 1 line
1.7.10.4