From 34ccb7210f1238f89229c117dc3d28cea7ae00bb Mon Sep 17 00:00:00 2001 From: matben2 Date: Thu, 9 Jul 2015 17:40:18 +1200 Subject: [PATCH] link: set ifi_change in link message The ifi_change field can be set with the mask of the flags that need to be changed as part of the link message to the kernel. This means only the specific flags that have been changed will be modified in the kernel, rather than the entire flags entry. [thaller@redhat.com: add capability to indicate the change in behavior] https://github.com/thom311/libnl/pull/86 --- include/netlink/utils.h | 8 ++++++++ lib/route/link.c | 1 + lib/utils.c | 9 +++++++++ 3 files changed, 18 insertions(+) diff --git a/include/netlink/utils.h b/include/netlink/utils.h index 4e5adcf..74b167b 100644 --- a/include/netlink/utils.h +++ b/include/netlink/utils.h @@ -143,6 +143,14 @@ enum { NL_CAPABILITY_NL_RECV_FAIL_TRUNC_NO_PEEK = 8, #define NL_CAPABILITY_NL_RECV_FAIL_TRUNC_NO_PEEK NL_CAPABILITY_NL_RECV_FAIL_TRUNC_NO_PEEK + /** + * rtnl_link_build_change_request() and rtnl_link_change() 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 in changes. + */ + NL_CAPABILITY_LINK_BUILD_CHANGE_REQUEST_SET_CHANGE = 9, +#define NL_CAPABILITY_LINK_BUILD_CHANGE_REQUEST_SET_CHANGE NL_CAPABILITY_LINK_BUILD_CHANGE_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 d66a798..35946bd 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -1465,6 +1465,7 @@ int rtnl_link_build_change_request(struct rtnl_link *orig, if (changes->ce_mask & LINK_ATTR_FLAGS) { ifi.ifi_flags = orig->l_flags & ~changes->l_flag_mask; ifi.ifi_flags |= changes->l_flags; + ifi.ifi_change = changes->l_flag_mask; } if (changes->l_family && changes->l_family != orig->l_family) { diff --git a/lib/utils.c b/lib/utils.c index 56eb556..bde176b 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -1151,6 +1151,15 @@ int nl_has_capability (int capability) NL_CAPABILITY_ROUTE_ADDR_COMPARE_CACHEINFO, NL_CAPABILITY_VERSION_3_2_26, NL_CAPABILITY_NL_RECV_FAIL_TRUNC_NO_PEEK), + _NL_SET(1, + NL_CAPABILITY_LINK_BUILD_CHANGE_REQUEST_SET_CHANGE, + 0, + 0, + 0, + 0, + 0, + 0, + 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 * libnl3.