From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH net-next v4 3/9] net: ensure unbound datagram socket to be chosen when not in a VRF Date: Tue, 6 Nov 2018 10:59:45 -0700 Message-ID: <4c8da935-35c0-d2b3-af12-9557209ac5dd@gmail.com> References: <20181102191020.14170-1-mmanning@vyatta.att-mail.com> <20181102191020.14170-4-mmanning@vyatta.att-mail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: Mike Manning , netdev@vger.kernel.org Return-path: Received: from mail-pl1-f179.google.com ([209.85.214.179]:37180 "EHLO mail-pl1-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387739AbeKGD0K (ORCPT ); Tue, 6 Nov 2018 22:26:10 -0500 Received: by mail-pl1-f179.google.com with SMTP id p6-v6so6557765pll.4 for ; Tue, 06 Nov 2018 09:59:48 -0800 (PST) In-Reply-To: <20181102191020.14170-4-mmanning@vyatta.att-mail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 11/2/18 1:10 PM, Mike Manning wrote: > diff --git a/include/net/udp.h b/include/net/udp.h > index 9e82cb391dea..057972d0eea5 100644 > --- a/include/net/udp.h > +++ b/include/net/udp.h > @@ -252,6 +252,17 @@ static inline int udp_rqueue_get(struct sock *sk) > return sk_rmem_alloc_get(sk) - READ_ONCE(udp_sk(sk)->forward_deficit); > } > > +static inline bool udp_sk_bound_dev_eq(struct net *net, int bound_dev_if, > + int dif, int sdif) > +{ > +#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV) > + return inet_bound_dev_eq(net->ipv4.sysctl_udp_l3mdev_accept, !!net->ipv4.sysctl_udp_l3mdev_accept since first arg is a bool > + bound_dev_if, dif, sdif); > +#else > + return inet_bound_dev_eq(1, bound_dev_if, dif, sdif); > +#endif > +} > + > /* net/ipv4/udp.c */ > void udp_destruct_sock(struct sock *sk); > void skb_consume_udp(struct sock *sk, struct sk_buff *skb, int len); ... > diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c > index 1ede7a16a0be..4813293d4fad 100644 > --- a/net/ipv6/datagram.c > +++ b/net/ipv6/datagram.c > @@ -782,7 +782,10 @@ int ip6_datagram_send_ctl(struct net *net, struct sock *sk, > > if (src_info->ipi6_ifindex) { > if (fl6->flowi6_oif && > - src_info->ipi6_ifindex != fl6->flowi6_oif) > + src_info->ipi6_ifindex != fl6->flowi6_oif && > + (sk->sk_bound_dev_if != fl6->flowi6_oif || > + !sk_dev_equal_l3scope( > + sk, src_info->ipi6_ifindex))) That's getting ugly to read. A tmp variable int idx = rc_info->ipi6_ifindex; should shorten that to fit on one line. > return -EINVAL; > fl6->flowi6_oif = src_info->ipi6_ifindex; > }