diff --git a/radix/radix.c b/radix/radix.c index 3cbbb94..2f30653 100644 --- a/radix/radix.c +++ b/radix/radix.c @@ -85,7 +85,7 @@ int radix_insert(radix_holder_t t, ipv6_t key, int val, int mask) { } /* exact match */ - if (node->_rule_valid) { + if (node->_rule_valid && node->_ip_end_bit == mask) { printf("WARNING: conflicting rule %x:%x:%x:%x:%x:%x:%x:%x", key.s[0], key.s[1], key.s[2], key.s[3], key.s[4], key.s[5], key.s[6], key.s[7]); @@ -94,6 +94,15 @@ int radix_insert(radix_holder_t t, ipv6_t key, int val, int mask) { return 0; } + /* match with lower mask */ + if (node->_rule_valid) { + split_node(node, ibit); + + b = GET_BIT(node->_ip, ibit + 1); + next = b ? &node->_r : &node->_l; + *next = NULL; + } + node->_rule_valid = VALID_RULE; node->_rule = val; return 1;