Commit Graph

422 Commits

Author SHA1 Message Date
Donald Sharp
f00b37e710 zebra: make rib_process_dplane_results own ctx freeing
The rib_process_dplane_results function was having each
sub function handler process the results and then
free the ctx.  Lot's of functionality that needs to remember
to free the context.  Let's just free it in the main loop.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-29 15:24:20 -04:00
anlan_cs
41a8b88ce4 zebra: move the check for l3vni
The two checks for l3vni have been already done in
`lib_vrf_zebra_l3vni_id_modify()` as it should be. And it is improper that
the two checks are put after `zebra_vxlan_handle_vni_transition()`, which
will do real things.

My original fix is to remove them. But NB module can't guarantee many changes,
so we'd better keep them in `zebra_vxlan_process_vrf_vni_cmd()` in APPLY stage
for safe.

Just move them in front of `zebra_vxlan_handle_vni_transition()`.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-06-23 01:33:45 -04:00
Trey Aspelund
56599dd9c8 zebra: Update advertise-svi-ip MACIPs w/ new MAC
When the kernel was sending an RTM_NEWLINK updating the MAC of a known
SVI, Type-2 routes created by advertise-svi-ip were not getting updated
with the new address.
This adds removal of any old Type-2 routes (with old MAC) and creation
of new Type-2 routes (with new MAC) into RTM_NEWLINK processing.

Fixes: #11174

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2022-05-28 03:30:05 -04:00
Sri Mohana Singamsetty
595ebf525b
Merge pull request #11210 from anlancs/fix/zebra-leak-vtp
zebra: fix missing delete vtep during vni transition
2022-05-19 09:35:27 -07:00
anlan_cs
2fe5a02ea4 zebra: fix missing delete vtep during vni transition
All `vtep`s in dplane should be deleted/uninstalled during vni transition.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-16 09:30:28 -04:00
anlan_cs
0717f2d83c zebra: remove unncecessary check for l3vni
Since `l3vni` created by `zl3vni_add()` is always valid, remove the check
for it.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-16 05:40:15 -04:00
anlan_cs
81157cbd10 zebra: remove unnecessary check for "zevpn_vrf"
The global vrf in zebra is always non-NULL. In general, it is bound to
default vrf by `zebra_vrf_init()`, at other times bound to some specific
vrf. Anyway, non-NULL.

So remove all redundant checkings for the returned value of
`zebra_vrf_get_evpn()`.

Additionally, remove the unnecessary check for `zvrf` in
`zebra_vxlan_cleanup_tables()`.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-13 23:31:52 -04:00
Donatas Abraitis
6006b807b1 *: Properly use memset() when zeroing
Wrong: memset(&a, 0, sizeof(struct ...));
    Good:  memset(&a, 0, sizeof(a));

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-11 14:08:47 +03:00
Donatas Abraitis
8998807f69 *: Avoid casting to the same type as on the left
Just not necessary.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-08 16:07:42 +03:00
anlan_cs
8e3aae66ce *: remove the checking returned value for hash_get()
Firstly, *keep no change* for `hash_get()` with NULL
`alloc_func`.

Only focus on cases with non-NULL `alloc_func` of
`hash_get()`.

Since `hash_get()` with non-NULL `alloc_func` parameter
shall not fail, just ignore the returned value of it.
The returned value must not be NULL.
So in this case, remove the unnecessary checking NULL
or not for the returned value and add `void` in front
of it.

Importantly, also *keep no change* for the two cases with
non-NULL `alloc_func` -
1) Use `assert(<returned_data> == <searching_data>)` to
   ensure it is a created node, not a found node.
   Refer to `isis_vertex_queue_insert()` of isisd, there
   are many examples of this case in isid.
2) Use `<returned_data> != <searching_data>` to judge it
   is a found node, then free <searching_data>.
   Refer to `aspath_intern()` of bgpd, there are many
   examples of this case in bgpd.

Here, <returned_data> is the returned value from `hash_get()`,
and <searching_data> is the data, which is to be put into
hash table.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-03 00:41:48 +08:00
Donald Sharp
2c38c8ad35
Merge pull request #10928 from anlancs/zebra-cleanup-1
zebra: use "assert" instead of unnecessary check
2022-04-05 09:49:00 -04:00
anlan_cs
c4992a2f71 zebra: fix missing vrf change of l2vni on vxlan interface
The bounded vrf of `l2vni/zevpn` have wrong relation with the order
in which vxlan interface and svi interface are set.

If set vxlan interface with vlanid first, then set svi interface with
vrf, it is ok that vxlan interface will get correct `vrf` inherited
from svi. But reverse the set sequence (i.e. set svi first, then vxlan),
vxlan interface can't get correct `vrf`, becasue the handling of
`ZEBRA_VXLIF_VLAN_CHANGE` missed inheritting `vrf` by mistake.

```
host# do show  evpn vni 101
VNI: 101
Type: L2
Tenant VRF: vrf1
```

So update `vrf` ("Tenant VRF") of l2vni in `zebra_vxlan_if_update()`.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-03-31 02:51:26 -04:00
anlan_cs
44a84850a9 zebra: use "assert" instead of unnecessary check
Like `zvni_map_to_svi_ns()` for `ns_walk_func()`, just use "assert"
instead of unnecessary check.

Since these parameters for `ns_walk_func()`, e.g. `in_param` and others,
must not be NULL. So use `assert` to ensure the these parameters, and
remove those unnecessary checks.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-03-30 03:19:28 -04:00
Sri Mohana Singamsetty
116f0dd905
Merge pull request #10726 from chiragshah6/fdev2
zebra: evpn revamp l3vni routermac db
2022-03-22 22:05:47 -07:00
Sri Mohana Singamsetty
3d58538a75
Merge pull request #10770 from chiragshah6/evpn_dev3
zebra: evpn disable remove l2vni from l3vni list
2022-03-15 12:32:22 -07:00
Donald Sharp
052b0eee2a
Merge pull request #10693 from anlancs/bgpd-add-check-ns
zebra: use "assert" instead of unnecessary check
2022-03-15 08:27:44 -04:00
anlan_cs
df44783078 zebra: use "assert" instead of unnecessary check
Since `zvni_map_to_svi_ns()` is used to find and return one specific interface
based on passed attributes of SVI, so the two parameters `in_param` and `p_ifp`
must not be NULL.

Passing NULL `p_ifp` makes no sense, so the check `if (p_ifp)` is
unnecessary.

So use `assert` to ensure the two parameters, and remove that unnecessary check.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-03-12 12:44:47 +08:00
Chirag Shah
b27be4dbd7 zebra: evpn disable remove l2vni from l3vni list
Upon 'no advertise-all-vni', cleanup l2vni from
its tenant-vrf's l3vni list, instead of passed
zvrf->l3vni which will not be present in case
of default instance.

Reviewed By:
Testing Done:
Before Fix:
----------
TORC12(config-router-af)# advertise-all-vni
TORC12(config-router-af)# end
TORC12# show evpn vni 4001
VNI: 4001
  Type: L3
  Tenant VRF: vrf1
  Vxlan-Intf: vni4001
  State: Up
  Router MAC: 44:38:39:ff:ff:01
  L2 VNIs: 134217728 0 1000 1002 <-----

After Fix:
----------
TORC12# show evpn vni 4001
VNI: 4001
  Type: L3
  Tenant VRF: vrf1
  Vxlan-Intf: vni4001
  State: Up
  Router MAC: 44:38:39:ff:ff:01
  L2 VNIs: 1000 1002

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-03-10 19:59:33 -08:00
Chirag Shah
3d43b95ce1 zebra: cleanup host prefix from rmac
Ticket:#2798406
Testing Done:

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-03-10 17:27:15 -08:00
Chirag Shah
4a8e182a66 zebra: print rmac nexthop list
Ticket:#2798406
Reviewed By:
Testing Done:

Before change:
--------------

TORS1# show evpn rmac vni 4001 mac  44:38:39:ff:ff:01
MAC: 44:38:39:ff:ff:01
 Remote VTEP: 36.0.0.11
 Refcount: 1
  Prefixes:
    [1]:[00:00:00:00:00:00:00:00:00:00]:[::]/352
TORS1#
TORS1# show evpn rmac vni 4001 mac 44:38:39:ff:ff:01 json
{
  "routerMac":"44:38:39:ff:ff:01",
  "vtepIp":"36.0.0.11",
  "refCount":1,
  "localSequence":0,
  "remoteSequence":0,
  "prefixList":[
    "[1]:[00:00:00:00:00:00:00:00:00:00]:[::]\/352"
  ]
}

After change:
-------------

TORS1# show evpn rmac vni 4001 mac 44:38:39:ff:ff:01
MAC: 44:38:39:ff:ff:01
 Remote VTEP: 36.0.0.11
 Refcount: 0
  Prefixes:
TORS1#
TORS1# show evpn rmac vni 4001 mac 44:38:39:ff:ff:01 json
{
  "routerMac":"44:38:39:ff:ff:01",
  "vtepIp":"36.0.0.11",
  "nexthops":[
    "36.0.0.11"
  ]
}

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-03-10 17:27:15 -08:00
Chirag Shah
ae9e6beaea zebra: remove host prefix mapping in rmac
RMAC keeping list of nexthops to keep track
of its existiance, remove the (old way) host prefix
mapping.

Ticket: #2798406
Reviewed By:
Testing Done:

TORS1# show evpn rmac vni 4001 mac  44:38:39:ff:ff:01
MAC: 44:38:39:ff:ff:01
 Remote VTEP: 36.0.0.11
  Refcount: 0
    Prefixes:

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-03-10 17:27:15 -08:00
Chirag Shah
db88997872 zebra: maintain list of nhs in rmac db
Keep the list of remote-vteps/nexthops in
rmac db.

Problem:
In CLAG deployment there might be a situation
where CLAG secondary sends individual ip as nexthop
along with anycast mac as RMAC. This combination
is updated in zebra's rmac cache.
Upon recovery at clag secondary sends withdrawal
of the incorrect rmac and nexthop mapping.
The RMAC entry mapping to nh is not cleaned up properly
in the zebra rmac cache.

Fix:
Zebra rmac db needs to maintain a list of nexthops.
When a bgp withdrawal for rmac to nexthop mapping
is received, remove the old nexthop from the rmac's nh
list and if the host reference still remains for
the RMAC,fall back to the nexthop one remaining in
the list.
At most you expect two nexthops mapped to RMAC
(in clag deployment).

Ticket: 2798406
Reviewed By:
Testing Done:

CLAG primary and secondary have advertise-pip enabled
advertise type-5 route (default route) with
individual IP as nh and individual svi mac as rmac.

- disable advertise pip on both clag devices, this
results in advertisement of routes with anycast ip as nh
and anycast mac as rmac.

- disable peerlink on clag primary, this triggers
clag secondary to (transitory) send bgp update with
individual ip as nh and anycast mac as rmac.

- At the remote vtep:
Check the zebra's rmac cache/nh mapping correctly
and points to anycast rmac and anycast ip as nh of the
clag system.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-03-10 17:27:15 -08:00
anlan_cs
97511d01af zebra: Remove unnecessary check
Since `assert` is already done, just remove these unnecessary check.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-02-06 20:28:31 -05:00
anlan_cs
b816de6213 zebra: correct one spell error
Signed-off-by: anlan_cs <anlan_cs@tom.com>
2021-12-19 20:47:01 -05:00
Donatas Abraitis
c48349e346 *: Remove redundand braces for single statement blocks
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-27 11:20:59 +02:00
Donatas Abraitis
962af8a8cd zebra: Convert vty_out to vty_json for JSON
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25 17:49:46 +02:00
Igor Ryzhov
096f7609f9 *: cleanup ifp->vrf_id
Since f60a1188 we store a pointer to the VRF in the interface structure.
There's no need anymore to store a separate vrf_id field.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-22 20:47:23 +03:00
Donatas Abraitis
08edf9c6af zebra: Replace inet_ntop to %pI4/6 for JSON outputs
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-18 18:45:41 +02:00
Quentin Young
b0b77855c8 zebra: use tabs instead of spaces zebra_vxlan.c
Bad style introduced in
https://github.com/FRRouting/frr/pull/10006

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2021-11-12 11:09:48 -05:00
Chirag Shah
b13f35ec67 zebra: svi down remove l2vni from l3vni list
Problem:
L2-VNI SVI down followed by L2-VNI's vxlan device
deletion leads to stale entry into L3VNI's
L2-VNI list.

Solution:
When L2-VNI associated SVI is down, default vrf
is the new tenant vrf.
Remove L2-VNI from L3VNI's l2vni list as
L3VNI/VRF is no longer valid in absence of associated
SVI.

When SVI is up re-add L2-VNI into associated VRF's
L3VNI.

The above remove/add from the L3VNI's L2VNI list is
already done when vxlan or L2-VNI is flaped, just need
to handle when SVI is flapped.

Ticket:#2817127
Reviewed By:
Testing Done:

After deleting SVI following by L2-VNI deletion,
L3VNI's L2-VNI list delets the L2-VNI. (no stale entry).

After adding back SVI/L2-VNI, L3VNI list adds back the
L2-VNI and it is associated right tenant VRF.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-11-08 09:33:16 -08:00
Igor Ryzhov
a2df495fdf zebra: don't use if_lookup_by_index_all_vrf
if_lookup_by_index_all_vrf doesn't work correctly with netns VRF backend
as the same index may be used in multiple netns simultaneously.

In both case where it's used, we know the VRF in which we need to lookup
for the interface.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-28 18:54:46 +03:00
Philippe Guibert
c762010889 zebra: handle bridge mac address update in evpn contexts
when running bgp evpn rt5 setup, the Rmac sent in BGP updates
stands for the MAC address of the bridge interface. After
having loaded frr configuration, the Rmac address is not refreshed.
This issue can be easily reproduced by executing some commands:

ip netns exec cust1 ip link set dev br1000 address  2e🆎45:aa:bb:cc

Actually, the BGP EVPN contexts are kept unchanged.
That commit proposes to fix this by intercepting the mac address
change, and refreshing the vxlan interfaces attached to te bridge
interface that changed its MAC address.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-09-17 10:25:35 +02:00
Philippe Guibert
2490726201 zebra: update zl3vni when bridge link refreshed in other namespaces
When running bgp evpn rt5 setup with vrf namespace backend, once the
BGP configuration loaded, some refresh like the config change of a
vxlan interface is not taken into account. As consequence, the BGP
l2vpn evpn entries are empty. This can happen by recreating vxlan
interface like follows:

ip netns exec cust1 ip li del vxlan1000
ip link add vxlan1000 type vxlan id 1000 dev loopback0 local 10.209.36.1 learning
ip link set dev vxlan1000 mtu 9000
ip link set dev vxlan1000 netns cust1
ip netns exec cust1 bash
ip link set dev vxlan1000 up
ip link set dev vxlan1000 master br1000

Actually, changing learning attribute requires recreation, and this
change needs to manually reload the frr configuration.

The update mechanism in zebra about vxlan interface updates is
already put in place, but it does not work well with namespace
based vrf backend. The function zl3vni_from_svi() is then
modified to parse all the interfaces of each namespace.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-09-07 14:10:58 +02:00
Donald Sharp
72de4110dc zebra: Convert to struct zebra_neigh as per our internal standard
We do not use typedef's to talk about structures as per our standard.
Fixing.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-02 10:33:23 -04:00
Donald Sharp
05843a27f5 zebra: Convert to struct zebra_l3nvi as per our internal standard
We do not use typedef's to talk about structures as per our standard.
Fixing.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-02 10:33:22 -04:00
Donald Sharp
847f168d76 zebra: Convert to struct zebra_vxlan_sg as per our internal standard
We do not use typedef's to talk about structures as per our standard.
Fixing.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-02 10:33:22 -04:00
Donald Sharp
3198b2b347 zebra: Convert to struct zebra_mac as per our internal standard
We do not use typedef's to talk about structures as per our standard.
Fixing.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-02 10:33:22 -04:00
Donald Sharp
c172c032ef zebra: Convert to struct zebra_vtep as per our internal standard
We do not use typedef's to talk about structures as per our standard.
Fixing.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-02 10:33:22 -04:00
Donald Sharp
f6371c343a zebra: Convert to struct zebra_evpn as per our internal standard
We do not use typedef's to talk about structures as per our standard.
Fixing.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-02 10:33:22 -04:00
Anuradha Karuppiah
82732723da zebra: use a separate dummy prefix for referencing v6 nexthops
v4 and v6 host/refernce prefixes need to be setup separately for
[RMAC, VTEP] entries as the VTEP is always normalized to a v4 addr.

Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
2021-07-29 17:25:11 -07:00
Trey Aspelund
fb0b54b361 zebra: Remove MM seq from evpn rmac json output
Currently 'show evpn rmac vni .. mac .. json' includes fields for
localSequence and remoteSequence, which are misleading since they
aren't applicable to a macs in the IP-VRF mac table (RMAC).
This removes the localSequence + remoteSequence fields from the output.

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2021-07-22 20:23:56 +00:00
Mark Stapp
7e5b0b2b36 zebra: process EVPN remote VTEP updates from the workqueue
Move remote VTEP updates from immediate, inline processing
in their ZAPI message handlers to the main workqueue.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-07-19 10:36:12 -04:00
Mark Stapp
7f7e49d11a zebra: use workqueue for vxlan remote macip updates
Enqueue incoming vxlan remote macip updates on the main
workqueue, instead of performing the updates immediately,
in-line.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-07-19 10:36:12 -04:00
Mark Stapp
272e11bfc4 zebra: give some evpn apis better names
Use more useful names for a few evpn apis.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-07-19 08:43:48 -04:00
Ameya Dharkar
1b09e77e4d Zebra: FPM support for gateway IP overlay Index
FPM sends VNI to the data plane with the EVPN prefix. For pure type-5 EVPN
route, nexthop interface of EVPN prefix is L3VNI SVI. Thus, we encode L3VNI
corresponding to the nexthop vrf with rtmsg for this prefix.

For EVPN type-5 route with gateway IP overlay index, we supporting
asymmetric IRB. Thus, nexthop interface is L2VNI SVI. So, instead of fetching
vrf VNI, fetch VNI corresponding to the nexthop SVI and encode it in the rtmsg
for EVPN prefix.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2021-06-07 17:59:45 -07:00
Ameya Dharkar
9daa5d471a bgpd, zebra: Add svi_interface to zebra VNI and bgp EVPN structures
SVI ifindex for L2VNI is required in BGP to perform EVPN type-5 to type-2
recusrsive resolution using gateway IP overlay index.

Program this svi_ifindex in struct zebra_vni_t as well as in struct bgpevpn

Changes include:
1. Add svi_if field to struct zebra_evpn_t
2. Add svi_ifindex field to struct bgpevpn
3. When SVI (bridge or VLAN) is bound to a VxLAN interface, store it in the
zebra_evpn_t structure.
4. Add this SVI ifindex to ZEBRA_VNI_ADD
5. Store svi_ifindex in struct bgpevpn

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2021-06-07 17:58:23 -07:00
Patrick Ruddy
4006e41baf
Merge pull request #8646 from chiragshah6/mdev
zebra: evpn check vni oper state in svi up/down event
2021-05-18 11:45:56 +01:00
David Lamparter
e207132594 zebra: fix style warnings in previous commits
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-05-09 19:37:12 +02:00
Chirag Shah
196d7a86d0 zebra: check vni oper state in svi up notif
When clagd is stopped on secondary device,
all vxlan interfaces (vnis) are kept in protodown state.
FRR treats protodown vxlan interfaces (vnis) as interface down
and sends vni delete to bgpd.

In the event of clagd down, SVIs are flapping as underlying
bridge is going through churn.
When FRR receives SVI up notification do not trigger event to bgpd
if vnis are operationaly down.

Ticket:#2600210 CM-22929
Reviewed By:CCR-11544
Testing Done:
Performed CLAG stop/start on secondary device, all vxlan devices
remained in protodown along with this validated the vnis are cleaned up
and added back in bgpd.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-05-07 15:02:05 -07:00
Donald Sharp
4a73887e0f zebra: Reduce per vrf memory usage from hash table creation
When creating a large number of vrf's we are creating a fairly
large number of hash tables per vrf.  Reduce memory usage on
startup as well as let us identify the table these things come
from.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-05 10:08:06 -04:00