netdev-linux: HFSC in linux
[openvswitch] / ofproto / ofproto.c
index dbde7c04630f84d3cc8d3c51d6ec287d33272ead..4403a53448fd8f1708d5004312ef3b0f9f7d2451 100644 (file)
@@ -88,7 +88,7 @@ struct rule {
     uint16_t idle_timeout;      /* In seconds from time of last use. */
     uint16_t hard_timeout;      /* In seconds from time of creation. */
     bool send_flow_removed;     /* Send a flow removed message? */
-    long long int used;         /* Last-used time (0 if never used). */
+    long long int used;         /* Time last used; time created if not used. */
     long long int created;      /* Creation time. */
     uint64_t packet_count;      /* Number of packets received. */
     uint64_t byte_count;        /* Number of bytes received. */
@@ -1298,15 +1298,21 @@ ofproto_send_packet(struct ofproto *p, const struct flow *flow,
     return 0;
 }
 
+/* Adds a flow to the OpenFlow flow table in 'p' that matches 'cls_rule' and
+ * performs the 'n_actions' actions in 'actions'.  The new flow will not
+ * timeout.
+ *
+ * If cls_rule->priority is in the range of priorities supported by OpenFlow
+ * (0...65535, inclusive) then the flow will be visible to OpenFlow
+ * controllers; otherwise, it will be hidden.
+ *
+ * The caller retains ownership of 'cls_rule' and 'actions'. */
 void
 ofproto_add_flow(struct ofproto *p, const struct cls_rule *cls_rule,
-                 const union ofp_action *actions, size_t n_actions,
-                 int idle_timeout)
+                 const union ofp_action *actions, size_t n_actions)
 {
     struct rule *rule;
-    rule = rule_create(p, NULL, actions, n_actions,
-                       idle_timeout >= 0 ? idle_timeout : 5 /* XXX */,
-                       0, 0, false);
+    rule = rule_create(p, NULL, actions, n_actions, 0, 0, 0, false);
     rule->cr = *cls_rule;
     rule_insert(p, rule, NULL, 0);
 }
@@ -1854,7 +1860,7 @@ rule_create(struct ofproto *ofproto, struct rule *super,
         rule->n_actions = n_actions;
         rule->actions = xmemdup(actions, n_actions * sizeof *actions);
     }
-    netflow_flow_clear(&rule->nf_flow);
+    netflow_flow_init(&rule->nf_flow);
     netflow_flow_update_time(ofproto->netflow, &rule->nf_flow, rule->created);
 
     return rule;
@@ -2102,7 +2108,6 @@ rule_make_actions(struct ofproto *p, struct rule *rule,
     assert(!rule->cr.wc.wildcards);
 
     super = rule->super ? rule->super : rule;
-    rule->tags = 0;
     xlate_actions(super->actions, super->n_actions, &rule->cr.flow, p,
                   packet, &a, &rule->tags, &rule->may_install,
                   &rule->nf_flow.output_iface);
@@ -2431,7 +2436,7 @@ struct action_xlate_ctx {
 
     /* Output. */
     struct odp_actions *out;    /* Datapath actions. */
-    tag_type *tags;             /* Tags associated with OFPP_NORMAL actions. */
+    tag_type tags;              /* Tags associated with OFPP_NORMAL actions. */
     bool may_set_up_flow;       /* True ordinarily; false if the actions must
                                  * be reassessed for every packet. */
     uint16_t nf_output_iface;   /* Output interface index for NetFlow. */
@@ -2551,7 +2556,7 @@ xlate_output_action__(struct action_xlate_ctx *ctx,
         break;
     case OFPP_NORMAL:
         if (!ctx->ofproto->ofhooks->normal_cb(&ctx->flow, ctx->packet,
-                                              ctx->out, ctx->tags,
+                                              ctx->out, &ctx->tags,
                                               &ctx->nf_output_iface,
                                               ctx->ofproto->aux)) {
             COVERAGE_INC(ofproto_uninstallable);
@@ -2859,8 +2864,8 @@ xlate_actions(const union ofp_action *in, size_t n_in,
               struct odp_actions *out, tag_type *tags, bool *may_set_up_flow,
               uint16_t *nf_output_iface)
 {
-    tag_type no_tags = 0;
     struct action_xlate_ctx ctx;
+
     COVERAGE_INC(ofproto_ofp2odp);
     odp_actions_init(out);
     ctx.flow = *flow;
@@ -2868,7 +2873,7 @@ xlate_actions(const union ofp_action *in, size_t n_in,
     ctx.ofproto = ofproto;
     ctx.packet = packet;
     ctx.out = out;
-    ctx.tags = tags ? tags : &no_tags;
+    ctx.tags = 0;
     ctx.may_set_up_flow = true;
     ctx.nf_output_iface = NF_OUT_DROP;
     do_xlate_actions(in, n_in, &ctx);
@@ -2880,6 +2885,9 @@ xlate_actions(const union ofp_action *in, size_t n_in,
         ctx.may_set_up_flow = false;
     }
 
+    if (tags) {
+        *tags = ctx.tags;
+    }
     if (may_set_up_flow) {
         *may_set_up_flow = ctx.may_set_up_flow;
     }
@@ -4823,8 +4831,7 @@ revalidate_rule(struct ofproto *p, struct rule *rule)
             rule->super = super;
             rule->hard_timeout = super->hard_timeout;
             rule->idle_timeout = super->idle_timeout;
-            rule->created = super->created;
-            rule->used = 0;
+            rule->created = rule->used = super->created;
         }
     }