Commit Graph

428 Commits

Author SHA1 Message Date
Yuqing Zhao
6e7f305e54 bgpd: Convert from struct bgp_node to struct bgp_dest
This is based on @donaldsharp's work

The current code base is the struct bgp_node data structure.
The problem with this is that it creates a bunch of
extra data per route_node.
The table structure generates ‘holder’ nodes
that are never going to receive bgp routes,
and now the memory of those nodes is allocated
as if they are a full bgp_node.

After splitting up the bgp_node into bgp_dest and route_node,
the memory of ‘holder’ node which does not have any bgp data
will be allocated as the route_node, not the bgp_node,
and the memory usage is reduced.
The memory usage of BGP node will be reduced from 200B to 96B.
The total memory usage optimization of this part is ~16.00%.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Yuqing Zhao <xiaopanghu99@163.com>
2023-08-22 09:35:46 +08:00
Donald Sharp
3e5a31b24e bgpd: Convert struct peer_connection to dynamically allocated
As part of the conversion to a `struct peer_connection` it will
be desirable to have 2 pointers one for when we open a connection
and one for when we receive a connection.  Start this actual
conversion over to this in `struct peer`.  If this sounds confusing
take a look at the bgp state machine for connections and how
it resolves the processing of this router opening -vs- this
router receiving an open.  At some point in time the state
machine decides that we are keeping one of the two connections.

Future commits will allow us to untangle the peer/doppelganger
duality with this abstraction.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-18 09:29:04 -04:00
Donald Sharp
e20c23fa5b bgpd: Move status and ostatus to struct peer_connection
The status and ostatus are a function of the `struct peer_connection`
move it into that data structure.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-18 09:29:04 -04:00
Donald Sharp
1e8ac95bfb bgpd: evpn code was not properly unlocking rd_dest
Found some code where bgp was not unlocking the dest
and rd_dest when walking the tree attempting to
find something to install.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-11 10:11:10 -04:00
Valerian_He
98efa5bc6b bgpd: bgp_path_info_extra memory optimization
Even if some of the attributes in bgp_path_info_extra are
not used, their memory is still allocated every time. It
cause a waste of memory.
This commit code deletes all unnecessary attributes and
changes the optional attributes to pointer storage. Memory
will only be allocated when they are actually used. After
optimization, extra info related memory is reduced by about
half(~400B -> ~200B).

Signed-off-by: Valerian_He <1826906282@qq.com>
2023-08-08 10:48:07 +00:00
Chirag Shah
bad029e92d bgpd: fix evpn zclient_send_message return code
In scaled EVPN route sync from bgp to zebra, return
code can be ZCLIENT_SEND_BUFFERED which was treated
as error and leads to route install/uninstall failure.

Following error logs were seen:
2023-07-07T17:05:59.640899+03:00 vtep12 bgpd[15305]: [WYBZ0-MM8F1][EC
33554471] 0: Failed to uninstall EVPN IMET route in VNI 478
2023-07-07T17:05:59.640913+03:00 vtep12 bgpd[15305]: [Y5VKN-9BV7H][EC
33554471] default (0): Failed to uninstall EVPN [3]:[0]:[32]:[27.0.0.5]
route from VNI 465 IP table
2023-07-07T17:05:59.640927+03:00 vtep12 bgpd[15305]: [WYBZ0-MM8F1][EC
33554471] 0: Failed to uninstall EVPN IMET route in VNI 465
2023-07-07T17:05:59.640940+03:00 vtep12 bgpd[15305]: [Y5VKN-9BV7H][EC
33554471] default (0): Failed to uninstall EVPN [3]:[0]:[32]:[27.0.0.5]
route from VNI 173 IP table

Ticket:#3499957
Testing Done:

Before fix:

root@vtep12:mgmt:/home/cumulus# bridge -d -s fdb show | grep  27.0.0.5 |
wc -l
16010

Once source VTEP withdraws, DUT VTEP still has stale entries
root@vtep12:mgmt:~# bridge -d -s fdb show | grep  27.0.0.5 | wc -l
12990

After fix:

Once source VTEP withdraws, DUT VTEP still is able to delete entries
root@vtep12:mgmt:/home/cumulus# bridge -d -s fdb show | grep  27.0.0.5 |
wc -l
0

Zapi stats:

Client: bgp
[32/133]
------------------------
FD: 76
Connect Time: 00:26:17
Nexthop Registry Time: 00:26:11
Nexthop Last Update Time: 00:23:31
Client will Not be notified about it's routes status
Last Msg Rx Time: 00:21:33
Last Msg Tx Time: 00:23:31
Last Rcvd Cmd: ZEBRA_REMOTE_MACIP_ADD
Last Sent Cmd: ZEBRA_NEXTHOP_UPDATE

Type        Add         Update      Del
==================================================
IPv4        7           0           1
IPv6        0           0           0
Redist:v4   22          0           0
Redist:v6   0           0           0
VRF         2           0           0
Connected   4170        0           0
Interface   9           0           4
Intf Addr   2166        0           0
BFD peer    0           0           0
NHT v4      2           0           1
NHT v6      4           0           0
VxLAN SG    0           0           0
VNI         1010        0           0
L3-VNI      0           0           0
MAC-IP      46010       0           0
ES          2024        0           0
ES-EVI      0           0           0
Errors: 0

Signed-off-by: Chirag Shah <chirag@nvidai.com>
2023-07-07 18:55:04 -07:00
Russ White
95070f2eef
Merge pull request #13557 from anlancs/fix/bgpd-evpn-rmac-best-path
bgpd: Fix missing deletion of evpn routes
2023-06-20 09:12:51 -04:00
anlan_cs
0c061db4d0 bgpd: Fix missing deletion of evpn routes
Consider the scenario of evpn, the box has some type-5 ECMP routes.

After one of its remote peers is removed ( or down ), `show evpn rmac vni all`
kept no change **sometimes**, it means the rmac of the removed peer maybe is
still in this box, and the traffic will be wrongly forwarded to the removed
peer.

The root cause is that the best path selection for type-5 routes maybe
keep no change and the best path is not routed to the removed peer, so `bgpd`
wrongly doesn't tell `zebra` to remove ( withdraw ) the type-5 routes owned
by the removed peer.

So, add a new flag to force the deletion.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-06-03 09:27:53 +08:00
Trey Aspelund
badc4857aa bgpd: add EVPN reimport handler for martian change
Adds a generalized martian reimport function used for triggering a
relearn/reimport of EVPN routes that were previously filtered/deleted
as a result of a "self" check (either during import or by a martian
change handler). The MAC-VRF SoO is the first consumer of this function,
but can be expanded for use with Martian Tunnel-IPs, Interface-IPs,
Interface-MACs, and RMACs.

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2023-05-30 15:20:35 +00:00
Trey Aspelund
67b493a5b3 bgpd: generalize EVPN martian nexthop changes
Currently we have a handler function that will walk the global EVPN
rib and unimport/remove routes matching a local IP/TIP. This generalizes
this function so that it can be re-used for other BGP Martian entry
types. Now this can be used to unimport routes when the MAC-VRF SoO is
reconfigured.

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2023-05-30 15:20:35 +00:00
Trey Aspelund
465d3e356d bgpd: track L3VNI VTEP-IPs in tip_hash
For whatever reason, we were only updating tip_hash when we processed an
L2VNI add/del. This adds tip_hash updates to the L3VNI add/del codepaths
so that their VTEP-IPs are also used when when considering martian
addresses, e.g. bgp_nexthop_self().

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2023-05-30 15:20:35 +00:00
Trey Aspelund
65cdb9ce9b bgpd: Add MAC-VRF Site-of-Origin support
Initial support for configuring an SoO for all MAC-VRFs (EVIs/L2VNIs).
This provides a topology-independent method of preventing EVPN routes
from one MAC-VRF "site" (an L2 domain) from being imported by other PEs
in the same MAC-VRF "site", similar to how SoO is traditionally used in
L3VPN to identify and break loops for an L3/IP-VRF "site".
One example of where a MAC-VRF SoO can be used to avoid an L2 control
plane loop is with Active/Active MLAG VTEPs. For a given L2 site only
one control plane should be active. SoO can be used to ID/ignore entries
originated from the local MAC-VRF site so that EVPN will not attempt to
manage entries that are already handled by MLAG.

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2023-05-30 15:20:35 +00:00
Trey Aspelund
5d5d126777 bgpd: migrate MTYPE_BGP_EVPN_INFO
bgp_create() and bgp_free() already call EVPN-specific handlers,
so there's no need to XCALLOC/XFREE BGP_EVPN_INFO directly. Let's move
all the references to MTYPE_BGP_EVPN_INFO into the EVPN specific files.

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2023-05-30 15:20:35 +00:00
Russ White
4855ca5e56
Merge pull request #13310 from opensourcerouting/feature/bgpd_node_target_extended_community
bgpd: Add Node Target Extended Communities support
2023-04-25 11:06:23 -04:00
Donatas Abraitis
8f2a51b7b7 bgpd: Reuse encode_route_target_ip() function
Before this patch, this function wasn't used in the code. Let's reuse this
since it's uses the same pattern for encoding route-target extcommunity.

Also reuse encode_route_target_as[4]() as well.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-04-14 22:33:34 +03:00
anlan_cs
e2c7a84bdd bgpd: Simplify the checking local path
Replace the checking local path code in `update_evpn_type5_route_entry()`
with generic function.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-04-13 08:47:06 +08:00
Donald Sharp
5a7c43c77e bgpd: Do not allow l3vni changes when shutting down
When a `no router bgp XXX` is issued and the bgp instance
is in the process of shutting down, do not allow a l3vni
change coming up from zebra to do anything.  We can just
safely ignore it at this point in time.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-10 14:14:01 -04:00
Donald Sharp
aa056a2a64 bgpd: Treat withdraw variable as a bool
Used as a bool, treated as a bool.  Make it a bool

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-06 17:41:32 -04:00
Donald Sharp
d8bc11a592 *: Add a hash_clean_and_free() function
Add a hash_clean_and_free() function as well as convert
the code to use it.  This function also takes a double
pointer to the hash to set it NULL.  Also it cleanly
does nothing if the pointer is NULL( as a bunch of
code tested for ).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-21 08:54:21 -04:00
Donatas Abraitis
0da34e499a bgpd: Drop afi_t from bgp_evpn_global_node_lookup()
Not used.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-03-14 12:05:58 +02:00
Donatas Abraitis
59d6b4d6ab bgpd: Rename bgp_afi_node_lookup() to bgp_safi_node_lookup()
afi not used in this function, reduce a bit.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-03-14 12:01:56 +02:00
Philippe Guibert
7171949de5 bgpd: attr evpn attributes should be modified before interning attr
As remind, the attr attribute is a structure that contains
the attributes for a given BGP update. In order to avoid too much
memory consumption, the attr structure is stored in a hash table.
As consequence, other BGP updates may reuse the same attr. The
storage in the hash table is done when calling bgp_attr_intern(),
and a key is calculated based on all the attributes values of the
structure.

In BGP EVPN, when modifying the attributes of the attr structure
after having interned it, this means that some BGP updates will
want to use the old reference, whereas a new attr value is used.
Because in BGP EVPN, the modifications are done on a per BGP update
basis, a new attr entry specific to that BGP update should be created.
This is why a local_attr structure is done, modified, then later
interned.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-02-24 08:16:36 +01:00
Russ White
f48c8a92fb
Merge pull request #12854 from opensourcerouting/fix/bgp_withdraw_attr_not_used
bgpd: Drop struct attr from bgp_withdraw()
2023-02-21 08:18:37 -05:00
Russ White
ba755d35e5
Merge pull request #12248 from pguibert6WIND/bgpasdot
lib, bgp: add initial support for asdot format
2023-02-21 08:01:03 -05:00
Donatas Abraitis
bf0c616383 bgpd: Drop struct attr from bgp_withdraw()
It's not used at all.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-02-21 11:35:59 +02:00
Donald Sharp
8383d53e43
Merge pull request #12780 from opensourcerouting/spdx-license-id
*: convert to SPDX License identifiers
2023-02-17 09:43:05 -05:00
Stephen Worley
742341e144 bgpd: add mpath label stack helper functions for dvni
Add some bgp_path_info helper functions for getting the correct l3vni
label, getting the vni from the label stack, and determinging if
the mpath is D-VNI based.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2023-02-13 18:12:05 -05:00
Philippe Guibert
fa566a94af bgpd: store the route-distinguisher from config as a string
The route-distinguisher string can be expressed in different
ways when the AS number is part of the RD. And the configured
string value has to be kept intact.
The following vty commands store the string value internally:
- router bgp / address-family ipv4 unicast / rd vpn export <>
- router bgp / address-family l2vpn evpn / rd <>
- router bgp / address-family l2vpn evpn / vni <> / rd <>

The vty commands where RD is configured in the below places is
not considered:
- router bgp / rfapi related commands
- router bgp / address-family xxx xxx / network .. rd <>

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-02-10 10:27:23 +01:00
Philippe Guibert
e55b088399 bgpd: add as-notation keyword to 'router bgp' vty command
A new keyword permits changing the BGP as-notation output:
- [no] router bgp <> [vrf BLABLA] [as-notation [<dot|plain|dot+>]]

At the BGP instance creation, the output will inherit the way the
BGP instance is declared. For instance, the 'router bgp 1.1'
command will configure the output in the dot format. However, if
the client wants to choose an alternate output, he will have to
add the extra command: 'router bgp 1.1 as-notation dot+'.

Also, if the user wants to have plain format, even if the BGP
instance is declared in dot format, the keyword can also be used
for that.

The as-notation output is only taken into account at the BGP
instance creation. In the case where VPN instances are used,
a separate instance may be dynamically created. In that case,
the real as-notation format will be taken into acccount at the
first configuration.

Linking the as-notation format with the BGP instance makes sense,
as the operators want to keep consistency of what they configure.

One technical reason why to link the as-notation output with the
BGP instance creation is that the as-path segment lists stored
in the BGP updates use a string representation to handle aspath
operations (by using regexp for instance). Changing on the fly
the output needs to regenerate this string representation to the
correct format. Linking the configuration to the BGP instance
creation avoids refreshing the BGP updates. A similar mechanism
is put in place in junos too.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-02-10 10:27:23 +01:00
Philippe Guibert
9eb1199710 bgpd: store the bgp as identifier in the configured as-notation
This is a preliminary work to handle various ways to configure
a BGP Autonomous System. When creating a BGP instance, the
user may want to define the AS number as a dotted value,
instead of using an integer value.

To handle both cases, an as_pretty char attribute will store
the as number as it has been given to the vtysh command:

router bgp <as number>

Whenever the as integer of the BGP instance was dumped,
the as_pretty original format is used.

The json output reuses the integer value to keep backward
compatibility with old displays.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-02-10 10:19:06 +01:00
David Lamparter
acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Donald Sharp
58cf0823bf bgpd: Add missing enum's to case statement
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-31 12:29:08 -05:00
Donald Sharp
367b458cb4 bgpd: bgp_update and bgp_withdraw never return failures
These two functions always return 0.  As such any and all
tests against this make no sense.  Remove the return 0
to a void and follow the chain, logically, to remove all
the dead code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-30 16:02:23 -05:00
Trey Aspelund
4dabdde32a bgpd: move tunnel-ip comparison into handler
Moves the old/new IP comparison into handle_tunnel_ip_change instead of
expecting the caller to do the check on their own.
Also changes handle_tunnel_ip_change to return void since it only ever
returned 0 in all cases.

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2023-01-27 11:12:14 -05:00
Trey Aspelund
826c3f6db3 bgpd: only unimport routes if tunnel-ip changes
When processing a new local VNI, we were always walking the global EVPN
table to look for routes that needed to be removed due to a martian
nexthop change (specifically a tunnel-ip change).
Since the martian TIP table is global (all VNIs) + the walk is also in
the global table (all VNIs), we can trust that any new TIP from any VNI
would result in routes getting removed from the global table and
unimported from all live (L2)VNIs.
i.e.
The only time this update is actionable is if we are adding/removing an
IP from the martian TIP table, and we do not need to walk the table for
normal refcount adjustments.

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2023-01-27 11:11:44 -05:00
Russ White
95e5cc2319
Merge pull request #12647 from anlancs/fix/bgpd-type-2
bgpd: cosmetic changes for debug
2023-01-24 10:13:22 -05:00
anlan_cs
47f5eb7487 bgpd: cosmetic changes for debug
Two changes for debug log -
1. Display empty VRF as "None".
2. Correct wrong "type-2" word for type-3 route.

Before:
```
2023/01/17 04:00:30 BGP: [Z5AV7-75RTE] VRF   vni 100 type-2 route evp [3]:[0]:[32]:[88.88.88.88] RMAC 00:00:00:00:00:00 nexthop 88.88.88.88 esi (null)
```

After:
```
2023/01/17 04:05:24 BGP: [M3X4Y-24DVB] VRF None vni 100 type-3 route evp [3]:[0]:[32]:[88.88.88.88] RMAC 00:00:00:00:00:00 nexthop 88.88.88.88 esi (null)
```

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-01-17 17:16:39 +08:00
anlan_cs
07b9f44dfa bgpd: remove one EC log
When creating one interface "vxlan66" ( ip link add vxlan66 type vxlan ... ),
which initially maintains down status, saw one unexpected EC log:

```
zebra[37906]: [ZAG0W-VSNSD] interface vxlan66 vrf default(0) index 35 becomes active.
zebra[37906]: [HPWGA-Y527W] IFLA_VXLAN_LINK missing from VXLAN IF message
...
zebra[37906]: [W6BZR-YZPAB] RTM_NEWLINK update for vxlan66(35) sl_type 0 master 0 flags 0x1002
zebra[37906]: [MR3ZF-ATDBY] Intf vxlan66(35) has gone DOWN
zebra[37906]: [T44X9-FFNVB] Intf vxlan66(35) L2-VNI 66 is DOWN
zebra[37906]: [KEGYY-K8XVV] Send EVPN_DEL 66 to bgp
zebra[37906]: [HPWGA-Y527W] IFLA_VXLAN_LINK missing from VXLAN IF message
bgpd[37911]: [TV0XP-3WR0A] Rx VNI del VRF default VNI 66 tenant-vrf default SVI ifindex 0
bgpd[37911]: [MDW89-YAXJG][EC 33554497] 0: VNI hash entry for VNI 66 not found at DEL
```

Since commit `6f908ded80eeba40a850e8d1f6246fb3ed31e648` support interfaces
from down to down, and bgpd doesn't know "VNI 66" at all. So, remove this
EC log.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-01-04 03:49:39 -05:00
Trey Aspelund
889360dcfd bgpd: cleanup macip_path_list for remote macip
ASAN reported the following memleak:
```
Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x4d4342 in calloc (/usr/lib/frr/bgpd+0x4d4342)
    #1 0xbc3d68 in qcalloc /home/sharpd/frr8/lib/memory.c:116:27
    #2 0xb869f7 in list_new /home/sharpd/frr8/lib/linklist.c:64:9
    #3 0x5a38bc in bgp_evpn_remote_ip_hash_alloc /home/sharpd/frr8/bgpd/bgp_evpn.c:6789:24
    #4 0xb358d3 in hash_get /home/sharpd/frr8/lib/hash.c:162:13
    #5 0x593d39 in bgp_evpn_remote_ip_hash_add /home/sharpd/frr8/bgpd/bgp_evpn.c:6881:7
    #6 0x59dbbd in install_evpn_route_entry_in_vni_common /home/sharpd/frr8/bgpd/bgp_evpn.c:3049:2
    #7 0x59cfe0 in install_evpn_route_entry_in_vni_ip /home/sharpd/frr8/bgpd/bgp_evpn.c:3126:8
    #8 0x59c6f0 in install_evpn_route_entry /home/sharpd/frr8/bgpd/bgp_evpn.c:3318:8
    #9 0x59bb52 in install_uninstall_route_in_vnis /home/sharpd/frr8/bgpd/bgp_evpn.c:3888:10
    #10 0x59b6d2 in bgp_evpn_install_uninstall_table /home/sharpd/frr8/bgpd/bgp_evpn.c:4019:5
    #11 0x578857 in install_uninstall_evpn_route /home/sharpd/frr8/bgpd/bgp_evpn.c:4051:9
    #12 0x58ada6 in bgp_evpn_import_route /home/sharpd/frr8/bgpd/bgp_evpn.c:6049:9
    #13 0x713794 in bgp_update /home/sharpd/frr8/bgpd/bgp_route.c:4842:3
    #14 0x583fa0 in process_type2_route /home/sharpd/frr8/bgpd/bgp_evpn.c:4518:9
    #15 0x5824ba in bgp_nlri_parse_evpn /home/sharpd/frr8/bgpd/bgp_evpn.c:5732:8
    #16 0x6ae6a2 in bgp_nlri_parse /home/sharpd/frr8/bgpd/bgp_packet.c:363:10
    #17 0x6be6fa in bgp_update_receive /home/sharpd/frr8/bgpd/bgp_packet.c:2020:15
    #18 0x6b7433 in bgp_process_packet /home/sharpd/frr8/bgpd/bgp_packet.c:2929:11
    #19 0xd00146 in thread_call /home/sharpd/frr8/lib/thread.c:2006:2
```

The list itself was not being cleaned up when the final list entry was
removed, so make sure we do that instead of leaking memory.

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2022-12-15 18:52:16 +00:00
Donatas Abraitis
f8d69be43f
Merge pull request #12081 from sworleys/EMM-upstream
Rework of Various Handling in EVPN for Extended Mac Mobility
2022-11-17 16:46:58 +02:00
Donatas Abraitis
272c6d5db1
Merge pull request #8647 from sworleys/DVNI-Config-Changes
bgpd: EVPN D-VNI L3 RT Config Enhancements
2022-10-18 14:17:04 +03:00
Trey Aspelund
b5118501ac bgpd: don't unlock bgp_dest twice
Both install_evpn_route_entry_in_vni_mac() and
install_evpn_route_entry_in_vni_ip() will unlock the bgp_dest when
install_evpn_route_entry_in_vni_common() returns, so there's no need to
unlock the bgp_dest inside the _common function.  Let's let the new
wrappers handle the cleanup of the dest.

Ticket: #3119673

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2022-10-11 16:18:21 -04:00
Stephen Worley
852d9f9757 bgpd,zebra,lib: bgp evpn vni macip into two tables
Re-work the bgp vni table to use separately keyed tables for type2
routes.

So, with type2 routes, we have the main table keyed off of the IP and a
new MAC table keyed off of MACs.

By separating out the two, we are able to run path selection separately
for the neigh and mac. Keeping the two separate is also more in-line
with what happens in zebra (they are managed comptletely seperate).

With this change type2 routes go into each table like so:

```
Remote MAC-IP -> IP Table & MAC Table
Remote MAC -> MAC Table

Local MAC-IP -> IP Table
Local MAC -> MAC Table
```

The difference for local is necessary because we should not ever allow
multiple paths for a local MAC.

Also cleaned up the commands for querying the vni tables:

```
show bgp vni all type ...
show bgp vni VNI type ...

```

Old commands will be deprecated in a separate commit.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-10-11 16:18:21 -04:00
Anuradha Karuppiah
36bac85c7f bgpd: sync seq numbers only if the MAC address is the same
We locate the sync path with the highest seq number for normalizing
local path to the same seq. With the change to maintain the VNI RT table
by IP address (instead of MAC&IP) we need additional changes to skip
paths with a different mac address than the local one we are trying to
normalize.

Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
2022-10-11 15:18:39 -04:00
Anuradha Karuppiah
90f30caa24 bgpd: include ESI in the zebra update log
Log changes only; no functional change.

Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
2022-10-11 15:18:39 -04:00
Stephen Worley
34c7f35f02 bgpd: rework VNI table for type2/macip routes
Use the IP addr of type2/macip routes only for the hash/key
of the VNI table and carry the MAC in a path_info_extra attribute.

There is exists situations that can be hit during extended MAC mobility events
where two MACs could be pointing to the same IP in our global table. It
is requires very specific timings.

When that happens, BPG would (because we key'd on both MAC and IP)
install both into it's VNI table as separate entries, but zebra only
knows/needs to know about a single IP -> MAC relationship for it's VNI
table's type2 routes. So it was compleletly undeterministic which one
zebra would end up with in these timing situations.

With these changes, we move BGP's VNI table to key'd the same as Zebra's
and now a single IP will have multiple path_info's with a path_info_extra
that is carrying the MAC info for each path.

BGP will then run best path to deterministically decide which one to send to
zebra during the occasions where there exist's two possible MACs.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-10-11 15:18:39 -04:00
Donatas Abraitis
fd43ffd974 bgpd: Do not forget to unlock bgp_dest from update_advertise_vni_routes
If "unexpected" happens.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-06 11:49:08 +03:00
Donatas Abraitis
3727e359e3 bgpd: Cleanup memory for missing hashes
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-30 13:46:26 +03:00
Donatas Abraitis
511211bf56 bgpd: Convert prefix2str to %pFX
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-25 14:35:27 +03:00
Donald Sharp
083ec940ab bgpd: Convert from bgp_clock() to monotime()
Let's convert to our actual library call instead
of using yet another abstraction that makes it fun
for people to switch daemons.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-24 08:23:40 -04:00