]> git.puffer.fish Git - matthieu/frr.git/commit
bgpd: Filter BGP routes by prefix version
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Fri, 9 Apr 2021 06:33:41 +0000 (09:33 +0300)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Mon, 12 Apr 2021 07:43:53 +0000 (10:43 +0300)
commit7d3cae70b22ee6124a403b179db7b4fbab70dff6
tree47deed1aec0f1871a20841543f89eb4b1a461e92
parent9119ef3a8bd571a0892f4627808ef5ebc5290fe2
bgpd: Filter BGP routes by prefix version

The idea is to find out prefixes including specific BGP table version and
above.

Let's say I have a converged network and suddently I noticed a couple of
prefixes seems hijacked.

I want to look what new prefixes arrived with a specific BGP table version.

```
exit1-debian-9# show ip bgp version 8
BGP table version is 9, local router ID is 192.168.100.1, vrf id 0
Default local pref 100, local AS 65534
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*  192.168.2.0/24   192.168.0.2              0             0 65030 ?
*>                  192.168.0.2              0             0 65030 ?
*  192.168.3.0/24   192.168.0.2              0             0 65030 ?
*>                  192.168.0.2              0             0 65030 ?

Displayed  2 routes and 18 total paths
exit1-debian-9#
```

```
exit1-debian-9# show ip bgp version 8 json
{
 "vrfId": 0,
 "vrfName": "default",
 "tableVersion": 9,
 "routerId": "192.168.100.1",
 "defaultLocPrf": 100,
 "localAS": 65534,
 "routes": { "192.168.2.0/24": [
  {
    "valid":true,
    "pathFrom":"external",
    "prefix":"192.168.2.0",
    "prefixLen":24,
    "network":"192.168.2.0\/24",
    "version":8,
    "metric":0,
    "weight":0,
    "peerId":"2a02:bbd::2",
    "path":"65030",
    "origin":"incomplete",
    "nexthops":[
      {
        "ip":"192.168.0.2",
        "hostname":"home-spine1.donatas.net",
        "afi":"ipv4",
        "used":true
      }
    ]
  },
  {
    "valid":true,
    "bestpath":true,
    "selectionReason":"Neighbor IP",
    "pathFrom":"external",
    "prefix":"192.168.2.0",
    "prefixLen":24,
    "network":"192.168.2.0\/24",
    "version":8,
    "metric":0,
    "weight":0,
    "peerId":"192.168.0.2",
    "path":"65030",
    "origin":"incomplete",
    "nexthops":[
      {
        "ip":"192.168.0.2",
        "hostname":"home-spine1.donatas.net",
        "afi":"ipv4",
        "used":true
      }
    ]
  }
],"192.168.3.0/24": [
  {
    "valid":true,
    "pathFrom":"external",
    "prefix":"192.168.3.0",
    "prefixLen":24,
    "network":"192.168.3.0\/24",
    "version":9,
    "metric":0,
    "weight":0,
    "peerId":"2a02:bbd::2",
    "path":"65030",
    "origin":"incomplete",
    "nexthops":[
      {
        "ip":"192.168.0.2",
        "hostname":"home-spine1.donatas.net",
        "afi":"ipv4",
        "used":true
      }
    ]
  },
  {
    "valid":true,
    "bestpath":true,
    "selectionReason":"Neighbor IP",
    "pathFrom":"external",
    "prefix":"192.168.3.0",
    "prefixLen":24,
    "network":"192.168.3.0\/24",
    "version":9,
    "metric":0,
    "weight":0,
    "peerId":"192.168.0.2",
    "path":"65030",
    "origin":"incomplete",
    "nexthops":[
      {
        "ip":"192.168.0.2",
        "hostname":"home-spine1.donatas.net",
        "afi":"ipv4",
        "used":true
      }
    ]
  }
] }  }

```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
bgpd/bgp_route.c
bgpd/bgp_route.h
bgpd/bgp_updgrp_adv.c
bgpd/bgp_vpn.c