Skip to content

[PATCH API-NEXT v3] api: ipsec: factor out IP protocol version parameter#20

Closed
lumag wants to merge 1 commit intoOpenDataPlane:api-nextfrom
lumag:ipsec-ipv
Closed

[PATCH API-NEXT v3] api: ipsec: factor out IP protocol version parameter#20
lumag wants to merge 1 commit intoOpenDataPlane:api-nextfrom
lumag:ipsec-ipv

Conversation

@lumag
Copy link

@lumag lumag commented May 3, 2017

Both tunnel and lookup parameters refer IP protocol version. Factor that
out as an IPsec enum used in both places.

Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org

@codecov-io
Copy link

codecov-io commented May 3, 2017

Codecov Report

❗ No coverage uploaded for pull request base (api-next@826ee89). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##             api-next      #20   +/-   ##
===========================================
  Coverage            ?   79.09%           
===========================================
  Files               ?      189           
  Lines               ?    33982           
  Branches            ?        0           
===========================================
  Hits                ?    26879           
  Misses              ?     7103           
  Partials            ?        0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 826ee89...fa2f4f0. Read the comment docs.

@muvarov
Copy link
Contributor

muvarov commented May 3, 2017

From: Dmitry Eremin-Solenikov 
 On 03.05.2017 17:00, Github ODP bot wrote:
> From: Dmitry Eremin-Solenikov 
> 
> Both tunnel and lookup parameters refer IP protocol version. Factor that
> out as an IPsec enum used in both places.
> 
> Signed-off-by: Dmitry Eremin-Solenikov 
> ---
> /** Email created from pull request 20 (lumag:ipsec-ipv)
>  ** https://github.com/Linaro/odp/pull/20
>  ** Patch: https://github.com/Linaro/odp/pull/20.patch
>  ** Base sha: 0b1dbf37b4030c6da4c6f13645c63fd4ac8ff923
>  ** Merge commit sha: 3525f2823e4a228a1fd0f9d8b661de0fc248457a
>  **/
>  include/odp/api/spec/ipsec.h | 21 +++++++++------------
>  1 file changed, 9 insertions(+), 12 deletions(-)

Maxim, this should have received [PATCH API-NEXT] subject prefix.

-- 
With best wishes
Dmitry
 

@muvarov muvarov changed the title api: ipsec: factor out IP protocol version parameter [PATCH API-NEXT v1] api: ipsec: factor out IP protocol version parameter May 3, 2017
@muvarov
Copy link
Contributor

muvarov commented May 3, 2017

From: Dmitry Eremin-Solenikov 
 On 03.05.2017 19:00, Github ODP bot wrote:
> From: Dmitry Eremin-Solenikov 
> 
> Both tunnel and lookup parameters refer IP protocol version. Factor that
> out as an IPsec enum used in both places.

Subject prefixes are still not correct.

-- 
With best wishes
Dmitry
 

@muvarov
Copy link
Contributor

muvarov commented May 3, 2017

From: Maxim Uvarov 
 On 05/03/17 17:06, Dmitry Eremin-Solenikov wrote:
> On 03.05.2017 17:00, Github ODP bot wrote:
>> From: Dmitry Eremin-Solenikov 
>>
>> Both tunnel and lookup parameters refer IP protocol version. Factor that
>> out as an IPsec enum used in both places.
>>
>> Signed-off-by: Dmitry Eremin-Solenikov 
>> ---
>> /** Email created from pull request 20 (lumag:ipsec-ipv)
>>  ** https://github.com/Linaro/odp/pull/20
>>  ** Patch: https://github.com/Linaro/odp/pull/20.patch
>>  ** Base sha: 0b1dbf37b4030c6da4c6f13645c63fd4ac8ff923
>>  ** Merge commit sha: 3525f2823e4a228a1fd0f9d8b661de0fc248457a
>>  **/
>>  include/odp/api/spec/ipsec.h | 21 +++++++++------------
>>  1 file changed, 9 insertions(+), 12 deletions(-)
> 
> Maxim, this should have received [PATCH API-NEXT] subject prefix.
> 
has to be fixed after update. If you want to resend email you can change
title in github page.

Maxim.
 

@muvarov
Copy link
Contributor

muvarov commented May 5, 2017

From: "Savolainen, Petri (Nokia - FI/Espoo)" 
 

> -----Original Message-----
> From: lng-odp [mailto:lng-odp-bounces@lists.linaro.org] On Behalf Of
> Github ODP bot
> Sent: Wednesday, May 03, 2017 7:00 PM
> To: lng-odp@lists.linaro.org
> Subject: [lng-odp] [PATCH] api: ipsec: factor out IP protocol version
> parameter
> 
> From: Dmitry Eremin-Solenikov 
> 
> Both tunnel and lookup parameters refer IP protocol version. Factor that
> out as an IPsec enum used in both places.
> 
> Signed-off-by: Dmitry Eremin-Solenikov 
> ---
> /** Email created from pull request 20 (lumag:ipsec-ipv)
>  ** https://github.com/Linaro/odp/pull/20
>  ** Patch: https://github.com/Linaro/odp/pull/20.patch
>  ** Base sha: 467285f59991e0f28d22a50c99e56f07a4380b8d
>  ** Merge commit sha: cd17da2593db2313648bb4b462e751dae1b19659
>  **/
>  include/odp/api/spec/ipsec.h | 21 +++++++++------------
>  1 file changed, 9 insertions(+), 12 deletions(-)
> 
> diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h
> index e83494d..7b3b1fe 100644
> --- a/include/odp/api/spec/ipsec.h
> +++ b/include/odp/api/spec/ipsec.h
> @@ -339,16 +339,16 @@ typedef enum odp_ipsec_protocol_t {
>  } odp_ipsec_protocol_t;
> 
>  /**
> - * IPSEC tunnel type
> + * IPSEC header type
>   */
> -typedef enum odp_ipsec_tunnel_type_t {
> -	/** Outer header is IPv4 */
> -	ODP_IPSEC_TUNNEL_IPV4 = 0,
> +typedef enum odp_ipsec_header_type_t {
> +	/** Header is IPv4 */
> +	ODP_IPSEC_IPV4 = 0,
> 
> -	/** Outer header is IPv6 */
> -	ODP_IPSEC_TUNNEL_IPV6
> +	/** Header is IPv6 */
> +	ODP_IPSEC_IPV6
> 
> -} odp_ipsec_tunnel_type_t;
> +} odp_ipsec_header_type_t;

Keep the current tunnel type. That way it's possible to extend it later with new tunnel types if needed.

> 
>  /**
>   * IPSEC crypto parameters
> @@ -378,7 +378,7 @@ typedef struct odp_ipsec_crypto_param_t {
>   */
>  typedef struct odp_ipsec_tunnel_param_t {
>  	/** Tunnel type: IPv4 or IPv6 */
> -	odp_ipsec_tunnel_type_t type;
> +	odp_ipsec_header_type_t type;
> 
>  	/** Variant mappings for tunnel parameters */
>  	union {
> @@ -613,11 +613,8 @@ typedef struct odp_ipsec_sa_param_t {
>  	 *  only in ODP_IPSEC_LOOKUP_DSTADDR_SPI lookup mode. */
>  	struct {
>  		/** Select IP version
> -		 *
> -		 *  4:   IPv4
> -		 *  6:   IPv6
>  		 */
> -		uint8_t ip_version;
> +		odp_ipsec_header_type_t ip_version;

Name the type as IP header version enum. E.g.

odp_ipsec_ip_version_t 

The down side of this is that enum is int vs. uint8_t is one byte.

-Petri


> 
>  		/** IP destination address (NETWORK ENDIAN) */
>  		void    *dst_addr;

 

@muvarov muvarov changed the title [PATCH API-NEXT v1] api: ipsec: factor out IP protocol version parameter [PATCH API-NEXT v2] api: ipsec: factor out IP protocol version parameter May 5, 2017
@muvarov
Copy link
Contributor

muvarov commented May 5, 2017

From: Dmitry Eremin-Solenikov 
 On 05.05.2017 13:12, Savolainen, Petri (Nokia - FI/Espoo) wrote:
> 
> 
>> -----Original Message-----
>> From: lng-odp [mailto:lng-odp-bounces@lists.linaro.org] On Behalf Of
>> Github ODP bot
>> Sent: Wednesday, May 03, 2017 7:00 PM
>> To: lng-odp@lists.linaro.org
>> Subject: [lng-odp] [PATCH] api: ipsec: factor out IP protocol version
>> parameter
>>
>> From: Dmitry Eremin-Solenikov 
>>
>> Both tunnel and lookup parameters refer IP protocol version. Factor that
>> out as an IPsec enum used in both places.
>>
>> Signed-off-by: Dmitry Eremin-Solenikov 
>> ---
>> /** Email created from pull request 20 (lumag:ipsec-ipv)
>>  ** https://github.com/Linaro/odp/pull/20
>>  ** Patch: https://github.com/Linaro/odp/pull/20.patch
>>  ** Base sha: 467285f59991e0f28d22a50c99e56f07a4380b8d
>>  ** Merge commit sha: cd17da2593db2313648bb4b462e751dae1b19659
>>  **/
>>  include/odp/api/spec/ipsec.h | 21 +++++++++------------
>>  1 file changed, 9 insertions(+), 12 deletions(-)
>>
>> diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h
>> index e83494d..7b3b1fe 100644
>> --- a/include/odp/api/spec/ipsec.h
>> +++ b/include/odp/api/spec/ipsec.h
>> @@ -339,16 +339,16 @@ typedef enum odp_ipsec_protocol_t {
>>  } odp_ipsec_protocol_t;
>>
>>  /**
>> - * IPSEC tunnel type
>> + * IPSEC header type
>>   */
>> -typedef enum odp_ipsec_tunnel_type_t {
>> -	/** Outer header is IPv4 */
>> -	ODP_IPSEC_TUNNEL_IPV4 = 0,
>> +typedef enum odp_ipsec_header_type_t {
>> +	/** Header is IPv4 */
>> +	ODP_IPSEC_IPV4 = 0,
>>
>> -	/** Outer header is IPv6 */
>> -	ODP_IPSEC_TUNNEL_IPV6
>> +	/** Header is IPv6 */
>> +	ODP_IPSEC_IPV6
>>
>> -} odp_ipsec_tunnel_type_t;
>> +} odp_ipsec_header_type_t;
> 
> Keep the current tunnel type. That way it's possible to extend it later with new tunnel types if needed.

Ack.

>>  /**
>>   * IPSEC crypto parameters
>> @@ -378,7 +378,7 @@ typedef struct odp_ipsec_crypto_param_t {
>>   */
>>  typedef struct odp_ipsec_tunnel_param_t {
>>  	/** Tunnel type: IPv4 or IPv6 */
>> -	odp_ipsec_tunnel_type_t type;
>> +	odp_ipsec_header_type_t type;
>>
>>  	/** Variant mappings for tunnel parameters */
>>  	union {
>> @@ -613,11 +613,8 @@ typedef struct odp_ipsec_sa_param_t {
>>  	 *  only in ODP_IPSEC_LOOKUP_DSTADDR_SPI lookup mode. */
>>  	struct {
>>  		/** Select IP version
>> -		 *
>> -		 *  4:   IPv4
>> -		 *  6:   IPv6
>>  		 */
>> -		uint8_t ip_version;
>> +		odp_ipsec_header_type_t ip_version;
> 
> Name the type as IP header version enum. E.g.
> 
> odp_ipsec_ip_version_t 
> 
> The down side of this is that enum is int vs. uint8_t is one byte.

Well, memory is cheap. One can use any kind of storage internally (even
1-bit flag). However inside parameters I would vote for clarity rather
than storage. Moreover for embedded implementations one can set
-fshort-enums.


-- 
With best wishes
Dmitry
 

/** Header is IPv4 */
ODP_IPSEC_IPV4 = 0,

/** Header is IPv6 */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make sense to define these enum values as 4 and 6 respectively?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bill-Fischofer-Linaro why would we like to have exact values for those enum names?

Instead of using 'magic' numbers for ip version in SA params, define new
enum to distinguish between IPv4 and IPv6.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
@muvarov muvarov changed the title [PATCH API-NEXT v2] api: ipsec: factor out IP protocol version parameter [PATCH API-NEXT v3] api: ipsec: factor out IP protocol version parameter May 23, 2017
Copy link
Contributor

@Bill-Fischofer-Linaro Bill-Fischofer-Linaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-by: Bill Fischofer bill.fischofer@linaro.org

@muvarov
Copy link
Contributor

muvarov commented May 23, 2017

Merged.

@muvarov muvarov closed this May 23, 2017
@lumag lumag deleted the ipsec-ipv branch May 31, 2017 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants