Designing a transparent module ...
Romain Giry
romain_giry@yahoo.fr
Mon, 10 Dec 2001 10:22:24 +0100
Hello,
For my thesis, I should do a module for linux that allows the user to
switch the physical device at run-time. In a first time this should be done
by user commands and later the module should decide himself to switch the
physical device.
To introduce an additional layer, it seems most natural to me to create a
dummy ethernet device driver which does not do anything else apart from
forwarding the packets received from the IP stack to a real (= physical)
network device.
For the moment i try to realize this dummy device that only forwards
packets to the ethernet card. It iscalled mydriver :
here is the ifconfig :
eth0 Link encap:Ethernet HWaddr 00:03:47:8E:72:32
inet addr:156.18.56.253 Bcast:156.18.56.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:11
mydriver Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:156.18.56.222 Mask:255.255.255.0
UP RUNNING MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Kernel IP routing table :
Destination Gateway Genmask Flags Metric Ref Use Iface
156.18.56.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
156.18.56.0 0.0.0.0 255.255.255.0 U 0 0 0 mydriver
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 156.18.56.206 0.0.0.0 UG 0 0 0 mydriver
In the code of mydriver.c, i get the reference of the ethernet device with
the (dev_get_by_name) and this is what i do in the hard_start_xmit function :
skb->dev = my_output_device; // i set my_ouput_device
if (my_output_device) dev_queue_xmit(skb) // send the packet
What i would like to know is :
1/ I'm not sure that i should use the dev_queue_xmit to send the packet
after having set the dev field to my_ouput_device?? Should i do anything
else before sending the packet??
2/ I don't know to what corresponds the dst field in the skb structure ??
3/ When i want to ping another computer on the net, my ethernet device send
packets that are not common packets... the mac adresses are not good and
the rest of the packet doesn't correspond to a ip header...i think the
first packets it sends is like arp requests and i'm not sure i should tell
mydriver to use the arp protocol or not?? otherwise i'd like to know
whether mydriver use the arp protocol??
4/ I'm not sure i should use the dev_queue_xmit function to send my packet??
5/ I also would like to know if i shoud implement the receive function or
not in my device as the incomming traffic goes to the ethernet device and
then is passed to the IP stack as usual ??
6/ If anybody has already created a transparent module ( i think a
tranparent firewall works well ), i would be great to find the source code..
Thanks a lot,
Romain Giry