[PATCH/API-NEXT,3/3] helper/ip: add ipv4/subnet parsing

Message ID 004001d1e8b2$c341ff00$49c5fd00$@linaro.org
State New
Headers show

Commit Message

Forrest Shi July 28, 2016, 9:31 a.m.
Hi Mike,

 

Here is the  gcov of helper function. Please see the attachments.

 

Thanks,

Forrest

 

From: Mike Holmes [mailto:mike.holmes@linaro.org] 

Sent: Wednesday, July 20, 2016 20:01
To: forrest.shi <forrest.shi@linaro.org>
Cc: Bill Fischofer <bill.fischofer@linaro.org>; lng-odp <lng-odp@lists.linaro.org>
Subject: Re: [lng-odp] [PATCH/API-NEXT 3/3] helper/ip: add ipv4/subnet parsing

 

Did you look in the publishing directory?

It should all be in there, by default everything  in the build dir is cleaned up unless you do CLEANUP=0 and output like docs is copied to that publishing dir.

 

On 20 July 2016 at 03:24, forrest.shi <forrest.shi@linaro.org <mailto:forrest.shi@linaro.org> > wrote:

Hi Mike

 

I got the following with:   GIT_URL=~/git/odp GIT_BRANCH=forrest LCOV=1 ./build.sh

No html is generated in the publishing.

 

--
2.1.0.27.g96db324





 

-- 

Mike Holmes

Technical Manager - Linaro Networking Group

 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

"Work should be fun and collaborative, the rest follows"

 





 

-- 

Mike Holmes

Technical Manager - Linaro Networking Group

 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

"Work should be fun and collaborative, the rest follows"

Comments

Mike Holmes July 28, 2016, 1:10 p.m. | #1
I ran it, the tests cover everything now

On 28 July 2016 at 05:31, forrest.shi <forrest.shi@linaro.org> wrote:

> Hi Mike,

>

>

>

> Here is the  gcov of helper function. Please see the attachments.

>

>

>

> Thanks,

>

> Forrest

>

>

>

> *From:* Mike Holmes [mailto:mike.holmes@linaro.org]

> *Sent:* Wednesday, July 20, 2016 20:01

> *To:* forrest.shi <forrest.shi@linaro.org>

>

> *Cc:* Bill Fischofer <bill.fischofer@linaro.org>; lng-odp <

> lng-odp@lists.linaro.org>

> *Subject:* Re: [lng-odp] [PATCH/API-NEXT 3/3] helper/ip: add ipv4/subnet

> parsing

>

>

>

> Did you look in the publishing directory?

>

> It should all be in there, by default everything  in the build dir is

> cleaned up unless you do CLEANUP=0 and output like docs is copied to that

> publishing dir.

>

>

>

> On 20 July 2016 at 03:24, forrest.shi <forrest.shi@linaro.org> wrote:

>

> Hi Mike

>

>

>

> I got the following with:   GIT_URL=~/git/odp GIT_BRANCH=forrest LCOV=1

> ./build.sh

>

> No html is generated in the publishing.

>

>

>

> =======================================================================

>

>    OpenDataPlane 1.10.1.0.git71.ga942cb4: helper/test/test-suite.log

>

> =======================================================================

>

>

>

> # TOTAL: 9

>

> # PASS:  8

>

> # SKIP:  0

>

> # XFAIL: 0

>

> # FAIL:  1

>

> # XPASS: 0

>

> # ERROR: 0

>

>

>

> .. contents:: :depth: 2

>

>

>

> FAIL: cuckootable

>

> =================

>

>

>

> cuckootable.c:213:odph_cuckoo_table_create():cuckoo hash table put_remove

> already exists

>

> cuckoo hash table creation failed

>

> cuckoo hash table test fail!!

>

>

>

> Thanks,

>

> Forrest

>

>

>

> *From:* Mike Holmes [mailto:mike.holmes@linaro.org]

> *Sent:* Friday, July 15, 2016 20:26

> *To:* Forrest Shi <forrest.shi@linaro.org>

> *Cc:* Bill Fischofer <bill.fischofer@linaro.org>; lng-odp <

> lng-odp@lists.linaro.org>

> *Subject:* Re: [lng-odp] [PATCH/API-NEXT 3/3] helper/ip: add ipv4/subnet

> parsing

>

>

>

>

>

>

>

> On 8 July 2016 at 04:14, <forrest.shi@linaro.org> wrote:

>

> From: Xuelin Shi <forrest.shi@linaro.org>

>

> parse an ipv4/subnet string like "192.168.1.0/24" into 3 values:

> ipv4-addr, subnet bit width and subnet mask

>

> Signed-off-by: Xuelin Shi <forrest.shi@linaro.org>

> ---

>  helper/include/odp/helper/ip.h | 19 +++++++++++++++++++

>  helper/ip.c                    | 33 +++++++++++++++++++++++++++++++++

>  2 files changed, 52 insertions(+)

>

> diff --git a/helper/include/odp/helper/ip.h

> b/helper/include/odp/helper/ip.h

> index 4cfc00f..dd538c9 100644

> --- a/helper/include/odp/helper/ip.h

> +++ b/helper/include/odp/helper/ip.h

> @@ -233,6 +233,25 @@ typedef struct ODP_PACKED {

>  int odph_ipv4_addr_parse(uint32_t *ip_addr, const char *str);

>

>  /**

> + * Parse text string representing an IPv4 address or subnet

> + *

> + * String is of the format "XXX.XXX.XXX.XXX(/W)" where

> + * "XXX" is decimal value and "/W" is optional subnet length

> + *

> + * @param ip_net_str Pointer to IP address/subnet string to convert

> + * @param ip_addr    Pointer to return IPv4 address, host endianness

> + * @param depth      Pointer to subnet bit width

> + * @param subnet_mask Pointer to subnet mask

> + *

> + * @retval 0 on success of parsing both ip and subnet

> + * @retval 1 on success of parsing only ip

> + * @retval 2 on success of parsing only subnet

> + * @retval <0 on failure

> + */

> +int odph_ipv4_subnet_parse(const char *ip_net_str, uint32_t *ip_addr,

> +                          uint32_t *depth, uint32_t *subnet_mask);

>

>

>

> This new api is not tested by the validation suite

>

>

>

> To see this in LCOV use check-odp and point at your repo and branch

> setting LCOV

>

>

>

> GIT_URL=~/git/odp GIT_BRANCH=forrest LCOV=1 ./build.sh

> firefox

> publishing/forrest/linux-generic-helper-lcov-html/helper/ip.c.gcov.html

>

>

>

> +

> +/**

>   * @}

>   */

>  #ifdef __cplusplus

> diff --git a/helper/ip.c b/helper/ip.c

> index e211001..d2ca21e 100644

> --- a/helper/ip.c

> +++ b/helper/ip.c

> @@ -30,3 +30,36 @@ int odph_ipv4_addr_parse(uint32_t *ip_addr, const char

> *str)

>

>         return 0;

>  }

> +

> +int odph_ipv4_subnet_parse(const char *ip_net_str, uint32_t *ip_addr,

> +                          uint32_t *depth, uint32_t *subnet_mask)

> +{

> +       char *s;

> +       int converted;

> +       uint32_t qualifier = 32;

> +       char ip_valid = 0;

> +       char subnet_valid = 0;

> +

> +       s = strchr(ip_net_str, '/');

> +       if (s) {

> +               converted = sscanf(s, "/%u", &qualifier);

> +               if (converted == 1 && qualifier && qualifier <= 32) {

> +                       *depth = qualifier;

> +                       *subnet_mask = ((1 << qualifier) - 1) <<

> +                                       (32 - qualifier);

> +                       subnet_valid = 1;

> +               }

> +       }

> +

> +       if (!odph_ipv4_addr_parse(ip_addr, ip_net_str))

> +               ip_valid = 1;

> +

> +       if (ip_valid && subnet_valid)

> +               return 0;

> +       else if (ip_valid)

> +               return 1;

> +       else if (subnet_valid)

> +               return 2;

> +       else

> +               return -1;

> +}

> --

> 2.1.0.27.g96db324

>

>

>

>

>

> --

>

> Mike Holmes

>

> Technical Manager - Linaro Networking Group

>

> Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs

>

> "Work should be fun and collaborative, the rest follows"

>

>

>

>

>

>

>

> --

>

> Mike Holmes

>

> Technical Manager - Linaro Networking Group

>

> Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs

>

> "Work should be fun and collaborative, the rest follows"

>

>

>




-- 
Mike Holmes
Technical Manager - Linaro Networking Group
Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"

Patch

=======================================================================

   OpenDataPlane 1.10.1.0.git71.ga942cb4: helper/test/test-suite.log

=======================================================================

 

# TOTAL: 9

# PASS:  8

# SKIP:  0

# XFAIL: 0

# FAIL:  1

# XPASS: 0

# ERROR: 0

 

.. contents:: :depth: 2

 

FAIL: cuckootable

=================

 

cuckootable.c:213:odph_cuckoo_table_create():cuckoo hash table put_remove already exists

cuckoo hash table creation failed

cuckoo hash table test fail!!

 

Thanks,

Forrest

 

From: Mike Holmes [mailto:mike.holmes@linaro.org <mailto:mike.holmes@linaro.org> ] 
Sent: Friday, July 15, 2016 20:26
To: Forrest Shi <forrest.shi@linaro.org <mailto:forrest.shi@linaro.org> >
Cc: Bill Fischofer <bill.fischofer@linaro.org <mailto:bill.fischofer@linaro.org> >; lng-odp <lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org> >
Subject: Re: [lng-odp] [PATCH/API-NEXT 3/3] helper/ip: add ipv4/subnet parsing

 

 

 

On 8 July 2016 at 04:14, <forrest.shi@linaro.org <mailto:forrest.shi@linaro.org> > wrote:

From: Xuelin Shi <forrest.shi@linaro.org <mailto:forrest.shi@linaro.org> >

parse an ipv4/subnet string like "192.168.1.0/24 <http://192.168.1.0/24> " into 3 values:
ipv4-addr, subnet bit width and subnet mask

Signed-off-by: Xuelin Shi <forrest.shi@linaro.org <mailto:forrest.shi@linaro.org> >
---
 helper/include/odp/helper/ip.h | 19 +++++++++++++++++++
 helper/ip.c                    | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h
index 4cfc00f..dd538c9 100644
--- a/helper/include/odp/helper/ip.h
+++ b/helper/include/odp/helper/ip.h
@@ -233,6 +233,25 @@  typedef struct ODP_PACKED {
 int odph_ipv4_addr_parse(uint32_t *ip_addr, const char *str);

 /**
+ * Parse text string representing an IPv4 address or subnet
+ *
+ * String is of the format "XXX.XXX.XXX.XXX(/W)" where
+ * "XXX" is decimal value and "/W" is optional subnet length
+ *
+ * @param ip_net_str Pointer to IP address/subnet string to convert
+ * @param ip_addr    Pointer to return IPv4 address, host endianness
+ * @param depth      Pointer to subnet bit width
+ * @param subnet_mask Pointer to subnet mask
+ *
+ * @retval 0 on success of parsing both ip and subnet
+ * @retval 1 on success of parsing only ip
+ * @retval 2 on success of parsing only subnet
+ * @retval <0 on failure
+ */
+int odph_ipv4_subnet_parse(const char *ip_net_str, uint32_t *ip_addr,
+                          uint32_t *depth, uint32_t *subnet_mask);

 

This new api is not tested by the validation suite

 

To see this in LCOV use check-odp and point at your repo and branch setting LCOV

 

GIT_URL=~/git/odp GIT_BRANCH=forrest LCOV=1 ./build.sh
firefox publishing/forrest/linux-generic-helper-lcov-html/helper/ip.c.gcov.html

 

+
+/**
  * @}
  */
 #ifdef __cplusplus
diff --git a/helper/ip.c b/helper/ip.c
index e211001..d2ca21e 100644
--- a/helper/ip.c
+++ b/helper/ip.c
@@ -30,3 +30,36 @@  int odph_ipv4_addr_parse(uint32_t *ip_addr, const char *str)

        return 0;
 }
+
+int odph_ipv4_subnet_parse(const char *ip_net_str, uint32_t *ip_addr,
+                          uint32_t *depth, uint32_t *subnet_mask)
+{
+       char *s;
+       int converted;
+       uint32_t qualifier = 32;
+       char ip_valid = 0;
+       char subnet_valid = 0;
+
+       s = strchr(ip_net_str, '/');
+       if (s) {
+               converted = sscanf(s, "/%u", &qualifier);
+               if (converted == 1 && qualifier && qualifier <= 32) {
+                       *depth = qualifier;
+                       *subnet_mask = ((1 << qualifier) - 1) <<
+                                       (32 - qualifier);
+                       subnet_valid = 1;
+               }
+       }
+
+       if (!odph_ipv4_addr_parse(ip_addr, ip_net_str))
+               ip_valid = 1;
+
+       if (ip_valid && subnet_valid)
+               return 0;
+       else if (ip_valid)
+               return 1;
+       else if (subnet_valid)
+               return 2;
+       else
+               return -1;
+}