netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Karl Krach <ml@kkrach.de>
To: netdev@vger.kernel.org
Subject: TUN works when SRC != own IP
Date: Mon, 21 Dec 2015 18:44:16 +0100	[thread overview]
Message-ID: <56783A70.6020308@kkrach.de> (raw)

Hello,

I have to forward IP-packets from an FPGA via network. For this I use 
packet_mmap / PACKET_TX_RING for destinations within the ARP cache and 
the TUN interface for all others (incl. packets to my own device).

When I send these foreign packets (ip4h->saddr != device address) via 
TUN device, they are forwarded to the appropriate interface eth1 
correctly. But when I want to send packets from the own device 
(ip4h->saddr == device address) they get lost between tunX and ethX.

I use the following to setup the system (Linux 4.0.0, PowerPC TQMP2020):

# openvpn --mktun --dev tun16
# ip link set tun16 up
# ip rule add iif tun16 table 50
# ip route add 0/0 dev eth1 table 50

and this program (https://github.com/kkrach/tuncom) to test the data 
transfer over TUN. When I use "1.1.1.1" as source address, everything 
works fine. But when I use the device's IP (192.168.32.60) the packets 
can be seen on the TUN interface (tcpdump -i tun16) but not on the 
network interface (tcpdump -i eth1).

Can't I use TUN for this purpose - or is my setup somehow wrong?





I ve figured out, that when I remove the rule "local 192.168.32.60 dev 
eth1 proto kernel scope host src 192.168.32.60" from the table "local" 
all packets (also those with the correct SRC address) are sent correctly 
- but then the device stops to receive any.

Could the problem be somewhere in my (local) rules?


# ip route show table local
broadcast 127.0.0.0 dev lo proto kernel  scope link  src 127.0.0.1
local 127.0.0.0/8 dev lo proto kernel  scope host  src 127.0.0.1
local 127.0.0.1 dev lo proto kernel  scope host  src 127.0.0.1
broadcast 127.255.255.255 dev lo proto kernel scope link  src 127.0.0.1
broadcast 172.16.10.0 dev eth0 proto kernel scope link src 172.16.10.12
local 172.16.10.12 dev eth0 proto kernel scope host  src 172.16.10.12
broadcast 172.16.11.255 dev eth0 proto kernel scope link src 172.16.10.12
broadcast 192.168.32.0 dev eth1 proto kernel scope link src 192.168.32.60
local 192.168.32.60 dev eth1 proto kernel scope host  src 192.168.32.60
broadcast 192.168.32.255 dev eth1  proto kernel scope link  src 
192.168.32.60
#

Best regards,
Karl Krach

                 reply	other threads:[~2015-12-21 17:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56783A70.6020308@kkrach.de \
    --to=ml@kkrach.de \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).