blob: 4aaf08cb0c9c4fe28369595346afa20f33df3fb1 [file] [log] [blame]
Renato Botelho do Coutoead1e532019-10-31 13:31:07 -05001#!/usr/bin/env python3
Eyal Bari284293a2017-06-06 14:18:55 +03002
3import unittest
4import random
5
6from scapy.packet import Raw
7from scapy.layers.l2 import Ether, Dot1Q
8from scapy.layers.inet import IP, UDP
9
10from util import Host
Dave Wallace8800f732023-08-31 00:47:44 -040011from framework import VppTestCase
12from asfframework import VppTestRunner
Paul Vinciguerra95c0ca42019-03-28 13:07:00 -070013from vpp_sub_interface import L2_VTR_OP, VppDot1QSubint, VppDot1ADSubint
Eyal Bari284293a2017-06-06 14:18:55 +030014from collections import namedtuple
15
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020016Tag = namedtuple("Tag", ["dot1", "vlan"])
Eyal Bari284293a2017-06-06 14:18:55 +030017DOT1AD = 0x88A8
18DOT1Q = 0x8100
19
20
21class TestVtr(VppTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020022 """VTR Test Case"""
Eyal Bari284293a2017-06-06 14:18:55 +030023
24 @classmethod
25 def setUpClass(cls):
26 super(TestVtr, cls).setUpClass()
27
28 # Test variables
29 cls.bd_id = 1
30 cls.mac_entries_count = 5
31 cls.Atag = 100
32 cls.Btag = 200
33 cls.dot1ad_sub_id = 20
34
35 try:
36 ifs = range(3)
37 cls.create_pg_interfaces(ifs)
38
39 cls.sub_interfaces = [
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020040 VppDot1ADSubint(cls, cls.pg1, cls.dot1ad_sub_id, cls.Btag, cls.Atag),
41 VppDot1QSubint(cls, cls.pg2, cls.Btag),
42 ]
Eyal Bari284293a2017-06-06 14:18:55 +030043
44 interfaces = list(cls.pg_interfaces)
45 interfaces.extend(cls.sub_interfaces)
46
47 # Create BD with MAC learning enabled and put interfaces and
48 # sub-interfaces to this BD
49 for pg_if in cls.pg_interfaces:
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020050 sw_if_index = (
51 pg_if.sub_if.sw_if_index
52 if hasattr(pg_if, "sub_if")
53 else pg_if.sw_if_index
54 )
55 cls.vapi.sw_interface_set_l2_bridge(
56 rx_sw_if_index=sw_if_index, bd_id=cls.bd_id
57 )
Eyal Bari284293a2017-06-06 14:18:55 +030058
59 # setup all interfaces
60 for i in interfaces:
61 i.admin_up()
62
63 # mapping between packet-generator index and lists of test hosts
64 cls.hosts_by_pg_idx = dict()
65
66 # create test host entries and inject packets to learn MAC entries
67 # in the bridge-domain
68 cls.create_hosts_and_learn(cls.mac_entries_count)
69 cls.logger.info(cls.vapi.ppcli("show l2fib"))
70
71 except Exception:
72 super(TestVtr, cls).tearDownClass()
73 raise
74
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070075 @classmethod
76 def tearDownClass(cls):
77 super(TestVtr, cls).tearDownClass()
78
Eyal Bari284293a2017-06-06 14:18:55 +030079 def setUp(self):
80 """
81 Clear trace and packet infos before running each test.
82 """
83 super(TestVtr, self).setUp()
84 self.reset_packet_infos()
85
86 def tearDown(self):
87 """
88 Show various debug prints after each test.
89 """
90 super(TestVtr, self).tearDown()
Paul Vinciguerra90cf21b2019-03-13 09:23:05 -070091
92 def show_commands_at_teardown(self):
93 self.logger.info(self.vapi.ppcli("show l2fib verbose"))
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020094 self.logger.info(self.vapi.ppcli("show bridge-domain %s detail" % self.bd_id))
Eyal Bari284293a2017-06-06 14:18:55 +030095
96 @classmethod
97 def create_hosts_and_learn(cls, count):
98 for pg_if in cls.pg_interfaces:
99 cls.hosts_by_pg_idx[pg_if.sw_if_index] = []
100 hosts = cls.hosts_by_pg_idx[pg_if.sw_if_index]
101 packets = []
102 for j in range(1, count + 1):
103 host = Host(
104 "00:00:00:ff:%02x:%02x" % (pg_if.sw_if_index, j),
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200105 "172.17.1%02x.%u" % (pg_if.sw_if_index, j),
106 )
107 packet = Ether(dst="ff:ff:ff:ff:ff:ff", src=host.mac)
Eyal Bari284293a2017-06-06 14:18:55 +0300108 hosts.append(host)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200109 if hasattr(pg_if, "sub_if"):
Eyal Bari284293a2017-06-06 14:18:55 +0300110 packet = pg_if.sub_if.add_dot1_layer(packet)
111 packets.append(packet)
112 pg_if.add_stream(packets)
113 cls.logger.info("Sending broadcast eth frames for MAC learning")
114 cls.pg_enable_capture(cls.pg_interfaces)
115 cls.pg_start()
116
117 def create_packet(self, src_if, dst_if, do_dot1=True):
118 packet_sizes = [64, 512, 1518, 9018]
119 dst_host = random.choice(self.hosts_by_pg_idx[dst_if.sw_if_index])
120 src_host = random.choice(self.hosts_by_pg_idx[src_if.sw_if_index])
121 pkt_info = self.create_packet_info(src_if, dst_if)
122 payload = self.info_to_payload(pkt_info)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200123 p = (
124 Ether(dst=dst_host.mac, src=src_host.mac)
125 / IP(src=src_host.ip4, dst=dst_host.ip4)
126 / UDP(sport=1234, dport=1234)
127 / Raw(payload)
128 )
Eyal Bari284293a2017-06-06 14:18:55 +0300129 pkt_info.data = p.copy()
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200130 if do_dot1 and hasattr(src_if, "sub_if"):
Eyal Bari284293a2017-06-06 14:18:55 +0300131 p = src_if.sub_if.add_dot1_layer(p)
132 size = random.choice(packet_sizes)
133 self.extend_packet(p, size)
134 return p
135
136 def _add_tag(self, packet, vlan, tag_type):
137 payload = packet.payload
138 inner_type = packet.type
139 packet.remove_payload()
140 packet.add_payload(Dot1Q(vlan=vlan) / payload)
141 packet.payload.type = inner_type
142 packet.payload.vlan = vlan
143 packet.type = tag_type
144 return packet
145
146 def _remove_tag(self, packet, vlan=None, tag_type=None):
147 if tag_type:
148 self.assertEqual(packet.type, tag_type)
149
150 payload = packet.payload
151 if vlan:
152 self.assertEqual(payload.vlan, vlan)
153 inner_type = payload.type
154 payload = payload.payload
155 packet.remove_payload()
156 packet.add_payload(payload)
157 packet.type = inner_type
158
159 def add_tags(self, packet, tags):
160 for t in reversed(tags):
161 self._add_tag(packet, t.vlan, t.dot1)
162
163 def remove_tags(self, packet, tags):
164 for t in tags:
165 self._remove_tag(packet, t.vlan, t.dot1)
166
167 def vtr_test(self, swif, tags):
168 p = self.create_packet(swif, self.pg0)
169 swif.add_stream(p)
170 self.pg_enable_capture(self.pg_interfaces)
171 self.pg_start()
172 rx = self.pg0.get_capture(1)
173
174 if tags:
175 self.remove_tags(rx[0], tags)
176 self.assertTrue(Dot1Q not in rx[0])
177
178 if not tags:
179 return
180
181 i = VppDot1QSubint(self, self.pg0, tags[0].vlan)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200182 self.vapi.sw_interface_set_l2_bridge(
183 rx_sw_if_index=i.sw_if_index, bd_id=self.bd_id, enable=1
184 )
Eyal Bari284293a2017-06-06 14:18:55 +0300185 i.admin_up()
186
187 p = self.create_packet(self.pg0, swif, do_dot1=False)
188 self.add_tags(p, tags)
189 self.pg0.add_stream(p)
190 self.pg_enable_capture(self.pg_interfaces)
191 self.pg_start()
192 rx = swif.get_capture(1)
193 swif.sub_if.remove_dot1_layer(rx[0])
194 self.assertTrue(Dot1Q not in rx[0])
195
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200196 self.vapi.sw_interface_set_l2_bridge(
197 rx_sw_if_index=i.sw_if_index, bd_id=self.bd_id, enable=0
198 )
Eyal Bari284293a2017-06-06 14:18:55 +0300199 i.remove_vpp_config()
200
201 def test_1ad_vtr_pop_1(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200202 """1AD VTR pop 1 test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300203 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_POP_1)
204 self.vtr_test(self.pg1, [Tag(dot1=DOT1Q, vlan=100)])
205
206 def test_1ad_vtr_pop_2(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200207 """1AD VTR pop 2 test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300208 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_POP_2)
209 self.vtr_test(self.pg1, [])
210
211 def test_1ad_vtr_push_1ad(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200212 """1AD VTR push 1 1AD test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300213 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_PUSH_1, tag=300)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200214 self.vtr_test(
215 self.pg1,
216 [
217 Tag(dot1=DOT1AD, vlan=300),
218 Tag(dot1=DOT1AD, vlan=200),
219 Tag(dot1=DOT1Q, vlan=100),
220 ],
221 )
Eyal Bari284293a2017-06-06 14:18:55 +0300222
223 def test_1ad_vtr_push_2ad(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200224 """1AD VTR push 2 1AD test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300225 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_PUSH_2, outer=400, inner=300)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200226 self.vtr_test(
227 self.pg1,
228 [
229 Tag(dot1=DOT1AD, vlan=400),
230 Tag(dot1=DOT1Q, vlan=300),
231 Tag(dot1=DOT1AD, vlan=200),
232 Tag(dot1=DOT1Q, vlan=100),
233 ],
234 )
Eyal Bari284293a2017-06-06 14:18:55 +0300235
236 def test_1ad_vtr_push_1q(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200237 """1AD VTR push 1 1Q test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300238 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_PUSH_1, tag=300, push1q=1)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200239 self.vtr_test(
240 self.pg1,
241 [
242 Tag(dot1=DOT1Q, vlan=300),
243 Tag(dot1=DOT1AD, vlan=200),
244 Tag(dot1=DOT1Q, vlan=100),
245 ],
246 )
Eyal Bari284293a2017-06-06 14:18:55 +0300247
248 def test_1ad_vtr_push_2q(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200249 """1AD VTR push 2 1Q test"""
250 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_PUSH_2, outer=400, inner=300, push1q=1)
251 self.vtr_test(
252 self.pg1,
253 [
254 Tag(dot1=DOT1Q, vlan=400),
255 Tag(dot1=DOT1Q, vlan=300),
256 Tag(dot1=DOT1AD, vlan=200),
257 Tag(dot1=DOT1Q, vlan=100),
258 ],
259 )
Eyal Bari284293a2017-06-06 14:18:55 +0300260
261 def test_1ad_vtr_translate_1_1ad(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200262 """1AD VTR translate 1 -> 1 1AD test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300263 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_1_1, tag=300)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200264 self.vtr_test(self.pg1, [Tag(dot1=DOT1AD, vlan=300), Tag(dot1=DOT1Q, vlan=100)])
Eyal Bari284293a2017-06-06 14:18:55 +0300265
266 def test_1ad_vtr_translate_1_2ad(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200267 """1AD VTR translate 1 -> 2 1AD test"""
268 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_1_2, inner=300, outer=400)
269 self.vtr_test(
270 self.pg1,
271 [
272 Tag(dot1=DOT1AD, vlan=400),
273 Tag(dot1=DOT1Q, vlan=300),
274 Tag(dot1=DOT1Q, vlan=100),
275 ],
276 )
Eyal Bari284293a2017-06-06 14:18:55 +0300277
278 def test_1ad_vtr_translate_2_1ad(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200279 """1AD VTR translate 2 -> 1 1AD test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300280 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_2_1, tag=300)
281 self.vtr_test(self.pg1, [Tag(dot1=DOT1AD, vlan=300)])
282
283 def test_1ad_vtr_translate_2_2ad(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200284 """1AD VTR translate 2 -> 2 1AD test"""
285 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_2_2, inner=300, outer=400)
286 self.vtr_test(self.pg1, [Tag(dot1=DOT1AD, vlan=400), Tag(dot1=DOT1Q, vlan=300)])
Eyal Bari284293a2017-06-06 14:18:55 +0300287
288 def test_1ad_vtr_translate_1_1q(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200289 """1AD VTR translate 1 -> 1 1Q test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300290 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_1_1, tag=300, push1q=1)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200291 self.vtr_test(self.pg1, [Tag(dot1=DOT1Q, vlan=300), Tag(dot1=DOT1Q, vlan=100)])
Eyal Bari284293a2017-06-06 14:18:55 +0300292
293 def test_1ad_vtr_translate_1_2q(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200294 """1AD VTR translate 1 -> 2 1Q test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300295 self.pg1.sub_if.set_vtr(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200296 L2_VTR_OP.L2_TRANSLATE_1_2, inner=300, outer=400, push1q=1
297 )
298 self.vtr_test(
299 self.pg1,
300 [
301 Tag(dot1=DOT1Q, vlan=400),
302 Tag(dot1=DOT1Q, vlan=300),
303 Tag(dot1=DOT1Q, vlan=100),
304 ],
305 )
Eyal Bari284293a2017-06-06 14:18:55 +0300306
307 def test_1ad_vtr_translate_2_1q(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200308 """1AD VTR translate 2 -> 1 1Q test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300309 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_2_1, tag=300, push1q=1)
310 self.vtr_test(self.pg1, [Tag(dot1=DOT1Q, vlan=300)])
311
312 def test_1ad_vtr_translate_2_2q(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200313 """1AD VTR translate 2 -> 2 1Q test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300314 self.pg1.sub_if.set_vtr(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200315 L2_VTR_OP.L2_TRANSLATE_2_2, inner=300, outer=400, push1q=1
316 )
317 self.vtr_test(self.pg1, [Tag(dot1=DOT1Q, vlan=400), Tag(dot1=DOT1Q, vlan=300)])
Eyal Bari284293a2017-06-06 14:18:55 +0300318
319 def test_1q_vtr_pop_1(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200320 """1Q VTR pop 1 test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300321 self.pg2.sub_if.set_vtr(L2_VTR_OP.L2_POP_1)
322 self.vtr_test(self.pg2, [])
323
324 def test_1q_vtr_push_1(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200325 """1Q VTR push 1 test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300326 self.pg2.sub_if.set_vtr(L2_VTR_OP.L2_PUSH_1, tag=300)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200327 self.vtr_test(self.pg2, [Tag(dot1=DOT1AD, vlan=300), Tag(dot1=DOT1Q, vlan=200)])
Eyal Bari284293a2017-06-06 14:18:55 +0300328
329 def test_1q_vtr_push_2(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200330 """1Q VTR push 2 test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300331 self.pg2.sub_if.set_vtr(L2_VTR_OP.L2_PUSH_2, outer=400, inner=300)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200332 self.vtr_test(
333 self.pg2,
334 [
335 Tag(dot1=DOT1AD, vlan=400),
336 Tag(dot1=DOT1Q, vlan=300),
337 Tag(dot1=DOT1Q, vlan=200),
338 ],
339 )
Eyal Bari284293a2017-06-06 14:18:55 +0300340
341 def test_1q_vtr_translate_1_1(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200342 """1Q VTR translate 1 -> 1 test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300343 self.pg2.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_1_1, tag=300)
344 self.vtr_test(self.pg2, [Tag(dot1=DOT1AD, vlan=300)])
345
346 def test_1q_vtr_translate_1_2(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200347 """1Q VTR translate 1 -> 2 test"""
348 self.pg2.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_1_2, inner=300, outer=400)
349 self.vtr_test(self.pg2, [Tag(dot1=DOT1AD, vlan=400), Tag(dot1=DOT1Q, vlan=300)])
Eyal Bari284293a2017-06-06 14:18:55 +0300350
Jon Loeliger9485d992019-11-08 15:05:23 -0600351 def test_if_vtr_disable(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200352 """Disable VTR on non-sub-interfaces"""
Jon Loeliger9485d992019-11-08 15:05:23 -0600353 # First set the VTR fields to junk
354 self.vapi.l2_interface_vlan_tag_rewrite(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200355 sw_if_index=self.pg0.sw_if_index,
356 vtr_op=L2_VTR_OP.L2_PUSH_2,
357 push_dot1q=1,
358 tag1=19,
359 tag2=630,
360 )
Jon Loeliger9485d992019-11-08 15:05:23 -0600361
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200362 if_state = self.vapi.sw_interface_dump(sw_if_index=self.pg0.sw_if_index)
Jon Loeliger9485d992019-11-08 15:05:23 -0600363 self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index)
364 self.assertNotEqual(if_state[0].vtr_op, L2_VTR_OP.L2_DISABLED)
365
366 # Then ensure that a request to disable VTR is honored.
367 self.vapi.l2_interface_vlan_tag_rewrite(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200368 sw_if_index=self.pg0.sw_if_index, vtr_op=L2_VTR_OP.L2_DISABLED
369 )
Jon Loeliger9485d992019-11-08 15:05:23 -0600370
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200371 if_state = self.vapi.sw_interface_dump(sw_if_index=self.pg0.sw_if_index)
Jon Loeliger9485d992019-11-08 15:05:23 -0600372 self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index)
373 self.assertEqual(if_state[0].vtr_op, L2_VTR_OP.L2_DISABLED)
374
375 def test_if_vtr_push_1q(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200376 """1Q VTR push 1 on non-sub-interfaces"""
Jon Loeliger9485d992019-11-08 15:05:23 -0600377 self.vapi.l2_interface_vlan_tag_rewrite(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200378 sw_if_index=self.pg0.sw_if_index,
379 vtr_op=L2_VTR_OP.L2_PUSH_1,
380 push_dot1q=1,
381 tag1=150,
382 )
Jon Loeliger9485d992019-11-08 15:05:23 -0600383
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200384 if_state = self.vapi.sw_interface_dump(sw_if_index=self.pg0.sw_if_index)
Jon Loeliger9485d992019-11-08 15:05:23 -0600385 self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index)
386 self.assertEqual(if_state[0].vtr_op, L2_VTR_OP.L2_PUSH_1)
387 self.assertEqual(if_state[0].vtr_tag1, 150)
388 self.assertNotEqual(if_state[0].vtr_push_dot1q, 0)
389
390 def test_if_vtr_push_2ad(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200391 """1AD VTR push 2 on non-sub-interfaces"""
Jon Loeliger9485d992019-11-08 15:05:23 -0600392 self.vapi.l2_interface_vlan_tag_rewrite(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200393 sw_if_index=self.pg0.sw_if_index,
394 vtr_op=L2_VTR_OP.L2_PUSH_2,
395 push_dot1q=0,
396 tag1=450,
397 tag2=350,
398 )
Jon Loeliger9485d992019-11-08 15:05:23 -0600399
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200400 if_state = self.vapi.sw_interface_dump(sw_if_index=self.pg0.sw_if_index)
Jon Loeliger9485d992019-11-08 15:05:23 -0600401 self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index)
402 self.assertEqual(if_state[0].vtr_op, L2_VTR_OP.L2_PUSH_2)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200403 self.assertEqual(if_state[0].vtr_tag1, 450) # outer
404 self.assertEqual(if_state[0].vtr_tag2, 350) # inner
Jon Loeliger9485d992019-11-08 15:05:23 -0600405 self.assertEqual(if_state[0].vtr_push_dot1q, 0)
Eyal Bari284293a2017-06-06 14:18:55 +0300406
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200407
408if __name__ == "__main__":
Eyal Bari284293a2017-06-06 14:18:55 +0300409 unittest.main(testRunner=VppTestRunner)