Skip to content

Commit 9f0f3eb

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: helpers: remove data_len usage for inkernel helpers
No need to track this for inkernel helpers anymore as NF_CT_HELPER_BUILD_BUG_ON checks do this now. All inkernel helpers know what kind of structure they stored in helper->data. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 157ffff commit 9f0f3eb

File tree

9 files changed

+19
-33
lines changed

9 files changed

+19
-33
lines changed

include/net/netfilter/nf_conntrack_helper.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ struct nf_conntrack_helper {
2929
struct module *me; /* pointer to self */
3030
const struct nf_conntrack_expect_policy *expect_policy;
3131

32-
/* length of internal data, ie. sizeof(struct nf_ct_*_master) */
33-
size_t data_len;
34-
3532
/* Tuple of things we will help (compared against server response) */
3633
struct nf_conntrack_tuple tuple;
3734

@@ -49,7 +46,11 @@ struct nf_conntrack_helper {
4946
unsigned int expect_class_max;
5047

5148
unsigned int flags;
52-
unsigned int queue_num; /* For user-space helpers. */
49+
50+
/* For user-space helpers: */
51+
unsigned int queue_num;
52+
/* length of userspace private data stored in nf_conn_help->data */
53+
u16 data_len;
5354
};
5455

5556
/* Must be kept in sync with the classes defined by helpers */
@@ -82,7 +83,7 @@ void nf_ct_helper_init(struct nf_conntrack_helper *helper,
8283
u16 l3num, u16 protonum, const char *name,
8384
u16 default_port, u16 spec_port, u32 id,
8485
const struct nf_conntrack_expect_policy *exp_pol,
85-
u32 expect_class_max, u32 data_len,
86+
u32 expect_class_max,
8687
int (*help)(struct sk_buff *skb, unsigned int protoff,
8788
struct nf_conn *ct,
8889
enum ip_conntrack_info ctinfo),

net/netfilter/nf_conntrack_ftp.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,12 +591,10 @@ static int __init nf_conntrack_ftp_init(void)
591591
for (i = 0; i < ports_c; i++) {
592592
nf_ct_helper_init(&ftp[2 * i], AF_INET, IPPROTO_TCP, "ftp",
593593
FTP_PORT, ports[i], ports[i], &ftp_exp_policy,
594-
0, sizeof(struct nf_ct_ftp_master), help,
595-
nf_ct_ftp_from_nlattr, THIS_MODULE);
594+
0, help, nf_ct_ftp_from_nlattr, THIS_MODULE);
596595
nf_ct_helper_init(&ftp[2 * i + 1], AF_INET6, IPPROTO_TCP, "ftp",
597596
FTP_PORT, ports[i], ports[i], &ftp_exp_policy,
598-
0, sizeof(struct nf_ct_ftp_master), help,
599-
nf_ct_ftp_from_nlattr, THIS_MODULE);
597+
0, help, nf_ct_ftp_from_nlattr, THIS_MODULE);
600598
}
601599

602600
ret = nf_conntrack_helpers_register(ftp, ports_c * 2);

net/netfilter/nf_conntrack_h323_main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,6 @@ static const struct nf_conntrack_expect_policy h245_exp_policy = {
637637
static struct nf_conntrack_helper nf_conntrack_helper_h245 __read_mostly = {
638638
.name = "H.245",
639639
.me = THIS_MODULE,
640-
.data_len = sizeof(struct nf_ct_h323_master),
641640
.tuple.src.l3num = AF_UNSPEC,
642641
.tuple.dst.protonum = IPPROTO_UDP,
643642
.help = h245_help,
@@ -1215,7 +1214,6 @@ static struct nf_conntrack_helper nf_conntrack_helper_q931[] __read_mostly = {
12151214
{
12161215
.name = "Q.931",
12171216
.me = THIS_MODULE,
1218-
.data_len = sizeof(struct nf_ct_h323_master),
12191217
.tuple.src.l3num = AF_INET,
12201218
.tuple.src.u.tcp.port = cpu_to_be16(Q931_PORT),
12211219
.tuple.dst.protonum = IPPROTO_TCP,
@@ -1800,7 +1798,6 @@ static struct nf_conntrack_helper nf_conntrack_helper_ras[] __read_mostly = {
18001798
{
18011799
.name = "RAS",
18021800
.me = THIS_MODULE,
1803-
.data_len = sizeof(struct nf_ct_h323_master),
18041801
.tuple.src.l3num = AF_INET,
18051802
.tuple.src.u.udp.port = cpu_to_be16(RAS_PORT),
18061803
.tuple.dst.protonum = IPPROTO_UDP,
@@ -1810,7 +1807,6 @@ static struct nf_conntrack_helper nf_conntrack_helper_ras[] __read_mostly = {
18101807
{
18111808
.name = "RAS",
18121809
.me = THIS_MODULE,
1813-
.data_len = sizeof(struct nf_ct_h323_master),
18141810
.tuple.src.l3num = AF_INET6,
18151811
.tuple.src.u.udp.port = cpu_to_be16(RAS_PORT),
18161812
.tuple.dst.protonum = IPPROTO_UDP,

net/netfilter/nf_conntrack_helper.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ nf_ct_helper_ext_add(struct nf_conn *ct,
178178
{
179179
struct nf_conn_help *help;
180180

181-
help = nf_ct_ext_add_length(ct, NF_CT_EXT_HELPER,
182-
helper->data_len, gfp);
181+
help = nf_ct_ext_add(ct, NF_CT_EXT_HELPER, gfp);
183182
if (help)
184183
INIT_HLIST_HEAD(&help->expectations);
185184
else
@@ -484,7 +483,7 @@ void nf_ct_helper_init(struct nf_conntrack_helper *helper,
484483
u16 l3num, u16 protonum, const char *name,
485484
u16 default_port, u16 spec_port, u32 id,
486485
const struct nf_conntrack_expect_policy *exp_pol,
487-
u32 expect_class_max, u32 data_len,
486+
u32 expect_class_max,
488487
int (*help)(struct sk_buff *skb, unsigned int protoff,
489488
struct nf_conn *ct,
490489
enum ip_conntrack_info ctinfo),
@@ -497,7 +496,6 @@ void nf_ct_helper_init(struct nf_conntrack_helper *helper,
497496
helper->tuple.src.u.all = htons(spec_port);
498497
helper->expect_policy = exp_pol;
499498
helper->expect_class_max = expect_class_max;
500-
helper->data_len = data_len;
501499
helper->help = help;
502500
helper->from_nlattr = from_nlattr;
503501
helper->me = module;

net/netfilter/nf_conntrack_irc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ static int __init nf_conntrack_irc_init(void)
263263
for (i = 0; i < ports_c; i++) {
264264
nf_ct_helper_init(&irc[i], AF_INET, IPPROTO_TCP, "irc",
265265
IRC_PORT, ports[i], i, &irc_exp_policy,
266-
0, 0, help, NULL, THIS_MODULE);
266+
0, help, NULL, THIS_MODULE);
267267
}
268268

269269
ret = nf_conntrack_helpers_register(&irc[0], ports_c);

net/netfilter/nf_conntrack_pptp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,6 @@ static const struct nf_conntrack_expect_policy pptp_exp_policy = {
596596
static struct nf_conntrack_helper pptp __read_mostly = {
597597
.name = "pptp",
598598
.me = THIS_MODULE,
599-
.data_len = sizeof(struct nf_ct_pptp_master),
600599
.tuple.src.l3num = AF_INET,
601600
.tuple.src.u.tcp.port = cpu_to_be16(PPTP_CONTROL_PORT),
602601
.tuple.dst.protonum = IPPROTO_TCP,

net/netfilter/nf_conntrack_sane.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,11 @@ static int __init nf_conntrack_sane_init(void)
198198
for (i = 0; i < ports_c; i++) {
199199
nf_ct_helper_init(&sane[2 * i], AF_INET, IPPROTO_TCP, "sane",
200200
SANE_PORT, ports[i], ports[i],
201-
&sane_exp_policy, 0,
202-
sizeof(struct nf_ct_sane_master), help, NULL,
201+
&sane_exp_policy, 0, help, NULL,
203202
THIS_MODULE);
204203
nf_ct_helper_init(&sane[2 * i + 1], AF_INET6, IPPROTO_TCP, "sane",
205204
SANE_PORT, ports[i], ports[i],
206-
&sane_exp_policy, 0,
207-
sizeof(struct nf_ct_sane_master), help, NULL,
205+
&sane_exp_policy, 0, help, NULL,
208206
THIS_MODULE);
209207
}
210208

net/netfilter/nf_conntrack_sip.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,23 +1630,19 @@ static int __init nf_conntrack_sip_init(void)
16301630
for (i = 0; i < ports_c; i++) {
16311631
nf_ct_helper_init(&sip[4 * i], AF_INET, IPPROTO_UDP, "sip",
16321632
SIP_PORT, ports[i], i, sip_exp_policy,
1633-
SIP_EXPECT_MAX,
1634-
sizeof(struct nf_ct_sip_master), sip_help_udp,
1633+
SIP_EXPECT_MAX, sip_help_udp,
16351634
NULL, THIS_MODULE);
16361635
nf_ct_helper_init(&sip[4 * i + 1], AF_INET, IPPROTO_TCP, "sip",
16371636
SIP_PORT, ports[i], i, sip_exp_policy,
1638-
SIP_EXPECT_MAX,
1639-
sizeof(struct nf_ct_sip_master), sip_help_tcp,
1637+
SIP_EXPECT_MAX, sip_help_tcp,
16401638
NULL, THIS_MODULE);
16411639
nf_ct_helper_init(&sip[4 * i + 2], AF_INET6, IPPROTO_UDP, "sip",
16421640
SIP_PORT, ports[i], i, sip_exp_policy,
1643-
SIP_EXPECT_MAX,
1644-
sizeof(struct nf_ct_sip_master), sip_help_udp,
1641+
SIP_EXPECT_MAX, sip_help_udp,
16451642
NULL, THIS_MODULE);
16461643
nf_ct_helper_init(&sip[4 * i + 3], AF_INET6, IPPROTO_TCP, "sip",
16471644
SIP_PORT, ports[i], i, sip_exp_policy,
1648-
SIP_EXPECT_MAX,
1649-
sizeof(struct nf_ct_sip_master), sip_help_tcp,
1645+
SIP_EXPECT_MAX, sip_help_tcp,
16501646
NULL, THIS_MODULE);
16511647
}
16521648

net/netfilter/nf_conntrack_tftp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ static int __init nf_conntrack_tftp_init(void)
121121
for (i = 0; i < ports_c; i++) {
122122
nf_ct_helper_init(&tftp[2 * i], AF_INET, IPPROTO_UDP, "tftp",
123123
TFTP_PORT, ports[i], i, &tftp_exp_policy,
124-
0, 0, tftp_help, NULL, THIS_MODULE);
124+
0, tftp_help, NULL, THIS_MODULE);
125125
nf_ct_helper_init(&tftp[2 * i + 1], AF_INET6, IPPROTO_UDP, "tftp",
126126
TFTP_PORT, ports[i], i, &tftp_exp_policy,
127-
0, 0, tftp_help, NULL, THIS_MODULE);
127+
0, tftp_help, NULL, THIS_MODULE);
128128
}
129129

130130
ret = nf_conntrack_helpers_register(tftp, ports_c * 2);

0 commit comments

Comments
 (0)