From: Mark Montague <mark@catseye.org>
To: netfilter-devel@vger.kernel.org
Subject: Problem getting IPv6 port numbers
Date: Fri, 25 Mar 2011 07:27:28 -0400 [thread overview]
Message-ID: <4D8C7C20.8090500@catseye.org> (raw)
I'm writing a netfilter match extension (xtables-addons 1.33, kernel
2.6.35, .family=NFPROTO_UNSPEC) that needs to examine the source and
destination port numbers of all packets. The following code
successfully gets the port numbers for IPv4 TCP and UDP packets:
static bool xt_mymatch_mt(const struct sk_buff *skb,
struct xt_action_param *par)
{
const __be16 *pptr;
__be16 _ports[2];
int sport = 0;
int dport = 0;
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 -- instead, it is large numbers such as
33569744, 2164528116, or 2164412871. However, par->in and par->out are
both correct. par->matchinfo, ipv6_hdr(skb)->saddr, and
ipv6_hdr(skb)->daddr are also all correct.
What am I doing wrong?
Thanks in advance for any help.
--
Mark Montague
mark@catseye.org
next reply other threads:[~2011-03-25 11:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-25 11:27 Mark Montague [this message]
2011-03-25 13:29 ` Problem getting IPv6 port numbers Jan Engelhardt
2011-03-26 2:54 ` Mark Montague
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=4D8C7C20.8090500@catseye.org \
--to=mark@catseye.org \
--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.