From: Sriharsha Basavapatna
When an encapsulated packet is recirculated through a TUNNEL_POP
action, the metadata gets reinitialized and the originating physical
port information is lost. When this flow gets processed by the vport
and it needs to be offloaded, we can't figure out the physical port
through which the tunneled packet was received.
Add a new member to the metadata: 'orig_in_port'. This is passed to
the next stage during recirculation and the offload layer can use it
to offload the flow to this physical port.
Signed-off-by: Sriharsha Basavapatna
Signed-off-by: Eli Britstein
Reviewed-by: Gaetan Rivet
---
lib/dpif-netdev.c| 20 ++--
lib/netdev-offload.h | 1 +
lib/packets.h| 8 +++-
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index c93a95a9f..b6b4125ed 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -431,6 +431,7 @@ struct dp_flow_offload_item {
struct match match;
struct nlattr *actions;
size_t actions_len;
+odp_port_t orig_in_port; /* Originating in_port for tnl flows. */
struct ovs_list node;
};
@@ -2696,11 +2697,13 @@ dp_netdev_flow_offload_put(struct dp_flow_offload_item
*offload)
}
}
info.flow_mark = mark;
+info.orig_in_port = offload->orig_in_port;
port = netdev_ports_get(in_port, dpif_type_str);
if (!port) {
goto err_free;
}
+
/* Taking a global 'port_mutex' to fulfill thread safety restrictions for
* the netdev-offload-dpdk module. */
ovs_mutex_lock(>dp->port_mutex);
@@ -2798,7 +2801,8 @@ queue_netdev_flow_del(struct dp_netdev_pmd_thread *pmd,
static void
queue_netdev_flow_put(struct dp_netdev_pmd_thread *pmd,
struct dp_netdev_flow *flow, struct match *match,
- const struct nlattr *actions, size_t actions_len)
+ const struct nlattr *actions, size_t actions_len,
+ odp_port_t orig_in_port)
{
struct dp_flow_offload_item *offload;
int op;
@@ -2824,6 +2828,7 @@ queue_netdev_flow_put(struct dp_netdev_pmd_thread *pmd,
offload->actions = xmalloc(actions_len);
memcpy(offload->actions, actions, actions_len);
offload->actions_len = actions_len;
+offload->orig_in_port = orig_in_port;
dp_netdev_append_flow_offload(offload);
}
@@ -3625,7 +3630,8 @@ dp_netdev_get_mega_ufid(const struct match *match,
ovs_u128 *mega_ufid)
static struct dp_netdev_flow *
dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd,
struct match *match, const ovs_u128 *ufid,
- const struct nlattr *actions, size_t actions_len)
+ const struct nlattr *actions, size_t actions_len,
+ odp_port_t orig_in_port)
OVS_REQUIRES(pmd->flow_mutex)
{
struct ds extra_info = DS_EMPTY_INITIALIZER;
@@ -3691,7 +3697,8 @@ dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd,
cmap_insert(>flow_table, CONST_CAST(struct cmap_node *, >node),
dp_netdev_flow_hash(>ufid));
-queue_netdev_flow_put(pmd, flow, match, actions, actions_len);
+queue_netdev_flow_put(pmd, flow, match, actions, actions_len,
+ orig_in_port);
if (OVS_UNLIKELY(!VLOG_DROP_DBG((_rl {
struct ds ds = DS_EMPTY_INITIALIZER;
@@ -3762,7 +3769,7 @@ flow_put_on_pmd(struct dp_netdev_pmd_thread *pmd,
if (!netdev_flow) {
if (put->flags & DPIF_FP_CREATE) {
dp_netdev_flow_add(pmd, match, ufid, put->actions,
- put->actions_len);
+ put->actions_len, ODPP_NONE);
} else {
error = ENOENT;
}
@@ -3778,7 +3785,7 @@ flow_put_on_pmd(struct dp_netdev_pmd_thread *pmd,
ovsrcu_set(_flow->actions, new_actions);
queue_netdev_flow_put(pmd, netdev_flow, match,
- put->actions, put->actions_len);
+ put->actions, put->actions_len, ODPP_NONE);
if (stats) {
get_dpif_flow_status(pmd->dp, netdev_flow, stats, NULL);
@@ -7256,6 +7263,7 @@ handle_packet_upcall(struct dp_netdev_pmd_thread *pmd,
ovs_u128 ufid;
int error;
uint64_t cycles = cycles_counter_update(>perf_stats);
+odp_port_t orig_in_port = packet->md.orig_in_port;
match.tun_md.valid = false;
miniflow_expand(>mf, );
@@ -7305,7 +7313,7 @@ handle_packet_upcall(struct dp_netdev_pmd_thread *pmd,
if (OVS_LIKELY(!netdev_flow)) {
netdev_flow = dp_netdev_flow_add(pmd, , ,
add_actions->data,
- add_actions->size);
+ add_actions->size, orig_in_port);
}
ovs_mutex_unlock(>flow_mutex);
uint32_t hash = dp_netdev_flow_hash(_flow->ufid);
diff --git