Skip to content

Commit

Permalink
fix ipv6 prefix-ranges.
Browse files Browse the repository at this point in the history
  • Loading branch information
snar committed Aug 14, 2018
1 parent d879f21 commit f199f1a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -4,6 +4,7 @@ untagged yet (2018-08-10)
Reported by Pier Carlo Chiodi.
- initial support for Huawei format (prefix-lists and as-path filters)
New flag -U. Requested by Alexander Wagberg.
- fix ipv6 prefix-ranges. Reported by Jay Ford.

0.1.35-rc2 (2017-06-14)
- OpenBSD need <sys/select.h>. Reported by Denis Fondras.
Expand Down
6 changes: 5 additions & 1 deletion bgpq_expander.c
Expand Up @@ -305,7 +305,11 @@ int
bgpq_expanded_v6prefix(char* prefix, struct bgpq_expander* ex,
struct bgpq_request* req)
{
bgpq_expander_add_prefix(ex,prefix);
char* d = strchr(prefix, '^');
if (!d)
bgpq_expander_add_prefix(ex,prefix);
else
bgpq_expander_add_prefix_range(ex,prefix);
return 1;
};

Expand Down
13 changes: 11 additions & 2 deletions sx_prefix.c
Expand Up @@ -242,10 +242,19 @@ sx_prefix_range_parse(struct sx_radix_tree* tree, int af, int maxlen,
text, min, p.masklen);
return 0;
};
SX_DEBUG(debug_expander, "parsed prefix-range %s as %lu-%lu\n",
text, min, max);
if (af == AF_INET && max > 32) {
sx_report(SX_ERROR, "Invalid prefix-range %s: max %lu > 32\n",
text, max);
return 0;
} else if (af == AF_INET6 && max > 128) {
sx_report(SX_ERROR, "Invalid ipv6 prefix-range %s: max %lu > 128\n",
text, max);
return 0;
};
if (max > maxlen)
max = maxlen;
SX_DEBUG(debug_expander, "parsed prefix-range %s as %lu-%lu (maxlen: %u)\n",
text, min, max, maxlen);
sx_radix_tree_insert_specifics(tree, p, min, max);
return 1;
};
Expand Down

0 comments on commit f199f1a

Please sign in to comment.