For SNAT, don't store the pre-fragment L2 header before actions are applied.
[sliver-openvswitch.git] / lib / vconn-netlink.c
index 625b524..a0fcc8d 100644 (file)
@@ -31,6 +31,7 @@
  * derivatives without specific, written prior permission.
  */
 
+#include <config.h>
 #include "vconn.h"
 #include <arpa/inet.h>
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include "openflow-netlink.h"
-#include "buffer.h"
 #include "dpif.h"
 #include "netlink.h"
+#include "ofpbuf.h"
+#include "openflow/openflow-netlink.h"
+#include "openflow/openflow.h"
 #include "poll-loop.h"
 #include "socket-util.h"
 #include "util.h"
-#include "openflow.h"
+#include "vconn-provider.h"
 
 #include "vlog.h"
 #define THIS_MODULE VLM_VCONN_NETLINK
@@ -63,7 +65,7 @@ struct netlink_vconn
 static struct netlink_vconn *
 netlink_vconn_cast(struct vconn *vconn) 
 {
-    assert(vconn->class == &netlink_vconn_class);
+    vconn_assert_class(vconn, &netlink_vconn_class);
     return CONTAINER_OF(vconn, struct netlink_vconn, vconn); 
 }
 
@@ -72,16 +74,18 @@ netlink_open(const char *name, char *suffix, struct vconn **vconnp)
 {
     struct netlink_vconn *netlink;
     int dp_idx;
+    int subscribe;
     int retval;
 
-    if (sscanf(suffix, "%d", &dp_idx) != 1) {
-        fatal(0, "%s: bad peer name format", name);
+    subscribe = 1;
+    if (sscanf(suffix, "%d:%d", &dp_idx, &subscribe) < 1) {
+        ofp_error(0, "%s: syntax error", name);
+        return EAFNOSUPPORT;
     }
 
     netlink = xmalloc(sizeof *netlink);
-    netlink->vconn.class = &netlink_vconn_class;
-    netlink->vconn.connect_status = 0;
-    retval = dpif_open(dp_idx, true, &netlink->dp);
+    vconn_init(&netlink->vconn, &netlink_vconn_class, 0, 0, name);
+    retval = dpif_open(dp_idx, subscribe, &netlink->dp);
     if (retval) {
         free(netlink);
         *vconnp = NULL;
@@ -100,19 +104,19 @@ netlink_close(struct vconn *vconn)
 }
 
 static int
-netlink_recv(struct vconn *vconn, struct buffer **bufferp)
+netlink_recv(struct vconn *vconn, struct ofpbuf **bufferp)
 {
     struct netlink_vconn *netlink = netlink_vconn_cast(vconn);
     return dpif_recv_openflow(&netlink->dp, bufferp, false);
 }
 
 static int
-netlink_send(struct vconn *vconn, struct buffer *buffer) 
+netlink_send(struct vconn *vconn, struct ofpbuf *buffer) 
 {
     struct netlink_vconn *netlink = netlink_vconn_cast(vconn);
     int retval = dpif_send_openflow(&netlink->dp, buffer, false);
     if (!retval) {
-        buffer_delete(buffer);
+        ofpbuf_delete(buffer);
     }
     return retval;
 }
@@ -134,14 +138,15 @@ netlink_wait(struct vconn *vconn, enum vconn_wait_type wait)
     default:
         NOT_REACHED();
     }
-    poll_fd_wait(nl_sock_fd(netlink->dp.sock), events, NULL);
+    poll_fd_wait(nl_sock_fd(netlink->dp.sock), events);
 }
 
 struct vconn_class netlink_vconn_class = {
-    .name = "nl",
-    .open = netlink_open,
-    .close = netlink_close,
-    .recv = netlink_recv,
-    .send = netlink_send,
-    .wait = netlink_wait,
+    "nl",                       /* name */
+    netlink_open,               /* open */
+    netlink_close,              /* close */
+    NULL,                       /* connect */
+    netlink_recv,               /* recv */
+    netlink_send,               /* send */
+    netlink_wait,               /* wait */
 };