From 6f9620721200d171d6a317573b3c1c00141f036b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 29 Nov 2016 22:41:46 +0100 Subject: [PATCH] link: set ifi_change flags for rtnl_link_build_add_request() For the add-request, we should set ifi_change flags together with the ifi_flags. A similar thing is done by rtnl_link_build_change_request() in commit 34ccb7210f1238f89229c117dc3d28cea7ae00bb. https://github.com/thom311/libnl/issues/111 --- include/netlink/utils.h | 8 ++++++++ lib/route/link.c | 1 + lib/utils.c | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/netlink/utils.h b/include/netlink/utils.h index 6501b0d..6f984e1 100644 --- a/include/netlink/utils.h +++ b/include/netlink/utils.h @@ -238,6 +238,14 @@ enum { NL_CAPABILITY_XFRM_SEC_CTX_LEN = 22, #define NL_CAPABILITY_XFRM_SEC_CTX_LEN NL_CAPABILITY_XFRM_SEC_CTX_LEN + /** + * rtnl_link_build_add_request() would set ifi.ifi_flags but leave ifi.ifi_change at zero. + * This was later fixed to set ifi.ifi_change to the flags that are actually + * set + */ + NL_CAPABILITY_LINK_BUILD_ADD_REQUEST_SET_CHANGE = 23, +#define NL_CAPABILITY_LINK_BUILD_ADD_REQUEST_SET_CHANGE NL_CAPABILITY_LINK_BUILD_ADD_REQUEST_SET_CHANGE + __NL_CAPABILITY_MAX, NL_CAPABILITY_MAX = (__NL_CAPABILITY_MAX - 1), #define NL_CAPABILITY_MAX NL_CAPABILITY_MAX diff --git a/lib/route/link.c b/lib/route/link.c index f9d9b93..6a6e0d3 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -1594,6 +1594,7 @@ int rtnl_link_build_add_request(struct rtnl_link *link, int flags, .ifi_family = link->l_family, .ifi_index = link->l_index, .ifi_flags = link->l_flags, + .ifi_change = link->l_flag_mask, }; return build_link_msg(RTM_NEWLINK, &ifi, link, flags, result); diff --git a/lib/utils.c b/lib/utils.c index 7d339ae..0427322 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -1191,7 +1191,7 @@ int nl_has_capability (int capability) NL_CAPABILITY_RTNL_ADDR_PEER_ID_FIX, NL_CAPABILITY_NL_ADDR_FILL_SOCKADDR, NL_CAPABILITY_XFRM_SEC_CTX_LEN, - 0, + NL_CAPABILITY_LINK_BUILD_ADD_REQUEST_SET_CHANGE, 0), /* IMPORTANT: these capability numbers are intended to be universal and stable * for libnl3. Don't allocate new numbers on your own that differ from upstream -- 2.40.0