Commit Graph

601 Commits

Author SHA1 Message Date
Donatas Abraitis
ce39ca16dd zebra: Avoid buffer overflow using netlink_parse_rtattr_nested()
memset(tb, 0, sizeof(struct rtattr *) * (max + 1)); in netlink_parse_rtattr()
seems a good candidate to buffer overflow.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-17 22:31:48 +03:00
David Lamparter
e1cd4bb178 zebra: fix remaining MR RTM_GETROUTE oddities
The IPv6 version needs rtm_src_len and rtm_dst_len filled in due to
strict validation.  IPv4 also has this requirement, but zebra is running
in non-strict mode there so the kernel accepts it...

Also the table ID hack is IPv4 only.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-07-07 11:36:40 +02:00
David Lamparter
c6a89c8ef5 zebra: IIF/OIF are not used in MR RTM_GETROUTE
The multicast routing RTM_GETROUTE command does not use IIF/OIF
attributes, and the IPv6 version will refuse them with an error due to
being new netlink API and thus using strict validation.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-07-06 11:29:56 +02:00
David Lamparter
31071fe357 zebra: netlink MR is a rtmsg, not ndmsg
These two structs happen to be the same size and have the family field
in the same spot, but the correct one to use here is rtmsg not ndmsg.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-07-06 11:23:06 +02:00
David Lamparter
afeb8524e2 zebra: correctly ignore multicast nl msgs
zebra does not care about _notifications_ from the kernel regarding
multicast routing;  we only use the MR netlink API to request stats from
the kernel by actively sending a RTM_GETROUTE.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-07-06 11:19:05 +02:00
Donald Sharp
b09388f0ea zebra: Add more cases to proto2zebra for understanding kernel routes
Just some missing ones.  Make zebra stop complaining, was getting
some messages from proto2zebra when doing testing, let's clean
that up from happening.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-01 07:59:53 -04:00
Donald Sharp
c3dcd24bc2 zebra: Notice to end operator when a failure happens
When reading a multipath route and we detect an encoding
error from the kernel( yeah I don't think so either ),
let's tell the operator what happened to that route.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-01 07:59:53 -04:00
Anuradha Karuppiah
4cf4fad153 zebra: add support for maintaining local neigh entries
Currently specific local neighbors (attached to SVIs) are maintatined
in an EVPN specific database. There is a need to maintain L3 neighbors
for other purposes including MAC resolution for PBR nexthops.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
   Cleanup compile and fix crash
Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
2022-06-27 07:56:55 -04:00
Russ White
a9adefc22f
Merge pull request #11464 from donaldsharp/linkdown
Linkdown
2022-06-24 10:15:55 -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
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
anlan_cs
81157cbd10 zebra: remove unnecessary check for "zevpn_vrf"
The global vrf in zebra is always non-NULL. In general, it is bound to
default vrf by `zebra_vrf_init()`, at other times bound to some specific
vrf. Anyway, non-NULL.

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

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

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

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-11 14:08:47 +03:00
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
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
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
3819e4ced7 *: Fix spelling of inteface
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:21:31 -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
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