[PATCH] IPv6: fix bug when specifying the non-exist outgoing interface

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <yoshfuji@...>, <davem@...>
Cc: <netdev@...>
Date: Monday, June 2, 2008 - 4:12 am

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


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] IPv6: fix bug when specifying the non-exist outgoing..., Shan Wei, (Mon Jun 2, 4:12 am)
Re: [PATCH] IPv6: fix bug when specifying the non-exist outg..., YOSHIFUJI Hideaki / , (Mon Jun 2, 4:20 am)
Re: [PATCH v2] IPv6: fix bug when specifying the non-exist o..., YOSHIFUJI Hideaki / , (Mon Jun 2, 12:41 pm)
Re: [PATCH v2] IPv6: fix bug when specifying the non-exist o..., YOSHIFUJI Hideaki / , (Mon Jun 2, 12:46 pm)
Re: [PATCH v2] IPv6: fix bug when specifying the non-exist o..., YOSHIFUJI Hideaki / , (Mon Jun 2, 12:48 pm)
Re: [PATCH v2] IPv6: fix bug when specifying the non-exist o..., YOSHIFUJI Hideaki / , (Mon Jun 2, 1:07 pm)
Re: [PATCH v2] IPv6: fix bug when specifying the non-exist o..., YOSHIFUJI Hideaki / , (Tue Jun 3, 12:52 am)
Re: [PATCH v2] IPv6: fix bug when specifying the non-exist o..., YOSHIFUJI Hideaki / , (Mon Jun 2, 5:17 am)