summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_nht.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* bgpd: fix do re-send post-policy bgp update when not validPhilippe Guibert2024-12-301-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a BGP listener configured with BMP receives the first BGP IPv6 update from a connected BGP IPv6 peer, the BMP collector receives a withdraw post-policy message. > {"peer_type": "route distinguisher instance", "policy": "post-policy", > "ipv6": true, "peer_ip": "192:167::3", "peer_distinguisher": "444:1", > "peer_asn": 65501, "peer_bgp_id": "192.168.1.3", "timestamp": > "2024-10-29 11:44:47.111962", "bmp_log_type": "withdraw", "afi": 2, > "safi": 1, "ip_prefix": "2001::1125/128", "seq": 22} > {"peer_type": "route distinguisher instance", "policy": "pre-policy", > "ipv6": true, "peer_ip": "192:167::3", "peer_distinguisher": "444:1", > "peer_asn": 65501, "peer_bgp_id": "192.168.1.3", "timestamp": > "2024-10-29 11:44:47.111963", "bmp_log_type": "update", "origin": > "IGP", "as_path": "", "afi": 2, "safi": 1, "nxhp_ip": "192:167::3", > "nxhp_link-local": "fe80::7063:d8ff:fedb:9e11", "ip_prefix": "2001::1125/128", "seq": 23} Actually, the BGP update is not valid, and BMP considers it as a withdraw message. The BGP upate is not valid, because the nexthop reachability is unknown at the time of reception, and no other BMP message is sent. Fix this by re-sending a BMP post update message when nexthop tracking becomes successfull. Generalise the re-sending of messages when nexthop tracking changes. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* bgpd: move l3nhg functions in separate bgp_nhg.[ch] filePhilippe Guibert2023-12-111-6/+0
| | | | | | | | This rework separates l3nhg functionality from the nexthop tracking code, by introducing two bgp_nhg.[ch] files. The calling functions are renamed from bgp_l3nhg* to bgp_nhg*. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* bgpd: use `zclient->nexthop_update`David Lamparter2023-11-201-2/+3
| | | | | | Same as before. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: auto-convert to SPDX License IDsDavid Lamparter2023-02-091-16/+1
| | | | | | Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: prevent routes loop through itselfPhilippe Guibert2021-07-121-1/+2
| | | | | | | | | | | | | | | | Some BGP updates received by BGP invite local router to install a route through itself. The system will not do it, and the route should be considered as not valid at the earliest. This case is detected on the zebra, and this detection prevents from trying to install this route to the local system. However, the nexthop tracking mechanism is called, and acts as if the route was valid, which is not the case. By detecting in BGP that use case, we avoid installing the invalid routes. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* bgpd: EVPN route type-5 to type-2 recursive resolution using gateway IPAmeya Dharkar2021-06-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When EVPN prefix route with a gateway IP overlay index is imported into the IP vrf at the ingress PE, BGP nexthop of this route is set to the gateway IP. For this vrf route to be valid, following conditions must be met. - Gateway IP nexthop of this route should be L3 reachable, i.e., this route should be resolved in RIB. - A remote MAC/IP route should be present for the gateway IP address in the EVI(L2VPN table). To check for the first condition, gateway IP is registered with nht (nexthop tracking) to receive the reachability notifications for this IP from zebra RIB. If the gateway IP is reachable, zebra sends the reachability information (i.e., nexthop interface) for the gateway IP. This nexthop interface should be the SVI interface. Now, to find out type-2 route corresponding to the gateway IP, we need to fetch the VNI for the above SVI. To do this VNI lookup effitiently, define a hashtable of struct bgpevpn with svi_ifindex as key. struct hash *vni_svi_hash; An EVI instance is added to vni_svi_hash if its svi_ifindex is nonzero. Using this hash, we obtain struct bgpevpn corresponding to the gateway IP. For gateway IP overlay index recursive lookup, once we find the correct EVI, we have to lookup its route table for a MAC/IP prefix. As we have to iterate the entire route table for every lookup, this lookup is expensive. We can optimize this lookup by adding all the remote IP addresses in a hash table. Following hash table is defined for this purpose in struct bgpevpn Struct hash *remote_ip_hash; When a MAC/IP route is installed in the EVI table, it is also added to remote_ip_hash. It is possible to have multiple MAC/IP routes with the same IP address because of host move scenarios. Thus, for every address addr in remote_ip_hash, we maintain list of all the MAC/IP routes having addr as their IP address. Following structure defines an address in remote_ip_hash. struct evpn_remote_ip { struct ipaddr addr; struct list *macip_path_list; }; A Boolean field is added to struct bgp_nexthop_cache to indicate that the nexthop is EVPN gateway IP overlay index. bool is_evpn_gwip_nexthop; A flag BGP_NEXTHOP_EVPN_INCOMPLETE is added to struct bgp_nexthop_cache. This flag is set when the gateway IP is L3 reachable but not yet resolved by a MAC/IP route. Following table explains the combination of L3 and L2 reachability w.r.t. BGP_NEXTHOP_VALID and BGP_NEXTHOP_EVPN_INCOMPLETE flags * | MACIP resolved | MACIP unresolved *----------------|----------------|------------------ * L3 reachable | VALID = 1 | VALID = 0 * | INCOMPLETE = 0 | INCOMPLETE = 1 * ---------------|----------------|-------------------- * L3 unreachable | VALID = 0 | VALID = 0 * | INCOMPLETE = 0 | INCOMPLETE = 0 Procedure that we use to check if the gateway IP is resolvable by a MAC/IP route: - Find the EVI/L2VRF that belongs to the nexthop SVI using vni_svi_hash. - Check if the gateway IP is present in remote_ip_hash in this EVI. When the gateway IP is L3 reachable and it is also resolved by a MAC/IP route, unset BGP_NEXTHOP_EVPN_INCOMPLETE flag and set BGP_NEXTHOP_VALID flag. Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
* bgpd: Address LL peer not NHT when receiving connection attemptDonald Sharp2021-04-151-1/+1
| | | | | | | | | | | | | | | The new LL code in: 8761cd6ddb5437767625f58c8e9cc3ccda7887ab Introduced the idea of the bgp unnumbered peers using interface up/down events to track the bgp peers nexthop. This code was not properly working when a connection was received from a peer in some circumstances. Effectively the connection from a peer was immediately skipping state transitions and FRR was never properly tracking the peers nexthop. When we receive the connection attempt, let's track the nexthop now. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* bgpd: Switch LL nexthop tracking to be interface basedDonald Sharp2021-02-171-0/+4
| | | | | | | | | | | | | | | | | | | | bgp is currently registering v6 LL as nexthops to be tracked from zebra. This presents several problems. a) zebra does not properly track multiple prefixes that match the same route properly at this point in time. b) BGP was receiving nexthops that were just incorrect because of (a). c) When a nexthop changed that really didn't affect the v6 LL we were responding incorrectly because of this Modify the code such that bgp nexthop tracking notices that we are trying to register a v6 LL. When we do so, shortcut and watch interface up/down events for this v6 LL and do the work when an interface goes up / down for this type of tracking. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* bgpd: make sure nh is valid for MPLS vpn routesPat Ruddy2021-01-271-2/+3
| | | | | | | | | | If we are using a nexthop for a MPLS VPN route make sure the nexthop is over a labeled path. This new check mirrors the one in validate_paths (where routes are enabled when a nexthop becomes reachable). The check is introduced to the code path where routes are added and the nexthop is looked up. Signed-off-by: Pat Ruddy <pat@voltanet.io>
* bgpd: L3NHG infrastructure for host routes in EVPNAnuradha Karuppiah2020-11-241-0/+6
| | | | | | | | | | | | | | | | | ES-VRF entries are maintained for the purpose of L3-NHG creation - 1. Each ES-EVI entry is associated with a tenant VRF. This associaton triggers the creation of an ES-VRF entry. 2. Type-2/MAC-IP routes are imported into a tenant VRF and programmed as a /32 or host route entry in the dataplane. If the destination of the host route is a remote-ES the route is programmed with the corresponding (keyed in by {vrf,ES-id}) L3-NHG. 3. The reason for this indirection (route->L3-NHG, L3-NHG->list-of-VTEPs) is to avoid route updates to the dplane when a remote-ES link flaps i.e. instead of updating all the dependent routes the NHG's contents are updated. This reduces the amount of dataplane updates (fewer nhg updates vs. route updates) allowing for a faster failover. Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
* bgpd: turn off RAs when numbered peers are deletedDon Slice2020-04-271-1/+2
| | | | | | | | | | | Problem reported that in many circumstances, RAs created in the process of bringing up numbered IPv6 peers with extended-nexthop capability enabled (for ipv4 over ipv6) were not stopped on the interface when those peers were deleted. Found several circumstances where this occurred and fix them in this patch. Ticket: CM-26875 Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
* bgpd: Remove not used bgp_find_nexthop() functionDonatas Abraitis2019-11-081-8/+0
| | | | | | Seems like a dead code. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* bgpd: Late registration of Extended Nexthop should allow RA's to happenDonald Sharp2018-11-071-0/+9
| | | | | | | | When we have a late registration of the Extended Nexthop capability for BGP and the peer already has nexthop information stored, go through and enable RA on the important interfaces. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd: Allow registration of nexthops after zebra connectionDonald Sharp2018-10-311-0/+6
| | | | | | | | If we attempt to register nexthops before we have the zebra connection, they will not be installed. After we have noticed that we are up, re-install them. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd: Fix crash when using v4 route w/ v6 nexthopDonald Sharp2018-10-171-0/+7
| | | | | | | | | | | | | Recent changes to the nht code in bgp caused us to actually keep a true count of v6 nexthop paths when using v4 over v6. This change introduced a race condition on shutdown on who got to the bnc cache first( the v4 table or not ). Effectively we were allowing the continued existence of the path->nexthop pointing to the freed bnc. This was especially true when we had route leaking. So when we free the bnc make sure we clean up the path->nexthop variables pointing at it too. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd: Convert `struct bgp_info` to `struct bgp_path_info`Donald Sharp2018-10-091-5/+6
| | | | | | | | | | | | Do a straight conversion of `struct bgp_info` to `struct bgp_path_info`. This commit will setup the rename of variables as well. This is being done because `struct bgp_info` is not descriptive of what this data actually is. It is path information for routes that we keep to build the actual routes nexthops plus some extra information. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd: nexthop tracking with labels for vrf-vpn leakingG. Paul Ziemba2018-04-041-3/+5
| | | | | | | | | | | | | | | Routes that have labels must be sent via a nexthop that also has labels. This change notes whether any path in a nexthop update from zebra contains labels. If so, then the nexthop is valid for routes that have labels. If a nexthop update has no labeled paths, then any labeled routes referencing the nexthop are marked not valid. Add a route flag BGP_INFO_ANNC_NH_SELF that means "advertise myself as nexthop when announcing" so that we can track our notion of the nexthop without revealing it to peers. Signed-off-by: G. Paul Ziemba <paulz@labn.net>
* bgpd: Cleanup NHT state when underlying VRF goes downvivek2017-08-171-0/+6
| | | | | | | | | | | | | | | When the underlying VRF is deleted, ensure that state for the next hops that BGP registers with zebra for tracking purposes is properly updated. Otherwise BGP will not re-register the next hop when the VRF is re-created, resulting in the next hop staying unresolved. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Don Slice <dslice@cumulusnetworks.com> Ticket: CM-17456 Reviewed By: CCR-6587 Testing Done: Manual, bgp-min, vrf
* *: reindentreindent-master-afterwhitespace / reindent2017-07-171-4/+4
| | | | | | indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: make consistent & update GPLv2 file headersDavid Lamparter2017-05-151-4/+3
| | | | | | | | | | | The FSF's address changed, and we had a mixture of comment styles for the GPL file header. (The style with * at the beginning won out with 580 to 141 in existing files.) Note: I've intentionally left intact other "variations" of the copyright header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: bgp_nexthop_cache not deleted with peersPaul Jakma2016-10-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | * Fix mild leak, bgp_nexthop_caches were not deleted when their peer was. Not a huge one, but makes valgrinding for other leaks noisier. Credit to Lou Berger <lberger@labn.net> for doing the hard work of debugging and pinning down the leak, and supplying an initial fix. That one didn't quite get the refcounting right, it seemed, hence this version. This version also keeps bncs pinned so long as the peer is defined, where Lou's tried to delete whenever the peer went through bgp_stop. That causes lots of zebra traffic if down peers go Active->Connect->Active, etc., so leaving bnc's in place until peer_delete seemed better. * bgp_nht.c: (bgp_unlink_nexthop_by_peer) similar to bgp_unlink_nexthop, but by peer. * bgp_nht.c: (bgp_unlink_nexthop_check) helper to consolidate checking if a bnc should be deleted. (bgp_unlink_nexthop_by_peer) ensure the bnc->nht_info peer reference is removed, and hence allow bncs to be removed by previous. * bgpd.c: (peer_delete) cleanup the peer's bnc.
* BGP: VRF registration and cleanupvivek2016-02-121-2/+0
| | | | | | | | | | | | | | | | | | Various changes and fixes related to VRF registration, deletion, BGP exit etc. - Define instance type - Ensure proper handling upon instance create, delete and VRF add/delete from zebra - Cleanup upon bgp_exit() - Ensure messages are not sent to zebra for unknown VRFs Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Ticket: CM-9128, CM-7203 Reviewed By: CCR-4098 Testing Done: Manual
* bgpd: Add the ability to use a VRF to bgpDonald Sharp2016-02-021-1/+1
| | | | Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
* *: add VRF ID in the API message headerFeng Lu2015-11-041-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The API messages are used by zebra to exchange the interfaces, addresses, routes and router-id information with its clients. To distinguish which VRF the information belongs to, a new field "VRF ID" is added in the message header. And hence the message version is increased to 3. * The new field "VRF ID" in the message header: Length (2 bytes) Marker (1 byte) Version (1 byte) VRF ID (2 bytes, newly added) Command (2 bytes) - Client side: - zclient_create_header() adds the VRF ID in the message header. - zclient_read() extracts and validates the VRF ID from the header, and passes the VRF ID to the callback functions registered to the API messages. - All relative functions are appended with a new parameter "vrf_id", including all the callback functions. - "vrf_id" is also added to "struct zapi_ipv4" and "struct zapi_ipv6". Clients need to correctly set the VRF ID when using the API functions zapi_ipv4_route() and zapi_ipv6_route(). - Till now all messages sent from a client have the default VRF ID "0" in the header. - The HELLO message is special, which is used as the heart-beat of a client, and has no relation with VRF. The VRF ID in the HELLO message header will always be 0 and ignored by zebra. - Zebra side: - zserv_create_header() adds the VRF ID in the message header. - zebra_client_read() extracts and validates the VRF ID from the header, and passes the VRF ID to the functions which process the received messages. - All relative functions are appended with a new parameter "vrf_id". * Suppress the messages in a VRF which a client does not care: Some clients may not care about the information in the VRF X, and zebra should not send the messages in the VRF X to those clients. Extra flags are used to indicate which VRF is registered by a client, and a new message ZEBRA_VRF_UNREGISTER is introduced to let a client can unregister a VRF when it does not need any information in that VRF. A client sends any message other than ZEBRA_VRF_UNREGISTER in a VRF will automatically register to that VRF. - lib/vrf: A new utility "VRF bit-map" is provided to manage the flags for VRFs, one bit per VRF ID. - Use vrf_bitmap_init()/vrf_bitmap_free() to initialize/free a bit-map; - Use vrf_bitmap_set()/vrf_bitmap_unset() to set/unset a flag in the given bit-map, corresponding to the given VRF ID; - Use vrf_bitmap_check() to test whether the flag, in the given bit-map and for the given VRF ID, is set. - Client side: - In "struct zclient", the following flags are changed from "u_char" to "vrf_bitmap_t": redist[ZEBRA_ROUTE_MAX] default_information These flags are extended for each VRF, and controlled by the clients themselves (or with the help of zclient_redistribute() and zclient_redistribute_default()). - Zebra side: - In "struct zserv", the following flags are changed from "u_char" to "vrf_bitmap_t": redist[ZEBRA_ROUTE_MAX] redist_default ifinfo ridinfo These flags are extended for each VRF, as the VRF registration flags. They are maintained on receiving a ZEBRA_XXX_ADD or ZEBRA_XXX_DELETE message. When sending an interface/address/route/router-id message in a VRF to a client, if the corresponding VRF registration flag is not set, this message will not be dropped by zebra. - A new function zread_vrf_unregister() is introduced to process the new command ZEBRA_VRF_UNREGISTER. All the VRF registration flags are cleared for the requested VRF. Those clients, who support only the default VRF, will never receive a message in a non-default VRF, thanks to the filter in zebra. * New callback for the event of successful connection to zebra: - zclient_start() is splitted, keeping only the code of connecting to zebra. - Now zclient_init()=>zclient_connect()=>zclient_start() operations are purely dealing with the connection to zbera. - Once zebra is successfully connected, at the end of zclient_start(), a new callback is used to inform the client about connection. - Till now, in the callback of connect-to-zebra event, all clients send messages to zebra to request the router-id/interface/routes information in the default VRF. Of corse in future the client can do anything it wants in this callback. For example, it may send requests for both default VRF and some non-default VRFs. Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Donald Sharp <sharpd@cumulusnetworks.com> Conflicts: lib/zclient.h lib/zebra.h zebra/zserv.c zebra/zserv.h Conflicts: bgpd/bgp_nexthop.c bgpd/bgp_nht.c bgpd/bgp_zebra.c isisd/isis_zebra.c lib/zclient.c lib/zclient.h lib/zebra.h nhrpd/nhrp_interface.c nhrpd/nhrp_route.c nhrpd/nhrpd.h ospf6d/ospf6_zebra.c ospf6d/ospf6_zebra.h ospfd/ospf_vty.c ospfd/ospf_zebra.c pimd/pim_zebra.c pimd/pim_zlookup.c ripd/rip_zebra.c ripngd/ripng_zebra.c zebra/redistribute.c zebra/rt_netlink.c zebra/zebra_rnh.c zebra/zebra_rnh.h zebra/zserv.c zebra/zserv.h
* bgpd-nht-import-check-fix.patchDonald Sharp2015-05-201-1/+1
| | | | | | | | | | | | | BGP: Fix network import check use with NHT instead of scanner When next hop tracking was implemented and the bgp scanner was eliminated, the "network import-check" command got broken. This patch fixes that issue. NHT is used to not just track nexthops, but also the static routes that are announced as part of BGP's network command. The routes are registered only when import-check is enabled. To optimize performance, we register static routes only when import-check is enabled. Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
* Ensure connected nexthop entry for the peer is freed when the peer is freed.Donald Sharp2015-05-201-0/+10
|
* When internal operations are performed (e.g., best-path selection, next-hopDonald Sharp2015-05-201-2/+3
| | | | | | | | | | | | | | change processing etc.) that refer to the BGP instance, the correct BGP instance must be referenced and not the default BGP instance. The default BGP instance is the first instance on the instance list. In a scenario where one BGP instance is deleted (through operator action such as a "no router bgp" command) and another instance exists or is created, there may still be events in-flight that need to be processed against the deleted instance. Trying to process these against the default instance is erroneous. The calls to bgp_get_default() must be limited to the user interface (vtysh) context. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
* bgpd-nht-connected-route.patchDonald Sharp2015-05-201-10/+6
| | | | | | BGP: Use next hop tracking for connected routes too And cleanup obsolete code in bgp_scan and bgp_import.
* nexthop-tracking.patchDonald Sharp2015-05-201-0/+62
quagga: nexthop-tracking.patch Add next hop tracking support to Quagga. Complete documentation in doc/next-hop-tracking.txt. Signed-off-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com> Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>