UBUNTU: SAUCE: vxlan: correctly handle ipv6.disable module parameter

Message ID 1526385098-2847-2-git-send-email-matt.rae@canonical.com
State New
Headers show
Series
  • UBUNTU: SAUCE: vxlan: correctly handle ipv6.disable module parameter
Related show

Commit Message

Matt Rae May 15, 2018, 11:51 a.m.
From: Jiri Benc <jbenc@redhat.com>

OriginalAuthor: Jiri Benc <jbenc@redhat.com>
BugLink: http://bugs.launchpad.net/bugs/1771301

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 <jbenc@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(backported from RHEL https://bugzilla.redhat.com/show_bug.cgi?id=1445054)
Signed-off-by: Matt Rae <matt.rae@canonical.com>
---
 drivers/net/vxlan.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Jay Vosburgh May 15, 2018, 2:11 p.m. | #1
Matt Rae <mattrae@gmail.com> wrote:

>From: Jiri Benc <jbenc@redhat.com>
>
>OriginalAuthor: Jiri Benc <jbenc@redhat.com>
>BugLink: http://bugs.launchpad.net/bugs/1771301
>
>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 <jbenc@redhat.com>
>Signed-off-by: David S. Miller <davem@davemloft.net>
>(backported from RHEL https://bugzilla.redhat.com/show_bug.cgi?id=1445054)
>Signed-off-by: Matt Rae <matt.rae@canonical.com>

	I believe this should come from the actual mainline commit:

commit d074bf9600443403aa24fbc12c1f18eadc90f5aa
Author: Jiri Benc <jbenc@redhat.com>
Date:   Thu Apr 27 21:24:35 2017 +0200

    vxlan: correctly handle ipv6.disable module parameter

	-J
>---
> drivers/net/vxlan.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
>diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
>index ca91ef9..6b3e66e 100644
>--- a/drivers/net/vxlan.c
>+++ b/drivers/net/vxlan.c
>@@ -2947,17 +2947,21 @@ static int __vxlan_sock_add(struct vxlan_dev *vxlan, bool ipv6)
> 
> static int vxlan_sock_add(struct vxlan_dev *vxlan)
> {
>-	bool ipv6 = vxlan->flags & VXLAN_F_IPV6;
> 	bool metadata = vxlan->flags & VXLAN_F_COLLECT_METADATA;
>+	bool ipv6 = vxlan->flags & VXLAN_F_IPV6 || metadata;
>+	bool ipv4 = !ipv6 || metadata;
> 	int ret = 0;
> 
> 	vxlan->vn4_sock = NULL;
> #if IS_ENABLED(CONFIG_IPV6)
>-	vxlan->vn6_sock = NULL;
>-	if (ipv6 || metadata)
>+	RCU_INIT_POINTER(vxlan->vn6_sock, NULL);
>+	if (ipv6) {
> 		ret = __vxlan_sock_add(vxlan, true);
>+		if (ret < 0 && ret != -EAFNOSUPPORT)
>+			ipv4 = false;
>+	}
> #endif
>-	if (!ret && (!ipv6 || metadata))
>+	if (ipv4)
> 		ret = __vxlan_sock_add(vxlan, false);
> 	if (ret < 0)
> 		vxlan_sock_release(vxlan);
>-- 
>2.7.4
>
>
>-- 
>kernel-team mailing list
>kernel-team@lists.ubuntu.com
>https://lists.ubuntu.com/mailman/listinfo/kernel-team

---
	-Jay Vosburgh, jay.vosburgh@canonical.com

Patch

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index ca91ef9..6b3e66e 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2947,17 +2947,21 @@  static int __vxlan_sock_add(struct vxlan_dev *vxlan, bool ipv6)
 
 static int vxlan_sock_add(struct vxlan_dev *vxlan)
 {
-	bool ipv6 = vxlan->flags & VXLAN_F_IPV6;
 	bool metadata = vxlan->flags & VXLAN_F_COLLECT_METADATA;
+	bool ipv6 = vxlan->flags & VXLAN_F_IPV6 || metadata;
+	bool ipv4 = !ipv6 || metadata;
 	int ret = 0;
 
 	vxlan->vn4_sock = NULL;
 #if IS_ENABLED(CONFIG_IPV6)
-	vxlan->vn6_sock = NULL;
-	if (ipv6 || metadata)
+	RCU_INIT_POINTER(vxlan->vn6_sock, NULL);
+	if (ipv6) {
 		ret = __vxlan_sock_add(vxlan, true);
+		if (ret < 0 && ret != -EAFNOSUPPORT)
+			ipv4 = false;
+	}
 #endif
-	if (!ret && (!ipv6 || metadata))
+	if (ipv4)
 		ret = __vxlan_sock_add(vxlan, false);
 	if (ret < 0)
 		vxlan_sock_release(vxlan);