LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-16-2009, 06:15 PM   #1
drblmb
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Rep: Reputation: 0
Question why doesn't dev_queue_xmit actually transmit the packet?


I have a PC with two network cards (eth0 and eth1). I create a simple netfilter NF_INET_PRE_ROUTING hook. In my hook, I change the pkt_type to PACKET_OUTGOING, and the skb->dev to eth1/eth0, whichever it didn't come in on. I call dev_queue_xmit(skb) and then return NF_STOLEN.

I think this should create a simple bridge, since I also put the network cards in promiscuous mode, but what I am seeing is that only broadcast packets are being transmitted. Can anyone help with this? Here is the code:

unsigned int in_hook(
unsigned int hooknum,
struct sk_buff *skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff*))
{
struct net_device * eth0 = dev_get_by_name(&init_net, "eth0");
struct net_device * eth1 = dev_get_by_name(&init_net, "eth1");

if (eth1 == skb->dev)
{
skb->dev = eth0;
skb->pkt_type = PACKET_OUTGOING;
dev_queue_xmit(skb);
return NF_STOLEN;
}
else if (eth0 == skb->dev)
{
skb->dev = eth1;
skb->pkt_type = PACKET_OUTGOING;
dev_queue_xmit(skb);
return NF_STOLEN;
}
else
{
return NF_ACCEPT;
}
}

Last edited by drblmb; 09-16-2009 at 06:27 PM.
 
Old 09-17-2009, 01:05 PM   #2
orgcandman
Member
 
Registered: May 2002
Location: new hampshire
Distribution: Fedora, RHEL
Posts: 600

Rep: Reputation: 110Reputation: 110
1) please use the code tags.

2) Where is initnet coming from?

3) Any reason that the existing ethernet bridging (and corresponding ebtables framework) isn't good enough?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
dmesg Invalid packet / INPUT packet died flood H_TeXMeX_H Slackware 5 11-12-2007 02:52 PM
A packet filter using libipq which uses ether type field to capture the packet can26_manish Programming 2 10-16-2007 05:35 AM
Raw Packet Sockets in Fedora Core 6 don't transmit Son_of_Merlin Linux - Networking 6 01-02-2007 12:55 AM
Packet Filter to redirect a packet to a user level process akawale Linux - Networking 3 09-01-2006 12:06 PM
dump packet data to file, but no packet header Nathanael Linux - Networking 3 02-08-2006 10:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration