Skip to content

Commit 8eeef23

Browse files
Liping Zhangummakynes
authored andcommitted
netfilter: nf_ct_ext: invoke destroy even when ext is not attached
For NF_NAT_MANIP_SRC, we will insert the ct to the nat_bysource_table, then remove it from the nat_bysource_table via nat_extend->destroy. But now, the nat extension is attached on demand, so if the nat extension is not attached, we will not be notified when the ct is destroyed, i.e. we may fail to remove ct from the nat_bysource_table. So just keep it simple, even if the extension is not attached, we will still invoke the related ext->destroy. And this will also preserve the flexibility for the future extension. Fixes: 9a08ecf ("netfilter: don't attach a nat extension by default") Signed-off-by: Liping Zhang <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent d1908ca commit 8eeef23

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

include/net/netfilter/nf_conntrack_extend.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,7 @@ static inline void *__nf_ct_ext_find(const struct nf_conn *ct, u8 id)
6969
((id##_TYPE *)__nf_ct_ext_find((ext), (id)))
7070

7171
/* Destroy all relationships */
72-
void __nf_ct_ext_destroy(struct nf_conn *ct);
73-
static inline void nf_ct_ext_destroy(struct nf_conn *ct)
74-
{
75-
if (ct->ext)
76-
__nf_ct_ext_destroy(ct);
77-
}
72+
void nf_ct_ext_destroy(struct nf_conn *ct);
7873

7974
/* Free operation. If you want to free a object referred from private area,
8075
* please implement __nf_ct_ext_free() and call it.

net/netfilter/nf_conntrack_extend.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,12 @@ static struct nf_ct_ext_type __rcu *nf_ct_ext_types[NF_CT_EXT_NUM];
2020
static DEFINE_MUTEX(nf_ct_ext_type_mutex);
2121
#define NF_CT_EXT_PREALLOC 128u /* conntrack events are on by default */
2222

23-
void __nf_ct_ext_destroy(struct nf_conn *ct)
23+
void nf_ct_ext_destroy(struct nf_conn *ct)
2424
{
2525
unsigned int i;
2626
struct nf_ct_ext_type *t;
27-
struct nf_ct_ext *ext = ct->ext;
2827

2928
for (i = 0; i < NF_CT_EXT_NUM; i++) {
30-
if (!__nf_ct_ext_exist(ext, i))
31-
continue;
32-
3329
rcu_read_lock();
3430
t = rcu_dereference(nf_ct_ext_types[i]);
3531

@@ -42,7 +38,7 @@ void __nf_ct_ext_destroy(struct nf_conn *ct)
4238
rcu_read_unlock();
4339
}
4440
}
45-
EXPORT_SYMBOL(__nf_ct_ext_destroy);
41+
EXPORT_SYMBOL(nf_ct_ext_destroy);
4642

4743
void *nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp)
4844
{

0 commit comments

Comments
 (0)