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