]> git.proxmox.com Git - ovs.git/commitdiff
ofproto-dpif-sflow: Recursively examine actions inside clone.
authorZoltan Balogh <zoltan.balogh@ericsson.com>
Tue, 9 Jan 2018 18:54:31 +0000 (19:54 +0100)
committerBen Pfaff <blp@ovn.org>
Tue, 23 Jan 2018 18:31:35 +0000 (10:31 -0800)
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>
ofproto/ofproto-dpif-sflow.c
ofproto/ofproto-dpif-sflow.h
ofproto/ofproto-dpif-upcall.c
ofproto/ofproto-dpif-xlate.c
tests/ofproto-dpif.at

index fb7589fda070cb9a2becfae5921cd82eef42fd4b..60e1b4e0a661874ce5be0698f411b139a53faece 100644 (file)
@@ -961,7 +961,7 @@ sflow_read_set_action(const struct nlattr *attr,
         } else {
             dpif_sflow_read_actions(NULL,
                                     nl_attr_get(attr), nl_attr_get_size(attr),
-                                    sflow_actions);
+                                    sflow_actions, true);
         }
         break;
     case OVS_KEY_ATTR_PRIORITY:
@@ -1088,8 +1088,9 @@ dpif_sflow_capture_input_mpls(const struct flow *flow,
 
 void
 dpif_sflow_read_actions(const struct flow *flow,
-                       const struct nlattr *actions, size_t actions_len,
-                       struct dpif_sflow_actions *sflow_actions)
+                        const struct nlattr *actions, size_t actions_len,
+                        struct dpif_sflow_actions *sflow_actions,
+                        bool capture_mpls)
 {
     const struct nlattr *a;
     unsigned int left;
@@ -1099,7 +1100,7 @@ dpif_sflow_read_actions(const struct flow *flow,
        return;
     }
 
-    if (flow != NULL) {
+    if (flow != NULL && capture_mpls == true) {
        /* Make sure the MPLS output stack
         * is seeded with the input stack.
         */
@@ -1198,8 +1199,13 @@ dpif_sflow_read_actions(const struct flow *flow,
             * structure to report this.
             */
            break;
+    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_CLONE:
         case OVS_ACTION_ATTR_PUSH_NSH:
         case OVS_ACTION_ATTR_POP_NSH:
        case OVS_ACTION_ATTR_UNSPEC:
index 74fe58007af07352cbd58844d1842aa937d3d750..c5d9b8aad23f6f6c88663669500f1cb44404e588 100644 (file)
@@ -71,7 +71,7 @@ void dpif_sflow_wait(struct dpif_sflow *);
 
 void dpif_sflow_read_actions(const struct flow *,
                              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 *,
                          const struct flow *, odp_port_t odp_port,
index cb5018d9952c3fd72d2620704c7def896eccc82a..5ddf08a75ec010245a6eb9e8420daa53d2ccb3f2 100644 (file)
@@ -1330,7 +1330,7 @@ dpif_read_actions(struct udpif *udpif, struct upcall *upcall,
 
     switch (type) {
     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;
     case FLOW_SAMPLE_UPCALL:
     case IPFIX_UPCALL:
index aee18bf33d3a42f83fa79e017cbfe2175acfc85a..b85bcacae4f87390a13a83b2eb151733b730acd3 100644 (file)
@@ -3264,6 +3264,9 @@ native_tunnel_output(struct xlate_ctx *ctx, const struct xport *xport,
     char buf_sip6[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. */
     struct flow old_base_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. */
     memcpy(&ctx->xin->flow, &old_flow, sizeof ctx->xin->flow);
     memcpy(&ctx->base_flow, &old_base_flow, sizeof ctx->base_flow);
+
+    /* Restore sFlow data. */
+    ctx->sflow_n_outputs = sflow_n_outputs;
+
     return 0;
 }
 
index a582aaf391b1aa31146aeb2377ad98d27e1d1cd8..1945d222eafcf197722a1519ff9f82390f067fa2 100644 (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])
 
 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
 ovs-vsctl \