summary refs log tree commit diff
path: root/src/libnm-platform
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2022-10-18 11:56:48 +0200
committerMichael Biebl <biebl@debian.org>2022-10-18 11:56:48 +0200
commit9f101839d9e64df832e9e43c5181887369c46a7e (patch)
tree3e23589a9d4e9e7c32ce41b634ccf26af3f0d45e /src/libnm-platform
parentab0efddcdb48d800e2f938da54cfe3074640792e (diff)
New upstream version 1.40.2 upstream/1.40.2
Diffstat (limited to 'src/libnm-platform')
-rw-r--r--src/libnm-platform/nm-linux-platform.c81
-rw-r--r--src/libnm-platform/nm-netlink.c36
-rw-r--r--src/libnm-platform/nm-netlink.h6
-rw-r--r--src/libnm-platform/nm-platform.c14
-rw-r--r--src/libnm-platform/nm-platform.h3
-rw-r--r--src/libnm-platform/nmp-global-tracker.c20
-rw-r--r--src/libnm-platform/tests/test-nm-platform.c5
-rw-r--r--src/libnm-platform/wifi/nm-wifi-utils-nl80211.c2
-rw-r--r--src/libnm-platform/wpan/nm-wpan-utils.c2
9 files changed, 91 insertions, 78 deletions
diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c
index cd685fe2..eb7c671b 100644
--- a/src/libnm-platform/nm-linux-platform.c
+++ b/src/libnm-platform/nm-linux-platform.c
@@ -1589,11 +1589,8 @@ _parse_lnk_bond(const char *kind, struct nlattr *info_data)
 
     if (tb[IFLA_BOND_MODE])
         props->mode = nla_get_u8(tb[IFLA_BOND_MODE]);
-    if (tb[IFLA_BOND_PRIMARY]) {
-        props->primary = nla_get_u32(tb[IFLA_BOND_PRIMARY]);
-    } else if (tb[IFLA_BOND_ACTIVE_SLAVE]) {
-        props->primary = nla_get_u32(tb[IFLA_BOND_ACTIVE_SLAVE]);
-    }
+    if (tb[IFLA_BOND_PRIMARY])
+        props->primary = NM_CLAMP((int) nla_get_u32(tb[IFLA_BOND_PRIMARY]), 0, G_MAXINT);
     if (tb[IFLA_BOND_MIIMON]) {
         props->miimon     = nla_get_u32(tb[IFLA_BOND_MIIMON]);
         props->miimon_has = TRUE;
@@ -1631,12 +1628,8 @@ _parse_lnk_bond(const char *kind, struct nlattr *info_data)
     }
     if (tb[IFLA_BOND_ARP_VALIDATE])
         props->arp_validate = nla_get_u32(tb[IFLA_BOND_ARP_VALIDATE]);
-    if (tb[IFLA_BOND_ARP_ALL_TARGETS]) {
-        props->arp_all_targets     = nla_get_u32(tb[IFLA_BOND_ARP_ALL_TARGETS]);
-        props->arp_all_targets_has = TRUE;
-    } else {
-        props->arp_all_targets_has = FALSE;
-    }
+    if (tb[IFLA_BOND_ARP_ALL_TARGETS])
+        props->arp_all_targets = nla_get_u32(tb[IFLA_BOND_ARP_ALL_TARGETS]);
     if (tb[IFLA_BOND_PRIMARY_RESELECT])
         props->primary_reselect = nla_get_u8(tb[IFLA_BOND_PRIMARY_RESELECT]);
     if (tb[IFLA_BOND_FAIL_OVER_MAC])
@@ -2677,7 +2670,7 @@ _wireguard_read_info(NMPlatform     *platform /* used only as logging context */
           ifindex,
           wireguard_family_id);
 
-    msg = nlmsg_alloc();
+    msg = nlmsg_alloc(0);
 
     if (!genlmsg_put(msg,
                      NL_AUTO_PORT,
@@ -2886,7 +2879,7 @@ _wireguard_create_change_nlmsgs(NMPlatform                               *platfo
 
 again:
 
-    msg = nlmsg_alloc();
+    msg = nlmsg_alloc(0);
     if (!genlmsg_put(msg,
                      NL_AUTO_PORT,
                      NL_AUTO_SEQ,
@@ -4521,7 +4514,7 @@ _nl_msg_new_link_set_linkinfo(struct nl_msg *msg, NMLinkType link_type, gconstpo
             nla_nest_end(msg, targets);
         }
 
-        if (props->arp_all_targets_has)
+        if (props->arp_all_targets)
             NLA_PUT_U32(msg, IFLA_BOND_ARP_ALL_TARGETS, props->arp_all_targets);
         if (props->arp_interval)
             NLA_PUT_U32(msg, IFLA_BOND_ARP_INTERVAL, props->arp_interval);
@@ -4539,7 +4532,7 @@ _nl_msg_new_link_set_linkinfo(struct nl_msg *msg, NMLinkType link_type, gconstpo
             NLA_PUT_U32(msg, IFLA_BOND_PACKETS_PER_SLAVE, props->packets_per_port);
         if (props->peer_notif_delay_has)
             NLA_PUT_U32(msg, IFLA_BOND_PEER_NOTIF_DELAY, props->peer_notif_delay);
-        if (props->primary)
+        if (props->primary > 0)
             NLA_PUT_U32(msg, IFLA_BOND_PRIMARY, props->primary);
         if (props->resend_igmp_has)
             NLA_PUT_U32(msg, IFLA_BOND_RESEND_IGMP, props->resend_igmp);
@@ -4972,7 +4965,8 @@ _nl_msg_new_link_full(uint16_t    nlmsg_type,
                       const char *ifname,
                       guint8      family,
                       unsigned    flags_mask,
-                      unsigned    flags_set)
+                      unsigned    flags_set,
+                      size_t      len)
 {
     nm_auto_nlmsg struct nl_msg *msg = NULL;
     const struct ifinfomsg       ifi = {
@@ -4984,7 +4978,7 @@ _nl_msg_new_link_full(uint16_t    nlmsg_type,
 
     nm_assert(NM_IN_SET(nlmsg_type, RTM_DELLINK, RTM_NEWLINK, RTM_GETLINK, RTM_SETLINK));
 
-    msg = nlmsg_alloc_simple(nlmsg_type, nlmsg_flags);
+    msg = nlmsg_alloc_new(len ? nlmsg_total_size(NLMSG_HDRLEN + len) : 0, nlmsg_type, nlmsg_flags);
 
     if (nlmsg_append_struct(msg, &ifi) < 0)
         goto nla_put_failure;
@@ -5001,7 +4995,7 @@ nla_put_failure:
 static struct nl_msg *
 _nl_msg_new_link(uint16_t nlmsg_type, uint16_t nlmsg_flags, int ifindex, const char *ifname)
 {
-    return _nl_msg_new_link_full(nlmsg_type, nlmsg_flags, ifindex, ifname, AF_UNSPEC, 0, 0);
+    return _nl_msg_new_link_full(nlmsg_type, nlmsg_flags, ifindex, ifname, AF_UNSPEC, 0, 0, 0);
 }
 
 /* Copied and modified from libnl3's build_addr_msg(). */
@@ -5033,7 +5027,7 @@ _nl_msg_new_address(uint16_t      nlmsg_type,
     nm_assert(NM_IN_SET(family, AF_INET, AF_INET6));
     nm_assert(NM_IN_SET(nlmsg_type, RTM_NEWADDR, RTM_DELADDR));
 
-    msg = nlmsg_alloc_simple(nlmsg_type, nlmsg_flags);
+    msg = nlmsg_alloc_new(0, nlmsg_type, nlmsg_flags);
 
     addr_len = family == AF_INET ? sizeof(in_addr_t) : sizeof(struct in6_addr);
 
@@ -5140,7 +5134,7 @@ _nl_msg_new_route(uint16_t nlmsg_type, uint16_t nlmsg_flags, const NMPObject *ob
         NM_IN_SET(NMP_OBJECT_GET_TYPE(obj), NMP_OBJECT_TYPE_IP4_ROUTE, NMP_OBJECT_TYPE_IP6_ROUTE));
     nm_assert(NM_IN_SET(nlmsg_type, RTM_NEWROUTE, RTM_DELROUTE));
 
-    msg = nlmsg_alloc_simple(nlmsg_type, nlmsg_flags);
+    msg = nlmsg_alloc_new(0, nlmsg_type, nlmsg_flags);
 
     if (nlmsg_append_struct(msg, &rtmsg) < 0)
         goto nla_put_failure;
@@ -5232,7 +5226,7 @@ _nl_msg_new_routing_rule(uint16_t                     nlmsg_type,
     const guint8 addr_size           = nm_utils_addr_family_to_size(routing_rule->addr_family);
     guint32      table;
 
-    msg = nlmsg_alloc_simple(nlmsg_type, nlmsg_flags);
+    msg = nlmsg_alloc_new(0, nlmsg_type, nlmsg_flags);
 
     table = routing_rule->table;
 
@@ -5351,7 +5345,7 @@ _nl_msg_new_qdisc(uint16_t nlmsg_type, uint16_t nlmsg_flags, const NMPlatformQdi
                   .tcm_info    = qdisc->info,
     };
 
-    msg = nlmsg_alloc_simple(nlmsg_type, nlmsg_flags | NMP_NLM_FLAG_F_ECHO);
+    msg = nlmsg_alloc_new(0, nlmsg_type, nlmsg_flags | NMP_NLM_FLAG_F_ECHO);
 
     if (nlmsg_append_struct(msg, &tcm) < 0)
         goto nla_put_failure;
@@ -5439,7 +5433,7 @@ _nl_msg_new_tfilter(uint16_t nlmsg_type, uint16_t nlmsg_flags, const NMPlatformT
                   .tcm_info    = tfilter->info,
     };
 
-    msg = nlmsg_alloc_simple(nlmsg_type, nlmsg_flags | NMP_NLM_FLAG_F_ECHO);
+    msg = nlmsg_alloc_new(0, nlmsg_type, nlmsg_flags | NMP_NLM_FLAG_F_ECHO);
 
     if (nlmsg_append_struct(msg, &tcm) < 0)
         goto nla_put_failure;
@@ -7234,7 +7228,7 @@ _nl_msg_new_dump_rtnl(NMPObjectType obj_type, int preferred_addr_family)
     nm_assert(klass);
     nm_assert(klass->rtm_gettype > 0);
 
-    nlmsg = nlmsg_alloc_simple(klass->rtm_gettype, NLM_F_DUMP);
+    nlmsg = nlmsg_alloc_new(0, klass->rtm_gettype, NLM_F_DUMP);
 
     if (klass->addr_family != AF_UNSPEC) {
         /* if the class specifies a particular address family, then it is preferred. */
@@ -7279,7 +7273,7 @@ _nl_msg_new_dump_genl_families(void)
 {
     nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
 
-    nlmsg = nlmsg_alloc_size(nlmsg_total_size(GENL_HDRLEN));
+    nlmsg = nlmsg_alloc(nlmsg_total_size(GENL_HDRLEN));
 
     if (!genlmsg_put(nlmsg,
                      NL_AUTO_PORT,
@@ -8095,7 +8089,8 @@ link_change_flags(NMPlatform *platform, int ifindex, unsigned flags_mask, unsign
           nm_platform_link_flags2str(flags_set, s_flags, sizeof(s_flags)),
           nm_platform_link_flags2str(flags_mask, s_flags2, sizeof(s_flags2)));
 
-    nlmsg = _nl_msg_new_link_full(RTM_NEWLINK, 0, ifindex, NULL, AF_UNSPEC, flags_mask, flags_set);
+    nlmsg =
+        _nl_msg_new_link_full(RTM_NEWLINK, 0, ifindex, NULL, AF_UNSPEC, flags_mask, flags_set, 0);
     if (!nlmsg)
         return -NME_UNSPEC;
     return do_change_link(platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL);
@@ -8410,16 +8405,23 @@ link_set_sriov_vfs(NMPlatform *platform, int ifindex, const NMPlatformVF *const
 {
     nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
     struct nlattr               *list, *info, *vlan_list;
-    guint                        i;
+    guint                        i      = 0;
+    guint                        num    = 0;
+    size_t                       buflen = 0;
 
-    nlmsg = _nl_msg_new_link(RTM_NEWLINK, 0, ifindex, NULL);
+    while (vfs[num])
+        num++;
+
+    /* A single IFLA_VF_INFO shouldn't take more than 200 bytes. */
+    buflen = (num + 1) * 200;
+    nlmsg  = _nl_msg_new_link_full(RTM_NEWLINK, 0, ifindex, NULL, AF_UNSPEC, 0, 0, buflen);
     if (!nlmsg)
         g_return_val_if_reached(-NME_BUG);
 
     if (!(list = nla_nest_start(nlmsg, IFLA_VFINFO_LIST)))
         goto nla_put_failure;
 
-    for (i = 0; vfs[i]; i++) {
+    for (; vfs[i]; i++) {
         const NMPlatformVF *vf = vfs[i];
 
         if (!(info = nla_nest_start(nlmsg, IFLA_VF_INFO)))
@@ -8492,6 +8494,11 @@ link_set_sriov_vfs(NMPlatform *platform, int ifindex, const NMPlatformVF *const
 
     return (do_change_link(platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) >= 0);
 nla_put_failure:
+    _LOGE("error building SR-IOV VFs netlink message: used %u/%zu bytes for %u/%u VFs",
+          nlmsg_hdr(nlmsg)->nlmsg_len,
+          buflen,
+          i,
+          num);
     g_return_val_if_reached(FALSE);
 }
 
@@ -8506,8 +8513,14 @@ link_set_bridge_vlans(NMPlatform                        *platform,
     struct bridge_vlan_info      vinfo = {};
     guint                        i;
 
-    nlmsg =
-        _nl_msg_new_link_full(vlans ? RTM_SETLINK : RTM_DELLINK, 0, ifindex, NULL, AF_BRIDGE, 0, 0);
+    nlmsg = _nl_msg_new_link_full(vlans ? RTM_SETLINK : RTM_DELLINK,
+                                  0,
+                                  ifindex,
+                                  NULL,
+                                  AF_BRIDGE,
+                                  0,
+                                  0,
+                                  0);
     if (!nlmsg)
         g_return_val_if_reached(-NME_BUG);
 
@@ -9535,7 +9548,7 @@ tc_delete(NMPlatform *platform,
         log_tag = "do-delete-tc";
     }
 
-    msg = nlmsg_alloc_simple(nlmsg_type, NMP_NLM_FLAG_F_ECHO);
+    msg = nlmsg_alloc_new(0, nlmsg_type, NMP_NLM_FLAG_F_ECHO);
 
     if (nlmsg_append_struct(msg, &tcm) < 0)
         goto nla_put_failure;
@@ -10259,7 +10272,7 @@ mptcp_addr_update(NMPlatform *platform, NMOptionBool add, const NMPlatformMptcpA
           cmd_str,
           nm_platform_mptcp_addr_to_string(addr, sbuf, sizeof(sbuf)));
 
-    nlmsg = nlmsg_alloc_size(nlmsg_total_size(GENL_HDRLEN) + 200);
+    nlmsg = nlmsg_alloc(nlmsg_total_size(GENL_HDRLEN) + 200);
 
     if (!genlmsg_put(nlmsg,
                      NL_AUTO_PORT,
@@ -10350,7 +10363,7 @@ mptcp_addrs_dump(NMPlatform *platform)
         return NULL;
     }
 
-    nlmsg = nlmsg_alloc_size(nlmsg_total_size(GENL_HDRLEN));
+    nlmsg = nlmsg_alloc(nlmsg_total_size(GENL_HDRLEN));
 
     if (!genlmsg_put(nlmsg,
                      NL_AUTO_PORT,
diff --git a/src/libnm-platform/nm-netlink.c b/src/libnm-platform/nm-netlink.c
index 36841d56..e08eee5e 100644
--- a/src/libnm-platform/nm-netlink.c
+++ b/src/libnm-platform/nm-netlink.c
@@ -364,11 +364,22 @@ nla_reserve(struct nl_msg *msg, int attrtype, int attrlen)
 
 /*****************************************************************************/
 
+/**
+ * Allocate a new netlink message.
+ *
+ * Allocates a new netlink message without any further payload. If @len is zero,
+ * the maximum payload size is set to the size of one memory page.
+ *
+ * @return Newly allocated netlink message or NULL.
+ */
 struct nl_msg *
-nlmsg_alloc_size(size_t len)
+nlmsg_alloc(size_t len)
 {
     struct nl_msg *nm;
 
+    if (len == 0)
+        len = nm_utils_getpagesize();
+
     if (len < sizeof(struct nlmsghdr))
         len = sizeof(struct nlmsghdr);
     else if (len > UINT32_MAX)
@@ -384,38 +395,23 @@ nlmsg_alloc_size(size_t len)
     return nm;
 }
 
-/**
- * Allocate a new netlink message with the default maximum payload size.
- *
- * Allocates a new netlink message without any further payload. The
- * maximum payload size defaults to PAGESIZE or as otherwise specified
- * with nlmsg_set_default_size().
- *
- * @return Newly allocated netlink message or NULL.
- */
-struct nl_msg *
-nlmsg_alloc(void)
-{
-    return nlmsg_alloc_size(nm_utils_getpagesize());
-}
-
 struct nl_msg *
 nlmsg_alloc_convert(struct nlmsghdr *hdr)
 {
     struct nl_msg *nm;
 
-    nm = nlmsg_alloc_size(NLMSG_ALIGN(hdr->nlmsg_len));
+    nm = nlmsg_alloc(NLMSG_ALIGN(hdr->nlmsg_len));
     memcpy(nm->nm_nlh, hdr, hdr->nlmsg_len);
     return nm;
 }
 
 struct nl_msg *
-nlmsg_alloc_simple(uint16_t nlmsgtype, uint16_t flags)
+nlmsg_alloc_new(size_t size, uint16_t nlmsgtype, uint16_t flags)
 {
     struct nl_msg *nm;
     struct nlmsghdr *new;
 
-    nm               = nlmsg_alloc();
+    nm               = nlmsg_alloc(size);
     new              = nm->nm_nlh;
     new->nlmsg_type  = nlmsgtype;
     new->nlmsg_flags = flags;
@@ -928,7 +924,7 @@ genl_ctrl_resolve(struct nl_sock *sk, const char *name)
                              .valid_arg = &response_data,
     };
 
-    msg = nlmsg_alloc();
+    msg = nlmsg_alloc(0);
 
     if (!genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ, GENL_ID_CTRL, 0, 0, CTRL_CMD_GETFAMILY, 1))
         return -ENOMEM;
diff --git a/src/libnm-platform/nm-netlink.h b/src/libnm-platform/nm-netlink.h
index 44ed70af..634be2b4 100644
--- a/src/libnm-platform/nm-netlink.h
+++ b/src/libnm-platform/nm-netlink.h
@@ -393,13 +393,11 @@ nla_parse_nested(struct nlattr           *tb[],
 
 /*****************************************************************************/
 
-struct nl_msg *nlmsg_alloc(void);
-
-struct nl_msg *nlmsg_alloc_size(size_t max);
+struct nl_msg *nlmsg_alloc(size_t len);
 
 struct nl_msg *nlmsg_alloc_convert(struct nlmsghdr *hdr);
 
-struct nl_msg *nlmsg_alloc_simple(uint16_t nlmsgtype, uint16_t flags);
+struct nl_msg *nlmsg_alloc_new(size_t size, uint16_t nlmsgtype, uint16_t flags);
 
 void *nlmsg_reserve(struct nl_msg *n, uint32_t len, uint32_t pad);
 
diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c
index df177485..7d82083c 100644
--- a/src/libnm-platform/nm-platform.c
+++ b/src/libnm-platform/nm-platform.c
@@ -6082,7 +6082,6 @@ nm_platform_lnk_bond_to_string(const NMPlatformLnkBond *lnk, char *buf, gsize le
     char sbuf_updelay[30];
     char sbuf_downdelay[30];
     char sbuf_peer_notif_delay[60];
-    char sbuf_arp_all_targets[30];
     char sbuf_resend_igmp[30];
     char sbuf_lp_interval[30];
     char sbuf_tlb_dynamic_lb[30];
@@ -6096,7 +6095,7 @@ nm_platform_lnk_bond_to_string(const NMPlatformLnkBond *lnk, char *buf, gsize le
         &len,
         "bond"
         " mode %u"
-        " primary %u"
+        " primary %d"
         "%s" /* miimon */
         "%s" /* updelay */
         "%s" /* downdelay */
@@ -6106,7 +6105,7 @@ nm_platform_lnk_bond_to_string(const NMPlatformLnkBond *lnk, char *buf, gsize le
         "%s" /* lp_interval */
         " packets_per_port %u"
         "%s" /* peer_notif_delay */
-        "%s" /* arp_all_targets */
+        " arp_all_targets %u"
         " arp_validate %u"
         " ad_actor_sys_prio %u"
         " ad_user_port_key %u"
@@ -6156,12 +6155,7 @@ nm_platform_lnk_bond_to_string(const NMPlatformLnkBond *lnk, char *buf, gsize le
                              !lnk->peer_notif_delay_has ? "?" : "",
                              lnk->peer_notif_delay)
             : "",
-        lnk->arp_all_targets_has || lnk->arp_all_targets != 0
-            ? nm_sprintf_buf(sbuf_arp_all_targets,
-                             " arp_all_targets%s %u",
-                             !lnk->arp_all_targets_has ? "?" : "",
-                             lnk->arp_all_targets)
-            : "",
+        lnk->arp_all_targets,
         lnk->arp_validate,
         lnk->ad_actor_sys_prio,
         lnk->ad_user_port_key,
@@ -8043,7 +8037,6 @@ nm_platform_lnk_bond_hash_update(const NMPlatformLnkBond *obj, NMHashState *h)
                         obj->primary_reselect,
                         obj->xmit_hash_policy,
                         NM_HASH_COMBINE_BOOLS(guint16,
-                                              obj->arp_all_targets_has,
                                               obj->downdelay_has,
                                               obj->lp_interval_has,
                                               obj->miimon_has,
@@ -8089,7 +8082,6 @@ nm_platform_lnk_bond_cmp(const NMPlatformLnkBond *a, const NMPlatformLnkBond *b)
     NM_CMP_FIELD(a, b, mode);
     NM_CMP_FIELD(a, b, primary_reselect);
     NM_CMP_FIELD(a, b, xmit_hash_policy);
-    NM_CMP_FIELD_BOOL(a, b, arp_all_targets_has);
     NM_CMP_FIELD_BOOL(a, b, downdelay_has);
     NM_CMP_FIELD_BOOL(a, b, lp_interval_has);
     NM_CMP_FIELD_BOOL(a, b, miimon_has);
diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h
index 90ffbed0..7792bbf5 100644
--- a/src/libnm-platform/nm-platform.h
+++ b/src/libnm-platform/nm-platform.h
@@ -895,6 +895,7 @@ extern const NMPlatformLnkBridge nm_platform_lnk_bridge_default;
 #define NM_BOND_MAX_ARP_TARGETS 16
 
 typedef struct {
+    int         primary;
     in_addr_t   arp_ip_target[NM_BOND_MAX_ARP_TARGETS];
     guint32     arp_all_targets;
     guint32     arp_interval;
@@ -905,7 +906,6 @@ typedef struct {
     guint32     min_links;
     guint32     packets_per_port;
     guint32     peer_notif_delay;
-    guint32     primary;
     guint32     resend_igmp;
     guint32     updelay;
     guint16     ad_actor_sys_prio;
@@ -920,7 +920,6 @@ typedef struct {
     guint8      mode;
     guint8      primary_reselect;
     guint8      xmit_hash_policy;
-    bool        arp_all_targets_has : 1;
     bool        downdelay_has : 1;
     bool        lp_interval_has : 1;
     bool        miimon_has : 1;
diff --git a/src/libnm-platform/nmp-global-tracker.c b/src/libnm-platform/nmp-global-tracker.c
index ea4da284..12869cb2 100644
--- a/src/libnm-platform/nmp-global-tracker.c
+++ b/src/libnm-platform/nmp-global-tracker.c
@@ -198,7 +198,7 @@ _track_data_hash(gconstpointer data)
     _track_data_assert(track_data, FALSE);
 
     nm_hash_init(&h, 269297543u);
-    nmp_object_id_hash_update(track_data->obj, &h);
+    nmp_object_hash_update(track_data->obj, &h);
     nm_hash_update_val(&h, track_data->user_tag);
     return nm_hash_complete(&h);
 }
@@ -213,7 +213,7 @@ _track_data_equal(gconstpointer data_a, gconstpointer data_b)
     _track_data_assert(track_data_b, FALSE);
 
     return track_data_a->user_tag == track_data_b->user_tag
-           && nmp_object_id_equal(track_data_a->obj, track_data_b->obj);
+           && nmp_object_equal(track_data_a->obj, track_data_b->obj);
 }
 
 static void
@@ -253,6 +253,22 @@ _track_obj_data_get_best_data(TrackObjData *obj_data)
         td_best = track_data;
     }
 
+    if (!td_best)
+        return NULL;
+
+    /* Always copy the object from the best TrackData to the TrackObjData. It is
+     * a bit odd that this getter modifies TrackObjData. However, it gives the
+     * nice property that after calling _track_obj_data_get_best_data() you can
+     * use obj_data->obj (and get the same as td_best->obj).
+     *
+     * This is actually important, because the previous obj_data->obj will have
+     * the same ID, but it might have minor differences to td_best->obj.
+     *
+     * Note that at this point obj_data->obj also might be an object that is no longer
+     * tracked. Updating the reference will ensure that we don't have such old references
+     * around and update to use the most appropriate one. */
+    nmp_object_ref_set(&obj_data->obj, td_best->obj);
+
     return td_best;
 }
 
diff --git a/src/libnm-platform/tests/test-nm-platform.c b/src/libnm-platform/tests/test-nm-platform.c
index c351f014..cd54df92 100644
--- a/src/libnm-platform/tests/test-nm-platform.c
+++ b/src/libnm-platform/tests/test-nm-platform.c
@@ -27,10 +27,9 @@ test_use_symbols(void)
         (void (*)(void)) nlmsg_hdr,
         (void (*)(void)) nlmsg_reserve,
         (void (*)(void)) nla_reserve,
-        (void (*)(void)) nlmsg_alloc_size,
-        (void (*)(void)) nlmsg_alloc,
         (void (*)(void)) nlmsg_alloc_convert,
-        (void (*)(void)) nlmsg_alloc_simple,
+        (void (*)(void)) nlmsg_alloc_new,
+        (void (*)(void)) nlmsg_alloc,
         (void (*)(void)) nlmsg_free,
         (void (*)(void)) nlmsg_append,
         (void (*)(void)) nlmsg_parse,
diff --git a/src/libnm-platform/wifi/nm-wifi-utils-nl80211.c b/src/libnm-platform/wifi/nm-wifi-utils-nl80211.c
index 37edd928..c7ee0473 100644
--- a/src/libnm-platform/wifi/nm-wifi-utils-nl80211.c
+++ b/src/libnm-platform/wifi/nm-wifi-utils-nl80211.c
@@ -86,7 +86,7 @@ _nl80211_alloc_msg(guint16 genl_family_id, int ifindex, int phy, uint8_t cmd, ui
 {
     nm_auto_nlmsg struct nl_msg *msg = NULL;
 
-    msg = nlmsg_alloc();
+    msg = nlmsg_alloc(0);
     genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ, genl_family_id, 0, flags, cmd, 0);
     NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
     if (phy != -1)
diff --git a/src/libnm-platform/wpan/nm-wpan-utils.c b/src/libnm-platform/wpan/nm-wpan-utils.c
index 675efe5a..03c9581f 100644
--- a/src/libnm-platform/wpan/nm-wpan-utils.c
+++ b/src/libnm-platform/wpan/nm-wpan-utils.c
@@ -79,7 +79,7 @@ _nl802154_alloc_msg(guint16 genl_family_id, int ifindex, uint8_t cmd, uint16_t f
 {
     nm_auto_nlmsg struct nl_msg *msg = NULL;
 
-    msg = nlmsg_alloc();
+    msg = nlmsg_alloc(0);
     if (!genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ, genl_family_id, 0, flags, cmd, 0))
         goto nla_put_failure;
     NLA_PUT_U32(msg, NL802154_ATTR_IFINDEX, ifindex);