aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/mpls/interface.c
AgeCommit message (Collapse)AuthorFilesLines
2018-12-04MPLS: buffer over-run with incorrectly init'd vector. fix VAT dumpNeale Ranns1-1/+1
Change-Id: Ifdbb4c4cffd90c4ec8b39513d284ebf7be39eca5 Signed-off-by: Neale Ranns <nranns@cisco.com>
2018-07-23fix vector index range checksEyal Bari1-1/+1
Change-Id: I63c36644c9d93f2c3ec6606ca0205b407499de4e Signed-off-by: Eyal Bari <ebari@cisco.com>
2017-11-22CLI for interface MPLS enable returns errors to callerNeale Ranns1-1/+5
Change-Id: I9eef6fb9d050552f0759080ea645b885d5b9cc12 Signed-off-by: Neale Ranns <nranns@cisco.com>
2017-09-11FIB table add/delete APINeale Ranns1-8/+18
part 2; - this adds the code to create an IP and MPLS table via the API. - but the enforcement that the table must be created before it is used is still missing, this is so that CSIT can pass. Change-Id: Id124d884ade6cb7da947225200e3bb193454c555 Signed-off-by: Neale Ranns <nranns@cisco.com>
2017-04-01MTRIE Optimisations 2Neale Ranns1-0/+1
1) 16-8-8 stride. Reduce trie depth walk traded with increased memory in the top PLY. 2) separate the vector of protocol-independent (PI) fib_table_t with the vector of protocol dependent (PD) FIBs. PD FIBs are large structures, we don't want to burn the memory for ech PD type 3) Go straight to the PD FIB in the data-path thus avoiding an indirection through, e.g., a PLY pool. Change-Id: I800d1ed0b2049040d5da95213f3ed6b12bdd78b7 Signed-off-by: Neale Ranns <nranns@cisco.com>
2017-03-17Use the feature anchor in the MPLS input arc - it performs much betterNeale Ranns1-2/+2
Change-Id: I3d64ddb248478accd4d9b3124f018c9aab63a60f Signed-off-by: Neale Ranns <nranns@cisco.com>
2016-12-28Reorganize source tree to use single autotools instanceDamjan Marion1-0/+121
Change-Id: I7b51f88292e057c6443b12224486f2d0c9f8ae23 Signed-off-by: Damjan Marion <damarion@cisco.com>
>Namespaces.py
blob: 00d615350e762c1b2bcfc13907d6677293109798 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Copyright (c) 2016 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Linux namespace utilities library."""

from resources.libraries.python.ssh import exec_cmd_no_error, exec_cmd


class Namespaces(object):
    """Linux namespace utilities."""
    def __init__(self):
        self._namespaces = []

    def create_namespace(self, node, namespace_name):
        """Create namespace and add the name to the list for later clean-up.

        :param node: Where to create namespace.
        :param namespace_name: Name for namespace.
        :type node: dict
        :type namespace_name: str
        """
        cmd = ('ip netns add {0}'.format(namespace_name))
        exec_cmd_no_error(node, cmd, sudo=True)
        self._namespaces.append(namespace_name)

    @staticmethod
    def attach_interface_to_namespace(node, namespace, interface):
        """Attach specific interface to namespace.

        :param node: Node where to execute command.
        :param namespace: Namespace to execute command on.
        :param interface: Interface in namespace.
        :type node: dict
        :type namespace: str
        :type interface: str
        :raises RuntimeError: Interface could not be attached.
        """
        cmd = 'ip link set {0} netns {1}'.format(interface, namespace)
        (ret_code, _, stderr) = exec_cmd(node, cmd, timeout=5, sudo=True)
        if ret_code != 0:
            raise RuntimeError(
                'Could not attach interface, reason:{}'.format(stderr))
        cmd = 'ip netns exec {} ip link set {} up'.format(
            namespace, interface)
        (ret_code, _, stderr) = exec_cmd(node, cmd, timeout=5, sudo=True)
        if ret_code != 0:
            raise RuntimeError(
                'Could not set interface state, reason:{}'.format(stderr))

    @staticmethod
    def create_bridge_for_int_in_namespace(
            node, namespace, bridge_name, *interfaces):
        """Setup bridge domain and add interfaces to it.

        :param node: Node where to execute command.
        :param namespace: Namespace to execute command on.
        :param bridge_name: Name of the bridge to be created.
        :param interfaces: List of interfaces to add to the namespace.
        :type node: dict
        :type namespace: str
        :type bridge_name: str
        :type interfaces: list
        """
        cmd = 'ip netns exec {} brctl addbr {}'.format(namespace, bridge_name)
        exec_cmd_no_error(node, cmd, sudo=True)
        for interface in interfaces:
            cmd = 'ip netns exec {} brctl addif {} {}'.format(
                namespace, bridge_name, interface)
            exec_cmd_no_error(node, cmd, sudo=True)
        cmd = 'ip netns exec {} ip link set dev {} up'.format(
            namespace, bridge_name)
        exec_cmd_no_error(node, cmd, sudo=True)

    def clean_up_namespaces(self, node):
        """Remove all old namespaces.

        :param node: Node where to execute command.
        :type node: dict
        :raises RuntimeError: Namespaces could not be cleaned properly.
        """
        for namespace in self._namespaces:
            print "Cleaning namespace {}".format(namespace)
            cmd = 'ip netns delete {}'.format(namespace)
            (ret_code, _, _) = exec_cmd(node, cmd, timeout=5, sudo=True)
            if ret_code != 0:
                raise RuntimeError('Could not delete namespace')