Blame SOURCES/0011-support-IFLA_LINK_NETNSID-rh1255050.patch

e3ad84
From 42d8ecc85940e86213d194ae81bb74d174726084 Mon Sep 17 00:00:00 2001
e3ad84
From: Thomas Graf <tgraf@suug.ch>
e3ad84
Date: Sat, 9 Nov 2013 10:04:35 +0100
e3ad84
Subject: [PATCH 1/4] link: Fall back to global provisioned link cache if
e3ad84
 object is not a cache resident
e3ad84
e3ad84
... if that fails, print ifindices directly.
e3ad84
e3ad84
Reported-by: Dan Williams <dcbw@redhat.com>
e3ad84
Signed-off-by: Thomas Graf <tgraf@suug.ch>
e3ad84
(cherry picked from commit 04040110cde4966e287e8d04a8ebea2855c89a79)
e3ad84
---
e3ad84
 lib/route/link.c | 31 +++++++++++++++++++++++--------
e3ad84
 1 file changed, 23 insertions(+), 8 deletions(-)
e3ad84
e3ad84
diff --git a/lib/route/link.c b/lib/route/link.c
e3ad84
index 1f27247..49a8b65 100644
e3ad84
--- a/lib/route/link.c
e3ad84
+++ b/lib/route/link.c
e3ad84
@@ -599,6 +599,12 @@ static void link_dump_line(struct nl_object *obj, struct nl_dump_params *p)
e3ad84
 	char buf[128];
e3ad84
 	struct nl_cache *cache = obj->ce_cache;
e3ad84
 	struct rtnl_link *link = (struct rtnl_link *) obj;
e3ad84
+	int fetched_cache = 0;
e3ad84
+
e3ad84
+	if (!cache) {
e3ad84
+		cache = nl_cache_mngt_require_safe("route/link");
e3ad84
+		fetched_cache = 1;
e3ad84
+	}
e3ad84
 
e3ad84
 	nl_dump_line(p, "%s %s ", link->l_name,
e3ad84
 		     nl_llproto2str(link->l_arptype, buf, sizeof(buf)));
e3ad84
@@ -607,10 +613,13 @@ static void link_dump_line(struct nl_object *obj, struct nl_dump_params *p)
e3ad84
 		nl_dump(p, "%s ", nl_addr2str(link->l_addr, buf, sizeof(buf)));
e3ad84
 
e3ad84
 	if (link->ce_mask & LINK_ATTR_MASTER) {
e3ad84
-		struct rtnl_link *master = rtnl_link_get(cache, link->l_master);
e3ad84
-		nl_dump(p, "master %s ", master ? master->l_name : "inv");
e3ad84
-		if (master)
e3ad84
-			rtnl_link_put(master);
e3ad84
+		if (cache) {
e3ad84
+			struct rtnl_link *master = rtnl_link_get(cache, link->l_master);
e3ad84
+			nl_dump(p, "master %s ", master ? master->l_name : "inv");
e3ad84
+			if (master)
e3ad84
+				rtnl_link_put(master);
e3ad84
+		} else
e3ad84
+			nl_dump(p, "master %d ", link->l_master);
e3ad84
 	}
e3ad84
 
e3ad84
 	rtnl_link_flags2str(link->l_flags, buf, sizeof(buf));
e3ad84
@@ -618,10 +627,13 @@ static void link_dump_line(struct nl_object *obj, struct nl_dump_params *p)
e3ad84
 		nl_dump(p, "<%s> ", buf);
e3ad84
 
e3ad84
 	if (link->ce_mask & LINK_ATTR_LINK) {
e3ad84
-		struct rtnl_link *ll = rtnl_link_get(cache, link->l_link);
e3ad84
-		nl_dump(p, "slave-of %s ", ll ? ll->l_name : "NONE");
e3ad84
-		if (ll)
e3ad84
-			rtnl_link_put(ll);
e3ad84
+		if (cache) {
e3ad84
+			struct rtnl_link *ll = rtnl_link_get(cache, link->l_link);
e3ad84
+			nl_dump(p, "slave-of %s ", ll ? ll->l_name : "NONE");
e3ad84
+			if (ll)
e3ad84
+				rtnl_link_put(ll);
e3ad84
+		} else
e3ad84
+			nl_dump(p, "slave-of %d ", link->l_link);
e3ad84
 	}
e3ad84
 
e3ad84
 	if (link->ce_mask & LINK_ATTR_GROUP)
e3ad84
@@ -633,6 +645,9 @@ static void link_dump_line(struct nl_object *obj, struct nl_dump_params *p)
e3ad84
 	do_foreach_af(link, af_dump_line, p);
e3ad84
 
e3ad84
 	nl_dump(p, "\n");
e3ad84
+
e3ad84
+	if (fetched_cache)
e3ad84
+		nl_cache_put(cache);
e3ad84
 }
e3ad84
 
e3ad84
 static void link_dump_details(struct nl_object *obj, struct nl_dump_params *p)
e3ad84
-- 
e3ad84
2.4.3
e3ad84
e3ad84
e3ad84
From a67cd6a68c16292f724269bc8da5f2f2501cacb7 Mon Sep 17 00:00:00 2001
e3ad84
From: Cong Wang <xiyou.wangcong@gmail.com>
e3ad84
Date: Tue, 9 Jun 2015 21:53:09 -0700
e3ad84
Subject: [PATCH 2/4] include/linux: update copy of kernel header "if_link.h"
e3ad84
e3ad84
Taken from upstream kernel commit b953c0d234bc72e8489d3bf51a276c5c4ec85345
e3ad84
(v4.1), file 'include/uapi/linux/if_link.h' (after `make headers_install`).
e3ad84
e3ad84
Signed-off-by: Thomas Haller <thaller@redhat.com>
e3ad84
(cherry picked from commit f808b84a5de7c33694d362807e897d8a064b9bcd)
e3ad84
---
e3ad84
 include/linux/if_link.h | 69 +++++++++++++++++++++++++++++++++++++++++++++----
e3ad84
 1 file changed, 64 insertions(+), 5 deletions(-)
e3ad84
e3ad84
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
e3ad84
index ff95760..3d0d613 100644
e3ad84
--- a/include/linux/if_link.h
e3ad84
+++ b/include/linux/if_link.h
e3ad84
@@ -1,5 +1,5 @@
e3ad84
-#ifndef _UAPI_LINUX_IF_LINK_H
e3ad84
-#define _UAPI_LINUX_IF_LINK_H
e3ad84
+#ifndef _LINUX_IF_LINK_H
e3ad84
+#define _LINUX_IF_LINK_H
e3ad84
 
e3ad84
 #include <linux/types.h>
e3ad84
 #include <linux/netlink.h>
e3ad84
@@ -145,6 +145,9 @@ enum {
e3ad84
 	IFLA_CARRIER,
e3ad84
 	IFLA_PHYS_PORT_ID,
e3ad84
 	IFLA_CARRIER_CHANGES,
e3ad84
+	IFLA_PHYS_SWITCH_ID,
e3ad84
+	IFLA_LINK_NETNSID,
e3ad84
+	IFLA_PHYS_PORT_NAME,
e3ad84
 	__IFLA_MAX
e3ad84
 };
e3ad84
 
e3ad84
@@ -152,10 +155,8 @@ enum {
e3ad84
 #define IFLA_MAX (__IFLA_MAX - 1)
e3ad84
 
e3ad84
 /* backwards compatibility for userspace */
e3ad84
-#ifndef __KERNEL__
e3ad84
 #define IFLA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
e3ad84
 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
e3ad84
-#endif
e3ad84
 
e3ad84
 enum {
e3ad84
 	IFLA_INET_UNSPEC,
e3ad84
@@ -213,8 +214,24 @@ enum {
e3ad84
 enum in6_addr_gen_mode {
e3ad84
 	IN6_ADDR_GEN_MODE_EUI64,
e3ad84
 	IN6_ADDR_GEN_MODE_NONE,
e3ad84
+	IN6_ADDR_GEN_MODE_STABLE_PRIVACY,
e3ad84
 };
e3ad84
 
e3ad84
+/* Bridge section */
e3ad84
+
e3ad84
+enum {
e3ad84
+	IFLA_BR_UNSPEC,
e3ad84
+	IFLA_BR_FORWARD_DELAY,
e3ad84
+	IFLA_BR_HELLO_TIME,
e3ad84
+	IFLA_BR_MAX_AGE,
e3ad84
+	IFLA_BR_AGEING_TIME,
e3ad84
+	IFLA_BR_STP_STATE,
e3ad84
+	IFLA_BR_PRIORITY,
e3ad84
+	__IFLA_BR_MAX,
e3ad84
+};
e3ad84
+
e3ad84
+#define IFLA_BR_MAX	(__IFLA_BR_MAX - 1)
e3ad84
+
e3ad84
 enum {
e3ad84
 	BRIDGE_MODE_UNSPEC,
e3ad84
 	BRIDGE_MODE_HAIRPIN,
e3ad84
@@ -231,6 +248,9 @@ enum {
e3ad84
 	IFLA_BRPORT_FAST_LEAVE,	/* multicast fast leave    */
e3ad84
 	IFLA_BRPORT_LEARNING,	/* mac learning */
e3ad84
 	IFLA_BRPORT_UNICAST_FLOOD, /* flood unicast traffic */
e3ad84
+	IFLA_BRPORT_PROXYARP,	/* proxy ARP */
e3ad84
+	IFLA_BRPORT_LEARNING_SYNC, /* mac learning sync from device */
e3ad84
+	IFLA_BRPORT_PROXYARP_WIFI, /* proxy ARP for Wi-Fi */
e3ad84
 	__IFLA_BRPORT_MAX
e3ad84
 };
e3ad84
 #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
e3ad84
@@ -291,6 +311,10 @@ enum {
e3ad84
 	IFLA_MACVLAN_UNSPEC,
e3ad84
 	IFLA_MACVLAN_MODE,
e3ad84
 	IFLA_MACVLAN_FLAGS,
e3ad84
+	IFLA_MACVLAN_MACADDR_MODE,
e3ad84
+	IFLA_MACVLAN_MACADDR,
e3ad84
+	IFLA_MACVLAN_MACADDR_DATA,
e3ad84
+	IFLA_MACVLAN_MACADDR_COUNT,
e3ad84
 	__IFLA_MACVLAN_MAX,
e3ad84
 };
e3ad84
 
e3ad84
@@ -301,10 +325,33 @@ enum macvlan_mode {
e3ad84
 	MACVLAN_MODE_VEPA    = 2, /* talk to other ports through ext bridge */
e3ad84
 	MACVLAN_MODE_BRIDGE  = 4, /* talk to bridge ports directly */
e3ad84
 	MACVLAN_MODE_PASSTHRU = 8,/* take over the underlying device */
e3ad84
+	MACVLAN_MODE_SOURCE  = 16,/* use source MAC address list to assign */
e3ad84
+};
e3ad84
+
e3ad84
+enum macvlan_macaddr_mode {
e3ad84
+	MACVLAN_MACADDR_ADD,
e3ad84
+	MACVLAN_MACADDR_DEL,
e3ad84
+	MACVLAN_MACADDR_FLUSH,
e3ad84
+	MACVLAN_MACADDR_SET,
e3ad84
 };
e3ad84
 
e3ad84
 #define MACVLAN_FLAG_NOPROMISC	1
e3ad84
 
e3ad84
+/* IPVLAN section */
e3ad84
+enum {
e3ad84
+	IFLA_IPVLAN_UNSPEC,
e3ad84
+	IFLA_IPVLAN_MODE,
e3ad84
+	__IFLA_IPVLAN_MAX
e3ad84
+};
e3ad84
+
e3ad84
+#define IFLA_IPVLAN_MAX (__IFLA_IPVLAN_MAX - 1)
e3ad84
+
e3ad84
+enum ipvlan_mode {
e3ad84
+	IPVLAN_MODE_L2 = 0,
e3ad84
+	IPVLAN_MODE_L3,
e3ad84
+	IPVLAN_MODE_MAX
e3ad84
+};
e3ad84
+
e3ad84
 /* VXLAN section */
e3ad84
 enum {
e3ad84
 	IFLA_VXLAN_UNSPEC,
e3ad84
@@ -328,6 +375,10 @@ enum {
e3ad84
 	IFLA_VXLAN_UDP_CSUM,
e3ad84
 	IFLA_VXLAN_UDP_ZERO_CSUM6_TX,
e3ad84
 	IFLA_VXLAN_UDP_ZERO_CSUM6_RX,
e3ad84
+	IFLA_VXLAN_REMCSUM_TX,
e3ad84
+	IFLA_VXLAN_REMCSUM_RX,
e3ad84
+	IFLA_VXLAN_GBP,
e3ad84
+	IFLA_VXLAN_REMCSUM_NOPARTIAL,
e3ad84
 	__IFLA_VXLAN_MAX
e3ad84
 };
e3ad84
 #define IFLA_VXLAN_MAX	(__IFLA_VXLAN_MAX - 1)
e3ad84
@@ -412,6 +463,9 @@ enum {
e3ad84
 	IFLA_VF_SPOOFCHK,	/* Spoof Checking on/off switch */
e3ad84
 	IFLA_VF_LINK_STATE,	/* link state enable/disable/auto switch */
e3ad84
 	IFLA_VF_RATE,		/* Min and Max TX Bandwidth Allocation */
e3ad84
+	IFLA_VF_RSS_QUERY_EN,	/* RSS Redirection Table and Hash Key query
e3ad84
+				 * on/off switch
e3ad84
+				 */
e3ad84
 	__IFLA_VF_MAX,
e3ad84
 };
e3ad84
 
e3ad84
@@ -456,6 +510,11 @@ struct ifla_vf_link_state {
e3ad84
 	__u32 link_state;
e3ad84
 };
e3ad84
 
e3ad84
+struct ifla_vf_rss_query_en {
e3ad84
+	__u32 vf;
e3ad84
+	__u32 setting;
e3ad84
+};
e3ad84
+
e3ad84
 /* VF ports management section
e3ad84
  *
e3ad84
  *	Nested layout of set/get msg is:
e3ad84
@@ -561,4 +620,4 @@ enum {
e3ad84
 
e3ad84
 #define IFLA_HSR_MAX (__IFLA_HSR_MAX - 1)
e3ad84
 
e3ad84
-#endif /* _UAPI_LINUX_IF_LINK_H */
e3ad84
+#endif /* _LINUX_IF_LINK_H */
e3ad84
-- 
e3ad84
2.4.3
e3ad84
e3ad84
e3ad84
From f348f1be682ea7be2d6953162d618c0b8f69e2ab Mon Sep 17 00:00:00 2001
e3ad84
From: Thomas Haller <thaller@redhat.com>
e3ad84
Date: Fri, 14 Aug 2015 17:32:38 +0200
e3ad84
Subject: [PATCH 3/4] route/link: add support for IFLA_LINK_NETNSID
e3ad84
e3ad84
Signed-off-by: Thomas Haller <thaller@redhat.com>
e3ad84
(cherry picked from commit 66aab65595fb20bf166936fcfa4c8568b58f7f68)
e3ad84
---
e3ad84
 include/netlink-private/types.h |  3 ++-
e3ad84
 include/netlink/route/link.h    | 14 ++++++++++++
e3ad84
 lib/route/link.c                | 49 ++++++++++++++++++++++++++++++++++++++++-
e3ad84
 3 files changed, 64 insertions(+), 2 deletions(-)
e3ad84
e3ad84
diff --git a/include/netlink-private/types.h b/include/netlink-private/types.h
e3ad84
index 70b95c1..598e79e 100644
e3ad84
--- a/include/netlink-private/types.h
e3ad84
+++ b/include/netlink-private/types.h
e3ad84
@@ -157,8 +157,9 @@ struct rtnl_link
e3ad84
 	uint32_t			l_index;
e3ad84
 	uint32_t			l_flags;
e3ad84
 	uint32_t			l_change;
e3ad84
-	uint32_t 			l_mtu;
e3ad84
+	uint32_t			l_mtu;
e3ad84
 	uint32_t			l_link;
e3ad84
+	uint32_t                        l_link_netnsid;
e3ad84
 	uint32_t			l_txqlen;
e3ad84
 	uint32_t			l_weight;
e3ad84
 	uint32_t			l_master;
e3ad84
diff --git a/include/netlink/route/link.h b/include/netlink/route/link.h
e3ad84
index 2d061be..ca37f66 100644
e3ad84
--- a/include/netlink/route/link.h
e3ad84
+++ b/include/netlink/route/link.h
e3ad84
@@ -201,6 +201,20 @@ extern uint8_t	rtnl_link_get_operstate(struct rtnl_link *);
e3ad84
 extern void	rtnl_link_set_linkmode(struct rtnl_link *, uint8_t);
e3ad84
 extern uint8_t	rtnl_link_get_linkmode(struct rtnl_link *);
e3ad84
 
e3ad84
+#ifdef NL_RHEL7_ENABLE_LINK_NETNSID
e3ad84
+/* The API for IFLA_LINK_NETNSID was backported from upstream to
e3ad84
+ * RHEL-7 (https://bugzilla.redhat.com/show_bug.cgi?id=1255050).
e3ad84
+ * Using backported API can cause problems when upgrading
e3ad84
+ * or downgrading the libnl package or when the user chooses to
e3ad84
+ * compile libnl from upstream source.
e3ad84
+ *
e3ad84
+ * Only use it if you understand the consequences and are willing
e3ad84
+ * to cope with them.
e3ad84
+ * */
e3ad84
+int             rtnl_link_set_link_netnsid(struct rtnl_link *link, uint32_t link_netnsid);
e3ad84
+int             rtnl_link_get_link_netnsid(const struct rtnl_link *link, uint32_t *out_link_netnsid);
e3ad84
+#endif
e3ad84
+
e3ad84
 extern const char *	rtnl_link_get_ifalias(struct rtnl_link *);
e3ad84
 extern void		rtnl_link_set_ifalias(struct rtnl_link *, const char *);
e3ad84
 
e3ad84
diff --git a/lib/route/link.c b/lib/route/link.c
e3ad84
index 49a8b65..d914fd5 100644
e3ad84
--- a/lib/route/link.c
e3ad84
+++ b/lib/route/link.c
e3ad84
@@ -57,6 +57,7 @@
e3ad84
 #define LINK_ATTR_CARRIER	(1 << 25)
e3ad84
 #define LINK_ATTR_PROTINFO	(1 << 26)
e3ad84
 #define LINK_ATTR_AF_SPEC	(1 << 27)
e3ad84
+#define LINK_ATTR_LINK_NETNSID  (1 << 31)
e3ad84
 
e3ad84
 static struct nl_cache_ops rtnl_link_ops;
e3ad84
 static struct nl_object_ops link_obj_ops;
e3ad84
@@ -443,6 +444,11 @@ static int link_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
e3ad84
 		link->ce_mask |= LINK_ATTR_LINK;
e3ad84
 	}
e3ad84
 
e3ad84
+	if (tb[IFLA_LINK_NETNSID]) {
e3ad84
+		link->l_link_netnsid = nla_get_u32(tb[IFLA_LINK_NETNSID]);
e3ad84
+		link->ce_mask |= LINK_ATTR_LINK_NETNSID;
e3ad84
+	}
e3ad84
+
e3ad84
 	if (tb[IFLA_WEIGHT]) {
e3ad84
 		link->l_weight = nla_get_u32(tb[IFLA_WEIGHT]);
e3ad84
 		link->ce_mask |= LINK_ATTR_WEIGHT;
e3ad84
@@ -627,7 +633,8 @@ static void link_dump_line(struct nl_object *obj, struct nl_dump_params *p)
e3ad84
 		nl_dump(p, "<%s> ", buf);
e3ad84
 
e3ad84
 	if (link->ce_mask & LINK_ATTR_LINK) {
e3ad84
-		if (cache) {
e3ad84
+		if (   cache
e3ad84
+		    && !(link->ce_mask & LINK_ATTR_LINK_NETNSID)) {
e3ad84
 			struct rtnl_link *ll = rtnl_link_get(cache, link->l_link);
e3ad84
 			nl_dump(p, "slave-of %s ", ll ? ll->l_name : "NONE");
e3ad84
 			if (ll)
e3ad84
@@ -635,6 +642,8 @@ static void link_dump_line(struct nl_object *obj, struct nl_dump_params *p)
e3ad84
 		} else
e3ad84
 			nl_dump(p, "slave-of %d ", link->l_link);
e3ad84
 	}
e3ad84
+	if (link->ce_mask & LINK_ATTR_LINK_NETNSID)
e3ad84
+		nl_dump(p, "link-netnsid %u ", link->l_link_netnsid);
e3ad84
 
e3ad84
 	if (link->ce_mask & LINK_ATTR_GROUP)
e3ad84
 		nl_dump(p, "group %u ", link->l_group);
e3ad84
@@ -858,6 +867,7 @@ static int link_compare(struct nl_object *_a, struct nl_object *_b,
e3ad84
 	diff |= LINK_DIFF(IFINDEX,	a->l_index != b->l_index);
e3ad84
 	diff |= LINK_DIFF(MTU,		a->l_mtu != b->l_mtu);
e3ad84
 	diff |= LINK_DIFF(LINK,		a->l_link != b->l_link);
e3ad84
+	diff |= LINK_DIFF(LINK_NETNSID, a->l_link_netnsid != b->l_link_netnsid);
e3ad84
 	diff |= LINK_DIFF(TXQLEN,	a->l_txqlen != b->l_txqlen);
e3ad84
 	diff |= LINK_DIFF(WEIGHT,	a->l_weight != b->l_weight);
e3ad84
 	diff |= LINK_DIFF(MASTER,	a->l_master != b->l_master);
e3ad84
@@ -1238,6 +1248,9 @@ static int build_link_msg(int cmd, struct ifinfomsg *hdr,
e3ad84
 	if (link->ce_mask & LINK_ATTR_LINK)
e3ad84
 		NLA_PUT_U32(msg, IFLA_LINK, link->l_link);
e3ad84
 
e3ad84
+	if (link->ce_mask & LINK_ATTR_LINK_NETNSID)
e3ad84
+		NLA_PUT_U32(msg, IFLA_LINK_NETNSID, link->l_link_netnsid);
e3ad84
+
e3ad84
 	if (link->ce_mask & LINK_ATTR_MASTER)
e3ad84
 		NLA_PUT_U32(msg, IFLA_MASTER, link->l_master);
e3ad84
 
e3ad84
@@ -1894,6 +1907,40 @@ int rtnl_link_get_link(struct rtnl_link *link)
e3ad84
 }
e3ad84
 
e3ad84
 /**
e3ad84
+ * Set the netnsid of the link
e3ad84
+ * @arg link            Link object
e3ad84
+ * @link_netnsid        the netnsid to set
e3ad84
+ *
e3ad84
+ * Sets the IFLA_LINK_NETNSID attribute of the link
e3ad84
+ * @returns 0 on success
e3ad84
+ */
e3ad84
+int rtnl_link_set_link_netnsid(struct rtnl_link *link, uint32_t link_netnsid)
e3ad84
+{
e3ad84
+	link->l_link_netnsid = link_netnsid;
e3ad84
+	link->ce_mask |= LINK_ATTR_LINK_NETNSID;
e3ad84
+	return 0;
e3ad84
+}
e3ad84
+
e3ad84
+/**
e3ad84
+ * Get the netnsid of the link
e3ad84
+ * @arg link            Link object
e3ad84
+ * @out_link_netnsid    the netnsid
e3ad84
+ *
e3ad84
+ * Gets the IFLA_LINK_NETNSID attribute of the link
e3ad84
+ * or returns an error if the value is unset.
e3ad84
+ *
e3ad84
+ * @returns 0 on success
e3ad84
+ */
e3ad84
+int rtnl_link_get_link_netnsid(const struct rtnl_link *link, uint32_t *out_link_netnsid)
e3ad84
+{
e3ad84
+	if (!(link->ce_mask & LINK_ATTR_LINK_NETNSID))
e3ad84
+		return -NLE_INVAL;
e3ad84
+
e3ad84
+	*out_link_netnsid = link->l_link_netnsid;
e3ad84
+	return 0;
e3ad84
+}
e3ad84
+
e3ad84
+/**
e3ad84
  * Set master link of link object
e3ad84
  * @arg link		Link object
e3ad84
  * @arg ifindex		Interface index of master link
e3ad84
-- 
e3ad84
2.4.3
e3ad84
e3ad84
e3ad84
From 7b4336d26a83d5de10bbaf67804400995848a51c Mon Sep 17 00:00:00 2001
e3ad84
From: Thomas Haller <thaller@redhat.com>
e3ad84
Date: Fri, 14 Aug 2015 17:32:36 +0200
e3ad84
Subject: [PATCH 4/4] route/link: make link_netnsid argument (signed) int32_t
e3ad84
e3ad84
Fixes: 66aab65595fb20bf166936fcfa4c8568b58f7f68
e3ad84
e3ad84
Signed-off-by: Thomas Haller <thaller@redhat.com>
e3ad84
(cherry picked from commit 2fc97e66e7f509e89f36aa601939c314bdfe6c08)
e3ad84
e3ad84
[thaller@redhat.com: while backporting, the patch was modified and
e3ad84
partially merged with commit 7bb956501ccd58ed3bbffc59de996f056e178683.
e3ad84
Instead of backporting new API for s32 attributes, it was defined locally]
e3ad84
---
e3ad84
 include/netlink-private/types.h |  2 +-
e3ad84
 include/netlink/route/link.h    |  4 ++--
e3ad84
 lib/route/link.c                | 32 +++++++++++++++++++++++++++-----
e3ad84
 3 files changed, 30 insertions(+), 8 deletions(-)
e3ad84
e3ad84
diff --git a/include/netlink-private/types.h b/include/netlink-private/types.h
e3ad84
index 598e79e..0550e8a 100644
e3ad84
--- a/include/netlink-private/types.h
e3ad84
+++ b/include/netlink-private/types.h
e3ad84
@@ -159,7 +159,7 @@ struct rtnl_link
e3ad84
 	uint32_t			l_change;
e3ad84
 	uint32_t			l_mtu;
e3ad84
 	uint32_t			l_link;
e3ad84
-	uint32_t                        l_link_netnsid;
e3ad84
+	int32_t                         l_link_netnsid;
e3ad84
 	uint32_t			l_txqlen;
e3ad84
 	uint32_t			l_weight;
e3ad84
 	uint32_t			l_master;
e3ad84
diff --git a/include/netlink/route/link.h b/include/netlink/route/link.h
e3ad84
index ca37f66..e1e6e20 100644
e3ad84
--- a/include/netlink/route/link.h
e3ad84
+++ b/include/netlink/route/link.h
e3ad84
@@ -211,8 +211,8 @@ extern uint8_t	rtnl_link_get_linkmode(struct rtnl_link *);
e3ad84
  * Only use it if you understand the consequences and are willing
e3ad84
  * to cope with them.
e3ad84
  * */
e3ad84
-int             rtnl_link_set_link_netnsid(struct rtnl_link *link, uint32_t link_netnsid);
e3ad84
-int             rtnl_link_get_link_netnsid(const struct rtnl_link *link, uint32_t *out_link_netnsid);
e3ad84
+int             rtnl_link_set_link_netnsid(struct rtnl_link *link, int32_t link_netnsid);
e3ad84
+int             rtnl_link_get_link_netnsid(const struct rtnl_link *link, int32_t *out_link_netnsid);
e3ad84
 #endif
e3ad84
 
e3ad84
 extern const char *	rtnl_link_get_ifalias(struct rtnl_link *);
e3ad84
diff --git a/lib/route/link.c b/lib/route/link.c
e3ad84
index d914fd5..fc88959 100644
e3ad84
--- a/lib/route/link.c
e3ad84
+++ b/lib/route/link.c
e3ad84
@@ -59,6 +59,28 @@
e3ad84
 #define LINK_ATTR_AF_SPEC	(1 << 27)
e3ad84
 #define LINK_ATTR_LINK_NETNSID  (1 << 31)
e3ad84
 
e3ad84
+/***********************************************************************/
e3ad84
+
e3ad84
+/* upstream added new utility function. While backporting,
e3ad84
+ * they were needed, but we don't want to intoduce new
e3ad84
+ * API. Instead, define them locall.y */
e3ad84
+
e3ad84
+#define NLA_PUT_S32(msg, attrtype, value) \
e3ad84
+	NLA_PUT_TYPE(msg, int32_t, attrtype, value)
e3ad84
+
e3ad84
+/**
e3ad84
+ * Return payload of 32 bit integer attribute.
e3ad84
+ * @arg nla             32 bit integer attribute.
e3ad84
+ *
e3ad84
+ * @return Payload as 32 bit integer.
e3ad84
+ */
e3ad84
+static int32_t nla_get_s32(const struct nlattr *nla)
e3ad84
+{
e3ad84
+	return *(const int32_t *) nla_data(nla);
e3ad84
+}
e3ad84
+
e3ad84
+/***********************************************************************/
e3ad84
+
e3ad84
 static struct nl_cache_ops rtnl_link_ops;
e3ad84
 static struct nl_object_ops link_obj_ops;
e3ad84
 /** @endcond */
e3ad84
@@ -445,7 +467,7 @@ static int link_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
e3ad84
 	}
e3ad84
 
e3ad84
 	if (tb[IFLA_LINK_NETNSID]) {
e3ad84
-		link->l_link_netnsid = nla_get_u32(tb[IFLA_LINK_NETNSID]);
e3ad84
+		link->l_link_netnsid = nla_get_s32(tb[IFLA_LINK_NETNSID]);
e3ad84
 		link->ce_mask |= LINK_ATTR_LINK_NETNSID;
e3ad84
 	}
e3ad84
 
e3ad84
@@ -643,7 +665,7 @@ static void link_dump_line(struct nl_object *obj, struct nl_dump_params *p)
e3ad84
 			nl_dump(p, "slave-of %d ", link->l_link);
e3ad84
 	}
e3ad84
 	if (link->ce_mask & LINK_ATTR_LINK_NETNSID)
e3ad84
-		nl_dump(p, "link-netnsid %u ", link->l_link_netnsid);
e3ad84
+		nl_dump(p, "link-netnsid %d ", link->l_link_netnsid);
e3ad84
 
e3ad84
 	if (link->ce_mask & LINK_ATTR_GROUP)
e3ad84
 		nl_dump(p, "group %u ", link->l_group);
e3ad84
@@ -1249,7 +1271,7 @@ static int build_link_msg(int cmd, struct ifinfomsg *hdr,
e3ad84
 		NLA_PUT_U32(msg, IFLA_LINK, link->l_link);
e3ad84
 
e3ad84
 	if (link->ce_mask & LINK_ATTR_LINK_NETNSID)
e3ad84
-		NLA_PUT_U32(msg, IFLA_LINK_NETNSID, link->l_link_netnsid);
e3ad84
+		NLA_PUT_S32(msg, IFLA_LINK_NETNSID, link->l_link_netnsid);
e3ad84
 
e3ad84
 	if (link->ce_mask & LINK_ATTR_MASTER)
e3ad84
 		NLA_PUT_U32(msg, IFLA_MASTER, link->l_master);
e3ad84
@@ -1914,7 +1936,7 @@ int rtnl_link_get_link(struct rtnl_link *link)
e3ad84
  * Sets the IFLA_LINK_NETNSID attribute of the link
e3ad84
  * @returns 0 on success
e3ad84
  */
e3ad84
-int rtnl_link_set_link_netnsid(struct rtnl_link *link, uint32_t link_netnsid)
e3ad84
+int rtnl_link_set_link_netnsid(struct rtnl_link *link, int32_t link_netnsid)
e3ad84
 {
e3ad84
 	link->l_link_netnsid = link_netnsid;
e3ad84
 	link->ce_mask |= LINK_ATTR_LINK_NETNSID;
e3ad84
@@ -1931,7 +1953,7 @@ int rtnl_link_set_link_netnsid(struct rtnl_link *link, uint32_t link_netnsid)
e3ad84
  *
e3ad84
  * @returns 0 on success
e3ad84
  */
e3ad84
-int rtnl_link_get_link_netnsid(const struct rtnl_link *link, uint32_t *out_link_netnsid)
e3ad84
+int rtnl_link_get_link_netnsid(const struct rtnl_link *link, int32_t *out_link_netnsid)
e3ad84
 {
e3ad84
 	if (!(link->ce_mask & LINK_ATTR_LINK_NETNSID))
e3ad84
 		return -NLE_INVAL;
e3ad84
-- 
e3ad84
2.4.3
e3ad84