Setting tag sliver-openvswitch-2.2.90-1
[sliver-openvswitch.git] / lib / netlink-notifier.c
index 9446488..9aa185d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, 2011 Nicira Networks.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@
 
 #include "netlink-notifier.h"
 
-#include <assert.h>
 #include <errno.h>
 #include <poll.h>
 #include <stdlib.h>
@@ -42,7 +41,7 @@ struct nln {
 
     /* Passed in by nln_create(). */
     int multicast_group;         /* Multicast group we listen on. */
-    int protocol;                /* Protocal passed to nl_sock_create(). */
+    int protocol;                /* Protocol passed to nl_sock_create(). */
     nln_parse_func *parse;       /* Message parsing function. */
     void *change;                /* Change passed to parse. */
 };
@@ -87,7 +86,7 @@ void
 nln_destroy(struct nln *nln)
 {
     if (nln) {
-        assert(list_is_empty(&nln->all_notifiers));
+        ovs_assert(list_is_empty(&nln->all_notifiers));
         nl_sock_destroy(nln->notify_sock);
         free(nln);
     }
@@ -116,7 +115,8 @@ nln_notifier_create(struct nln *nln, nln_notify_func *cb, void *aux)
         }
         if (error) {
             nl_sock_destroy(sock);
-            VLOG_WARN("could not create netlink socket: %s", strerror(error));
+            VLOG_WARN("could not create netlink socket: %s",
+                      ovs_strerror(error));
             return NULL;
         }
         nln->notify_sock = sock;
@@ -164,18 +164,20 @@ nln_run(struct nln *nln)
 
     nln->has_run = true;
     for (;;) {
-        struct ofpbuf *buf;
+        uint64_t buf_stub[4096 / 8];
+        struct ofpbuf buf;
         int error;
 
+        ofpbuf_use_stub(&buf, buf_stub, sizeof buf_stub);
         error = nl_sock_recv(nln->notify_sock, &buf, false);
         if (!error) {
-            if (nln->parse(buf, nln->change)) {
+            if (nln->parse(&buf, nln->change)) {
                 nln_report(nln, nln->change);
             } else {
                 VLOG_WARN_RL(&rl, "received bad netlink message");
                 nln_report(nln, NULL);
             }
-            ofpbuf_delete(buf);
+            ofpbuf_uninit(&buf);
         } else if (error == EAGAIN) {
             return;
         } else {
@@ -183,7 +185,7 @@ nln_run(struct nln *nln)
                 VLOG_WARN_RL(&rl, "netlink receive buffer overflowed");
             } else {
                 VLOG_WARN_RL(&rl, "error reading netlink socket: %s",
-                             strerror(error));
+                             ovs_strerror(error));
             }
             nln_report(nln, NULL);
         }