From patchwork Thu Sep 18 17:00:39 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: iputils: ping.c - using -I for both interface and address From: Nadav Shemer X-Patchwork-Id: 538 Message-Id: To: netdev@vger.kernel.org Date: Thu, 18 Sep 2008 20:00:39 +0300 When I use 'ping 1.2.3.4 -I eth1 -I 2.3.4.5' the packets come out with eth1's address anyway. It seems to me that IP_PKTINFO is set for every packet, with ipi_spec_dst set to 0. This overrides the inet->saddr set by bind. Here's a fix: --- ping.c 2007-11-27 02:57:27.000000000 +0200 +++ ping.c.patched 2008-09-18 19:59:45.000000000 +0300 @@ -350,6 +350,8 @@ fprintf(stderr, "ping: unknown iface %s\n", device); exit(2); } + if (options & F_STRICTSOURCE) + cmsg.ipi.ipi_spec_dst.s_addr = source.sin_addr.s_addr; cmsg.ipi.ipi_ifindex = ifr.ifr_ifindex; cmsg_len = sizeof(cmsg); }