* [PATCH] netfilter: Remove skb_is_nonlinear check from nf_conntrack_sip
@ 2010-05-14 0:38 Jason Gunthorpe
2010-05-14 6:50 ` Jan Engelhardt
0 siblings, 1 reply; 3+ messages in thread
From: Jason Gunthorpe @ 2010-05-14 0:38 UTC (permalink / raw)
To: netfilter-devel, netdev
At least the XEN net front driver always produces non linear skbs,
so the SIP module does nothing at all when used with that NIC.
Copy the hacky technique for accessing SKB data from the ftp conntrack,
better than nothing..
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
---
net/netfilter/nf_conntrack_sip.c | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index 4b57216..37dd7a4 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -30,6 +30,10 @@ MODULE_DESCRIPTION("SIP connection tracking helper");
MODULE_ALIAS("ip_conntrack_sip");
MODULE_ALIAS_NFCT_HELPER("sip");
+/* This is slow, but it's simple. --RR */
+static char *sip_buffer;
+static DEFINE_SPINLOCK(nf_sip_lock);
+
#define MAX_PORTS 8
static unsigned short ports[MAX_PORTS];
static unsigned int ports_c;
@@ -1275,17 +1279,14 @@ static int sip_help(struct sk_buff *skb,
nf_ct_refresh(ct, skb, sip_timeout * HZ);
- if (!skb_is_nonlinear(skb))
- dptr = skb->data + dataoff;
- else {
- pr_debug("Copy of skbuff not supported yet.\n");
- return NF_ACCEPT;
- }
-
datalen = skb->len - dataoff;
if (datalen < strlen("SIP/2.0 200"))
return NF_ACCEPT;
+ spin_lock_bh(&nf_sip_lock);
+ dptr = skb_header_pointer(skb, dataoff, datalen, sip_buffer);
+ BUG_ON(dptr == NULL);
+
if (strnicmp(dptr, "SIP/2.0 ", strlen("SIP/2.0 ")) != 0)
ret = process_sip_request(skb, &dptr, &datalen);
else
@@ -1297,6 +1298,7 @@ static int sip_help(struct sk_buff *skb,
ret = NF_DROP;
}
+ spin_unlock_bh(&nf_sip_lock);
return ret;
}
@@ -1329,6 +1331,7 @@ static void nf_conntrack_sip_fini(void)
nf_conntrack_helper_unregister(&sip[i][j]);
}
}
+ kfree(sip_buffer);
}
static int __init nf_conntrack_sip_init(void)
@@ -1336,6 +1339,10 @@ static int __init nf_conntrack_sip_init(void)
int i, j, ret;
char *tmpname;
+ sip_buffer = kmalloc(65536, GFP_KERNEL);
+ if (!sip_buffer)
+ return -ENOMEM;
+
if (ports_c == 0)
ports[ports_c++] = SIP_PORT;
--
1.6.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] netfilter: Remove skb_is_nonlinear check from nf_conntrack_sip
2010-05-14 0:38 [PATCH] netfilter: Remove skb_is_nonlinear check from nf_conntrack_sip Jason Gunthorpe
@ 2010-05-14 6:50 ` Jan Engelhardt
2010-05-14 10:16 ` Patrick McHardy
0 siblings, 1 reply; 3+ messages in thread
From: Jan Engelhardt @ 2010-05-14 6:50 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: netfilter-devel, netdev
On Friday 2010-05-14 02:38, Jason Gunthorpe wrote:
>At least the XEN net front driver always produces non linear skbs,
>so the SIP module does nothing at all when used with that NIC.
>
>Copy the hacky technique for accessing SKB data from the ftp conntrack,
>better than nothing..
>
>Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
>
>+/* This is slow, but it's simple. --RR */
>+static char *sip_buffer;
>+static DEFINE_SPINLOCK(nf_sip_lock);
>+
skb_linearize seems simpler. (What about the cost?)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] netfilter: Remove skb_is_nonlinear check from nf_conntrack_sip
2010-05-14 6:50 ` Jan Engelhardt
@ 2010-05-14 10:16 ` Patrick McHardy
0 siblings, 0 replies; 3+ messages in thread
From: Patrick McHardy @ 2010-05-14 10:16 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: Jason Gunthorpe, netfilter-devel, netdev
Jan Engelhardt wrote:
> On Friday 2010-05-14 02:38, Jason Gunthorpe wrote:
>
>> At least the XEN net front driver always produces non linear skbs,
>> so the SIP module does nothing at all when used with that NIC.
>>
>> Copy the hacky technique for accessing SKB data from the ftp conntrack,
>> better than nothing..
>>
>> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
>>
>> +/* This is slow, but it's simple. --RR */
>> +static char *sip_buffer;
>> +static DEFINE_SPINLOCK(nf_sip_lock);
>> +
>
> skb_linearize seems simpler. (What about the cost?)
Yeah, we have to use skb_linearize(). The SIP NAT helper might mangle
the packet and alter its size, at which point we'd have to make a new
copy of the data area to get the offsets right.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-05-14 10:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-14 0:38 [PATCH] netfilter: Remove skb_is_nonlinear check from nf_conntrack_sip Jason Gunthorpe
2010-05-14 6:50 ` Jan Engelhardt
2010-05-14 10:16 ` Patrick McHardy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).