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

IOS XR get_bgp_neighbors_detail: flap_count return a negative value #1330

Closed
1 task done
pratimakini opened this issue Nov 28, 2020 · 1 comment · Fixed by #1449
Closed
1 task done

IOS XR get_bgp_neighbors_detail: flap_count return a negative value #1330

pratimakini opened this issue Nov 28, 2020 · 1 comment · Fixed by #1449
Milestone

Comments

@pratimakini
Copy link

Description of Issue/Question

Note: Please check https://guides.github.com/features/mastering-markdown/
to see how to properly format your request.

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.

Did you follow the steps from https://github.com/napalm-automation/napalm#faq

(Place an x between the square brackets where applicable)

  • Yes
  • [] No

Setup

napalm version

(Paste verbatim output from pip freeze | grep napalm between quotes below)

napalm==3.2.0
napalm-yang==0.1.0

Network operating system version

(Paste verbatim output from show version - or equivalent - between quotes below)

Cisco IOS XR Software, Version 7.4.1.08I

Steps to Reproduce the Issue

Error Traceback

(Paste the complete traceback of the exception between quotes below)


@mirceaulinic
Copy link
Member

Hi @pkinicisco. Yes, feel free to open a PR to fix this, I'll mark it as a bug. Thanks for reporting.

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

Successfully merging a pull request may close this issue.

2 participants