Message ID | 1465456362-58140-5-git-send-email-jpettit@ovn.org |
---|---|
State | Accepted |
Headers | show |
On Thu, Jun 9, 2016 at 12:12 AM, Justin Pettit <jpettit@ovn.org> wrote: > A zero prefix length is used to match any IP address, which is useful > for defining default routes. > > Signed-off-by: Justin Pettit <jpettit@ovn.org> > --- > lib/packets.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/lib/packets.c b/lib/packets.c > index 6a55d6f..ecb5339 100644 > --- a/lib/packets.c > +++ b/lib/packets.c > @@ -442,9 +442,9 @@ ip_parse_masked_len(const char *s, int *n, ovs_be32 > *ip, > /* OK. */ > } else if (ovs_scan_len(s, n, IP_SCAN_FMT"/%d", > IP_SCAN_ARGS(ip), &prefix)) { > - if (prefix <= 0 || prefix > 32) { > - return xasprintf("%s: network prefix bits not between 0 and " > - "32", s); > + if (prefix < 0 || prefix > 32) { > + return xasprintf("%s: IPv4 network prefix bits not between 0 > and " > + "31, inclusive", s); > Are we are talking number of bits, not bit indices ? + return xasprintf("%s: IPv4 network prefix bits not between 0 and " + "32, inclusive", s); > } > *mask = be32_prefix_mask(prefix); > } else if (ovs_scan_len(s, n, IP_SCAN_FMT, IP_SCAN_ARGS(ip))) { > @@ -533,9 +533,9 @@ ipv6_parse_masked_len(const char *s, int *n, struct > in6_addr *ip, > if (ovs_scan_len(s, n, " "IPV6_SCAN_FMT, ipv6_s) > && ipv6_parse(ipv6_s, ip)) { > if (ovs_scan_len(s, n, "/%d", &prefix)) { > - if (prefix <= 0 || prefix > 128) { > + if (prefix < 0 || prefix > 128) { > return xasprintf("%s: IPv6 network prefix bits not > between 0 " > - "and 128", s); > + "and 127, inclusive", s); > Are we are talking number of bits, not bit indices ? + "and 128, inclusive", s); > } > *mask = ipv6_create_mask(prefix); > } else if (ovs_scan_len(s, n, "/"IPV6_SCAN_FMT, ipv6_s)) { > -- > 1.9.1 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev >
> On Jun 9, 2016, at 9:25 AM, Darrell Ball <dlu998@gmail.com> wrote: > > > > On Thu, Jun 9, 2016 at 12:12 AM, Justin Pettit <jpettit@ovn.org> wrote: > A zero prefix length is used to match any IP address, which is useful > for defining default routes. > > Signed-off-by: Justin Pettit <jpettit@ovn.org> > --- > lib/packets.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/lib/packets.c b/lib/packets.c > index 6a55d6f..ecb5339 100644 > --- a/lib/packets.c > +++ b/lib/packets.c > @@ -442,9 +442,9 @@ ip_parse_masked_len(const char *s, int *n, ovs_be32 *ip, > /* OK. */ > } else if (ovs_scan_len(s, n, IP_SCAN_FMT"/%d", > IP_SCAN_ARGS(ip), &prefix)) { > - if (prefix <= 0 || prefix > 32) { > - return xasprintf("%s: network prefix bits not between 0 and " > - "32", s); > + if (prefix < 0 || prefix > 32) { > + return xasprintf("%s: IPv4 network prefix bits not between 0 and " > + "31, inclusive", s); > > > Are we are talking number of bits, not bit indices ? I'm trying specify the width of a CIDR block. Do you have a suggestion for a better way to phrase the error message? --Justin
On Thu, Jun 9, 2016 at 9:38 AM, Justin Pettit <jpettit@ovn.org> wrote: > > > On Jun 9, 2016, at 9:25 AM, Darrell Ball <dlu998@gmail.com> wrote: > > > > > > > > On Thu, Jun 9, 2016 at 12:12 AM, Justin Pettit <jpettit@ovn.org> wrote: > > A zero prefix length is used to match any IP address, which is useful > > for defining default routes. > > > > Signed-off-by: Justin Pettit <jpettit@ovn.org> > > --- > > lib/packets.c | 10 +++++----- > > 1 file changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/lib/packets.c b/lib/packets.c > > index 6a55d6f..ecb5339 100644 > > --- a/lib/packets.c > > +++ b/lib/packets.c > > @@ -442,9 +442,9 @@ ip_parse_masked_len(const char *s, int *n, ovs_be32 > *ip, > > /* OK. */ > > } else if (ovs_scan_len(s, n, IP_SCAN_FMT"/%d", > > IP_SCAN_ARGS(ip), &prefix)) { > > - if (prefix <= 0 || prefix > 32) { > > - return xasprintf("%s: network prefix bits not between 0 and > " > > - "32", s); > > + if (prefix < 0 || prefix > 32) { > > + return xasprintf("%s: IPv4 network prefix bits not between > 0 and " > > + "31, inclusive", s); > > > > > > Are we are talking number of bits, not bit indices ? > > I'm trying specify the width of a CIDR block. Do you have a suggestion > for a better way to phrase the error message? > I edited the error msgs, per below, in the previous response with an upper range change; that was my suggestion. + return xasprintf("%s: IPv4 network prefix bits not between 0 and " + "32, inclusive", s); + "and 128, inclusive", s); for v4, 0 to 32 is valid; i.e. /0 to /32; => not (between 0 and 32, inclusive) for v6, 0 to 128 is valid: i.e. /0 to /128; => not (between 0 and 128, inclusive) > > --Justin > > >
On Thu, Jun 9, 2016 at 3:12 AM, Justin Pettit <jpettit@ovn.org> wrote: > A zero prefix length is used to match any IP address, which is useful > for defining default routes. > > Signed-off-by: Justin Pettit <jpettit@ovn.org> > Acked-by: Flavio Fernandes <flavio@flaviof.com> > --- > lib/packets.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/lib/packets.c b/lib/packets.c > index 6a55d6f..ecb5339 100644 > --- a/lib/packets.c > +++ b/lib/packets.c > @@ -442,9 +442,9 @@ ip_parse_masked_len(const char *s, int *n, ovs_be32 > *ip, > /* OK. */ > } else if (ovs_scan_len(s, n, IP_SCAN_FMT"/%d", > IP_SCAN_ARGS(ip), &prefix)) { > - if (prefix <= 0 || prefix > 32) { > - return xasprintf("%s: network prefix bits not between 0 and " > - "32", s); > + if (prefix < 0 || prefix > 32) { > + return xasprintf("%s: IPv4 network prefix bits not between 0 > and " > + "31, inclusive", s); > } > *mask = be32_prefix_mask(prefix); > } else if (ovs_scan_len(s, n, IP_SCAN_FMT, IP_SCAN_ARGS(ip))) { > @@ -533,9 +533,9 @@ ipv6_parse_masked_len(const char *s, int *n, struct > in6_addr *ip, > if (ovs_scan_len(s, n, " "IPV6_SCAN_FMT, ipv6_s) > && ipv6_parse(ipv6_s, ip)) { > if (ovs_scan_len(s, n, "/%d", &prefix)) { > - if (prefix <= 0 || prefix > 128) { > + if (prefix < 0 || prefix > 128) { > return xasprintf("%s: IPv6 network prefix bits not > between 0 " > - "and 128", s); > + "and 127, inclusive", s); > } > *mask = ipv6_create_mask(prefix); > } else if (ovs_scan_len(s, n, "/"IPV6_SCAN_FMT, ipv6_s)) { > -- > 1.9.1 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev >
On Thu, Jun 09, 2016 at 12:12:38AM -0700, Justin Pettit wrote: > A zero prefix length is used to match any IP address, which is useful > for defining default routes. > > Signed-off-by: Justin Pettit <jpettit@ovn.org> With Darrell's comments, Acked-by: Ben Pfaff <blp@ovn.org>
> On Jun 9, 2016, at 9:57 AM, Darrell Ball <dlu998@gmail.com> wrote: > > I edited the error msgs, per below, in the previous response with an upper range change; that was my suggestion. > > + return xasprintf("%s: IPv4 network prefix bits not between 0 and " > + "32, inclusive", s); > > + "and 128, inclusive", s); > > for v4, 0 to 32 is valid; i.e. /0 to /32; => not (between 0 and 32, inclusive) > for v6, 0 to 128 is valid: i.e. /0 to /128; => not (between 0 and 128, inclusive) Thanks for pointing that out. I updated the error message and will push it soon. --Justin
diff --git a/lib/packets.c b/lib/packets.c index 6a55d6f..ecb5339 100644 --- a/lib/packets.c +++ b/lib/packets.c @@ -442,9 +442,9 @@ ip_parse_masked_len(const char *s, int *n, ovs_be32 *ip, /* OK. */ } else if (ovs_scan_len(s, n, IP_SCAN_FMT"/%d", IP_SCAN_ARGS(ip), &prefix)) { - if (prefix <= 0 || prefix > 32) { - return xasprintf("%s: network prefix bits not between 0 and " - "32", s); + if (prefix < 0 || prefix > 32) { + return xasprintf("%s: IPv4 network prefix bits not between 0 and " + "31, inclusive", s); } *mask = be32_prefix_mask(prefix); } else if (ovs_scan_len(s, n, IP_SCAN_FMT, IP_SCAN_ARGS(ip))) { @@ -533,9 +533,9 @@ ipv6_parse_masked_len(const char *s, int *n, struct in6_addr *ip, if (ovs_scan_len(s, n, " "IPV6_SCAN_FMT, ipv6_s) && ipv6_parse(ipv6_s, ip)) { if (ovs_scan_len(s, n, "/%d", &prefix)) { - if (prefix <= 0 || prefix > 128) { + if (prefix < 0 || prefix > 128) { return xasprintf("%s: IPv6 network prefix bits not between 0 " - "and 128", s); + "and 127, inclusive", s); } *mask = ipv6_create_mask(prefix); } else if (ovs_scan_len(s, n, "/"IPV6_SCAN_FMT, ipv6_s)) {
A zero prefix length is used to match any IP address, which is useful for defining default routes. Signed-off-by: Justin Pettit <jpettit@ovn.org> --- lib/packets.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)