Commit Graph

6805 Commits

Author SHA1 Message Date
Donald Sharp
75aaf03ff3 bgpd: entry->any is never true
The only places entry->any could ever be set to true was
when str was NULL.  Unfortunately with the way our CLI works
str is impossible to be NonNULL.  The entry->any value *used*
to work prior to commit e961923c72
but it was changed back in 2016 and no-one has noticed the changed
ability.

Let's just admit that there are no users of this and remove this
dead code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-05 07:57:49 -04:00
Donald Sharp
907234817c bgpd: Give more data when state machine fails to change state
When a state machine transition fails, bgpd would output
data about what happened, but not necessarily give the
reason why.  Add that data to the output.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-02 11:02:54 -04:00
mobash-rasool
205d27014f
Merge pull request #13641 from donaldsharp/com_list_str
Bunch of code cleanup from Coverity
2023-06-02 08:14:10 +05:30
mobash-rasool
e4bdeb6aca
Merge pull request #13660 from anlancs/bgpd-cleanup-12
bgpd: Fix typo in debug message
2023-06-02 08:11:55 +05:30
anlan_cs
32e29c746a bgpd: Fix typo in debug message
Cosmetic change for the debug messages, mainly on the parentheses.

Before:
```
[ZJYCS-KQYD6] VRF vrf-debug(140): Rcvd NH update 50.50.50.0/24(0)0) - metric 300/300 #nhops 2/1 flags Valid Reg Static Static Exact
[VZJVD-D7GXM] parse nexthop update(50.50.50.0/24(0)(VRF vrf-debug)): bnc info not found for nexthop cache
[NSWTE-81HEK] parse nexthop update(50.50.201.0/31(0)(VRF vrf-debug)): bnc info not found for import check
```

After:
```
[ZJYCS-KQYD6] VRF vrf-debug(140): Rcvd NH update 50.50.50.0/24(0)(0) - metric 300/300 #nhops 2/1 flags Valid Reg Static Static Exact
[VZJVD-D7GXM] parse nexthop update 50.50.50.0/24(0)(VRF vrf-debug): bnc info not found for nexthop cache
[NSWTE-81HEK] parse nexthop update 50.50.201.0/31(0)(VRF vrf-debug): bnc info not found for import check
```

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-06-01 23:31:45 +08:00
Donald Sharp
c36bd47d76 bgpd: vpn_policy_getafi can return AFI_MAX
Let's account for vpn_policy_getafi having a failure
situation and back out of the whole thing gracefully.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-01 08:58:16 -04:00
Donald Sharp
6e233c77d8 bgpd: blnc cannot be NULL at if statement time
It is impossible for the blnc statement to ever be NULL at
line 1470 as that the if statement at 1453 guarantees it
to be set to something.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-01 08:58:16 -04:00
Donald Sharp
1f7038386e bgpd: community_list_set str is always non null
When calling community_list_set the str variable is
always non NULL.  As such let's treat it as such.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-01 08:54:25 -04:00
Yuan Yuan
32af4995aa bgpd: fix bgpd core when unintern attr
When the remote peer is neither EBGP nor confed, aspath is the
shadow copy of attr->aspath in bgp_packet_attribute(). Striping
AS4_PATH should not be done on the aspath directly, since
that would lead to bgpd core dump when unintern the attr.

Signed-off-by: Yuan Yuan <yyuanam@amazon.com>
2023-05-30 22:49:07 +00:00
Donatas Abraitis
be393ade4a bgpd: Refactor subgroup_announce_table() to reuse an existing helpers
Reuse subgroup_process_announce_selected(). It does the same as we do here
duplicating the logic.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-25 17:04:47 +03:00
Rajasekar Raja
82465ca7f9 bgpd: Using no pretty json output for l2vpn-Evpn routes
The output of show bgp all json is inconsistent across Address-families
i.e. ipv4/ipv6 is a no pretty format while l2vpn-evpn is in a pretty
format. For huge scale (lots of routes with lots of paths), it is better
to use no_pretty format.

Before fix:
torm-11# sh bgp all json
{
"ipv4Unicast":{
 "vrfId": 0,
 "vrfName": "default",
 "tableVersion": 1,
 "routerId": "27.0.0.15",
 "defaultLocPrf": 100,
 "localAS": 65000,
 "routes": { } }
,
"l2VpnEvpn":{
"routes":{
  "27.0.0.15:2":{
    "rd":"27.0.0.15:2",
    "[1]:[0]:[03:44:38:39:ff:ff:01:00:00:01]:[128]:[::]:[0]":{
      "prefix":"[1]:[0]:[03:44:38:39:ff:ff:01:00:00:01]:[128]:[::]:[0]",
      "prefixLen":352,
      "paths":[
<SNIP>.............

After fix:
torm-11# sh bgp all json
{
"ipv4Unicast":{
 "vrfId": 0,
 "vrfName": "default",
 "tableVersion": 1,
 "routerId": "27.0.0.15",
 "defaultLocPrf": 100,
 "localAS": 65000,
 "routes": { } }
,
"l2VpnEvpn":{
"routes":{"27.0.0.15:2":{"rd":"27.0.0.15:2","[1]:[0]:[03:44:38:39:ff:ff:01:00:00:01]:[128]:[::]:[0]":{"prefix":"[1]:[0]:[03:44:38:39:ff:ff:01:00:00:01]:[128]:[::]:[0]","prefixLen":352,"paths":[[{"valid":true,"bestpath":true,"selectionReason":"First path received","pathFrom":"external","routeType":1,"weight":32768,"peerId":"(unspec)","path":"","origin":"IGP","extendedCommunity"
<SNIP>.............

Issue: 3472865

Ticket:#3472865

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2023-05-22 14:14:30 -07:00
Rajasekar Raja
be66fa05c9 bgpd: Fix the json output of show bgp all json to be in a valid format
In the json output of show bgp all json, the l2VpnEvpn afi-safi is
missing the 'routes' key making the json output format invalid.

Before Fix:
torm-11# sh bgp all json
{
<SNIP>....................
"l2VpnEvpn":{
{
  "27.0.0.15:2":{
    "rd":"27.0.0.15:2",
    "[4]:[03:44:38:39:ff:ff:01:00:00:01]:[32]:[27.0.0.15]":{
      "prefix":"[4]:[03:44:38:39:ff:ff:01:00:00:01]:[32]:[27.0.0.15]",
      "prefixLen":352,
      "paths":[
<SNIP>....................

After Fix:
torm-11# sh bgp all json
{
<SNIP>....................
"l2VpnEvpn":{
"routes":{
  "27.0.0.15:2":{
    "rd":"27.0.0.15:2",
    "[1]:[0]:[03:44:38:39:ff:ff:01:00:00:01]:[128]:[::]:[0]":{
      "prefix":"[1]:[0]:[03:44:38:39:ff:ff:01:00:00:01]:[128]:[::]:[0]",
      "prefixLen":352,
      "paths":[

Issue: 3472865
Ticket:#3472865

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2023-05-22 14:02:54 -07:00
Donatas Abraitis
98378a3546
Merge pull request #13564 from chiragshah6/fdev1
bgpd: aggregate route best path select and other fixes
2023-05-22 09:45:54 +03:00
Donatas Abraitis
e0b1c8ccdf bgpd: Initialize pfx_buf to zeros before using in bgp_path_info_cmp()
This can lead into some garbage outputs, that can't be decoded in utf-8 or so.

This was catched when testing 76b246aa1f.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-20 10:03:10 +03:00
Chirag Shah
e38e8edcf9 bgpd: fix memory leak in aggregate path info
Fix memory leak in aggregate route path info
comparison api.

Signed-off-by: Chirag shah <chirag@nvidia.com>
2023-05-19 14:45:49 -07:00
Chirag Shah
ff8bebd2a6 bgpd: fix aggregate route display
Based on RFC-4760, if NEXT_HOP attribute is not
suppose to be set if MP_REACH_NLRI NLRI is used.
for IPv4 aggregate route only NEXT_HOP attribute
with ipv4 prefixlen needs to be set.

Testing Done:

Before fix:
----------
aggregate route:
*> 184.123.0.0/16   ::(TORC11)               0         32768 i

After fix:
---------
aggregate route:
*> 184.123.0.0/16   0.0.0.0(TORC11)          0         32768 i
* i                 peerlink-3               0    100      0 i
*                   uplink1                                0 4435 5546 i
   184.123.1.0/24   0.0.0.0(TORC11)          0         32768 i
s> 184.123.8.0/22   0.0.0.0(TORC11)          0         32768 i

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-05-19 14:45:49 -07:00
Chirag Shah
cd845be6a7 bgpd: fix aggregate route best path select
In ebgp+ ibgp deployment aggregate summary-only route
selected path should always be locally originated
summary route.
When aggregate route summary-only config is removed
The selected path is iBGP peer as its lower cost
Upon reconfiguring aggregate route summary-only,
the locally originated is not selected due to
always choosing first path attribute and bailing
out as no change in route update.

Ticket:#3467890
Issue:3467890
Testing Done:

Config:
------
TORC11(config-router)#router bgp
TORC11(config-router)# address-family ipv4 unicast
TORC11(config-router-af)# aggregate-address 184.123.0.0/16
        summary-only
TORC11(config-router-af)# no aggregate-address 184.123.0.0/16
        summary-only
TORC11(config-router-af)# aggregate-address 184.123.0.0/16
        summary-only

Before fix:
-----------
*> 184.123.0.0/16   ::(TORC11)               0         32768 i
*                   uplink1                                0 4435 5546 i
*                   uplink2                                0 4435 5546 i
* i                 peerlink-3               0    100      0 i

After fix:
----------
*> 184.123.0.0/16   ::(TORC11)               0         32768 i
* i                 peerlink-3               0    100      0 i
*                   uplink2                                0 4435 5546 i
*                   uplink1                                0 4435 5546 i

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-05-19 14:45:38 -07:00
Donatas Abraitis
bdf8b8dda9 bgpd: Show the real table version for a decent peer subgroup
Without the patch:

```
Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt Desc
192.168.1.2     4      65002         4         5        2    0    0 00:00:45            1        1 N/A
192.168.1.3     4      65003         5         5        2    0    0 00:00:45            0        2 N/A
192.168.1.4     4      65004         5         5        2    0    0 00:00:45            0        2 N/A
```

With the patch:

```
Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt Desc
192.168.1.2     4      65002         6         6        2    0    0 00:01:05            0        1 N/A
192.168.1.3     4      65003         7         7        3    0    0 00:01:05            0        1 N/A
192.168.1.4     4      65004         7         7        3    0    0 00:01:05            0        1 N/A
```

JSON output is also fixed:

```
munet> r1 shi vtysh -c 'sh ip bgp sum json' | grep version -i
  "tableVersion":3,
      "version":4,
      "tableVersion":2,
      "version":4,
      "tableVersion":3,
      "version":4,
      "tableVersion":3,

munet>
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-15 21:46:41 +03:00
Donatas Abraitis
edc886635d
Merge pull request #13463 from pguibert6WIND/mpls_alloc_per_nh_2
Mpls allocatio mode per nexthop
2023-05-12 20:56:01 +03:00
Donatas Abraitis
1c035c8c2c bgpd: Implement match source-protocol for route-maps
The main idea is to filter routes by matching source (originating) protocol
for outgoing direction. For instance, filter outgoing routes to an arbitrary
router that are static only. Or filter out only routes learned from RIP.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-11 11:39:23 +03:00
Donatas Abraitis
5803c22573
Merge pull request #13493 from anlancs/fix/bgpd-cleanup-11
bgpd: Cosmetic change for mac check
2023-05-10 14:30:04 +03:00
anlan_cs
3dc1d6ca30 bgpd: Cosmetic change for mac check
Remove useless `return` code, and correct a spelling.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-05-10 16:58:29 +08:00
Philippe Guibert
6483c4d37b bgpd: add 'show bgp label-nexthop [detail]' command
The following command is made available to list the labels
allocated per-nexthop, along with the paths registered to it.

 > # show bgp vrf vrf1 label-nexthop
 > Current BGP label nexthop cache for IP, VRF vrf1
 >  192.0.2.11, label 20 #paths 3
 >    if r1-eth1
 >    Last update: Mon Jan 16 18:52:11 2023
 >  192.0.2.12, label 17 #paths 2
 >    if r1-eth1
 >    Last update: Mon Jan 16 18:52:08 2023
 >  192.0.2.14, label 18 #paths 1
 >    if r1-eth1
 >    Last update: Mon Jan 16 18:52:07 2023
 >  192.168.255.13, label 19 #paths 1
 >    if r1-eth2
 >    Last update: Mon Jan 16 18:52:10 2023

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09 21:00:57 +02:00
Philippe Guibert
60e5bc23b9 bgpd: update time of last change when label nexthop entry changed
A timer attribute is added for each label nexthop entry, in order
to know when the last change occured.
The timer value will be used for troubleshooting by a show
command in the next commit.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09 21:00:57 +02:00
Philippe Guibert
882d7b8179 bgpd: export redistributed routes with label allocation per nexthop
The label allocation per nexthop mode requires to use a nexthop
tracking context. For redistributed routes, a nexthop tracking
context is created, and the resolution helps to know the real
nexthop ip address used. The below configuration example has
been used:

 > vrf vrf1
 >  ip route 172.31.0.14/32 192.0.2.14
 >  ip route 172.31.0.15/32 192.0.2.12
 >  ip route 172.31.0.30/32 192.0.2.30
 > exit
 > router bgp 65500 vrf vrf1
 >  address-family ipv4 unicast
 >   redistribute static
 >   label vpn export per-nexthop
 > [..]

The static routes are correctly imported in the BGP IPv4 RIB.
Contrary to label allocation per vrf mode, some nexthop tracking
are created/or reused:

 > # show bgp vrf vrf1 nexthop
 > 192.0.2.12 valid [IGP metric 0], #paths 3, peer 192.0.2.12
 >  if r1-eth1
 >  Last update: Fri Jan 13 15:49:42 2023
 > 192.0.2.14 valid [IGP metric 0], #paths 1
 >  if r1-eth1
 >  Last update: Fri Jan 13 15:49:42 2023
 > 192.0.2.30 valid [IGP metric 0], #paths 1
 >  if r1-eth1
 >  Last update: Fri Jan 13 15:49:51 2023
 > [..]

This results in having a BGP VPN route for each of the static
routes:

 > # show bgp ipv4 vpn
 > [..]
 > Route Distinguisher: 444:1
 >  *> 172.31.0.14/32   192.0.2.14@9<            0         32768 ?
 >  *> 172.31.0.15/32   192.0.2.12@9<            0         32768 ?
 >  *> 172.31.0.30/32   192.0.2.30@9<            0         32768 ?
 > [..]

Without that patch, only the redistributed routes that rely on a
pre-existing nexthop tracking context could be exported.

Also, a command in the code about redistributed routes is modified
accordingly, to explain that redistribute routes may be submitted
to nexthop tracking in the case label allocation per next-hop is
used.

note:
VNC routes have been removed from the redistribution,
because of a test failure in the bgp_l3vpn_to_bgp_direct test.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09 21:00:57 +02:00
Philippe Guibert
5dba25927d bgpd: correctly initialize the IP nexthop of redistributed routes
This is a preliminary work to export redistributed routes from
a given VRF in an VPN network. The exportation works well, when
the label allocation is based on an per-vrf mode, but not on
a per nexthop mode.

To associate a label with a connected nexthop, the nexthop
tracking contexts are used. Until today, there was no tracking
context for redistributed routes. But when using this vpn
allocation mode, one needs to know whether the route is directly
connected or not. When using the nexthop tracking context, the
nexthop attribute of the bgp update needs to have the nexthop
properly set. This was not the case for the mp_nexthop_global_in
attribute which was empty.

This commit is mandatory in order to later use nexthop tracking
context.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09 21:00:57 +02:00
Philippe Guibert
1c6aa043ef bgpd: use nexthop interface when adding LSP in BGP MPLSVPN
BGP MPLSVPN next hop label allocation was using only the next-hop
IP address. As MPLSVPN contexts rely on bnc contexts, the real
nexthop interface is known, and the LSP entry to enter can apply
to the specific interface. To illustrate, the BGP service is able
to handle the following two iproute2 commands:

 > ip -f mpls route add 105 via inet 192.0.2.45 dev r1-eth1
 > ip -f mpls route add 105 via inet 192.0.2.46 dev r1-eth2

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09 21:00:57 +02:00
Philippe Guibert
577be36a41 bgpd: add support for l3vpn per-nexthop label
This commit introduces a new method to associate a label to
prefixes to export to a VPNv4 backbone. All the methods to
associate a label to a BGP update is documented in rfc4364,
chapter 4.3.2. Initially, the "single label for an entire
VRF" method was available. This commit adds "single label
for each attachment circuit" method.

The change impacts the control-plane, because each BGP update
is checked to know if the nexthop has reachability in the VRF
or not. If this is the case, then a unique label for a given
destination IP in the VRF will be picked up. This label will
be reused for an other BGP update that will have the same
nexthop IP address.

The change impacts the data-plane, because the MPLs pop
mechanism applied to incoming labelled packets changes: the
MPLS label is popped, and the packet is directly sent to the
connected nexthop described in the previous outgoing BGP VPN
update.

By default per-vrf mode is done, but the user may choose
the per-nexthop mode, by using the vty command from the
previous commit. In the latter case, a per-vrf label
will however be allocated to handle networks that are not directly
connected. This is the case for local traffic for instance.

The change also include the following:

-  ECMP case
In case a route is learnt in a given VRF, and is resolved via an
ECMP nexthop. This implies that when exporting the route as a BGP
update, if label allocation per nexthop is used, then two possible
MPLS values could be picked up, which is not possible with the
current implementation. Actually, the NLRI for VPNv4 stores one
prefix, and one single label value, not two. Today, RFC8277 with
multiple label capability is not yet available.
To avoid this corner case, when a route is resolved via more than one
nexthop, the label allocation per nexthop will not apply, and the
default per-vrf label will be chosen.
Let us imagine BGP redistributes a static route using the `172.31.0.20`
nexthop. The nexthop resolution will find two different nexthops fo a
unique BGP update.

 > r1# show running-config
 > [..]
 > vrf vrf1
 >  ip route 172.31.0.30/32 172.31.0.20
 > r1# show bgp vrf vrf1 nexthop
 > [..]
 > 172.31.0.20 valid [IGP metric 0], #paths 1
 >  gate 192.0.2.11
 >  gate 192.0.2.12
 >  Last update: Mon Jan 16 09:27:09 2023
 >  Paths:
 >    1/1 172.31.0.30/32 VRF vrf1 flags 0x20018

To avoid this situation, BGP updates that resolve over multiple
nexthops are using the unique per-vrf label.

- recursive route case

Prefixes that need a recursive route to be resolved can
also be eligible for mpls allocation per nexthop. In that
case, the nexthop will be the recursive nexthop calculated.

To achieve this, all nexthop types in bnc contexts are valid,
except for the blackhole nexthops.

- network declared prefixes

Nexthop tracking is used to look for the reachability of the
prefixes. When the the 'no bgp network import-check' command
is used, network declared prefixes are maintained active,
even if there is no active nexthop.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09 21:00:57 +02:00
Philippe Guibert
546d58702e bgpd: add the bgp_label_per_nexthop_cache struct and apis
This commit introduces the necessary structs and apis to
create the cache entries that store the label information
associated to a given nexthop.

A hash table is created in each BGP instance for all the
AFIs: IPv4 and IPv6. That hash table is initialised.
An API to look and/or create an entry based on a given
nexthop.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09 21:00:57 +02:00
Philippe Guibert
855dcbf158 bgpd: introduce LP_TYPE_NEXTHOP label type
A new label type is introduced: LP_TYPE_NEXTHOP. This new
label type will be used in next commits to allocate labels
for a specific nexthop IP address.
The commit changes add vty and json outputs to display
the new label type and the label values associated.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09 21:00:57 +02:00
Philippe Guibert
d4cdcee5bf bgpd: add vty command to select label allocation per nexthop
A new VTY command is introduced in ipv4 unicast and ipv6 unicast
address family, under a BGP instance.

 > r1# label vpn export allocation-mode per-nexthop|per-vrf

This command will update the label values associated for each
BGP update to export to the global instance. Two modes are
available: per-nexthop and per-vrf. The latter is the default
one.

With this commit only, configuring label allocation per nexthop
will only reset the BGP updates, and the per-vrf mode label
allocation will be chosen.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09 21:00:57 +02:00
Philippe Guibert
83b50eff9a bgpd: remove ATTR_NEXT_HOP for redistributed ipv6 nexthops
This commit addresses an issue with an MPLS VPN network
redistributing static routes that are exported to the VPN,
and where the labels are allocated per next-hop.

For that purpose, the nexthop of the static routes is
checked against the nexthop tracking. The validation
of a valid nexthop will trigger the use of a unique
label for all prefixes using that destination.

However, the nexthop fails to be validated, with the
following message:

 > evaluate_paths: prefix 172:31::14/128 (vrf vrf1), ignoring path due to
 > martian or self-next-hop

The reason is due to the way the attr is created.
By default, the ATTR_NEXTHOP attribute is set for
all prefixes, whereas this flag should only be valid
for IPv4. In the case there is an IPv6 nexthop, remove
the ATTR_NEXTHOP flag.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09 21:00:57 +02:00
Philippe Guibert
9fa282eeb6 bgpd: encode_label call, remove unnecessary braces
Remove unnecessary braces.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09 21:00:57 +02:00
Donatas Abraitis
911bfbf5f1
Merge pull request #13437 from raja-rajasekar/raja-rajasekar/show_cmd_fix
bgpd: Fixing the show bgp <vrf> <afi> <safi> detail command
2023-05-09 12:51:16 +03:00
Donatas Abraitis
53afb27eb8 bgpd: Make sure AIGP attribute is non-transitive
The AIGP attribute is an optional, non-transitive BGP path attribute.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-08 23:20:04 +03:00
Donatas Abraitis
32a2f283d1
Merge pull request #13446 from louis-6wind/fix-ext-comm
bgpd: fix show running of nt extcommunity
2023-05-08 13:44:56 +03:00
Donatas Abraitis
728c096823
Merge pull request #13440 from zice312963205/bgpfix
bgpd: fix the issue of connected tag error when BGP subscribes to NHT…
2023-05-08 11:47:14 +03:00
Jack.zhang
d1fe52f058 bgpd: fix the issue of connected tag error when BGP subscribes to NHT from Zebra
Imagine the following scenario:
1.Create a multihop ebgp peer and config the ttl as 254 for both side.
2.Call bgp_start and start an active connection.
Bgp will send a nht register with non-connected flag.
3.The function bgp_accept be called by remote connection.
Bgp will create a accept peer as a passive connection with default ttl(1). And then will send a nht register again with connected flag. This register result will cover the first one.
4.The active connection come to establish first. In funciton "peer_xfer_conn", check for "PEER_FLAG_CONFIG_NODE" flag of "from_peer->doppelganger" will not be pass, so we can not repair the nht register error forever.
Then the bgp nexthop will be like this:
2000::60 invalid, #paths 0, peer 2000::60
Must be Connected
Last update: Thu May 4 09:35:14 2023

The route from this peer can not be treat with a vaild nexthop forever.
This change will fix this error.

Signed-off-by: Jack.zhang <hanyu.zly@alibaba-inc.com>
2023-05-06 09:57:27 +08:00
Louis Scalbert
586861a141 bgpd: fix show running of nt extcommunity
Setting

> bgp extcommunity-list standard EXT seq 5 permit nt 192.168.1.3:0

results in:

> bgp extcommunity-list standard EXT seq 5 permit NT:192.168.1.3

Fix the display

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-05-05 17:50:36 +02:00
Rajasekar Raja
795bef98db bgpd: Fixing the show bgp <vrf> <afi> <safi> detail command
Adding support to show cmds like  show bgp vrf all detail, show bgp
<afi> <safi> detail & show bgp <vrf> <afi> <safi> detail

Issue:3168406
Ticket:#3168406

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2023-05-05 00:01:21 -07:00
Donatas Abraitis
786e2b8bdb Revert "MPLS allocation mode per next hop"
Broken tests, let's revert now.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-03 13:52:46 +03:00
Donatas Abraitis
99a1ab0b21
Merge pull request #12646 from pguibert6WIND/mpls_alloc_per_nh
MPLS allocation mode per next hop
2023-05-02 18:36:45 +03:00
Donatas Abraitis
bec4eeedc4
Merge pull request #13405 from dmytroshytyi-6WIND/srv6_bgp_no_sid_export_auto
bgpd, tests: srv6 "no sid vpn export auto" per AF in vtysh
2023-05-01 22:07:03 +03:00
Donatas Abraitis
997aad2af7
Merge pull request #13408 from pguibert6WIND/flowspec_sanity
bgpd: add some flowspec sanity returns
2023-05-01 21:58:53 +03:00
Dmytro Shytyi
d7967830ea bgpd: implement "no sid vpn export auto" per AF in vtysh
An example of implemented command for IPv4 AF is presented below.

dev-vm(config-router-af)# do show bgp segment-routing srv6
locator_name: Locator1
locator_chunks:
- 2001:db8:2:5::/64
  block-length: 40
  node-length: 24
  func-length: 16
  arg-length: 0
functions:
bgps:
- name: default
  vpn_policy[AFI_IP].tovpn_sid: (null)
  vpn_policy[AFI_IP6].tovpn_sid: (null)
  per-vrf tovpn_sid: (null)
- name: red
  vpn_policy[AFI_IP].tovpn_sid: (null)
  vpn_policy[AFI_IP6].tovpn_sid: (null)
  per-vrf tovpn_sid: (null)
dev-vm(config-router-af)# sid vpn export auto
^^^<<<<<<<<<<<<<<<<<<<<<< 1. configure sid per af
dev-vm(config-router-af)# do show bgp segment-routing srv6
locator_name: Locator1
locator_chunks:
- 2001:db8:2:5::/64
  block-length: 40
  node-length: 24
  func-length: 16
  arg-length: 0
functions:
- sid: 2001:db8:2:5:1::
  locator: Locator1
bgps:
- name: default
  vpn_policy[AFI_IP].tovpn_sid: (null)
  vpn_policy[AFI_IP6].tovpn_sid: (null)
  per-vrf tovpn_sid: (null)
- name: red
  vpn_policy[AFI_IP].tovpn_sid: 2001:db8:2:5:1::
^^^<<<<<<<<<<<<<<<<<<<<< 2. sid is configured
  vpn_policy[AFI_IP6].tovpn_sid: (null)
  per-vrf tovpn_sid: (null)
dev-vm(config-router-af)# no sid vpn export auto
^^^<<<<<<<<<<<<<<<<<<<< 3. deconfigure sid per af
dev-vm(config-router-af)# do show bgp segment-routing srv6
locator_name: Locator1
locator_chunks:
- 2001:db8:2:5::/64
  block-length: 40
  node-length: 24
  func-length: 16
  arg-length: 0
functions:
bgps:
- name: default
  vpn_policy[AFI_IP].tovpn_sid: (null)
  vpn_policy[AFI_IP6].tovpn_sid: (null)
  per-vrf tovpn_sid: (null)
- name: red
  vpn_policy[AFI_IP].tovpn_sid: (null)
^^^<<<<<<<<<<<<<<<<<<< 4. sid is deconfigured
  vpn_policy[AFI_IP6].tovpn_sid: (null)
  per-vrf tovpn_sid: (null)

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2023-04-28 22:51:12 +02:00
Philippe Guibert
9ba97a35a6 bgpd: add some flowspec sanity returns
If an error is detected in an NLRI, immediately return
an error, when there is a risk of buffer overflow.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-04-28 22:28:16 +02:00
Donatas Abraitis
8bc79f3855
Merge pull request #13335 from pguibert6WIND/bgp_lu_explicit_per_afi
bgpd: configure explicit-null for local paths per address family
2023-04-28 16:27:20 +03:00
Philippe Guibert
cf1c7e309e bgpd: configure explicit-null for local paths per address family
Until now, the bgp local paths were using the default null label
defined. It was not possible to select the null label for the ipv4
or the ipv6 address families.

This commit addresses this issues by adding two extra-parameters
to the BGP labeled-unicast command.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-04-27 17:05:35 +02:00
Philippe Guibert
20d072d3ec bgpd: keep interface index on bgp nexthop tracking
The following BGP configuration does not show that the
resolved next-hop to 192.0.2.1 has a defined interface.

> router bgp 65500
>  bgp router-id 192.0.2.2
>  neighbor 192.0.2.1 remote-as 65500
>  neighbor 192.0.2.1 update-source loop1
>  neighbor 192.168.0.1 remote-as 65500
>  !
>  address-family ipv4 unicast
>   network 192.0.2.2/32
>   no neighbor 192.168.0.1 activate
>  exit-address-family
>  !
>  address-family ipv4 labeled-unicast
>   neighbor 192.168.0.1 activate
>  exit-address-family
>  !
>  address-family ipv4 vpn
>   neighbor 192.0.2.1 activate
>  exit-address-family

The 'show bgp nexthop' dump does not output the interface
whereas the zebra rnh has the information.

> dut-vm# show bgp nexthop
> [..]
> Current BGP nexthop cache:
>  192.0.2.1 valid [IGP metric 0], #paths 1, peer 192.0.2.1
>   gate 192.168.0.1
>   Last update: Mon Apr 24 22:10:07 2023
>
> dut-vm# show ip nht
> 192.0.2.1
>  resolved via bgp
>  via 192.168.0.1, r2-eth0
>  Client list: bgp(fd 33)

Modify the display of BGP nexthop tracking to also dump
the interface used:

> dut-vm# show bgp nexthop
> [..]
> Current BGP nexthop cache:
>  192.0.2.1 valid [IGP metric 0], #paths 1, peer 192.0.2.1
>   gate 192.168.0.1, r2-eth0
>   Last update: Mon Apr 24 22:10:07 2023

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-04-27 17:04:20 +02:00
Donatas Abraitis
34a8441fe8
Merge pull request #13386 from donaldsharp/bgp_received_routes
bgpd: Fix `received-routes detail`
2023-04-26 11:07:00 +03:00