Skip to contentSkip to conversation

RFC: Support send-to-self over external interfaces (and veths).

PATCH Ben Greear 2 participants 4 messages Jun 9, 2007 – Jun 11, 2007

Subsystems (4)
lore
Share & tools
lore

Ben Greear

author
#0 lore raw

This should also be useful with the pending 'veth' driver, as it emulates two ethernet ports connected with a cross-over cable.

To make this work, you have to enable the sysctl (look Dave, no IOCTLS, there might be hope for me yet!! :)), and in your application you will need to use SO_BINDTODEVICE (and probably bind to the local IP as well). Some applications such as traceroute already support this binding..others such as ping do not.

You most likely will also have to set up routing tables using source IPs as a rule to direct these connections to a particular routing table.

Comments welcome.

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
include/linux/inetdevice.h +2 -0
index c0f7aec..88f78b6 100644
@@ -31,6 +31,7 @@ struct ipv4_devconf
 	int	no_policy;
 	int	force_igmp_version;
 	int	promote_secondaries;
+	int	accept_sts;
 	void	*sysctl;
 };
 
@@ -84,6 +85,7 @@ struct in_device
 #define IN_DEV_ARPFILTER(in_dev)	(ipv4_devconf.arp_filter || (in_dev)->cnf.arp_filter)
 #define IN_DEV_ARP_ANNOUNCE(in_dev)	(max(ipv4_devconf.arp_announce, (in_dev)->cnf.arp_announce))
 #define IN_DEV_ARP_IGNORE(in_dev)	(max(ipv4_devconf.arp_ignore, (in_dev)->cnf.arp_ignore))
+#define IN_DEV_ACCEPT_STS(in_dev)      (max(ipv4_devconf.accept_sts, (in_dev)->cnf.accept_sts))
 
 struct in_ifaddr
 {
include/linux/sysctl.h +1 -0
index 47f1c53..6c00bf4 100644
@@ -496,6 +496,7 @@ enum
 	NET_IPV4_CONF_ARP_IGNORE=19,
 	NET_IPV4_CONF_PROMOTE_SECONDARIES=20,
 	NET_IPV4_CONF_ARP_ACCEPT=21,
+	NET_IPV4_CONF_ACCEPT_STS=22,
 	__NET_IPV4_CONF_MAX
 };
 
net/ipv4/arp.c +52 -2

66 lines not on this page · raw message

net/ipv4/devinet.c +9 -0
index 7f95e6e..33ac2ed 100644
@@ -1513,6 +1513,15 @@ static struct devinet_sysctl_table {
 			.proc_handler	= &ipv4_doint_and_flush,
 			.strategy	= &ipv4_doint_and_flush_strategy,
 		},
+		{
+			.ctl_name       = NET_IPV4_CONF_ACCEPT_STS,
+			.procname       = "accept_sts",
+			.data           = &ipv4_devconf.accept_sts,
+			.maxlen         = sizeof(int),
+			.mode           = 0644,
+			.proc_handler   = &proc_dointvec,
+		},
+
 	},
 	.devinet_dev = {
 		{
net/ipv4/fib_frontend.c +10 -2
index 837f295..9b57bf5 100644
@@ -206,8 +206,16 @@ int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif,
 
 	if (fib_lookup(&fl, &res))
 		goto last_resort;
-	if (res.type != RTN_UNICAST)
-		goto e_inval_res;
+	if (res.type != RTN_UNICAST) {
+		if ((res.type == RTN_LOCAL) &&
+		    (IN_DEV_ACCEPT_STS(in_dev))) {
+			/* All is OK */
+		}
+		else {
+			goto e_inval_res;
+		}
+	}
+
 	*spec_dst = FIB_RES_PREFSRC(res);
 	fib_combine_itag(itag, &res);
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
#1 lore raw
Quoted 9 lines · Ben Greear

This should also be useful with the pending 'veth' driver, as it emulates two ethernet ports connected with a cross-over cable.

To make this work, you have to enable the sysctl (look Dave, no IOCTLS, there might be hope for me yet!! :)), and in your application you will need to use SO_BINDTODEVICE (and probably bind to the local IP as well). Some applications such as traceroute already support this binding..others such as ping do not.

Quoted 5 lines

You most likely will also have to set up routing tables using source IPs as a rule to direct these connections to a particular routing table.

Comments welcome.

I would really prefer to simply make the prio 0 "lookup local" rule deletable so you can rules with higher priority. That allows to do send to self without any further code changes and avoids the need to bind applications to a device.

author
#2 lore raw
Quoted 15 lines · Patrick McHardy
Quoted 13 lines · Ben Greear

This should also be useful with the pending 'veth' driver, as it emulates two ethernet ports connected with a cross-over cable.

To make this work, you have to enable the sysctl (look Dave, no IOCTLS, there might be hope for me yet!! :)), and in your application you will need to use SO_BINDTODEVICE (and probably bind to the local IP as well). Some applications such as traceroute already support this binding..others such as ping do not.

You most likely will also have to set up routing tables using source IPs as a rule to direct these connections to a particular routing table.

Quoted 9 lines
Quoted 2 lines

Comments welcome.

I would really prefer to simply make the prio 0 "lookup local" rule deletable so you can rules with higher priority. That allows to do send to self without any further code changes and avoids the need to bind applications to a device.

I am not against making that change as well, but it is often easier to just bind-to-device than to set up specific host routes for every possible combination..as it appears your method requires. (I could have mis-understood the routing requirements, but it seemed to if you wanted any 100 interfaces to send to any other, your method would required 100 * 100 routes.)

A decent set of programs already support bind-to-device, and others are easily patched if they need the behaviour.

Thanks,
Ben

Quoted 5 lines

-
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Ben Greear <[email protected]> Candela Technologies Inc  http://www.candelatech.com
#3 lore raw
Quoted 8 lines · Ben Greear
Quoted 5 lines · Patrick McHardy

I would really prefer to simply make the prio 0 "lookup local" rule deletable so you can rules with higher priority. That allows to do send to self without any further code changes and avoids the need to bind applications to a device.

Quoted 9 lines

I am not against making that change as well, but it is often easier to just bind-to-device
than to set up specific host routes for every possible combination..as it appears your
method requires. (I could have mis-understood the routing requirements, but it seemed to
if you wanted any 100 interfaces to send to any other, your method would required 100 * 100
routes.)

If you want arbitary combinations bases solely on routing, yes (thats not different from not using send to self). But binding explicitly should also work fine.