netfilter: nf_ct_dccp: add dccp_kmemdup_sysctl_table function
This patch is a cleanup. It adds dccp_kmemdup_sysctl_table to split code into smaller chunks. Yet it prepares introduction of nf_conntrack_proto_*_sysctl.c. Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
22ac03772f
commit
54b8873f7c
|
@ -387,7 +387,7 @@ dccp_state_table[CT_DCCP_ROLE_MAX + 1][DCCP_PKT_SYNCACK + 1][CT_DCCP_MAX + 1] =
|
||||||
/* this module per-net specifics */
|
/* this module per-net specifics */
|
||||||
static int dccp_net_id __read_mostly;
|
static int dccp_net_id __read_mostly;
|
||||||
struct dccp_net {
|
struct dccp_net {
|
||||||
struct nf_proto_net np;
|
struct nf_proto_net pn;
|
||||||
int dccp_loose;
|
int dccp_loose;
|
||||||
unsigned int dccp_timeout[CT_DCCP_MAX + 1];
|
unsigned int dccp_timeout[CT_DCCP_MAX + 1];
|
||||||
};
|
};
|
||||||
|
@ -815,26 +815,13 @@ static struct ctl_table dccp_sysctl_table[] = {
|
||||||
};
|
};
|
||||||
#endif /* CONFIG_SYSCTL */
|
#endif /* CONFIG_SYSCTL */
|
||||||
|
|
||||||
static int dccp_init_net(struct net *net, u_int16_t proto)
|
static int dccp_kmemdup_sysctl_table(struct nf_proto_net *pn,
|
||||||
|
struct dccp_net *dn)
|
||||||
{
|
{
|
||||||
struct dccp_net *dn = dccp_pernet(net);
|
#ifdef CONFIG_SYSCTL
|
||||||
struct nf_proto_net *pn = (struct nf_proto_net *)dn;
|
if (pn->ctl_table)
|
||||||
|
return 0;
|
||||||
|
|
||||||
#ifdef CONFIG_SYSCTL
|
|
||||||
if (!pn->ctl_table) {
|
|
||||||
#else
|
|
||||||
if (!pn->users++) {
|
|
||||||
#endif
|
|
||||||
/* default values */
|
|
||||||
dn->dccp_loose = 1;
|
|
||||||
dn->dccp_timeout[CT_DCCP_REQUEST] = 2 * DCCP_MSL;
|
|
||||||
dn->dccp_timeout[CT_DCCP_RESPOND] = 4 * DCCP_MSL;
|
|
||||||
dn->dccp_timeout[CT_DCCP_PARTOPEN] = 4 * DCCP_MSL;
|
|
||||||
dn->dccp_timeout[CT_DCCP_OPEN] = 12 * 3600 * HZ;
|
|
||||||
dn->dccp_timeout[CT_DCCP_CLOSEREQ] = 64 * HZ;
|
|
||||||
dn->dccp_timeout[CT_DCCP_CLOSING] = 64 * HZ;
|
|
||||||
dn->dccp_timeout[CT_DCCP_TIMEWAIT] = 2 * DCCP_MSL;
|
|
||||||
#ifdef CONFIG_SYSCTL
|
|
||||||
pn->ctl_table = kmemdup(dccp_sysctl_table,
|
pn->ctl_table = kmemdup(dccp_sysctl_table,
|
||||||
sizeof(dccp_sysctl_table),
|
sizeof(dccp_sysctl_table),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
|
@ -850,10 +837,29 @@ static int dccp_init_net(struct net *net, u_int16_t proto)
|
||||||
pn->ctl_table[6].data = &dn->dccp_timeout[CT_DCCP_TIMEWAIT];
|
pn->ctl_table[6].data = &dn->dccp_timeout[CT_DCCP_TIMEWAIT];
|
||||||
pn->ctl_table[7].data = &dn->dccp_loose;
|
pn->ctl_table[7].data = &dn->dccp_loose;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dccp_init_net(struct net *net, u_int16_t proto)
|
||||||
|
{
|
||||||
|
struct dccp_net *dn = dccp_pernet(net);
|
||||||
|
struct nf_proto_net *pn = &dn->pn;
|
||||||
|
|
||||||
|
if (!pn->users) {
|
||||||
|
/* default values */
|
||||||
|
dn->dccp_loose = 1;
|
||||||
|
dn->dccp_timeout[CT_DCCP_REQUEST] = 2 * DCCP_MSL;
|
||||||
|
dn->dccp_timeout[CT_DCCP_RESPOND] = 4 * DCCP_MSL;
|
||||||
|
dn->dccp_timeout[CT_DCCP_PARTOPEN] = 4 * DCCP_MSL;
|
||||||
|
dn->dccp_timeout[CT_DCCP_OPEN] = 12 * 3600 * HZ;
|
||||||
|
dn->dccp_timeout[CT_DCCP_CLOSEREQ] = 64 * HZ;
|
||||||
|
dn->dccp_timeout[CT_DCCP_CLOSING] = 64 * HZ;
|
||||||
|
dn->dccp_timeout[CT_DCCP_TIMEWAIT] = 2 * DCCP_MSL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dccp_kmemdup_sysctl_table(pn, dn);
|
||||||
|
}
|
||||||
|
|
||||||
static struct nf_conntrack_l4proto dccp_proto4 __read_mostly = {
|
static struct nf_conntrack_l4proto dccp_proto4 __read_mostly = {
|
||||||
.l3proto = AF_INET,
|
.l3proto = AF_INET,
|
||||||
.l4proto = IPPROTO_DCCP,
|
.l4proto = IPPROTO_DCCP,
|
||||||
|
|
Loading…
Reference in New Issue