blob: 243b2a9d7751954179ff7e8d9e0d6902c9174f32 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From 974dc36a87274d7bae13e7dddd3364fecf5b3e7c Mon Sep 17 00:00:00 2001
2From: Helmut Schaa <helmut.schaa@googlemail.com>
3Date: Wed, 8 Jan 2014 13:48:49 +0100
4Subject: [PATCH] netdev-linux: Let interface flag survive internal port setup
5
6Due to a race condition when bringing up an internal port on Linux
7some interface flags (e.g. IFF_MULTICAST) are falsely reset. This
8happens because netlink events may be processed after the according
9netdev has been brought up (which sets interface flags).
10
11Fix this by reading the interface flags just before updating them
12if they have not been updated by from the kernel yet.
13
14Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
15---
16 lib/netdev-linux.c | 8 +++++++-
17 1 file changed, 7 insertions(+), 1 deletion(-)
18
19--- a/lib/netdev-linux.c
20+++ b/lib/netdev-linux.c
21@@ -3571,7 +3571,13 @@ update_flags(struct netdev_linux *netdev
22 unsigned int old_flags, new_flags;
23 int error = 0;
24
25- old_flags = netdev->ifi_flags;
26+ if (!(netdev->cache_valid & VALID_DRVINFO)) {
27+ /* Most likely the debvice flags are not in sync yet, fetch them now */
28+ get_flags(&netdev->up, &old_flags);
29+ } else {
30+ old_flags = netdev->ifi_flags;
31+ }
32+
33 *old_flagsp = iff_to_nd_flags(old_flags);
34 new_flags = (old_flags & ~nd_to_iff_flags(off)) | nd_to_iff_flags(on);
35 if (new_flags != old_flags) {