Return-Path: Received: from mail-sn1nam01on0105.outbound.protection.outlook.com ([104.47.32.105]:54752 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965927AbeCHFC7 (ORCPT ); Thu, 8 Mar 2018 00:02:59 -0500 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Jiri Benc , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 125/190] vxlan: correctly handle ipv6.disable module parameter Date: Thu, 8 Mar 2018 04:59:46 +0000 Message-ID: <20180308045810.8041-125-alexander.levin@microsoft.com> References: <20180308045810.8041-1-alexander.levin@microsoft.com> In-Reply-To: <20180308045810.8041-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Jiri Benc [ Upstream commit d074bf9600443403aa24fbc12c1f18eadc90f5aa ] When IPv6 is compiled but disabled at runtime, __vxlan_sock_add returns -EAFNOSUPPORT. For metadata based tunnels, this causes failure of the whole operation of bringing up the tunnel. Ignore failure of IPv6 socket creation for metadata based tunnels caused by IPv6 not being available. Fixes: b1be00a6c39f ("vxlan: support both IPv4 and IPv6 sockets in a single= vxlan device") Signed-off-by: Jiri Benc Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/vxlan.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 983e941bdf29..817b22f913da 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -2816,17 +2816,21 @@ static int __vxlan_sock_add(struct vxlan_dev *vxlan= , bool ipv6) =20 static int vxlan_sock_add(struct vxlan_dev *vxlan) { - bool ipv6 =3D vxlan->flags & VXLAN_F_IPV6; bool metadata =3D vxlan->flags & VXLAN_F_COLLECT_METADATA; + bool ipv6 =3D vxlan->flags & VXLAN_F_IPV6 || metadata; + bool ipv4 =3D !ipv6 || metadata; int ret =3D 0; =20 RCU_INIT_POINTER(vxlan->vn4_sock, NULL); #if IS_ENABLED(CONFIG_IPV6) RCU_INIT_POINTER(vxlan->vn6_sock, NULL); - if (ipv6 || metadata) + if (ipv6) { ret =3D __vxlan_sock_add(vxlan, true); + if (ret < 0 && ret !=3D -EAFNOSUPPORT) + ipv4 =3D false; + } #endif - if (!ret && (!ipv6 || metadata)) + if (ipv4) ret =3D __vxlan_sock_add(vxlan, false); if (ret < 0) vxlan_sock_release(vxlan); --=20 2.14.1