LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-04-2005, 12:37 AM   #1
Sridhar Kumar K
LQ Newbie
 
Registered: Nov 2004
Location: India
Distribution: RHL 9
Posts: 6

Rep: Reputation: 0
sending a packet to another machine from a kernel module.


I have two machines.

Machine 1 (IP 172.27.22.201) has two IP Aliases. 10.0.1.1 and 10.0.1.2.
Machine 2 (IP 172.27.22.232) has a IP alias 10.0.2.1.
(IP Alias is created using cmd #ifconfig eth0:1 10.0.0.1)

I want to send a packet from 10.0.1.1 (m/c 1) --> 10.0.2.1 (m/c 2) --> 10.0.1.2 (m/c 3).

In Machine 1, Iam capturing a packet from 10.0.1.1 to 10.0.1.2 at netfilter hook NF_IP_LOCAL_OUT. First to send the packet to 10.0.2.1 (m/c 2), I need to send the packet to Machine 2.
For sending the packet to machine 2 Iam doing the following changes in sk_buff structure of the packet.

sb->dev = dev_get_by_name("eth0");

Previously I captured the object of struct dst_entry * from a skbuffer of a packet going to Machine 2(for m/c 2 IP. Not to its alias) . Now, for the currently outgoing packet to m/c 2 IP Alias, Iam filling the sk_buff field struct dst_entry * with the previously captured dst_entry * object.

sb->dst = my_dst_entry; // previously captured dst_entry

Next Iam doing the following changes in the packet Header.

Iam adding another IP Header (i.e. IP-over-IP) with src IP 10.0.1.1 and dst IP 10.0.2.1. Iam changing the protocol field in the outer IP Header to IP-over-IP value. I changed the total len field and calculated the new checksum.
Next Iam filling the MAC Header fields. src MAC as the MAC address of m/c 1 and dst MAC as the MAC address of m/c 2 and type of packet to IP.
Now iam returning NF_ACCEPT.

Iam receiving the packet at machine 2. Now I captured the packet at netfilter-hook NF_IP_PRE_ROUTING. Now I want to send the packet to 10.0.1.2 (m/c 1). For this Iam changing the sk_buff fields, outer IP Header fileds and MAC Header fields as before.
Next Iam calling the dev_queue_xmit() to send the packet to machine 1.

Iam receiving the packet at m/c 1 netfilter hook NF_IP_PRE_ROUTING. But the packet is *not* reaching the Application.
Why it is not reaching the application ? Whether I need to fill any other fields in the sk_buff structure.
Iam using i) ping command ii) udp sockets to send packets at the application layer.

Thanks n Regards,
Sridhar.
 
  


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
TCP/IP Packet sending Resolve ARP cranium2004 Linux - Networking 3 02-03-2005 09:40 PM
Need Linux machine to route / packet forward rdd Linux - Networking 3 06-24-2004 09:59 AM
packet sending function in kernel ? help sunnyriver Programming 3 03-24-2004 12:35 PM
packet sending function in kernel sunnyriver Linux - Networking 0 03-22-2004 08:46 PM
sending a 512 byte packet geo_h Programming 0 09-20-2003 11:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:40 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