Replace most uses of assert by ovs_assert.
[sliver-openvswitch.git] / lib / route-table.c
index a0c8121..5bdcfb0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Nicira Networks.
+ * Copyright (c) 2011, 2012 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 "route-table.h"
 
-#include <assert.h>
 #include <arpa/inet.h>
 #include <sys/socket.h>
 #include <linux/rtnetlink.h>
@@ -161,8 +160,8 @@ void
 route_table_register(void)
 {
     if (!register_count) {
-        assert(!nln);
-        assert(!route_notifier);
+        ovs_assert(!nln);
+        ovs_assert(!route_notifier);
 
         nln = nln_create(NETLINK_ROUTE, RTNLGRP_IPV4_ROUTE,
                          (nln_parse_func *) route_table_parse, &rtmsg);
@@ -188,6 +187,8 @@ route_table_unregister(void)
     register_count--;
 
     if (!register_count) {
+        nln_notifier_destroy(route_notifier);
+        route_notifier = NULL;
         nln_destroy(nln);
         nln = NULL;
 
@@ -244,6 +245,7 @@ route_table_reset(void)
     rtmsg->rtgen_family = AF_INET;
 
     nl_dump_start(&dump, rtnl_sock, &request);
+    ofpbuf_uninit(&request);
 
     while (nl_dump_next(&dump, &reply)) {
         struct route_table_msg msg;
@@ -435,6 +437,8 @@ name_table_reset(void)
     rtmsg->rtgen_family = AF_INET;
 
     nl_dump_start(&dump, rtnl_sock, &request);
+    ofpbuf_uninit(&request);
+
     while (nl_dump_next(&dump, &reply)) {
         struct rtnetlink_link_change change;