Blame SOURCES/0050-libnetlink-Convert-GETADDR-dumps-to-use-rtnl_addrdum.patch

7e752c
From ae7cf70848d837d2ed85a21f6d7cbdf4c6ee6e4e Mon Sep 17 00:00:00 2001
7e752c
From: Andrea Claudi <aclaudi@redhat.com>
7e752c
Date: Mon, 10 Jun 2019 14:25:21 +0200
7e752c
Subject: [PATCH] libnetlink: Convert GETADDR dumps to use rtnl_addrdump_req
7e752c
7e752c
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1716772
7e752c
Upstream Status: iproute2.git commit 46917d0895fb0
7e752c
7e752c
commit 46917d0895fb0fb1df9b3c1575ccd467b4a1f860
7e752c
Author: David Ahern <dsahern@gmail.com>
7e752c
Date:   Sat Sep 29 08:41:46 2018 -0700
7e752c
7e752c
    libnetlink: Convert GETADDR dumps to use rtnl_addrdump_req
7e752c
7e752c
    Add rtnl_addrdump_req for address dumps using the proper ifaddrmsg
7e752c
    as the header. Convert existing RTM_GETADDR dumps to use it.
7e752c
7e752c
    Signed-off-by: David Ahern <dsahern@gmail.com>
7e752c
---
7e752c
 include/libnetlink.h |  4 ++++
7e752c
 ip/ipaddress.c       |  6 +++---
7e752c
 lib/libnetlink.c     | 16 ++++++++++++++++
7e752c
 3 files changed, 23 insertions(+), 3 deletions(-)
7e752c
7e752c
diff --git a/include/libnetlink.h b/include/libnetlink.h
7e752c
index 9d9249e634dc3..2d9f6190230c1 100644
7e752c
--- a/include/libnetlink.h
7e752c
+++ b/include/libnetlink.h
7e752c
@@ -46,6 +46,10 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned int subscriptions,
7e752c
 	__attribute__((warn_unused_result));
7e752c
 
7e752c
 void rtnl_close(struct rtnl_handle *rth);
7e752c
+
7e752c
+int rtnl_addrdump_req(struct rtnl_handle *rth, int family)
7e752c
+	__attribute__((warn_unused_result));
7e752c
+
7e752c
 int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type)
7e752c
 	__attribute__((warn_unused_result));
7e752c
 int rtnl_wilddump_req_filter(struct rtnl_handle *rth, int fam, int type,
7e752c
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
7e752c
index f315a815e945d..4714bce60db1b 100644
7e752c
--- a/ip/ipaddress.c
7e752c
+++ b/ip/ipaddress.c
7e752c
@@ -1672,7 +1672,7 @@ static int ipaddr_flush(void)
7e752c
 	filter.flushe = sizeof(flushb);
7e752c
 
7e752c
 	while ((max_flush_loops == 0) || (round < max_flush_loops)) {
7e752c
-		if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) {
7e752c
+		if (rtnl_addrdump_req(&rth, filter.family) < 0) {
7e752c
 			perror("Cannot send dump request");
7e752c
 			exit(1);
7e752c
 		}
7e752c
@@ -1764,7 +1764,7 @@ int ip_linkaddr_list(int family, req_filter_fn_t filter_fn,
7e752c
 	}
7e752c
 
7e752c
 	if (ainfo) {
7e752c
-		if (rtnl_wilddump_request(&rth, family, RTM_GETADDR) < 0) {
7e752c
+		if (rtnl_addrdump_req(&rth, family) < 0) {
7e752c
 			perror("Cannot send dump request");
7e752c
 			return 1;
7e752c
 		}
7e752c
@@ -1889,7 +1889,7 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
7e752c
 		if (ipadd_save_prep())
7e752c
 			exit(1);
7e752c
 
7e752c
-		if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETADDR) < 0) {
7e752c
+		if (rtnl_addrdump_req(&rth, preferred_family) < 0) {
7e752c
 			perror("Cannot send dump request");
7e752c
 			exit(1);
7e752c
 		}
7e752c
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
7e752c
index a9932d423126e..db625b9bd18ca 100644
7e752c
--- a/lib/libnetlink.c
7e752c
+++ b/lib/libnetlink.c
7e752c
@@ -199,6 +199,22 @@ int rtnl_open(struct rtnl_handle *rth, unsigned int subscriptions)
7e752c
 	return rtnl_open_byproto(rth, subscriptions, NETLINK_ROUTE);
7e752c
 }
7e752c
 
7e752c
+int rtnl_addrdump_req(struct rtnl_handle *rth, int family)
7e752c
+{
7e752c
+	struct {
7e752c
+		struct nlmsghdr nlh;
7e752c
+		struct ifaddrmsg ifm;
7e752c
+	} req = {
7e752c
+		.nlh.nlmsg_len = sizeof(req),
7e752c
+		.nlh.nlmsg_type = RTM_GETADDR,
7e752c
+		.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
7e752c
+		.nlh.nlmsg_seq = rth->dump = ++rth->seq,
7e752c
+		.ifm.ifa_family = family,
7e752c
+	};
7e752c
+
7e752c
+	return send(rth->fd, &req, sizeof(req), 0);
7e752c
+}
7e752c
+
7e752c
 int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
7e752c
 {
7e752c
 	return rtnl_wilddump_req_filter(rth, family, type, RTEXT_FILTER_VF);
7e752c
-- 
7e752c
2.20.1
7e752c