All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Martin <martinn6@cs.man.ac.uk>
To: netfilter@vger.kernel.org
Subject: recv on nfq_fd receiving wrong number of bytes
Date: Wed, 18 Feb 2009 18:52:14 +0000	[thread overview]
Message-ID: <499C58DE.4030109@cs.man.ac.uk> (raw)

Hi all,

The situation is:
I have a test set up that sends a UDP packet containing "Hello" to a 
host. There is a rule that queues traffic to this host. Using wireshark 
when sending such a packet when it is not being queued shows that it 
should be either 48,34,20, or 6 bytes long (depending on which parts of 
the frame are received from a netfilter_queue fd, maybe somebody could 
explain that to me?).

The problem is:
recv returns 4 when receiving from the socket, which is too small to be 
anything. It only returns 4 when a packet it queued. When no packet is 
queued it returns -1 and sets errno to EAGAIN.

I'm obviously doing something wrong but I don't know what. This is what 
I've done before I call recv():
1) open a connection to netfilter_queue with nfq_open()
2) unbind, then bind the connection to AF_INET
3) create a queue (queue 0)
4) set the mode to NFNL_COPY_PACKET
5) get a file descriptor for the netfilter_queue connection
6) allocate space for my packet and payload buffers
7) recv from the socket

Here's my code:
http://pastebin.com/m5c702182

And the test script I'm using:
http://pastebin.com/m63ad9715

If anybody has any ideas what might be going on or any good ways to find 
out whats going on I'd appreciate it. Thanks for any help guys.

Regards,

Nick Martin

             reply	other threads:[~2009-02-18 18:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-18 18:52 Nick Martin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-02-18 19:07 recv on nfq_fd receiving wrong number of bytes Nick Martin

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=499C58DE.4030109@cs.man.ac.uk \
    --to=martinn6@cs.man.ac.uk \
    --cc=netfilter@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.