summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Schiller <ms@dev.tdt.de>2017-09-28 10:32:28 +0200
committerHans Dedecker <dedeckeh@gmail.com>2017-10-06 13:54:58 +0200
commit3429bd8e7e34454d32615134bb5a5b2f6d832935 (patch)
treec585b9aebadc8e2fb7401c24848294b420cb1725
parent7d94ede3c38dd7b8e08c8a2fd8ae5ede71a2059b (diff)
system-linux: add support for hotplug event 'move'
If you rename a network interface, there is a move uevent invoked instead of remove/add. This patch adds support for this kind of event. Signed-off-by: Martin Schiller <ms@dev.tdt.de> Acked-by: Hans Dedecker <dedeckeh@gmail.com>
-rw-r--r--system-linux.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/system-linux.c b/system-linux.c
index 6d97a02..32d6ffc 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -543,16 +543,20 @@ out:
static void
handle_hotplug_msg(char *data, int size)
{
- const char *subsystem = NULL, *interface = NULL;
+ const char *subsystem = NULL, *interface = NULL, *interface_old = NULL;
char *cur, *end, *sep;
struct device *dev;
int skip;
- bool add;
+ bool add, move = false;
if (!strncmp(data, "add@", 4))
add = true;
else if (!strncmp(data, "remove@", 7))
add = false;
+ else if (!strncmp(data, "move@", 5)) {
+ add = true;
+ move = true;
+ }
else
return;
@@ -573,12 +577,32 @@ handle_hotplug_msg(char *data, int size)
subsystem = sep + 1;
if (strcmp(subsystem, "net") != 0)
return;
+ } else if (!strcmp(cur, "DEVPATH_OLD")) {
+ interface_old = strrchr(sep + 1, '/');
+ if (interface_old)
+ interface_old++;
}
- if (subsystem && interface)
+ }
+
+ if (subsystem && interface) {
+ if (move && interface_old)
+ goto move;
+ else
goto found;
}
+
return;
+move:
+ dev = device_find(interface_old);
+ if (!dev)
+ goto found;
+
+ if (dev->type != &simple_device_type)
+ goto found;
+
+ device_set_present(dev, false);
+
found:
dev = device_find(interface);
if (!dev)