Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malformed JSON output on some "show" commands #15177

Closed
1 of 2 tasks
fdomain opened this issue Jan 19, 2024 · 2 comments
Closed
1 of 2 tasks

Malformed JSON output on some "show" commands #15177

fdomain opened this issue Jan 19, 2024 · 2 comments
Labels
triage Needs further investigation

Comments

@fdomain
Copy link

fdomain commented Jan 19, 2024


Describe the bug
JSON output from some "show" commands is malformed and are note considered as valid JSON. It is visible on "show ip prefix-list <prefix_list_name> json" and "show route-map <route_map> json" commands, but I believe this is present in many cases.

There are 2 consecutive JSON objects concatenated, one from the Zebra perspective, and another one for BGP. The problem is that these objects are not in a list, making it an invalid JSON output, and make it harder for programs to parse it.

  • Did you check if this is a duplicate issue?
  • Did you test it on the latest FRRouting/frr master branch?

To Reproduce

  1. Declare a route-map in your config
  2. Run the following "show route-map <route_map_name> json"

example:

router# show route-map RM-DENY json
{
  "ZEBRA":{
    "RM-DENY":{
      "invoked":0,
      "disabledOptimization":false,
      "processedChange":false,
      "rules":[
        {
          "sequenceNumber":10,
          "type":"deny",
          "invoked":0,
          "matchClauses":[
          ],
          "setClauses":[
          ],
          "action":"Exit routemap"
        }
      ]
    }
  }
}
{
  "BGP":{
    "RM-DENY":{
      "invoked":0,
      "disabledOptimization":false,
      "processedChange":false,
      "rules":[
        {
          "sequenceNumber":10,
          "type":"deny",
          "invoked":0,
          "matchClauses":[
          ],
          "setClauses":[
          ],
          "action":"Exit routemap"
        }
      ]
    }
  }
}

Expected behavior

Wrap the JSON objects in a list, that would make it a valid JSON output:

[
  {
    "ZEBRA": {
      "RM-DENY": {
        "invoked": 0,
        "disabledOptimization": false,
        "processedChange": false,
        "rules": [
          {
            "sequenceNumber": 10,
            "type": "deny",
            "invoked": 0,
            "matchClauses": [],
            "setClauses": [],
            "action": "Exit routemap"
          }
        ]
      }
    }
  },
  {
    "BGP": {
      "RM-DENY": {
        "invoked": 0,
        "disabledOptimization": false,
        "processedChange": false,
        "rules": [
          {
            "sequenceNumber": 10,
            "type": "deny",
            "invoked": 0,
            "matchClauses": [],
            "setClauses": [],
            "action": "Exit routemap"
          }
        ]
      }
    }
  }
]

Versions

  • OS Version: CentOS 8
  • Kernel: Linux 6.1.38
  • FRR Version: 8.4.2 (but also tested on 9.1, same issue)

Additional context

@fdomain fdomain added the triage Needs further investigation label Jan 19, 2024
@donaldsharp
Copy link
Member

I took the output of show route-map json and put it in several online json validators and got a it's valid from the ones I've used. Looking at the code, this was fixed last november with commit:

commit 570fdc55fd65899cd4376193e833594af6bca093
Author: Rafael Zalamena <[email protected]>
Date:   Mon Nov 20 17:32:19 2023 -0300

    lib,vtysh: fix show route map JSON output
    
    Move the command from 'lib' to 'vtysh' so we can properly format the
    JSON output in a correct manner.
    
    Signed-off-by: Rafael Zalamena <[email protected]>

This commit was also backported to the 9.1 and 9.0 releases. Please ensure you ahve this commit

@fdomain
Copy link
Author

fdomain commented Jan 31, 2024

Hi @donaldsharp ,

Could you re-open the issue please ?
Indeed, this commit fixes the issue for the show route-map json command but not for others. As I mentioned in my original post, there is the exact same issue for the show ip prefix-list json command for instance.

So there is a lack of consistency on JSON outputs between "show" commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Needs further investigation
Projects
None yet
Development

No branches or pull requests

2 participants