summaryrefslogtreecommitdiff
path: root/bgpd/bgp_fsm.h
AgeCommit message (Collapse)Author
2024-10-24bgpd: Fix wrong pthread event cancellingDonald Sharp
0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=130719886083648) at ./nptl/pthread_kill.c:44 1 __pthread_kill_internal (signo=6, threadid=130719886083648) at ./nptl/pthread_kill.c:78 2 __GI___pthread_kill (threadid=130719886083648, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 3 0x000076e399e42476 in __GI_raise (sig=6) at ../sysdeps/posix/raise.c:26 4 0x000076e39a34f950 in core_handler (signo=6, siginfo=0x76e3985fca30, context=0x76e3985fc900) at lib/sigevent.c:258 5 <signal handler called> 6 __pthread_kill_implementation (no_tid=0, signo=6, threadid=130719886083648) at ./nptl/pthread_kill.c:44 7 __pthread_kill_internal (signo=6, threadid=130719886083648) at ./nptl/pthread_kill.c:78 8 __GI___pthread_kill (threadid=130719886083648, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 9 0x000076e399e42476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 10 0x000076e399e287f3 in __GI_abort () at ./stdlib/abort.c:79 11 0x000076e39a39874b in _zlog_assert_failed (xref=0x76e39a46cca0 <_xref.27>, extra=0x0) at lib/zlog.c:789 12 0x000076e39a369dde in cancel_event_helper (m=0x5eda32df5e40, arg=0x5eda33afeed0, flags=1) at lib/event.c:1428 13 0x000076e39a369ef6 in event_cancel_event_ready (m=0x5eda32df5e40, arg=0x5eda33afeed0) at lib/event.c:1470 14 0x00005eda0a94a5b3 in bgp_stop (connection=0x5eda33afeed0) at bgpd/bgp_fsm.c:1355 15 0x00005eda0a94b4ae in bgp_stop_with_notify (connection=0x5eda33afeed0, code=8 '\b', sub_code=0 '\000') at bgpd/bgp_fsm.c:1610 16 0x00005eda0a979498 in bgp_packet_add (connection=0x5eda33afeed0, peer=0x5eda33b11800, s=0x76e3880daf90) at bgpd/bgp_packet.c:152 17 0x00005eda0a97a80f in bgp_keepalive_send (peer=0x5eda33b11800) at bgpd/bgp_packet.c:639 18 0x00005eda0a9511fd in peer_process (hb=0x5eda33c9ab80, arg=0x76e3985ffaf0) at bgpd/bgp_keepalives.c:111 19 0x000076e39a2cd8e6 in hash_iterate (hash=0x76e388000be0, func=0x5eda0a95105e <peer_process>, arg=0x76e3985ffaf0) at lib/hash.c:252 20 0x00005eda0a951679 in bgp_keepalives_start (arg=0x5eda3306af80) at bgpd/bgp_keepalives.c:214 21 0x000076e39a2c9932 in frr_pthread_inner (arg=0x5eda3306af80) at lib/frr_pthread.c:180 22 0x000076e399e94ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442 23 0x000076e399f26850 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81 (gdb) f 12 12 0x000076e39a369dde in cancel_event_helper (m=0x5eda32df5e40, arg=0x5eda33afeed0, flags=1) at lib/event.c:1428 1428 assert(m->owner == pthread_self()); In this decode the attempt to cancel the connection's events from the wrong thread is causing the crash. Modify the code to create an event on the bm->master to cancel the events for the connection. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-06-27bgpd: Streamline GR config, act on change immediatelyvivek
Streamline the BGP graceful-restart configuration at the global and peer level some more. Similar to many other neighbor capability parameters like MP and ENHE, reset the session immediately upon a change to the configuration. This will be more aligned with the transactional UI model also and will not require a separate 'clear' command to be executed. Note: Peer-group graceful-restart configuration is not yet supported. Signed-off-by: Vivek Venkatraman <vivek@nvidia.com>
2024-02-29bgpd: Send "Send Hold Timer Expired" on such events notificationDonatas Abraitis
This is required by the current (latest/-02 draft). IANA has registered code 8 for "Send Hold Timer Expired" in the "BGP Error (Notification) Codes" sub-registry under the "Border Gateway Protocol (BGP) Parameters" registry. https://datatracker.ietf.org/doc/html/draft-ietf-idr-bgp-sendholdtimer Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-01-24bgpd: Fix format overflow for graceful-restart debug logsDonatas Abraitis
Use enum instead of int, and make the compiler happy when using -format-overflow. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-09-10bgpd: Convert bgp_fsm_nht_update to take a connectionDonald Sharp
Convert this function over to using a connection. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-10bgpd: bgp_fsm_change_status/BGP_TIMER_ON and BGP_EVENT_ADDDonald Sharp
Modify bgp_fsm_change_status to be connection oriented and also make the BGP_TIMER_ON and BGP_EVENT_ADD macros connection oriented as well. Attempt to make peer_xfer_conn a bit more understandable because, frankly it was/is confusing. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-10bgpd: make bgp_timer_set use a peer_connection insteadDonald Sharp
The bgp_timer_set function should use a peer_connection pointer instead. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-09bgpd: Remove BGP_EVENT_FLUSH and just use event_cancel_event_readyDonald Sharp
The usage of BGP_EVENT_FLUSH is unnecessarily abstracting the call into event_cancel_event_ready and in addtion the macro was not always being used! Just convert to using the actual event_cancel_event_ready function directly. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-18bgpd: Convert FSM to use `struct peer_connection`Donald Sharp
The BGP FSM was using the peer as the unit of work but the FSM is connection focused. So let's switch it over to using that. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-18bgpd: Convert `struct peer_connection` to dynamically allocatedDonald Sharp
As part of the conversion to a `struct peer_connection` it will be desirable to have 2 pointers one for when we open a connection and one for when we receive a connection. Start this actual conversion over to this in `struct peer`. If this sounds confusing take a look at the bgp state machine for connections and how it resolves the processing of this router opening -vs- this router receiving an open. At some point in time the state machine decides that we are keeping one of the two connections. Future commits will allow us to untangle the peer/doppelganger duality with this abstraction. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-18bgpd: Move status and ostatus to `struct peer_connection`Donald Sharp
The status and ostatus are a function of the `struct peer_connection` move it into that data structure. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-13bgpd: Use enum bgp_fsm_state_progress for bgp_stop()Donatas Abraitis
``` bgpd/bgp_fsm.c:1360:29: warning: conflicting types for ‘bgp_stop’ due to enum/integer mismatch; have ‘enum bgp_fsm_state_progress(struct peer *)’ [-Wenum-int-mismatch] 1360 | enum bgp_fsm_state_progress bgp_stop(struct peer *peer) | ^~~~~~~~ In file included from bgpd/bgp_fsm.c:29: ./bgpd/bgp_fsm.h:111:12: note: previous declaration of ‘bgp_stop’ with type ‘int(struct peer *)’ 111 | extern int bgp_stop(struct peer *peer); | ^~~~~~~~ ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-03-24*: Convert thread_cancelXXX to event_cancelXXXDonald Sharp
Modify the code base so that thread_cancel becomes event_cancel Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_add_XXX functions to event_add_XXXDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename `struct thread` to `struct event`Donald Sharp
Effectively a massive search and replace of `struct thread` to `struct event`. Using the term `thread` gives people the thought that this event system is a pthread when it is not 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-17Revert "bgpd: optimal router reflection cli and fsm changes"Donatas Abraitis
This reverts commit 70cd87ca02125616e9f61f97ab504248c935bd83. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-12-15bgpd: use the enum instead of an intDonald Sharp
The bgp_fsm_change_status function takes an int for the new bgp state, which is an `enum bgp_fsm_status status` let's convert over to being explicit.bgpd: use the enum instead of an int Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-10-12bgpd: optimal router reflection cli and fsm changesMadhuri Kuruganti
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-07-21bgpd: Remove various macros that overlap THREAD_OFFDonald Sharp
Let's just use THREAD_OFF consistently in the code base instead of each daemon having a special macro that needs to be looked at and remembered what it does. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-27bgpd: Rename graceful restart constants for R-bit capabilitiesDonatas Abraitis
Just to better understand what they mean. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-02-23*: Change thread->func to return void instead of intDonald Sharp
The int return value is never used. Modify the code base to just return a void instead. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-04-15bgpd: Address LL peer not NHT when receiving connection attemptDonald Sharp
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>
2021-03-17*: require semicolon after DEFINE_HOOK & co.David Lamparter
See previous commit. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-09libs, bgpd: improve task cancellation by argument valueMark Stapp
Extend the thread_cancel_event api so that it's more complete: look in all the lists of events, including io and timers, for matching tasks. Add a limited version of the api that only examines tasks in the event and ready queues. BGP appears to require the old behavior, so change its macro to use the more limited cancel api. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-11-06bgpd: Advertise FIB installed routes to bgp peers (Part 3)Soman K S
* Process FIB update in bgp_zebra_route_notify_owner() and call group_announce_route() if route is installed * When bgp update is received for a route which is not installed earlier (flag BGP_NODE_FIB_INSTALLED is not set) and suppress fib is enabled set the flag BGP_NODE_FIB_INSTALL_PENDING to indicate fib install is pending for the route. The route will be advertised when zebra send ZAPI_ROUTE_INSTALLED status. * The advertisement delay (BGP_DEFAULT_UPDATE_ADVERTISEMENT_TIME) is added to allow more routes to be sent in single update message. This is required since zebra sends route notify message for each route. The delay will be applied to update group timer which advertises routes to peers. Signed-off-by: kssoman <somanks@gmail.com>
2020-10-23*: unify thread/event cancel macrosMark Stapp
Replace all lib/thread cancel macros, use thread_cancel() everywhere. Only the THREAD_OFF macro and thread_cancel() api are supported. Also adjust thread_cancel_async() to NULL caller's pointer (if present). Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-12*: Use proper semantics for turning off threadDonald Sharp
We have this pattern in the code base: if (thread) THREAD_OFF(thread); If we look at THREAD_OFF we check to see if thread is non-null too. So we have a double check. This is unnecessary. Convert to just using THREAD_OFF Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-17bgpd: rename bgp_fsm_event_updateQuentin Young
This function is poorly named; it's really used to allow the FSM to decide the next valid state based on whether a peer has valid / reachable nexthops as determined by NHT or BFD. Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-03-21bgpd: Convert lots of int type functions to bool/voidDonatas Abraitis
Some were converted to bool, where true/false status is needed. Converted to void only those, where the return status was only false or true. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-20bgpd: Convert #define of bgp fsm events to an enumDonald Sharp
In PR #6052 which fixes issue #5963 the bgp fsm events were confused with the bgp fsm status leading to a bug. Let's start separating those out so these types of failures cannot just easily occur. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-16bgpd: Add subcodes for BGP Finite State Machine ErrorDonatas Abraitis
Implement https://tools.ietf.org/html/rfc6608 I used python scapy library to send a notification message in OpenSent state: ``` send(IP(dst="192.168.0.1")/TCP(sport=sp, dport=179, seq=rec.ack, ack=rec.seq + 1, flags=0x18)/BGPHeader(type=3)/BGPNotification(error_code=4, error_subcode=0)) ``` Logs from FRR: ``` %NOTIFICATION: sent to neighbor 192.168.0.2 5/1 (Neighbor Events Error/Receive Unexpected Message in OpenSent State) 0 bytes ``` Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-04bgpd, lib: fix style from BGP GR codeQuentin Young
This patch fixes the noncompliant style for the following commit range: 4a6e80fbf 2ba1fe695 efcb2ebbb 8c48b3b69 dc95985fe 0f0444fbd 85ef4179a eb451ee58 2d3dd828d 9e3b51a7f d6e3c15b6 34aa74486 6102cb7fe d7b3cda6f 2bb5d39b1 5f9c1aa29 5cce3f054 3a75afa4b f009ff269 cfd47646b 2986cac29 055679e91 034e185dc 794b37d52 b0965c44e 949b0f24f 63696f1d8 Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-01-23bgpd: BGP Garaceful Restart debug logs.bisdhdh
Reorganizing bgp gr debug logs and code review comments. Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23bgpd: Adding Selection Deferral Timer handler changes.bisdhdh
* Selection Deferral Timer for Graceful Restart. * Added selection deferral timer handling function. * Route marking as selection defer when update message is received. * Staggered processing of routes which are pending best selection. * Fix for multi-path test case. Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23bgpd: Adding BGP GR Per Neighbor show commands.bisdhdh
* Added new show command to show the graceful restart information for each neighbor. Cmd: show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart * Changes to show neighbors commands for displaying graceful restart information. Cmd :show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X| Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23bgpd: Adding BGP GR Global & Per Neighbour FSM changesbisdhdh
* Added FSM for peer and global configuration for graceful restart * Added debug option BGP_GRACEFUL_RESTART for logs specific to graceful restart processing Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23bgpd: BGP Graceful Restart Per Neighbor(BGPN), DS & header files.bisdhdh
This pr contains all the header files changes for BGP GR per Neighbour(BGPN) feature. Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2019-12-02*: generously apply constDavid Lamparter
const const const your boat, merrily down the stream... Signed-off-by: David Lamparter <equinox@diac24.net>
2019-08-13bgpd: hook for bgp peer status change eventsMarton Kun-Szabo
Generally available hook for plugging application-specific code in for bgp peer change events. This hook (peer_status_changed) replaces the previous, more specific 'peer_established' hook with a more general-purpose one. Also, 'bgp_dump_state' is now registered under this hook. Signed-off-by: Marton Kun-Szabo <martonk@amazon.com>
2019-04-18bgpd: improve reconnection mechanism by cancelling connect timersPhilippe Guibert
if bfd comes back up, and a bgp reconnection is in progress, theorically it should be necessary to wait for the end of the reconnection process. however, since that reconnection process may take some time, update the fsm by cancelling the connect timer. This done, one just have to call the start timer. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-11-30bgpd: fix bgp_packet.c / bgp_fsm.c organizationQuentin Young
Despaghettification of bgp_packet.c and bgp_fsm.c Sometimes we call bgp_event_update() inline packet parsing. Sometimes we post events instead. Sometimes we increment packet counters in the FSM. Sometimes we do it in packet routines. Sometimes we update EOR's in FSM. Sometimes we do it in packet routines. Fix the madness. bgp_process_packet() is now the centralized place to: - Update message counters - Execute FSM events in response to incoming packets FSM events are now executed directly from this function instead of being queued on the thread_master. This is to ensure that the FSM contains the proper state after each packet is parsed. Otherwise there could be race conditions where two packets are parsed in succession without the appropriate FSM update in between, leading to session closure due to receiving inappropriate messages for the current FSM state. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30bgpd: implement buffered readsQuentin Young
* Move and modify all network input related code to bgp_io.c * Add a real input buffer to `struct peer` * Move connection initialization to its own thread.c task instead of piggybacking off of bgp_read() * Tons of little fixups Primary changes are in bgp_packet.[ch], bgp_io.[ch], bgp_fsm.[ch]. Changes made elsewhere are almost exclusively refactoring peer->ibuf to peer->curr since peer->ibuf is now the true FIFO packet input buffer while peer->curr represents the packet currently being processed by the main pthread. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30bgpd: move packet writes into dedicated pthreadQuentin Young
* BGP_WRITE_ON() removed * BGP_WRITE_OFF() removed * peer_writes_on() added * peer_writes_off() added * bgp_write_proceed_actions() removed Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
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>
2017-05-15*: make consistent & update GPLv2 file headersDavid Lamparter
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>
2017-05-09*: remove THREAD_ON macros, add nullity checkQuentin Young
The way thread.c is written, a caller who wishes to be able to cancel a thread or avoid scheduling it twice must keep a reference to the thread. Typically this is done with a long lived pointer whose value is checked for null in order to know if the thread is currently scheduled. The check-and-schedule idiom is so common that several wrapper macros in thread.h existed solely to provide it. This patch removes those macros and adds a new parameter to all thread_add_* functions which is a pointer to the struct thread * to store the result of a scheduling call. If the value passed is non-null, the thread will only be scheduled if the value is null. This helps with consistency. A Coccinelle spatch has been used to transform code of the form: if (t == NULL) t = thread_add_* (...) to the form thread_add_* (..., &t) The THREAD_ON macros have also been transformed to the underlying thread.c calls. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-03-25*: use hooks for sending SNMP trapsDavid Lamparter
This means there are no ties into the SNMP code anymore other than the init call at startup. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2015-10-14bgpd: fix using of two pointers for struct thread_master *Donald Sharp
Ticket: CM-7861 Reviewed by: CCR-3651 Testing: See bug bgp is using both bm->master and master pointers interchangebly for thread manipulation. Since they are the same thing consolidate to one pointer. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-05-19BGP: Add dynamic update group supportDonald Sharp
This patch implements the 'update-groups' functionality in BGP. This is a function that can significantly improve BGP performance for Update generation and resultant network convergence. BGP Updates are formed for "groups" of peers and then replicated and sent out to each peer rather than being formed for each peer. Thus major BGP operations related to outbound policy application, adj-out maintenance and actual Update packet formation are optimized. BGP update-groups dynamically groups peers together based on configuration as well as run-time criteria. Thus, it is more flexible than update-formation based on peer-groups, which relies on operator configuration. [Note that peer-group based update formation has been introduced into BGP by Cumulus but is currently intended only for specific releases.] From 11098af65b2b8f9535484703e7f40330a71cbae4 Mon Sep 17 00:00:00 2001 Subject: [PATCH] updgrp commits