diff --git a/lib/netdev.c b/lib/netdev.c index 12d3ab4..3b6fbc5 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -202,6 +202,7 @@ get_ipv6_address(const char *name, struct in6_addr *in6) "classid %x:%x htb rate %dkbit ceil %dkbit" #define COMMAND_CHANGE_CLASS "/sbin/tc class change dev %s parent %x:%x " \ "classid %x:%x htb rate %dkbit ceil %dkbit" +#define COMMAND_DEL_CLASS "/sbin/tc class del dev %s parent %x:%x classid %x:%x" static int netdev_setup_root_class(const struct netdev *netdev, uint16_t class_id, @@ -288,6 +289,30 @@ netdev_change_class(const struct netdev *netdev, uint16_t class_id, uint16_t rat return 0; } +/** Deletes a class already defined to represent an OpenFlow queue. + * + * @param netdev the device under configuration + * @param class_id unique identifier for this queue. + * @param rate the minimum rate for this queue in kbps + * @return 0 on success, non-zero value when the configuration was not + * successful. + */ +int +netdev_delete_class(const struct netdev *netdev, uint16_t class_id) +{ + char command[1024]; + + snprintf(command, sizeof(command), COMMAND_DEL_CLASS, netdev->name, + TC_QDISC, TC_ROOT_CLASS, TC_QDISC, class_id); + if (system(command) != 0) { + VLOG_ERR("Problem deleting class %d for device %s",class_id, + netdev->name); + return -1; + } + + return 0; +} + static int open_queue_socket(const char * name, uint16_t class_id, int * fd) { diff --git a/lib/netdev.h b/lib/netdev.h index 2d0e840..b1937bb 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -98,6 +98,7 @@ int netdev_arp_lookup(const struct netdev *, uint32_t ip, uint8_t mac[6]); int netdev_setup_slicing(struct netdev *, uint16_t); int netdev_setup_class(const struct netdev *, uint16_t , uint16_t); int netdev_change_class(const struct netdev *, uint16_t , uint16_t); +int netdev_delete_class(const struct netdev *, uint16_t); void netdev_enumerate(struct svec *); int netdev_nodev_get_flags(const char *netdev_name, enum netdev_flags *); diff --git a/udatapath/of_ext_msg.c b/udatapath/of_ext_msg.c index f58f03d..680b9dd 100644 --- a/udatapath/of_ext_msg.c +++ b/udatapath/of_ext_msg.c @@ -107,6 +107,7 @@ recv_of_exp_queue_delete(struct datapath *dp, if (p->netdev) { q = dp_lookup_queue(p,queue_id); if (q) { + netdev_delete_class(p->netdev,q->class_id); port_delete_queue(p,q); } else {