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
This commit is contained in:
parent
734e9fb8a9
commit
0705a1c565
1 changed files with 12 additions and 5 deletions
|
@ -187,17 +187,24 @@ pxlen4:
|
||||||
net_ip4_: IP4 pxlen4
|
net_ip4_: IP4 pxlen4
|
||||||
{
|
{
|
||||||
net_fill_ip4(&($$), $1, $2);
|
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_ip6_: IP6 '/' NUM
|
||||||
{
|
{
|
||||||
net_fill_ip6(&($$), $1, $3);
|
|
||||||
if ($3 < 0 || $3 > IP6_MAX_PREFIX_LENGTH)
|
if ($3 < 0 || $3 > IP6_MAX_PREFIX_LENGTH)
|
||||||
cf_error("Invalid prefix length %d", $3);
|
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_
|
net_vpn4_: VPN_RD net_ip4_
|
||||||
|
|
Loading…
Reference in a new issue