Skip to content

Commit e7d7d33

Browse files
chumakdigsilya
authored andcommitted
ovs-router: Fix JSON type for user in rules/show.
The JSON output of ovs-appctl ovs/router/rule/show command printed the 'user' field as integer instead of a boolean. Fix that and add a unit test that checks standard router rules in JSON format. Fixes: e2a2415 ("ovs-router: Introduce ovs/route/rule/{add, del} commands.") Signed-off-by: Dima Chumak <dchumak@nvidia.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
1 parent b63ec0e commit e7d7d33

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

lib/ovs-router.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ ovs_router_rules_show_json(struct json *rule_entries, bool ipv6)
863863
entry = json_object_create();
864864

865865
json_object_put(entry, "priority", json_integer_create(rule->prio));
866-
json_object_put(entry, "user", json_integer_create(rule->user));
866+
json_object_put(entry, "user", json_boolean_create(rule->user));
867867
json_object_put(entry, "invert", json_boolean_create(rule->invert));
868868
json_object_put(entry, "ipv4", json_boolean_create(rule->ipv4));
869869
json_object_put(entry, "src-prefix",

tests/ovs-router.at

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,54 @@ Cached: 0: from all lookup local
258258
Cached: 32766: from all lookup main
259259
])
260260

261+
dnl Check JSON output for standard rules.
262+
AT_CHECK([ovs-appctl --format=json --pretty ovs/route/rule/show], [0], [dnl
263+
[[
264+
{
265+
"from": "all",
266+
"invert": false,
267+
"ipv4": true,
268+
"lookup": 255,
269+
"priority": 0,
270+
"src-prefix": 0,
271+
"user": false},
272+
{
273+
"from": "all",
274+
"invert": false,
275+
"ipv4": true,
276+
"lookup": 254,
277+
"priority": 32766,
278+
"src-prefix": 0,
279+
"user": false},
280+
{
281+
"from": "all",
282+
"invert": false,
283+
"ipv4": true,
284+
"lookup": 253,
285+
"priority": 32767,
286+
"src-prefix": 0,
287+
"user": false}]]
288+
])
289+
AT_CHECK([ovs-appctl --format=json --pretty ovs/route/rule/show -6], [0], [dnl
290+
[[
291+
{
292+
"from": "all",
293+
"invert": false,
294+
"ipv4": false,
295+
"lookup": 255,
296+
"priority": 0,
297+
"src-prefix": 0,
298+
"user": false},
299+
{
300+
"from": "all",
301+
"invert": false,
302+
"ipv4": false,
303+
"lookup": 254,
304+
"priority": 32766,
305+
"src-prefix": 0,
306+
"user": false}]]
307+
])
308+
261309
OVS_VSWITCHD_STOP
262310
AT_CLEANUP
263311

0 commit comments

Comments
 (0)