diff options
author | Pavel Tvrdik <pawel.tvrdik@gmail.com> | 2016-06-30 15:04:49 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2017-05-23 15:59:27 +0200 |
commit | 0705a1c5658c2682c915007f466f55d2a8f7ec14 (patch) | |
tree | 7584d519e21d29782db496f81b971ba0e427f4f6 | |
parent | 734e9fb8a933898cd3396786c06728bce6a754e5 (diff) |
Add a hint for an invalid IP prefix
bird> eval 200.210.220.0/16
Invalid IPv4 prefix 200.210.220.0/16, maybe you wanted 200.210.0.0/16
bird> eval 1000:2000::/8
Invalid IPv6 prefix 1000:2000::/8, maybe you wanted 1000::/8
-rw-r--r-- | conf/confbase.Y | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/conf/confbase.Y b/conf/confbase.Y index 47ee07ce..e7fd1677 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -187,17 +187,24 @@ pxlen4: net_ip4_: IP4 pxlen4 { net_fill_ip4(&($$), $1, $2); - if (!net_validate_ip4((net_addr_ip4 *) &($$))) - cf_error("Invalid IPv4 prefix"); + + net_addr_ip4 *n = (void *) &($$); + if (!net_validate_ip4(n)) + cf_error("Invalid IPv4 prefix %I4/%d, maybe you wanted %I4/%d", + n->prefix, n->pxlen, ip4_and(n->prefix, ip4_mkmask(n->pxlen)), n->pxlen); }; net_ip6_: IP6 '/' NUM { - net_fill_ip6(&($$), $1, $3); if ($3 < 0 || $3 > IP6_MAX_PREFIX_LENGTH) cf_error("Invalid prefix length %d", $3); - if (!net_validate_ip6((net_addr_ip6 *) &($$))) - cf_error("Invalid IPv6 prefix"); + + net_fill_ip6(&($$), $1, $3); + + net_addr_ip6 *n = (void *) &($$); + if (!net_validate_ip6(n)) + cf_error("Invalid IPv6 prefix %I6/%d, maybe you wanted %I6/%d", + n->prefix, n->pxlen, ip6_and(n->prefix, ip6_mkmask(n->pxlen)), n->pxlen); }; net_vpn4_: VPN_RD net_ip4_ |