|
@@ -1589,7 +1589,7 @@ static int sip_help_udp(struct sk_buff *skb, unsigned int protoff,
|
|
|
return process_sip_msg(skb, ct, protoff, dataoff, &dptr, &datalen);
|
|
|
}
|
|
|
|
|
|
-static struct nf_conntrack_helper sip[MAX_PORTS][4] __read_mostly;
|
|
|
+static struct nf_conntrack_helper sip[MAX_PORTS * 4] __read_mostly;
|
|
|
|
|
|
static const struct nf_conntrack_expect_policy sip_exp_policy[SIP_EXPECT_MAX + 1] = {
|
|
|
[SIP_EXPECT_SIGNALLING] = {
|
|
@@ -1616,20 +1616,12 @@ static const struct nf_conntrack_expect_policy sip_exp_policy[SIP_EXPECT_MAX + 1
|
|
|
|
|
|
static void nf_conntrack_sip_fini(void)
|
|
|
{
|
|
|
- int i, j;
|
|
|
-
|
|
|
- for (i = 0; i < ports_c; i++) {
|
|
|
- for (j = 0; j < ARRAY_SIZE(sip[i]); j++) {
|
|
|
- if (sip[i][j].me == NULL)
|
|
|
- continue;
|
|
|
- nf_conntrack_helper_unregister(&sip[i][j]);
|
|
|
- }
|
|
|
- }
|
|
|
+ nf_conntrack_helpers_unregister(sip, ports_c * 4);
|
|
|
}
|
|
|
|
|
|
static int __init nf_conntrack_sip_init(void)
|
|
|
{
|
|
|
- int i, j, ret;
|
|
|
+ int i, ret;
|
|
|
|
|
|
if (ports_c == 0)
|
|
|
ports[ports_c++] = SIP_PORT;
|
|
@@ -1637,43 +1629,32 @@ static int __init nf_conntrack_sip_init(void)
|
|
|
for (i = 0; i < ports_c; i++) {
|
|
|
memset(&sip[i], 0, sizeof(sip[i]));
|
|
|
|
|
|
- sip[i][0].tuple.src.l3num = AF_INET;
|
|
|
- sip[i][0].tuple.dst.protonum = IPPROTO_UDP;
|
|
|
- sip[i][0].help = sip_help_udp;
|
|
|
- sip[i][1].tuple.src.l3num = AF_INET;
|
|
|
- sip[i][1].tuple.dst.protonum = IPPROTO_TCP;
|
|
|
- sip[i][1].help = sip_help_tcp;
|
|
|
-
|
|
|
- sip[i][2].tuple.src.l3num = AF_INET6;
|
|
|
- sip[i][2].tuple.dst.protonum = IPPROTO_UDP;
|
|
|
- sip[i][2].help = sip_help_udp;
|
|
|
- sip[i][3].tuple.src.l3num = AF_INET6;
|
|
|
- sip[i][3].tuple.dst.protonum = IPPROTO_TCP;
|
|
|
- sip[i][3].help = sip_help_tcp;
|
|
|
-
|
|
|
- for (j = 0; j < ARRAY_SIZE(sip[i]); j++) {
|
|
|
- sip[i][j].data_len = sizeof(struct nf_ct_sip_master);
|
|
|
- sip[i][j].tuple.src.u.udp.port = htons(ports[i]);
|
|
|
- sip[i][j].expect_policy = sip_exp_policy;
|
|
|
- sip[i][j].expect_class_max = SIP_EXPECT_MAX;
|
|
|
- sip[i][j].me = THIS_MODULE;
|
|
|
-
|
|
|
- if (ports[i] == SIP_PORT)
|
|
|
- sprintf(sip[i][j].name, "sip");
|
|
|
- else
|
|
|
- sprintf(sip[i][j].name, "sip-%u", i);
|
|
|
-
|
|
|
- pr_debug("port #%u: %u\n", i, ports[i]);
|
|
|
+ nf_ct_helper_init(&sip[4 * i], AF_INET, IPPROTO_UDP, "sip",
|
|
|
+ SIP_PORT, ports[i], i, sip_exp_policy,
|
|
|
+ SIP_EXPECT_MAX,
|
|
|
+ sizeof(struct nf_ct_sip_master), sip_help_udp,
|
|
|
+ NULL, THIS_MODULE);
|
|
|
+ nf_ct_helper_init(&sip[4 * i + 1], AF_INET, IPPROTO_TCP, "sip",
|
|
|
+ SIP_PORT, ports[i], i, sip_exp_policy,
|
|
|
+ SIP_EXPECT_MAX,
|
|
|
+ sizeof(struct nf_ct_sip_master), sip_help_tcp,
|
|
|
+ NULL, THIS_MODULE);
|
|
|
+ nf_ct_helper_init(&sip[4 * i + 2], AF_INET6, IPPROTO_UDP, "sip",
|
|
|
+ SIP_PORT, ports[i], i, sip_exp_policy,
|
|
|
+ SIP_EXPECT_MAX,
|
|
|
+ sizeof(struct nf_ct_sip_master), sip_help_udp,
|
|
|
+ NULL, THIS_MODULE);
|
|
|
+ nf_ct_helper_init(&sip[4 * i + 3], AF_INET6, IPPROTO_TCP, "sip",
|
|
|
+ SIP_PORT, ports[i], i, sip_exp_policy,
|
|
|
+ SIP_EXPECT_MAX,
|
|
|
+ sizeof(struct nf_ct_sip_master), sip_help_tcp,
|
|
|
+ NULL, THIS_MODULE);
|
|
|
+ }
|
|
|
|
|
|
- ret = nf_conntrack_helper_register(&sip[i][j]);
|
|
|
- if (ret) {
|
|
|
- pr_err("failed to register helper for pf: %u port: %u\n",
|
|
|
- sip[i][j].tuple.src.l3num, ports[i]);
|
|
|
- ports_c = i;
|
|
|
- nf_conntrack_sip_fini();
|
|
|
- return ret;
|
|
|
- }
|
|
|
- }
|
|
|
+ ret = nf_conntrack_helpers_register(sip, ports_c * 4);
|
|
|
+ if (ret < 0) {
|
|
|
+ pr_err("failed to register helpers\n");
|
|
|
+ return ret;
|
|
|
}
|
|
|
return 0;
|
|
|
}
|