blob: e14a31eb722a8a4ce6090b53c271ad3dd8b24723 [file] [log] [blame]
Klement Sekeraf62ae122016-10-11 11:47:09 +02001from abc import abstractmethod, ABCMeta
2import socket
Klement Sekeraf62ae122016-10-11 11:47:09 +02003
Neale Ranns2a3ea492017-04-19 05:24:40 -07004from util import Host, mk_ll_addr
Jan65209ed2016-12-05 23:29:17 +01005
Klement Sekeraf62ae122016-10-11 11:47:09 +02006
7class VppInterface(object):
Matej Klotton86d87c42016-11-11 11:38:55 +01008 """Generic VPP interface."""
Klement Sekeraf62ae122016-10-11 11:47:09 +02009 __metaclass__ = ABCMeta
10
11 @property
12 def sw_if_index(self):
Matej Klotton86d87c42016-11-11 11:38:55 +010013 """Interface index assigned by VPP."""
Klement Sekeraf62ae122016-10-11 11:47:09 +020014 return self._sw_if_index
15
16 @property
17 def remote_mac(self):
Klement Sekerada505f62017-01-04 12:58:53 +010018 """MAC-address of the remote interface "connected" to this interface"""
Matej Klotton0178d522016-11-04 11:11:44 +010019 return self._remote_hosts[0].mac
Klement Sekeraf62ae122016-10-11 11:47:09 +020020
21 @property
22 def local_mac(self):
Matej Klotton86d87c42016-11-11 11:38:55 +010023 """MAC-address of the VPP interface."""
Klement Sekeraf62ae122016-10-11 11:47:09 +020024 return self._local_mac
25
26 @property
27 def local_ip4(self):
Matej Klotton86d87c42016-11-11 11:38:55 +010028 """Local IPv4 address on VPP interface (string)."""
Klement Sekeraf62ae122016-10-11 11:47:09 +020029 return self._local_ip4
30
31 @property
32 def local_ip4n(self):
Matej Klotton86d87c42016-11-11 11:38:55 +010033 """Local IPv4 address - raw, suitable as API parameter."""
Matej Klotton0178d522016-11-04 11:11:44 +010034 return socket.inet_pton(socket.AF_INET, self._local_ip4)
Klement Sekeraf62ae122016-10-11 11:47:09 +020035
36 @property
37 def remote_ip4(self):
Matej Klotton86d87c42016-11-11 11:38:55 +010038 """IPv4 address of remote peer "connected" to this interface."""
Matej Klotton0178d522016-11-04 11:11:44 +010039 return self._remote_hosts[0].ip4
Klement Sekeraf62ae122016-10-11 11:47:09 +020040
41 @property
42 def remote_ip4n(self):
Matej Klotton86d87c42016-11-11 11:38:55 +010043 """IPv4 address of remote peer - raw, suitable as API parameter."""
Matej Klotton0178d522016-11-04 11:11:44 +010044 return socket.inet_pton(socket.AF_INET, self.remote_ip4)
Klement Sekeraf62ae122016-10-11 11:47:09 +020045
46 @property
47 def local_ip6(self):
Matej Klotton86d87c42016-11-11 11:38:55 +010048 """Local IPv6 address on VPP interface (string)."""
Klement Sekeraf62ae122016-10-11 11:47:09 +020049 return self._local_ip6
50
51 @property
52 def local_ip6n(self):
Matej Klotton86d87c42016-11-11 11:38:55 +010053 """Local IPv6 address - raw, suitable as API parameter."""
Matej Klotton0178d522016-11-04 11:11:44 +010054 return socket.inet_pton(socket.AF_INET6, self.local_ip6)
Klement Sekeraf62ae122016-10-11 11:47:09 +020055
56 @property
57 def remote_ip6(self):
Matej Klotton86d87c42016-11-11 11:38:55 +010058 """IPv6 address of remote peer "connected" to this interface."""
Matej Klotton0178d522016-11-04 11:11:44 +010059 return self._remote_hosts[0].ip6
Klement Sekeraf62ae122016-10-11 11:47:09 +020060
61 @property
62 def remote_ip6n(self):
63 """IPv6 address of remote peer - raw, suitable as API parameter"""
Matej Klotton0178d522016-11-04 11:11:44 +010064 return socket.inet_pton(socket.AF_INET6, self.remote_ip6)
Klement Sekeraf62ae122016-10-11 11:47:09 +020065
66 @property
Juraj Slobodac0374232018-02-01 15:18:49 +010067 def local_ip6_ll(self):
68 """Local IPv6 linnk-local address on VPP interface (string)."""
69 return self._local_ip6_ll
70
71 @property
72 def local_ip6n_ll(self):
73 """Local IPv6 link-local address - raw, suitable as API parameter."""
74 return self._local_ip6n_ll
75
76 @property
77 def remote_ip6_ll(self):
78 """Link-local IPv6 address of remote peer
79 "connected" to this interface."""
80 return self._remote_ip6_ll
81
82 @property
83 def remote_ip6n_ll(self):
84 """Link-local IPv6 address of remote peer
85 - raw, suitable as API parameter"""
86 return self._remote_ip6n_ll
87
88 @property
Klement Sekeraf62ae122016-10-11 11:47:09 +020089 def name(self):
Matej Klotton86d87c42016-11-11 11:38:55 +010090 """Name of the interface."""
Klement Sekeraf62ae122016-10-11 11:47:09 +020091 return self._name
92
93 @property
94 def dump(self):
Matej Klotton86d87c42016-11-11 11:38:55 +010095 """RAW result of sw_interface_dump for this interface."""
Klement Sekeraf62ae122016-10-11 11:47:09 +020096 return self._dump
97
98 @property
99 def test(self):
Matej Klotton86d87c42016-11-11 11:38:55 +0100100 """Test case creating this interface."""
Klement Sekeraf62ae122016-10-11 11:47:09 +0200101 return self._test
102
Matej Klotton0178d522016-11-04 11:11:44 +0100103 @property
104 def remote_hosts(self):
105 """Remote hosts list"""
106 return self._remote_hosts
107
108 @remote_hosts.setter
109 def remote_hosts(self, value):
Matej Klotton86d87c42016-11-11 11:38:55 +0100110 """
111 :param list value: List of remote hosts.
112 """
Matej Klotton0178d522016-11-04 11:11:44 +0100113 self._remote_hosts = value
Matej Klotton86d87c42016-11-11 11:38:55 +0100114 self._hosts_by_mac = {}
115 self._hosts_by_ip4 = {}
116 self._hosts_by_ip6 = {}
117 for host in self._remote_hosts:
118 self._hosts_by_mac[host.mac] = host
119 self._hosts_by_ip4[host.ip4] = host
120 self._hosts_by_ip6[host.ip6] = host
Matej Klotton0178d522016-11-04 11:11:44 +0100121
122 def host_by_mac(self, mac):
Matej Klotton86d87c42016-11-11 11:38:55 +0100123 """
Matej Klottonc5bf07f2016-11-23 15:27:17 +0100124 :param mac: MAC address to find host by.
Matej Klotton86d87c42016-11-11 11:38:55 +0100125 :return: Host object assigned to interface.
126 """
Matej Klotton0178d522016-11-04 11:11:44 +0100127 return self._hosts_by_mac[mac]
128
129 def host_by_ip4(self, ip):
Matej Klotton86d87c42016-11-11 11:38:55 +0100130 """
131 :param ip: IPv4 address to find host by.
132 :return: Host object assigned to interface.
133 """
Matej Klotton0178d522016-11-04 11:11:44 +0100134 return self._hosts_by_ip4[ip]
135
136 def host_by_ip6(self, ip):
Matej Klotton86d87c42016-11-11 11:38:55 +0100137 """
138 :param ip: IPv6 address to find host by.
139 :return: Host object assigned to interface.
140 """
Matej Klotton0178d522016-11-04 11:11:44 +0100141 return self._hosts_by_ip6[ip]
142
143 def generate_remote_hosts(self, count=1):
Matej Klotton86d87c42016-11-11 11:38:55 +0100144 """Generate and add remote hosts for the interface.
145
146 :param int count: Number of generated remote hosts.
147 """
Matej Klotton0178d522016-11-04 11:11:44 +0100148 self._remote_hosts = []
149 self._hosts_by_mac = {}
150 self._hosts_by_ip4 = {}
151 self._hosts_by_ip6 = {}
Klement Sekera7bb873a2016-11-18 07:38:42 +0100152 for i in range(
153 2, count + 2): # 0: network address, 1: local vpp address
Matej Klotton0178d522016-11-04 11:11:44 +0100154 mac = "02:%02x:00:00:ff:%02x" % (self.sw_if_index, i)
155 ip4 = "172.16.%u.%u" % (self.sw_if_index, i)
Klement Sekera46a87ad2017-01-02 08:22:23 +0100156 ip6 = "fd01:%x::%x" % (self.sw_if_index, i)
Neale Ranns2a3ea492017-04-19 05:24:40 -0700157 ip6_ll = mk_ll_addr(mac)
158 host = Host(mac, ip4, ip6, ip6_ll)
Matej Klotton0178d522016-11-04 11:11:44 +0100159 self._remote_hosts.append(host)
160 self._hosts_by_mac[mac] = host
161 self._hosts_by_ip4[ip4] = host
162 self._hosts_by_ip6[ip6] = host
163
Matej Klottonc5bf07f2016-11-23 15:27:17 +0100164 @abstractmethod
165 def __init__(self, test):
166 self._test = test
167
168 self._remote_hosts = []
169 self._hosts_by_mac = {}
170 self._hosts_by_ip4 = {}
171 self._hosts_by_ip6 = {}
Matej Klotton0178d522016-11-04 11:11:44 +0100172
Klement Sekera31da2e32018-06-24 22:49:55 +0200173 def set_sw_if_index(self, sw_if_index):
174 self._sw_if_index = sw_if_index
175
Matej Klotton0178d522016-11-04 11:11:44 +0100176 self.generate_remote_hosts()
Klement Sekeraf62ae122016-10-11 11:47:09 +0200177
178 self._local_ip4 = "172.16.%u.1" % self.sw_if_index
179 self._local_ip4n = socket.inet_pton(socket.AF_INET, self.local_ip4)
Neale Ranns24b170a2017-08-15 05:33:11 -0700180 self._local_ip4_subnet = "172.16.%u.0" % self.sw_if_index
181 self._local_ip4n_subnet = socket.inet_pton(socket.AF_INET,
182 self._local_ip4_subnet)
183 self._local_ip4_bcast = "172.16.%u.255" % self.sw_if_index
184 self._local_ip4n_bcast = socket.inet_pton(socket.AF_INET,
185 self._local_ip4_bcast)
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100186 self.local_ip4_prefix_len = 24
187 self.has_ip4_config = False
188 self.ip4_table_id = 0
Klement Sekeraf62ae122016-10-11 11:47:09 +0200189
Klement Sekera46a87ad2017-01-02 08:22:23 +0100190 self._local_ip6 = "fd01:%x::1" % self.sw_if_index
Klement Sekeraf62ae122016-10-11 11:47:09 +0200191 self._local_ip6n = socket.inet_pton(socket.AF_INET6, self.local_ip6)
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100192 self.local_ip6_prefix_len = 64
193 self.has_ip6_config = False
194 self.ip6_table_id = 0
Klement Sekeraf62ae122016-10-11 11:47:09 +0200195
196 r = self.test.vapi.sw_interface_dump()
197 for intf in r:
198 if intf.sw_if_index == self.sw_if_index:
199 self._name = intf.interface_name.split(b'\0', 1)[0]
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100200 self._local_mac = \
Klement Sekera7bb873a2016-11-18 07:38:42 +0100201 ':'.join(intf.l2_address.encode('hex')[i:i + 2]
202 for i in range(0, 12, 2))
Klement Sekeraf62ae122016-10-11 11:47:09 +0200203 self._dump = intf
204 break
205 else:
206 raise Exception(
207 "Could not find interface with sw_if_index %d "
208 "in interface dump %s" %
209 (self.sw_if_index, repr(r)))
Neale Ranns2a3ea492017-04-19 05:24:40 -0700210 self._local_ip6_ll = mk_ll_addr(self.local_mac)
211 self._local_ip6n_ll = socket.inet_pton(socket.AF_INET6,
212 self.local_ip6_ll)
Juraj Slobodac0374232018-02-01 15:18:49 +0100213 self._remote_ip6_ll = mk_ll_addr(self.remote_mac)
214 self._remote_ip6n_ll = socket.inet_pton(socket.AF_INET6,
215 self.remote_ip6_ll)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200216
Klement Sekeraf62ae122016-10-11 11:47:09 +0200217 def config_ip4(self):
Matej Klotton86d87c42016-11-11 11:38:55 +0100218 """Configure IPv4 address on the VPP interface."""
Klement Sekeraf62ae122016-10-11 11:47:09 +0200219 self.test.vapi.sw_interface_add_del_address(
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100220 self.sw_if_index, self.local_ip4n, self.local_ip4_prefix_len)
Neale Ranns177bbdc2016-11-15 09:46:51 +0000221 self.has_ip4_config = True
222
223 def unconfig_ip4(self):
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100224 """Remove IPv4 address on the VPP interface."""
Neale Ranns177bbdc2016-11-15 09:46:51 +0000225 try:
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100226 if self.has_ip4_config:
Neale Ranns177bbdc2016-11-15 09:46:51 +0000227 self.test.vapi.sw_interface_add_del_address(
228 self.sw_if_index,
229 self.local_ip4n,
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100230 self.local_ip4_prefix_len,
231 is_add=0)
Neale Ranns177bbdc2016-11-15 09:46:51 +0000232 except AttributeError:
233 self.has_ip4_config = False
234 self.has_ip4_config = False
Klement Sekeraf62ae122016-10-11 11:47:09 +0200235
Neale Rannsbaf2e902017-02-25 04:20:00 -0800236 def configure_ipv4_neighbors(self):
Jane546d3b2016-12-08 13:10:03 +0100237 """For every remote host assign neighbor's MAC to IPv4 addresses.
238
239 :param vrf_id: The FIB table / VRF ID. (Default value = 0)
240 """
Matej Klotton0178d522016-11-04 11:11:44 +0100241 for host in self._remote_hosts:
242 macn = host.mac.replace(":", "").decode('hex')
243 ipn = host.ip4n
Jane546d3b2016-12-08 13:10:03 +0100244 self.test.vapi.ip_neighbor_add_del(
Neale Rannsbaf2e902017-02-25 04:20:00 -0800245 self.sw_if_index, macn, ipn)
Matej Klotton0178d522016-11-04 11:11:44 +0100246
Klement Sekeraf62ae122016-10-11 11:47:09 +0200247 def config_ip6(self):
Matej Klotton86d87c42016-11-11 11:38:55 +0100248 """Configure IPv6 address on the VPP interface."""
Klement Sekeraf62ae122016-10-11 11:47:09 +0200249 self.test.vapi.sw_interface_add_del_address(
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100250 self.sw_if_index, self._local_ip6n, self.local_ip6_prefix_len,
251 is_ipv6=1)
Neale Ranns177bbdc2016-11-15 09:46:51 +0000252 self.has_ip6_config = True
253
254 def unconfig_ip6(self):
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100255 """Remove IPv6 address on the VPP interface."""
Neale Ranns177bbdc2016-11-15 09:46:51 +0000256 try:
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100257 if self.has_ip6_config:
Neale Ranns177bbdc2016-11-15 09:46:51 +0000258 self.test.vapi.sw_interface_add_del_address(
259 self.sw_if_index,
260 self.local_ip6n,
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100261 self.local_ip6_prefix_len,
262 is_ipv6=1, is_add=0)
Neale Ranns177bbdc2016-11-15 09:46:51 +0000263 except AttributeError:
264 self.has_ip6_config = False
265 self.has_ip6_config = False
266
Neale Rannsbaf2e902017-02-25 04:20:00 -0800267 def configure_ipv6_neighbors(self):
Jan Gelety057bb8c2016-12-20 17:32:45 +0100268 """For every remote host assign neighbor's MAC to IPv6 addresses.
269
270 :param vrf_id: The FIB table / VRF ID. (Default value = 0)
271 """
Klement Sekera46a87ad2017-01-02 08:22:23 +0100272 for host in self._remote_hosts:
273 macn = host.mac.replace(":", "").decode('hex')
Jan Gelety057bb8c2016-12-20 17:32:45 +0100274 ipn = host.ip6n
Klement Sekera46a87ad2017-01-02 08:22:23 +0100275 self.test.vapi.ip_neighbor_add_del(
Neale Rannsbaf2e902017-02-25 04:20:00 -0800276 self.sw_if_index, macn, ipn, is_ipv6=1)
Klement Sekera46a87ad2017-01-02 08:22:23 +0100277
Neale Ranns177bbdc2016-11-15 09:46:51 +0000278 def unconfig(self):
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100279 """Unconfigure IPv6 and IPv4 address on the VPP interface."""
Neale Ranns177bbdc2016-11-15 09:46:51 +0000280 self.unconfig_ip4()
281 self.unconfig_ip6()
Klement Sekeraf62ae122016-10-11 11:47:09 +0200282
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000283 def set_table_ip4(self, table_id):
284 """Set the interface in a IPv4 Table.
Matej Klotton86d87c42016-11-11 11:38:55 +0100285
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100286 .. note:: Must be called before configuring IP4 addresses.
287 """
288 self.ip4_table_id = table_id
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000289 self.test.vapi.sw_interface_set_table(
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100290 self.sw_if_index, 0, self.ip4_table_id)
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000291
292 def set_table_ip6(self, table_id):
293 """Set the interface in a IPv6 Table.
Matej Klotton86d87c42016-11-11 11:38:55 +0100294
295 .. note:: Must be called before configuring IP6 addresses.
296 """
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100297 self.ip6_table_id = table_id
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000298 self.test.vapi.sw_interface_set_table(
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100299 self.sw_if_index, 1, self.ip6_table_id)
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000300
Klement Sekeraf62ae122016-10-11 11:47:09 +0200301 def disable_ipv6_ra(self):
Matej Klotton86d87c42016-11-11 11:38:55 +0100302 """Configure IPv6 RA suppress on the VPP interface."""
Klement Sekeraf62ae122016-10-11 11:47:09 +0200303 self.test.vapi.sw_interface_ra_suppress(self.sw_if_index)
304
Neale Ranns32e1c012016-11-22 17:07:28 +0000305 def ip6_ra_config(self, no=0, suppress=0, send_unicast=0):
Neale Ranns75152282017-01-09 01:00:45 -0800306 """Configure IPv6 RA suppress on the VPP interface."""
307 self.test.vapi.ip6_sw_interface_ra_config(self.sw_if_index,
Neale Ranns32e1c012016-11-22 17:07:28 +0000308 no,
Neale Ranns75152282017-01-09 01:00:45 -0800309 suppress,
310 send_unicast)
311
Neale Ranns87df12d2017-02-18 08:16:41 -0800312 def ip6_ra_prefix(self, address, address_length, is_no=0,
313 off_link=0, no_autoconfig=0, use_default=0):
314 """Configure IPv6 RA suppress on the VPP interface."""
315 self.test.vapi.ip6_sw_interface_ra_prefix(self.sw_if_index,
316 address,
317 address_length,
318 is_no=is_no,
319 off_link=off_link,
320 no_autoconfig=no_autoconfig,
321 use_default=use_default)
322
Klement Sekeraf62ae122016-10-11 11:47:09 +0200323 def admin_up(self):
Matej Klotton86d87c42016-11-11 11:38:55 +0100324 """Put interface ADMIN-UP."""
Klement Sekerada505f62017-01-04 12:58:53 +0100325 self.test.vapi.sw_interface_set_flags(self.sw_if_index,
326 admin_up_down=1)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200327
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100328 def admin_down(self):
329 """Put interface ADMIN-down."""
Klement Sekerada505f62017-01-04 12:58:53 +0100330 self.test.vapi.sw_interface_set_flags(self.sw_if_index,
331 admin_up_down=0)
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100332
Neale Ranns75152282017-01-09 01:00:45 -0800333 def ip6_enable(self):
334 """IPv6 Enable interface"""
Klement Sekerada505f62017-01-04 12:58:53 +0100335 self.test.vapi.ip6_sw_interface_enable_disable(self.sw_if_index,
336 enable=1)
Neale Ranns75152282017-01-09 01:00:45 -0800337
338 def ip6_disable(self):
339 """Put interface ADMIN-DOWN."""
Klement Sekerada505f62017-01-04 12:58:53 +0100340 self.test.vapi.ip6_sw_interface_enable_disable(self.sw_if_index,
341 enable=0)
Neale Ranns75152282017-01-09 01:00:45 -0800342
Klement Sekeraf62ae122016-10-11 11:47:09 +0200343 def add_sub_if(self, sub_if):
Matej Klotton86d87c42016-11-11 11:38:55 +0100344 """Register a sub-interface with this interface.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200345
346 :param sub_if: sub-interface
Klement Sekeraf62ae122016-10-11 11:47:09 +0200347 """
348 if not hasattr(self, 'sub_if'):
349 self.sub_if = sub_if
350 else:
351 if isinstance(self.sub_if, list):
352 self.sub_if.append(sub_if)
353 else:
354 self.sub_if = sub_if
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000355
356 def enable_mpls(self):
Matej Klotton86d87c42016-11-11 11:38:55 +0100357 """Enable MPLS on the VPP interface."""
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000358 self.test.vapi.sw_interface_enable_disable_mpls(
359 self.sw_if_index)
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100360
Neale Ranns180279b2017-03-16 15:49:09 -0400361 def disable_mpls(self):
362 """Enable MPLS on the VPP interface."""
363 self.test.vapi.sw_interface_enable_disable_mpls(
364 self.sw_if_index, 0)
365
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100366 def is_ip4_entry_in_fib_dump(self, dump):
367 for i in dump:
368 if i.address == self.local_ip4n and \
369 i.address_length == self.local_ip4_prefix_len and \
370 i.table_id == self.ip4_table_id:
371 return True
372 return False
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800373
374 def set_unnumbered(self, ip_sw_if_index):
375 """ Set the interface to unnumbered via ip_sw_if_index """
376 self.test.vapi.sw_interface_set_unnumbered(
377 self.sw_if_index,
378 ip_sw_if_index)
379
Neale Ranns37be7362017-02-21 17:30:26 -0800380 def unset_unnumbered(self, ip_sw_if_index):
Neale Ranns4b919a52017-03-11 05:55:21 -0800381 """ Unset the interface to unnumbered via ip_sw_if_index """
Neale Ranns37be7362017-02-21 17:30:26 -0800382 self.test.vapi.sw_interface_set_unnumbered(
383 self.sw_if_index,
384 ip_sw_if_index,
385 is_add=0)
386
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800387 def set_proxy_arp(self, enable=1):
388 """ Set the interface to enable/disable Proxy ARP """
389 self.test.vapi.proxy_arp_intfc_enable_disable(
390 self.sw_if_index,
391 enable)
Klement Sekera75e7d132017-09-20 08:26:30 +0200392
393 def query_vpp_config(self):
394 dump = self.test.vapi.sw_interface_dump()
395 return self.is_interface_config_in_dump(dump)
396
397 def is_interface_config_in_dump(self, dump):
398 for i in dump:
399 if i.interface_name.rstrip(' \t\r\n\0') == self.name and \
400 i.sw_if_index == self.sw_if_index:
401 return True
402 else:
403 return False