diff options
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/netfilter/ipv4/nf_conntrack_icmp.h | 11 | ||||
-rw-r--r-- | include/net/netfilter/ipv6/nf_conntrack_icmpv6.h | 7 | ||||
-rw-r--r-- | include/net/netfilter/nf_conntrack.h | 9 | ||||
-rw-r--r-- | include/net/netfilter/nf_conntrack_ecache.h | 113 | ||||
-rw-r--r-- | include/net/netfilter/nf_conntrack_l4proto.h | 4 | ||||
-rw-r--r-- | include/net/netlink.h | 9 |
6 files changed, 109 insertions, 44 deletions
diff --git a/include/net/netfilter/ipv4/nf_conntrack_icmp.h b/include/net/netfilter/ipv4/nf_conntrack_icmp.h deleted file mode 100644 index 3dd22cff23ec..000000000000 --- a/include/net/netfilter/ipv4/nf_conntrack_icmp.h +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | #ifndef _NF_CONNTRACK_ICMP_H | ||
2 | #define _NF_CONNTRACK_ICMP_H | ||
3 | /* ICMP tracking. */ | ||
4 | #include <asm/atomic.h> | ||
5 | |||
6 | struct ip_ct_icmp | ||
7 | { | ||
8 | /* Optimization: when number in == number out, forget immediately. */ | ||
9 | atomic_t count; | ||
10 | }; | ||
11 | #endif /* _NF_CONNTRACK_ICMP_H */ | ||
diff --git a/include/net/netfilter/ipv6/nf_conntrack_icmpv6.h b/include/net/netfilter/ipv6/nf_conntrack_icmpv6.h index 86591afda29c..67edd50a398a 100644 --- a/include/net/netfilter/ipv6/nf_conntrack_icmpv6.h +++ b/include/net/netfilter/ipv6/nf_conntrack_icmpv6.h | |||
@@ -9,7 +9,6 @@ | |||
9 | 9 | ||
10 | #ifndef _NF_CONNTRACK_ICMPV6_H | 10 | #ifndef _NF_CONNTRACK_ICMPV6_H |
11 | #define _NF_CONNTRACK_ICMPV6_H | 11 | #define _NF_CONNTRACK_ICMPV6_H |
12 | #include <asm/atomic.h> | ||
13 | 12 | ||
14 | #ifndef ICMPV6_NI_QUERY | 13 | #ifndef ICMPV6_NI_QUERY |
15 | #define ICMPV6_NI_QUERY 139 | 14 | #define ICMPV6_NI_QUERY 139 |
@@ -18,10 +17,4 @@ | |||
18 | #define ICMPV6_NI_REPLY 140 | 17 | #define ICMPV6_NI_REPLY 140 |
19 | #endif | 18 | #endif |
20 | 19 | ||
21 | struct nf_ct_icmpv6 | ||
22 | { | ||
23 | /* Optimization: when number in == number out, forget immediately. */ | ||
24 | atomic_t count; | ||
25 | }; | ||
26 | |||
27 | #endif /* _NF_CONNTRACK_ICMPV6_H */ | 20 | #endif /* _NF_CONNTRACK_ICMPV6_H */ |
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index 6c3f964de9e1..ecc79f959076 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h | |||
@@ -23,7 +23,6 @@ | |||
23 | #include <linux/netfilter/nf_conntrack_dccp.h> | 23 | #include <linux/netfilter/nf_conntrack_dccp.h> |
24 | #include <linux/netfilter/nf_conntrack_sctp.h> | 24 | #include <linux/netfilter/nf_conntrack_sctp.h> |
25 | #include <linux/netfilter/nf_conntrack_proto_gre.h> | 25 | #include <linux/netfilter/nf_conntrack_proto_gre.h> |
26 | #include <net/netfilter/ipv4/nf_conntrack_icmp.h> | ||
27 | #include <net/netfilter/ipv6/nf_conntrack_icmpv6.h> | 26 | #include <net/netfilter/ipv6/nf_conntrack_icmpv6.h> |
28 | 27 | ||
29 | #include <net/netfilter/nf_conntrack_tuple.h> | 28 | #include <net/netfilter/nf_conntrack_tuple.h> |
@@ -34,8 +33,6 @@ union nf_conntrack_proto { | |||
34 | struct nf_ct_dccp dccp; | 33 | struct nf_ct_dccp dccp; |
35 | struct ip_ct_sctp sctp; | 34 | struct ip_ct_sctp sctp; |
36 | struct ip_ct_tcp tcp; | 35 | struct ip_ct_tcp tcp; |
37 | struct ip_ct_icmp icmp; | ||
38 | struct nf_ct_icmpv6 icmpv6; | ||
39 | struct nf_ct_gre gre; | 36 | struct nf_ct_gre gre; |
40 | }; | 37 | }; |
41 | 38 | ||
@@ -96,6 +93,8 @@ struct nf_conn { | |||
96 | plus 1 for any connection(s) we are `master' for */ | 93 | plus 1 for any connection(s) we are `master' for */ |
97 | struct nf_conntrack ct_general; | 94 | struct nf_conntrack ct_general; |
98 | 95 | ||
96 | spinlock_t lock; | ||
97 | |||
99 | /* XXX should I move this to the tail ? - Y.K */ | 98 | /* XXX should I move this to the tail ? - Y.K */ |
100 | /* These are my tuples; original and reply */ | 99 | /* These are my tuples; original and reply */ |
101 | struct nf_conntrack_tuple_hash tuplehash[IP_CT_DIR_MAX]; | 100 | struct nf_conntrack_tuple_hash tuplehash[IP_CT_DIR_MAX]; |
@@ -144,6 +143,8 @@ static inline u_int8_t nf_ct_protonum(const struct nf_conn *ct) | |||
144 | return ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum; | 143 | return ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum; |
145 | } | 144 | } |
146 | 145 | ||
146 | #define nf_ct_tuple(ct, dir) (&(ct)->tuplehash[dir].tuple) | ||
147 | |||
147 | /* get master conntrack via master expectation */ | 148 | /* get master conntrack via master expectation */ |
148 | #define master_ct(conntr) (conntr->master) | 149 | #define master_ct(conntr) (conntr->master) |
149 | 150 | ||
@@ -201,7 +202,7 @@ __nf_conntrack_find(struct net *net, const struct nf_conntrack_tuple *tuple); | |||
201 | 202 | ||
202 | extern void nf_conntrack_hash_insert(struct nf_conn *ct); | 203 | extern void nf_conntrack_hash_insert(struct nf_conn *ct); |
203 | 204 | ||
204 | extern void nf_conntrack_flush(struct net *net, u32 pid, int report); | 205 | extern void nf_conntrack_flush_report(struct net *net, u32 pid, int report); |
205 | 206 | ||
206 | extern bool nf_ct_get_tuplepr(const struct sk_buff *skb, | 207 | extern bool nf_ct_get_tuplepr(const struct sk_buff *skb, |
207 | unsigned int nhoff, u_int16_t l3num, | 208 | unsigned int nhoff, u_int16_t l3num, |
diff --git a/include/net/netfilter/nf_conntrack_ecache.h b/include/net/netfilter/nf_conntrack_ecache.h index 0ff0dc69ca4a..1afb907e015a 100644 --- a/include/net/netfilter/nf_conntrack_ecache.h +++ b/include/net/netfilter/nf_conntrack_ecache.h | |||
@@ -6,11 +6,55 @@ | |||
6 | #define _NF_CONNTRACK_ECACHE_H | 6 | #define _NF_CONNTRACK_ECACHE_H |
7 | #include <net/netfilter/nf_conntrack.h> | 7 | #include <net/netfilter/nf_conntrack.h> |
8 | 8 | ||
9 | #include <linux/notifier.h> | ||
10 | #include <linux/interrupt.h> | 9 | #include <linux/interrupt.h> |
11 | #include <net/net_namespace.h> | 10 | #include <net/net_namespace.h> |
12 | #include <net/netfilter/nf_conntrack_expect.h> | 11 | #include <net/netfilter/nf_conntrack_expect.h> |
13 | 12 | ||
13 | /* Connection tracking event bits */ | ||
14 | enum ip_conntrack_events | ||
15 | { | ||
16 | /* New conntrack */ | ||
17 | IPCT_NEW_BIT = 0, | ||
18 | IPCT_NEW = (1 << IPCT_NEW_BIT), | ||
19 | |||
20 | /* Expected connection */ | ||
21 | IPCT_RELATED_BIT = 1, | ||
22 | IPCT_RELATED = (1 << IPCT_RELATED_BIT), | ||
23 | |||
24 | /* Destroyed conntrack */ | ||
25 | IPCT_DESTROY_BIT = 2, | ||
26 | IPCT_DESTROY = (1 << IPCT_DESTROY_BIT), | ||
27 | |||
28 | /* Status has changed */ | ||
29 | IPCT_STATUS_BIT = 3, | ||
30 | IPCT_STATUS = (1 << IPCT_STATUS_BIT), | ||
31 | |||
32 | /* Update of protocol info */ | ||
33 | IPCT_PROTOINFO_BIT = 4, | ||
34 | IPCT_PROTOINFO = (1 << IPCT_PROTOINFO_BIT), | ||
35 | |||
36 | /* New helper for conntrack */ | ||
37 | IPCT_HELPER_BIT = 5, | ||
38 | IPCT_HELPER = (1 << IPCT_HELPER_BIT), | ||
39 | |||
40 | /* Mark is set */ | ||
41 | IPCT_MARK_BIT = 6, | ||
42 | IPCT_MARK = (1 << IPCT_MARK_BIT), | ||
43 | |||
44 | /* NAT sequence adjustment */ | ||
45 | IPCT_NATSEQADJ_BIT = 7, | ||
46 | IPCT_NATSEQADJ = (1 << IPCT_NATSEQADJ_BIT), | ||
47 | |||
48 | /* Secmark is set */ | ||
49 | IPCT_SECMARK_BIT = 8, | ||
50 | IPCT_SECMARK = (1 << IPCT_SECMARK_BIT), | ||
51 | }; | ||
52 | |||
53 | enum ip_conntrack_expect_events { | ||
54 | IPEXP_NEW_BIT = 0, | ||
55 | IPEXP_NEW = (1 << IPEXP_NEW_BIT), | ||
56 | }; | ||
57 | |||
14 | #ifdef CONFIG_NF_CONNTRACK_EVENTS | 58 | #ifdef CONFIG_NF_CONNTRACK_EVENTS |
15 | struct nf_conntrack_ecache { | 59 | struct nf_conntrack_ecache { |
16 | struct nf_conn *ct; | 60 | struct nf_conn *ct; |
@@ -24,9 +68,13 @@ struct nf_ct_event { | |||
24 | int report; | 68 | int report; |
25 | }; | 69 | }; |
26 | 70 | ||
27 | extern struct atomic_notifier_head nf_conntrack_chain; | 71 | struct nf_ct_event_notifier { |
28 | extern int nf_conntrack_register_notifier(struct notifier_block *nb); | 72 | int (*fcn)(unsigned int events, struct nf_ct_event *item); |
29 | extern int nf_conntrack_unregister_notifier(struct notifier_block *nb); | 73 | }; |
74 | |||
75 | extern struct nf_ct_event_notifier *nf_conntrack_event_cb; | ||
76 | extern int nf_conntrack_register_notifier(struct nf_ct_event_notifier *nb); | ||
77 | extern void nf_conntrack_unregister_notifier(struct nf_ct_event_notifier *nb); | ||
30 | 78 | ||
31 | extern void nf_ct_deliver_cached_events(const struct nf_conn *ct); | 79 | extern void nf_ct_deliver_cached_events(const struct nf_conn *ct); |
32 | extern void __nf_ct_event_cache_init(struct nf_conn *ct); | 80 | extern void __nf_ct_event_cache_init(struct nf_conn *ct); |
@@ -52,13 +100,23 @@ nf_conntrack_event_report(enum ip_conntrack_events event, | |||
52 | u32 pid, | 100 | u32 pid, |
53 | int report) | 101 | int report) |
54 | { | 102 | { |
55 | struct nf_ct_event item = { | 103 | struct nf_ct_event_notifier *notify; |
56 | .ct = ct, | 104 | |
57 | .pid = pid, | 105 | rcu_read_lock(); |
58 | .report = report | 106 | notify = rcu_dereference(nf_conntrack_event_cb); |
59 | }; | 107 | if (notify == NULL) |
60 | if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct)) | 108 | goto out_unlock; |
61 | atomic_notifier_call_chain(&nf_conntrack_chain, event, &item); | 109 | |
110 | if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct)) { | ||
111 | struct nf_ct_event item = { | ||
112 | .ct = ct, | ||
113 | .pid = pid, | ||
114 | .report = report | ||
115 | }; | ||
116 | notify->fcn(event, &item); | ||
117 | } | ||
118 | out_unlock: | ||
119 | rcu_read_unlock(); | ||
62 | } | 120 | } |
63 | 121 | ||
64 | static inline void | 122 | static inline void |
@@ -73,9 +131,13 @@ struct nf_exp_event { | |||
73 | int report; | 131 | int report; |
74 | }; | 132 | }; |
75 | 133 | ||
76 | extern struct atomic_notifier_head nf_ct_expect_chain; | 134 | struct nf_exp_event_notifier { |
77 | extern int nf_ct_expect_register_notifier(struct notifier_block *nb); | 135 | int (*fcn)(unsigned int events, struct nf_exp_event *item); |
78 | extern int nf_ct_expect_unregister_notifier(struct notifier_block *nb); | 136 | }; |
137 | |||
138 | extern struct nf_exp_event_notifier *nf_expect_event_cb; | ||
139 | extern int nf_ct_expect_register_notifier(struct nf_exp_event_notifier *nb); | ||
140 | extern void nf_ct_expect_unregister_notifier(struct nf_exp_event_notifier *nb); | ||
79 | 141 | ||
80 | static inline void | 142 | static inline void |
81 | nf_ct_expect_event_report(enum ip_conntrack_expect_events event, | 143 | nf_ct_expect_event_report(enum ip_conntrack_expect_events event, |
@@ -83,12 +145,23 @@ nf_ct_expect_event_report(enum ip_conntrack_expect_events event, | |||
83 | u32 pid, | 145 | u32 pid, |
84 | int report) | 146 | int report) |
85 | { | 147 | { |
86 | struct nf_exp_event item = { | 148 | struct nf_exp_event_notifier *notify; |
87 | .exp = exp, | 149 | |
88 | .pid = pid, | 150 | rcu_read_lock(); |
89 | .report = report | 151 | notify = rcu_dereference(nf_expect_event_cb); |
90 | }; | 152 | if (notify == NULL) |
91 | atomic_notifier_call_chain(&nf_ct_expect_chain, event, &item); | 153 | goto out_unlock; |
154 | |||
155 | { | ||
156 | struct nf_exp_event item = { | ||
157 | .exp = exp, | ||
158 | .pid = pid, | ||
159 | .report = report | ||
160 | }; | ||
161 | notify->fcn(event, &item); | ||
162 | } | ||
163 | out_unlock: | ||
164 | rcu_read_unlock(); | ||
92 | } | 165 | } |
93 | 166 | ||
94 | static inline void | 167 | static inline void |
diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h index ba32ed7bdabe..3767fb41e541 100644 --- a/include/net/netfilter/nf_conntrack_l4proto.h +++ b/include/net/netfilter/nf_conntrack_l4proto.h | |||
@@ -59,11 +59,11 @@ struct nf_conntrack_l4proto | |||
59 | const struct nf_conntrack_tuple *); | 59 | const struct nf_conntrack_tuple *); |
60 | 60 | ||
61 | /* Print out the private part of the conntrack. */ | 61 | /* Print out the private part of the conntrack. */ |
62 | int (*print_conntrack)(struct seq_file *s, const struct nf_conn *); | 62 | int (*print_conntrack)(struct seq_file *s, struct nf_conn *); |
63 | 63 | ||
64 | /* convert protoinfo to nfnetink attributes */ | 64 | /* convert protoinfo to nfnetink attributes */ |
65 | int (*to_nlattr)(struct sk_buff *skb, struct nlattr *nla, | 65 | int (*to_nlattr)(struct sk_buff *skb, struct nlattr *nla, |
66 | const struct nf_conn *ct); | 66 | struct nf_conn *ct); |
67 | /* Calculate protoinfo nlattr size */ | 67 | /* Calculate protoinfo nlattr size */ |
68 | int (*nlattr_size)(void); | 68 | int (*nlattr_size)(void); |
69 | 69 | ||
diff --git a/include/net/netlink.h b/include/net/netlink.h index eddb50289d6d..007bdb07dabb 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h | |||
@@ -940,6 +940,15 @@ static inline u64 nla_get_u64(const struct nlattr *nla) | |||
940 | } | 940 | } |
941 | 941 | ||
942 | /** | 942 | /** |
943 | * nla_get_be64 - return payload of __be64 attribute | ||
944 | * @nla: __be64 netlink attribute | ||
945 | */ | ||
946 | static inline __be64 nla_get_be64(const struct nlattr *nla) | ||
947 | { | ||
948 | return *(__be64 *) nla_data(nla); | ||
949 | } | ||
950 | |||
951 | /** | ||
943 | * nla_get_flag - return payload of flag attribute | 952 | * nla_get_flag - return payload of flag attribute |
944 | * @nla: flag netlink attribute | 953 | * @nla: flag netlink attribute |
945 | */ | 954 | */ |