All of lore.kernel.org
 help / color / mirror / Atom feed
From: "U.Mutlu" <for-gmane@mutluit.com>
To: netfilter-devel@vger.kernel.org
Subject: Re: a problem with netfilter
Date: Thu, 18 Oct 2012 04:15:56 +0200	[thread overview]
Message-ID: <507F665C.40507@mutluit.com> (raw)
In-Reply-To: <507EA5C3.6020903@cert-ro.eu>

Bozeanu Andrei wrote, On 10/17/2012 02:34 PM:
> Hey all,
>
> I am writing a linux firewall kernel module (something a bit specific)
> using Netfilter, in C. I extract the
> TCP header and the IP header using the functions tcp_hdr() and ip_hdr()
> on the skb. I extract the source and
> destination IPs without any problem, yet, when I try to see the source
> port and the destination port i get wrong
> values.
>
> sport = ntohs(tcp_hdr(skb)->source);
> dport= ntohs(tcp_hdr(skb)->dest);

Just guessing: maybe ntohs has already been applied to source and dest, so try it w/o ntohs()...

> I use printk to send the info to the syslog and
> printk(KERN_INFO "got data on port %hu from source port %hu\n", dport,
> sport);
>
> the result i get is
> "got data on port 17680 from port 84"
> "got data on port 17680 from port 84"
> "got data on port 17680 from port 100"
>
> while netstat shows me that the right values for these ports are dport =
> 56188 and sport = 22.
>
> I must be doing something wrong or missing something of the bigger
> picture, I would apreciate any insight
> on why this behavior is generated.
>
> Thank you all,
> A.



      reply	other threads:[~2012-10-18  2:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-17 12:34 a problem with netfilter Bozeanu Andrei
2012-10-18  2:15 ` U.Mutlu [this message]

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=507F665C.40507@mutluit.com \
    --to=for-gmane@mutluit.com \
    --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.