From e25d1a2ea2c42c24e5c5d5a79d3ab25ee0d65318 Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Thu, 8 Mar 2012 13:24:17 +0000 Subject: [PATCH] Fix prefix-map build code logic. --- src/radv.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/radv.c b/src/radv.c index 5cade0f..c8e2f01 100644 --- a/src/radv.c +++ b/src/radv.c @@ -443,10 +443,13 @@ static int add_subnet(struct in6_addr *local, int prefix, is_same_net6(local, &context->end6, prefix)) { for (map = *subnets; map; map = map->next) - if (map->iface == 0) + if (map->iface == 0 || + (map->iface == if_index && is_same_net6(local, &map->subnet, prefix))) break; - else if (map->iface == if_index && is_same_net6(local, &map->subnet, prefix)) - continue; + + /* It's there already */ + if (map && map->iface != 0) + continue; if (!map && (map = whine_malloc(sizeof(struct subnet_map)))) { @@ -478,9 +481,10 @@ struct subnet_map *build_subnet_map(void) if ((context->flags & CONTEXT_RA_NAME)) break; + /* no ra-names, no need to go further. */ if (!context) return NULL; - + /* mark unused */ for (map = subnets; map; map = map->next) map->iface = 0;