From: Nader Al-Naji <nbal@princeton.edu>
To: <netfilter-devel@vger.kernel.org>
Subject: Send Packets In Prerouting?
Date: Fri, 01 Jul 2011 12:33:18 -0400 [thread overview]
Message-ID: <38209.1309537998@princeton.edu> (raw)
Hello, I'm writing a prerouting hook module that modifies packets and sends them back to the source without letting the higher layers know anything about it. Using tcpdump, I see that everything works fine except for the fact that the ethernet header is written incorrectly by dev_queue_xmit. Before I call dev_queue_xmit, the ethernet header is set to zero-- but then it goes writes in the same source/dest as were on it when the packet arrived, and it shouldn't because I manually change the IP's in my hook. I have no idea how macs are chosen even from close inspection of the code for dev_queue_xmit and friends. I thought it would inspect the packet's reversed IP addresses to see which macs to put in before sending it off but this isn't happening as I expect it to. Am I missing something here
? Are there some fields I should set in the sk_buff to let dev_queue_xmit know that it needs to inspect the IP addresses in the packet before choosing/finding MAC addresses?
Here is an abbreviation of the offending code:
//The main hook function
static unsigned int myhook_in_func(unsigned int hooknum,
struct sk_buff *skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
......
MAKE MODIFICATIONS TO THE PACKET HERE INCLUDING CHANGING IP'S
......
//The ethernet header is zero at this point-- I checked.
skb_push(skb, ETH_HLEN);
//Set the packet type to outgoing-- didn't help.
skb->pkt_type = PACKET_OUTGOING;
//Send the packet on the wire; ARP resolution is done somewhere in here..
dev_queue_xmit(skb);
//NF_STOLEN because dev_queue_xmit consumes the skb
return NF_STOLEN;
}
The hook is registered in NF_IP_PRE_ROUTING.
Thanks in advance for your help!
--Nader Al-Naji
PS: Wasn't sure whether to post this in the netfilter user list (instead of development) but after reading their questions, it seems to me that this is really more of a development-oriented issue. Please let me know if these kinds of questions actually belong more in the user list.
reply other threads:[~2011-07-01 16:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=38209.1309537998@princeton.edu \
--to=nbal@princeton.edu \
--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.