Skip to content

Commit 8a75a2c

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: conntrack: remove unconfirmed list
It has no function anymore and can be removed. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent ace53fd commit 8a75a2c

File tree

4 files changed

+3
-105
lines changed

4 files changed

+3
-105
lines changed

include/net/netfilter/nf_conntrack.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ struct nf_conn {
101101
/* Have we seen traffic both ways yet? (bitset) */
102102
unsigned long status;
103103

104-
u16 cpu;
105104
possible_net_t ct_net;
106105

107106
#if IS_ENABLED(CONFIG_NF_NAT)

include/net/netns/conntrack.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ struct nf_ip_net {
9393
#endif
9494
};
9595

96-
struct ct_pcpu {
97-
spinlock_t lock;
98-
struct hlist_nulls_head unconfirmed;
99-
};
100-
10196
struct netns_ct {
10297
#ifdef CONFIG_NF_CONNTRACK_EVENTS
10398
bool ecache_dwork_pending;
@@ -109,7 +104,6 @@ struct netns_ct {
109104
u8 sysctl_tstamp;
110105
u8 sysctl_checksum;
111106

112-
struct ct_pcpu __percpu *pcpu_lists;
113107
struct ip_conntrack_stat __percpu *stat;
114108
struct nf_ct_event_notifier __rcu *nf_conntrack_event_cb;
115109
struct nf_ip_net nf_ct_proto;

net/netfilter/nf_conntrack_core.c

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -525,35 +525,6 @@ clean_from_lists(struct nf_conn *ct)
525525
nf_ct_remove_expectations(ct);
526526
}
527527

528-
/* must be called with local_bh_disable */
529-
static void nf_ct_add_to_unconfirmed_list(struct nf_conn *ct)
530-
{
531-
struct ct_pcpu *pcpu;
532-
533-
/* add this conntrack to the (per cpu) unconfirmed list */
534-
ct->cpu = smp_processor_id();
535-
pcpu = per_cpu_ptr(nf_ct_net(ct)->ct.pcpu_lists, ct->cpu);
536-
537-
spin_lock(&pcpu->lock);
538-
hlist_nulls_add_head(&ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode,
539-
&pcpu->unconfirmed);
540-
spin_unlock(&pcpu->lock);
541-
}
542-
543-
/* must be called with local_bh_disable */
544-
static void nf_ct_del_from_unconfirmed_list(struct nf_conn *ct)
545-
{
546-
struct ct_pcpu *pcpu;
547-
548-
/* We overload first tuple to link into unconfirmed list.*/
549-
pcpu = per_cpu_ptr(nf_ct_net(ct)->ct.pcpu_lists, ct->cpu);
550-
551-
spin_lock(&pcpu->lock);
552-
BUG_ON(hlist_nulls_unhashed(&ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode));
553-
hlist_nulls_del_rcu(&ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode);
554-
spin_unlock(&pcpu->lock);
555-
}
556-
557528
#define NFCT_ALIGN(len) (((len) + NFCT_INFOMASK) & ~NFCT_INFOMASK)
558529

559530
/* Released via nf_ct_destroy() */
@@ -625,19 +596,13 @@ void nf_ct_destroy(struct nf_conntrack *nfct)
625596
if (unlikely(nf_ct_protonum(ct) == IPPROTO_GRE))
626597
destroy_gre_conntrack(ct);
627598

628-
local_bh_disable();
629599
/* Expectations will have been removed in clean_from_lists,
630600
* except TFTP can create an expectation on the first packet,
631601
* before connection is in the list, so we need to clean here,
632602
* too.
633603
*/
634604
nf_ct_remove_expectations(ct);
635605

636-
if (unlikely(!nf_ct_is_confirmed(ct)))
637-
nf_ct_del_from_unconfirmed_list(ct);
638-
639-
local_bh_enable();
640-
641606
if (ct->master)
642607
nf_ct_put(ct->master);
643608

@@ -1248,7 +1213,6 @@ __nf_conntrack_confirm(struct sk_buff *skb)
12481213
* user context, else we insert an already 'dead' hash, blocking
12491214
* further use of that particular connection -JM.
12501215
*/
1251-
nf_ct_del_from_unconfirmed_list(ct);
12521216
ct->status |= IPS_CONFIRMED;
12531217

12541218
if (unlikely(nf_ct_is_dying(ct))) {
@@ -1803,9 +1767,8 @@ init_conntrack(struct net *net, struct nf_conn *tmpl,
18031767
if (!exp)
18041768
__nf_ct_try_assign_helper(ct, tmpl, GFP_ATOMIC);
18051769

1806-
/* Now it is inserted into the unconfirmed list, set refcount to 1. */
1770+
/* Now it is going to be associated with an sk_buff, set refcount to 1. */
18071771
refcount_set(&ct->ct_general.use, 1);
1808-
nf_ct_add_to_unconfirmed_list(ct);
18091772

18101773
local_bh_enable();
18111774

@@ -2594,7 +2557,6 @@ void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list)
25942557
nf_conntrack_ecache_pernet_fini(net);
25952558
nf_conntrack_expect_pernet_fini(net);
25962559
free_percpu(net->ct.stat);
2597-
free_percpu(net->ct.pcpu_lists);
25982560
}
25992561
}
26002562

@@ -2805,26 +2767,14 @@ int nf_conntrack_init_net(struct net *net)
28052767
{
28062768
struct nf_conntrack_net *cnet = nf_ct_pernet(net);
28072769
int ret = -ENOMEM;
2808-
int cpu;
28092770

28102771
BUILD_BUG_ON(IP_CT_UNTRACKED == IP_CT_NUMBER);
28112772
BUILD_BUG_ON_NOT_POWER_OF_2(CONNTRACK_LOCKS);
28122773
atomic_set(&cnet->count, 0);
28132774

2814-
net->ct.pcpu_lists = alloc_percpu(struct ct_pcpu);
2815-
if (!net->ct.pcpu_lists)
2816-
goto err_stat;
2817-
2818-
for_each_possible_cpu(cpu) {
2819-
struct ct_pcpu *pcpu = per_cpu_ptr(net->ct.pcpu_lists, cpu);
2820-
2821-
spin_lock_init(&pcpu->lock);
2822-
INIT_HLIST_NULLS_HEAD(&pcpu->unconfirmed, UNCONFIRMED_NULLS_VAL);
2823-
}
2824-
28252775
net->ct.stat = alloc_percpu(struct ip_conntrack_stat);
28262776
if (!net->ct.stat)
2827-
goto err_pcpu_lists;
2777+
return ret;
28282778

28292779
ret = nf_conntrack_expect_pernet_init(net);
28302780
if (ret < 0)
@@ -2840,8 +2790,5 @@ int nf_conntrack_init_net(struct net *net)
28402790

28412791
err_expect:
28422792
free_percpu(net->ct.stat);
2843-
err_pcpu_lists:
2844-
free_percpu(net->ct.pcpu_lists);
2845-
err_stat:
28462793
return ret;
28472794
}

net/netfilter/nf_conntrack_netlink.c

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,49 +1752,7 @@ static int ctnetlink_dump_one_entry(struct sk_buff *skb,
17521752
static int
17531753
ctnetlink_dump_unconfirmed(struct sk_buff *skb, struct netlink_callback *cb)
17541754
{
1755-
struct ctnetlink_list_dump_ctx *ctx = (void *)cb->ctx;
1756-
struct nf_conn *ct, *last;
1757-
struct nf_conntrack_tuple_hash *h;
1758-
struct hlist_nulls_node *n;
1759-
struct net *net = sock_net(skb->sk);
1760-
int res, cpu;
1761-
1762-
if (ctx->done)
1763-
return 0;
1764-
1765-
last = ctx->last;
1766-
1767-
for (cpu = ctx->cpu; cpu < nr_cpu_ids; cpu++) {
1768-
struct ct_pcpu *pcpu;
1769-
1770-
if (!cpu_possible(cpu))
1771-
continue;
1772-
1773-
pcpu = per_cpu_ptr(net->ct.pcpu_lists, cpu);
1774-
spin_lock_bh(&pcpu->lock);
1775-
restart:
1776-
hlist_nulls_for_each_entry(h, n, &pcpu->unconfirmed, hnnode) {
1777-
ct = nf_ct_tuplehash_to_ctrack(h);
1778-
1779-
res = ctnetlink_dump_one_entry(skb, cb, ct, false);
1780-
if (res < 0) {
1781-
ctx->cpu = cpu;
1782-
spin_unlock_bh(&pcpu->lock);
1783-
goto out;
1784-
}
1785-
}
1786-
if (ctx->last) {
1787-
ctx->last = NULL;
1788-
goto restart;
1789-
}
1790-
spin_unlock_bh(&pcpu->lock);
1791-
}
1792-
ctx->done = true;
1793-
out:
1794-
if (last)
1795-
nf_ct_put(last);
1796-
1797-
return skb->len;
1755+
return 0;
17981756
}
17991757

18001758
static int

0 commit comments

Comments
 (0)