From: Mark Montague <mark@catseye.org>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: Problem getting IPv6 port numbers
Date: Fri, 25 Mar 2011 22:54:04 -0400 [thread overview]
Message-ID: <4D8D554C.4070907@catseye.org> (raw)
In-Reply-To: <alpine.LNX.2.01.1103251427500.28161@obet.zrqbmnf.qr>
On March 25, 2011 9:29 , Jan Engelhardt <jengelh@medozas.de> wrote:
>> if (par->fragoff == 0) {
>> pptr = skb_header_pointer(skb, par->thoff,
>> sizeof(_ports), _ports);
>> if (pptr != NULL) {
>> sport = ntohs(pptr[0]);
>> dport = ntohs(pptr[1]);
>> }
>> }
>> /* ...remaining code omitted... */
>> }
>>
>> However, when I test this with "telnet ::1 1234", it does not work for IPv6 TCP
>> packets (I have not tried with IPv6 UDP packets yet). By adding printk()
>> statements, I've determined that par->fragoff is never 0 for my IPv6 TCP
>> packets
> It seems that for IPv6, fragoff is only filled when you explicitly test
> for a protocol using -p.
This was the problem. Many thanks for the answer!
Adding a "-p tcp" to my ip6tables rule causes the above code to report
the source and destination port numbers properly.
Also of note: it seems like the transport header can only be retrieved
if the ip6tables rule explicitly tests for a protocol: Without a -p
test, I took out the "if (par->fragoff == 0)" check, with the result
that the sport and dport were set to random (incorrect) numbers.
So I'll continue checking fragoff and I'll put in the documentation for
the module I'm writing, "If you are using IPv6, port numbers are only
available if you use '-p tcp' or '-p udp' in your ip6tables rule. For
IPv4, you do not have to use a -p test in your iptables rule; ports will
automatically be correctly reported for protocols that use ports, and
will be reported as 0 for protocols that do not use ports."
--
Mark Montague
mark@catseye.org
next prev parent reply other threads:[~2011-03-26 2:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-25 11:27 Problem getting IPv6 port numbers Mark Montague
2011-03-25 13:29 ` Jan Engelhardt
2011-03-26 2:54 ` Mark Montague [this message]
2011-03-26 12:19 ` Jan Engelhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D8D554C.4070907@catseye.org \
--to=mark@catseye.org \
--cc=jengelh@medozas.de \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.