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