netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Haley <brian.haley@hp.com>
To: Shan Wei <shanwei@cn.fujitsu.com>
Cc: "YOSHIFUJI Hideaki / 吉藤英明" <yoshfuji@linux-ipv6.org>,
	davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH v2] IPv6: fix bug when specifying the non-exist outgoing interface
Date: Mon, 02 Jun 2008 12:14:58 -0400	[thread overview]
Message-ID: <48441C82.1070609@hp.com> (raw)
In-Reply-To: <4843B65C.1060702@cn.fujitsu.com>

[-- Attachment #1: Type: text/plain, Size: 1145 bytes --]

Shan Wei wrote:
>   When specifying the outgoing interface with sendmsg, if the ipi6_addr is 
> the unspecified address and the ipi6_ifindex is the not-exist interface, 
> it should be fail and the errno should be set ENODEV.
>   Actually, it does well(sendmsg returns on success ), because the kernel 
> don't check the interface。

This patch changes this code path to be different than most others that 
completely ignore the device for the unspecified address - for example 
inet6_bind() and rawv6_bind().  Those paths only care about the device 
for a link-local address, so I don't think this patch is correct.

In the current git tree, this :: address is going to turn-into ::1, so 
the ifindex is irrelevant, the packet will be looped-back.  Older 
kernels could transmit the packet on the wire using the default route. 
Can you elaborate on the problem you were seeing?

I did notice a slight problem where if fl->oif is set in the caller (for 
example via SO_BINDTODEVICE), it's ignored in datagram_send_ctl() if 
src_info->ipi6_ifindex is zero, attached patch fixes that.

-Brian

Signed-off-by: Brian Haley <brian.haley@hp.com>
---

[-- Attachment #2: datagram_send_ctl.floif.patch --]
[-- Type: text/x-diff, Size: 426 bytes --]

diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 94fa6ae..b6a7c7b 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -541,7 +541,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
 				break;
 
 			if (addr_type & IPV6_ADDR_LINKLOCAL) {
-				if (!src_info->ipi6_ifindex)
+				if (!fl->oif)
 					return -EINVAL;
 				else {
 					dev = dev_get_by_index(&init_net, src_info->ipi6_ifindex);

  parent reply	other threads:[~2008-06-02 16:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-02  8:12 [PATCH] IPv6: fix bug when specifying the non-exist outgoing interface Shan Wei
2008-06-02  8:20 ` YOSHIFUJI Hideaki / 吉藤英明
2008-06-02  8:52   ` [PATCH v2] " Shan Wei
2008-06-02  8:59   ` Shan Wei
2008-06-02  9:17     ` YOSHIFUJI Hideaki / 吉藤英明
2008-06-02 16:14     ` Brian Haley [this message]
2008-06-02 16:26       ` Brian Haley
2008-06-02 16:41       ` YOSHIFUJI Hideaki / 吉藤英明
2008-06-02 16:46         ` YOSHIFUJI Hideaki / 吉藤英明
2008-06-02 16:48           ` YOSHIFUJI Hideaki / 吉藤英明
2008-06-02 17:07             ` YOSHIFUJI Hideaki / 吉藤英明
2008-06-02 17:39               ` Brian Haley
2008-06-03  4:52                 ` YOSHIFUJI Hideaki / 吉藤英明
2008-06-03  7:03                   ` Shan Wei
2008-06-03  7:04                   ` Shan Wei
2008-06-02 17:39         ` Brian Haley

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=48441C82.1070609@hp.com \
    --to=brian.haley@hp.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=shanwei@cn.fujitsu.com \
    --cc=yoshfuji@linux-ipv6.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).