Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 1 | import binascii |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 2 | import socket |
Paul Vinciguerra | 3bce8eb | 2018-11-24 21:46:05 -0800 | [diff] [blame] | 3 | import abc |
Paul Vinciguerra | 00671cf | 2018-11-25 12:47:04 -0800 | [diff] [blame] | 4 | |
Paul Vinciguerra | 3bce8eb | 2018-11-24 21:46:05 -0800 | [diff] [blame] | 5 | import six |
Paul Vinciguerra | 6c74617 | 2018-11-26 09:57:21 -0800 | [diff] [blame] | 6 | from six import moves |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 7 | |
Ole Troan | 7f99183 | 2018-12-06 17:35:12 +0100 | [diff] [blame] | 8 | from util import Host, mk_ll_addr |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 9 | from vpp_papi import mac_ntop, VppEnum |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 10 | from ipaddress import IPv4Network, IPv6Network |
Neale Ranns | 097fa66 | 2018-05-01 05:17:55 -0700 | [diff] [blame] | 11 | |
| 12 | try: |
| 13 | text_type = unicode |
| 14 | except NameError: |
| 15 | text_type = str |
Jan | 65209ed | 2016-12-05 23:29:17 +0100 | [diff] [blame] | 16 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 17 | |
Paul Vinciguerra | 3bce8eb | 2018-11-24 21:46:05 -0800 | [diff] [blame] | 18 | @six.add_metaclass(abc.ABCMeta) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 19 | class VppInterface(object): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 20 | """Generic VPP interface.""" |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 21 | |
| 22 | @property |
| 23 | def sw_if_index(self): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 24 | """Interface index assigned by VPP.""" |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 25 | return self._sw_if_index |
| 26 | |
| 27 | @property |
| 28 | def remote_mac(self): |
Klement Sekera | da505f6 | 2017-01-04 12:58:53 +0100 | [diff] [blame] | 29 | """MAC-address of the remote interface "connected" to this interface""" |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 30 | return self._remote_hosts[0].mac |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 31 | |
| 32 | @property |
| 33 | def local_mac(self): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 34 | """MAC-address of the VPP interface.""" |
Ole Troan | 6ed154f | 2019-10-15 19:31:55 +0200 | [diff] [blame] | 35 | return str(self._local_mac) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 36 | |
| 37 | @property |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 38 | def local_addr(self): |
| 39 | return self._local_addr |
| 40 | |
| 41 | @property |
| 42 | def remote_addr(self): |
| 43 | return self._remote_addr |
| 44 | |
| 45 | @property |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 46 | def local_ip4(self): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 47 | """Local IPv4 address on VPP interface (string).""" |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 48 | return self._local_ip4 |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 49 | |
| 50 | @local_ip4.setter |
| 51 | def local_ip4(self, value): |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 52 | self._local_ip4 = value |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 53 | |
| 54 | @property |
| 55 | def local_ip4_prefix_len(self): |
| 56 | """Local IPv4 prefix length """ |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 57 | return self._local_ip4_len |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 58 | |
| 59 | @local_ip4_prefix_len.setter |
| 60 | def local_ip4_prefix_len(self, value): |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 61 | self._local_ip4_len = value |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 62 | |
| 63 | @property |
| 64 | def local_ip4_prefix(self): |
| 65 | """Local IPv4 prefix """ |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 66 | return ("%s/%d" % (self._local_ip4, self._local_ip4_len)) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 67 | |
| 68 | @property |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 69 | def remote_ip4(self): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 70 | """IPv4 address of remote peer "connected" to this interface.""" |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 71 | return self._remote_hosts[0].ip4 |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 72 | |
| 73 | @property |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 74 | def local_ip6(self): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 75 | """Local IPv6 address on VPP interface (string).""" |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 76 | return self._local_ip6 |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 77 | |
| 78 | @local_ip6.setter |
| 79 | def local_ip6(self, value): |
Paul Vinciguerra | 5d440d9 | 2019-12-01 21:55:52 -0500 | [diff] [blame] | 80 | self._local_ip6 = value |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 81 | |
| 82 | @property |
| 83 | def local_ip6_prefix_len(self): |
| 84 | """Local IPv6 prefix length """ |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 85 | return self._local_ip6_len |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 86 | |
| 87 | @local_ip6_prefix_len.setter |
| 88 | def local_ip6_prefix_len(self, value): |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 89 | self._local_ip6_len = value |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 90 | |
| 91 | @property |
| 92 | def local_ip6_prefix(self): |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 93 | """Local IPv4 prefix """ |
| 94 | return ("%s/%d" % (self._local_ip6, self._local_ip6_len)) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 95 | |
| 96 | @property |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 97 | def remote_ip6(self): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 98 | """IPv6 address of remote peer "connected" to this interface.""" |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 99 | return self._remote_hosts[0].ip6 |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 100 | |
| 101 | @property |
Juraj Sloboda | c037423 | 2018-02-01 15:18:49 +0100 | [diff] [blame] | 102 | def local_ip6_ll(self): |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 103 | """Local IPv6 link-local address on VPP interface (string).""" |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 104 | return self._local_ip6_ll |
Juraj Sloboda | c037423 | 2018-02-01 15:18:49 +0100 | [diff] [blame] | 105 | |
| 106 | @property |
Juraj Sloboda | c037423 | 2018-02-01 15:18:49 +0100 | [diff] [blame] | 107 | def remote_ip6_ll(self): |
| 108 | """Link-local IPv6 address of remote peer |
| 109 | "connected" to this interface.""" |
| 110 | return self._remote_ip6_ll |
| 111 | |
| 112 | @property |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 113 | def name(self): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 114 | """Name of the interface.""" |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 115 | return self._name |
| 116 | |
| 117 | @property |
| 118 | def dump(self): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 119 | """RAW result of sw_interface_dump for this interface.""" |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 120 | return self._dump |
| 121 | |
| 122 | @property |
| 123 | def test(self): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 124 | """Test case creating this interface.""" |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 125 | return self._test |
| 126 | |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 127 | @property |
| 128 | def remote_hosts(self): |
| 129 | """Remote hosts list""" |
| 130 | return self._remote_hosts |
| 131 | |
| 132 | @remote_hosts.setter |
| 133 | def remote_hosts(self, value): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 134 | """ |
| 135 | :param list value: List of remote hosts. |
| 136 | """ |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 137 | self._remote_hosts = value |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 138 | self._hosts_by_mac = {} |
| 139 | self._hosts_by_ip4 = {} |
| 140 | self._hosts_by_ip6 = {} |
| 141 | for host in self._remote_hosts: |
| 142 | self._hosts_by_mac[host.mac] = host |
| 143 | self._hosts_by_ip4[host.ip4] = host |
| 144 | self._hosts_by_ip6[host.ip6] = host |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 145 | |
| 146 | def host_by_mac(self, mac): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 147 | """ |
Matej Klotton | c5bf07f | 2016-11-23 15:27:17 +0100 | [diff] [blame] | 148 | :param mac: MAC address to find host by. |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 149 | :return: Host object assigned to interface. |
| 150 | """ |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 151 | return self._hosts_by_mac[mac] |
| 152 | |
| 153 | def host_by_ip4(self, ip): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 154 | """ |
| 155 | :param ip: IPv4 address to find host by. |
| 156 | :return: Host object assigned to interface. |
| 157 | """ |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 158 | return self._hosts_by_ip4[ip] |
| 159 | |
| 160 | def host_by_ip6(self, ip): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 161 | """ |
| 162 | :param ip: IPv6 address to find host by. |
| 163 | :return: Host object assigned to interface. |
| 164 | """ |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 165 | return self._hosts_by_ip6[ip] |
| 166 | |
| 167 | def generate_remote_hosts(self, count=1): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 168 | """Generate and add remote hosts for the interface. |
| 169 | |
| 170 | :param int count: Number of generated remote hosts. |
| 171 | """ |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 172 | self._remote_hosts = [] |
| 173 | self._hosts_by_mac = {} |
| 174 | self._hosts_by_ip4 = {} |
| 175 | self._hosts_by_ip6 = {} |
Klement Sekera | 7bb873a | 2016-11-18 07:38:42 +0100 | [diff] [blame] | 176 | for i in range( |
| 177 | 2, count + 2): # 0: network address, 1: local vpp address |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 178 | mac = "02:%02x:00:00:ff:%02x" % (self.sw_if_index, i) |
| 179 | ip4 = "172.16.%u.%u" % (self.sw_if_index, i) |
Klement Sekera | 46a87ad | 2017-01-02 08:22:23 +0100 | [diff] [blame] | 180 | ip6 = "fd01:%x::%x" % (self.sw_if_index, i) |
Neale Ranns | 2a3ea49 | 2017-04-19 05:24:40 -0700 | [diff] [blame] | 181 | ip6_ll = mk_ll_addr(mac) |
| 182 | host = Host(mac, ip4, ip6, ip6_ll) |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 183 | self._remote_hosts.append(host) |
| 184 | self._hosts_by_mac[mac] = host |
| 185 | self._hosts_by_ip4[ip4] = host |
| 186 | self._hosts_by_ip6[ip6] = host |
| 187 | |
Paul Vinciguerra | 3bce8eb | 2018-11-24 21:46:05 -0800 | [diff] [blame] | 188 | @abc.abstractmethod |
Matej Klotton | c5bf07f | 2016-11-23 15:27:17 +0100 | [diff] [blame] | 189 | def __init__(self, test): |
| 190 | self._test = test |
| 191 | |
| 192 | self._remote_hosts = [] |
| 193 | self._hosts_by_mac = {} |
| 194 | self._hosts_by_ip4 = {} |
| 195 | self._hosts_by_ip6 = {} |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 196 | |
Neale Ranns | 3b81a1e | 2018-09-06 09:50:26 -0700 | [diff] [blame] | 197 | def set_mac(self, mac): |
Ole Troan | 8006c6a | 2018-12-17 12:02:26 +0100 | [diff] [blame] | 198 | self._local_mac = str(mac) |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 199 | self._local_ip6_ll = mk_ll_addr(self._local_mac) |
Neale Ranns | 3b81a1e | 2018-09-06 09:50:26 -0700 | [diff] [blame] | 200 | self.test.vapi.sw_interface_set_mac_address( |
Ole Troan | 8006c6a | 2018-12-17 12:02:26 +0100 | [diff] [blame] | 201 | self.sw_if_index, mac.packed) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 202 | return self |
Neale Ranns | 3b81a1e | 2018-09-06 09:50:26 -0700 | [diff] [blame] | 203 | |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 204 | def set_sw_if_index(self, sw_if_index): |
Paul Vinciguerra | 5ef9ca6 | 2019-12-01 22:16:54 -0500 | [diff] [blame] | 205 | if sw_if_index > 255: |
| 206 | raise RuntimeError("Don't support sw_if_index values " |
| 207 | "greater than 255.") |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 208 | self._sw_if_index = sw_if_index |
| 209 | |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 210 | self.generate_remote_hosts() |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 211 | |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 212 | self._local_ip4 = "172.16.%u.1" % self.sw_if_index |
| 213 | self._local_ip4_len = 24 |
Neale Ranns | 24b170a | 2017-08-15 05:33:11 -0700 | [diff] [blame] | 214 | self._local_ip4_subnet = "172.16.%u.0" % self.sw_if_index |
Neale Ranns | 24b170a | 2017-08-15 05:33:11 -0700 | [diff] [blame] | 215 | self._local_ip4_bcast = "172.16.%u.255" % self.sw_if_index |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 216 | self.has_ip4_config = False |
| 217 | self.ip4_table_id = 0 |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 218 | |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 219 | self._local_ip6 = "fd01:%x::1" % self.sw_if_index |
| 220 | self._local_ip6_len = 64 |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 221 | self.has_ip6_config = False |
| 222 | self.ip6_table_id = 0 |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 223 | |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 224 | self._local_addr = {socket.AF_INET: self.local_ip4, |
| 225 | socket.AF_INET6: self.local_ip6} |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 226 | self._remote_addr = {socket.AF_INET: self.remote_ip4, |
| 227 | socket.AF_INET6: self.remote_ip6} |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 228 | |
Paul Vinciguerra | 7a99823 | 2019-06-07 15:01:12 -0400 | [diff] [blame] | 229 | r = self.test.vapi.sw_interface_dump(sw_if_index=self.sw_if_index) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 230 | for intf in r: |
| 231 | if intf.sw_if_index == self.sw_if_index: |
Ole Troan | 6ed154f | 2019-10-15 19:31:55 +0200 | [diff] [blame] | 232 | self._name = intf.interface_name |
| 233 | self._local_mac = intf.l2_address |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 234 | self._dump = intf |
| 235 | break |
| 236 | else: |
| 237 | raise Exception( |
| 238 | "Could not find interface with sw_if_index %d " |
| 239 | "in interface dump %s" % |
Paul Vinciguerra | 6c74617 | 2018-11-26 09:57:21 -0800 | [diff] [blame] | 240 | (self.sw_if_index, moves.reprlib.repr(r))) |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 241 | self._local_ip6_ll = mk_ll_addr(self.local_mac) |
Juraj Sloboda | c037423 | 2018-02-01 15:18:49 +0100 | [diff] [blame] | 242 | self._remote_ip6_ll = mk_ll_addr(self.remote_mac) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 243 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 244 | def config_ip4(self): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 245 | """Configure IPv4 address on the VPP interface.""" |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 246 | self.test.vapi.sw_interface_add_del_address( |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 247 | sw_if_index=self.sw_if_index, prefix=self.local_ip4_prefix) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 248 | self.has_ip4_config = True |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 249 | return self |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 250 | |
| 251 | def unconfig_ip4(self): |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 252 | """Remove IPv4 address on the VPP interface.""" |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 253 | try: |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 254 | if self.has_ip4_config: |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 255 | self.test.vapi.sw_interface_add_del_address( |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 256 | sw_if_index=self.sw_if_index, |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 257 | prefix=self.local_ip4_prefix, is_add=0) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 258 | except AttributeError: |
| 259 | self.has_ip4_config = False |
| 260 | self.has_ip4_config = False |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 261 | return self |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 262 | |
Neale Ranns | baf2e90 | 2017-02-25 04:20:00 -0800 | [diff] [blame] | 263 | def configure_ipv4_neighbors(self): |
Jan | e546d3b | 2016-12-08 13:10:03 +0100 | [diff] [blame] | 264 | """For every remote host assign neighbor's MAC to IPv4 addresses. |
| 265 | |
| 266 | :param vrf_id: The FIB table / VRF ID. (Default value = 0) |
| 267 | """ |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 268 | for host in self._remote_hosts: |
Neale Ranns | 3702930 | 2018-08-10 05:30:06 -0700 | [diff] [blame] | 269 | self.test.vapi.ip_neighbor_add_del(self.sw_if_index, |
| 270 | host.mac, |
| 271 | host.ip4) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 272 | return self |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 273 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 274 | def config_ip6(self): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 275 | """Configure IPv6 address on the VPP interface.""" |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 276 | self.test.vapi.sw_interface_add_del_address( |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 277 | sw_if_index=self.sw_if_index, prefix=self.local_ip6_prefix) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 278 | self.has_ip6_config = True |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 279 | return self |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 280 | |
| 281 | def unconfig_ip6(self): |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 282 | """Remove IPv6 address on the VPP interface.""" |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 283 | try: |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 284 | if self.has_ip6_config: |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 285 | self.test.vapi.sw_interface_add_del_address( |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 286 | sw_if_index=self.sw_if_index, |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 287 | prefix=self.local_ip6_prefix, is_add=0) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 288 | except AttributeError: |
| 289 | self.has_ip6_config = False |
| 290 | self.has_ip6_config = False |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 291 | return self |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 292 | |
Neale Ranns | baf2e90 | 2017-02-25 04:20:00 -0800 | [diff] [blame] | 293 | def configure_ipv6_neighbors(self): |
Jan Gelety | 057bb8c | 2016-12-20 17:32:45 +0100 | [diff] [blame] | 294 | """For every remote host assign neighbor's MAC to IPv6 addresses. |
| 295 | |
| 296 | :param vrf_id: The FIB table / VRF ID. (Default value = 0) |
| 297 | """ |
Klement Sekera | 46a87ad | 2017-01-02 08:22:23 +0100 | [diff] [blame] | 298 | for host in self._remote_hosts: |
Neale Ranns | 3702930 | 2018-08-10 05:30:06 -0700 | [diff] [blame] | 299 | self.test.vapi.ip_neighbor_add_del(self.sw_if_index, |
| 300 | host.mac, |
| 301 | host.ip6) |
Klement Sekera | 46a87ad | 2017-01-02 08:22:23 +0100 | [diff] [blame] | 302 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 303 | def unconfig(self): |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 304 | """Unconfigure IPv6 and IPv4 address on the VPP interface.""" |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 305 | self.unconfig_ip4() |
| 306 | self.unconfig_ip6() |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 307 | return self |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 308 | |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 309 | def set_table_ip4(self, table_id): |
| 310 | """Set the interface in a IPv4 Table. |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 311 | |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 312 | .. note:: Must be called before configuring IP4 addresses. |
| 313 | """ |
| 314 | self.ip4_table_id = table_id |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 315 | self.test.vapi.sw_interface_set_table( |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 316 | self.sw_if_index, 0, self.ip4_table_id) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 317 | return self |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 318 | |
| 319 | def set_table_ip6(self, table_id): |
| 320 | """Set the interface in a IPv6 Table. |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 321 | |
| 322 | .. note:: Must be called before configuring IP6 addresses. |
| 323 | """ |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 324 | self.ip6_table_id = table_id |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 325 | self.test.vapi.sw_interface_set_table( |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 326 | self.sw_if_index, 1, self.ip6_table_id) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 327 | return self |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 328 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 329 | def disable_ipv6_ra(self): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 330 | """Configure IPv6 RA suppress on the VPP interface.""" |
Ole Troan | e1ade68 | 2019-03-04 23:55:43 +0100 | [diff] [blame] | 331 | self.test.vapi.sw_interface_ip6nd_ra_config( |
| 332 | sw_if_index=self.sw_if_index, |
| 333 | suppress=1) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 334 | return self |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 335 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 336 | def ip6_ra_config(self, no=0, suppress=0, send_unicast=0): |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 337 | """Configure IPv6 RA suppress on the VPP interface.""" |
Ole Troan | e1ade68 | 2019-03-04 23:55:43 +0100 | [diff] [blame] | 338 | self.test.vapi.sw_interface_ip6nd_ra_config( |
| 339 | sw_if_index=self.sw_if_index, |
| 340 | is_no=no, |
| 341 | suppress=suppress, |
| 342 | send_unicast=send_unicast) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 343 | return self |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 344 | |
Paul Vinciguerra | ab05508 | 2019-06-06 14:07:55 -0400 | [diff] [blame] | 345 | def ip6_ra_prefix(self, prefix, is_no=0, |
Neale Ranns | 87df12d | 2017-02-18 08:16:41 -0800 | [diff] [blame] | 346 | off_link=0, no_autoconfig=0, use_default=0): |
Paul Vinciguerra | ab05508 | 2019-06-06 14:07:55 -0400 | [diff] [blame] | 347 | """Configure IPv6 RA suppress on the VPP interface. |
| 348 | |
| 349 | prefix can be a string in the format of '<address>/<length_in_bits>' |
| 350 | or ipaddress.ipnetwork object (if strict.)""" |
| 351 | |
Ole Troan | e1ade68 | 2019-03-04 23:55:43 +0100 | [diff] [blame] | 352 | self.test.vapi.sw_interface_ip6nd_ra_prefix( |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 353 | sw_if_index=self.sw_if_index, |
Paul Vinciguerra | ab05508 | 2019-06-06 14:07:55 -0400 | [diff] [blame] | 354 | prefix=prefix, |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 355 | use_default=use_default, |
| 356 | off_link=off_link, no_autoconfig=no_autoconfig, |
| 357 | is_no=is_no) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 358 | return self |
Neale Ranns | 87df12d | 2017-02-18 08:16:41 -0800 | [diff] [blame] | 359 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 360 | def admin_up(self): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 361 | """Put interface ADMIN-UP.""" |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 362 | self.test.vapi.sw_interface_set_flags( |
| 363 | self.sw_if_index, |
| 364 | flags=VppEnum.vl_api_if_status_flags_t.IF_STATUS_API_FLAG_ADMIN_UP) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 365 | return self |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 366 | |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 367 | def admin_down(self): |
| 368 | """Put interface ADMIN-down.""" |
Klement Sekera | da505f6 | 2017-01-04 12:58:53 +0100 | [diff] [blame] | 369 | self.test.vapi.sw_interface_set_flags(self.sw_if_index, |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 370 | flags=0) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 371 | return self |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 372 | |
Neale Ranns | 6348074 | 2019-03-13 06:41:52 -0700 | [diff] [blame] | 373 | def link_up(self): |
| 374 | """Put interface link-state-UP.""" |
| 375 | self.test.vapi.cli("test interface link-state %s up" % self.name) |
| 376 | |
| 377 | def link_down(self): |
| 378 | """Put interface link-state-down.""" |
| 379 | self.test.vapi.cli("test interface link-state %s down" % self.name) |
| 380 | |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 381 | def ip6_enable(self): |
| 382 | """IPv6 Enable interface""" |
Ole Troan | e1ade68 | 2019-03-04 23:55:43 +0100 | [diff] [blame] | 383 | self.test.vapi.sw_interface_ip6_enable_disable(self.sw_if_index, |
Klement Sekera | da505f6 | 2017-01-04 12:58:53 +0100 | [diff] [blame] | 384 | enable=1) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 385 | return self |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 386 | |
| 387 | def ip6_disable(self): |
| 388 | """Put interface ADMIN-DOWN.""" |
Ole Troan | e1ade68 | 2019-03-04 23:55:43 +0100 | [diff] [blame] | 389 | self.test.vapi.sw_interface_ip6_enable_disable(self.sw_if_index, |
Klement Sekera | da505f6 | 2017-01-04 12:58:53 +0100 | [diff] [blame] | 390 | enable=0) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 391 | return self |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 392 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 393 | def add_sub_if(self, sub_if): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 394 | """Register a sub-interface with this interface. |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 395 | |
| 396 | :param sub_if: sub-interface |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 397 | """ |
| 398 | if not hasattr(self, 'sub_if'): |
| 399 | self.sub_if = sub_if |
| 400 | else: |
| 401 | if isinstance(self.sub_if, list): |
| 402 | self.sub_if.append(sub_if) |
| 403 | else: |
| 404 | self.sub_if = sub_if |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 405 | return self |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 406 | |
| 407 | def enable_mpls(self): |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 408 | """Enable MPLS on the VPP interface.""" |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 409 | self.test.vapi.sw_interface_set_mpls_enable(self.sw_if_index) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 410 | return self |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 411 | |
Neale Ranns | 180279b | 2017-03-16 15:49:09 -0400 | [diff] [blame] | 412 | def disable_mpls(self): |
| 413 | """Enable MPLS on the VPP interface.""" |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 414 | self.test.vapi.sw_interface_set_mpls_enable(self.sw_if_index, 0) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 415 | return self |
Neale Ranns | 180279b | 2017-03-16 15:49:09 -0400 | [diff] [blame] | 416 | |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 417 | def is_ip4_entry_in_fib_dump(self, dump): |
| 418 | for i in dump: |
Neale Ranns | 097fa66 | 2018-05-01 05:17:55 -0700 | [diff] [blame] | 419 | n = IPv4Network(text_type("%s/%d" % (self.local_ip4, |
| 420 | self.local_ip4_prefix_len))) |
| 421 | if i.route.prefix == n and \ |
| 422 | i.route.table_id == self.ip4_table_id: |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 423 | return True |
| 424 | return False |
Neale Ranns | 39f9d8b | 2017-02-16 21:57:05 -0800 | [diff] [blame] | 425 | |
| 426 | def set_unnumbered(self, ip_sw_if_index): |
| 427 | """ Set the interface to unnumbered via ip_sw_if_index """ |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 428 | self.test.vapi.sw_interface_set_unnumbered(ip_sw_if_index, |
| 429 | self.sw_if_index) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 430 | return self |
Neale Ranns | 39f9d8b | 2017-02-16 21:57:05 -0800 | [diff] [blame] | 431 | |
Neale Ranns | 37be736 | 2017-02-21 17:30:26 -0800 | [diff] [blame] | 432 | def unset_unnumbered(self, ip_sw_if_index): |
Neale Ranns | 4b919a5 | 2017-03-11 05:55:21 -0800 | [diff] [blame] | 433 | """ Unset the interface to unnumbered via ip_sw_if_index """ |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 434 | self.test.vapi.sw_interface_set_unnumbered(ip_sw_if_index, |
| 435 | self.sw_if_index, is_add=0) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 436 | return self |
Neale Ranns | 37be736 | 2017-02-21 17:30:26 -0800 | [diff] [blame] | 437 | |
Neale Ranns | 39f9d8b | 2017-02-16 21:57:05 -0800 | [diff] [blame] | 438 | def set_proxy_arp(self, enable=1): |
| 439 | """ Set the interface to enable/disable Proxy ARP """ |
| 440 | self.test.vapi.proxy_arp_intfc_enable_disable( |
| 441 | self.sw_if_index, |
| 442 | enable) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 443 | return self |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 444 | |
| 445 | def query_vpp_config(self): |
Paul Vinciguerra | 7a99823 | 2019-06-07 15:01:12 -0400 | [diff] [blame] | 446 | dump = self.test.vapi.sw_interface_dump(sw_if_index=self.sw_if_index) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 447 | return self.is_interface_config_in_dump(dump) |
| 448 | |
Juraj Sloboda | b3f9050 | 2018-10-04 15:15:16 +0200 | [diff] [blame] | 449 | def get_interface_config_from_dump(self, dump): |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 450 | for i in dump: |
| 451 | if i.interface_name.rstrip(' \t\r\n\0') == self.name and \ |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 452 | i.sw_if_index == self.sw_if_index: |
Juraj Sloboda | b3f9050 | 2018-10-04 15:15:16 +0200 | [diff] [blame] | 453 | return i |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 454 | else: |
Juraj Sloboda | b3f9050 | 2018-10-04 15:15:16 +0200 | [diff] [blame] | 455 | return None |
| 456 | |
| 457 | def is_interface_config_in_dump(self, dump): |
| 458 | return self.get_interface_config_from_dump(dump) is not None |
| 459 | |
| 460 | def assert_interface_state(self, admin_up_down, link_up_down, |
| 461 | expect_event=False): |
| 462 | if expect_event: |
| 463 | event = self.test.vapi.wait_for_event(timeout=1, |
| 464 | name='sw_interface_event') |
| 465 | self.test.assert_equal(event.sw_if_index, self.sw_if_index, |
| 466 | "sw_if_index") |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 467 | self.test.assert_equal((event.flags & 1), admin_up_down, |
Juraj Sloboda | b3f9050 | 2018-10-04 15:15:16 +0200 | [diff] [blame] | 468 | "admin state") |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 469 | self.test.assert_equal((event.flags & 2), link_up_down, |
Juraj Sloboda | b3f9050 | 2018-10-04 15:15:16 +0200 | [diff] [blame] | 470 | "link state") |
| 471 | dump = self.test.vapi.sw_interface_dump() |
| 472 | if_state = self.get_interface_config_from_dump(dump) |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 473 | self.test.assert_equal((if_state.flags & 1), admin_up_down, |
Juraj Sloboda | b3f9050 | 2018-10-04 15:15:16 +0200 | [diff] [blame] | 474 | "admin state") |
Jakub Grajciar | 053204a | 2019-03-18 13:17:53 +0100 | [diff] [blame] | 475 | self.test.assert_equal((if_state.flags & 2), link_up_down, |
Juraj Sloboda | b3f9050 | 2018-10-04 15:15:16 +0200 | [diff] [blame] | 476 | "link state") |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 477 | |
| 478 | def __str__(self): |
| 479 | return self.name |
Neale Ranns | 2ac885c | 2019-03-20 18:24:43 +0000 | [diff] [blame] | 480 | |
| 481 | def get_rx_stats(self): |
| 482 | c = self.test.statistics.get_counter("^/if/rx$") |
| 483 | return c[0][self.sw_if_index] |
| 484 | |
| 485 | def get_tx_stats(self): |
| 486 | c = self.test.statistics.get_counter("^/if/tx$") |
| 487 | return c[0][self.sw_if_index] |
Ole Troan | eb284a1 | 2019-10-09 13:33:19 +0200 | [diff] [blame] | 488 | |
| 489 | def set_l3_mtu(self, mtu): |
| 490 | self.test.vapi.sw_interface_set_mtu(self.sw_if_index, [mtu, 0, 0, 0]) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 491 | return self |
Ole Troan | eb284a1 | 2019-10-09 13:33:19 +0200 | [diff] [blame] | 492 | |
| 493 | def set_ip4_mtu(self, mtu): |
| 494 | self.test.vapi.sw_interface_set_mtu(self.sw_if_index, [0, mtu, 0, 0]) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 495 | return self |
Ole Troan | eb284a1 | 2019-10-09 13:33:19 +0200 | [diff] [blame] | 496 | |
| 497 | def set_ip6_mtu(self, mtu): |
| 498 | self.test.vapi.sw_interface_set_mtu(self.sw_if_index, [0, 0, mtu, 0]) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 499 | return self |
Ole Troan | eb284a1 | 2019-10-09 13:33:19 +0200 | [diff] [blame] | 500 | |
| 501 | def set_mpls_mtu(self, mtu): |
| 502 | self.test.vapi.sw_interface_set_mtu(self.sw_if_index, [0, 0, 0, mtu]) |
Paul Vinciguerra | 207083f | 2019-12-02 22:38:00 -0500 | [diff] [blame] | 503 | return self |