Skip to content

Commit fe0b929

Browse files
yasuyuki5David S. Miller
authored andcommitted
[NETFILTER]: x_tables: error if ip_conntrack is asked to handle IPv6 packets
To do that, this makes nf_ct_l3proto_try_module_{get,put} compatible functions. As a result we can remove '#ifdef' surrounds and direct call of need_conntrack(). Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 083e69e commit fe0b929

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

include/net/netfilter/nf_conntrack_compat.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ static inline int nf_ct_get_ctinfo(const struct sk_buff *skb,
6464
return (ct != NULL);
6565
}
6666

67+
static inline int nf_ct_l3proto_try_module_get(unsigned short l3proto)
68+
{
69+
need_conntrack();
70+
return l3proto == PF_INET ? 0 : -1;
71+
}
72+
73+
static inline void nf_ct_l3proto_module_put(unsigned short l3proto)
74+
{
75+
}
76+
6777
#else /* CONFIG_IP_NF_CONNTRACK */
6878

6979
#include <net/netfilter/ipv4/nf_conntrack_ipv4.h>

net/netfilter/xt_connmark.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,18 @@ checkentry(const char *tablename,
6363
printk(KERN_WARNING "connmark: only support 32bit mark\n");
6464
return 0;
6565
}
66-
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
6766
if (nf_ct_l3proto_try_module_get(match->family) < 0) {
68-
printk(KERN_WARNING "can't load nf_conntrack support for "
67+
printk(KERN_WARNING "can't load conntrack support for "
6968
"proto=%d\n", match->family);
7069
return 0;
7170
}
72-
#endif
7371
return 1;
7472
}
7573

7674
static void
7775
destroy(const struct xt_match *match, void *matchinfo)
7876
{
79-
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
8077
nf_ct_l3proto_module_put(match->family);
81-
#endif
8278
}
8379

8480
#ifdef CONFIG_COMPAT
@@ -140,7 +136,6 @@ static struct xt_match xt_connmark_match[] = {
140136

141137
static int __init xt_connmark_init(void)
142138
{
143-
need_conntrack();
144139
return xt_register_matches(xt_connmark_match,
145140
ARRAY_SIZE(xt_connmark_match));
146141
}

net/netfilter/xt_conntrack.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <linux/netfilter/x_tables.h>
2222
#include <linux/netfilter/xt_conntrack.h>
23+
#include <net/netfilter/nf_conntrack_compat.h>
2324

2425
MODULE_LICENSE("GPL");
2526
MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
@@ -228,21 +229,17 @@ checkentry(const char *tablename,
228229
void *matchinfo,
229230
unsigned int hook_mask)
230231
{
231-
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
232232
if (nf_ct_l3proto_try_module_get(match->family) < 0) {
233-
printk(KERN_WARNING "can't load nf_conntrack support for "
233+
printk(KERN_WARNING "can't load conntrack support for "
234234
"proto=%d\n", match->family);
235235
return 0;
236236
}
237-
#endif
238237
return 1;
239238
}
240239

241240
static void destroy(const struct xt_match *match, void *matchinfo)
242241
{
243-
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
244242
nf_ct_l3proto_module_put(match->family);
245-
#endif
246243
}
247244

248245
static struct xt_match conntrack_match = {
@@ -257,7 +254,6 @@ static struct xt_match conntrack_match = {
257254

258255
static int __init xt_conntrack_init(void)
259256
{
260-
need_conntrack();
261257
return xt_register_match(&conntrack_match);
262258
}
263259

net/netfilter/xt_helper.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#endif
2525
#include <linux/netfilter/x_tables.h>
2626
#include <linux/netfilter/xt_helper.h>
27+
#include <net/netfilter/nf_conntrack_compat.h>
2728

2829
MODULE_LICENSE("GPL");
2930
MODULE_AUTHOR("Martin Josefsson <gandalf@netfilter.org>");
@@ -143,23 +144,19 @@ static int check(const char *tablename,
143144
{
144145
struct xt_helper_info *info = matchinfo;
145146

146-
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
147147
if (nf_ct_l3proto_try_module_get(match->family) < 0) {
148-
printk(KERN_WARNING "can't load nf_conntrack support for "
148+
printk(KERN_WARNING "can't load conntrack support for "
149149
"proto=%d\n", match->family);
150150
return 0;
151151
}
152-
#endif
153152
info->name[29] = '\0';
154153
return 1;
155154
}
156155

157156
static void
158157
destroy(const struct xt_match *match, void *matchinfo)
159158
{
160-
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
161159
nf_ct_l3proto_module_put(match->family);
162-
#endif
163160
}
164161

165162
static struct xt_match xt_helper_match[] = {
@@ -185,7 +182,6 @@ static struct xt_match xt_helper_match[] = {
185182

186183
static int __init xt_helper_init(void)
187184
{
188-
need_conntrack();
189185
return xt_register_matches(xt_helper_match,
190186
ARRAY_SIZE(xt_helper_match));
191187
}

net/netfilter/xt_state.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,18 @@ static int check(const char *tablename,
5050
void *matchinfo,
5151
unsigned int hook_mask)
5252
{
53-
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
5453
if (nf_ct_l3proto_try_module_get(match->family) < 0) {
55-
printk(KERN_WARNING "can't load nf_conntrack support for "
54+
printk(KERN_WARNING "can't load conntrack support for "
5655
"proto=%d\n", match->family);
5756
return 0;
5857
}
59-
#endif
6058
return 1;
6159
}
6260

6361
static void
6462
destroy(const struct xt_match *match, void *matchinfo)
6563
{
66-
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
6764
nf_ct_l3proto_module_put(match->family);
68-
#endif
6965
}
7066

7167
static struct xt_match xt_state_match[] = {
@@ -91,7 +87,6 @@ static struct xt_match xt_state_match[] = {
9187

9288
static int __init xt_state_init(void)
9389
{
94-
need_conntrack();
9590
return xt_register_matches(xt_state_match, ARRAY_SIZE(xt_state_match));
9691
}
9792

0 commit comments

Comments
 (0)