richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
923a60
From 0dd3b68d80bd32ecc5db65d634072390dad581aa Mon Sep 17 00:00:00 2001
923a60
From: Richard Maw <richard.maw@codethink.co.uk>
923a60
Date: Thu, 12 Mar 2015 18:14:58 +0000
923a60
Subject: [PATCH] networkd: Begin with serial number 1 for netlink requests
923a60
923a60
"Notifications are of informal nature and no reply is expected, therefore the
923a60
sequence number is typically set to 0."[1]
923a60
923a60
If networkd is started soon after recent netlink activity, then there
923a60
will be messages with sequence number 0 in the buffer.
923a60
923a60
The first thing networkd does is to request a dump of all the links. If
923a60
it uses sequence number 0 for this, then it may confuse the dump request's
923a60
response with that of a notification.
923a60
923a60
This will result in it failing to properly enumerate all the links,
923a60
but more importantly, when it comes to enumerate all the addresses, it
923a60
will still have the link dump in progress, so the address enumeration
923a60
will fail with -EBUSY.
923a60
923a60
[1]: http://www.infradead.org/~tgr/libnl/doc/core.html#core_msg_types
923a60
923a60
[tomegun: sequence -> serial]
923a60
923a60
(cherry picked from commit d422e52a3523ad0955bec4f9fbed46e234d28590)
923a60
---
923a60
 src/libsystemd/sd-rtnl/sd-rtnl.c | 5 +++++
923a60
 1 file changed, 5 insertions(+)
923a60
923a60
diff --git a/src/libsystemd/sd-rtnl/sd-rtnl.c b/src/libsystemd/sd-rtnl/sd-rtnl.c
923a60
index ae49c77e01..7cdcc5d96a 100644
923a60
--- a/src/libsystemd/sd-rtnl/sd-rtnl.c
923a60
+++ b/src/libsystemd/sd-rtnl/sd-rtnl.c
923a60
@@ -61,6 +61,11 @@ static int sd_rtnl_new(sd_rtnl **ret) {
923a60
                             sizeof(struct nlmsghdr), sizeof(uint8_t)))
923a60
                 return -ENOMEM;
923a60
 
923a60
+        /* Change notification responses have sequence 0, so we must
923a60
+         * start our request sequence numbers at 1, or we may confuse our
923a60
+         * responses with notifications from the kernel */
923a60
+        rtnl->serial = 1;
923a60
+
923a60
         *ret = rtnl;
923a60
         rtnl = NULL;
923a60