osrg / gobgp

BGP implemented in the Go Programming Language
https://osrg.github.io/gobgp/
Apache License 2.0
3.64k stars 693 forks source link

Neighbor output and JSON output different #2082

Closed gedOHub closed 5 years ago

gedOHub commented 5 years ago

I have noticed that output in JSON format differs from CLI output.

With command gobgp neighbor I'm getting information about two neighbors:

[root@server1 ~]# gobgp neighbor
Peer                    AS     Up/Down State       |#Received  Accepted
192.168.201.1        61317 1d 02:50:38 Establ      |        0         0
fd11:11:a:aaa:e2dc:: 61317 1d 02:50:28 Establ      |        0         0

With command gobgp neighbor -j I'm getting information about one neighbor + additional information:

{
    "apply_policy": {
        "export_policy": {
            "direction": 2,
            "default_action": -1
        },
        "import_policy": {
            "direction": 1,
            "default_action": -1
        }
    },
    "conf": {
        "local_as": 61317,
        "neighbor_address": "fd11:11:a:aaa:e2dc::",
        "peer_as": 61317
    },
    "ebgp_multihop": {},
    "route_reflector": {},
    "state": {
        "messages": {
            "received": {
                "open": 1,
                "keepalive": 3140,
                "total": 3141
            },
            "sent": {
                "update": 50,
                "open": 1,
                "keepalive": 3224,
                "total": 3275
            }
        },
        "neighbor_address": "fd11:11:a:aaa:e2dc::",
        "peer_as": 61317,
        "queues": {},
        "session_state": 6,
        "remote_cap": [
            {
                "type_url": "type.googleapis.com/gobgpapi.RouteRefreshCapability"
            },
            {
                "type_url": "type.googleapis.com/gobgpapi.GracefulRestartCapability",
                "value": "EHg="
            },
            {
                "type_url": "type.googleapis.com/gobgpapi.FourOctetASNumberCapability",
                "value": "CIXfAw=="
            },
            {
                "type_url": "type.googleapis.com/gobgpapi.MultiProtocolCapability",
                "value": "CgQIAhAB"
            },
            {
                "type_url": "type.googleapis.com/gobgpapi.RouteRefreshCiscoCapability"
            }
        ],
        "local_cap": [
            {
                "type_url": "type.googleapis.com/gobgpapi.RouteRefreshCapability"
            },
            {
                "type_url": "type.googleapis.com/gobgpapi.MultiProtocolCapability",
                "value": "CgQIAhAB"
            },
            {
                "type_url": "type.googleapis.com/gobgpapi.FourOctetASNumberCapability",
                "value": "CIXfAw=="
            }
        ],
        "router_id": "192.168.200.2"
    },
    "timers": {
        "config": {
            "connect_retry": 120,
            "hold_time": 90,
            "keepalive_interval": 30
        },
        "state": {
            "keepalive_interval": 30,
            "negotiated_hold_time": 90,
            "uptime": {
                "seconds": 1557997170
            },
            "downtime": {
                "seconds": 1557997170
            }
        }
    },
    "transport": {
        "local_address": "fd11:11:a:aaa:e2dc::1"
    },
    "route_server": {},
    "graceful_restart": {},
    "afi_safis": [
        {
            "mp_graceful_restart": {
                "config": {}
            },
            "config": {
                "family": {
                    "afi": 2,
                    "safi": 1
                },
                "enabled": true
            },
            "state": {
                "family": {
                    "afi": 2,
                    "safi": 1
                },
                "enabled": true
            },
            "apply_policy": {
                "export_policy": {
                    "direction": 2,
                    "default_action": -1
                },
                "import_policy": {
                    "direction": 1,
                    "default_action": -1
                }
            },
            "route_selection_options": {
                "config": {}
            },
            "use_multiple_paths": {
                "config": {},
                "ebgp": {
                    "config": {}
                },
                "ibgp": {
                    "config": {}
                }
            },
            "route_target_membership": {
                "config": {}
            },
            "long_lived_graceful_restart": {
                "config": {}
            },
            "add_paths": {
                "config": {}
            }
        }
    ]
}
fujita commented 5 years ago

gobgp neighbor command shows some of the response. '-j' option simply converts the response to json. No guarantee that '-j' option gives the same.

nskalis commented 3 years ago

but the number of neighbours listed in the json output is 1 and in the cli output is 2. how is this explained? @gedOHub did you figure it out maybe?