0

I'm writing a C program on Linux machine that needs convert data from UART port to ETH and send it to the ETH port. In order to do so, I build a UDP packet with a given payload (in a SKB from UART) and send it to another machine (win7) on a given destination IP via the ETH port.

I do the following all on Linux machine:

  1. "Learn" the other machine (win7) MAC address, from receive packets.
  2. Allocate a new SKB and copy all the given UART SKB data to the new SKB
  3. Build ETH, IP and UDP headers with correct data
  4. Send the UDP packet that I built to the network by 'netif_rx(MsgSkb);' command.

Now, when I write in the ETH header the local port MAC address, I get an error on the Linux machine:

net_ratelimit: 167 callbacks suppressed

br0: received packet on mb_radio with own address as source address

br0: received packet on mb_radio with own address as source address

br0: received packet on mb_radio with own address as source address

br0: received packet on mb_radio with own address as source address 

When I write in the ETH header a junk MAC address as 00:01:02:03:04:05, all works OK.

In both the cases, I checked and verified in the destination machine (win7) with a sniffer (Wireshark) that all the packet that I send from the Linux machine are received OK with the MAC address that I wrote.

How can I write the packet to leave the Linux machine with the correct MAC address?

Thank ahead for your help and advice, -yaron.

skrtbhtngr
  • 2,223
  • 23
  • 29
Yaron
  • 1
  • 1
  • So you want to use raw sockets and create the IP and UDP layers yourself? May I ask why? – Some programmer dude Nov 21 '16 at 12:46
  • `netif_rx` doesn't send a packet. It will report that packet as having been received to the kernel on your local machine (which is consistent with the message you're reporting). So it isn't clear how the packet could possibly have been received on the other machine (though perhaps `br0` is a bridge that is forwarding the packet even though it's been "received" on the local machine?). In any case, there are better ways to do this, look here (and linked-to answers): http://stackoverflow.com/questions/10499865/sending-udp-packets-from-the-linux-kernel/12175937#12175937 – Gil Hamilton Nov 21 '16 at 17:42
  • Hi,1st thanks for the replies! 1) i'm using this because my application transport data receive in the UART port of the Linux machine and sends it to the other machine (win7) via the ETH port. 2) yes - the Linux uses a bridge to pass the data from 1 side to the other. this is a legacy code that i got - can't change it at the moment. – Yaron Dec 04 '16 at 13:53

0 Answers0