netdev: New function netdev_ref().
[sliver-openvswitch.git] / lib / netdev.c
index 5c2e9f5..5aae01c 100644 (file)
@@ -277,6 +277,17 @@ netdev_open(const char *name, const char *type, struct netdev **netdevp)
     return 0;
 }
 
+/* Returns a reference to 'netdev_' for the caller to own. */
+struct netdev *
+netdev_ref(const struct netdev *netdev_)
+{
+    struct netdev *netdev = CONST_CAST(struct netdev *, netdev_);
+
+    ovs_assert(netdev->ref_cnt > 0);
+    netdev->ref_cnt++;
+    return netdev;
+}
+
 /* Reconfigures the device 'netdev' with 'args'.  'args' may be empty
  * or NULL if none are needed. */
 int