linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willy Tarreau <willy@w.ods.org>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Carlos Velasco <carlosev@newipnet.com>,
	Lamont Granquist <lamont@scriptkiddie.org>,
	Bill Davidsen <davidsen@tmr.com>,
	"David S. Miller" <davem@redhat.com>,
	bloemsaa@xs4all.nl, Marcelo Tosatti <marcelo@conectiva.com.br>,
	netdev@oss.sgi.com, linux-net@vger.kernel.org, layes@loran.com,
	torvalds@osdl.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [2.4 PATCH] bugfix: ARP respond on all devices
Date: Mon, 18 Aug 2003 00:48:49 +0200	[thread overview]
Message-ID: <20030817224849.GB734@alpha.home.local> (raw)
In-Reply-To: <1061141045.21885.74.camel@dhcp23.swansea.linux.org.uk>

Hi Alan !

On Sun, Aug 17, 2003 at 06:24:06PM +0100, Alan Cox wrote:
 
> So stick the address on eth0 not on lo since its not a loopback but an eth0
> address, then use arpfilter so you don't arp for the invalid magic shared IP
> address, or NAT it, or it may work to do
> 
>          ip route add nexthop-addr src my-virtual-addr dev eth0 scope local onlink
>          ip route add default src my-virtual-addr via nexthop-addr dev eth0 scope global
 
I have a case where this doesn't work, and which required me to apply Julian's
arp_prefsrc patch, because I couldn't resolve it with iproute alone. This is a
fairly simple and certainly common scenario :

   box A : client        router           box B
   +------------+     +---------+      +--------+
---+ eth0  eth1 +-----+ gateway +------+ server +
   +------------+     +---------+      +--------+
   10.1      11.1     11.2   12.2      12.3    <-- IP : 10.1 for 10.0.0.1, etc.

Network 11 is an interconnect network, it is not known from box B, but B knows
how to reach network 10 through the router (12.0.0.2), which also knows how to
reach 10 through 11.0.0.1 of course.

If I want to be able to reach box B from A (eg for debugging purposes), I need
it to join B from its 10.1 address, through gateway 11.2. I do the following
on Box A:
  ip route add 11.0.0.2 src 11.0.0.1 dev eth1 onlink
  ip route add 12.0.0.3 via 11.0.0.2 src 10.0.0.1 dev eth1

To me, it means that when talking to 12.0.0.3, I bind to source 10.0.0.1, and
route through 11.0.0.2, which I obtain the MAC address by asking with a source
of 11.0.0.1.

But it doesn't work this way : 11.0.0.2 receives ARP requests from 10.0.0.1
and obviously refuses them.

But now if I simply ping 11.0.0.2, this one won't work either because box A
will still try to request its MAC address with 10.0.0.1 as its source ! So I
manually delete the incomplete ARP entry, and ping 11.0.0.2 again. This time,
the valid address (11.0.0.1) is used, and I can reach 12.0.0.3 from 10.0.0.1
as long as the ARP entry stays valid.

Perhaps this is a standard arp_filter case, but I didn't find how to resolve
it, except by using Julian's arp_prefsrc patch which does a lookup of a valid
source address to send the ARP request. Now, each time I have these sort of
setup and I don't have a patched kernel, I prepare a background ping to feed
the ARP cache correctly.

And frankly, I don't understand what feature it brings to deliberately use a
wrong address as the source for ARP requests. I have searched a long time, but
still didn't find any advantage to this behaviour. Reading the code, I don't
think it was deliberate, but only a forgotten case. To me, the first route
entry above is explicit enough : use 11.0.0.1 as a source when trying to reach
11.0.0.2, so I don't see why ARP requests don't respect this.

If you want to reproduce the setup above, you only need ONE host and tcpdump.
Simply put the two addresses on the same NIC, add the routes and watch the ARP
requests go out with the wrong source.

Here is Julian's patch if you want to take a look at it. It seems fairly
logical to me, and I don't see what it could break. But again, if you have a
way to do something equivalent with iproute or any other standard method, I'd
be glad to try.

Cheers,
Willy

--- v2.4.12/linux/net/ipv4/arp.c	Tue Sep 25 02:38:23 2001
+++ linux/net/ipv4/arp.c	Mon Oct 22 22:58:49 2001
@@ -316,16 +316,19 @@
 
 static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb)
 {
+	struct rtable *rt;
 	u32 saddr;
 	u8  *dst_ha = NULL;
 	struct net_device *dev = neigh->dev;
 	u32 target = *(u32*)neigh->primary_key;
 	int probes = atomic_read(&neigh->probes);
 
-	if (skb && inet_addr_type(skb->nh.iph->saddr) == RTN_LOCAL)
-		saddr = skb->nh.iph->saddr;
-	else
-		saddr = inet_select_addr(dev, target, RT_SCOPE_LINK);
+	if (ip_route_output(&rt, target, 0, 0, dev->ifindex) < 0)
+		return;
+	saddr = rt->rt_src;
+	ip_rt_put(rt);
+	if (!saddr)
+		return;
 
 	if ((probes -= neigh->parms->ucast_probes) < 0) {
 		if (!(neigh->nud_state&NUD_VALID))



  reply	other threads:[~2003-08-17 22:56 UTC|newest]

Thread overview: 168+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-27 20:52 [2.4 PATCH] bugfix: ARP respond on all devices Bas Bloemsaat
2003-07-27 22:12 ` David S. Miller
2003-07-28  2:31   ` Ben Greear
2003-07-28  7:33     ` Bas Bloemsaat
2003-07-27 23:40 ` Carlos Velasco
2003-07-27 23:46   ` David S. Miller
2003-07-27 23:58     ` Carlos Velasco
2003-07-27 23:58       ` David S. Miller
2003-07-28  0:11         ` Carlos Velasco
2003-07-28  0:14           ` David S. Miller
2003-07-28  0:35             ` Carlos Velasco
2003-07-28  0:36               ` David S. Miller
2003-07-28  0:53                 ` Carlos Velasco
2003-07-28  0:55                   ` David S. Miller
2003-07-28  1:23                     ` Carlos Velasco
2003-07-28  1:35                       ` David S. Miller
2003-07-28 10:43                         ` Carlos Velasco
2003-07-28 17:09                           ` Phil Oester
2003-07-28 18:56                             ` Bas Bloemsaat
2003-07-28  4:37                     ` David Lang
2003-07-28  4:39                       ` David S. Miller
2003-07-28 10:49                       ` Carlos Velasco
2003-07-28  0:57           ` Assorted 2.6.0-test2 build warnings J.C. Wren
2003-07-28 22:11             ` Randy.Dunlap
2003-07-29 10:42               ` Adrian Bunk
2003-07-29  2:51     ` [2.4 PATCH] bugfix: ARP respond on all devices Bill Davidsen
2003-07-29  4:48       ` Lamont Granquist
2003-08-04  6:10         ` Pekka Savola
2003-08-17 13:09         ` Carlos Velasco
2003-08-17 13:16           ` Carlos Velasco
2003-08-17 13:41             ` Alan Cox
2003-08-17 13:55               ` Carlos Velasco
2003-08-17 15:12                 ` Bernd Eckenfels
2003-08-17 15:28                 ` Alan Cox
2003-08-17 15:57                   ` Bas Bloemsaat
2003-08-17 15:59                   ` Carlos Velasco
2003-08-17 16:26                     ` Alan Cox
2003-08-17 16:27                       ` Carlos Velasco
2003-08-17 17:24                         ` Alan Cox
2003-08-17 22:48                           ` Willy Tarreau [this message]
2003-08-18  5:22                             ` David S. Miller
2003-08-18  6:56                               ` Willy Tarreau
2003-08-18  7:01                                 ` David S. Miller
2003-08-18  7:29                                   ` Willy Tarreau
2003-08-18  7:43                                     ` Willy Tarreau
2003-08-18  5:31                             ` David S. Miller
2003-08-18 11:39                               ` Stephan von Krawczynski
2003-08-18 11:44                                 ` David S. Miller
2003-08-18 12:34                                   ` Stephan von Krawczynski
2003-08-18 12:30                                     ` David S. Miller
2003-08-18 12:51                                       ` Mr. James W. Laferriere
2003-08-18 12:53                                       ` Stephan von Krawczynski
2003-08-18 12:55                                         ` David S. Miller
2003-08-18 13:17                                           ` Stephan von Krawczynski
2003-08-18 13:14                                             ` David S. Miller
2003-08-18 14:23                                               ` Stephan von Krawczynski
2003-08-18 14:19                                                 ` David S. Miller
2003-08-18 15:46                                                   ` Stephan von Krawczynski
2003-08-18 13:23                                           ` jamal
2003-08-18 13:21                                             ` David S. Miller
2003-08-18 13:40                                               ` Stephan von Krawczynski
2003-08-20  6:55                                             ` Bas Bloemsaat
2003-08-18 21:54                                       ` Bill Davidsen
2003-08-18 13:40                                     ` Dominik Kubla
2003-08-18 12:51                                   ` Willy Tarreau
2003-08-18 12:53                                     ` David S. Miller
2003-08-18 14:28                                       ` Willy Tarreau
2003-08-18 14:28                                         ` David S. Miller
2003-08-18 12:08                                 ` Bas Bloemsaat
2003-08-18 12:03                                   ` David S. Miller
2003-08-18 21:32                               ` Bill Davidsen
2003-08-19  3:21                                 ` Ben Greear
2003-08-19 15:22                                   ` David S. Miller
2003-08-19  7:58                                 ` Bas Bloemsaat
2003-08-18 15:49                         ` SRC IP selection in ARP request (Was: bugfix: ARP respond on all devices) Vladimir B. Savkin
2003-08-17 16:51                     ` [2.4 PATCH] bugfix: ARP respond on all devices David T Hollis
2003-08-17 16:45                       ` Carlos Velasco
2003-08-17 17:13                         ` Arjan van de Ven
2003-08-17 19:46                           ` insecure
2003-08-18  5:11                             ` David S. Miller
2003-08-18  5:29                 ` David S. Miller
2003-08-17 13:59               ` Bas Bloemsaat
2003-08-18 10:48               ` Robert Collier
2003-08-17 13:38           ` Alan Cox
     [not found] <e2Yb.5CB.17@gated-at.bofh.it>
     [not found] ` <e43Y.6x0.17@gated-at.bofh.it>
     [not found]   ` <e43Y.6x0.19@gated-at.bofh.it>
     [not found]     ` <e43Y.6x0.21@gated-at.bofh.it>
     [not found]       ` <e43Y.6x0.23@gated-at.bofh.it>
     [not found]         ` <e43Y.6x0.25@gated-at.bofh.it>
     [not found]           ` <e43Y.6x0.15@gated-at.bofh.it>
     [not found]             ` <e4nd.6K9.5@gated-at.bofh.it>
     [not found]               ` <e4ne.6K9.11@gated-at.bofh.it>
     [not found]                 ` <e4x3.6RV.23@gated-at.bofh.it>
     [not found]                   ` <e4Qe.7cR.3@gated-at.bofh.it>
     [not found]                     ` <e503.7kj.23@gated-at.bofh.it>
     [not found]                       ` <e5jh.7yW.5@gated-at.bofh.it>
     [not found]                         ` <edJU.6nT.25@gated-at.bofh.it>
2003-07-28 20:45                           ` Julien Oster
2003-08-19 12:02 Richard Underwood
2003-08-19 12:35 ` Alan Cox
2003-08-19 18:30   ` Daniel Gryniewicz
2003-08-19 18:29     ` David S. Miller
2003-08-19 19:12       ` Daniel Gryniewicz
2003-08-19 19:10         ` David S. Miller
2003-08-20 16:49         ` Bill Davidsen
2003-08-20 17:00           ` David S. Miller
2003-08-20 17:44             ` Ben Greear
2003-08-20 17:48               ` David S. Miller
2003-08-20 23:18                 ` Julian Anastasov
2003-08-23 20:50                 ` Bill Davidsen
2003-08-20 19:08             ` Bill Davidsen
2003-08-20 20:07               ` Bas Bloemsaat
2003-08-19 19:42       ` bill davidsen
2003-08-19 13:11 ` Bas Bloemsaat
2003-08-19 15:34   ` David S. Miller
2003-08-19 17:39     ` Lars Marowsky-Bree
2003-08-19 17:36       ` David S. Miller
2003-08-19 21:01         ` Harley Stenzel
2003-08-19 16:19   ` Stephan von Krawczynski
2003-08-19 16:54   ` David S. Miller
2003-08-19 17:15     ` Stephan von Krawczynski
2003-08-19 16:56 ` David S. Miller
2003-08-19 14:34 Richard Underwood
2003-08-19 14:54 ` Willy Tarreau
2003-08-19 15:07   ` Stephan von Krawczynski
2003-08-19 15:57     ` David S. Miller
2003-08-19 16:52       ` Stephan von Krawczynski
2003-08-19 16:53         ` David S. Miller
2003-08-19 17:12           ` Stephan von Krawczynski
2003-08-19 17:09             ` David S. Miller
2003-08-19 19:04         ` Alan Cox
2003-08-19 19:01           ` David S. Miller
2003-08-19 19:19             ` Bas Bloemsaat
2003-08-19 19:16               ` David S. Miller
2003-08-20  8:49               ` Roman Pletka
2003-08-20 14:15                 ` Stephan von Krawczynski
2003-08-20 14:43                   ` Roman Pletka
2003-08-20 15:55                     ` Stephan von Krawczynski
2003-08-20 16:47                       ` Roman Pletka
2003-08-19 15:53   ` Bill Davidsen
2003-08-19 16:14     ` David S. Miller
2003-08-19 17:17       ` Bill Davidsen
2003-08-19 19:08 ` Alan Cox
2003-08-19 21:53   ` Stephan von Krawczynski
2003-08-19 16:54 Richard Underwood
2003-08-19 16:51 ` David S. Miller
2003-08-19 17:10   ` Stephan von Krawczynski
2003-08-19 17:07     ` David S. Miller
2003-08-19 19:57       ` bill davidsen
2003-08-19 17:56 Richard Underwood
2003-08-19 17:53 ` David S. Miller
2003-08-19 18:05 Richard Underwood
2003-08-19 18:21 ` David S. Miller
2003-08-20 12:52   ` Harley Stenzel
2003-08-19 18:16 Richard Underwood
2003-08-19 18:13 ` David S. Miller
2003-08-19 18:30   ` Bas Bloemsaat
     [not found] <mdtk.Zy.1@gated-at.bofh.it>
     [not found] ` <mgUv.3Wb.39@gated-at.bofh.it>
     [not found]   ` <mgUv.3Wb.37@gated-at.bofh.it>
     [not found]     ` <miMw.5yo.31@gated-at.bofh.it>
2003-08-19 18:48       ` Andi Kleen
2003-08-19 19:17         ` Daniel Gryniewicz
2003-08-19 19:21           ` Andi Kleen
2003-08-19 19:27             ` Daniel Gryniewicz
2003-08-19 19:24               ` David S. Miller
2003-08-19 19:32               ` Andi Kleen
2003-08-19 19:28                 ` David S. Miller
2003-08-20  9:53                   ` Alan Cox
2003-08-20 15:41                   ` Stephan von Krawczynski
2003-08-20 15:38                     ` David S. Miller
2003-08-19 19:38           ` Valdis.Kletnieks
2003-08-19 19:37             ` David S. Miller
2003-08-19 20:44               ` Valdis.Kletnieks
2003-08-19 19:00 Richard Underwood
2003-08-19 18:58 ` David S. Miller
     [not found] <mfYi.374.31@gated-at.bofh.it>
     [not found] ` <mkbE.6Rk.35@gated-at.bofh.it>
2003-08-19 20:00   ` Andi Kleen
2003-08-19 19:56     ` David S. Miller
2003-08-19 22:12 Richard Underwood
2003-08-19 22:11 ` David S. Miller
2003-08-19 23:15   ` Stephan von Krawczynski
2003-08-20  8:58 Richard Underwood
2003-08-20 15:23 ` jamal
2003-08-20 15:28   ` jamal
2003-08-20 20:10 Richard Underwood

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=20030817224849.GB734@alpha.home.local \
    --to=willy@w.ods.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=bloemsaa@xs4all.nl \
    --cc=carlosev@newipnet.com \
    --cc=davem@redhat.com \
    --cc=davidsen@tmr.com \
    --cc=lamont@scriptkiddie.org \
    --cc=layes@loran.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-net@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    --cc=netdev@oss.sgi.com \
    --cc=torvalds@osdl.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).