@@ -278,6 +278,21 @@ static int addr6_resolve_remote(struct s
fl.nl_u.ip6_u.daddr = dst_in->sin6_addr;
fl.nl_u.ip6_u.saddr = src_in->sin6_addr;
+ if (ipv6_addr_type(&dst_in->sin6_addr) & IPV6_ADDR_LINKLOCAL){
+ // Link-local address require an interface to be specified.
+ if (!(dst_in->sin6_scope_id||src_in->sin6_scope_id))
+ return -EINVAL;
+
+ // If src and dst interfaces are supplied they must match.
+ if ( (dst_in->sin6_scope_id && src_in->sin6_scope_id) &&
+ (src_in->sin6_scope_id != dst_in->sin6_scope_id) )
+ return -EINVAL;
+ if ( dst_in->sin6_scope_id )
+ fl.oif = dst_in->sin6_scope_id;
+ else
+ fl.oif = src_in->sin6_scope_id;
+ }
+
dst = ip6_route_output(&init_net, NULL, &fl);
if (!dst)
return ret;