netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Radu Rendec <radu.rendec@mindbit.ro>
To: netdev@vger.kernel.org
Subject: TUN interfaces loopback
Date: Wed, 25 Nov 2015 18:58:13 +0200	[thread overview]
Message-ID: <1448470693.7801.41.camel@mindbit.ro> (raw)

Disclaimer: I know this is a *development* list, but I feel the answer
lies deep down in the ipv4 routing code, so it's more likely that I
find help here.

That being said, I have two TUN interfaces that are "cross-connected"
in user space (i.e. whatever is read on the socket corresponding to
either interface is written to the socket of the other interface).

The problem: if I assign IPv4 addresses to both TUN interfaces, local
traffic to either address flows through the loopback interface. Getting
packets to be routed through the TUN interfaces is easy. The real
challenge is to get packets to be accepted/processed as input packets
when they pop out of the opposite TUN interface.

I tracked down the problem to ip_route_input_slow() in net/ipv4/route.c

What I tried so far:

1. Remove the implicit routes from the local table. This apparently
causes packets to be silently dropped by ip_route_input_slow(), since
it looks for a corresponding route and only delivers packets locally if
a local route is found.

2. Keep implicit routes in the local table, change the priority of the
"lookup local" ip rule, mark *output* packets with iptables and add a
higher priority rule to lookup the main table for marked packets.

By doing that, the main table is looked up on the egress path and
packets are routed through the TUN interface. When packets pop out of
the opposite TUN interface, they are no longer marked (because they are
actually different packets), so ingress routing correctly looks up the
local table.

The next problem is that packets are seen as "martians" and dropped,
most probably because of __fib_validate_source() failing due to the
fact that the input interface is not the expected one.

This is where I stopped. Any idea or help would be highly appreciated.
Please CC my private address (I am not subscribed to the list). Thanks
in advance!

             reply	other threads:[~2015-11-25 17:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-25 16:58 Radu Rendec [this message]
2015-11-29  8:40 ` TUN interfaces loopback Lorenzo Colitti
2015-11-29 21:56   ` Radu Rendec
2015-12-01 11:02 ` Hannes Frederic Sowa

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=1448470693.7801.41.camel@mindbit.ro \
    --to=radu.rendec@mindbit.ro \
    --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).