Does not work

I am new to kernel module development. I am trying to develop a pseudo-network driver working in loopback mode without any real device. My goal is to use the following setting:

iperf -s -u.........iperf -c 192.168.1.1 -p 5001 -u 

====== .............. ============

| ... if0 .... | ............. | ........ if1 ......... |

====== .............. ============

  | | /|\ \|/ | | --------------- 

I registered two interfaces from the driver. Then I changed the UDP packet received from if1 to appear when it was received in if0. But this never comes to the iperf server application listening on all udp if the udp port. But whenever I sniffed a packet through wirehark on if0, it seems that the packet is accepted at if0. But for some reason, it does not go through the network stack.

any clues? Both the ip checksum and the udp checksum were recalculated and verified (using wirehark). I use netif_rx to point the package to another interface descriptor (if0 descriptor).

I used only 5 ptr callbacks {open, close, xmit_start, get_stats and config} functions for network operations. Also, the checksum is set to REQUIRED. The IF flag is set to indicate NO_ARP.

EDIT: IP ADDR OUTPUT

eth1: mtu 1500 qdisc

pfifo_fast state UP qlen 1000 link / ether 00: e0: ff: 00: 00: e0 brd

ff: ff: ff: ff: ff: ff inet 192.168.1.1/24 brd 192.168.1.255 scope globa eth1 valid_lft

forever preferred_lft forever 4:

eth2: mtu 1500 qdisc pfifo_fast

state UP qlen 1000 link / ether 00: e0: ff: 40: 00: e0 brd ff: ff: ff: ff: ff: ff

inet 192.168.2.1/24 brd 192.168.2.255 scope global eth2 valid_lft

forever preferred_lft forever

+4
source share
1 answer

Ok, I figured it out.

I feel stupid not to think about it. The package was removed due to a routing problem.

The received packet in the receiving IF must have the same network as the IF.

So, if the IF has 192.168.1.1/24, the routing system only accepts a packet received from 192.168.1.X / 24.

I did not notice this until I tried with a single IF loop. Can anyone explain why this happened?

0
source

Source: https://habr.com/ru/post/1444133/


All Articles