interface: fix interface memory corruption
authorFelix Fietkau <nbd@nbd.name>
Tue, 21 Nov 2023 05:45:09 +0000 (06:45 +0100)
committerFelix Fietkau <nbd@nbd.name>
Tue, 21 Nov 2023 05:48:33 +0000 (06:48 +0100)
- set vlist keep_old=true, because the iface_update_cb expects it
- update ifindex on reload

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

index e98eddeb2467352a3c35c0fed68edbf499699893..5b1591c3704b775b13585453514ad1276266d3bc 100644 (file)
@@ -464,6 +464,7 @@ iface_update_cb(struct vlist_tree *tree, struct vlist_node *node_new,
                        cache_cleanup(if_old);
                free(if_old->addrs.v4);
                if_old->addrs = if_new->addrs;
+               if_old->ifindex = if_new->ifindex;
                free(if_new);
                return;
        }
@@ -669,4 +670,4 @@ struct interface *interface_get(const char *name, enum umdns_socket_type type)
        return iface;
 }
 
-VLIST_TREE(interfaces, avl_strcmp, iface_update_cb, false, false);
+VLIST_TREE(interfaces, avl_strcmp, iface_update_cb, true, false);