I notice that the get_bgp_neighbors_detail function returns a negative value for flap_count as seen in the output below.
Script
=====
from napalm import get_network_driver
driver = get_network_driver('iosxr')
device1.open()
info = device1.get_bgp_neighbors_detail()
print (json.dumps(info, indent=4))
Output returned:
===========
"VRF-A": {
"110": [
{
"up": true,
"local_as": 18522,
"remote_as": 110,
"router_id": "198.0.0.177",
"local_address": "10:11:b0::1",
"routing_table": "VRF-A",
"local_address_configured": false,
"local_port": 179,
"remote_address": "10:11:b0::11",
"remote_port": 33155,
"multihop": false,
"multipath": false,
"import_policy": "pass-all",
"export_policy": "pass-all",
"input_messages": 0,
"output_messages": 3061,
"input_updates": 0,
"output_updates": 0,
"messages_queued_out": 0,
"connection_state": "Established",
"previous_connection_state": "Connect",
"last_event": "",
"remove_private_as": false,
"suppress_4byte_as": false,
"local_as_prepend": true,
"holdtime": 90,
"configured_holdtime": 180,
"keepalive": 30,
"configured_keepalive": 60,
"active_prefix_count": 101,
"received_prefix_count": 101,
"accepted_prefix_count": 101,
"suppressed_prefix_count": 0,
"advertised_prefix_count": 202,
**"flap_count": -1**
}
]
}
I looked at the following relevant code at napalm/napalm/iosxr/iosxr.py:
connection_down_count = napalm.base.helpers.convert(
int,
napalm.base.helpers.find_txt(neighbor, "ConnectionDownCount"),
0,
)
flap_count = int(connection_down_count / 2)
if up:
**flap_count -= 1**
The connection-down-count field can have value in the range 0 to 4294967295. If the value is 0, the above code will result in a flap_count that is negative. This logic needs to be fixed.
Description of Issue/Question
Note: Please check https://guides.github.com/features/mastering-markdown/ to see how to properly format your request.
Did you follow the steps from https://github.com/napalm-automation/napalm#faq
(Place an
x
between the square brackets where applicable)Setup
napalm version
(Paste verbatim output from
pip freeze | grep napalm
between quotes below)Network operating system version
(Paste verbatim output from
show version
- or equivalent - between quotes below)Steps to Reproduce the Issue
Error Traceback
(Paste the complete traceback of the exception between quotes below)