Commit Graph

5113 Commits

Author SHA1 Message Date
Donatas Abraitis
cc6c75300d
Merge pull request #11429 from donaldsharp/interface_funkiness
zebra: Fix rtadv startup when config read in is before interface up
2022-06-24 23:07:45 +03:00
Jafar Al-Gharaibeh
443795a864
Merge pull request #11469 from donaldsharp/fdev2
zebra: netlink rtm tunnel msg parsing
2022-06-24 10:05:56 -05:00
Russ White
a9adefc22f
Merge pull request #11464 from donaldsharp/linkdown
Linkdown
2022-06-24 10:15:55 -04:00
Donald Sharp
4cd26be0f3
Merge pull request #11258 from anlancs/fix/zebra-keep-nb-check
zebra: move the checks for l3vni
2022-06-24 09:46:12 -04:00
Chirag Shah
acc8e68720 zebra: netlink rtm tunnel msg parsing
'bridge vni add vni <id> dev <vxlan device>'
generates new RTM_NEWTUNNEL and RTM_DELTUNNEL
to add or remove vni to l3vxlan device.

Register new RTNLGRP_TUNNEL group to receive
new netlink notification.
Callback for the new RTM_xxxTUNNEL.

kernel patches:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/
linux.git/commit/?h=v5.18-rc7&id=7b8135f4df98b155b23754b6065c157861e268f1

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/
linux.git/commit/?h=v5.18-rc7&id=f9c4bb0b245cee35ef66f75bf409c9573d934cf9

Ticket:#3073812
Testing Done:

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-06-24 07:33:34 -04:00
Donald Sharp
7937058b94 zebra: Fix rtadv startup when config read in is before interface up
When a interface is configured with this:
int eva
  ipv6 nd ra-interval 5
  no ipv6 nd suppress-ra
!

And then subsuquently the interface is created and brought up, FRR
would both error on joining the RA multicast address and never
properly work in this state.

Delay the startup of the join and start of the Router Advertisements
until after the ifindex has actually been found.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-24 07:18:41 -04:00
Donald Sharp
8a8fd10a47
Merge pull request #11453 from ribarroetavena/master
zebra: rtnetlink: flow attr per gateway attr in multipath updates
2022-06-23 13:55:51 -04:00
Donald Sharp
fc3de981be zebra: Allow kernel routes to stick around better on interface state changes
Currently kernel routes on system bring up would be `auto-accepted`,
then if an interface went down all kernel and system routes would
be re-evaluated.  There exists situations where a kernel route can
exist but the interface itself is not exactly in a state that is
ready to create a connected route yet.  As such when any interface
goes down in the system all kernel/system routes would be re-evaluated
and then since that interfaces connected route is not in the table yet
the route is matching against a default route( or not at all ) and
is being dropped.

Modify the code such that kernel or system routes just look for interface
being in a good state (up or operative) and accept it.

Broken code:
eva# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:05:08
K>* 1.2.3.5/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:05:08
K>* 1.2.3.6/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:05:08
K>* 1.2.3.7/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:05:08
K>* 1.2.3.8/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:05:08
K>* 1.2.3.9/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:05:08
K>* 1.2.3.10/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:05:08
K>* 1.2.3.11/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:05:08
K>* 1.2.3.12/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:05:08
K>* 1.2.3.13/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:05:08
K>* 1.2.3.14/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:05:08
K>* 1.2.3.16/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:05:08
K>* 1.2.3.17/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:05:08
C>* 4.5.6.99/32 is directly connected, dummy9, 00:05:08
K>* 4.9.10.11/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:05:08
K>* 10.11.12.13/32 [0/0] via 192.168.119.1, enp39s0, 00:05:08
C>* 192.168.10.0/24 is directly connected, dummy99, 00:05:08
C>* 192.168.119.0/24 is directly connected, enp39s0, 00:05:08
<shutdown a non-related interface>
eva# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:05:28
C>* 4.5.6.99/32 is directly connected, dummy9, 00:05:28
K>* 10.11.12.13/32 [0/0] via 192.168.119.1, enp39s0, 00:05:28
C>* 192.168.10.0/24 is directly connected, dummy99, 00:05:28
C>* 192.168.119.0/24 is directly connected, enp39s0, 00:05:28

Working code:
eva# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:00:04
K>* 1.2.3.5/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:04
K>* 1.2.3.6/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:04
K>* 1.2.3.7/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:04
K>* 1.2.3.8/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:04
K>* 1.2.3.9/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:04
K>* 1.2.3.10/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:04
K>* 1.2.3.11/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:04
K>* 1.2.3.12/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:04
K>* 1.2.3.13/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:04
K>* 1.2.3.14/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:04
K>* 1.2.3.16/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:04
K>* 1.2.3.17/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:04
C>* 4.5.6.99/32 is directly connected, dummy9, 00:00:04
K>* 4.9.10.11/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:04
K>* 10.11.12.13/32 [0/0] via 192.168.119.1, enp39s0, 00:00:04
C>* 192.168.10.0/24 is directly connected, dummy99, 00:00:04
C>* 192.168.119.0/24 is directly connected, enp39s0, 00:00:04
<shutdown a non-related interface>
eva# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:00:15
K>* 1.2.3.5/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:15
K>* 1.2.3.6/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:15
K>* 1.2.3.7/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:15
K>* 1.2.3.8/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:15
K>* 1.2.3.9/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:15
K>* 1.2.3.10/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:15
K>* 1.2.3.11/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:15
K>* 1.2.3.12/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:15
K>* 1.2.3.13/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:15
K>* 1.2.3.14/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:15
K>* 1.2.3.16/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:15
K>* 1.2.3.17/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:15
C>* 4.5.6.99/32 is directly connected, dummy9, 00:00:15
K>* 4.9.10.11/32 [0/0] via 172.22.0.44, br-23e378ed7fd2 linkdown, 00:00:15
K>* 10.11.12.13/32 [0/0] via 192.168.119.1, enp39s0, 00:00:15
C>* 192.168.10.0/24 is directly connected, dummy99, 00:00:15
C>* 192.168.119.0/24 is directly connected, enp39s0, 00:00:15
eva#

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-23 12:22:30 -04:00
Donald Sharp
3689905d32 zebra: Add interface sysctl ignore on linkdown status
Add the ability to decode the ignore on linkdown nexthop
status for an interface.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-23 11:23:37 -04:00
Donald Sharp
c704cb44a9 lib, zebra: Notice when a nexthop is set linkdown
When a nexthop is set RTNH_F_LINKDOWN, start noticing
that this flag is set.  Allow FRR to know about this
flag but at this point do not do anything with it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-23 11:23:37 -04:00
Donald Sharp
2b9dc841b7 zebra: Fix bug in netconf handling where dplane would drop the change
When reading a on the fly change of an interested netconf netlink
message. The ifindex and ns_id for the context was being set for the sub structure
but not for the main context data structure and zebra_if_dplane_result
was dropping the result on the floor because it was expecting the ns_id and
the interface id to be in a different spot.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-23 11:23:08 -04:00
Ricardo
63eaefa86c zebra: rtnetlink: flow attr per gateway attr in multipath updates
Signed-off-by: Ricardo <rbarroetavena@anura.com.ar>
2022-06-23 12:05:26 -03:00
Russ White
98b3ab772e
Merge pull request #10629 from leonshaw/fix/mp-evpn-nh
lib, zebra, bgpd: Move route EVPN flag to nexthop
2022-06-23 07:00:33 -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
Donatas Abraitis
0ba27f1cb2
Merge pull request #11427 from anlancs/fix/minor-2
zebra: remove redundant calling hook for fpm
2022-06-22 11:39:13 +03:00
rvaratharaj
4bf66f436e Zebra EVPN Debug: Fixing log flooding when disabling MLAG leaf configuration
When disabling MLAG leaf configuration with EVPN, logs are
getting flooded for each VNI, This is the result of each Type-2
packets. Ideally, this should be under log debugging, not a warning.

Testing: UT
Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>
2022-06-21 18:18:14 -07:00
Donatas Abraitis
01ceb8b23c
Merge pull request #11417 from donaldsharp/nhg_timer
Nhg timer
2022-06-21 18:43:45 +03:00
Donatas Abraitis
4ed0abcb55
Merge pull request #11423 from donaldsharp/lgtm_fixes
Lgtm fixes
2022-06-19 22:33:01 +03:00
anlan_cs
f1f4a65288 zebra: remove redundant calling hook for fpm
Since the calling hook for old fpm is done in `rib_uninstall_kernel()`
inside, this calling place outside should be redundant. Just remove it.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-06-17 17:42:12 -04:00
Donald Sharp
8dfcf20fa0
Merge pull request #11419 from anlancs/fix/minor-1
zebra, lib: minor changes
2022-06-16 16:35:38 -04:00
Donald Sharp
87472c6999 zebra: ret is always -1 or 0 at this point so remove the if test
Remove the if test and cleanup the code to better align.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-16 16:31:35 -04:00
Donald Sharp
c9af62e314 zebra: Add a configurable knob zebra nexthop-group keep (1-3600)
Allow end operator to set how long a nexthop-group is kept around
in the system after it is no-longer being used.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-16 14:47:19 -04:00
Donald Sharp
35729f38fa zebra: Add a timer to nexthop group deletion
Before deleting nexthop groups, that are installed,
from the system, start a timer and hold the nexthop
group for that time.

Suppose you have this scenario

a) create a static route with 1 x ecmp
      creates a nhg with 1 x ecmp
b) create a static route with 2 x ecmp
      creates a nhg with 2 x ecmp
      deletes a's nhg
c) create a static route with 3 x ecmp
      creates a nhg with 3 x ecmp
      deletes b's nhg
d) create a different route with 1 x ecmp
      creates another 1 x ecmp ( since a's ecmp was deleted )
e) create a different route with 2 x ecmp
      creates another 2 x ecmp ( since b's ecmp was deleted )

If you don't delete the nhg, start a timer, the nhg's used
in steps a and b can be reused for steps d and e.  This reduces
overhead work with zebra <-> kernel interactions and improves
the speed of the system.

So modify the code to note that an installed nexthop group should
be kept around a bit and hopefully reused.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-16 14:47:19 -04:00
Donald Sharp
382858d015 zebra: Move where zebra marks a nhg as uninstalled in fib
Currently the code is marking the nhg as uninstalled but not
causing that to flood up to the dependent nhgs:

nhg 3 is a group of 1/2
   1 -> interface A
   2 -> interface B

Suppose A goes down, old code would mark nhg 1 as !VALID and !INSTALLED.
Suppose B then goes down, old code would mark nhg 2 as !VALID and !INSTALLED
But would not mark nhg 3 as !VALID and !INSTALLED (sort of assuming that
it would just be cleaned up by NHG refcounts ).  I would prefer that
the code is pedantic about nhg 3 actually being removed from the system.

This code moves the setting of !INSTALLED into zebra_nhg.c where it
really belongs.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-16 14:47:19 -04:00
Donald Sharp
5772319ef1 zebra: Document some data structures better
I keep getting confused about nhg_depends and nhg_dependents.
So take a second and write them down for the next person.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-16 14:47:19 -04:00
Donatas Abraitis
7ea104c111
Merge pull request #11415 from donaldsharp/interface_duplication_linux
Interface duplication linux
2022-06-16 21:19:14 +03:00
anlan_cs
e3f05a8a1a zebra: adjust one variable name
Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-06-16 10:15:12 -04:00
Russ White
93ab9a2c0b
Merge pull request #11409 from donaldsharp/zebra_nhg_debug
Zebra nhg debug
2022-06-16 10:13:20 -04:00
Donald Sharp
8b9b1d6043 zebra: On linux let interface data come in through netlink messaging
Consolidate on linux to using the netlink api for gathering all data
about a interface.  Leave this interface alone in the meantime for
other OS's.

This also has the side effect of reducing the amount of work
being done on linux in that FRR was handling shut/no shut
events 2 times.  Once for the ioctl question asked and
once for the netlink message received.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-15 10:34:30 -04:00
Donald Sharp
7c4910cead zebra: Attempt to make ioctl.c have a bit more useful log messges
While examining the code, it was noticed that there was a chance
to improve the log output in some cases to give a fuller understanding
of what went wrong where.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-15 10:34:30 -04:00
Donald Sharp
d9db1a4092 zebra: stream_dup cannot fail
If stream_dup was unable to actually allocate memory
then FRR would crash instead.  So let's remove the
check for null since it is not needed.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-15 10:24:01 -04:00
Donald Sharp
68d188be7a zebra: Convert debugs to use %pNG
The nexthop group debugs were using %u to just display the id.
I found this very hard to figure out what was going on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-14 20:25:56 -04:00
Donald Sharp
cc75cbea1b zebra: Add %pNG to zebra print routines
Add `%pNG` so that a nexthop group can be displayed in debugs/logs
such that it can provide useful information.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-14 20:25:56 -04:00
Donald Sharp
f90391998c
Merge pull request #11229 from anlancs/fix/zebra-nb-remove-checknode
zebra: remove one unnecessary check for l3vni nb
2022-06-14 13:58:16 -04:00
Donatas Abraitis
70dd370f5a *: Use autocomplete for route-maps under commands that require it
For example:

```
donatas-laptop# show bgp ipv4 unicast neighbors 127.0.0.2 advertised-routes route-map ?
  RMAP_NAME  Name of the route map
       testas2 testas

donatas-laptop(config)# router bgp
donatas-laptop(config-router)# address-family ipv4
donatas-laptop(config-router-af)# redistribute connected route-map ?
  RMAP_NAME  Pointer to route-map entries
       testas2 testas

donatas-laptop(config-router-af)# network 192.168.0.0/23 route-map ?
  RMAP_NAME  Name of the route map
       testas2 testas
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-13 21:00:51 +03:00
Xiao Liang
5609e70fb8 lib, zebra, bgpd: Move route EVPN flag to nexthop
Multipath route may have mixed nexthops of EVPN and IP unicast. Move
EVPN flag to nexthop to support such cases.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
2022-06-10 17:12:48 +08:00
Chirag Shah
e5b1de8a11 zebra: add error check condition to sock option
Adding error checking condition which was missed
in PR-11216.

*** CID 1517953:  Error handling issues  (CHECKED_RETURN)
/zebra/kernel_netlink.c: 313 in netlink_socket()
307                     memset(&snl, 0, sizeof(snl));
308                     snl.nl_family = AF_NETLINK;
309                     snl.nl_groups = groups;
310
311     #if defined SOL_NETLINK
312                     if (ext_groups)
>>>     CID 1517953:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "setsockopt(sock, 270, 1, &ext_groups, 8U)" without checking return value. This library function may fail and return an error code.
313                             setsockopt(sock, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP,
314                                        &ext_groups, sizeof(ext_groups));
315     #endif
316
317                     /* Bind the socket to the netlink structure for anything. */
318                     ret = bind(sock, (struct sockaddr *)&snl, sizeof(snl));

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-05-31 13:50:48 -07: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
Philippe Guibert
c9250e28e8 zebra: avoid pbr iptable added twice when used with flowspec
The usage of zebra dplane makes the job asyncronous which implies
that a given job will try to add an iptable, while the second job
will not know that its iptable is the same as the former one.

The below exabgp rules stand for two bgp flowspec rules sent to
the bgp device:

flow {
route {match {
source 185.228.172.73/32;
destination 0.0.0.0/0;
source-port >=49156&<=49159;
}then {redirect 213.242.114.113;}}
route {match {
source 185.228.172.73/32;
destination 0.0.0.0/0;
source-port >=49160&<=49163;
}then {redirect 213.242.114.113;}}
}

This rule creates a single iptable, but in fact, the same iptable
name is appended twice. This results in duplicated entries in the
iptables context. This also results in contexts not flushed, when
BGP session or 'flush' operation is performed.

iptables-save:
[..]
-A PREROUTING -m set --match-set match0x55baf4c25cb0 src,src -g match0x55baf4c25cb0
-A PREROUTING -m set --match-set match0x55baf4c25cb0 src,src -g match0x55baf4c25cb0
-A match0x55baf4c25cb0 -j MARK --set-xmark 0x100/0xffffffff
-A match0x55baf4c25cb0 -j ACCEPT
-A match0x55baf4c25cb0 -j MARK --set-xmark 0x100/0xffffffff
-A match0x55baf4c25cb0 -j ACCEPT
[..]

This commit addresses this issue, by checking that an iptable
context is not already being processed. A flag is added in the
original iptable context, and a check is done if the iptable
context is not already being processed for install or uinstall.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-05-25 14:26:28 +02:00
Donatas Abraitis
4febdb6b9a
Merge pull request #10836 from anlancs/bgpd-mh-delay-esi
zebra: delay setting esi in zebra_evpn_local_es_update()
2022-05-23 07:49:08 +02:00
David Lamparter
7ca9c407ed zebra: clean up rtadv integration
Move a few things into places they actually belong, and reduce the
number of places we have `#ifdev HAVE_RTADV`.  Just overall code
prettification.

... I had actually done this quite a while ago while doing some other
random hacking and thought it more useful to not be sitting on it on my
disk...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-05-21 14:14:01 +02:00
anlan_cs
c331ef1665 zebra: remove one unnecessary check for l3vni nb
The parent node of "vrf"  MUST be non-NULL, so the check is unnecessary and
misleading. Otherwise, there will be a branch of NULL parent node, it makes
no sense, remove it.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-20 03:11:27 -04:00
Sri Mohana Singamsetty
bde51e807f
Merge pull request #11216 from chiragshah6/fdev2
zebra: netlink registry of rtm tunnel notification
2022-05-19 10:28:25 -07:00
Sri Mohana Singamsetty
0e6e6bc36e
Merge pull request #11222 from donaldsharp/bgp_zebra_stuff
Bgp zebra stuff
2022-05-19 09:41:41 -07: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
Donald Sharp
1b3cf91b0c zebra: Fix newline in log message
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-18 14:42:22 -04:00
Russ White
c1e2a1eae3
Merge pull request #11205 from chiragshah6/fdev1
zebra: new netlink parse utility for rta used to send nhg msg
2022-05-18 11:13:22 -04:00
Chirag Shah
42ed3bd77f zebra: add netlink tunnel msg to dump routine
This patch parses vxlan vnifilter rtm tunnel
message which contains vni mapping to vxlan device.
The new notifications are RTM_NEWTUNNEL,
RTM_DELTUNNEL, and RTM_GETTUNNEL.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/
linux.git/commit/?h=v5.18-rc7&id=7b8135f4df98b155b23754b6065c157861e268f1

Testing Done:

2022/05/18 00:34:25 ZEBRA: netlink_recv_msg: << netlink message dump
[recv]
2022/05/18 00:34:25 ZEBRA: nlmsghdr [len=36 type=(120) NEWTUNNEL
flags=(0x0000) {} seq=0 pid=0]
2022/05/18 00:34:25 ZEBRA:   tnlm [family=(7) AF_BRIDGE ifindex=46
2022/05/18 00:34:25 ZEBRA:   vni_start 4001, vni_end 0

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-05-18 07:56:44 -07:00
Chirag Shah
47e2eb270d zebra: netlink registry rtm tunnel notif
The kernel supports l3vxlan device to have (l3vni)
vni filter similar to vlan filtering on bridge device.

To receive netlink notification, FRR to register
for new netlink RTNLGRP_TUNNEL message.
This message required to register via additional
socket option as it's beyond bitmap size.

kernel patches:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/
linux.git/commit/?h=v5.18-rc7&id=7b8135f4df98b155b23754b6065c157861e268f1

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/
linux.git/commit/?h=v5.18-rc7&id=f9c4bb0b245cee35ef66f75bf409c9573d934cf9

Ticket:#3073812
Testing Done:

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-05-18 07:56:35 -07:00
Mark Stapp
6ca1b0f44e
Merge pull request #11192 from cyberstorm-mauritius/zebra_netlink
zebra: Add startup message and display netlink buffer size.
2022-05-17 08:13:23 -04:00
Chirag Shah
f8f3e484d4 zebra: new netlink parse utility for rta
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-05-16 10:45:14 -07:00
Chirag Shah
865c12e1a7 zebra: add protocol name to nexthop dump
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-05-16 08:40:19 -07:00
anlan_cs
0dfc0dd974 zebra: delay setting esi in zebra_evpn_local_es_update()
Currently, `zif->es_info.esi` is always set even for a few unnecessary
cases in `zebra_evpn_local_es_update()`.

Delay setting `zif->es_info.esi` and remove the annoying rollback
(i.e. unset `zif->es_info.esi`) operation on failure case.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-16 09:40:49 -04: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
Donald Sharp
950e7e6660
Merge pull request #11207 from anlancs/fix/zebra-remove-check-l3vni
zebra: remove unncecessary check for l3vni
2022-05-16 08:02:58 -04:00
Rafael Zalamena
854dea850c
Merge pull request #11199 from donaldsharp/nexthop_dump
zebra: Add encap and group type decoding to nexthop dump
2022-05-16 08:09:54 -03: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
Donatas Abraitis
8f5e706a2f
Merge pull request #11201 from donaldsharp/unused_in_netlink_compiles
Remove some unused functions in zebra
2022-05-16 09:57:30 +03: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
Donald Sharp
20ceb5475d zebra: Remove unused function route_entry_copy_nexthops
This function is no longer used.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-13 16:11:09 -04:00
Donald Sharp
388907d53c zebra: Remove unused functions in netlink compiles
When compiling with netlink,  Remove the usage of these
functions.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-13 15:58:33 -04:00
Donald Sharp
c30c607027 zebra: Add encap and group type decoding to nexthop dump
Add the ability to give data about the nexthop group type
and encap type so that it is human readable.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-13 10:37:30 -04:00
Donald Sharp
f205a2309c
Merge pull request #11177 from opensourcerouting/fix/memset_memcpy
*: memcpy/memset zeroing
2022-05-13 07:40:58 -04:00
Loganaden Velvindron
0c99696f30 zebra: Add startup message and display netlink buffer size.
Add startup message and display netlink buffer size.

Signed-off-by: Loganaden Velvindron <logan@cyberstorm.mu>
2022-05-13 14:58:18 +04:00
Donatas Abraitis
4d5a0ff391
Merge pull request #11186 from anlancs/fix/bgpd-comment-should-es
bgpd,zebra: correct one debug log for evpn-mh
2022-05-12 11:32:25 +03:00
anlan_cs
b0b9a2fe52 bgpd,zebra: correct one debug log for evpn-mh
Correct one debug log in evpn-mh.
BTW, correct one misspelled word in comment.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-12 02:19:51 -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
Mark Stapp
00358e444e
Merge pull request #11155 from LabNConsulting/ziemba/link-delay-min-max
zebra bugfix interface link-param: allow delay min <= avg <= max (was: min<avg<max)
2022-05-10 11:31:52 -04:00
Igor Ryzhov
2a3807c3ce
Merge pull request #11163 from opensourcerouting/fix/same_type_casting
*: Avoid casting to the same type as on the left
2022-05-10 00:16:30 +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
Donatas Abraitis
432ee88c21 zebra, ospf6d: Do not check if NULL for XCALLOC()
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-08 15:43:21 +03:00
G. Paul Ziemba
d029fe275c zebra/interface.c: allow link-param delay min <= avg <= max
RFC 7471 Section 4.2.7:
	It is possible for min delay and max delay to be the same value.

    Prior to this change, the code required min < avg < max. This
    change allows min == avg and avg == max.

    test case:

    interface eth-rt1
      link-params
        delay 8000 min 8000 max 8000

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2022-05-06 14:48:31 -07:00
Donatas Abraitis
50f1f2e724
Merge pull request #11059 from anlancs/fix/bgpd-evnp-wrong-check-hashget
bgpd: fix memory leak for evpn
2022-05-04 21:19:51 +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
Rafael Zalamena
3682bd90f3 *: use FRR interface name definition everywhere
Don't rely on the OS interface name length definition and use the FRR
definition instead.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-05-02 13:00:12 -03:00
David Lamparter
46a3bfa695
Merge pull request #10988 from AbhishekNR/ipv6_mroute_cli 2022-04-29 10:23:37 +02:00
mobash-rasool
c4aa8aa669
Merge pull request #11114 from opensourcerouting/vrf-declvar-macros
lib, zebra, pimd: clean up/fix VRF DECLVAR macros
2022-04-29 13:53:08 +05:30
David Lamparter
0cbed9511a lib, zebra, pimd: clean up/fix VRF DECLVAR macros
There's a common pattern of "get VRF context for CLI node" here, which
first got a helper macro in zebra that then permeated into pimd.

Unfortunately the pimd copy wasn't quite adjusted correctly and thus
caused two coverity warnings (CID 1517453, CID 1517454).

Fix the PIM one, and clean up by providing a common base macro in
`lib/vty.h`.

Also rename the macros (add `_VRF`) to make more clear what they do.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-28 11:09:26 +02:00
Abhishek N R
1d06e3547a zebra: Removed show_ipv6_mroute cli from zebra_vty.c
Signed-off-by: Abhishek N R <abnr@vmware.com>
2022-04-28 01:43:19 -07:00
Mobashshera Rasool
51f4fd9810 zebra, pimd: Add a field family in the message ZEBRA_IPMR_ROUTE_STATS
1. Adding a field family in the existing ZEBRA_IPMR_ROUTE_STATS
to get the ipv4 as well as ipv6 trafic stats between pim and zebra.
2. Modify the debug to print both v4/v6 prefixes

pimd: pim6d: Modify pim_zlookup_sg_statistics to get ipv6 stats

Modify the pim_zlookup_sg_statistics api to
get ipv4/ipv6 stats from zebra. Making the api
common.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-04-28 01:10:49 -07:00
Mobashshera Rasool
4d3b4b1851 zebra: Modify base code to get ipv6 stats from kernel
Modify the structure mcast_route_data to store ipv4/ipv6
addr and lastused multicast information from kernel.
Adjust the related APIs to parse ipv4/ipv6 informations.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-04-28 01:10:49 -07:00
David Lamparter
34ee41c6c9 zebra, pimd: add AF param on NEXTHOP_LOOKUP_MRIB
By changing this API call to use a `struct ipaddr`, which encodes the
type of IP address with it.  (And rename/remove the `IPV4` from the
command name.)

Also add a comment explaining that this function call is going to be
obsolete in the long run since pimd needs to move to proper MRIB NHT.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-26 16:15:00 +02:00
David Lamparter
425fd200c9 zebra: add rib_match_ipv6_multicast variant
... for IPv6, analogous to v4.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-26 16:15:00 +02:00
Donald Sharp
0bba3bd873 zebra: Name variable better in zebra_trace.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-20 09:49:36 -04:00
Donald Sharp
1239b60c06 zebra: Add tracepoint for netlink_rule_change
Add a tracepoint for the netlink_rule_change function.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-20 09:43:47 -04:00
Donald Sharp
3cee213500 zebra: Add tracepoint for netlink_route_change_read_unicast
Add a tracepoint to zebra for the netlink_route_change_read_unicast
functionality.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-20 09:43:47 -04:00
Donald Sharp
14ed061501 zebra: Add netlink_interface_addr tracepoint
Add a tracepoint for netlink_interface_addr.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-20 09:43:47 -04:00
Donald Sharp
1d80c20919 zebra: Add netlink_nexthop_change tracepoint
Add a tracepoint for the netlink_nexthop_change function.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-20 09:43:47 -04:00
Donald Sharp
097ef2afd1 zebra: Add netlink_request_intf_addr tracepoint
Add a tracepoint for the netlink_request_intf_addr function.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-20 09:43:47 -04:00
Donald Sharp
d42e61420a zebra: Add initial zebra tracepoint support
Add initial zebra tracepoint support infrastructure
as well as add a frr_zebra:netlink_interface
callback.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-20 09:39:47 -04:00
Donald Sharp
a71e190d44
Merge pull request #10961 from opensourcerouting/build-ms-ext
build: enable `-fms-extensions`
2022-04-20 07:51:45 -04:00
Donatas Abraitis
3d3c38b1d4
Merge pull request #11051 from donaldsharp/speell_more
Speell more
2022-04-20 11:04:14 +03:00
mobash-rasool
1815b8f335
Merge pull request #11045 from anlancs/fix/bgpd-cleanup-8-remove
zebra: cleanup duplicated "extern"s for evpn-mh
2022-04-20 13:28:17 +05:30
Volodymyr Huti
7fb9825cf7 zebra: set ZEBRA_IFC_DOWN on connected routes for inactive interfaces
If you are in a situation where you have multiple addresses on an
interface, zebra creates one connected route for them.
The issue is that the rib entry is not created if addresses were
added before the interface was running.

We add the address to a running interface in a typical flow.
Therefore, we handle the route & rib creation within a single ADD event.
In the opposite case, we create the route entries without activating them.
These are considered to be active since ZEBRA_IFC_DOWN is not set.
On the following interface UP, we ignore the same ADDR_ADD as it overlaps
with the existing prefixes -> rib is never created.

The minimal reproducible setup:
-----------------------------------------
ip link add name dummy0 type dummy
ip addr flush dev dummy0
ip link set dummy0 down
ip addr add 192.168.1.7/24 dev dummy0
ip addr add 192.168.1.8/24 dev dummy0
ip link set dummy0 up
vtysh -c 'show ip route' | grep dummy0

Signed-off-by: Volodymyr Huti <v.huti@vyos.io>
2022-04-19 22:53:57 +03:00
mobash-rasool
16b5065b47
Merge pull request #10908 from donaldsharp/proto_only_error
zebra: When `zebra nexthop proto only` limit errors
2022-04-19 21:27:29 +05:30
Donald Sharp
4667220e3a *: Fix spelling of accidently
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:31:30 -04:00
Donald Sharp
f526739897 *: Fix spelling of accomodate
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:29:58 -04:00
Donald Sharp
3819e4ced7 *: Fix spelling of inteface
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:21:31 -04:00
Donatas Abraitis
f5327fc339
Merge pull request #11012 from anlancs/bgpd-mh-simplify-condition
zebra: simplify one check for evpn-mh
2022-04-19 13:04:43 +03:00
anlan_cs
4e5bda347c zebra: cleanup duplicated "extern"s for evpn-mh
There are some duplicated `extern`s in this header
file, just remove them.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-04-19 05:20:10 -04:00
Russ White
1258cfcd8c
Merge pull request #11001 from donaldsharp/system_route_recursion
zebra: Allow system routes to recurse through themselves
2022-04-18 09:47:47 -04:00
Donald Sharp
1cadfaf213 zebra: When zebra nexthop proto only limit errors
Operators are seeing:

Mar 28 07:19:37 kingpin zebra[418]: [TZANK-DEMSE] netlink_nexthop_msg_encode: nhg_id 68 (zebra): proto-based nexthops only, ignoring
Mar 28 07:19:37 kingpin zebra[418]: [TZANK-DEMSE] netlink_nexthop_msg_encode: nhg_id 68 (zebra): proto-based nexthops only, ignoring
Mar 28 07:19:37 kingpin zebra[418]: [YXPF5-B2CE0] netlink_route_multipath_msg_encode: RTM_DELROUTE 2804:4d48:4000::/42 vrf 0(254)
Mar 28 07:19:37 kingpin zebra[418]: [YXPF5-B2CE0] netlink_route_multipath_msg_encode: RTM_NEWROUTE 2804:4d48:4000::/42 vrf 0(254)
Mar 28 07:19:37 kingpin zebra[418]: [TVM3E-A8ZAG] _netlink_route_build_singlepath: (single-path): 2804:4d48:4000::/42 nexthop via fe80::b6fb:e4ff:fe26:c5d5  if 2 vrf default(0)
Mar 28 07:19:37 kingpin zebra[418]: [HYEHE-CQZ9G] nl_batch_send: netlink-dp (NS 0), batch size=140, msg cnt=2
Mar 28 07:19:37 kingpin zebra[418]: [P2XBZ-RAFQ5][EC 4043309074] Failed to install Nexthop ID (68) into the kernel

When `zebra nexthop proto only` is turned on.

Effectively zebra intentionally does not do the nexthop group installation
and the dplane notification in zebra_nhg.c just assumes it was a failure
and prints an error message.  Since this act was intentional, let's
just notice that it was intentional and not report the message
as a failure.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-18 09:41:38 -04:00
Donatas Abraitis
cd876f8a78
Merge pull request #10935 from anlancs/zebra-mh-esi-warning
zebra: adjust the warnings for ESI of evpn-mh
2022-04-13 15:45:07 +03:00
anlan_cs
9a8fc8f88d zebra: simplify one check for evpn-mh
An simplification for one check in
`zebra_evpn_mh_uplink_oper_flags_update()`.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-04-12 01:26:54 -04:00
Donald Sharp
c9e4abf81f zebra: Allow system routes to recurse through themselves
Currently if a end user has something like this:

Routing entry for 192.168.212.1/32
  Known via "kernel", distance 0, metric 100, best
  Last update 00:07:50 ago
  * directly connected, ens5

Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

K>* 0.0.0.0/0 [0/100] via 192.168.212.1, ens5, src 192.168.212.19, 00:00:15
C>* 192.168.212.0/27 is directly connected, ens5, 00:07:50
K>* 192.168.212.1/32 [0/100] is directly connected, ens5, 00:07:50

And FRR does a link flap, it refigures the route and rejects the default
route:

2022/04/09 16:38:20 ZEBRA: [NZNZ4-7P54Y] default(0:254):0.0.0.0/0: Processing rn 0x56224dbb5b00
2022/04/09 16:38:20 ZEBRA: [ZJVZ4-XEGPF] default(0:254):0.0.0.0/0: Examine re 0x56224dbddc20 (kernel) status: Changed Installed flags: Selected dist 0 metric 100
2022/04/09 16:38:20 ZEBRA: [GG8QH-195KE] nexthop_active_update: re 0x56224dbddc20 nhe 0x56224dbdd950 (7), curr_nhe 0x56224dedb550
2022/04/09 16:38:20 ZEBRA: [T9JWA-N8HM5] nexthop_active_check: re 0x56224dbddc20, nexthop 192.168.212.1, via ens5
2022/04/09 16:38:20 ZEBRA: [M7EN1-55BTH]         nexthop_active: Route Type kernel has not turned on recursion
2022/04/09 16:38:20 ZEBRA: [HJ48M-MB610]         nexthop_active_check: Unable to find active nexthop
2022/04/09 16:38:20 ZEBRA: [JPJF4-TGCY5] default(0:254):0.0.0.0/0: After processing: old_selected 0x56224dbddc20 new_selected 0x0 old_fib 0x56224dbddc20 new_fib 0x0

So the 192.168.212.1 route is matched for the nexthop but it is not connected and
zebra treats it as a problem.  Modify the code such that if a system route
matches through another system route, then it should work imo.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-09 13:17:14 -04:00
Donald Sharp
48dc861028 zebra: Allow multiple connected routes to be choosen for kernel routes
This bug should only really affect kernel routes.  To reproduce:

a) Have multiple connected routes that point to the same prefix
swp8  up      default         169.254.0.250/30
swp9  up      default         169.254.0.250/30

b) Have a kernel route that uses one of those connected routes
7.6.2.8 via 169.254.0.249 dev swp8 proto static
(But have it choose a non-selected connected nexthop)

c) Introduce an event that causes the rib table to be reprocessed,
say a unrelated interface going up / down

  This causes the route to be lost with this message:
2022/03/28 21:21:53 ZEBRA: [YXCJP-0WZWV] netlink_nexthop_msg_encode: ID (3454): 169.254.0.249, via swp8(1383) vrf default(0)
2022/03/28 21:21:53 ZEBRA: [YF2E6-J60JH] nexthop_active: 169.254.0.249, via swp8 given ifindex does not match nexthops ifindex found found: directly connected, swp9

Effectively the nexthop that zebra is choosing would not be the one
that the kernel route has choosen and FRR removes the route:
022/03/28 21:21:53 ZEBRA: [NM15X-X83N9] rib_process: (0:254):7.6.2.8/32: rn 0x56042e632e90, removing re 0x56042e6316e0
2022/03/28 21:21:53 ZEBRA: [Y53JX-CBC5H] rib_unlink: (0:254):7.6.2.8/32: rn 0x56042e632e90, re 0x56042e6316e0
2022/03/28 21:21:53 ZEBRA: [KT8QQ-45WQ0] rib_gc_dest: (0:?):7.6.2.8/32: removing dest from table

What is happening?

Zebra is not looking at all connected routes and if any of them
would have the appropriate ifindex and just blindly rejecting
the route.

So when nexthop resolution happens and it matches a connected
route and the dest->selected nexthop ifindex does not match, let's sort
through the rest of them and see if any of them match and if so
let's keep the route.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-08 08:15:20 -04: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
Russ White
977405eeac
Merge pull request #10938 from anlancs/fix-zebra-vxlan-change-vrfid
zebra: fix missing vrf change of l2vni on vxlan interface
2022-04-05 08:55:42 -04:00
David Lamparter
5b4f4e626f build: first header *must* be zebra.h or config.h
This has already been a requirement for Solaris, it is still a
requirement for some of the autoconf feature checks to work correctly,
and it will be a requirement for `-fms-extensions`.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-04 18:33:10 +02:00
Donald Sharp
07b12758be pimd, zebra: Fix spelling of fowarding
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-02 07:46:19 -04:00
Donald Sharp
17be83bf99 *: Fix spelling of Gracefull
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-02 07:46:19 -04:00
anlan_cs
21311bc8a0 zebra: add whitespace after "%%" for prompt
Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-04-01 03:27:20 -04:00
anlan_cs
2e39ebbb09 zebra: adjust the warnings for ESI of evpn-mh
Since there are two kinds of ESI (Type-0 and Type-3), the warnings
should distinguish between the two cases.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-04-01 03:00:11 -04:00
Trey Aspelund
436a6a3e51 zebra: don't send RAs w/o LLv6 or on bridge-ports
It's confusing for a user to see 'Tx RA failed' in the logs when
they've enabled RAs (either through interface config or BGP unnumbered)
on an interface that can't send them.  Let's avoid sending RAs on
interfaces that are bridge_slaves or don't have a link-local address,
since they are the two of the most common reasons for RA Tx failures.

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2022-03-31 16:38:37 +00: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
2be18df4dc zebra: remove unnecessary check for parsing macfdb
Since `NDA_VLAN` is no longer mannually defined in header file,
the check for `NDA_VLAN` should be removed.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-03-30 05:50:21 -04:00
Donatas Abraitis
11fc3db305
Merge pull request #10902 from bobuhiro11/fix_zebra_srv6_func_bits
zebra: fix doc and default value of "func-bits" for SRv6
2022-03-30 10:20:36 +03: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
Donald Sharp
80e39114b5
Merge pull request #10897 from opensourcerouting/safi-nht
zebra,staticd,*: SAFI_MULTICAST NHT groundwork
2022-03-28 08:23:36 -04:00
Nobuhiro MIKI
fbd01eaa41 zebra: output optional param "func-bits" for SRv6
Signed-off-by: Nobuhiro MIKI <nmiki@yahoo-corp.jp>
2022-03-28 17:37:45 +09:00
David Lamparter
7d08e1e31c zebra: add a few const in RNH code
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-27 14:57:22 +02:00
David Lamparter
6c90403bb1 zebra: show ip nht mrib
Prints the SAFI_MULTICAST NHT state in zebra.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-27 14:57:18 +02:00
David Lamparter
e9ac2861e5 zebra: register NHT nexthops with proper SAFI
Just a small puzzle piece missing in zebra SAFI NHT support.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-27 14:51:00 +02:00
David Lamparter
bc9b1cbfae zebra: check other SAFIs when removing gone client
When a client disconnects, we need to check & remove NHT entries for
other SAFIs too.  Otherwise we crash later trying to access stale data.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-27 14:51:00 +02:00
Donald Sharp
2f71996a68 zebra: Note when the netlink DUMP command is interrupted
There exists code paths in the linux kernel where a dump command
will be interrupted( I am not sure I understand what this really
means ) and the data sent back from the kernel is wrong or incomplete.

At this point in time I am not 100% certain what should be done, but
let's start noticing that this has happened so we can formulate a plan
or allow the end operator to know bad stuff is a foot at the circle K.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-25 19:08:14 -04:00
Donald Sharp
a5f711a11a
Merge pull request #10862 from anlancs/zebra-mh-svi-add
zebra: optimization on the mac addition for evpn-mh
2022-03-25 10:09:59 -04:00
David Lamparter
619a6623cb
Merge pull request #10867 from donaldsharp/ifp_use_after_free 2022-03-25 06:55:37 +01:00
David Lamparter
f908faed4a
Merge pull request #10866 from donaldsharp/freebsd_unknown_type2str 2022-03-25 04:20:19 +01:00
Donald Sharp
d0438da6b0 zebra: Fix use after deletion event in freebsd
In the FreeBSD code if you delete the interface
and it has no configuration, the ifp pointer will
be deleted from the system *but* zebra continues
to dereference the just freed pointer.

==58624== Invalid read of size 1
==58624==    at 0x48539F3: strlcpy (in /usr/local/libexec/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==58624==    by 0x2B0565: ifreq_set_name (ioctl.c:48)
==58624==    by 0x2B0565: if_get_flags (ioctl.c:416)
==58624==    by 0x2B2D9E: ifan_read (kernel_socket.c:455)
==58624==    by 0x2B2D9E: kernel_read (kernel_socket.c:1403)
==58624==    by 0x499F46E: thread_call (thread.c:2002)
==58624==    by 0x495D2B7: frr_run (libfrr.c:1196)
==58624==    by 0x2B40B8: main (main.c:471)
==58624==  Address 0x6baa7f0 is 64 bytes inside a block of size 432 free'd
==58624==    at 0x484ECDC: free (in /usr/local/libexec/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==58624==    by 0x4953A64: if_delete (if.c:283)
==58624==    by 0x2A93C1: if_delete_update (interface.c:874)
==58624==    by 0x2B2DF3: ifan_read (kernel_socket.c:453)
==58624==    by 0x2B2DF3: kernel_read (kernel_socket.c:1403)
==58624==    by 0x499F46E: thread_call (thread.c:2002)
==58624==    by 0x495D2B7: frr_run (libfrr.c:1196)
==58624==    by 0x2B40B8: main (main.c:471)
==58624==  Block was alloc'd at
==58624==    at 0x4851381: calloc (in /usr/local/libexec/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==58624==    by 0x496A022: qcalloc (memory.c:116)
==58624==    by 0x49546BC: if_new (if.c:164)
==58624==    by 0x49546BC: if_create_name (if.c:218)
==58624==    by 0x49546BC: if_get_by_name (if.c:603)
==58624==    by 0x2B1295: ifm_read (kernel_socket.c:628)
==58624==    by 0x2A7FB6: interface_list (if_sysctl.c:129)
==58624==    by 0x2E99C8: zebra_ns_enable (zebra_ns.c:127)
==58624==    by 0x2E99C8: zebra_ns_init (zebra_ns.c:214)
==58624==    by 0x2B3FF2: main (main.c:401)
==58624==

Zebra needs to pass back whether or not the ifp pointer
was freed when if_delete_update is called and it should
then check in ifan_read as well as ifm_read that the
ifp pointer is still valid for use.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-24 20:48:24 -04:00
Donald Sharp
0081ab91e6 zebra: When handling unprocessed messages from kernel print usable string
Add new debug output to show the string of the message type that
is currently unhandled:

2022-03-24 18:30:15.284 [DEBG] zebra: [V3NSB-BPKBD] Kernel:
2022-03-24 18:30:15.284 [DEBG] zebra: [HDTM1-ENZNM] Kernel: message seq 792
2022-03-24 18:30:15.284 [DEBG] zebra: [MJD4M-0AAAR] Kernel: pid 594488, rtm_addrs {DST,GENMASK}
2022-03-24 18:30:15.285 [DEBG] zebra: [GRDRZ-0N92S] Unprocessed RTM_type: RTM_NEWMADDR(d)

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-24 20:07:00 -04:00
Donald Sharp
ceacdc7216 zebra: Don't send uninited data to kernel on FreeBSD
When running zebra w/ valgrind, it was noticed that there
was a bunch of passing uninitialized data to the kernel:

==38194== Syscall param ioctl(generic) points to uninitialised byte(s)
==38194==    at 0x4CDF88A: ioctl (in /lib/libc.so.7)
==38194==    by 0x49A4031: vrf_ioctl (vrf.c:860)
==38194==    by 0x2AFE29: vrf_if_ioctl (ioctl.c:91)
==38194==    by 0x2AFF39: if_get_mtu (ioctl.c:161)
==38194==    by 0x2B12C3: ifm_read (kernel_socket.c:653)
==38194==    by 0x2A7F76: interface_list (if_sysctl.c:129)
==38194==    by 0x2E9958: zebra_ns_enable (zebra_ns.c:127)
==38194==    by 0x2E9958: zebra_ns_init (zebra_ns.c:214)
==38194==    by 0x2B3F82: main (main.c:401)
==38194==  Address 0x7fc000967 is on thread 1's stack
==38194==  in frame #3, created by if_get_mtu (ioctl.c:155)
==38194==
==38194== Syscall param ioctl(generic) points to uninitialised byte(s)
==38194==    at 0x4CDF88A: ioctl (in /lib/libc.so.7)
==38194==    by 0x49A4031: vrf_ioctl (vrf.c:860)
==38194==    by 0x2AFE29: vrf_if_ioctl (ioctl.c:91)
==38194==    by 0x2AFED9: if_get_metric (ioctl.c:143)
==38194==    by 0x2B12CB: ifm_read (kernel_socket.c:655)
==38194==    by 0x2A7F76: interface_list (if_sysctl.c:129)
==38194==    by 0x2E9958: zebra_ns_enable (zebra_ns.c:127)
==38194==    by 0x2E9958: zebra_ns_init (zebra_ns.c:214)
==38194==    by 0x2B3F82: main (main.c:401)
==38194==  Address 0x7fc000967 is on thread 1's stack
==38194==  in frame #3, created by if_get_metric (ioctl.c:137)
==38194==
==38194== Syscall param ioctl(generic) points to uninitialised byte(s)
==38194==    at 0x4CDF88A: ioctl (in /lib/libc.so.7)
==38194==    by 0x49A4031: vrf_ioctl (vrf.c:860)
==38194==    by 0x2AFE29: vrf_if_ioctl (ioctl.c:91)
==38194==    by 0x2B052D: if_get_flags (ioctl.c:419)
==38194==    by 0x2B1CF1: ifam_read (kernel_socket.c:930)
==38194==    by 0x2A7F57: interface_list (if_sysctl.c:132)
==38194==    by 0x2E9958: zebra_ns_enable (zebra_ns.c:127)
==38194==    by 0x2E9958: zebra_ns_init (zebra_ns.c:214)
==38194==    by 0x2B3F82: main (main.c:401)
==38194==  Address 0x7fc000707 is on thread 1's stack
==38194==  in frame #3, created by if_get_flags (ioctl.c:411)

Valgrind is no longer reporting these issues.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-24 12:57:01 -04:00
anlan_cs
b83d220aa9 zebra: optimization on the mac addition for evpn-mh
When `zebra_evpn_mac_svi_add()` adds one found mac by
`zebra_evpn_mac_lookup()` and the found mac is without
svi flag, then call `zebra_evpn_mac_svi_add()` to create
one appropriate mac, but it will call `zebra_evpn_mac_lookup()`
the second time. So lookup twice, the procedure is redundant.

Just an optimization for it, make sure only lookup once.

Modify `zebra_evpn_mac_gw_macip_add()` to check the `macp`
parameter passed by caller, so it can distinguish whether
really need lookup or not.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-03-24 22:31:50 +08: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
Donatas Abraitis
ecf0ea4b00
Merge pull request #9953 from donaldsharp/system_route_replace
zebra: Better handle replacing our route by a system route
2022-03-20 23:25:52 +02:00
Donald Sharp
0399a608e0
Merge pull request #10830 from anlancs/zebra-rb-remove
zebra, bgpd: remove check returning value of RB_INSERT()
2022-03-20 14:32:49 -04:00
Donald Sharp
f2f2a16af4 zebra: Do not complain if deletion fails
When issuing a RTM_DELETE operation and the kernel tells
us that the route is already deleted, let's not complain
about the situation:

2022/03/19 02:40:34 ZEBRA: [EC 100663303] kernel_rtm: 2a10:cc42:1d51::/48: rtm_write() unexpectedly returned -4 for command RTM_DELETE

I can recreate this issue on freebsd by doing this:
a) create a route using sharpd
b) shutdown the nexthop's interface
c) remove the route using sharpd

This would also be true of pretty much any routing protocol's behavior.
Let's just not complain about the situation if a RTM_DELETE
operation is issued and FRR is told that the route does not
exist to delete.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-19 07:44:54 -04:00
anlan_cs
2a778afe9d zebra: remove check returning value of RB_INSERT()
Since the `RB_INSERT()` is called after not found in RB tree, it MUST be ok and
and return zero. The check of returning value of `RB_INSERT()` is redundant,
just remove them.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-03-19 13:45:14 +08:00
Jafar Al-Gharaibeh
d6d0d718b0
Merge pull request #10806 from donaldsharp/dplane_fixup_for_lua
zebra: Fixup lua with new dplane ops
2022-03-16 16:38:01 -05:00
Donald Sharp
60cd8d3b14
Merge pull request #10790 from anlancs/zebra-adjust-flag
zebra: minor changes on "zebra_evpn_mac_gw_macip_add" function
2022-03-16 16:25:24 -04:00
Donald Sharp
105271792d zebra: Fixup lua with new dplane ops
Commit: 5d41413833 added 3 new dplane ops:

DPLANE_OP_INTF_INSTALL
DPLANE_OP_INTF_UPDATE
DPLANE_OP_INTF_DELETE

The build system does not build lua so zebra_script.c
was not updated.  Update of course!

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-16 15:10:54 -04:00
Russ White
5d97021ba3
Merge pull request #10427 from sworleys/Protodown-Reason-Upstream
Add Support for Setting Protodown Reason Code
2022-03-15 19:58:16 -04: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
2ea93eb023
Merge pull request #10580 from leonshaw/fix/link-ns
zebra: Lookup linked interface in link netns
2022-03-15 15:23:18 -04: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
Donald Sharp
6c72dd869e
Merge pull request #10725 from opensourcerouting/zebra-fpm-crash-fix
zebra: don't enqueue data with FPM socket closed
2022-03-14 08:27:10 -04:00
Donatas Abraitis
a9321141fc
Merge pull request #10731 from donaldsharp/multipath_output_in_zebra
zebra: Multipath output
2022-03-14 13:38:08 +02:00
Rafael Zalamena
3b1caddd34 zebra: don't enqueue data with FPM socket closed
It will trigger an assert while trying to schedule the next write.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-03-14 07:14:36 -03:00
Donald Sharp
7547d5288e
Merge pull request #10704 from anlancs/zebra-remove-check
zebra: Remove unnecessary check
2022-03-13 10:17:13 -04:00
Donald Sharp
b74f72c1fb zebra: prefixlen is not afi/safi dependant in encoding nexthops
When encoding a response to the upper level protocol the
prefixlen is not something that needs to be part of the
switch statement for handling of a prefix.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-12 11:18:45 -05:00
Donald Sharp
06e4e90132 *: When matching against a nexthop send and process what it matched against
Currently the nexthop tracking code is only sending to the requestor
what it was requested to match against.  When the nexthop tracking
code was simplified to not need an import check and a nexthop check
in b8210849b8 for bgpd.  It was not
noticed that a longer prefix could match but it would be seen
as a match because FRR was not sending up both the resolved
route prefix and the route FRR was asked to match against.

This code change causes the nexthop tracking code to pass
back up the matched requested route (so that the calling
protocol can figure out which one it is being told about )
as well as the actual prefix that was matched to.

Fixes: #10766
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-12 11:18:45 -05:00