summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_fpm_netlink.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* zebra_fpm: Add support for other protocols in fpm:netlinkSpoorthi K2023-01-241-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* zebra: fix fpm netlink encode out of bounds readRafael Zalamena2023-01-181-1/+1
| | | | | | | | | | | 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>
* zebra: fix wrong gateway for fpm debuganlan_cs2022-12-171-4/+9
| | | | | | | | | | 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>
* lib, zebra, bgpd: Move route EVPN flag to nexthopXiao Liang2022-06-101-1/+1
| | | | | | | 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>
* *: Fix spelling of accomodateDonald Sharp2022-04-191-1/+1
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* zebra: FPM next hop weightskiselev99@gmail.com2022-02-101-0/+5
| | | | | | Don't lose next hop weights while exporting via FPM Signed-off-by: Alex Kiselev <alex@bisonrouter.com>
* zebra: add inbound netlink socket for dataplaneMark Stapp2021-09-141-1/+1
| | | | | | | | 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>
* zebra: Fix IPv4 routes with IPv6 link local next hops install in FPMNikhil Kelapure2021-09-131-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Zebra: FPM support for gateway IP overlay IndexAmeya Dharkar2021-06-081-6/+27
| | | | | | | | | | | | | 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>
* fpm: use printfrr extsDavid Lamparter2021-03-141-7/+4
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* zebra: set nlmsg_pid in netlink msgs sent by 'fpm'Duncan Eastoe2021-01-151-1/+9
| | | | | | | | | | | 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>
* zebra: replace inet_ntoaMark Stapp2020-10-221-41/+12
| | | | | | Stop using inet_ntoa - use %pI4 or inet_ntop instead Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: fix FPM abort for unreach/prohibit routesDuncan Eastoe2020-09-291-4/+12
| | | | | | | | | | | | | | 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>
* Merge pull request #6698 from deastoe/fpm-netlink-fixesDonald Sharp2020-08-041-4/+1
|\ | | | | zebra: always set kernel table ID in FPM netlink
| * zebra: always set kernel table ID in FPM netlinkDuncan Eastoe2020-07-081-4/+1
| | | | | | | | | | | | | | | | 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>
* | lib,zebra,bgpd: Fix for nexthop as IPv4 mapped IPv6 addressKaushik2020-08-041-2/+10
|/ | | | | | | | | | 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>
* zebra: clean up netlink apiJakub Urbańczyk2020-06-131-50/+37
| | | | | | | | | | * 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>
* zebra: Fix zebra crashed in building FPM netlink message when bgp sends ↵Richard Wu2020-06-031-1/+1
| | | | | | | | | | | | | | | | | | 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>
* zebra: Remove typedef netlink_route_info_tDonald Sharp2020-05-081-9/+10
| | | | Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: Remove the typedef netlink_nh_info_tDonald Sharp2020-05-081-7/+7
| | | | Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: Cleanup dead codeDonald Sharp2020-04-221-30/+22
| | | | | | | | | 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>
* *: Finish off the __PRETTY_FUNCTION__ to __func__Donald Sharp2020-03-061-2/+1
| | | | | | FINISH IT Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__Donatas Abraitis2020-03-051-1/+1
| | | | | | Just keep the code cool. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* zebra: Embed lib nexthop-group in zebra hash entryMark Stapp2020-02-271-1/+1
| | | | | | | 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>
* *: Remove break after returnDonatas Abraitis2020-02-131-5/+0
| | | | | | Just a deadcode. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* *: Replace s_addr 0 => INADDR_ANYDonatas Abraitis2020-02-061-2/+2
| | | | Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* lib,zebra: use nhg_hash_entry pointer in route_entryMark Stapp2019-12-041-1/+1
| | | | | | | | | 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>
* zebra: Replace nexthop_group with pointer in route entryDonald Sharp2019-10-251-1/+1
| | | | | | | | 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>
* Zebra: Incorrect L3VNI for FPM rtmsg for EVPN RT-5 prefixAmeya Dharkar2019-08-101-1/+1
| | | | | | | | | | 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>
* *: s/TRUE/true/, s/FALSE/false/Quentin Young2019-07-011-2/+2
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Zebra: Address review comments for RMAC FPM feature 1Ameya Dharkar2019-06-171-2/+2
| | | | | | Address minor review comments. Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
* Zebra: Build nelink message for RMAC updatesAmeya Dharkar2019-06-171-0/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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>
* Merge pull request #4359 from adharkar/frr-master-rtm_vxlanDonald Sharp2019-05-211-4/+112
|\ | | | | Zebra: Handle VxLAN encap in netlink rtmsg for FPM
| * Zebra: Handle VxLAN encap in netlink rtmsg for FPMAmeya Dharkar2019-05-171-4/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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>
* | Zebra: Enhancements for rtm_table field in FPM netlink messageAmeya Dharkar2019-05-171-2/+19
|/ | | | | | | | | | - 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>
* Merge pull request #4327 from sworleys/Move-Multipath-NumRuss White2019-05-161-1/+2
|\ | | | | zebra: Move multipath_num into zrouter
| * zebra: Move multipath_num into zrouterDonald Sharp2019-05-141-1/+2
| | | | | | | | | | | | | | The multipath_num variable is a property of zebra_router, so move it there. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* | zebra: send nexthop blackhole information in FPMRafael Zalamena2019-05-141-1/+0
|/ | | | | | Don't return prematurely so we can add blackhole nexthop information. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
* lib: ZEBRA_NUM_OF -> array_sizeDavid Lamparter2019-04-181-1/+1
| | | | | | The latter is widely used, e.g. in the Linux kernel. Signed-off-by: David Lamparter <equinox@diac24.net>
* zebra: Use ROUTE_ENTRY_INSTALLED as decision for route is installedDonald Sharp2019-01-261-1/+1
| | | | | | | | | | | | | | 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>
* zebra: Start abstraction of zebra_dplane_info for context passingMark Stapp2018-09-201-0/+1
| | | | | | | | | 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>
* *: use C99 standard fixed-width integer typesQuentin Young2018-03-271-6/+6
| | | | | | | | | | | | | | | | | | | | | | 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>
* lib: Isolate nexthop_group functions to nexthop_group.cDonald Sharp2018-03-091-1/+1
| | | | | | | 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>
* zebra: cleanup blackhole supportDavid Lamparter2017-08-281-23/+17
| | | | | | | | | | 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>
* build: zebra: remove *_method Makefile hacksDavid Lamparter2017-07-311-0/+4
| | | | | | replace with preprocessor checks in source files. Much simpler... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: reindentreindent-master-afterwhitespace / reindent2017-07-171-324/+295
| | | | | | indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* Remove recursive param from netlink_route_info_addßingen2017-07-101-4/+3
| | | | ..._nh
* Rename ALL_NEXTHOPS_RO to ALL_NEXTHOPSßingen2017-07-101-1/+1
|
* Allow for more than 1 NH recursion levelßingen2017-06-281-4/+3
| | | | | | Before, only one level of recursive resolution was supported. Signed-off-by: ßingen <bingen@voltanet.io>
* zebra: Refactor 'struct rib' to be 'struct route_entry'Donald Sharp2017-06-011-12/+12
| | | | | | | | | | The 'struct rib' data structure is missnamed. It really is a 'struct route_entry' as part of the 'struct route_node'. We have 1 'struct route_entry' per route src. As such 1 route node can have multiple route entries if multiple protocols attempt to install the same route. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>