Commit Graph

634 Commits

Author SHA1 Message Date
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
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
d4000d7ba3 zebra: Remove struct nlsock from dataplane information and use int fd
Store the fd that corresponds to the appropriate `struct nlsock` and pass
that around in the dplane context instead of the pointer to the nlsock.
Modify the kernel_netlink.c code to store in a hash the `struct nlsock`
with the socket fd as the key.

Why do this?  The dataplane context is used to pass around the `struct nlsock`
but the zebra code has a bug where the received buffer for kernel netlink
messages from the kernel is not big enough.  So we need to dynamically
grow the receive buffer per socket, instead of having a non-dynamic buffer
that we read into.  By passing around the fd we can look up the `struct nlsock`
that will soon have the associated buffer and not have to worry about `const`
issues that will arise.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-08 17:28:19 -05:00
Russ White
1a8a7016a6
Merge pull request #9066 from donaldsharp/ships_in_the_night
zebra: Fix ships in the night issue
2022-02-08 14:41:01 -05:00
Russ White
e735c8073c
Merge pull request #9649 from proelbtn/add-support-for-end-dt4
add support for SRv6 IPv4 L3VPN
2022-02-08 08:30:02 -05:00
Donald Sharp
c6eee91f66 zebra: Fix ships in the night issue
When using wait for install there exists situations where
zebra will issue several route change operations to the kernel
but end up in a state where we shouldn't be at the end
due to extra data being received.  Example:

a) zebra receives from bgp a route change, installs sends the
route to the kernel.
b) zebra receives a route deletion from bgp, removes the
struct route entry and then sends to the kernel a deletion.
c) zebra receives an asynchronous notification that (a) succeeded
but we treat this as a new route.

This is the ships in the night problem.  In this case if we receive
notification from the kernel about a route that we know nothing
about and we are not in startup and we are doing asic offload
then we can ignore this update.

Ticket: #2563300
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-07 16:10:03 -05:00
Donald Sharp
090ee85656 zebra: Add kernel nexthop group support to show zebra
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-04 10:29:38 -05:00
Donald Sharp
6b390b3c7b zebra: Better handle replacing our route by a system route
When a operator has a FRR based route installed into the
FIB and a better route comes in from the system.  There
is code in the data plane to schedule the batching
and continue processing.  But in this case we are done
so we can just return

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-26 10:26:46 -05: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
Ryoga Saito
7eab60a793 zebra: add support for End.DT4
This patch enables zebra to insert End.DT4 nexthop into linux kernel.

Signed-off-by: Ryoga Saito <ryoga.saito@linecorp.com>
2021-11-22 23:32:30 +09:00
Donald Sharp
6e1e2e8da9 zebra: Fix netlink RTM_NEWNEXTHOP parsing for nested attributes
With the addition of resillient hashing for nexthops, the
parsing of nexthops requires telling the decoder functions
that there may be nested attributes.  This was found by
code inspection of iproute2/ipnexthop.c when trying to
understand resillient hashing as well as statistics
gathering for nexthops that are / will be in upstream
kernels in the near future.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-10-28 08:10:28 -04:00
Donald Sharp
ba3df8987f
Merge pull request #9686 from idryzhov/fix-nda-lladdr
zebra: fix buffer overflow
2021-10-12 12:04:00 -04:00
Donald Sharp
9bfadae860 zebra: Use a bool for startup indications
Let's not pass around an int startup when all we are doing
is true/falsing it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-10-04 20:26:38 -04:00
Igor Ryzhov
b7c21fad11 zebra: fix buffer overflow
mac is only 6 bytes long and we shouldn't blindly copy unknown number of
bytes into it.

Fixes #9671.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-09-28 15:45:14 +03:00
Donald Sharp
f2595bd505 zebra: Convert to struct zebra_nhlfe 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
Philippe Guibert
80f6b5faeb lib, zebra: complete the ndm flags on zclient api
Insist on the fact that zclient neighbor state flags are
mapped over netlink state flags. List all the defines
currently known on kernel, and create a netlink API to
convert netlink values to zclient values. The function is
simplified as it is a 1-1 match.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-08-26 09:19:42 +02:00
Mark Stapp
deb28338de zebra: ignore unknown address-family in netlink route msg
Ignore AFs we don't handle in incoming netlink route
updates.

Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
2021-08-10 11:44:08 -04:00
Mark Stapp
1a3bd37f7c zebra: use more const
Use const in many more evpn apis, especially for macaddr,
ipaddr arguments.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-07-19 10:36:12 -04:00
Hiroki Shirokura
0a543b7929 zebra: early return on seg6local nlmsg crafting
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
eab0f8f0a2 lib,sharpd,zebra: update nexthop object with nh_srv6
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
f463eac768 zebra: fill_seg6ipt_encap func with boundary check
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
52026569ca zebra: error check for nl_attr_xxx
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
8a18a7c0c9 zebra: use const on fill_seg6ipt_encap func
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
b9596f139b zebra: fix implicit conversion
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
1bda3e627d *: use one line init instead of memset and format it
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
361a62ac9d zebra: fix compile error of missing-braces
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
4df9d8592b *: fix code format accourding to checkpatch
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
f16de90b8c zebra: parse non-zebra seg6 configuration via netlink (step3)
FRRouting operator can install seg6 route via ZAPI,
But linux kernel operator also can install seg6 route
via Netlink directry (i.e. iproute2)

This commit make zebra to parse non-frr seg6 route
configuration via netlink and audit Zebra's RIB.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
76fb7ae4de zebra: ZEBRA_ROUTE_ADD supports seg6 route (step3)
With this patch, zclient can intall seg6 rotues when
they set properties "nh_seg6_segs" on struct nexthop
and set ZEBRA_FLAG_SEG6_ROUTE on zapi_route's flag.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
d49e6c4afd zebra: parse non-zebra seg6local configuration via netlink (step1)
FRRouting operator can install seg6local route via ZAPI,
But linux kernel operator also can install seg6local route
via Netlink directry (i.e. iproute2)

This commit make zebra to parse non-frr seg6local
route configuration via netlink and audit Zebra's RIB.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:47 -04:00
Hiroki Shirokura
8689b25a08 zebra: ZEBRA_ROUTE_ADD supports seg6local route (step1)
With this patch, zclient can intall seg6local rotues whem
they set properties nh_seg6local_{action,ctx} on struct nexthop
and set ZEBRA_FLAG_SEG6LOCAL_ROUTE on zapi_route's flag.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:47 -04:00
Donald Sharp
269b69d703 zebra: memset the struct rtattr *tb[SIZE] in setting function
In order to parse the netlink message into the
`struct rtattr *tb[size]` it is assumed that the buffer is
memset to 0 before the parsing.  As such if you attempt
to read a value that was not returned in the message
you will not crash when you test for it.

The code has places were we memset it and places where we don't.
This *will* lead to crashes when the kernel changes.  In
our parsing routines let's have them memset instead of having
to remember to do it pre pass in to the parser.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-11 20:05:51 -04:00
Philippe Guibert
88217099de zebra, lib: replace ZEBRA_ROUTE_NEIGH with simplified version
do not add a new route type, and consider 0 as a value meaning
that zebra should be the owner.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-13 08:58:54 +02:00
Philippe Guibert
d603c0774e nhrp, zebra, lib: enforce usage of zapi_neigh_ip structure
zapi_nbr structure is renamed to zapi_neigh_ip.
Initially used to set a neighbor ip entry for gre interfaces, this
structure is used to get events from the zebra layer to nhrp layer.

The ndm state has been added, as it is needed on both sides.
The zebra dplane layer is slightly modified.

Also, to clarify what ZEBRA_NEIGH_ADD/DEL means, a rename is done:
it is called now ZEBRA_NEIGH_IP_ADD/DEL, and it signified that this
zapi interface permits to set link operations by associating ip
addresses to link addresses.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-13 08:58:49 +02:00
Philippe Guibert
e18747a967 zebra: move neighbor table configuration to dplane contexts
Instead of directly configuring the neighbor table after read from zapi
interface, a zebra dplane context is prepared to host the interface and
the family where the neighbor table is updated. Also, some other fields
are hosted: app_probes, ucast_probes, and mcast_probes. More information
on those fields can be found on ip-ntable configuration.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
Philippe Guibert
0a27a2fef5 zebra, lib: handle NEIGH_ADD/DELETE to zebra dataplane framework
EVPN neighbor operations were already done in the zebra dataplane
framework. Now that NHRP is able to use zebra to perform neighbor IP
operations (by programming link IP operations), handle this operation
under dataplane framework:
- assign two new operations NEIGH_IP_INSTALL and NEIGH_IP_DELETE; this
is reserved for GRE like interfaces:
example: ip neigh add A.B.C.D lladdr E.F.G.H
- use 'struct ipaddr' to store and encode the link ip address
- reuse dplane_neigh_info, and create an union with mac address
- reuse the protocol type and use it for neighbor operations; this
permits to store the daemon originating this neighbor operation.
a new route type is created: ZEBRA_ROUTE_NEIGH.
- the netlink level functions will handle a pointer, and a type; the
type indicates the family of the pointer: AF_INET or AF_INET6 if the
link type is an ip address, mac address otherwise.
- to keep backward compatibility with old queries, as no extension was
done, an option NEIGH_NO_EXTENSION has been put in place
- also, 2 new state flags are used: NUD_PERMANENT and NUD_FAILED.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
Philippe Guibert
541025d6ff zebra: handler for configuring neighbor table
neighbor table api in zebra is added. a netlink api is created for that.
the handler is called from the api defined in the previous commit.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
Philippe Guibert
df948efc56 zebra: fixes NDA_DST in netlink_neigh_update() function
When netlink_neigh_update() is called, the link registration was
failing, due to bad request length.
Also, the query was failing if NDA_DST was an ipv6 address.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
Philippe Guibert
05657ec2b7 nhrp, lib, zebra: add/del neighbor entry possible from nhrp
a zebra api is extended to offer ability to add or remove neighbor
entry from daemon. Also this extension makes possible to add neigh
entry, not only between IPs and macs, but also between IPs and NBMA IPs.
This API supports configuring ipv6/ipv4 entries with ipv4/ipv6 lladdr.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
Philippe Guibert
7723e8d3fd zebra: link layer config and notification, implementation in zebra
zebra implements zebra api for configuring link layer information. that
can be an arp entry (for ipv4) or ipv6 neighbor discovery entry. This
can also be an ipv4/ipv6 entry associated to an underlay ipv4 address,
as it is used in gre point to multipoint interfaces.
this api will also be used as monitoring. an hash list is instantiated
into zebra (this is the vrf bitmap). each client interested in those entries
in a specific vrf, will listen for following messages: entries added, removed,
or who-has messages.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
David Lamparter
224ccf29d9 zebra: kill zebra_memory.h, use MTYPE_STATIC
This one also needed a bit of shuffling around, but MTYPE_RE is the only
one left used across file boundaries now.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-22 20:02:17 +01:00
David Lamparter
ef7b8be459 zebra: use printfrr exts in EVPN/VXLAN code
Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-14 22:56:07 +01:00
Stephen Worley
b1077f0fa2
Merge pull request #8152 from idryzhov/fix-zebra-blackhole
zebra: don't use kernel nexthops for blackhole routes
2021-03-02 11:50:46 -05:00
Patrick Ruddy
e1cfd75ffb
Merge pull request #8021 from AnuradhaKaruppiah/evpn-weak-override-fix
zebra: disable setting weak override flag in neigh updates
2021-03-02 10:44:43 +00:00
Igor Ryzhov
4be03ff4ca zebra: don't use kernel nexthops for blackhole routes
Fixes #6522 and #8149.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-01 17:47:38 +03:00
Mark Stapp
15869cd81d
Merge pull request #8035 from qlyoung/remove-more-sprintf
*: remove more sprintf()
2021-02-23 15:55:02 -05:00
Anuradha Karuppiah
736475cdf6 zebra: disable setting weak override flag in neigh updates
This is causing problems with VM move i.e. transition from remote
neigh to local neigh. This transition involves changing the NUD_STATE
NUD_NOARP to NUD_STALE. And the weak override flag prevents changing
the state from connected (REACHABLE, NOARP, PERMANENT) to STALE.

PS: Weak-override was originally used to prevent race conditions where
FRR can end up making a REACHABLE neigh STALE. We may need to revisit
and address that case at a later point.

Ticket: CM-30273

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2021-02-22 11:56:30 -08:00
Donald Sharp
d6816f68bd zebra: use AF_INET for protocol family
When looking up the conversion from kernel protocol to
internal protocol family make sure we use the correct
AF_INET( what the kernel uses ) instead of AFI_IP (which
is what FRR uses ).

Routes from OSPF will show up from the kernel as OSPF6 instead of
OSPF.  Which will cause mayhem

Ticket: CM-33306
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-02-16 15:54:08 -05:00
David Lamparter
1d5453d607 *: remove tabs & newlines from log messages
Neither tabs nor newlines are acceptable in syslog messages.  They also
break line-based parsing of file logs.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-14 15:36:51 +01:00
Quentin Young
7533cad751 *: remove more sprintf()
Should be just a couple non-development, non-test occurrences of this
function left now.

Signed-off-by: Quentin Young <qlyoung@qlyoung.net>
2021-02-09 15:40:40 -05:00
Donald Sharp
cadc15cfe2 zebra: Remove #if 0 code
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-28 13:57:49 -05:00
Patrick Ruddy
f87fe77aeb
Merge pull request #7723 from AnuradhaKaruppiah/fdb-ext-attrs
zebra: move from NDA_NOTIFY to NDA_FDB_EXT_ATTRS
2021-01-19 16:27:54 +00:00
Patrick Ruddy
b567ed7eeb
Merge pull request #7722 from AnuradhaKaruppiah/mh-fixes
bgpd, zebra: evpn mh fixes
2021-01-05 09:26:17 +00:00
Stephen Worley
a4525d25b5
Merge pull request #7788 from deastoe/zebra2proto-kernel-connect
zebra: zebra2proto() handle kernel/connect type
2020-12-28 14:57:41 -05:00
Duncan Eastoe
911d4d4804 zebra: zebra2proto() handle kernel/connect type
When dplane_fpm_nl is used the "Please add this protocol(n) to proper
rt_netlink.c handling" debug message is emitted for any route of type
kernel or connected.

This severely reduces performance of dplane_fpm_nl when large numbers
of these routes are present in the RIB.

The messages are not observed when using the original fpm module since
this uses a custom function, netlink_proto_from_route_type().

zebra2proto() now returns RTPROT_KERNEL for ZEBRA_ROUTE_CONNECT and
ZEBRA_ROUTE_KERNEL. This should only impact dplane_fpm_nl's use of
the common netlink routines since these routes generally ignored via
checking of RSYSTEM_ROUTE().

Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
2020-12-22 21:27:52 +00:00
Anuradha Karuppiah
7c0e4dc659 zebra: reinstall missing peer-sync flag
If a netlink/dp notification is rxed for a neigh without the peer-sync
flag FRR re-installs the entry with the right flags. This change is
needed to handle cases where the dataplane and FRR may fall out of
sync because of neigh learning on the network ports (i.e. via
the VxLAN).

Ticket: CM-30693
The problem was found during VM mobility "torture" tests where 100s
of extended VM moves were done.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-12-21 08:41:17 -08:00
Anuradha Karuppiah
2c89cb9017 zebra: changes to log ext_flags in neigh nl add
Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-12-21 08:41:17 -08:00
Anuradha Karuppiah
c7bfd08568 zebra: advertise stale neighs if EVPN-MH is not enabled
With EVPN-MH, Type-2 routes are also used for MAC-IP syncing between
ES peers so a change was done to only treat REACHABLE local neigh
entries as local-active and advertise them as Type-2 routes i.e. STALE
neigh entries are no longer advertised as Type-2s.

This however exposed some unexpected problems with MLAG where a
secondary reboot followed by a primary reboot left a lot of neighs
in STALE state (on the primary) resulting in them not being
advertised. And remote routed traffic to those hosts being
blackholed in a sym-IRB setup.

This commit is a workaround to fix the regression (it doesn't fix
the underlying problems with entries not becoming REACHABLE; which
maybe a day-1 problem). The workaround is to continue advertising
STALE neighbors if EVPN-MH is not enabled.

Ticket: CM-30303

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-12-21 08:41:15 -08:00
Donald Sharp
3ceae22b7f Revert "zebra: When shutting down an interface immediately notify about rnh"
This reverts commit 0aaa722883.
2020-12-11 20:45:43 -05:00
Nikolay Aleksandrov
4bcdb6086c zebra: move from NDA_NOTIFY to NDA_FDB_EXT_ATTRS
Use the new nested NDA_FDB_EXT_ATTRS attribute to control per-fdb
notifications.

PS: The attributes where updated as a part of the kernel upstreaming
hence the change.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-12-11 12:13:36 -08:00
Anuradha Karuppiah
15400f95b7 zebra: support for slow-failover of local MACs on an ES
When a local ES flaps there are two modes in which the local
MACs are failed over -
1. Fast failover - A backup NHG (ES-peer group) is programmed in the
dataplane per-access port. When a local ES flaps the MAC entries
are left unaltered i.e. pointing to the down access port. And the
dataplane redirects traffic destined to the oper-down access port
via the backup NHG.
2. Slow failover - This mode needs to be turned on to allow dataplanes
not capable of re-directing traffic. In this mode local MAC entries
on a down local ES are re-programmed to point to the ES-peers'
NHG. And vice-versa i.e. when the ES comes up the MAC entries
are re-programmed with the access port as dest.

Fast failover is on by default. Slow failover can be enabled via the
following config -
evpn mh redirect-off

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-12-01 09:46:26 -08:00
Anuradha Karuppiah
80e19eb71f zebra: skip NDA_DST attr if NHG is present
NHG and DST (VTEP-IP) are mutually exclusive attributes. If DST is
present the kernel ignores NHG.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-12-01 09:44:37 -08:00
Donald Sharp
e4876266e4 zebra: Add --asic-offload command
Add a command that allows FRR to know it's being used with
an underlying asic offload, from the linux kernel perspective.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 10:19:25 -05:00
Donald Sharp
0d32fbee6d lib, zebra: Add ability to read kernel notice of Offload Failed
The linux kernel is getting RTM_F_OFFLOAD_FAILED for kernel routes
that have failed to offload.  Write the code
to receive these notifications from the linux kernel
and store that data for display about the routes.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 10:12:50 -05:00
Anuradha Karuppiah
60e372e9cb zebra: Set NUD_NOARP on sticky MAC entries in addition to NTF_STICKY
(ndm_state & NUD_NOARP) - prevents the entry from expiring
(ndm_flags & NTF_STICKY) - prevents station moves on the entry

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-11-06 17:21:12 -08:00
Donald Sharp
acde7f6b8e zebra: Consolidate on 32 bits as the flag size for route flags
When we get a route for installation via any method we should
consolidate on 32 bits as the flag size, since we have
actually more than 8 bits of data to bass around.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-29 09:13:59 -04:00
Mark Stapp
bdd085a874 zebra: fix strange indentation
Fix some odd indentation in rt_netlink.c - merge damage, maybe?

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-27 12:03:41 -04:00
Mark Stapp
9bcef951be zebra: replace inet_ntoa
Stop using inet_ntoa - use %pI4 or inet_ntop instead

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-22 13:37:25 -04:00
Donatas Abraitis
2dbe669bdf :* Convert prefix2str to %pFX
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-22 09:07:41 +03:00
Stephen Worley
ff9aca4f8d lib,zebra,sharpd: clang format
Clang format for NHG API and sharpd patches.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
72938edfbc zebra: add logging for NHG ignoring in netlink
Add some logging for when we choose to ignore a NHG install
for one reason or another. Also, cleanup some of the code
using the same accessor functions for the context object.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
54c89c9377 zebra: NHG ID bounds macros
Determine the NHG ID spacing and lower bound with ZEBRA_ROUTE_MAX
in macros.

Directly set the upperbound to be the lower 28bits of the uint32_t ID
space (the top 4 are reserved for l2-NHGs). Round that number down
a bit to make it more even.

Convert all former lower_bound calls to just use the macro.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
6c67f41f9e zebra,lib: command to only install proto-based nexthops
Add a command/functionality to only install proto-based nexthops.
That is nexthops owned/created by upper level protocols, not ones
implicitly created by zebra.

There are some scenarios where you would not want zebra to be
arbitrarily installing nexthop groups and but you still want
to use ones you have control over via lib/nexthop_group config
and an upper level protocol.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Mark Stapp
ccda0eadac
Merge pull request #7155 from donaldsharp/TRAP
Offload/Trap
2020-09-23 16:06:37 -04:00
Donald Sharp
5a3cf85391 lib, zebra: Add ability to read kernel notice of TRAP/OFFLOAD
The linux kernel is getting RTM_F_TRAP and RTM_F_OFFLOAD for
kernel routes that have an underlying asic offload.  Write the
code to receive these notifications from the linux kernel and
to store that data for display about the routes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-09-22 15:57:43 -04:00
Anuradha Karuppiah
ccd187cdaa zebra: setup static neigh flag in the dataplane
Changes to setup peer-synced as static in the dataplane. This prevents
them from being flushed out when the local switch cannot establish
their reachability.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-09-16 17:24:18 -07:00
Donald Sharp
0aaa722883 zebra: When shutting down an interface immediately notify about rnh
Imagine a situation where a interface is bouncing up/down.
The interface comes up and daemons like pbr will get a nht
tracking callback for a connected interface up and will install
the routes down to zebra.  At this same time the interface can
go down.  But since zebra is busy handling route changes ( from pbr )
it has not read the netlink message and can get into a situation
where the route resolves properly and then we attempt to install
it into the kernel( which is rejected ).  If the interface
bounces back up fast at this point, the down then up netlink
message will be read and create two route entries off the connected
route node.  Zebra will then enqueue both route entries for future processing.

After this processing happens the down/up is collapsed into an up
and nexthop tracking sees no changes and does not inform any upper
level protocol( in this case pbr ) that nexthop tracking has changed.
So pbr still believes the nexthops are good but the routes are not
installed since pbr has taken no action.

Fix this by immediately running rnh when we signal a connected
route entry is scheduled for removal.  This should cause
upper level protocols to get a rnh notification for the small
amount of time that the connected route was bouncing around like
a madman.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-28 14:45:59 -04:00
Jakub Urbańczyk
d68e74b41c lib, zebra: add support for sending ARP requests
We can make the Linux kernel send an ARP/NDP request by adding
a neighbour with the 'NUD_INCOMPLETE' state and the 'NTF_USE' flag.

This commit adds new dataplane operation as well as new zapi message
to allow other daemons send ARP/NDP requests.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-12 23:19:58 +02:00
Jakub Urbańczyk
18f60fe999 zebra: remove old kernel one-update-at-a-time api
The old one is replaced by the api that is suitable for the batching.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10 21:57:04 +02:00
Jakub Urbańczyk
67e3369ed4 zebra: netlink message batching
Integrate existing functions with batching infrastructure.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10 21:42:43 +02:00
Jakub Urbańczyk
fef24b0339 zebra: prepare dplane for batching
Extend kernel interface to allow the data plane to send many kernel
updates at once.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10 21:32:59 +02:00
Sebastien Merle
31f937fb43 lib, zebra: Add SR-TE policy infrastructure to zebra
For the sake of Segment Routing (SR) and Traffic Engineering (TE)
Policies there's a need for additional infrastructure within zebra.
The infrastructure in this PR is supposed to manage such policies
in terms of installing binding SIDs and LSPs. Also it is capable of
managing MPLS labels using the label manager, keeping track of
nexthops (for resolving labels) and notifying interested parties about
changes of a policy/LSP state. Further it enables a route map mechanism
for BGP and SR-TE colors such that learned BGP routes can be mapped
onto SR-TE Policies.

This PR does not introduce any usable features by now, it is just
infrastructure for other upcoming PRs which will introduce 'pathd',
a new SR-TE daemon.

Co-authored-by: Renato Westphal <renato@opensourcerouting.org>
Co-authored-by: GalaxyGorilla <sascha@netdef.org>
Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-08-07 11:08:49 +02:00
Anuradha Karuppiah
9e0c2fd182 bgpd, zebra: remove strcpy, strlen and sprintf calls
Replace with safe copy functions - strlcpy, strlcat, strnlen and
snprintf.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:13 -07:00
Anuradha Karuppiah
d87ed8d74a zebra: remove linux/ifbridge.h from rt_netlink.c
It is causing build failures because of conflicts with netinet.
Instead I have re-defined the MAC-SYNC UAPIs in the re_netlink.c

This is clearly a hack that needs to be re-visited.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:13 -07:00
Anuradha Karuppiah
b169fd6fd5 zebra: support for MAC-IP sync routes
MAC-IP routes are used for syncing local entries across redundant
switches in an EVPN-MH setup. A path from a peer that has a local
ES as destination is tagged as a SYNC path. The SYNC path results in the
addition of local MAC and/or local neigh entry in zebra and in the
dataplane.

Implementation overview
=======================
1. Three new flags "local-inactive", "peer-active" and "peer-proxy"
are maintained per-local-MAC and per-local-Neigh entry.
2. The "peer-XXX" flags are set and cleared via SYNC path updates
from BGP. Proxy sync paths result in the setting of "peer-proxy" flag
(and non-proxies result in the "peer-active").
3. A neigh entry that has a "peer-XXX" flag set is programmed as
"static" in the dataplane.
4. A MAC entry that has a "peer-XXX" flag set or is referenced by
a sync-neigh entry (that has a "peer-XXX" flags set) is programmed
as "static" in the dataplane.
5. The sync-seq number is used to normalize the MM seq number across
all the redundant switches i.e. the max MM seq number across all
switches is used by each of the switches. This commit also includes
the changes needed for extended MM seq syncing.
6. A MAC/neigh entry has to be local-active or peer-active to sent to
BGP. An entry that is NOT local-active is sent with the proxy flag (so
BGP can "proxy" advertise it).
7. The "peer-active" flag is aged out by zebra by using a hold_timer
(this is instead of being abruptly dropped on SYNC path delete). This
age-out is needed to handle peer-switch restart (procedures are specified
in draft-rbickhart-evpn-ip-mac-proxy-adv). The holdtime needs to be
sufficiently long to allow an external neighmgr daemon or the dataplane
component to independently probe and establish local reachability of a
host. The MAC and neigh hold time values are configurable.
PS: In the future this probing may happen in FRR itself.

CLI changes to display sync info
================================
MAC
===
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
root@torm-11:mgmt:~# net show evpn mac vni 1000
Number of MACs (local and remote) known for this VNI: 6
Flags: N=sync-neighs, I=local-inactive, P=peer-active, X=peer-proxy
MAC               Type   Flags Intf/Remote ES/VTEP            VLAN  Seq #'s
00:02:00:00:00:25 local        vlan1000                       1000  0/0
02:02:00:00:00:02 local  PI    hostbond1                      1000  0/0
02:02:00:00:00:06 remote       03:00:00:00:00:02:11:00:00:01        0/0
02:02:00:00:00:01 local  X     hostbond1                      1000  0/0
00:00:00:00:00:11 local  PI    hostbond1                      1000  0/0
02:02:00:00:00:05 remote       03:00:00:00:00:02:11:00:00:01        0/0
root@torm-11:mgmt:~#
root@torm-11:mgmt:~# net show evpn mac vni 1000 mac 00:00:00:00:00:11
MAC: 00:00:00:00:00:11
 ESI: 03:00:00:00:00:01:11:00:00:01
 Intf: hostbond1(58) VLAN: 1000
 Sync-info: neigh#: 0 local-inactive peer-active >>>>>>>>>>>>
 Local Seq: 0 Remote Seq: 0
 Neighbors:
    No Neighbors
root@torm-11:mgmt:~#
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
neigh
=====
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
root@torm-11:mgmt:~# net show evpn arp vni 1003
Number of ARPs (local and remote) known for this VNI: 4
Flags: I=local-inactive, P=peer-active, X=peer-proxy
Neighbor             Type   Flags State    MAC               Remote ES/VTEP                 Seq #'s
2001:fee1:0:3::6     local        active   00:02:00:00:00:25                                0/0
45.0.3.66            local  P     active   00:02:00:00:00:66                                0/0
45.0.3.6             local        active   00:02:00:00:00:25                                0/0
fe80::202:ff:fe00:25 local        active   00:02:00:00:00:25                                0/0
root@torm-11:mgmt:~#
root@torm-11:mgmt:~# net show evpn arp vni 1003 ip 45.0.3.66
IP: 45.0.3.66
 Type: local
 State: active
 MAC: 00:02:00:00:00:66
 Sync-info: peer-active >>>>>>>>>>>>>>>>
 Local Seq: 0 Remote Seq: 0
root@torm-11:mgmt:~#
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:13 -07:00
Anuradha Karuppiah
f188e68e5c zebra: debug flags for MAC-IP sync
Filters for zebra debug logs.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:13 -07:00
Anuradha Karuppiah
506efd379b zebra: support for adding L2NHG and mac-ecmp in the linux kernel
Multihoming support requires a new dataplane feature, MAC-ECMP, to
bridge traffic to remote ESs that are attached to more than one
active VTEP.

As a part of this support indirection has also been added via
L2-NHGs. Using a nexthop group allows for fast failover
of MAC entries when an access port attached to a remote-ES goes
down i.e. instead of updating many MAC entries this becomes a
single NHG update to the dataplane.

Note: Some of the code here needs to be reworked to the new
dataplane model.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Kaushik
92d6f76988 lib,zebra,bgpd: Fix for nexthop as IPv4 mapped IPv6 address
Added a macro to validate the v4 mapped v6 address.
Modified bgp receive & send updates for v4 mapped v6 address as
nexthop and installing it as recursive nexthop in RIB.
Minor change in fpm while sending the routes for nexthop as
v4 mapped v6 address.

Signed-off-by: Kaushik <kaushik@niralnetworks.com>
2020-08-03 23:24:04 -07:00
Jakub Urbańczyk
45c80fbd08 zebra: fix installing an evpn neighbor update
Fix the function encoding evpn neighbor. The size of the buffer
for the netlink message wasn't correct and because of that we thought that
the message didn't fit entirely in the buffer and thus we were not sending
the update to the kernel.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-07-16 15:49:05 +02:00
Rafael Zalamena
013fef4c91 zebra,fpm: fix force disable next hop groups
`force_nhg` is only settable when calling from `fpm`, so if the kernel
was using next hop groups it would override our knob.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-07-10 13:13:55 -03:00
Donald Sharp
d52c949b2c zebra: When installing a nexthop-group success is vital
When installing a nexthop-group the recent commit:
commit 0be6e7d75d

reversed the logic for testing if adding data to
the netlink message succeeded and we thought we did
not thus not creating the nexthop group.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-06-17 23:36:42 -04:00
Jakub Urbańczyk
a757997cab zebra: more clean-ups in netlink code
* Use nl_attr_add32 instead of nl_attr_add where it is possible.
 * Move common code from build_singlepath() and build_multipath()
   to separate function.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-06-13 22:56:25 +02:00
Jakub Urbańczyk
0be6e7d75d zebra: check for buffer boundary
* Move code encoding Netlink messages to separate functions
 * Add buffer bounds checking while creating Nelink messages

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-06-13 22:56:25 +02:00
Jakub Urbańczyk
312a6beed6 zebra: clean up netlink api
* Rename netlink utility functions like addattr to be less ambiguous
 * Replace rta_attr_* functions with nl_attr_* since they introduced
   inconsistencies in the code
 * Add helper functions for adding rtnexthop struct to the Netlink
   message

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-06-13 22:53:24 +02:00
Mark Stapp
ee70f62979 zebra: convert LSP nhlfe lists to use typesafe lists
Convert the embedded lists of nhlfes and snhlfes in zebra LSPs
and SLSPs to use typesafe dlists.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-01 14:46:12 -04:00
Sri Mohana Singamsetty
6e19892fdf
Merge pull request #6419 from vivek-cumulus/zebra_macfdb_fixup
Zebra macfdb fixup
2020-05-19 08:18:37 -07:00
Stephen Worley
22857da1bb
Merge pull request #6351 from opensourcerouting/fpm-nh
fpm: explicit next hop groups control
2020-05-19 11:01:03 -04:00
vivek
bbd4285bc7 zebra: Install bridge FDB entries with correct VTEP IP
Fixes: zebra: adapt and export rmac netlink functions

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-05-15 14:01:59 -07:00
vivek
4682d1bf81 zebra: Pass correct buffer to MAC FDB netlink message build
Fixes: zebra: adapt and export rmac netlink functions

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-05-15 13:58:30 -07:00
Rafael Zalamena
a2072e7100 zebra: format files to make polychaeta happy
Use clang-format to make code match what polychaeta wants for
formatting.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-13 13:56:16 -03:00