genieparser icon indicating copy to clipboard operation
genieparser copied to clipboard

BGP Advertised Routes pulls junk value

Open mupchu opened this issue 3 years ago • 11 comments

When I am parsing the output of 'show ip bgp all neighbors advertised-routes, In the resulting dictionary I am getting a route 'econdary'.

image cr1c-22ae-107-mdc-cli-1644421833.log

mupchu avatar Feb 09 '22 17:02 mupchu

any luck with this?

mupchu avatar Feb 15 '22 15:02 mupchu

Hi, apologies for the delay. Is that the exact command you attempted to parse? We have a parser for show bgp all neighbors {neighbor} advertised-routes but not specifically for show bgp all neighbors advertised-routes. I am attempting to find if it is selecting the correct parser, or if a new command needs to be added.

bastell avatar Feb 28 '22 20:02 bastell

it is show bgp all neighbors {neighbor} advertised-routes, sorry for the syntax mix up.

mupchu avatar Feb 28 '22 21:02 mupchu

Is this issue being looked at,?!

mupchu avatar Mar 31 '22 23:03 mupchu

This is still broken, I wrote my own program to parse out the data I needed. Leaving this open just in case this gets any attention, but I am no longer using pyats for this use case.

mupchu avatar May 22 '22 16:05 mupchu

Hi, apologies for the delay.

Can you share what output you are expecting and what output you got with the parser. Please share the output and not the screenshot of the output to investigate further.

Taarini avatar Jul 07 '22 17:07 Taarini

Hi,

Are you still looking into this issue.

Taarini avatar Jul 11 '22 13:07 Taarini

I no longer use this tool, however I think it is something I would like to be able to use. I will try and pull the information today, I need to rerun a test, and give you some files to look at.

mupchu avatar Jul 11 '22 15:07 mupchu

Sure thanks for the update.

Taarini avatar Jul 11 '22 16:07 Taarini

adv_route.zip I printed the output of the parse command so you can see what the parser if grabbing. All the logs files zipped up in here as well.

thanks!

mupchu avatar Jul 11 '22 20:07 mupchu

Thanks for the update. Will look into it and get back back to you with an update

Taarini avatar Jul 12 '22 01:07 Taarini

I have noticed a similar issue on IOS Show command show bgp all neighbors 10.3.4.5 advertised-routes

Sample Data

For address family: IPv4 Unicast
BGP table version is 87654, local router ID is 10.1.2.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
              t secondary path,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>   10.111.222.0/24 0.0.0.0                  0         32768 i
 *>   10.111.223.3/3  0.0.0.0                  0         32768 i
 *>   10.200.1.1/32   0.0.0.0                  0         32768 i
 *>   15.16.17.0/20   0.0.0.0                  0         32768 i

Parsed Result

{
    "vrf": {
        "default": {
            "neighbor": {
                "10.3.4.5": {
                    "address_family": {
                        "ipv4 unicast": {
                            "advertised": {
                                "condary": {
                                    "index": {
                                        "1": {
                                            "status_codes": "t s",
                                            "path_type": "e",
                                            "next_hop": "path,"
                                        }
                                    }
                                }
                            },
                            "bgp_table_version": 44660,
                            "local_router_id": "10.1.2.3"
                        }
                    }
                }
            }
        }
    }
}

Note that under ipv4_unicast : advertised: CONDARY. I believe the parser is breaking and detecting part of 'secondary'

So in the IOS-XE parser for show_bgp.py, p3_1 on line 4814-4817 image

Results in the following regex processing

image

image

Which shows the

  • group "status_codes" as "t s"
  • group "prefix" as "condary"
  • group "next_hop" as "path,"
  • group "path_type" as "e"

The flow should be:

  • Match on p1 = Get Address family.lower() -Working
  • Match on p2: -Working
    • create default vrf or add named vrf
    • create neighbor and add ip
    • add address family, and type
    • Add Table Version, and Local RID
  • Match P3_1 - Broken

Match P3_1 is:

^\s*(?P<status_codes>(s|d|h|\*|\>|i|r|S|m|b|f|x|a|c|t|L|\s)+)?(?P<path_type>(i|e|c|l|a|r|I))?(\s)?(?P<prefix>[a-zA-Z0-9\.\:\/\[\]\,]+)(?: *(?P<next_hop>[a-zA-Z0-9\.\:\/\[\]\,]+))?$

and the offending section is: (?P<status_codes>(s|d|h|\*|\>|i|r|S|m|b|f|x|a|c|t|L|\s)+)

Obviously we need to cater for routes with the 't' secondary path designation

*>i     [2]:[77][7,0][10.69.9.9,1,151587081][10.135.1.1,22][10.106.101.1,10.76.1.30]/616
*>t     2001:db8:aaaa:1::/113       ::ffff:10.106.101.1
*>      2001:db8:a69:484::/64   2001:DB8:20:4:6::6

but I am unsure of the best way to do this.

zacsmits avatar Nov 21 '22 04:11 zacsmits

I wound up writing my own parser and ignoring a large portion of the values in pyats. I rewrote this so that I would pull primarily the flags, prefix and next-hop values as those were the most interesting to us. Hopefully, this gets some attention though, as I am sure others have had some issues.

mupchu avatar Nov 21 '22 22:11 mupchu

Yeah, I've been creating an automatic site documentation builder, and I need to list the advertised networks, and this seems to be the best way to do it.

or i can dodgy it up to process part of the show run like the ospf and eigrp parsers do.

zacsmits avatar Nov 22 '22 03:11 zacsmits

Hello @mupchu,

Are you still looking for a resolution for this issue, Please let me know .

ParimiNeeraja avatar Oct 10 '23 09:10 ParimiNeeraja

Hello @mupchu,

Is there any update, Kindly let me know.

ParimiNeeraja avatar Oct 11 '23 09:10 ParimiNeeraja

Sorry, been a busy week.

I am no longer using pyats for this feature, but I can help test if someone does want to look into what is going on with this. I had to create my own parser, and it was just easier to do outside of pyats. If someone wants to work on this great, if not then this can be closed.

mupchu avatar Oct 11 '23 14:10 mupchu

Hi,

I am working on this parser issue. Trying to fix the pattern.

kameswararaot avatar Oct 24 '23 09:10 kameswararaot

I have noticed a similar issue on IOS Show command show bgp all neighbors 10.3.4.5 advertised-routes

Sample Data

For address family: IPv4 Unicast
BGP table version is 87654, local router ID is 10.1.2.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
              t secondary path,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>   10.111.222.0/24 0.0.0.0                  0         32768 i
 *>   10.111.223.3/3  0.0.0.0                  0         32768 i
 *>   10.200.1.1/32   0.0.0.0                  0         32768 i
 *>   15.16.17.0/20   0.0.0.0                  0         32768 i

Parsed Result

{
    "vrf": {
        "default": {
            "neighbor": {
                "10.3.4.5": {
                    "address_family": {
                        "ipv4 unicast": {
                            "advertised": {
                                "condary": {
                                    "index": {
                                        "1": {
                                            "status_codes": "t s",
                                            "path_type": "e",
                                            "next_hop": "path,"
                                        }
                                    }
                                }
                            },
                            "bgp_table_version": 44660,
                            "local_router_id": "10.1.2.3"
                        }
                    }
                }
            }
        }
    }
}

Note that under ipv4_unicast : advertised: CONDARY. I believe the parser is breaking and detecting part of 'secondary'

So in the IOS-XE parser for show_bgp.py, p3_1 on line 4814-4817 image

Results in the following regex processing

image

image

Which shows the

* group "status_codes" as "t s"

* group "prefix" as "condary"

* group "next_hop" as "path,"

* group "path_type" as "e"

The flow should be:

* Match on p1 = Get Address family.lower()        -Working

* Match on p2:                                                      -Working
  
  * create default vrf or add named vrf
  * create neighbor and add ip
  * add address family, and type
  * Add Table Version, and Local RID

* Match P3_1       - **Broken**

Match P3_1 is:

^\s*(?P<status_codes>(s|d|h|\*|\>|i|r|S|m|b|f|x|a|c|t|L|\s)+)?(?P<path_type>(i|e|c|l|a|r|I))?(\s)?(?P<prefix>[a-zA-Z0-9\.\:\/\[\]\,]+)(?: *(?P<next_hop>[a-zA-Z0-9\.\:\/\[\]\,]+))?$

and the offending section is: (?P<status_codes>(s|d|h|\*|\>|i|r|S|m|b|f|x|a|c|t|L|\s)+)

Obviously we need to cater for routes with the 't' secondary path designation

*>i     [2]:[77][7,0][10.69.9.9,1,151587081][10.135.1.1,22][10.106.101.1,10.76.1.30]/616
*>t     2001:db8:aaaa:1::/113       ::ffff:10.106.101.1
*>      2001:db8:a69:484::/64   2001:DB8:20:4:6::6

but I am unsure of the best way to do this.

yes same observation here as well - would be nice to get this fixed

MaikHahn avatar Oct 25 '23 15:10 MaikHahn

I will say that this parser should almost be split up between the header and the actual table. What I needed was the actual table, so there were a few python libraries that were able to pull what I needed without having to fuss about with the rest of this. I also wrote my own parser outside of pyats, that just used regex and was able to gather what i needed from the table (for this particular table i did not need every value but, I did need the prefix, and the next-hop).

mupchu avatar Oct 25 '23 22:10 mupchu

Hello @mupchu, @MaikHahn and @zacsmits,

I have added a fix for this issue and it will be available in the upcoming version of pyATS. Hence, I am closing this issue, if you still face the same issue with newer version of pyATS then kindly re-open the ticket.

Thank you.

SohanTirpude avatar Dec 18 '23 17:12 SohanTirpude

Hi @SohanTirpude, thanks 👍

  1. where could I find it in the code (branch/parser/...) if I would like to check and patch it manually in my version ?
  2. in which release will it be fixed ?

MaikHahn avatar Jan 10 '24 09:01 MaikHahn

Hello @MaikHahn,

The fix will be available un the upcoming pyATS release 24.1, so kindly wait until that.

Thank you.

SohanTirpude avatar Jan 10 '24 13:01 SohanTirpude

Hi @SohanTirpude I still have issue - not sure if this is the right place but the show command which I need also links to the same show_bgp.py

device#sh ip bgp all neighbors ? A.B.C.D Neighbor to display information about X:X:X:X::X IPv6 neighbor to display information about slow Slow neighbor status | Output modifiers

the command itself is not supported in ios-xe Version 17.6.5 on C9500-32C

so I'm using show bgp {address_family} neighbors {neighbor} advertised-routes

https://pubhub.devnetcloud.com/media/genie-feature-browser/docs/#/parsers/show%2520bgp%2520%257Baddress_family%257D%2520neighbors%2520%257Bneighbor%257D%2520advertised-routes

https://github.com/CiscoTestAutomation/genieparser/blob/master/src/genie/libs/parser/iosxe/show_bgp.py#L5319

Even I have plenty of routes which are advertised I get

| Parsed command 'show bgp vpnv4 unicast vrf rb-bcn neighbors 10.1.1.1 | | advertised-routes' but it returned empty |

MaikHahn avatar Feb 16 '24 12:02 MaikHahn

Hello @MaikHahn,

It seems your current issues is not related to this issue, so kindly create a new issue with complete information to exclude confusion.

From your comment, this I what I understood that you are using this command: show bgp {address_family} neighbors {neighbor} advertised-routes but it is taking 'show bgp vpnv4 unicast vrf rb-bcn neighbors 10.1.1.1 | advertised-routes this command.

If I am wrong, then kindly in your new ticket explain clearly. The logs will be better to understand it clearly.

Thank you.

SohanTirpude avatar Feb 16 '24 12:02 SohanTirpude

Yes I have already opened a new issue - thanks :-)

MaikHahn avatar Feb 16 '24 12:02 MaikHahn