blob: b33dcb665419cf97ad378ca5ddb48bb87fd4bfcc [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
11from framework import VppTestCase, VppTestRunner
Paul Vinciguerra95c0ca42019-03-28 13:07:00 -070012from vpp_sub_interface import L2_VTR_OP, VppDot1QSubint, VppDot1ADSubint
Eyal Bari284293a2017-06-06 14:18:55 +030013from collections import namedtuple
14
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020015Tag = namedtuple("Tag", ["dot1", "vlan"])
Eyal Bari284293a2017-06-06 14:18:55 +030016DOT1AD = 0x88A8
17DOT1Q = 0x8100
18
19
20class TestVtr(VppTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020021 """VTR Test Case"""
Eyal Bari284293a2017-06-06 14:18:55 +030022
23 @classmethod
24 def setUpClass(cls):
25 super(TestVtr, cls).setUpClass()
26
27 # Test variables
28 cls.bd_id = 1
29 cls.mac_entries_count = 5
30 cls.Atag = 100
31 cls.Btag = 200
32 cls.dot1ad_sub_id = 20
33
34 try:
35 ifs = range(3)
36 cls.create_pg_interfaces(ifs)
37
38 cls.sub_interfaces = [
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020039 VppDot1ADSubint(cls, cls.pg1, cls.dot1ad_sub_id, cls.Btag, cls.Atag),
40 VppDot1QSubint(cls, cls.pg2, cls.Btag),
41 ]
Eyal Bari284293a2017-06-06 14:18:55 +030042
43 interfaces = list(cls.pg_interfaces)
44 interfaces.extend(cls.sub_interfaces)
45
46 # Create BD with MAC learning enabled and put interfaces and
47 # sub-interfaces to this BD
48 for pg_if in cls.pg_interfaces:
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020049 sw_if_index = (
50 pg_if.sub_if.sw_if_index
51 if hasattr(pg_if, "sub_if")
52 else pg_if.sw_if_index
53 )
54 cls.vapi.sw_interface_set_l2_bridge(
55 rx_sw_if_index=sw_if_index, bd_id=cls.bd_id
56 )
Eyal Bari284293a2017-06-06 14:18:55 +030057
58 # setup all interfaces
59 for i in interfaces:
60 i.admin_up()
61
62 # mapping between packet-generator index and lists of test hosts
63 cls.hosts_by_pg_idx = dict()
64
65 # create test host entries and inject packets to learn MAC entries
66 # in the bridge-domain
67 cls.create_hosts_and_learn(cls.mac_entries_count)
68 cls.logger.info(cls.vapi.ppcli("show l2fib"))
69
70 except Exception:
71 super(TestVtr, cls).tearDownClass()
72 raise
73
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070074 @classmethod
75 def tearDownClass(cls):
76 super(TestVtr, cls).tearDownClass()
77
Eyal Bari284293a2017-06-06 14:18:55 +030078 def setUp(self):
79 """
80 Clear trace and packet infos before running each test.
81 """
82 super(TestVtr, self).setUp()
83 self.reset_packet_infos()
84
85 def tearDown(self):
86 """
87 Show various debug prints after each test.
88 """
89 super(TestVtr, self).tearDown()
Paul Vinciguerra90cf21b2019-03-13 09:23:05 -070090
91 def show_commands_at_teardown(self):
92 self.logger.info(self.vapi.ppcli("show l2fib verbose"))
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020093 self.logger.info(self.vapi.ppcli("show bridge-domain %s detail" % self.bd_id))
Eyal Bari284293a2017-06-06 14:18:55 +030094
95 @classmethod
96 def create_hosts_and_learn(cls, count):
97 for pg_if in cls.pg_interfaces:
98 cls.hosts_by_pg_idx[pg_if.sw_if_index] = []
99 hosts = cls.hosts_by_pg_idx[pg_if.sw_if_index]
100 packets = []
101 for j in range(1, count + 1):
102 host = Host(
103 "00:00:00:ff:%02x:%02x" % (pg_if.sw_if_index, j),
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200104 "172.17.1%02x.%u" % (pg_if.sw_if_index, j),
105 )
106 packet = Ether(dst="ff:ff:ff:ff:ff:ff", src=host.mac)
Eyal Bari284293a2017-06-06 14:18:55 +0300107 hosts.append(host)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200108 if hasattr(pg_if, "sub_if"):
Eyal Bari284293a2017-06-06 14:18:55 +0300109 packet = pg_if.sub_if.add_dot1_layer(packet)
110 packets.append(packet)
111 pg_if.add_stream(packets)
112 cls.logger.info("Sending broadcast eth frames for MAC learning")
113 cls.pg_enable_capture(cls.pg_interfaces)
114 cls.pg_start()
115
116 def create_packet(self, src_if, dst_if, do_dot1=True):
117 packet_sizes = [64, 512, 1518, 9018]
118 dst_host = random.choice(self.hosts_by_pg_idx[dst_if.sw_if_index])
119 src_host = random.choice(self.hosts_by_pg_idx[src_if.sw_if_index])
120 pkt_info = self.create_packet_info(src_if, dst_if)
121 payload = self.info_to_payload(pkt_info)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200122 p = (
123 Ether(dst=dst_host.mac, src=src_host.mac)
124 / IP(src=src_host.ip4, dst=dst_host.ip4)
125 / UDP(sport=1234, dport=1234)
126 / Raw(payload)
127 )
Eyal Bari284293a2017-06-06 14:18:55 +0300128 pkt_info.data = p.copy()
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200129 if do_dot1 and hasattr(src_if, "sub_if"):
Eyal Bari284293a2017-06-06 14:18:55 +0300130 p = src_if.sub_if.add_dot1_layer(p)
131 size = random.choice(packet_sizes)
132 self.extend_packet(p, size)
133 return p
134
135 def _add_tag(self, packet, vlan, tag_type):
136 payload = packet.payload
137 inner_type = packet.type
138 packet.remove_payload()
139 packet.add_payload(Dot1Q(vlan=vlan) / payload)
140 packet.payload.type = inner_type
141 packet.payload.vlan = vlan
142 packet.type = tag_type
143 return packet
144
145 def _remove_tag(self, packet, vlan=None, tag_type=None):
146 if tag_type:
147 self.assertEqual(packet.type, tag_type)
148
149 payload = packet.payload
150 if vlan:
151 self.assertEqual(payload.vlan, vlan)
152 inner_type = payload.type
153 payload = payload.payload
154 packet.remove_payload()
155 packet.add_payload(payload)
156 packet.type = inner_type
157
158 def add_tags(self, packet, tags):
159 for t in reversed(tags):
160 self._add_tag(packet, t.vlan, t.dot1)
161
162 def remove_tags(self, packet, tags):
163 for t in tags:
164 self._remove_tag(packet, t.vlan, t.dot1)
165
166 def vtr_test(self, swif, tags):
167 p = self.create_packet(swif, self.pg0)
168 swif.add_stream(p)
169 self.pg_enable_capture(self.pg_interfaces)
170 self.pg_start()
171 rx = self.pg0.get_capture(1)
172
173 if tags:
174 self.remove_tags(rx[0], tags)
175 self.assertTrue(Dot1Q not in rx[0])
176
177 if not tags:
178 return
179
180 i = VppDot1QSubint(self, self.pg0, tags[0].vlan)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200181 self.vapi.sw_interface_set_l2_bridge(
182 rx_sw_if_index=i.sw_if_index, bd_id=self.bd_id, enable=1
183 )
Eyal Bari284293a2017-06-06 14:18:55 +0300184 i.admin_up()
185
186 p = self.create_packet(self.pg0, swif, do_dot1=False)
187 self.add_tags(p, tags)
188 self.pg0.add_stream(p)
189 self.pg_enable_capture(self.pg_interfaces)
190 self.pg_start()
191 rx = swif.get_capture(1)
192 swif.sub_if.remove_dot1_layer(rx[0])
193 self.assertTrue(Dot1Q not in rx[0])
194
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200195 self.vapi.sw_interface_set_l2_bridge(
196 rx_sw_if_index=i.sw_if_index, bd_id=self.bd_id, enable=0
197 )
Eyal Bari284293a2017-06-06 14:18:55 +0300198 i.remove_vpp_config()
199
200 def test_1ad_vtr_pop_1(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200201 """1AD VTR pop 1 test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300202 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_POP_1)
203 self.vtr_test(self.pg1, [Tag(dot1=DOT1Q, vlan=100)])
204
205 def test_1ad_vtr_pop_2(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200206 """1AD VTR pop 2 test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300207 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_POP_2)
208 self.vtr_test(self.pg1, [])
209
210 def test_1ad_vtr_push_1ad(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200211 """1AD VTR push 1 1AD test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300212 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_PUSH_1, tag=300)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200213 self.vtr_test(
214 self.pg1,
215 [
216 Tag(dot1=DOT1AD, vlan=300),
217 Tag(dot1=DOT1AD, vlan=200),
218 Tag(dot1=DOT1Q, vlan=100),
219 ],
220 )
Eyal Bari284293a2017-06-06 14:18:55 +0300221
222 def test_1ad_vtr_push_2ad(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200223 """1AD VTR push 2 1AD test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300224 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_PUSH_2, outer=400, inner=300)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200225 self.vtr_test(
226 self.pg1,
227 [
228 Tag(dot1=DOT1AD, vlan=400),
229 Tag(dot1=DOT1Q, vlan=300),
230 Tag(dot1=DOT1AD, vlan=200),
231 Tag(dot1=DOT1Q, vlan=100),
232 ],
233 )
Eyal Bari284293a2017-06-06 14:18:55 +0300234
235 def test_1ad_vtr_push_1q(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200236 """1AD VTR push 1 1Q test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300237 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_PUSH_1, tag=300, push1q=1)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200238 self.vtr_test(
239 self.pg1,
240 [
241 Tag(dot1=DOT1Q, vlan=300),
242 Tag(dot1=DOT1AD, vlan=200),
243 Tag(dot1=DOT1Q, vlan=100),
244 ],
245 )
Eyal Bari284293a2017-06-06 14:18:55 +0300246
247 def test_1ad_vtr_push_2q(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200248 """1AD VTR push 2 1Q test"""
249 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_PUSH_2, outer=400, inner=300, push1q=1)
250 self.vtr_test(
251 self.pg1,
252 [
253 Tag(dot1=DOT1Q, vlan=400),
254 Tag(dot1=DOT1Q, vlan=300),
255 Tag(dot1=DOT1AD, vlan=200),
256 Tag(dot1=DOT1Q, vlan=100),
257 ],
258 )
Eyal Bari284293a2017-06-06 14:18:55 +0300259
260 def test_1ad_vtr_translate_1_1ad(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200261 """1AD VTR translate 1 -> 1 1AD test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300262 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_1_1, tag=300)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200263 self.vtr_test(self.pg1, [Tag(dot1=DOT1AD, vlan=300), Tag(dot1=DOT1Q, vlan=100)])
Eyal Bari284293a2017-06-06 14:18:55 +0300264
265 def test_1ad_vtr_translate_1_2ad(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200266 """1AD VTR translate 1 -> 2 1AD test"""
267 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_1_2, inner=300, outer=400)
268 self.vtr_test(
269 self.pg1,
270 [
271 Tag(dot1=DOT1AD, vlan=400),
272 Tag(dot1=DOT1Q, vlan=300),
273 Tag(dot1=DOT1Q, vlan=100),
274 ],
275 )
Eyal Bari284293a2017-06-06 14:18:55 +0300276
277 def test_1ad_vtr_translate_2_1ad(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200278 """1AD VTR translate 2 -> 1 1AD test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300279 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_2_1, tag=300)
280 self.vtr_test(self.pg1, [Tag(dot1=DOT1AD, vlan=300)])
281
282 def test_1ad_vtr_translate_2_2ad(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200283 """1AD VTR translate 2 -> 2 1AD test"""
284 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_2_2, inner=300, outer=400)
285 self.vtr_test(self.pg1, [Tag(dot1=DOT1AD, vlan=400), Tag(dot1=DOT1Q, vlan=300)])
Eyal Bari284293a2017-06-06 14:18:55 +0300286
287 def test_1ad_vtr_translate_1_1q(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200288 """1AD VTR translate 1 -> 1 1Q test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300289 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_1_1, tag=300, push1q=1)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200290 self.vtr_test(self.pg1, [Tag(dot1=DOT1Q, vlan=300), Tag(dot1=DOT1Q, vlan=100)])
Eyal Bari284293a2017-06-06 14:18:55 +0300291
292 def test_1ad_vtr_translate_1_2q(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200293 """1AD VTR translate 1 -> 2 1Q test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300294 self.pg1.sub_if.set_vtr(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200295 L2_VTR_OP.L2_TRANSLATE_1_2, inner=300, outer=400, push1q=1
296 )
297 self.vtr_test(
298 self.pg1,
299 [
300 Tag(dot1=DOT1Q, vlan=400),
301 Tag(dot1=DOT1Q, vlan=300),
302 Tag(dot1=DOT1Q, vlan=100),
303 ],
304 )
Eyal Bari284293a2017-06-06 14:18:55 +0300305
306 def test_1ad_vtr_translate_2_1q(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200307 """1AD VTR translate 2 -> 1 1Q test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300308 self.pg1.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_2_1, tag=300, push1q=1)
309 self.vtr_test(self.pg1, [Tag(dot1=DOT1Q, vlan=300)])
310
311 def test_1ad_vtr_translate_2_2q(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200312 """1AD VTR translate 2 -> 2 1Q test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300313 self.pg1.sub_if.set_vtr(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200314 L2_VTR_OP.L2_TRANSLATE_2_2, inner=300, outer=400, push1q=1
315 )
316 self.vtr_test(self.pg1, [Tag(dot1=DOT1Q, vlan=400), Tag(dot1=DOT1Q, vlan=300)])
Eyal Bari284293a2017-06-06 14:18:55 +0300317
318 def test_1q_vtr_pop_1(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200319 """1Q VTR pop 1 test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300320 self.pg2.sub_if.set_vtr(L2_VTR_OP.L2_POP_1)
321 self.vtr_test(self.pg2, [])
322
323 def test_1q_vtr_push_1(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200324 """1Q VTR push 1 test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300325 self.pg2.sub_if.set_vtr(L2_VTR_OP.L2_PUSH_1, tag=300)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200326 self.vtr_test(self.pg2, [Tag(dot1=DOT1AD, vlan=300), Tag(dot1=DOT1Q, vlan=200)])
Eyal Bari284293a2017-06-06 14:18:55 +0300327
328 def test_1q_vtr_push_2(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200329 """1Q VTR push 2 test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300330 self.pg2.sub_if.set_vtr(L2_VTR_OP.L2_PUSH_2, outer=400, inner=300)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200331 self.vtr_test(
332 self.pg2,
333 [
334 Tag(dot1=DOT1AD, vlan=400),
335 Tag(dot1=DOT1Q, vlan=300),
336 Tag(dot1=DOT1Q, vlan=200),
337 ],
338 )
Eyal Bari284293a2017-06-06 14:18:55 +0300339
340 def test_1q_vtr_translate_1_1(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200341 """1Q VTR translate 1 -> 1 test"""
Eyal Bari284293a2017-06-06 14:18:55 +0300342 self.pg2.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_1_1, tag=300)
343 self.vtr_test(self.pg2, [Tag(dot1=DOT1AD, vlan=300)])
344
345 def test_1q_vtr_translate_1_2(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200346 """1Q VTR translate 1 -> 2 test"""
347 self.pg2.sub_if.set_vtr(L2_VTR_OP.L2_TRANSLATE_1_2, inner=300, outer=400)
348 self.vtr_test(self.pg2, [Tag(dot1=DOT1AD, vlan=400), Tag(dot1=DOT1Q, vlan=300)])
Eyal Bari284293a2017-06-06 14:18:55 +0300349
Jon Loeliger9485d992019-11-08 15:05:23 -0600350 def test_if_vtr_disable(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200351 """Disable VTR on non-sub-interfaces"""
Jon Loeliger9485d992019-11-08 15:05:23 -0600352 # First set the VTR fields to junk
353 self.vapi.l2_interface_vlan_tag_rewrite(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200354 sw_if_index=self.pg0.sw_if_index,
355 vtr_op=L2_VTR_OP.L2_PUSH_2,
356 push_dot1q=1,
357 tag1=19,
358 tag2=630,
359 )
Jon Loeliger9485d992019-11-08 15:05:23 -0600360
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200361 if_state = self.vapi.sw_interface_dump(sw_if_index=self.pg0.sw_if_index)
Jon Loeliger9485d992019-11-08 15:05:23 -0600362 self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index)
363 self.assertNotEqual(if_state[0].vtr_op, L2_VTR_OP.L2_DISABLED)
364
365 # Then ensure that a request to disable VTR is honored.
366 self.vapi.l2_interface_vlan_tag_rewrite(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200367 sw_if_index=self.pg0.sw_if_index, vtr_op=L2_VTR_OP.L2_DISABLED
368 )
Jon Loeliger9485d992019-11-08 15:05:23 -0600369
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200370 if_state = self.vapi.sw_interface_dump(sw_if_index=self.pg0.sw_if_index)
Jon Loeliger9485d992019-11-08 15:05:23 -0600371 self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index)
372 self.assertEqual(if_state[0].vtr_op, L2_VTR_OP.L2_DISABLED)
373
374 def test_if_vtr_push_1q(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200375 """1Q VTR push 1 on non-sub-interfaces"""
Jon Loeliger9485d992019-11-08 15:05:23 -0600376 self.vapi.l2_interface_vlan_tag_rewrite(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200377 sw_if_index=self.pg0.sw_if_index,
378 vtr_op=L2_VTR_OP.L2_PUSH_1,
379 push_dot1q=1,
380 tag1=150,
381 )
Jon Loeliger9485d992019-11-08 15:05:23 -0600382
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200383 if_state = self.vapi.sw_interface_dump(sw_if_index=self.pg0.sw_if_index)
Jon Loeliger9485d992019-11-08 15:05:23 -0600384 self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index)
385 self.assertEqual(if_state[0].vtr_op, L2_VTR_OP.L2_PUSH_1)
386 self.assertEqual(if_state[0].vtr_tag1, 150)
387 self.assertNotEqual(if_state[0].vtr_push_dot1q, 0)
388
389 def test_if_vtr_push_2ad(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200390 """1AD VTR push 2 on non-sub-interfaces"""
Jon Loeliger9485d992019-11-08 15:05:23 -0600391 self.vapi.l2_interface_vlan_tag_rewrite(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200392 sw_if_index=self.pg0.sw_if_index,
393 vtr_op=L2_VTR_OP.L2_PUSH_2,
394 push_dot1q=0,
395 tag1=450,
396 tag2=350,
397 )
Jon Loeliger9485d992019-11-08 15:05:23 -0600398
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200399 if_state = self.vapi.sw_interface_dump(sw_if_index=self.pg0.sw_if_index)
Jon Loeliger9485d992019-11-08 15:05:23 -0600400 self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index)
401 self.assertEqual(if_state[0].vtr_op, L2_VTR_OP.L2_PUSH_2)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200402 self.assertEqual(if_state[0].vtr_tag1, 450) # outer
403 self.assertEqual(if_state[0].vtr_tag2, 350) # inner
Jon Loeliger9485d992019-11-08 15:05:23 -0600404 self.assertEqual(if_state[0].vtr_push_dot1q, 0)
Eyal Bari284293a2017-06-06 14:18:55 +0300405
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200406
407if __name__ == "__main__":
Eyal Bari284293a2017-06-06 14:18:55 +0300408 unittest.main(testRunner=VppTestRunner)