[patch libnl] add support for IFA_FLAGS nl attribute

Jiri Pirko jiri at resnulli.us
Sun Dec 8 06:26:24 EST 2013


Signed-off-by: Jiri Pirko <jiri at resnulli.us>
---
 include/linux/if_addr.h         | 1 +
 include/netlink-private/types.h | 2 +-
 lib/route/addr.c                | 4 +++-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/linux/if_addr.h b/include/linux/if_addr.h
index c355522..7ef47c1 100644
--- a/include/linux/if_addr.h
+++ b/include/linux/if_addr.h
@@ -28,6 +28,7 @@ enum {
 	IFA_ANYCAST,
 	IFA_CACHEINFO,
 	IFA_MULTICAST,
+	IFA_FLAGS,
 	__IFA_MAX,
 };
 
diff --git a/include/netlink-private/types.h b/include/netlink-private/types.h
index 59e8402..6750be7 100644
--- a/include/netlink-private/types.h
+++ b/include/netlink-private/types.h
@@ -244,8 +244,8 @@ struct rtnl_addr
 
 	uint8_t		a_family;
 	uint8_t		a_prefixlen;
-	uint8_t		a_flags;
 	uint8_t		a_scope;
+	uint32_t	a_flags;
 	uint32_t	a_ifindex;
 
 	struct nl_addr *a_peer;
diff --git a/lib/route/addr.c b/lib/route/addr.c
index 1ec298c..21f415d 100644
--- a/lib/route/addr.c
+++ b/lib/route/addr.c
@@ -216,8 +216,9 @@ static int addr_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
 	ifa = nlmsg_data(nlh);
 	addr->a_family = family = ifa->ifa_family;
 	addr->a_prefixlen = ifa->ifa_prefixlen;
-	addr->a_flags = ifa->ifa_flags;
 	addr->a_scope = ifa->ifa_scope;
+	addr->a_flags = tb[IFA_FLAGS] ? nla_get_u32(tb[IFA_FLAGS]) :
+					ifa->ifa_flags;
 	addr->a_ifindex = ifa->ifa_index;
 
 	addr->ce_mask = (ADDR_ATTR_FAMILY | ADDR_ATTR_PREFIXLEN |
@@ -597,6 +598,7 @@ static int build_addr_msg(struct rtnl_addr *tmpl, int cmd, int flags,
 		NLA_PUT(msg, IFA_CACHEINFO, sizeof(ca), &ca);
 	}
 
+	NLA_PUT_U32(msg, IFA_FLAGS, tmpl->a_flags);
 
 	*result = msg;
 	return 0;
-- 
1.8.3.1




More information about the libnl mailing list