From 12c6e6ea42d724db197d5b63276442c9b6ac0e6b Mon Sep 17 00:00:00 2001 From: Giuseppe Lettieri Date: Thu, 20 Dec 2012 13:25:14 +0000 Subject: [PATCH] proper handling of the DOWN flag --- lib/netdev-pltap.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/netdev-pltap.c b/lib/netdev-pltap.c index 257cc6d13..b7ebed935 100644 --- a/lib/netdev-pltap.c +++ b/lib/netdev-pltap.c @@ -338,6 +338,37 @@ cleanup: return error; } +static int +netdev_pltap_down(struct netdev_dev_pltap *dev) +{ + int error; + char *msg = NULL, *reply = NULL; + const size_t reply_size = 1024; + + if (!netdev_pltap_finalized(dev)) { + return 0; + } + + msg = xasprintf("%s\n", dev->real_name); + reply = (char*)xmalloc(reply_size); + if (!msg || !reply) { + VLOG_ERR("Out of memory\n"); + error = ENOMEM; + goto cleanup; + } + error = vsys_transaction("vif_down", msg, reply, reply_size); + if (error) { + goto cleanup; + } + netdev_pltap_update_seq(dev); + +cleanup: + free(msg); + free(reply); + + return error; +} + static void netdev_pltap_sync_flags(struct netdev_dev_pltap *dev) { @@ -357,7 +388,9 @@ netdev_pltap_sync_flags(struct netdev_dev_pltap *dev) if ((dev->new_flags & NETDEV_UP) && !(dev->flags & NETDEV_UP)) { (void) netdev_pltap_up(dev); - } /* TODO: implement the down case */ + } else if (!(dev->new_flags & NETDEV_UP) && (dev->flags & NETDEV_UP)) { + (void) netdev_pltap_down(dev); + } if ((dev->new_flags & NETDEV_PROMISC) ^ (dev->flags & NETDEV_PROMISC)) { msg = xasprintf("%s\n%s", -- 2.43.0