From: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
To: Jan Synacek <jsynacek@redhat.com>
Cc: Ben Greear <greearb@candelatech.com>,
netdev@vger.kernel.org,
YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Subject: Re: iputils: ping -I <iface>
Date: Sat, 01 Dec 2012 04:04:06 +0900 [thread overview]
Message-ID: <50B90326.2010302@linux-ipv6.org> (raw)
In-Reply-To: <50B84CCB.7000502@redhat.com>
(2012年11月30日 15:06), Jan Synacek wrote:
> On 11/29/2012 08:48 PM, Ben Greear wrote:
>> On 11/29/2012 06:12 AM, Jan Synacek wrote:
>>> Hello,
>>>
>>> There seems to be a bug(?) when calling ping with -I lo:
>>>
>>> $ ping -I lo kernel.org
>>>
>>> PING kernel.org (149.20.4.69) from 192.168.1.10 lo: 56(84) bytes of data.
>>> ^C
>>>
>>> Note that 192.168.1.10 is my primary interface's address (em1). However, no
>>> replies are coming back.
>>>
>>> $ ping -I em1 kernel.org
>>>
>>> PING kernel.org (149.20.4.69) from 192.168.1.10 em1: 56(84) bytes of data.
>>> 64 bytes from pub2.kernel.org (149.20.4.69): icmp_seq=1 ttl=42 time=202 ms
>>> 64 bytes from pub2.kernel.org (149.20.4.69): icmp_seq=2 ttl=42 time=187 ms
>>> ^C
>>>
>>> Works as expected.
>>>
>>> I know that binding to loopback probably doesn't make much sense, but I think
>>> that ping should be able to cope with that.
>>
>> I think it would be wrong if ping worked as you suggest. Binding to an
>> interface means use that interface as the source of your packets, and having
>> it bind hard helps when using systems with multiple NICs on same subnet
>> (or possibly, same IP).
>
> I just wanted to point out that if I call ping with -I lo, its 'from' address is
> wrong (in my case 192.168.1.10) and nothing happens (that's, I guess, expected
> if it really bound to loopback). If I call ping with the -I <the same address>
> or -I em1 (the same address again), it works as expected. I'm sorry if I wasn't
> clear enough.
>
>>
>>> Also, it would be nice to mention the difference between -I <ip> and -I <iface>
>>> in the manpage.
>>
>> In my opinion, -I <iface> should use SO_BINDTODEVICE, but at least in
>> older versions of ping it did not.
>
> Ping does use SO_BINDTODEVICE.
So far, -I device is related to source address selection (using
SO_BINDTODEVICE) and outgoing device (using in_pktinfo).
On the other hand, -I addr is, in fact, related to source
address selection (and it is enfoced by bind), only.
Something like this:
-I interface
interface is either an address, or an interface name. If
interface is an address, it sets source address to
specified interface address. If interface
in an interface name, it tells the command to use that
interface. For ping6, when doing ping to a link-local
scope address, link specification (by the
'%'-notation in destination, or by this option) is
required.
BUT, even with -I device, net/ipv4/dev_inet.c:inet_select_addr()
may select an address from other interfaces, AFAIK).
Should we check if the selected source address blongs to the actual
device?
--yoshfuji
next prev parent reply other threads:[~2012-11-30 19:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-29 14:12 iputils: ping -I <iface> Jan Synacek
2012-11-29 19:48 ` Ben Greear
2012-11-30 6:06 ` Jan Synacek
2012-11-30 19:04 ` YOSHIFUJI Hideaki [this message]
2012-11-30 19:11 ` Ben Greear
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=50B90326.2010302@linux-ipv6.org \
--to=yoshfuji@linux-ipv6.org \
--cc=greearb@candelatech.com \
--cc=jsynacek@redhat.com \
--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).