Skip to content

Commit fac1769

Browse files
authored
Accept 0 for queue and dscp (sonic-net#2162)
Signed-off-by: bingwang <[email protected]>
1 parent 288c2d8 commit fac1769

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

config/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,7 @@ def gather_session_info(session_info, policer, queue, src_port, direction):
20252025
if policer:
20262026
session_info['policer'] = policer
20272027

2028-
if queue:
2028+
if queue is not None:
20292029
session_info['queue'] = queue
20302030

20312031
if src_port:
@@ -2051,7 +2051,7 @@ def add_erspan(session_name, src_ip, dst_ip, dscp, ttl, gre_type, queue, policer
20512051
"ttl": ttl
20522052
}
20532053

2054-
if gre_type:
2054+
if gre_type is not None:
20552055
session_info['gre_type'] = gre_type
20562056

20572057
session_info = gather_session_info(session_info, policer, queue, src_port, direction)

tests/config_mirror_session_test.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ def test_mirror_session_add():
8080

8181
mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, 0x1234, 100, None)
8282

83+
result = runner.invoke(
84+
config.config.commands["mirror_session"].commands["add"],
85+
["test_session", "100.1.1.1", "2.2.2.2", "8", "63", "0", "0"])
86+
87+
mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, 0, 0, None)
88+
8389

8490
def test_mirror_session_erspan_add():
8591
runner = CliRunner()
@@ -153,6 +159,12 @@ def test_mirror_session_erspan_add():
153159

154160
mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, 0x1234, 100, None, None, None)
155161

162+
result = runner.invoke(
163+
config.config.commands["mirror_session"].commands["erspan"].commands["add"],
164+
["test_session", "100.1.1.1", "2.2.2.2", "8", "63", "0", "0"])
165+
166+
mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, 0, 0, None, None, None)
167+
156168

157169
def test_mirror_session_span_add():
158170
runner = CliRunner()
@@ -246,9 +258,12 @@ def test_mirror_session_span_add():
246258
result = runner.invoke(
247259
config.config.commands["mirror_session"].commands["span"].commands["add"],
248260
["test_session", "Ethernet8", "Ethernet4", "tx", "100"])
261+
262+
mocked.assert_called_with("test_session", "Ethernet8", "Ethernet4", "tx", 100, None)
263+
249264
result = runner.invoke(
250265
config.config.commands["mirror_session"].commands["span"].commands["add"],
251-
["test_session", "Ethernet0", "Ethernet4", "rx", "100"])
266+
["test_session", "Ethernet0", "Ethernet4", "rx", "0"])
252267

253-
mocked.assert_called_with("test_session", "Ethernet0", "Ethernet4", "rx", 100, None)
268+
mocked.assert_called_with("test_session", "Ethernet0", "Ethernet4", "rx", 0, None)
254269

0 commit comments

Comments
 (0)