aboutsummaryrefslogtreecommitdiffstats
path: root/vicn/resource/vpp
diff options
context:
space:
mode:
authorMarcel Enguehard <mengueha+fdio@cisco.com>2017-05-15 16:26:27 +0200
committerMarcel Enguehard <mengueha+fdio@cisco.com>2017-05-15 16:26:27 +0200
commit895a6328d6e64948ed213e8fbbb3ab15aca0df43 (patch)
tree2c85049fcf73c445ea25097b4753299568061538 /vicn/resource/vpp
parent548479d60dafb24eddcec3762aa558f13581cdb2 (diff)
IPv6 dataplane support + Decentralized IPv4 prefix attribution + Bug fix for attribute default values handling + Various fixes
Change-Id: I0a26eda064d9e22d9d55fd568748076148f49645 Signed-off-by: Marcel Enguehard <mengueha+fdio@cisco.com>
Diffstat (limited to 'vicn/resource/vpp')
-rw-r--r--vicn/resource/vpp/interface.py29
-rw-r--r--vicn/resource/vpp/vpp_bridge.py26
-rw-r--r--vicn/resource/vpp/vpp_commands.py2
3 files changed, 32 insertions, 25 deletions
diff --git a/vicn/resource/vpp/interface.py b/vicn/resource/vpp/interface.py
index efe4fe5a..5f8f5018 100644
--- a/vicn/resource/vpp/interface.py
+++ b/vicn/resource/vpp/interface.py
@@ -35,15 +35,16 @@ class VPPInterface(Resource):
An interface representation in VPP
"""
- vpp = Attribute(VPP,
+ vpp = Attribute(VPP,
description = 'Forwarder to which this interface belong to',
mandatory = True,
multiplicity = Multiplicity.ManyToOne,
key = True,
- reverse_name = 'interfaces')
- parent = Attribute(Interface, description = 'parent',
- mandatory = True, reverse_name = 'vppinterface')
- ip_address = Attribute(String)
+ reverse_name = 'interfaces')
+ parent = Attribute(Interface, description = 'parent',
+ mandatory = True, reverse_name = 'vppinterface')
+ ip4_address = Attribute(String)
+ ip6_address = Attribute(String)
prefix_len = Attribute(Integer, default = 31)
up = Attribute(Bool, description = 'Interface up/down status')
monitored = Attribute(Bool, default = True)
@@ -73,7 +74,8 @@ class VPPInterface(Resource):
# belongs to vpp
self.parent.has_vpp_child = True
- self.ip_address = self.parent.ip_address
+ self.ip4_address = self.parent.ip4_address
+ self.ip6_address = self.parent.ip6_address
self.up = True
if isinstance(self.parent,NonTapBaseNetDevice):
@@ -86,7 +88,8 @@ class VPPInterface(Resource):
{'vpp_interface': self},
lock = self.vpp.vppctl_lock)
- self.parent.set('ip_address', None)
+ self.parent.set('ip4_address', None)
+ self.parent.set('ip6_address', None)
self.parent.set('offload', False)
self.parent.remote.set('offload', False)
@@ -107,8 +110,8 @@ class VPPInterface(Resource):
# Attributes
#--------------------------------------------------------------------------
- def _set_ip_address(self):
- if self.ip_address:
+ def _set_ip4_address(self):
+ if self.ip4_address:
return BashTask(self.vpp.node, CMD_VPP_SET_IP, {'netdevice': self},
lock = self.vpp.vppctl_lock)
@@ -121,5 +124,9 @@ class VPPInterface(Resource):
return {'up' : False}
@task
- def _get_ip_address(self):
- return {'ip_address' : None}
+ def _get_ip4_address(self):
+ return {'ip4_address' : None}
+
+ @task
+ def _get_ip6_address(self):
+ return {'ip6_address' : None}
diff --git a/vicn/resource/vpp/vpp_bridge.py b/vicn/resource/vpp/vpp_bridge.py
index c7a70c02..612145d9 100644
--- a/vicn/resource/vpp/vpp_bridge.py
+++ b/vicn/resource/vpp/vpp_bridge.py
@@ -40,8 +40,8 @@ class VPPBridge(Channel, LinuxApplication):
"""
Resource: VPPBridge
- VPPBridge instantiate a vpp resource and set it as a vpp bridge.
-
+ VPPBridge instantiate a vpp resource and set it as a vpp bridge.
+
This resource requires to be run within a LxcContainer which will have VPP.
Every interface in the lxc_container (i.e., the ones contained in
self.node.interfaces) will be added to the vpp bridge. To connect other vpp
@@ -64,7 +64,7 @@ class VPPBridge(Channel, LinuxApplication):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._vpp_interfaces = list()
-
+
#--------------------------------------------------------------------------
# Resource lifecycle
#--------------------------------------------------------------------------
@@ -72,7 +72,7 @@ class VPPBridge(Channel, LinuxApplication):
def __subresources__ (self):
# We don't need any reference to the list of SymVethPair because each
# side of a veth will be included in the node.interfaces list
- self._veths = [SymVethPair(node1 = self.node, node2 = node,
+ self._veths = [SymVethPair(node1 = self.node, node2 = node,
owner = self) for node in self.connected_nodes]
return Resource.__concurrent__(*self._veths)
@@ -82,7 +82,7 @@ class VPPBridge(Channel, LinuxApplication):
# Add the veth side on the connected_nodes to the set of interfaces of
# the channel
self.interfaces.extend([veth.side2 for veth in self._veths])
-
+
@task
def __get__(self):
# Forces creation
@@ -90,10 +90,10 @@ class VPPBridge(Channel, LinuxApplication):
# Nothing to do
__delete__ = None
-
+
def __create__(self):
manager = self._state.manager
-
+
# Create a VPPInterface for each interface in the node. These will be
# the interfaces we will connect to the vpp bridge process
vpp_interfaces = list()
@@ -102,9 +102,9 @@ class VPPBridge(Channel, LinuxApplication):
if interface.device_name == 'eth0':
continue
- vpp_interface = VPPInterface(vpp = self.node.vpp,
- parent = interface,
- ip_address = Reference(interface, 'ip_address'),
+ vpp_interface = VPPInterface(vpp = self.node.vpp,
+ parent = interface,
+ ip4_address = Reference(interface, 'ip4_address'),
device_name = 'host-' + interface.device_name)
vpp_interfaces.append(vpp_interface)
manager.commit_resource(vpp_interface)
@@ -112,17 +112,17 @@ class VPPBridge(Channel, LinuxApplication):
tasks = EmptyTask()
for vpp_interface in vpp_interfaces:
- tasks = tasks > (wait_resource_task(vpp_interface) >
+ tasks = tasks > (wait_resource_task(vpp_interface) >
self._add_interface(vpp_interface,0))
- return wait_resource_task(self.node.vpp) > tasks
+ return wait_resource_task(self.node.vpp) > tasks
#--------------------------------------------------------------------------
# Internal methods
#--------------------------------------------------------------------------
def _add_interface(self, interface, br_domain):
- return BashTask(self.node, CMD_ADD_INTERFACE_TO_BR,
+ return BashTask(self.node, CMD_ADD_INTERFACE_TO_BR,
{'interface': interface, 'br_domain': br_domain})
def _del_interface(self, interface, br_domain):
diff --git a/vicn/resource/vpp/vpp_commands.py b/vicn/resource/vpp/vpp_commands.py
index 63c74808..40315c19 100644
--- a/vicn/resource/vpp/vpp_commands.py
+++ b/vicn/resource/vpp/vpp_commands.py
@@ -21,7 +21,7 @@ CMD_VPP_CREATE_IFACE = '''
vppctl create host-interface name {vpp_interface.parent.device_name} hw-addr {vpp_interface.parent.mac_address}
vppctl set interface state {vpp_interface.device_name} up
'''
-CMD_VPP_SET_IP = 'vppctl set int ip address {netdevice.device_name} {netdevice.ip_address}/{netdevice.prefix_len}'
+CMD_VPP_SET_IP = 'vppctl set int ip address {netdevice.device_name} {netdevice.ip4_address}/{netdevice.prefix_len}'
CMD_VPP_SET_UP = 'vppctl set int state {netdevice.device_name} up'
##### VPP IP ROUTING #####