]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: neighbor: Always add neighbors with replace
authorWilliam A. Kennington III <william@wkennington.com>
Tue, 27 Apr 2021 08:25:58 +0000 (01:25 -0700)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 27 Apr 2021 15:06:20 +0000 (00:06 +0900)
We were duplicating setting flags for the message and a combination of
NLM_F_APPEND and NLM_F_CREATE which does not make sense. We should have
been using NLM_F_REPLACE and NLM_F_CREATE since the kernel can
dynamically create neighbors prior to us adding an entry. Otherwise, we
can end up with cases where the message will time out after ~25s even
though the neighbor still gets added. This delays the rest of the setup
of the interface even though the error is ultimately ignored.

src/libsystemd/sd-netlink/rtnl-message.c
src/network/networkd-neighbor.c

index d14fa1a5cb75664a03da2bd23db2c2dd16dd2622..ead19672587baf704cee1480a90e46288c2515c4 100644 (file)
@@ -447,7 +447,7 @@ int sd_rtnl_message_new_neigh(sd_netlink *rtnl, sd_netlink_message **ret, uint16
                 return r;
 
         if (nlmsg_type == RTM_NEWNEIGH)
-                (*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_APPEND;
+                (*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_REPLACE;
 
         ndm = NLMSG_DATA((*ret)->hdr);
 
index f54a2f9c99f458744c9da432abb87b384b142e03..ef09665a85451fa101cb1d393563b1ce1afd8389 100644 (file)
@@ -258,10 +258,6 @@ static int neighbor_configure(Neighbor *neighbor, Link *link) {
         if (r < 0)
                 return log_link_error_errno(link, r, "Could not set state: %m");
 
-        r = sd_netlink_message_set_flags(req, NLM_F_REQUEST | NLM_F_ACK | NLM_F_CREATE | NLM_F_REPLACE);
-        if (r < 0)
-                return log_link_error_errno(link, r, "Could not set flags: %m");
-
         r = sd_netlink_message_append_data(req, NDA_LLADDR, &neighbor->lladdr, neighbor->lladdr_size);
         if (r < 0)
                 return log_link_error_errno(link, r, "Could not append NDA_LLADDR attribute: %m");