From 0db63e538decbebb94604e60f0461931f6753fad Mon Sep 17 00:00:00 2001 From: juanmont Date: Sat, 17 Mar 2018 21:07:14 +0100 Subject: [PATCH] B #1680: Prepared nic when instantiate a Virtual Router with FLOATING_IP (#1834) (cherry picked from commit a3d4d353404a623855684dd3370d57c15020b6fd) --- src/vrouter/VirtualRouter.cc | 70 +++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/src/vrouter/VirtualRouter.cc b/src/vrouter/VirtualRouter.cc index 530bc112da..b214c0eeff 100644 --- a/src/vrouter/VirtualRouter.cc +++ b/src/vrouter/VirtualRouter.cc @@ -40,6 +40,40 @@ static const History::VMAction action[15] = { const ActionSet VirtualRouter::SUPPORTED_ACTIONS(action, 15); +/* -------------------------------------------------------------------------- */ + +static void vrouter_prefix(VectorAttribute* nic, const string& attr) +{ + string val; + + if (nic->vector_value(attr.c_str(), val) == 0) + { + nic->remove(attr); + nic->replace("VROUTER_"+attr, val); + } +} + +/* -------------------------------------------------------------------------- */ + +static void prepare_nic_vm(VectorAttribute * nic) +{ + bool floating = false; + nic->vector_value("FLOATING_IP", floating); + + if (floating) + { + vrouter_prefix(nic, "MAC"); + vrouter_prefix(nic, "IP"); + vrouter_prefix(nic, "IP6_LINK"); + vrouter_prefix(nic, "IP6_ULA"); + vrouter_prefix(nic, "IP6_GLOBAL"); + + // TODO: remove all other attrs, such as AR, BRIDGE, etc? + } +} + +/* -------------------------------------------------------------------------- */ + /* ************************************************************************ */ /* VirtualRouter :: Constructor/Destructor */ /* ************************************************************************ */ @@ -209,6 +243,9 @@ int VirtualRouter::get_network_leases(string& estr) { return -1; } + + prepare_nic_vm(nics[i]); + } return 0; @@ -434,39 +471,6 @@ int VirtualRouter::release_network_leases(const VectorAttribute * nic) return 0; } -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -void vrouter_prefix(VectorAttribute* nic, const string& attr) -{ - string val; - - if (nic->vector_value(attr.c_str(), val) == 0) - { - nic->remove(attr); - nic->replace("VROUTER_"+attr, val); - } -} - -/* -------------------------------------------------------------------------- */ - -static void prepare_nic_vm(VectorAttribute * nic) -{ - bool floating = false; - nic->vector_value("FLOATING_IP", floating); - - if (floating) - { - vrouter_prefix(nic, "MAC"); - vrouter_prefix(nic, "IP"); - vrouter_prefix(nic, "IP6_LINK"); - vrouter_prefix(nic, "IP6_ULA"); - vrouter_prefix(nic, "IP6_GLOBAL"); - - // TODO: remove all other attrs, such as AR, BRIDGE, etc? - } -} - /* -------------------------------------------------------------------------- */ Template * VirtualRouter::get_vm_template() const