Exa-Networks / exabgp

The BGP swiss army knife of networking
Other
2.07k stars 443 forks source link

bgp-ls: json decoding error for node-descriptors for node and prefix nlri #1081

Closed joshqoon closed 2 years ago

joshqoon commented 2 years ago

Hi

JSONDecodeError for key node-descriptors in bgpls nlri types node and prefix:

$ ./sbin/exabgp version
ExaBGP : master-b3f4dd8dfd5582fc50a25704bc3b9e2baaf5105e
Python : 3.10.4 (main, Apr  2 2022, 12:32:41) [GCC 9.4.0]
Uname  : Linux sr-lab-exabgp 5.4.0-107-generic #121-Ubuntu SMP Thu Mar 24 16:04:27 UTC 2022 x86_6
2022-04-28 19:20:57.375 | INFO     | __main__:<module>:42 - { "exabgp": "5.0.0", "time": 1651162857.3749788, "host" : "sr-lab-exabgp", "pid" : 3913028, "ppid" : 84633, "counter": 5, "type": "update", "header": "0xFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFF007502", "body": "0x0000005E900E003D40044704C0A8640200000300300200000000000002BC0100001A0200000400003E34020100040000000002030006010135000041010900051E0A86025840010100400206020100003E34801D0D04830004000000640492000100"
, "neighbor": {     "address": { "local": "192.168.100.1", "peer": "192.168.100.2" },     "asn": { "local": 65050, "peer": 15924 }     , "direction": "receive", "message": { "update": { "attribute": { "origin": "igp", "as-path": {"
0": {"element": "as-sequence", "value": [15924]}}, "bgp-ls": { "prefix-metric": 100, "sr-prefix-attribute-flags": {"X": 0, "R": 0, "N": 0, "RSV": 0} } }, "announce": { "bgp-ls bgp-ls": { "192.168.100.2": [ { "ls-nlri-type": "bgpls-
prefix-v4", "l3-routing-topology": 700, "protocol-id": 2, "node-descriptors": { { "autonomous-system": 15924 }, { "bgp-ls-identifier": "0" }, { "router-id": "010135000041" } }, "ip-reachability-tlv": "10.134.2.88", "ip-reach-prefix
": "10.134.2.88/30", "nexthop": "192.168.100.2" } ] } } } } } }
Traceback (most recent call last):
  File "/home/cpn/exabgp-master/dump.py", line 33, in <module>
    sys.stderr.write(json.dumps(json.loads(line), indent=4))
  File "/home/cpn/.pyenv/versions/3.10.4/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/home/cpn/.pyenv/versions/3.10.4/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/cpn/.pyenv/versions/3.10.4/lib/python3.10/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 945 (char 944)

the following line should return a list .

https://github.com/Exa-Networks/exabgp/blob/b3f4dd8dfd5582fc50a25704bc3b9e2baaf5105e/src/exabgp/bgp/message/update/nlri/bgpls/prefixv4.py#L132

same for this line:

https://github.com/Exa-Networks/exabgp/blob/b3f4dd8dfd5582fc50a25704bc3b9e2baaf5105e/src/exabgp/bgp/message/update/nlri/bgpls/node.py#L57

thomas-mangin commented 2 years ago
./sbin/exabgp decode -f 'bgp-ls bgp-ls' FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0075020000005E900E003D40044704C0A8640200000300300200000000000002BC0100001A0200000400003E34020100040000000002030006010135000041010900051E0A86025840010100400206020100003E34801D0D04830004000000640492000100 2>&1 | tail -1 | cut -b28- | jsonpp
{
  "exabgp": "5.0.0",
  "time": 1651190252.206673,
  "host": "MacBook-Pro-2.local",
  "pid": 26366,
  "ppid": 60659,
  "counter": 1,
  "type": "update",
  "neighbor": {
    "address": {
      "local": "127.0.0.1",
      "peer": "127.0.0.1"
    },
    "asn": {
      "local": 65533,
      "peer": 65533
    },
    "direction": "in",
    "message": {
      "update": {
        "attribute": {
          "origin": "igp",
          "as-path": {
            "0": {
              "element": "as-sequence",
              "value": [
                15924
              ]
            }
          },
          "bgp-ls": {
            "prefix-metric": 100,
            "sr-prefix-attribute-flags": {
              "X": 0,
              "R": 0,
              "N": 0,
              "RSV": 0
            }
          }
        },
        "announce": {
          "bgp-ls bgp-ls": {
            "192.168.100.2": [
              {
                "ls-nlri-type": "bgpls-prefix-v4",
                "l3-routing-topology": 700,
                "protocol-id": 2,
                "node-descriptors": [
                  {
                    "autonomous-system": 15924
                  },
                  {
                    "bgp-ls-identifier": "0"
                  },
                  {
                    "router-id": "010135000041"
                  }
                ],
                "ip-reachability-tlv": "10.134.2.88",
                "ip-reach-prefix": "10.134.2.88/30",
                "nexthop": "192.168.100.2"
              }
            ]
          }
        }
      }
    }
  }
}