From 831372003d3701fb3cf82168fe114d60c710b1b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 18 Dec 2015 17:10:48 +0100 Subject: [PATCH] Feature #4215: Support IPv6 in VR management --- .../public/app/tabs/vnets-topology-tab.js | 16 +++++++++--- src/vrouter/VirtualRouter.cc | 25 +++++++++++++------ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/sunstone/public/app/tabs/vnets-topology-tab.js b/src/sunstone/public/app/tabs/vnets-topology-tab.js index a5864d395c..a6cb8de539 100644 --- a/src/sunstone/public/app/tabs/vnets-topology-tab.js +++ b/src/sunstone/public/app/tabs/vnets-topology-tab.js @@ -167,8 +167,6 @@ define(function(require) { } } - // TODO: VR edges with floating IPs - $.each(vrs, function(j,vr){ var nodeId = "vr"+vr; @@ -223,9 +221,14 @@ define(function(require) { var label = undefined; - // TODO: IPv6 IPs if (lease.IP != undefined){ label = lease.IP; + } else if (lease.IP6_GLOBAL != undefined){ + label = lease.IP6_GLOBAL; + } else if (lease.IP6_ULA != undefined){ + label = lease.IP6_ULA; + } else if (lease.IP6_LINK != undefined){ + label = lease.IP6_LINK; } edges.push({from: vnetNodeId, to: nodeId, label: label}); @@ -242,9 +245,14 @@ define(function(require) { var label = undefined; - // TODO: IPv6 IPs if (lease.IP != undefined){ label = lease.IP; + } else if (lease.IP6_GLOBAL != undefined){ + label = lease.IP6_GLOBAL; + } else if (lease.IP6_ULA != undefined){ + label = lease.IP6_ULA; + } else if (lease.IP6_LINK != undefined){ + label = lease.IP6_LINK; } edges.push({from: vnetNodeId, to: nodeId, label: label}); diff --git a/src/vrouter/VirtualRouter.cc b/src/vrouter/VirtualRouter.cc index 5cb10d5bc0..4707604222 100644 --- a/src/vrouter/VirtualRouter.cc +++ b/src/vrouter/VirtualRouter.cc @@ -401,13 +401,25 @@ int VirtualRouter::release_network_leases(VectorAttribute const * nic) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +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); + } +} + +/* -------------------------------------------------------------------------- */ + Template * VirtualRouter::get_nics() const { Template * tmpl = new Template(); int num_nics; bool floating; - string ip; vector nics; VectorAttribute * nic; @@ -429,13 +441,12 @@ Template * VirtualRouter::get_nics() const if (floating) { - // TODO: this is IPv4 only nic->remove("MAC"); - if (nic->vector_value("IP", ip) == 0) - { - nic->remove("IP"); - nic->replace("VROUTER_IP", ip); - } + + 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? }