[ovs-dev] [PATCH 2/4] ofproto-dpif: Store the initial tunnel IP TOS values for later use.

Justin Pettit jpettit at nicira.com
Wed Feb 13 23:31:43 UTC 2013


When a packet arrives on an IP tunnel, store the TOS value for later
use.  This value will be used in a couple of future commits.

Signed-off-by: Justin Pettit <jpettit at nicira.com>
---
 ofproto/ofproto-dpif.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index a3dc855..aac2204 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -293,6 +293,9 @@ struct initial_vals {
      * splinters can cause it to differ.  This value should be removed when
      * the VLAN splinters feature is no longer needed.  */
     uint16_t vlan_tci;
+
+    /* If received on a tunnel, the IP TOS value of the tunnel. */
+    uint8_t tunnel_ip_tos;
 };
 
 static void action_xlate_ctx_init(struct action_xlate_ctx *,
@@ -3651,11 +3654,12 @@ drop_key_clear(struct dpif_backer *backer)
  * flow->vlan_tci correctly for the VLAN of the VLAN splinter port, and pushes
  * a VLAN header onto 'packet' (if it is nonnull).
  *
- * Optionally, if nonnull, sets '*initial_vals->vlan_tci' to the VLAN TCI
- * with which the packet was really received, that is, the actual VLAN
- * TCI extracted by odp_flow_key_to_flow().  (This differs from the
- * value returned in flow->vlan_tci only for packets received on VLAN
- * splinters.)
+ * Optionally, if 'initial_vals' is nonnull, sets '*initial_vals->vlan_tci'
+ * to the VLAN TCI with which the packet was really received, that is, the
+ * actual VLAN TCI extracted by odp_flow_key_to_flow().  (This differs from
+ * the value returned in flow->vlan_tci only for packets received on
+ * VLAN splinters.)  Also, if received on an IP tunnel, sets
+ * '*initial_vals->tunnel_ip_tos' to the tunnel's IP TOS.
  *
  * Similarly, this function also includes some logic to help with tunnels.  It
  * may modify 'flow' as necessary to make the tunneling implementation
@@ -3682,6 +3686,7 @@ ofproto_receive(const struct dpif_backer *backer, struct ofpbuf *packet,
 
     if (initial_vals) {
         initial_vals->vlan_tci = flow->vlan_tci;
+        initial_vals->tunnel_ip_tos = flow->tunnel.ip_tos;
     }
 
     if (odp_in_port) {
@@ -4431,6 +4436,7 @@ facet_learn(struct facet *facet)
     }
 
     initial_vals.vlan_tci = facet->flow.vlan_tci;
+    initial_vals.tunnel_ip_tos = 0;
     action_xlate_ctx_init(&ctx, ofproto, &facet->flow, &initial_vals,
                           facet->rule, facet->tcp_flags, NULL);
     ctx.may_learn = true;
@@ -4922,6 +4928,7 @@ flow_push_stats(struct rule_dpif *rule,
     ofproto_rule_update_used(&rule->up, stats->used);
 
     initial_vals.vlan_tci = flow->vlan_tci;
+    initial_vals.tunnel_ip_tos = 0;
     action_xlate_ctx_init(&ctx, ofproto, flow, &initial_vals, rule,
                           0, NULL);
     ctx.resubmit_stats = stats;
@@ -5443,6 +5450,7 @@ rule_dpif_execute(struct rule_dpif *rule, const struct flow *flow,
     rule_credit_stats(rule, &stats);
 
     initial_vals.vlan_tci = flow->vlan_tci;
+    initial_vals.tunnel_ip_tos = flow->tunnel.ip_tos;
     ofpbuf_use_stub(&odp_actions, odp_actions_stub, sizeof odp_actions_stub);
     action_xlate_ctx_init(&ctx, ofproto, flow, &initial_vals,
                           rule, stats.tcp_flags, packet);
@@ -6525,6 +6533,7 @@ action_xlate_ctx_init(struct action_xlate_ctx *ctx,
     memset(&ctx->flow.tunnel, 0, sizeof ctx->flow.tunnel);
     ctx->base_flow = ctx->flow;
     ctx->base_flow.vlan_tci = initial_vals->vlan_tci;
+    ctx->base_flow.tunnel.ip_tos = initial_vals->tunnel_ip_tos;
     ctx->flow.tunnel.tun_id = initial_tun_id;
     ctx->rule = rule;
     ctx->packet = packet;
@@ -6612,6 +6621,7 @@ xlate_actions(struct action_xlate_ctx *ctx,
         uint32_t local_odp_port;
 
         initial_vals.vlan_tci = ctx->base_flow.vlan_tci;
+        initial_vals.tunnel_ip_tos = 0;
 
         add_sflow_action(ctx);
 
@@ -7372,6 +7382,7 @@ packet_out(struct ofproto *ofproto_, struct ofpbuf *packet,
     dpif_flow_stats_extract(flow, packet, time_msec(), &stats);
 
     initial_vals.vlan_tci = flow->vlan_tci;
+    initial_vals.tunnel_ip_tos = 0;
     action_xlate_ctx_init(&ctx, ofproto, flow, &initial_vals, NULL,
                           packet_get_tcp_flags(packet, flow), packet);
     ctx.resubmit_stats = &stats;
@@ -7674,6 +7685,7 @@ ofproto_unixctl_trace(struct unixctl_conn *conn, int argc, const char *argv[],
             }
 
             initial_vals.vlan_tci = flow.vlan_tci;
+            initial_vals.tunnel_ip_tos = flow.tunnel.ip_tos;
         }
 
         /* Generate a packet, if requested. */
@@ -7708,6 +7720,7 @@ ofproto_unixctl_trace(struct unixctl_conn *conn, int argc, const char *argv[],
         flow_extract(packet, priority, mark, NULL, in_port, &flow);
         flow.tunnel.tun_id = tun_id;
         initial_vals.vlan_tci = flow.vlan_tci;
+        initial_vals.tunnel_ip_tos = flow.tunnel.ip_tos;
     } else {
         unixctl_command_reply_error(conn, "Bad command syntax");
         goto exit;
-- 
1.7.5.4




More information about the dev mailing list