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

From: Brian Haley <[email-masked]>
Date: Mon, 02 Jun 2008 12:26:48 -0400

> 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.

Actually, previous patch wasn't exactly correct either, I missed one 
conversion, below is ok.

-Brian

Signed-off-by: Brian Haley <[email-masked]>
---
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 94fa6ae..3abe181 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -541,10 +541,10 @@ 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);
+					dev = dev_get_by_index(&init_net, fl->oif);
 					if (!dev)
 						return -ENODEV;
 				}