Extend sFlow agent to report tunnel and MPLS structures
[cascardo/ovs.git] / lib / dpif-netlink.c
index 15f83b9..8884a9f 100644 (file)
@@ -768,6 +768,9 @@ get_vport_type(const struct dpif_netlink_vport *vport)
     case OVS_VPORT_TYPE_LISP:
         return "lisp";
 
+    case OVS_VPORT_TYPE_STT:
+        return "stt";
+
     case OVS_VPORT_TYPE_UNSPEC:
     case __OVS_VPORT_TYPE_MAX:
         break;
@@ -787,6 +790,8 @@ netdev_to_ovs_vport_type(const struct netdev *netdev)
         return OVS_VPORT_TYPE_NETDEV;
     } else if (!strcmp(type, "internal")) {
         return OVS_VPORT_TYPE_INTERNAL;
+    } else if (strstr(type, "stt")) {
+        return OVS_VPORT_TYPE_STT;
     } else if (!strcmp(type, "geneve")) {
         return OVS_VPORT_TYPE_GENEVE;
     } else if (strstr(type, "gre64")) {
@@ -867,8 +872,8 @@ dpif_netlink_port_add__(struct dpif_netlink *dpif, struct netdev *netdev,
             }
             nl_msg_end_nested(&options, ext_ofs);
         }
-        request.options = ofpbuf_data(&options);
-        request.options_len = ofpbuf_size(&options);
+        request.options = options.data;
+        request.options_len = options.size;
     }
 
     request.port_no = *port_nop;
@@ -1335,8 +1340,8 @@ dpif_netlink_init_flow_del(struct dpif_netlink *dpif,
                            const struct dpif_flow_del *del,
                            struct dpif_netlink_flow *request)
 {
-    return dpif_netlink_init_flow_del__(dpif, del->key, del->key_len,
-                                        del->ufid, del->terse, request);
+    dpif_netlink_init_flow_del__(dpif, del->key, del->key_len,
+                                 del->ufid, del->terse, request);
 }
 
 struct dpif_netlink_flow_dump {
@@ -1469,7 +1474,7 @@ dpif_netlink_flow_dump_next(struct dpif_flow_dump_thread *thread_,
 
     n_flows = 0;
     while (!n_flows
-           || (n_flows < max_flows && ofpbuf_size(&thread->nl_flows))) {
+           || (n_flows < max_flows && thread->nl_flows.size)) {
         struct dpif_netlink_flow datapath_flow;
         struct ofpbuf nl_flow;
         int error;
@@ -1964,6 +1969,7 @@ parse_odp_packet(const struct dpif_netlink *dpif, struct ofpbuf *buf,
         /* OVS_PACKET_CMD_ACTION only. */
         [OVS_PACKET_ATTR_USERDATA] = { .type = NL_A_UNSPEC, .optional = true },
         [OVS_PACKET_ATTR_EGRESS_TUN_KEY] = { .type = NL_A_NESTED, .optional = true },
+        [OVS_PACKET_ATTR_ACTIONS] = { .type = NL_A_NESTED, .optional = true },
     };
 
     struct ovs_header *ovs_header;
@@ -1973,7 +1979,7 @@ parse_odp_packet(const struct dpif_netlink *dpif, struct ofpbuf *buf,
     struct ofpbuf b;
     int type;
 
-    ofpbuf_use_const(&b, ofpbuf_data(buf), ofpbuf_size(buf));
+    ofpbuf_use_const(&b, buf->data, buf->size);
 
     nlmsg = ofpbuf_try_pull(&b, sizeof *nlmsg);
     genl = ofpbuf_try_pull(&b, sizeof *genl);
@@ -2000,6 +2006,7 @@ parse_odp_packet(const struct dpif_netlink *dpif, struct ofpbuf *buf,
     dpif_flow_hash(&dpif->dpif, upcall->key, upcall->key_len, &upcall->ufid);
     upcall->userdata = a[OVS_PACKET_ATTR_USERDATA];
     upcall->out_tun_key = a[OVS_PACKET_ATTR_EGRESS_TUN_KEY];
+    upcall->actions = a[OVS_PACKET_ATTR_ACTIONS];
 
     /* Allow overwriting the netlink attribute header without reallocating. */
     dp_packet_use_stub(&upcall->packet,
@@ -2274,6 +2281,7 @@ dpif_netlink_get_datapath_version(void)
 
 const struct dpif_class dpif_netlink_class = {
     "system",
+    NULL,                       /* init */
     dpif_netlink_enumerate,
     NULL,
     dpif_netlink_open,
@@ -2393,7 +2401,7 @@ dpif_netlink_vport_from_ofpbuf(struct dpif_netlink_vport *vport,
 
     dpif_netlink_vport_init(vport);
 
-    ofpbuf_use_const(&b, ofpbuf_data(buf), ofpbuf_size(buf));
+    ofpbuf_use_const(&b, buf->data, buf->size);
     nlmsg = ofpbuf_try_pull(&b, sizeof *nlmsg);
     genl = ofpbuf_try_pull(&b, sizeof *genl);
     ovs_header = ofpbuf_try_pull(&b, sizeof *ovs_header);
@@ -2561,7 +2569,7 @@ dpif_netlink_dp_from_ofpbuf(struct dpif_netlink_dp *dp, const struct ofpbuf *buf
 
     dpif_netlink_dp_init(dp);
 
-    ofpbuf_use_const(&b, ofpbuf_data(buf), ofpbuf_size(buf));
+    ofpbuf_use_const(&b, buf->data, buf->size);
     nlmsg = ofpbuf_try_pull(&b, sizeof *nlmsg);
     genl = ofpbuf_try_pull(&b, sizeof *genl);
     ovs_header = ofpbuf_try_pull(&b, sizeof *ovs_header);
@@ -2719,7 +2727,7 @@ dpif_netlink_flow_from_ofpbuf(struct dpif_netlink_flow *flow,
 
     dpif_netlink_flow_init(flow);
 
-    ofpbuf_use_const(&b, ofpbuf_data(buf), ofpbuf_size(buf));
+    ofpbuf_use_const(&b, buf->data, buf->size);
     nlmsg = ofpbuf_try_pull(&b, sizeof *nlmsg);
     genl = ofpbuf_try_pull(&b, sizeof *genl);
     ovs_header = ofpbuf_try_pull(&b, sizeof *ovs_header);