[ovs-dev] [PATCH 4/8] packets: Parse IP address strings with a zero length prefix.

FlaviofOvsML ovs at flaviof.com
Thu Jun 9 17:14:44 UTC 2016


On Thu, Jun 9, 2016 at 3:12 AM, Justin Pettit <jpettit at 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 at ovn.org>
>


Acked-by: Flavio Fernandes <flavio at 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 at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>



More information about the dev mailing list