9 #include <linux/types.h>
12 #include <linux/netfilter.h>
19 return &net->ct.nf_ct_proto.generic;
22 static bool generic_pkt_to_tuple(
const struct sk_buff *
skb,
42 static int generic_print_tuple(
struct seq_file *
s,
48 static unsigned int *generic_get_timeouts(
struct net *
net)
50 return &(generic_pernet(net)->timeout);
54 static int generic_packet(
struct nf_conn *
ct,
62 nf_ct_refresh_acct(ct, ctinfo, skb, *timeout);
68 unsigned int dataoff,
unsigned int *timeouts)
73 #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
75 #include <linux/netfilter/nfnetlink.h>
78 static int generic_timeout_nlattr_to_obj(
struct nlattr *
tb[],
86 ntohl(nla_get_be32(tb[CTA_TIMEOUT_GENERIC_TIMEOUT])) *
HZ;
96 generic_timeout_obj_to_nlattr(
struct sk_buff *
skb,
const void *data)
98 const unsigned int *timeout =
data;
100 if (nla_put_be32(skb, CTA_TIMEOUT_GENERIC_TIMEOUT,
htonl(*timeout /
HZ)))
101 goto nla_put_failure;
116 static struct ctl_table generic_sysctl_table[] = {
118 .
procname =
"nf_conntrack_generic_timeout",
119 .maxlen =
sizeof(
unsigned int),
125 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
126 static struct ctl_table generic_compat_sysctl_table[] = {
128 .
procname =
"ip_conntrack_generic_timeout",
129 .maxlen =
sizeof(
unsigned int),
142 pn->ctl_table =
kmemdup(generic_sysctl_table,
143 sizeof(generic_sysctl_table),
148 pn->ctl_table[0].data = &gn->
timeout;
153 static int generic_kmemdup_compat_sysctl_table(
struct nf_proto_net *pn,
157 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
158 pn->ctl_compat_table =
kmemdup(generic_compat_sysctl_table,
159 sizeof(generic_compat_sysctl_table),
161 if (!pn->ctl_compat_table)
164 pn->ctl_compat_table[0].data = &gn->
timeout;
176 gn->
timeout = nf_ct_generic_timeout;
178 ret = generic_kmemdup_compat_sysctl_table(pn, gn);
182 ret = generic_kmemdup_sysctl_table(pn, gn);
184 nf_ct_kfree_compat_sysctl_table(pn);
189 static struct nf_proto_net *generic_get_net_proto(
struct net *net)
191 return &net->ct.nf_ct_proto.generic.pn;
199 .pkt_to_tuple = generic_pkt_to_tuple,
200 .invert_tuple = generic_invert_tuple,
201 .print_tuple = generic_print_tuple,
202 .packet = generic_packet,
203 .get_timeouts = generic_get_timeouts,
205 #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
207 .nlattr_to_obj = generic_timeout_nlattr_to_obj,
208 .obj_to_nlattr = generic_timeout_obj_to_nlattr,
210 .obj_size =
sizeof(
unsigned int),