Skip to content

Commit

Permalink
netfilter: conntrack: remove empty pernet fini stubs
Browse files Browse the repository at this point in the history
after moving sysctl handling into single place, the init functions
can't fail anymore and some of the fini functions are empty.

Remove them and change return type to void.
This also simplifies error unwinding in conntrack module init path.

Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
  • Loading branch information
Florian Westphal authored and ummakynes committed Dec 20, 2018
1 parent cb2833e commit fc3893f
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 62 deletions.
3 changes: 1 addition & 2 deletions include/net/netfilter/nf_conntrack_acct.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ static inline void nf_ct_set_acct(struct net *net, bool enable)
net->ct.sysctl_acct = enable;
}

int nf_conntrack_acct_pernet_init(struct net *net);
void nf_conntrack_acct_pernet_fini(struct net *net);
void nf_conntrack_acct_pernet_init(struct net *net);

int nf_conntrack_acct_init(void);
void nf_conntrack_acct_fini(void);
Expand Down
7 changes: 2 additions & 5 deletions include/net/netfilter/nf_conntrack_ecache.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void nf_ct_expect_event_report(enum ip_conntrack_expect_events event,
struct nf_conntrack_expect *exp,
u32 portid, int report);

int nf_conntrack_ecache_pernet_init(struct net *net);
void nf_conntrack_ecache_pernet_init(struct net *net);
void nf_conntrack_ecache_pernet_fini(struct net *net);

int nf_conntrack_ecache_init(void);
Expand Down Expand Up @@ -182,10 +182,7 @@ static inline void nf_ct_expect_event_report(enum ip_conntrack_expect_events e,
u32 portid,
int report) {}

static inline int nf_conntrack_ecache_pernet_init(struct net *net)
{
return 0;
}
static inline void nf_conntrack_ecache_pernet_init(struct net *net) {}

static inline void nf_conntrack_ecache_pernet_fini(struct net *net)
{
Expand Down
3 changes: 1 addition & 2 deletions include/net/netfilter/nf_conntrack_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ static inline void *nfct_help_data(const struct nf_conn *ct)
return (void *)help->data;
}

int nf_conntrack_helper_pernet_init(struct net *net);
void nf_conntrack_helper_pernet_fini(struct net *net);
void nf_conntrack_helper_pernet_init(struct net *net);

int nf_conntrack_helper_init(void);
void nf_conntrack_helper_fini(void);
Expand Down
13 changes: 2 additions & 11 deletions include/net/netfilter/nf_conntrack_timestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,12 @@ static inline void nf_ct_set_tstamp(struct net *net, bool enable)
}

#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
int nf_conntrack_tstamp_pernet_init(struct net *net);
void nf_conntrack_tstamp_pernet_fini(struct net *net);
void nf_conntrack_tstamp_pernet_init(struct net *net);

int nf_conntrack_tstamp_init(void);
void nf_conntrack_tstamp_fini(void);
#else
static inline int nf_conntrack_tstamp_pernet_init(struct net *net)
{
return 0;
}

static inline void nf_conntrack_tstamp_pernet_fini(struct net *net)
{
return;
}
static inline void nf_conntrack_tstamp_pernet_init(struct net *net) {}

static inline int nf_conntrack_tstamp_init(void)
{
Expand Down
7 changes: 1 addition & 6 deletions net/netfilter/nf_conntrack_acct.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,9 @@ static const struct nf_ct_ext_type acct_extend = {
.id = NF_CT_EXT_ACCT,
};

int nf_conntrack_acct_pernet_init(struct net *net)
void nf_conntrack_acct_pernet_init(struct net *net)
{
net->ct.sysctl_acct = nf_ct_acct;
return 0;
}

void nf_conntrack_acct_pernet_fini(struct net *net)
{
}

int nf_conntrack_acct_init(void)
Expand Down
28 changes: 6 additions & 22 deletions net/netfilter/nf_conntrack_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2110,10 +2110,7 @@ void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list)

list_for_each_entry(net, net_exit_list, exit_list) {
nf_conntrack_proto_pernet_fini(net);
nf_conntrack_helper_pernet_fini(net);
nf_conntrack_ecache_pernet_fini(net);
nf_conntrack_tstamp_pernet_fini(net);
nf_conntrack_acct_pernet_fini(net);
nf_conntrack_expect_pernet_fini(net);
free_percpu(net->ct.stat);
free_percpu(net->ct.pcpu_lists);
Expand Down Expand Up @@ -2410,32 +2407,19 @@ int nf_conntrack_init_net(struct net *net)
ret = nf_conntrack_expect_pernet_init(net);
if (ret < 0)
goto err_expect;
ret = nf_conntrack_acct_pernet_init(net);
if (ret < 0)
goto err_acct;
ret = nf_conntrack_tstamp_pernet_init(net);
if (ret < 0)
goto err_tstamp;
ret = nf_conntrack_ecache_pernet_init(net);
if (ret < 0)
goto err_ecache;
ret = nf_conntrack_helper_pernet_init(net);
if (ret < 0)
goto err_helper;

nf_conntrack_acct_pernet_init(net);
nf_conntrack_tstamp_pernet_init(net);
nf_conntrack_ecache_pernet_init(net);
nf_conntrack_helper_pernet_init(net);

ret = nf_conntrack_proto_pernet_init(net);
if (ret < 0)
goto err_proto;
return 0;

err_proto:
nf_conntrack_helper_pernet_fini(net);
err_helper:
nf_conntrack_ecache_pernet_fini(net);
err_ecache:
nf_conntrack_tstamp_pernet_fini(net);
err_tstamp:
nf_conntrack_acct_pernet_fini(net);
err_acct:
nf_conntrack_expect_pernet_fini(net);
err_expect:
free_percpu(net->ct.stat);
Expand Down
3 changes: 1 addition & 2 deletions net/netfilter/nf_conntrack_ecache.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,10 @@ static const struct nf_ct_ext_type event_extend = {
.id = NF_CT_EXT_ECACHE,
};

int nf_conntrack_ecache_pernet_init(struct net *net)
void nf_conntrack_ecache_pernet_init(struct net *net)
{
net->ct.sysctl_events = nf_ct_events;
INIT_DELAYED_WORK(&net->ct.ecache_dwork, ecache_work);
return 0;
}

void nf_conntrack_ecache_pernet_fini(struct net *net)
Expand Down
7 changes: 1 addition & 6 deletions net/netfilter/nf_conntrack_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,10 @@ static const struct nf_ct_ext_type helper_extend = {
.id = NF_CT_EXT_HELPER,
};

int nf_conntrack_helper_pernet_init(struct net *net)
void nf_conntrack_helper_pernet_init(struct net *net)
{
net->ct.auto_assign_helper_warned = false;
net->ct.sysctl_auto_assign_helper = nf_ct_auto_assign_helper;
return 0;
}

void nf_conntrack_helper_pernet_fini(struct net *net)
{
}

int nf_conntrack_helper_init(void)
Expand Down
7 changes: 1 addition & 6 deletions net/netfilter/nf_conntrack_timestamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,9 @@ static const struct nf_ct_ext_type tstamp_extend = {
.id = NF_CT_EXT_TSTAMP,
};

int nf_conntrack_tstamp_pernet_init(struct net *net)
void nf_conntrack_tstamp_pernet_init(struct net *net)
{
net->ct.sysctl_tstamp = nf_ct_tstamp;
return 0;
}

void nf_conntrack_tstamp_pernet_fini(struct net *net)
{
}

int nf_conntrack_tstamp_init(void)
Expand Down

0 comments on commit fc3893f

Please sign in to comment.