sending a packet to another machine from a kernel module.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Iam using RHL 9, kernel vs 2.4.20-8.
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.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux