naccyde / rpms / iproute

Forked from rpms/iproute 7 months ago
Clone

Blame SOURCES/0020-iplink_vxlan-take-into-account-preferred_family-crea.patch

930fb9
From f08a8608335d46bea1b2cb122823a4c538ce6e46 Mon Sep 17 00:00:00 2001
930fb9
From: Phil Sutter <psutter@redhat.com>
930fb9
Date: Thu, 18 Oct 2018 10:53:57 +0200
930fb9
Subject: [PATCH] iplink_vxlan: take into account preferred_family creating
930fb9
 vxlan device
930fb9
930fb9
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1626321
930fb9
Upstream Status: iproute2.git commit c1360e3b483e5
930fb9
930fb9
commit c1360e3b483e54a61a36bd2fdb3bfb91a4d2b32a
930fb9
Author: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
930fb9
Date:   Fri Sep 21 15:34:25 2018 +0200
930fb9
930fb9
    iplink_vxlan: take into account preferred_family creating vxlan device
930fb9
930fb9
    Take into account the configured preferred_family if neither saddr or
930fb9
    daddr are provided since otherwise vxlan kernel module will use IPv4 as
930fb9
    default remote inet family neglecting the one provided by userspace.
930fb9
    This behaviour was originally in commit 97d564b90ccb ("vxlan: use
930fb9
    preferred address family when neither group or remote is specified").
930fb9
    The issue can be triggered with the following reproducer:
930fb9
930fb9
    $ip -6 link add vxlan1 type vxlan id 42 dev enp0s2 \
930fb9
         proxy nolearning l2miss l3miss
930fb9
    $bridge fdb add 46:47:1f:a7:1c:25 dev vxlan1 dst 2000::2
930fb9
    RTNETLINK answers: Address family not supported by protocol
930fb9
930fb9
    Fixes: 1e9b8072de2c ("iplink_vxlan: Get rid of inet_get_addr()")
930fb9
    Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
930fb9
    Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
930fb9
---
930fb9
 ip/iplink_vxlan.c | 15 +++++++++++++++
930fb9
 1 file changed, 15 insertions(+)
930fb9
930fb9
diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c
930fb9
index 2bc253f..831f39a 100644
930fb9
--- a/ip/iplink_vxlan.c
930fb9
+++ b/ip/iplink_vxlan.c
930fb9
@@ -82,6 +82,7 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
930fb9
 	__u64 attrs = 0;
930fb9
 	bool set_op = (n->nlmsg_type == RTM_NEWLINK &&
930fb9
 		       !(n->nlmsg_flags & NLM_F_CREATE));
930fb9
+	bool selected_family = false;
930fb9
 
930fb9
 	saddr.family = daddr.family = AF_UNSPEC;
930fb9
 
930fb9
@@ -356,12 +357,26 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
930fb9
 		int type = (saddr.family == AF_INET) ? IFLA_VXLAN_LOCAL
930fb9
 						     : IFLA_VXLAN_LOCAL6;
930fb9
 		addattr_l(n, 1024, type, saddr.data, saddr.bytelen);
930fb9
+		selected_family = true;
930fb9
 	}
930fb9
 
930fb9
 	if (is_addrtype_inet(&daddr)) {
930fb9
 		int type = (daddr.family == AF_INET) ? IFLA_VXLAN_GROUP
930fb9
 						     : IFLA_VXLAN_GROUP6;
930fb9
 		addattr_l(n, 1024, type, daddr.data, daddr.bytelen);
930fb9
+		selected_family = true;
930fb9
+	}
930fb9
+
930fb9
+	if (!selected_family) {
930fb9
+		if (preferred_family == AF_INET) {
930fb9
+			get_addr(&daddr, "default", AF_INET);
930fb9
+			addattr_l(n, 1024, IFLA_VXLAN_GROUP,
930fb9
+				  daddr.data, daddr.bytelen);
930fb9
+		} else if (preferred_family == AF_INET6) {
930fb9
+			get_addr(&daddr, "default", AF_INET6);
930fb9
+			addattr_l(n, 1024, IFLA_VXLAN_GROUP6,
930fb9
+				  daddr.data, daddr.bytelen);
930fb9
+		}
930fb9
 	}
930fb9
 
930fb9
 	if (!set_op || VXLAN_ATTRSET(attrs, IFLA_VXLAN_LEARNING))
930fb9
-- 
930fb9
1.8.3.1
930fb9