From b31f8203d943346f60a92bace16098debe53205b Mon Sep 17 00:00:00 2001 From: Jiri Pirko Date: Sun, 8 Dec 2013 12:26:24 +0100 Subject: [PATCH 1/3] add support for IFA_FLAGS nl attribute (cherry picked from commit 42c41336000e1ff781a91c6ec397fd787aae3124) Signed-off-by: Jiri Pirko Signed-off-by: Thomas Haller --- include/linux/if_addr.h | 4 ++++ include/netlink-private/types.h | 2 +- lib/route/addr.c | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/linux/if_addr.h b/include/linux/if_addr.h index c355522..63da1cd 100644 --- a/include/linux/if_addr.h +++ b/include/linux/if_addr.h @@ -18,6 +18,9 @@ struct ifaddrmsg { * It makes no difference for normally configured broadcast interfaces, * but for point-to-point IFA_ADDRESS is DESTINATION address, * local address is supplied in IFA_LOCAL attribute. + * + * IFA_FLAGS is a u32 attribute that extends the u8 field ifa_flags. + * If present, the value from struct ifaddrmsg will be ignored. */ enum { IFA_UNSPEC, @@ -28,6 +31,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 60a3bce..72570c4 100644 --- a/include/netlink-private/types.h +++ b/include/netlink-private/types.h @@ -233,8 +233,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 95a9447..bcdc319 100644 --- a/lib/route/addr.c +++ b/lib/route/addr.c @@ -215,8 +215,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 | @@ -593,6 +594,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