[1/3] ethdev: add flow api actions to modify IP addresses
diff mbox series

Message ID 05c072bcd94a9767d08b2ffdafb2f8f54b8dadc9.1537776502.git.rahul.lakkireddy@chelsio.com
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • ethdev: add IP address and TCP/UDP port rewrite actions to flow API
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Rahul Lakkireddy Sept. 24, 2018, 8:28 a.m. UTC
Add actions:
- SET_IPV4_SRC - set a new IPv4 source address.
- SET_IPV4_DST - set a new IPv4 destination address.
- SET_IPV6_SRC - set a new IPv6 source address.
- SET_IPV6_DST - set a new IPv6 destination address.

Original work by Shagun Agrawal

Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
---
Changes since RFC v2:
- Updated comments, help messages, and doc to indicate that IP/TCP/UDP
  of the outermost headers are modified.
- Updated comments and doc to indicate that a corresponding valid flow
  pattern item must be specified to offload corresponding header rewrite
  action.
- Updated release notes.

 app/test-pmd/cmdline_flow.c                 | 104 ++++++++++++++++++++
 app/test-pmd/config.c                       |   8 ++
 doc/guides/prog_guide/rte_flow.rst          |  72 ++++++++++++++
 doc/guides/rel_notes/release_18_11.rst      |   6 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  18 ++++
 lib/librte_ethdev/rte_flow.c                |   8 ++
 lib/librte_ethdev/rte_flow.h                |  70 +++++++++++++
 7 files changed, 286 insertions(+)

Comments

Xiaoyu Min Sept. 25, 2018, 3:03 a.m. UTC | #1
On 18-09-24 13:58:17, Rahul Lakkireddy wrote:
> Add actions:
> - SET_IPV4_SRC - set a new IPv4 source address.
> - SET_IPV4_DST - set a new IPv4 destination address.
> - SET_IPV6_SRC - set a new IPv6 source address.
> - SET_IPV6_DST - set a new IPv6 destination address.
> 
> Original work by Shagun Agrawal
> 
> Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
> ---
> Changes since RFC v2:
> - Updated comments, help messages, and doc to indicate that IP/TCP/UDP
>   of the outermost headers are modified.
> - Updated comments and doc to indicate that a corresponding valid flow
>   pattern item must be specified to offload corresponding header rewrite
>   action.
> - Updated release notes.
> 
>  app/test-pmd/cmdline_flow.c                 | 104 ++++++++++++++++++++
>  app/test-pmd/config.c                       |   8 ++
>  doc/guides/prog_guide/rte_flow.rst          |  72 ++++++++++++++
>  doc/guides/rel_notes/release_18_11.rst      |   6 ++
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  18 ++++
>  lib/librte_ethdev/rte_flow.c                |   8 ++
>  lib/librte_ethdev/rte_flow.h                |  70 +++++++++++++
>  7 files changed, 286 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index f9260600e..1432498a3 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -243,6 +243,14 @@ enum index {
>  	ACTION_VXLAN_DECAP,
>  	ACTION_NVGRE_ENCAP,
>  	ACTION_NVGRE_DECAP,
> +	ACTION_SET_IPV4_SRC,
> +	ACTION_SET_IPV4_SRC_IPV4_SRC,
> +	ACTION_SET_IPV4_DST,
> +	ACTION_SET_IPV4_DST_IPV4_DST,
> +	ACTION_SET_IPV6_SRC,
> +	ACTION_SET_IPV6_SRC_IPV6_SRC,
> +	ACTION_SET_IPV6_DST,
> +	ACTION_SET_IPV6_DST_IPV6_DST,
>  };
>  
>  /** Maximum size for pattern in struct rte_flow_item_raw. */
> @@ -816,6 +824,10 @@ static const enum index next_action[] = {
>  	ACTION_VXLAN_DECAP,
>  	ACTION_NVGRE_ENCAP,
>  	ACTION_NVGRE_DECAP,
> +	ACTION_SET_IPV4_SRC,
> +	ACTION_SET_IPV4_DST,
> +	ACTION_SET_IPV6_SRC,
> +	ACTION_SET_IPV6_DST,
>  	ZERO,
>  };
>  
> @@ -918,6 +930,30 @@ static const enum index action_of_push_mpls[] = {
>  	ZERO,
>  };
>  
> +static const enum index action_set_ipv4_src[] = {
> +	ACTION_SET_IPV4_SRC_IPV4_SRC,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_set_ipv4_dst[] = {
> +	ACTION_SET_IPV4_DST_IPV4_DST,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_set_ipv6_src[] = {
> +	ACTION_SET_IPV6_SRC_IPV6_SRC,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_set_ipv6_dst[] = {
> +	ACTION_SET_IPV6_DST_IPV6_DST,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
>  static const enum index action_jump[] = {
>  	ACTION_JUMP_GROUP,
>  	ACTION_NEXT,
> @@ -2470,6 +2506,74 @@ static const struct token token_list[] = {
>  		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
>  		.call = parse_vc,
>  	},
> +	[ACTION_SET_IPV4_SRC] = {
> +		.name = "set_ipv4_src",
> +		.help = "Set a new IPv4 source address in the outermost"
> +			" IPv4 header",
> +		.priv = PRIV_ACTION(SET_IPV4_SRC,
> +			sizeof(struct rte_flow_action_set_ipv4)),
> +		.next = NEXT(action_set_ipv4_src),
> +		.call = parse_vc,
> +	},
> +	[ACTION_SET_IPV4_SRC_IPV4_SRC] = {
> +		.name = "ipv4_addr",
> +		.help = "new IPv4 source address to set",
> +		.next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_set_ipv4, ipv4_addr)),
> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_SET_IPV4_DST] = {
> +		.name = "set_ipv4_dst",
> +		.help = "Set a new IPv4 destination address in the outermost"
> +			" IPv4 header",
> +		.priv = PRIV_ACTION(SET_IPV4_DST,
> +			sizeof(struct rte_flow_action_set_ipv4)),
> +		.next = NEXT(action_set_ipv4_dst),
> +		.call = parse_vc,
> +	},
> +	[ACTION_SET_IPV4_DST_IPV4_DST] = {
> +		.name = "ipv4_addr",
> +		.help = "new IPv4 destination address to set",
> +		.next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_set_ipv4, ipv4_addr)),
> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_SET_IPV6_SRC] = {
> +		.name = "set_ipv6_src",
> +		.help = "Set a new IPv6 source address in the outermost"
> +			" IPv6 header",
> +		.priv = PRIV_ACTION(SET_IPV6_SRC,
> +			sizeof(struct rte_flow_action_set_ipv6)),
> +		.next = NEXT(action_set_ipv6_src),
> +		.call = parse_vc,
> +	},
> +	[ACTION_SET_IPV6_SRC_IPV6_SRC] = {
> +		.name = "ipv6_addr",
> +		.help = "new IPv6 source address to set",
> +		.next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_set_ipv6, ipv6_addr)),
> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_SET_IPV6_DST] = {
> +		.name = "set_ipv6_dst",
> +		.help = "Set a new IPv6 destination address in the outermost"
> +			" IPv6 header",
> +		.priv = PRIV_ACTION(SET_IPV6_DST,
> +			sizeof(struct rte_flow_action_set_ipv6)),
> +		.next = NEXT(action_set_ipv6_dst),
> +		.call = parse_vc,
> +	},
> +	[ACTION_SET_IPV6_DST_IPV6_DST] = {
> +		.name = "ipv6_addr",
> +		.help = "new IPv6 destination address to set",
> +		.next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_set_ipv6, ipv6_addr)),
> +		.call = parse_vc_conf,
> +	},
>  };
>  
>  /** Remove and return last entry from argument stack. */
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index 794aa5268..14dbdf7a3 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -1172,6 +1172,14 @@ static const struct {
>  		       sizeof(struct rte_flow_action_of_pop_mpls)),
>  	MK_FLOW_ACTION(OF_PUSH_MPLS,
>  		       sizeof(struct rte_flow_action_of_push_mpls)),
> +	MK_FLOW_ACTION(SET_IPV4_SRC,
> +		       sizeof(struct rte_flow_action_set_ipv4)),
> +	MK_FLOW_ACTION(SET_IPV4_DST,
> +		       sizeof(struct rte_flow_action_set_ipv4)),
> +	MK_FLOW_ACTION(SET_IPV6_SRC,
> +		       sizeof(struct rte_flow_action_set_ipv6)),
> +	MK_FLOW_ACTION(SET_IPV6_DST,
> +		       sizeof(struct rte_flow_action_set_ipv6)),
>  };
>  
>  /** Compute storage space needed by action configuration and copy it. */
> diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
> index b305a72a5..b9bcaa3d1 100644
> --- a/doc/guides/prog_guide/rte_flow.rst
> +++ b/doc/guides/prog_guide/rte_flow.rst
> @@ -2076,6 +2076,78 @@ RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
>  
>  This action modifies the payload of matched flows.
>  
> +Action: ``SET_IPV4_SRC``
> +^^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Set a new IPv4 source address in the outermost IPv4 header.
> +
> +It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV4 flow pattern item.
> +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
> +
> +.. _table_rte_flow_action_set_ipv4_src:
> +
> +.. table:: SET_IPV4_SRC
> +
> +   +-----------------------------------------+
> +   | Field         | Value                   |
> +   +===============+=========================+
> +   | ``ipv4_addr`` | new IPv4 source address |
> +   +---------------+-------------------------+
> +
> +Action: ``SET_IPV4_DST``
> +^^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Set a new IPv4 destination address in the outermost IPv4 header.
> +
> +It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV4 flow pattern item.
> +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
> +
> +.. _table_rte_flow_action_set_ipv4_dst:
> +
> +.. table:: SET_IPV4_DST
> +
> +   +---------------+------------------------------+
> +   | Field         | Value                        |
> +   +===============+==============================+
> +   | ``ipv4_addr`` | new IPv4 destination address |
> +   +---------------+------------------------------+
> +
> +Action: ``SET_IPV6_SRC``
> +^^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Set a new IPv6 source address in the outermost IPv6 header.
> +
> +It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV6 flow pattern item.
> +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
> +
> +.. _table_rte_flow_action_set_ipv6_src:
> +
> +.. table:: SET_IPV6_SRC
> +
> +   +---------------+-------------------------+
> +   | Field         | Value                   |
> +   +===============+=========================+
> +   | ``ipv6_addr`` | new IPv6 source address |
> +   +---------------+-------------------------+
> +
> +Action: ``SET_IPV6_DST``
> +^^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Set a new IPv6 destination address in the outermost IPv6 header.
> +
> +It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV6 flow pattern item.
> +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
> +
> +.. _table_rte_flow_action_set_ipv6_dst:
> +
> +.. table:: SET_IPV6_DST
> +
> +   +---------------+------------------------------+
> +   | Field         | Value                        |
> +   +===============+==============================+
> +   | ``ipv6_addr`` | new IPv6 destination address |
> +   +---------------+------------------------------+
> +
>  Negative types
>  ~~~~~~~~~~~~~~
>  
> diff --git a/doc/guides/rel_notes/release_18_11.rst b/doc/guides/rel_notes/release_18_11.rst
> index f39cb15d2..782722318 100644
> --- a/doc/guides/rel_notes/release_18_11.rst
> +++ b/doc/guides/rel_notes/release_18_11.rst
> @@ -87,6 +87,12 @@ New Features
>    the specified port. The port must be stopped before the command call in order
>    to reconfigure queues.
>  
> +* **Added new Flow API actions to rewrite fields in packet headers.**
> +
> +  Added new Flow API actions to:
> +
> +  * Modify source and destination IP addresses in the outermost IPv4/IPv6
> +    headers.
>  
>  API Changes
>  -----------
> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index 3a73000a6..97d91f066 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -3704,6 +3704,24 @@ This section lists supported actions and their attributes, if any.
>  - ``nvgre_decap``: Performs a decapsulation action by stripping all headers of
>    the NVGRE tunnel network overlay from the matched flow.
>  
> +- ``set_ipv4_src``: Set a new IPv4 source address in the outermost IPv4 header.
> +
> +  - ``ipv4_addr``: New IPv4 source address.
> +
> +- ``set_ipv4_dst``: Set a new IPv4 destination address in the outermost IPv4
> +  header.
> +
> +  - ``ipv4_addr``: New IPv4 destination address.
> +
> +- ``set_ipv6_src``: Set a new IPv6 source address in the outermost IPv6 header.
> +
> +  - ``ipv6_addr``: New IPv6 source address.
> +
> +- ``set_ipv6_dst``: Set a new IPv6 destination address in the outermost IPv6
> +  header.
> +
> +  - ``ipv6_addr``: New IPv6 destination address.
> +
>  Destroying flow rules
>  ~~~~~~~~~~~~~~~~~~~~~
>  
> diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
> index cff4b5209..d4f1b9a05 100644
> --- a/lib/librte_ethdev/rte_flow.c
> +++ b/lib/librte_ethdev/rte_flow.c
> @@ -109,6 +109,14 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
>  		       sizeof(struct rte_flow_action_of_pop_mpls)),
>  	MK_FLOW_ACTION(OF_PUSH_MPLS,
>  		       sizeof(struct rte_flow_action_of_push_mpls)),
> +	MK_FLOW_ACTION(SET_IPV4_SRC,
> +		       sizeof(struct rte_flow_action_set_ipv4)),
> +	MK_FLOW_ACTION(SET_IPV4_DST,
> +		       sizeof(struct rte_flow_action_set_ipv4)),
> +	MK_FLOW_ACTION(SET_IPV6_SRC,
> +		       sizeof(struct rte_flow_action_set_ipv6)),
> +	MK_FLOW_ACTION(SET_IPV6_DST,
> +		       sizeof(struct rte_flow_action_set_ipv6)),
>  };
>  
>  static int
> diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
> index f8ba71cdb..0fe91ae89 100644
> --- a/lib/librte_ethdev/rte_flow.h
> +++ b/lib/librte_ethdev/rte_flow.h
> @@ -1505,6 +1505,46 @@ enum rte_flow_action_type {
>  	 * error.
>  	 */
>  	RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
> +
> +	/**
> +	 * Modify IPv4 source address in the outermost IPv4 header.
> +	 *
> +	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
> +	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
> +	 *
> +	 * See struct rte_flow_action_set_ipv4.
> +	 */
> +	RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
> +
> +	/**
> +	 * Modify IPv4 destination address in the outermost IPv4 header.
> +	 *
> +	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
> +	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
> +	 *
> +	 * See struct rte_flow_action_set_ipv4.
> +	 */
> +	RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
> +
> +	/**
> +	 * Modify IPv6 source address in the outermost IPv6 header.
> +	 *
> +	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
> +	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
> +	 *
> +	 * See struct rte_flow_action_set_ipv6.
> +	 */
> +	RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
> +
> +	/**
> +	 * Modify IPv6 destination address in the outermost IPv6 header.
> +	 *
> +	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
> +	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
> +	 *
> +	 * See struct rte_flow_action_set_ipv6.
> +	 */
> +	RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
>  };
>  
>  /**
> @@ -1868,6 +1908,36 @@ struct rte_flow_action_nvgre_encap {
>  	struct rte_flow_item *definition;
>  };
>  
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this structure may change without prior notice
> + *
> + * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
> + * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
> + *
> + * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
> + * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
> + * specified outermost IPv4 header.
> + */
> +struct rte_flow_action_set_ipv4 {
> +	uint32_t ipv4_addr;
> +};
> +
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this structure may change without prior notice
> + *
> + * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
> + * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
> + *
> + * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
> + * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
> + * specified outermost IPv6 header.
> + */
> +struct rte_flow_action_set_ipv6 {
> +	uint8_t ipv6_addr[16];
> +};
> +
>  /*
>   * Definition of a single action.
>   *
> -- 
> 2.18.0
> 
Acked-by: Xiaoyu Min <jackmin@mellanox.com>

Thanks

Patch
diff mbox series

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index f9260600e..1432498a3 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -243,6 +243,14 @@  enum index {
 	ACTION_VXLAN_DECAP,
 	ACTION_NVGRE_ENCAP,
 	ACTION_NVGRE_DECAP,
+	ACTION_SET_IPV4_SRC,
+	ACTION_SET_IPV4_SRC_IPV4_SRC,
+	ACTION_SET_IPV4_DST,
+	ACTION_SET_IPV4_DST_IPV4_DST,
+	ACTION_SET_IPV6_SRC,
+	ACTION_SET_IPV6_SRC_IPV6_SRC,
+	ACTION_SET_IPV6_DST,
+	ACTION_SET_IPV6_DST_IPV6_DST,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -816,6 +824,10 @@  static const enum index next_action[] = {
 	ACTION_VXLAN_DECAP,
 	ACTION_NVGRE_ENCAP,
 	ACTION_NVGRE_DECAP,
+	ACTION_SET_IPV4_SRC,
+	ACTION_SET_IPV4_DST,
+	ACTION_SET_IPV6_SRC,
+	ACTION_SET_IPV6_DST,
 	ZERO,
 };
 
@@ -918,6 +930,30 @@  static const enum index action_of_push_mpls[] = {
 	ZERO,
 };
 
+static const enum index action_set_ipv4_src[] = {
+	ACTION_SET_IPV4_SRC_IPV4_SRC,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_set_ipv4_dst[] = {
+	ACTION_SET_IPV4_DST_IPV4_DST,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_set_ipv6_src[] = {
+	ACTION_SET_IPV6_SRC_IPV6_SRC,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_set_ipv6_dst[] = {
+	ACTION_SET_IPV6_DST_IPV6_DST,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static const enum index action_jump[] = {
 	ACTION_JUMP_GROUP,
 	ACTION_NEXT,
@@ -2470,6 +2506,74 @@  static const struct token token_list[] = {
 		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
 		.call = parse_vc,
 	},
+	[ACTION_SET_IPV4_SRC] = {
+		.name = "set_ipv4_src",
+		.help = "Set a new IPv4 source address in the outermost"
+			" IPv4 header",
+		.priv = PRIV_ACTION(SET_IPV4_SRC,
+			sizeof(struct rte_flow_action_set_ipv4)),
+		.next = NEXT(action_set_ipv4_src),
+		.call = parse_vc,
+	},
+	[ACTION_SET_IPV4_SRC_IPV4_SRC] = {
+		.name = "ipv4_addr",
+		.help = "new IPv4 source address to set",
+		.next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_set_ipv4, ipv4_addr)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_SET_IPV4_DST] = {
+		.name = "set_ipv4_dst",
+		.help = "Set a new IPv4 destination address in the outermost"
+			" IPv4 header",
+		.priv = PRIV_ACTION(SET_IPV4_DST,
+			sizeof(struct rte_flow_action_set_ipv4)),
+		.next = NEXT(action_set_ipv4_dst),
+		.call = parse_vc,
+	},
+	[ACTION_SET_IPV4_DST_IPV4_DST] = {
+		.name = "ipv4_addr",
+		.help = "new IPv4 destination address to set",
+		.next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_set_ipv4, ipv4_addr)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_SET_IPV6_SRC] = {
+		.name = "set_ipv6_src",
+		.help = "Set a new IPv6 source address in the outermost"
+			" IPv6 header",
+		.priv = PRIV_ACTION(SET_IPV6_SRC,
+			sizeof(struct rte_flow_action_set_ipv6)),
+		.next = NEXT(action_set_ipv6_src),
+		.call = parse_vc,
+	},
+	[ACTION_SET_IPV6_SRC_IPV6_SRC] = {
+		.name = "ipv6_addr",
+		.help = "new IPv6 source address to set",
+		.next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_set_ipv6, ipv6_addr)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_SET_IPV6_DST] = {
+		.name = "set_ipv6_dst",
+		.help = "Set a new IPv6 destination address in the outermost"
+			" IPv6 header",
+		.priv = PRIV_ACTION(SET_IPV6_DST,
+			sizeof(struct rte_flow_action_set_ipv6)),
+		.next = NEXT(action_set_ipv6_dst),
+		.call = parse_vc,
+	},
+	[ACTION_SET_IPV6_DST_IPV6_DST] = {
+		.name = "ipv6_addr",
+		.help = "new IPv6 destination address to set",
+		.next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_set_ipv6, ipv6_addr)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 794aa5268..14dbdf7a3 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1172,6 +1172,14 @@  static const struct {
 		       sizeof(struct rte_flow_action_of_pop_mpls)),
 	MK_FLOW_ACTION(OF_PUSH_MPLS,
 		       sizeof(struct rte_flow_action_of_push_mpls)),
+	MK_FLOW_ACTION(SET_IPV4_SRC,
+		       sizeof(struct rte_flow_action_set_ipv4)),
+	MK_FLOW_ACTION(SET_IPV4_DST,
+		       sizeof(struct rte_flow_action_set_ipv4)),
+	MK_FLOW_ACTION(SET_IPV6_SRC,
+		       sizeof(struct rte_flow_action_set_ipv6)),
+	MK_FLOW_ACTION(SET_IPV6_DST,
+		       sizeof(struct rte_flow_action_set_ipv6)),
 };
 
 /** Compute storage space needed by action configuration and copy it. */
diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index b305a72a5..b9bcaa3d1 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2076,6 +2076,78 @@  RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
 
 This action modifies the payload of matched flows.
 
+Action: ``SET_IPV4_SRC``
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+Set a new IPv4 source address in the outermost IPv4 header.
+
+It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV4 flow pattern item.
+Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
+
+.. _table_rte_flow_action_set_ipv4_src:
+
+.. table:: SET_IPV4_SRC
+
+   +-----------------------------------------+
+   | Field         | Value                   |
+   +===============+=========================+
+   | ``ipv4_addr`` | new IPv4 source address |
+   +---------------+-------------------------+
+
+Action: ``SET_IPV4_DST``
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+Set a new IPv4 destination address in the outermost IPv4 header.
+
+It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV4 flow pattern item.
+Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
+
+.. _table_rte_flow_action_set_ipv4_dst:
+
+.. table:: SET_IPV4_DST
+
+   +---------------+------------------------------+
+   | Field         | Value                        |
+   +===============+==============================+
+   | ``ipv4_addr`` | new IPv4 destination address |
+   +---------------+------------------------------+
+
+Action: ``SET_IPV6_SRC``
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+Set a new IPv6 source address in the outermost IPv6 header.
+
+It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV6 flow pattern item.
+Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
+
+.. _table_rte_flow_action_set_ipv6_src:
+
+.. table:: SET_IPV6_SRC
+
+   +---------------+-------------------------+
+   | Field         | Value                   |
+   +===============+=========================+
+   | ``ipv6_addr`` | new IPv6 source address |
+   +---------------+-------------------------+
+
+Action: ``SET_IPV6_DST``
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+Set a new IPv6 destination address in the outermost IPv6 header.
+
+It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV6 flow pattern item.
+Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
+
+.. _table_rte_flow_action_set_ipv6_dst:
+
+.. table:: SET_IPV6_DST
+
+   +---------------+------------------------------+
+   | Field         | Value                        |
+   +===============+==============================+
+   | ``ipv6_addr`` | new IPv6 destination address |
+   +---------------+------------------------------+
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/doc/guides/rel_notes/release_18_11.rst b/doc/guides/rel_notes/release_18_11.rst
index f39cb15d2..782722318 100644
--- a/doc/guides/rel_notes/release_18_11.rst
+++ b/doc/guides/rel_notes/release_18_11.rst
@@ -87,6 +87,12 @@  New Features
   the specified port. The port must be stopped before the command call in order
   to reconfigure queues.
 
+* **Added new Flow API actions to rewrite fields in packet headers.**
+
+  Added new Flow API actions to:
+
+  * Modify source and destination IP addresses in the outermost IPv4/IPv6
+    headers.
 
 API Changes
 -----------
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 3a73000a6..97d91f066 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3704,6 +3704,24 @@  This section lists supported actions and their attributes, if any.
 - ``nvgre_decap``: Performs a decapsulation action by stripping all headers of
   the NVGRE tunnel network overlay from the matched flow.
 
+- ``set_ipv4_src``: Set a new IPv4 source address in the outermost IPv4 header.
+
+  - ``ipv4_addr``: New IPv4 source address.
+
+- ``set_ipv4_dst``: Set a new IPv4 destination address in the outermost IPv4
+  header.
+
+  - ``ipv4_addr``: New IPv4 destination address.
+
+- ``set_ipv6_src``: Set a new IPv6 source address in the outermost IPv6 header.
+
+  - ``ipv6_addr``: New IPv6 source address.
+
+- ``set_ipv6_dst``: Set a new IPv6 destination address in the outermost IPv6
+  header.
+
+  - ``ipv6_addr``: New IPv6 destination address.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index cff4b5209..d4f1b9a05 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -109,6 +109,14 @@  static const struct rte_flow_desc_data rte_flow_desc_action[] = {
 		       sizeof(struct rte_flow_action_of_pop_mpls)),
 	MK_FLOW_ACTION(OF_PUSH_MPLS,
 		       sizeof(struct rte_flow_action_of_push_mpls)),
+	MK_FLOW_ACTION(SET_IPV4_SRC,
+		       sizeof(struct rte_flow_action_set_ipv4)),
+	MK_FLOW_ACTION(SET_IPV4_DST,
+		       sizeof(struct rte_flow_action_set_ipv4)),
+	MK_FLOW_ACTION(SET_IPV6_SRC,
+		       sizeof(struct rte_flow_action_set_ipv6)),
+	MK_FLOW_ACTION(SET_IPV6_DST,
+		       sizeof(struct rte_flow_action_set_ipv6)),
 };
 
 static int
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index f8ba71cdb..0fe91ae89 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1505,6 +1505,46 @@  enum rte_flow_action_type {
 	 * error.
 	 */
 	RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
+
+	/**
+	 * Modify IPv4 source address in the outermost IPv4 header.
+	 *
+	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
+	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
+	 *
+	 * See struct rte_flow_action_set_ipv4.
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
+
+	/**
+	 * Modify IPv4 destination address in the outermost IPv4 header.
+	 *
+	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
+	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
+	 *
+	 * See struct rte_flow_action_set_ipv4.
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
+
+	/**
+	 * Modify IPv6 source address in the outermost IPv6 header.
+	 *
+	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
+	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
+	 *
+	 * See struct rte_flow_action_set_ipv6.
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
+
+	/**
+	 * Modify IPv6 destination address in the outermost IPv6 header.
+	 *
+	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
+	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
+	 *
+	 * See struct rte_flow_action_set_ipv6.
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
 };
 
 /**
@@ -1868,6 +1908,36 @@  struct rte_flow_action_nvgre_encap {
 	struct rte_flow_item *definition;
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
+ * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
+ *
+ * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
+ * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
+ * specified outermost IPv4 header.
+ */
+struct rte_flow_action_set_ipv4 {
+	uint32_t ipv4_addr;
+};
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
+ * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
+ *
+ * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
+ * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
+ * specified outermost IPv6 header.
+ */
+struct rte_flow_action_set_ipv6 {
+	uint8_t ipv6_addr[16];
+};
+
 /*
  * Definition of a single action.
  *