X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fnetdev.c;h=6c87bd4b346a11a621c3ebab4cfac4cffbdccc63;hb=cf3a5d915f8d4d0d1a7774430db4f11f161fea70;hp=fb0f98e6e2d2bcbba81c44d474c506c1e21f9532;hpb=6c88d577e83db12f73df12be8fc575419b011fda;p=openvswitch diff --git a/lib/netdev.c b/lib/netdev.c index fb0f98e6..6c87bd4b 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -42,6 +42,7 @@ static const struct netdev_class *netdev_classes[] = { &netdev_linux_class, &netdev_tap_class, + &netdev_gre_class, }; static int n_netdev_classes = ARRAY_SIZE(netdev_classes); @@ -179,9 +180,11 @@ netdev_destroy(const char *name) netdev_obj = node->data; if (netdev_obj->ref_cnt != 0) { - VLOG_WARN("attempt to destroy open netdev object (%d): %s", + VLOG_WARN("attempt to destroy netdev object with %d open handles: %s", netdev_obj->ref_cnt, name); +#if 0 /* Temp hack */ return EBUSY; +#endif } shash_delete(&netdev_obj_shash, node); @@ -273,7 +276,11 @@ netdev_close(struct netdev *netdev) int error; netdev_obj = shash_find_data(&netdev_obj_shash, name); +#if 0 assert(netdev_obj); +#else + if (netdev_obj) { +#endif if (netdev_obj->ref_cnt > 0) { netdev_obj->ref_cnt--; } else { @@ -285,6 +292,9 @@ netdev_close(struct netdev *netdev) if (!netdev_obj->ref_cnt && !netdev_obj->created) { netdev_destroy(name); } +#if 1 + } +#endif /* Restore flags that we changed, if any. */ fatal_signal_block(); @@ -833,9 +843,26 @@ netdev_obj_init(struct netdev_obj *netdev_obj, const char *name, netdev_obj->class = class; netdev_obj->ref_cnt = 0; netdev_obj->created = created; + netdev_obj->name = xstrdup(name); shash_add(&netdev_obj_shash, name, netdev_obj); } +/* Returns the class type of 'netdev_obj'. + * + * The caller must not free the returned value. */ +const char *netdev_obj_get_type(const struct netdev_obj *netdev_obj) +{ + return netdev_obj->class->type; +} + +/* Returns the name of 'netdev_obj'. + * + * The caller must not free the returned value. */ +const char *netdev_obj_get_name(const struct netdev_obj *netdev_obj) +{ + return netdev_obj->name; +} + /* Initializes 'netdev' as a netdev named 'name' of the specified 'class'. * * This function adds 'netdev' to a netdev-owned linked list, so it is very