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>
static void
handle_hotplug_msg(char *data, int size)
{
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;
char *cur, *end, *sep;
struct device *dev;
int skip;
+ bool add, move = false;
if (!strncmp(data, "add@", 4))
add = true;
else if (!strncmp(data, "remove@", 7))
add = 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;
+ }
subsystem = sep + 1;
if (strcmp(subsystem, "net") != 0)
return;
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
+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)
found:
dev = device_find(interface);
if (!dev)