summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2013-01-21 09:50:43 +0100
committerSteven Barth <steven@midlink.org>2013-01-21 10:18:30 +0100
commitf04430a371c2628193ced7dd1ff1a0f0dd01e70d (patch)
treea949ab3e62386d44c57d16359fae3df4ea9b29e0
parented984c7aea436999c38cc40c5ebaf98bd8294df4 (diff)
Fix segfaults in prefix handling
-rw-r--r--interface-ip.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/interface-ip.c b/interface-ip.c
index b5613b2..892631d 100644
--- a/interface-ip.c
+++ b/interface-ip.c
@@ -525,7 +525,7 @@ interface_ip_set_prefix_assignment(struct device_prefix *prefix,
struct device_prefix_assignment *assignment;
if (!length || length > 64) {
- assignment = vlist_find(prefix->assignments, &iface, assignment, node);
+ assignment = vlist_find(prefix->assignments, iface->name, assignment, node);
if (assignment)
interface_set_prefix_address(iface, false, assignment);
} else {
@@ -575,9 +575,11 @@ interface_update_prefix(struct vlist_tree *tree,
// Update all assignments
struct device_prefix_assignment *assignment;
struct vlist_tree *assignments = prefix_new->assignments;
- vlist_for_each_element(assignments, assignment, node)
+ vlist_for_each_element(assignments, assignment, node) {
+ assignment->prefix = prefix_new;
assignments->update(assignments,
&assignment->node, &assignment->node);
+ }
} else if (node_new) {
prefix_new->avail = 1ULL << (64 - prefix_new->length);
prefix_new->assignments = calloc(1, sizeof(*prefix_new->assignments));
@@ -590,8 +592,6 @@ interface_update_prefix(struct vlist_tree *tree,
interface_ip_set_prefix_assignment(prefix_new, iface,
iface->proto_ip.assignment_length);
- list_add(&prefix_new->head, &prefixes);
-
// Set null-route to avoid routing loops
system_add_route(NULL, &route);
}
@@ -608,6 +608,9 @@ interface_update_prefix(struct vlist_tree *tree,
}
free(prefix_old);
}
+
+ if (node_new)
+ list_add(&prefix_new->head, &prefixes);
}
void