Browse Source

interface: fix interface memory corruption

- set vlist keep_old=true, because the iface_update_cb expects it
- update ifindex on reload

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau 5 months ago
parent
commit
9040335e10
1 changed files with 2 additions and 1 deletions
  1. 2 1
      interface.c

+ 2 - 1
interface.c

@@ -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);