system-linux: only overwrite dev->present state on check_state for simple devices
authorFelix Fietkau <nbd@nbd.name>
Fri, 13 Nov 2020 11:44:56 +0000 (12:44 +0100)
committerFelix Fietkau <nbd@nbd.name>
Fri, 13 Nov 2020 11:44:58 +0000 (12:44 +0100)
After settting config_pending for vlan devices, a check_state call from
device_init_pending was leading to the vlan device present state being
overwritten because the linux device didn't exist yet, even though the
vlan code had already indicated its present state based on the lower dev.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
system-linux.c

index 91888990440e953898bedaf8739303ee68072ed8..78455aeab38d4a97161b11ec910275b050568dea 100644 (file)
@@ -1743,7 +1743,8 @@ static int cb_if_check_valid(struct nl_msg *msg, void *arg)
        if (nh->nlmsg_type != RTM_NEWLINK)
                return NL_SKIP;
 
-       device_set_present(chk->dev, ifi->ifi_index > 0 ? true : false);
+       if (chk->dev->type == &simple_device_type)
+               device_set_present(chk->dev, ifi->ifi_index > 0 ? true : false);
        device_set_link(chk->dev, ifi->ifi_flags & IFF_LOWER_UP ? true : false);
 
        return NL_OK;
@@ -1760,7 +1761,8 @@ static int cb_if_check_error(struct sockaddr_nl *nla, struct nlmsgerr *err, void
 {
        struct if_check_data *chk = (struct if_check_data *)arg;
 
-       device_set_present(chk->dev, false);
+       if (chk->dev->type == &simple_device_type)
+               device_set_present(chk->dev, false);
        device_set_link(chk->dev, false);
        chk->pending = err->error;