2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 09:58:01 +00:00

ofproto-dpif-sflow: Recursively examine actions inside clone.

Until now, dpif_sflow_read_actions() has ignored actions inside clone.
This means that sflow missed tnl_push actions inside clone, which OVS
now uses to avoid tx recirculation.  This commit fixes the problem
by making dpif_sflow_read_actions() recursively process actions inside
clone.

In addition, some sflow data needs to be stored and restored in
ofproto-dpif-xlate when native_tunnel_output() is invoked. Otherwise the
output action of underlay bridge is getting counted too when sFlow is set
on the overlay bridge.

Both bugs are connected to sflows and were introduced by the commit in
the "Fixes:" tag below.

Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
CC: Sugesh Chandran <sugesh.chandran@intel.com>
Fixes: 7c12dfc527a5 ("tunneling: Avoid datapath-recirc by combining recirc actions at xlate.")
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Zoltan Balogh 2018-01-09 19:54:31 +01:00 committed by Ben Pfaff
parent 08129599db
commit 283d866294
5 changed files with 21 additions and 8 deletions

View File

@ -961,7 +961,7 @@ sflow_read_set_action(const struct nlattr *attr,
} else { } else {
dpif_sflow_read_actions(NULL, dpif_sflow_read_actions(NULL,
nl_attr_get(attr), nl_attr_get_size(attr), nl_attr_get(attr), nl_attr_get_size(attr),
sflow_actions); sflow_actions, true);
} }
break; break;
case OVS_KEY_ATTR_PRIORITY: case OVS_KEY_ATTR_PRIORITY:
@ -1089,7 +1089,8 @@ dpif_sflow_capture_input_mpls(const struct flow *flow,
void void
dpif_sflow_read_actions(const struct flow *flow, dpif_sflow_read_actions(const struct flow *flow,
const struct nlattr *actions, size_t actions_len, const struct nlattr *actions, size_t actions_len,
struct dpif_sflow_actions *sflow_actions) struct dpif_sflow_actions *sflow_actions,
bool capture_mpls)
{ {
const struct nlattr *a; const struct nlattr *a;
unsigned int left; unsigned int left;
@ -1099,7 +1100,7 @@ dpif_sflow_read_actions(const struct flow *flow,
return; return;
} }
if (flow != NULL) { if (flow != NULL && capture_mpls == true) {
/* Make sure the MPLS output stack /* Make sure the MPLS output stack
* is seeded with the input stack. * is seeded with the input stack.
*/ */
@ -1198,8 +1199,13 @@ dpif_sflow_read_actions(const struct flow *flow,
* structure to report this. * structure to report this.
*/ */
break; break;
case OVS_ACTION_ATTR_SAMPLE:
case OVS_ACTION_ATTR_CLONE: case OVS_ACTION_ATTR_CLONE:
if (flow != NULL) {
dpif_sflow_read_actions(flow, nl_attr_get(a), nl_attr_get_size(a),
sflow_actions, false);
}
break;
case OVS_ACTION_ATTR_SAMPLE:
case OVS_ACTION_ATTR_PUSH_NSH: case OVS_ACTION_ATTR_PUSH_NSH:
case OVS_ACTION_ATTR_POP_NSH: case OVS_ACTION_ATTR_POP_NSH:
case OVS_ACTION_ATTR_UNSPEC: case OVS_ACTION_ATTR_UNSPEC:

View File

@ -71,7 +71,7 @@ void dpif_sflow_wait(struct dpif_sflow *);
void dpif_sflow_read_actions(const struct flow *, void dpif_sflow_read_actions(const struct flow *,
const struct nlattr *actions, size_t actions_len, const struct nlattr *actions, size_t actions_len,
struct dpif_sflow_actions *); struct dpif_sflow_actions *, bool capture_mpls);
void dpif_sflow_received(struct dpif_sflow *, const struct dp_packet *, void dpif_sflow_received(struct dpif_sflow *, const struct dp_packet *,
const struct flow *, odp_port_t odp_port, const struct flow *, odp_port_t odp_port,

View File

@ -1330,7 +1330,7 @@ dpif_read_actions(struct udpif *udpif, struct upcall *upcall,
switch (type) { switch (type) {
case SFLOW_UPCALL: case SFLOW_UPCALL:
dpif_sflow_read_actions(flow, actions, actions_len, upcall_data); dpif_sflow_read_actions(flow, actions, actions_len, upcall_data, true);
break; break;
case FLOW_SAMPLE_UPCALL: case FLOW_SAMPLE_UPCALL:
case IPFIX_UPCALL: case IPFIX_UPCALL:

View File

@ -3264,6 +3264,9 @@ native_tunnel_output(struct xlate_ctx *ctx, const struct xport *xport,
char buf_sip6[INET6_ADDRSTRLEN]; char buf_sip6[INET6_ADDRSTRLEN];
char buf_dip6[INET6_ADDRSTRLEN]; char buf_dip6[INET6_ADDRSTRLEN];
/* Store sFlow data. */
uint32_t sflow_n_outputs = ctx->sflow_n_outputs;
/* Structures to backup Ethernet and IP of base_flow. */ /* Structures to backup Ethernet and IP of base_flow. */
struct flow old_base_flow; struct flow old_base_flow;
struct flow old_flow; struct flow old_flow;
@ -3415,6 +3418,10 @@ native_tunnel_output(struct xlate_ctx *ctx, const struct xport *xport,
/* Restore the flows after the translation. */ /* Restore the flows after the translation. */
memcpy(&ctx->xin->flow, &old_flow, sizeof ctx->xin->flow); memcpy(&ctx->xin->flow, &old_flow, sizeof ctx->xin->flow);
memcpy(&ctx->base_flow, &old_base_flow, sizeof ctx->base_flow); memcpy(&ctx->base_flow, &old_base_flow, sizeof ctx->base_flow);
/* Restore sFlow data. */
ctx->sflow_n_outputs = sflow_n_outputs;
return 0; return 0;
} }

View File

@ -6336,7 +6336,7 @@ AT_CHECK([ovs-appctl ovs/route/add 1.1.2.92/24 br0], [0], [OK
AT_CHECK([ovs-ofctl add-flow br0 action=normal]) AT_CHECK([ovs-ofctl add-flow br0 action=normal])
dnl Prime ARP Cache for 1.1.2.92 dnl Prime ARP Cache for 1.1.2.92
AT_CHECK([ovs-appctl netdev-dummy/receive br0 'recirc_id(0),in_port(100),eth(src=f8:bc:12:44:34:b6,dst=ff:ff:ff:ff:ff:ff),eth_type(0x0806),arp(sip=1.1.2.92,tip=1.1.2.88,op=2,sha=f8:bc:12:44:34:b6,tha=00:00:00:00:00:00)']) AT_CHECK([ovs-appctl netdev-dummy/receive p0 'recirc_id(0),in_port(1),eth(src=f8:bc:12:44:34:b6,dst=ff:ff:ff:ff:ff:ff),eth_type(0x0806),arp(sip=1.1.2.92,tip=1.1.2.88,op=2,sha=f8:bc:12:44:34:b6,tha=00:00:00:00:00:00)'])
dnl configure sflow on int-br only dnl configure sflow on int-br only
ovs-vsctl \ ovs-vsctl \