valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0095-networkd-Begin-with-serial-number-1-for-netlink-requ.patch

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