netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* net 00/05: routing based send-to-self implementation
@ 2009-12-03 11:25 Patrick McHardy
  2009-12-03 11:25 ` net 01/05: fib_rules: rearrange struct fib_rule Patrick McHardy
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Patrick McHardy @ 2009-12-03 11:25 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy

These patches are yet another attempt at adding "send-to-self" functionality,
allowing to send packets between two local interfaces over the wire. Unlike
the approaches I've seen so far, this one is purely routing based.
Especially the oif classification should also be useful for different setups.

The patchset consists of three parts:

- the first three patches add oif classification to fib_rules. This can be
  used create special routing tables for sockets bound to an interface.

- the fourth patch changes IPv4 and IPv6 to allow to delete the local rule
  with priority 0. This allows to re-create it using a lower priority and
  insert new rules below it to force packets with a local destination out
  on the wire.

- the fifth patch adds a devinet sysctl to accept packets with local source
  addresses in fib_validate_source(). This one unfortunately seems to be
  necessary, I couldn't come up with a method based purely on adding more
  routes to fool fib_validate_source() into accepting those packets.

Usage example:

# move local routing rule to lower priority
ip rule add pref 1000 lookup local
ip rule del pref 0

# only reply to ARP requests for addresses configured on the device
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore

# configure device and force packets of bound sockets out on eth1
ip address add dev eth1 10.0.0.1/24
echo 1 > /proc/sys/net/ipv4/conf/eth1/accept_local
ip link set eth1 up
ip rule add pref 500 oif eth1 lookup 500
ip route add default dev eth1 table 500

# configure device and force packets of bound sockets out on eth2
ip address add dev eth2 10.0.0.2/24
echo 1 > /proc/sys/net/ipv4/conf/eth2/accept_local
ip link set eth2 up
ip rule add pref 501 oif eth2 lookup 501
ip route add default dev eth2 table 501

At this point packets between sockets bound to eth1/eth2 will go over the wire.

Changes since last posting:

- fixed an incorrect FIB_RULE_DEV_DETACHED define
- fixed incorrect example in the changelog

Please apply, thanks!


 Documentation/networking/ip-sysctl.txt |    6 +++
 include/linux/fib_rules.h              |    8 +++-
 include/linux/inetdevice.h             |    1 +
 include/linux/sysctl.h                 |    1 +
 include/net/fib_rules.h                |    9 +++-
 kernel/sysctl_check.c                  |    1 +
 net/core/fib_rules.c                   |   71 +++++++++++++++++++++++---------
 net/ipv4/devinet.c                     |    1 +
 net/ipv4/fib_frontend.c                |   11 +++--
 net/ipv4/fib_rules.c                   |    2 +-
 net/ipv6/fib6_rules.c                  |    2 +-
 11 files changed, 82 insertions(+), 31 deletions(-)

Patrick McHardy (5):
      net: fib_rules: rearrange struct fib_rule
      net: fib_rules: rename ifindex/ifname/FRA_IFNAME to iifindex/iifname/FRA_IIFNAME
      net: fib_rules: add oif classification
      net: fib_rules: allow to delete local rule
      ipv4: add sysctl to accept packets with local source addresses

^ permalink raw reply	[flat|nested] 14+ messages in thread
* RFC: net 00/05: routing based send-to-self implementation
@ 2009-11-30 17:55 Patrick McHardy
  2009-11-30 17:55 ` ipv4 05/05: add sysctl to accept packets with local source addresses Patrick McHardy
  0 siblings, 1 reply; 14+ messages in thread
From: Patrick McHardy @ 2009-11-30 17:55 UTC (permalink / raw)
  To: netdev; +Cc: Patrick McHardy

These patches are yet another attempt at adding "send-to-self" functionality,
allowing to send packets between two local interfaces over the wire. Unlike
the approaches I've seen so far, this one is purely routing based.
Especially the oif classification should also be useful for different setups.

The patchset consists of three parts:

- the first three patches add oif classification to fib_rules. This can be
  used create special routing tables for sockets bound to an interface.

- the fourth patch changes IPv4 and IPv6 to allow to delete the local rule
  with priority 0. This allows to re-create it using a lower priority and
  insert new rules below it to force packets with a local destination out
  on the wire.

- the fifth patch adds a devinet sysctl to accept packets with local source
  addresses in fib_validate_source(). This one unfortunately seems to be
  necessary, I couldn't come up with a method based purely on adding more
  routes to fool fib_validate_source() into accepting those packets.

Usage example:

# move local routing rule to lower priority
ip rule add pref 1000 lookup local
ip rule del pref 0

# only reply to ARP requests for addresses configured on the device
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore

# configure device and force packets of bound sockets out on eth1
ip address add dev eth1 10.0.0.1/24
echo 1 > /proc/sys/net/ipv4/conf/eth1/accept_local
ip link set eth1 up
ip rule add pref 500 oif eth1 lookup 500
ip route add default dev eth1 table 500

# configure device and force packets of bound sockets out on eth2
ip address add dev eth2 10.0.0.2/24
echo 1 > /proc/sys/net/ipv4/conf/eth2/accept_local
ip link set eth2 up
ip rule add pref 501 oif eth2 lookup 501
ip route add default dev eth2 table 501

At this point both packets between sockets bound to eth1/eth2 will
go over the wire.

Comments welcome.


 Documentation/networking/ip-sysctl.txt |    6 +++
 include/linux/fib_rules.h              |    8 +++-
 include/linux/inetdevice.h             |    1 +
 include/linux/sysctl.h                 |    1 +
 include/net/fib_rules.h                |    9 +++-
 kernel/sysctl_check.c                  |    1 +
 net/core/fib_rules.c                   |   71 +++++++++++++++++++++++---------
 net/ipv4/devinet.c                     |    1 +
 net/ipv4/fib_frontend.c                |   11 +++--
 net/ipv4/fib_rules.c                   |    2 +-
 net/ipv6/fib6_rules.c                  |    2 +-
 11 files changed, 82 insertions(+), 31 deletions(-)

Patrick McHardy (5):
      net: fib_rules: rearrange struct fib_rule
      net: fib_rules: rename ifindex/ifname/FRA_IFNAME to iifindex/iifname/FRA_IIFNAME
      net: fib_rules: add oif classification
      net: fib_rules: allow to delete local rule
      ipv4: add sysctl to accept packets with local source addresses

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-01-14 15:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-03 11:25 net 00/05: routing based send-to-self implementation Patrick McHardy
2009-12-03 11:25 ` net 01/05: fib_rules: rearrange struct fib_rule Patrick McHardy
2009-12-03 11:25 ` net 02/05: fib_rules: rename ifindex/ifname/FRA_IFNAME to iifindex/iifname/FRA_IIFNAME Patrick McHardy
2009-12-03 11:25 ` net 03/05: fib_rules: add oif classification Patrick McHardy
2009-12-03 11:25 ` net 04/05: fib_rules: allow to delete local rule Patrick McHardy
2009-12-03 11:25 ` ipv4 05/05: add sysctl to accept packets with local source addresses Patrick McHardy
2009-12-04  7:52   ` Eric W. Biederman
2009-12-04  7:55     ` Patrick McHardy
2009-12-03 20:15 ` net 00/05: routing based send-to-self implementation David Miller
2011-01-14 10:18 ` Kirill Smelkov
2011-01-14 12:22   ` Patrick McHardy
2011-01-14 13:40   ` Jonathan Corbet
2011-01-14 15:02     ` Kirill Smelkov
  -- strict thread matches above, loose matches on Subject: below --
2009-11-30 17:55 RFC: " Patrick McHardy
2009-11-30 17:55 ` ipv4 05/05: add sysctl to accept packets with local source addresses Patrick McHardy

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).