summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJon Loeliger <jdl@netgate.com>2019-11-08 15:05:23 -0600
committerOle Trøan <otroan@employees.org>2019-11-12 20:37:55 +0000
commit9485d99bd3941b13abf7e47fc7e1d56f7b4fee55 (patch)
treed3f4e90f5cdd5966300d61c89c4bfea81ce5dab9 /test
parent592a909a302262cf4088a5468b8e427f577725e8 (diff)
interface: Allow VLAN tag-rewrite on non-sub-interfaces too.
This fix was first made in commit fdea5c6a00b74971dbb1b7ec4e25839a871006ca but was subsequently lost in commit 053204ab039d34a990ff0e14c32ce3b294fcce0e Added unit test for setting VTR on a non-sub-interface to help ensure no future regressions of this ability. Type: fix Change-Id: I71ce2684fb72383741455829ae2d397ea2e95eae Signed-off-by: Jon Loeliger <jdl@netgate.com>
Diffstat (limited to 'test')
-rw-r--r--test/test_vtr.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/test_vtr.py b/test/test_vtr.py
index 239767a5d17..c3704f1e7b6 100644
--- a/test/test_vtr.py
+++ b/test/test_vtr.py
@@ -331,6 +331,56 @@ class TestVtr(VppTestCase):
self.vtr_test(self.pg2, [Tag(dot1=DOT1AD, vlan=400),
Tag(dot1=DOT1Q, vlan=300)])
+ def test_if_vtr_disable(self):
+ """ Disable VTR on non-sub-interfaces
+ """
+ # First set the VTR fields to junk
+ self.vapi.l2_interface_vlan_tag_rewrite(
+ sw_if_index=self.pg0.sw_if_index, vtr_op=L2_VTR_OP.L2_PUSH_2,
+ push_dot1q=1, tag1=19, tag2=630)
+
+ if_state = self.vapi.sw_interface_dump(
+ sw_if_index=self.pg0.sw_if_index)
+ self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index)
+ self.assertNotEqual(if_state[0].vtr_op, L2_VTR_OP.L2_DISABLED)
+
+ # Then ensure that a request to disable VTR is honored.
+ self.vapi.l2_interface_vlan_tag_rewrite(
+ sw_if_index=self.pg0.sw_if_index, vtr_op=L2_VTR_OP.L2_DISABLED)
+
+ if_state = self.vapi.sw_interface_dump(
+ sw_if_index=self.pg0.sw_if_index)
+ self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index)
+ self.assertEqual(if_state[0].vtr_op, L2_VTR_OP.L2_DISABLED)
+
+ def test_if_vtr_push_1q(self):
+ """ 1Q VTR push 1 on non-sub-interfaces
+ """
+ self.vapi.l2_interface_vlan_tag_rewrite(
+ sw_if_index=self.pg0.sw_if_index, vtr_op=L2_VTR_OP.L2_PUSH_1,
+ push_dot1q=1, tag1=150)
+
+ if_state = self.vapi.sw_interface_dump(
+ sw_if_index=self.pg0.sw_if_index)
+ self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index)
+ self.assertEqual(if_state[0].vtr_op, L2_VTR_OP.L2_PUSH_1)
+ self.assertEqual(if_state[0].vtr_tag1, 150)
+ self.assertNotEqual(if_state[0].vtr_push_dot1q, 0)
+
+ def test_if_vtr_push_2ad(self):
+ """ 1AD VTR push 2 on non-sub-interfaces
+ """
+ self.vapi.l2_interface_vlan_tag_rewrite(
+ sw_if_index=self.pg0.sw_if_index, vtr_op=L2_VTR_OP.L2_PUSH_2,
+ push_dot1q=0, tag1=450, tag2=350)
+
+ if_state = self.vapi.sw_interface_dump(
+ sw_if_index=self.pg0.sw_if_index)
+ self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index)
+ self.assertEqual(if_state[0].vtr_op, L2_VTR_OP.L2_PUSH_2)
+ self.assertEqual(if_state[0].vtr_tag1, 450) # outer
+ self.assertEqual(if_state[0].vtr_tag2, 350) # inner
+ self.assertEqual(if_state[0].vtr_push_dot1q, 0)
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)