From: Shan Wei <shanwei@cn.fujitsu.com>
To: yoshfuji@linux-ipv6.org, davem@sunset.davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH] IPv6: fix bug when specifying the non-exist outgoing interface
Date: Mon, 02 Jun 2008 16:12:01 +0800 [thread overview]
Message-ID: <4843AB51.6010206@cn.fujitsu.com> (raw)
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。
The patch is against 2.6.26-rc4.
Signed-off-by: Shan Wei<shanwei@cn.fujitsu.com>
---
net/ipv6/datagram.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 94fa6ae..a6d402b 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -535,6 +535,12 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
fl->oif = src_info->ipi6_ifindex;
}
+ if (fl->oif){
+ dev = dev_get_by_index(&init_net, fl->oif);
+ if (!dev)
+ return -ENODEV;
+ }
+
addr_type = ipv6_addr_type(&src_info->ipi6_addr);
if (addr_type == IPV6_ADDR_ANY)
@@ -543,11 +549,6 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
if (addr_type & IPV6_ADDR_LINKLOCAL) {
if (!src_info->ipi6_ifindex)
return -EINVAL;
- else {
- dev = dev_get_by_index(&init_net, src_info->ipi6_ifindex);
- if (!dev)
- return -ENODEV;
- }
}
if (!ipv6_chk_addr(&init_net, &src_info->ipi6_addr,
dev, 0)) {
-- 1.5.4.4
next reply other threads:[~2008-06-02 8:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-02 8:12 Shan Wei [this message]
2008-06-02 8:20 ` [PATCH] IPv6: fix bug when specifying the non-exist outgoing interface 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
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=4843AB51.6010206@cn.fujitsu.com \
--to=shanwei@cn.fujitsu.com \
--cc=davem@sunset.davemloft.net \
--cc=netdev@vger.kernel.org \
--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).