summaryrefslogtreecommitdiff
path: root/zebra/zebra_fpm_netlink.c
AgeCommit message (Collapse)Author
2023-08-01zebra: remove duplicated nexthops when sending fpm msg恭简
When zebra send msg to fpm client, it doesn't handle duplicated nexthops especially, which means if zebra has a route with NUM1 recursive nexthops, each resolved to the same NUM2 connected nexthops, it will send to fpm client a route with NUM1*NUM2 nexthops. But actually there are only NUM2 useful nexthops, the left NUM1*NUM2-NUM2 nexthops are all duplicated nexthops. By the way, zebra has duplicated nexthop remove logic when sending msg to kernel. Add duplicated nexthop remove logic to zebra when sending msg to fpm client. Signed-off-by: 恭简 <gongjian.lhr@alibaba-inc.com>
2023-05-19zebra: Do not allow old FPM to access freed memory after shutdownDonald Sharp
On shutdown, the old FPM queues up dests to be sent to the FPM listener. This is done through the rib_shutdown hook. Which is called when the table that the routes are stored in are being deleted. This dest has pointers to the rnode. The rnode has pointers to the table it is associated with as well as the table->info pointer for the zebra data associated with this table. The FPM after this attempts to tell this to it's listener via events. Unfortunately the zvrf, table_id and nl_pid was being grabbed from memory that had been freed! Since all this can be grabbed from memory that has not been freed on shutdown let's switch over to using that instead of freed memory for gathering data. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-31zebra: Add missing enums to switch statementsDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-24zebra_fpm: Add support for other protocols in fpm:netlinkSpoorthi K
fpm:netlink format doesn't indicate the protocol information in routes of BGP, OSPF and other protocols. Routes of those protocols just indicate protocol as zebra. The below route is actually BGP route but 'proto': 11 indicates that it is zebra. {'attrs': [('RTA_DST', 'dummy'), ('RTA_PRIORITY', 0), ('RTA_GATEWAY', 'dummy'), ('RTA_OIF', 2)], 'dst_len': 32, 'family': 2, 'flags': 0, 'header': {'flags': 1025, 'length': 60, 'pid': 3160253895, 'sequence_number': 0, 'type': 24}, 'proto': 11, 'scope': 0, 'src_len': 0, 'table': 254, 'tos': 0, 'type': 1} with this change it is now seen with 'proto': 186 indicates that it is BGP. {'attrs': [('RTA_DST', 'dummy'), ('RTA_PRIORITY', 0), ('RTA_GATEWAY', 'dummy'), ('RTA_OIF', 2)], 'dst_len': 32, 'family': 2, 'flags': 0, 'header': {'flags': 1025, 'length': 60, 'pid': 3160253895, 'sequence_number': 0, 'type': 24}, 'proto': 186, 'scope': 0, 'src_len': 0, 'table': 254, 'tos': 0, 'type': 1} Signed-off-by: Spoorthi K <spk@redhat.com>
2023-01-18zebra: fix fpm netlink encode out of bounds readRafael Zalamena
Don't attempt to encode the pointer address instead pass the pointer directly so the real contents can be accessed. (`ri->pref_src` type is `union g_addr *`) Found by Coverity Scan (CID 1482162) Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-12-17zebra: fix wrong gateway for fpm debuganlan_cs
The wrong parameter is passed in `inet_ntop()` of `zfpm_log_route_info()` in old fpm module, so the display of gateway is always wrong. Just remove that extra ampersand. Additionally, use "none" as gateway value for the case of no gateway. Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-06-10lib, zebra, bgpd: Move route EVPN flag to nexthopXiao Liang
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-04-19*: Fix spelling of accomodateDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-10zebra: FPM next hop weightskiselev99@gmail.com
Don't lose next hop weights while exporting via FPM Signed-off-by: Alex Kiselev <alex@bisonrouter.com>
2021-09-14zebra: add inbound netlink socket for dataplaneMark Stapp
Add a new netlink socket for events coming in from the host OS to the dataplane system for processing. Rename the existing outbound dplane socket. Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
2021-09-13zebra: Fix IPv4 routes with IPv6 link local next hops install in FPMNikhil Kelapure
Description: Currently IPv4 routes with IPv6 link local next hops are not properly installed in FPM. Reason is the netlink decoding truncates the ipv6 LL address to 4 byte ipv4 address. Ex : fe80:: is directly converted to ipv4 and it results in 254.128.0.0 as next hop for below routes 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 B>* 2.1.0.0/16 [200/0] via fe80::268a:7ff:fed0:d40, Ethernet0, weight 1, 02:22:26 B>* 5.1.0.0/16 [200/0] via fe80::268a:7ff:fed0:d40, Ethernet0, weight 1, 02:22:26 B>* 10.1.0.2/32 [200/0] via fe80::268a:7ff:fed0:d40, Ethernet0, weight 1, 02:22:26 Hence this fix converts the ipv6-LL address to ipv4-LL (169.254.0.1) address before sending it to FPM. This is inline with how these types of routes are currently programmed into kernel. Signed-off-by: Nikhil Kelapure <nikhil.kelapure@broadcom.com>
2021-06-07Zebra: FPM support for gateway IP overlay IndexAmeya Dharkar
FPM sends VNI to the data plane with the EVPN prefix. For pure type-5 EVPN route, nexthop interface of EVPN prefix is L3VNI SVI. Thus, we encode L3VNI corresponding to the nexthop vrf with rtmsg for this prefix. For EVPN type-5 route with gateway IP overlay index, we supporting asymmetric IRB. Thus, nexthop interface is L2VNI SVI. So, instead of fetching vrf VNI, fetch VNI corresponding to the nexthop SVI and encode it in the rtmsg for EVPN prefix. Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2021-03-14fpm: use printfrr extsDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2021-01-15zebra: set nlmsg_pid in netlink msgs sent by 'fpm'Duncan Eastoe
Use nl_pid from the netlink socket used for programming the kernel (netlink_dplane) in netlink route messages sent by the 'fpm' module. This makes 'fpm' consistent with 'dplane_fpm_nl' which already behaves this way, and allows FPM server implementations to determine route origin via nlmsg_pid. Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
2020-10-22zebra: replace inet_ntoaMark Stapp
Stop using inet_ntoa - use %pI4 or inet_ntop instead Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-09-29zebra: fix FPM abort for unreach/prohibit routesDuncan Eastoe
b0e9567ed162da708f8d0b3a3caf87cd03b62e96 fixed an issue whereby zebra would abort while building an update for a blackhole route. The same issue, `assert(data_len)` failing in `zfpm_build_route_updates()`, can be observed when building updates for unreachable and prohibit routes. To address this `netlink_route_info_fill()` is updated to not indicate failure, due to lack of nexthops, for any blackhole routes. Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
2020-08-04Merge pull request #6698 from deastoe/fpm-netlink-fixesDonald Sharp
zebra: always set kernel table ID in FPM netlink
2020-08-03lib,zebra,bgpd: Fix for nexthop as IPv4 mapped IPv6 addressKaushik
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-07-08zebra: always set kernel table ID in FPM netlinkDuncan Eastoe
Ensure that rtm_table is populated with the kernel table ID. Otherwise routes intended for a non-main table appear to the FPM server as though they should be installed in the main table. Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
2020-06-13zebra: clean up netlink apiJakub Urbańczyk
* 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-03zebra: Fix zebra crashed in building FPM netlink message when bgp sends ↵Richard Wu
aggregation routes to zebra. Issue: When BGP sends aggregation routes to zebra, the next hop is black hole. Then Zebra will try to build the netlink FPM message, but there is no next hop as it is a black hole route. Then the netlink_route_info_fill function returns 0. In the result, zebra will crashed in "assert(data_len)" of zfpm_build_route_updates. This issue also happen when I create a static black hole route via staticd. Fix: As the netlink message of the blackhole route is legal, it should return success. Signed-off-by: Richard Wu <wutong23@baidu.com>
2020-05-08zebra: Remove typedef netlink_route_info_tDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-08zebra: Remove the typedef netlink_nh_info_tDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-04-22zebra: Cleanup dead codeDonald Sharp
There are a couple of switch statements in netlink_route_info_encode in zebra_fpm_netlink.c that had logically dead code. We have a switch statement let's take actual advantage of it instead of doing gyrations to what we want. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-06*: Finish off the __PRETTY_FUNCTION__ to __func__Donald Sharp
FINISH IT Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-05*: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__Donatas Abraitis
Just keep the code cool. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-27zebra: Embed lib nexthop-group in zebra hash entryMark Stapp
Embed nexthop-group, which is just a pointer, in the zebra nexthop-hash-entry object, rather than mallocing one. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-13*: Remove break after returnDonatas Abraitis
Just a deadcode. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-06*: Replace s_addr 0 => INADDR_ANYDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-12-04lib,zebra: use nhg_hash_entry pointer in route_entryMark Stapp
Replace the existing list of nexthops (via a nexthop_group struct) in the route_entry with a direct pointer to zebra's new shared group (from zebra_nhg.h). This allows more direct access to that shared group and the info it carries. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-10-25zebra: Replace nexthop_group with pointer in route entryDonald Sharp
In the route_entry we are keeping a non pointer based nexthop group, switch the code to use a pointer for all operations here and ensure we create and delete the memory. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-08-09Zebra: Incorrect L3VNI for FPM rtmsg for EVPN RT-5 prefixAmeya Dharkar
We used the vrf_id in the rtm_table field of the netlink rtmsg to fetch L3VNI. But, now we program table_id to rtm_table field instead of vrf_id. Thus, L3VNI fetched using rtm_table is incorrect. Instead, use nexthop->vrf_id to fetch the L3VNI. Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-07-01*: s/TRUE/true/, s/FALSE/false/Quentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-06-17Zebra: Address review comments for RMAC FPM feature 1Ameya Dharkar
Address minor review comments. Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-06-17Zebra: Build nelink message for RMAC updatesAmeya Dharkar
- Function "zfpm_netlink_encode_mac()" builds a netlink message for RMAC updates. - To build a netlink message for RMAC updates, we use "ndmsg" in rtlink. - FPM Message structure is: FPM header -> nlmsg header -> ndmsg fields -> ndmsg attributes - Netlink message will look like: {'ndm_type': 0, 'family': 7, '__pad': (), 'header': {'flags': 1281, 'length':64, 'type': 28, 'pid': 0, 'sequence_number': 0}, 'state': 2, 'flags': 22, 'attrs': [('NDA_LLADDR', 'b2:66:eb:b9:5b:d3'), ('NDA_DST', '10.100.0.2'), ('NDA_MASTER', 11), ('NDA_VNI', 1000)], 'ifindex': 18} - Message details: nlmsghdr.nlmsg_type = RTM_NEWNEIGH(28) or RTM_DELNEIGH(29) nlmsghdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_REPLACE for "add" , "NLM_F_REQUEST" for delete. ndmsg.ndm_family = AF_BRIDGE ndmsg.ndm_ifindex = vxlan_if (ifindex) ndmsg.ndm_state = NUD_REACHABLE ndmsg.ndm_flags |= NTF_SELF | NTF_MASTER | NTF_EXT_LEARNED Attribute "NDA_LLADDR" for MAC address Attribute "NDA_DST" for remote vtep ip Attribute "NDA_MASTER" for bridge interface ifindex. Attribute "NDA_VNI" for VNI id. Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-05-21Merge pull request #4359 from adharkar/frr-master-rtm_vxlanDonald Sharp
Zebra: Handle VxLAN encap in netlink rtmsg for FPM
2019-05-17Zebra: Enhancements for rtm_table field in FPM netlink messageAmeya Dharkar
- Today, rtm_table field takes a vrf_id. It should take table_id - rtm_table field is a uchar field which can only accomodate table_id less than 256. To support table id greater than 255, if the table_id is greater than 255, set rtm_table to 0 and add RTA_TABLE attribute with 32 bit value as the table_id. Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-05-17Zebra: Handle VxLAN encap in netlink rtmsg for FPMAmeya Dharkar
- For data plane processing of VxLAN routes, add encap type and L3VNI info to rtmsg message for FPM. - Add "RTA_ENCAP_TYPE" attribute for VxLAN encap with value 100. This value is not currently used for RTA_ENCAP_TYPE for any encap. - If "RTA_ENCAP_TYPE" is 100, add "RTA_ENCAP" attribute with "RTA_VNI" as a nested attribute of RTA_ENCAP Format of RTA_VNI attribute: Len(2 bytes) type (2 bytes) Value(4 bytes)(VNI) 00 08 : 00 00 : 1000 RTA_VNI attribute is a custom attribute. Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-05-16Merge pull request #4327 from sworleys/Move-Multipath-NumRuss White
zebra: Move multipath_num into zrouter
2019-05-14zebra: Move multipath_num into zrouterDonald Sharp
The multipath_num variable is a property of zebra_router, so move it there. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-14zebra: send nexthop blackhole information in FPMRafael Zalamena
Don't return prematurely so we can add blackhole nexthop information. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-04-18lib: ZEBRA_NUM_OF -> array_sizeDavid Lamparter
The latter is widely used, e.g. in the Linux kernel. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-01-25zebra: Use ROUTE_ENTRY_INSTALLED as decision for route is installedDonald Sharp
zebra is using NEXTHOP_FLAG_FIB as the basis of whether or not a route_entry is installed. This is problematic in that we plan to separate out nexthop handling from route installation. So modify the code to keep track of whether or not a route_entry is installed/failed. This basically means that every place we set/unset NEXTHOP_FLAG_FIB, we actually also set/unset ROUTE_ENTRY_INSTALLED on the route_entry. Additionally where we check for route installed via NEXTHOP_FLAG_FIB switch over to checking if the route think's it is installed. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-19zebra: Start abstraction of zebra_dplane_info for context passingMark Stapp
Reduce or eliminate use of global zebra_ns structs in a couple of netlink/kernel code paths, so that those paths can potentially be made asynch eventually. Signed-off-by: Mark Stapp <mjs@voltanet.io> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-27*: use C99 standard fixed-width integer typesQuentin Young
The following types are nonstandard: - u_char - u_short - u_int - u_long - u_int8_t - u_int16_t - u_int32_t Replace them with the C99 standard types: - uint8_t - unsigned short - unsigned int - unsigned long - uint8_t - uint16_t - uint32_t Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-09lib: Isolate nexthop_group functions to nexthop_group.cDonald Sharp
Also modify `struct route_entry` to use nexthop_groups. Move ALL_NEXTHOPS loop to nexthop_group.h Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-28zebra: cleanup blackhole supportDavid Lamparter
blackhole support was horribly broken. cleanup by removing blackhole stuff from ZEBRA_FLAG_* introduces support for "prohibit" routes (Linux/netlink only) also clean up blackhole options on "ip route" vty commands. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-31build: zebra: remove *_method Makefile hacksDavid Lamparter
replace with preprocessor checks in source files. Much simpler... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17*: reindentreindent-master-afterwhitespace / reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>