ASoC: SOF: Drop superfluous snd_pcm_sgbuf_ops_page
[linux-2.6-block.git] / net / netfilter / nf_conntrack_proto_generic.c
CommitLineData
d2912cb1 1// SPDX-License-Identifier: GPL-2.0-only
9fb9cbb1
YK
2/* (C) 1999-2001 Paul `Rusty' Russell
3 * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
9fb9cbb1
YK
4 */
5
6#include <linux/types.h>
cd354f1a 7#include <linux/jiffies.h>
9fb9cbb1
YK
8#include <linux/timer.h>
9#include <linux/netfilter.h>
605dcad6 10#include <net/netfilter/nf_conntrack_l4proto.h>
c779e849 11#include <net/netfilter/nf_conntrack_timeout.h>
9fb9cbb1 12
2c9e8637 13static const unsigned int nf_ct_generic_timeout = 600*HZ;
9fb9cbb1 14
a874752a 15#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
50978462
PNA
16
17#include <linux/netfilter/nfnetlink.h>
18#include <linux/netfilter/nfnetlink_cttimeout.h>
19
8264deb8
G
20static int generic_timeout_nlattr_to_obj(struct nlattr *tb[],
21 struct net *net, void *data)
50978462 22{
a95a7774 23 struct nf_generic_net *gn = nf_generic_pernet(net);
c779e849
FW
24 unsigned int *timeout = data;
25
26 if (!timeout)
27 timeout = &gn->timeout;
50978462
PNA
28
29 if (tb[CTA_TIMEOUT_GENERIC_TIMEOUT])
30 *timeout =
31 ntohl(nla_get_be32(tb[CTA_TIMEOUT_GENERIC_TIMEOUT])) * HZ;
32 else {
33 /* Set default generic timeout. */
8264deb8 34 *timeout = gn->timeout;
50978462
PNA
35 }
36
37 return 0;
38}
39
40static int
41generic_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data)
42{
43 const unsigned int *timeout = data;
44
f5776941
DM
45 if (nla_put_be32(skb, CTA_TIMEOUT_GENERIC_TIMEOUT, htonl(*timeout / HZ)))
46 goto nla_put_failure;
50978462
PNA
47
48 return 0;
49
50nla_put_failure:
51 return -ENOSPC;
52}
53
54static const struct nla_policy
55generic_timeout_nla_policy[CTA_TIMEOUT_GENERIC_MAX+1] = {
56 [CTA_TIMEOUT_GENERIC_TIMEOUT] = { .type = NLA_U32 },
57};
a874752a 58#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
50978462 59
2a389de8 60void nf_conntrack_generic_init_net(struct net *net)
22ac0377 61{
a95a7774 62 struct nf_generic_net *gn = nf_generic_pernet(net);
22ac0377
G
63
64 gn->timeout = nf_ct_generic_timeout;
08911475
PNA
65}
66
9dae47ab 67const struct nf_conntrack_l4proto nf_conntrack_l4proto_generic =
9fb9cbb1 68{
fe2a7ce4 69 .l4proto = 255,
a874752a 70#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
50978462
PNA
71 .ctnl_timeout = {
72 .nlattr_to_obj = generic_timeout_nlattr_to_obj,
73 .obj_to_nlattr = generic_timeout_obj_to_nlattr,
74 .nlattr_max = CTA_TIMEOUT_GENERIC_MAX,
75 .obj_size = sizeof(unsigned int),
76 .nla_policy = generic_timeout_nla_policy,
77 },
a874752a 78#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
9fb9cbb1 79};