autopath: Create the autopath action.
[sliver-openvswitch.git] / ofproto / ofproto.c
index 8b8b28d..0b85e61 100644 (file)
@@ -24,6 +24,7 @@
 #include <netinet/in.h>
 #include <stdbool.h>
 #include <stdlib.h>
+#include "autopath.h"
 #include "byte-order.h"
 #include "cfm.h"
 #include "classifier.h"
@@ -57,7 +58,6 @@
 #include "shash.h"
 #include "sset.h"
 #include "stream-ssl.h"
-#include "svec.h"
 #include "tag.h"
 #include "timer.h"
 #include "timeval.h"
@@ -544,7 +544,7 @@ ofproto_set_desc(struct ofproto *p,
 }
 
 int
-ofproto_set_snoops(struct ofproto *ofproto, const struct svec *snoops)
+ofproto_set_snoops(struct ofproto *ofproto, const struct sset *snoops)
 {
     return connmgr_set_snoops(ofproto->connmgr, snoops);
 }
@@ -553,7 +553,7 @@ int
 ofproto_set_netflow(struct ofproto *ofproto,
                     const struct netflow_options *nf_options)
 {
-    if (nf_options && nf_options->collectors.n) {
+    if (nf_options && !sset_is_empty(&nf_options->collectors)) {
         if (!ofproto->netflow) {
             ofproto->netflow = netflow_create();
         }
@@ -668,8 +668,14 @@ ofproto_get_fail_mode(const struct ofproto *p)
     return connmgr_get_fail_mode(p->connmgr);
 }
 
+bool
+ofproto_has_snoops(const struct ofproto *ofproto)
+{
+    return connmgr_has_snoops(ofproto->connmgr);
+}
+
 void
-ofproto_get_snoops(const struct ofproto *ofproto, struct svec *snoops)
+ofproto_get_snoops(const struct ofproto *ofproto, struct sset *snoops)
 {
     connmgr_get_snoops(ofproto->connmgr, snoops);
 }
@@ -1159,8 +1165,8 @@ ofport_run(struct ofproto *ofproto, struct ofport *ofport)
             struct ccm *ccm;
 
             ofpbuf_init(&packet, 0);
-            ccm = compose_packet(&packet, eth_addr_ccm, ofport->opp.hw_addr,
-                                 ETH_TYPE_CFM,  sizeof *ccm);
+            ccm = eth_compose(&packet, eth_addr_ccm, ofport->opp.hw_addr,
+                              ETH_TYPE_CFM,  sizeof *ccm);
             cfm_compose_ccm(ofport->cfm, ccm);
             ofproto_send_packet(ofproto, ofport->odp_port, 0, &packet);
             ofpbuf_uninit(&packet);
@@ -2217,8 +2223,11 @@ xlate_nicira_action(struct action_xlate_ctx *ctx,
     const struct nx_action_set_tunnel *nast;
     const struct nx_action_set_queue *nasq;
     const struct nx_action_multipath *nam;
+    const struct nx_action_autopath *naa;
     enum nx_action_subtype subtype = ntohs(nah->subtype);
+    const struct ofhooks *ofhooks = ctx->ofproto->ofhooks;
     struct xlate_reg_state state;
+    uint16_t autopath_port;
     ovs_be64 tun_id;
 
     assert(nah->vendor == htonl(NX_VENDOR_ID));
@@ -2280,6 +2289,15 @@ xlate_nicira_action(struct action_xlate_ctx *ctx,
         multipath_execute(nam, &ctx->flow);
         break;
 
+    case NXAST_AUTOPATH:
+        naa = (const struct nx_action_autopath *) nah;
+        autopath_port = (ofhooks->autopath_cb
+                         ? ofhooks->autopath_cb(&ctx->flow, ntohl(naa->id),
+                                                &ctx->tags, ctx->ofproto->aux)
+                         : OFPP_NONE);
+        autopath_execute(naa, &ctx->flow, autopath_port);
+        break;
+
     /* If you add a new action here that modifies flow data, don't forget to
      * update the flow key in ctx->flow at the same time. */
 
@@ -4410,5 +4428,6 @@ static const struct ofhooks default_ofhooks = {
     default_normal_ofhook_cb,
     NULL,
     NULL,
+    NULL,
     NULL
 };