summaryrefslogtreecommitdiff
path: root/ospfd/ospf_bfd.c
AgeCommit message (Collapse)Author
2025-04-08ospfd: clean up -Wshadow warningsMark Stapp
Clean up various "shadow" warnings. Signed-off-by: Mark Stapp <mjs@cisco.com>
2023-03-24*: Convert event.h to frrevent.hDonald Sharp
We should probably prevent any type of namespace collision with something else. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert `struct event_master` to `struct event_loop`Donald Sharp
Let's find a better name for it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert struct thread_master to struct event_master and it's ilkDonald Sharp
Convert the `struct thread_master` to `struct event_master` across the code base. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename thread.[ch] to event.[ch]Donald Sharp
This is a first in a series of commits, whose goal is to rename the thread system in FRR to an event system. There is a continual problem where people are confusing `struct thread` with a true pthread. In reality, our entire thread.c is an event system. In this commit rename the thread.[ch] files to event.[ch]. 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>
2022-06-30ospfd: set/unset bfd profileDmitrii Turlupov
Before this patch we can enable 'ip ospf bfd' via '[no] ip ospf bfd profile ...' commads. After patch '[no] ip ospf bfd profile ...' actual only if 'ip ospf bfd' is set. Signed-off-by: Dmitrii Turlupov <dturlupov@factor-ts.ru>
2021-04-22lib: remove enabled flag for bfd sessionsIgor Ryzhov
Currently this flag is only helpful in an extremely rare situation when the BFD session registration was unsuccessful and after that zebra is restarted. Let's remove this flag to simplify the API. If we ever want to solve the problem of unsuccessful registration/deregistration, this can be done using internal flags, without API modification. Also add the error log to help user understand why the BFD session is not working. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-31ospfd: fix building with --disable-bfddIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-23ospfd: fix checkpatch warningsRafael Zalamena
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-03-23ospfd: add debug option for BFDRafael Zalamena
Add specialized debug option for BFD which also enables library debugging. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-03-23ospfd: support BFD profilesRafael Zalamena
Add new command to configure BFD peers to use a specific profile. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-03-23ospfd: rework BFD integrationRafael Zalamena
Use new BFD API to integrate with OSPFv2. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-02-07*: Fix usage of bfd_adj_eventDonald Sharp
Valgrind reports: 469901-==469901== 469901-==469901== Conditional jump or move depends on uninitialised value(s) 469901:==469901== at 0x3A090D: bgp_bfd_dest_update (bgp_bfd.c:416) 469901-==469901== by 0x497469E: zclient_read (zclient.c:3701) 469901-==469901== by 0x4955AEC: thread_call (thread.c:1684) 469901-==469901== by 0x48FF64E: frr_run (libfrr.c:1126) 469901-==469901== by 0x213AB3: main (bgp_main.c:540) 469901-==469901== Uninitialised value was created by a stack allocation 469901:==469901== at 0x3A0725: bgp_bfd_dest_update (bgp_bfd.c:376) 469901-==469901== 469901-==469901== Conditional jump or move depends on uninitialised value(s) 469901:==469901== at 0x3A093C: bgp_bfd_dest_update (bgp_bfd.c:421) 469901-==469901== by 0x497469E: zclient_read (zclient.c:3701) 469901-==469901== by 0x4955AEC: thread_call (thread.c:1684) 469901-==469901== by 0x48FF64E: frr_run (libfrr.c:1126) 469901-==469901== by 0x213AB3: main (bgp_main.c:540) 469901-==469901== Uninitialised value was created by a stack allocation 469901:==469901== at 0x3A0725: bgp_bfd_dest_update (bgp_bfd.c:376) On looking at bgp_bfd_dest_update the function call into bfd_get_peer_info when it fails to lookup the ifindex ifp pointer just returns leaving the dest and src prefix pointers pointing to whatever was passed in. Let's do two things: a) The src pointer was sometimes assumed to be passed in and sometimes not. Forget that. Make it always be passed in b) memset the src and dst pointers to be all zeros. Then when we look at either of the pointers we are not making decisions based upon random data in the pointers. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-22ospfd: replace inet_ntoaMark Stapp
Stop using inet_ntoa, use %pI4 etc or inet_ntop instead Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-22:* Convert prefix2str to %pFXDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-07-10 *: add BFD profile support for IS-ISGalaxyGorilla
BFD profiles can now be used on the interface level like this: interface eth1 ip router isis 1 isis bfd isis bfd profile default Here the 'default' profile needs to be specified as usual in the bfdd configuration. Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2019-10-31ospf: BFD down not tearing down OSPF adjacency for point-to-point networkRadhika Mahankali
Root Cause: Lookup for the point-to-point neighbor was failing because the neighbor lookup was based on neighbor interface IP address. But, for point-to-point neighbor the key is router-id for lookup. Lookup failure was causing the BFD updates from PTM to get dropped. Fix: Added walk of the neighbor list if the network type is point-to-point to find the appropriate neighbor. The match is based on source IP address of the neighbor since that’s the address registered with BFD for monitoring. Ticket: CM-20411 Signed-off-by: Radhika Mahankali <radhika@cumulusnetworks.com>
2019-10-28bfdd: Handling local and remote admin-downSumitAgarwal123
Scenarios where this code change is required: 1. BFD is un-configured from BGP at remote end. Neighbour BFD sends ADMIN_DOWN state, but BFD on local side will send DOWN to BGP, resulting in BGP session DOWN. Removing BFD session administratively shouldn't bring DOWN BGP session at local or remote. 2. BFD is un-configured from BGP or shutdown locally. BFD will send state DOWN to BGP resulting in BGP session DOWN. (This is akin to saying do not use BFD for BGP) Removing BFD session administratively shouldn't bring DOWN BGP session at local or remote. Signed-off-by: Sayed Mohd Saquib sayed.saquib@broadcom.com
2019-05-14bfdd, lib, bgpd: add bfd cbit usagePhilippe Guibert
bfd cbit is a value carried out in bfd messages, that permit to keep or not, the independence between control plane and dataplane. In other words, while most of the cases plan to flush entries, when bfd goes down, there are some cases where that bfd event should be ignored. this is the case with non stop forwarding mechanisms where entries may be kept. this is the case for BGP, when graceful restart capability is used. If BFD event down happens, and bgp is in graceful restart mode, it is wished to ignore the BFD event while waiting for the remote router to restart. The changes take into account the following: - add a config flag across zebra layer so that daemon can set or not the cbit capability. - ability for daemons to read the remote bfd capability associated to a bfd notification. - in bfdd, according to the value, the cbit value is set - in bfdd, the received value is retrived and stored in the bfd session context. - by default, the local cbit announced to remote is set to 1 while preservation of the local path is not set. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07bgp, ospfd, ospf6d, pimd, lib, isisd: add bfd_client_sendmsg vrf_idPhilippe Guibert
vrf_id parameter is added to the api of bfd_client_sendmsg(). this permits being registered to bfd from a separate vrf. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-06Merge pull request #4264 from pguibert6WIND/trace_bfdDonald Sharp
More traces for BFD clients
2019-05-06ospfd: add bfd up event tracePhilippe Guibert
that bfd trace is visible when using 'debug ospf nsm event' command. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-03*: use ZAPI_CALLBACK_ARGS macro for zapi handlersQuentin Young
This macro: - Marks ZAPI callbacks for readability - Standardizes argument names - Makes it simple to add ZAPI arguments in the future - Ensures proper types - Looks better - Shortens function declarations Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-30bgpd/ospfd: make bgp and ospf json response a bit more consistentDon Slice
Problem reported that some bgp and ospf json commands did not return any json output at all if the bgp/ospf instance did not exist. Additionally, some bgp and ospf json commands did not return any json output if the instance existed but no neighbors were defined. This fix makes these commands more consistent in returning empty braces for json output and issue a message if not using json output. Additionally, made the flag "use_json" a bool to make it consistent since previously, it had been defined as an int, char, u_char, and bool at various places. Ticket: CM-21040 Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-08-08bgpd/ospf(6)d/pimd: hide BFD commands with timersRafael Zalamena
Don't show BFD commands with timers since it might confuse users ("show running-config" won't display timers in client daemons anymore), but keep accepting this command from previous configurations. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08bgpd/ospf(6)d/pimd: don't show BFD timersRafael Zalamena
When BFD timers are configured, don't show it anymore in the daemon side. This will help us migrate the timers command from daemons to `bfdd`. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
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>
2017-10-03ospfd: OSPFv2 VRF SupportChirag Shah
Signed-off-by: Chirag Shah <chirag@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-07-13*: ditch vty_outln(), part 1 of 2David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-06-29*: use vty_outlnQuentin Young
Saves 400 lines Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
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-01-23*: use monotime()David Lamparter
This is largely a bulk-replace made with coccinelle. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-09*: coccinelle-replace vty->indexDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-01Merge branch 'stable/2.0'David Lamparter
2016-11-29ospfd: "ip ospf bfd" removes the "ip ospf bfd 3 250 250" commandDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Ticket: CM-13712 (cherry picked from commit 367b138748e894bbfaae36d1cf7c90eafebfebc9) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-09-29ospfd: resolve CHECK ME'sQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-25Expand #defines in command stringsDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23ospfd: add 'int idx_foo' argv index variablesDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23ALIAS removal for bgp, ospf, pim, isis, rip, ripng, lib and zebraDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-22ospfd: argv update for all but ospf_vty.cDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-06-21bfd: Fix for missing BFD client regs/deregs from quagga clientsradhika
Ticket: CM-11256 Signed-off-by: Radhika Mahankali <radhika@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Kanna Rajagopal <kanna@cumulusnetworks.com> Testing: Unit, PTM smoke, OSPF smoke, BGP Smoke Issue: BFD client registrations are not being sent to PTM from BGP/OSPF clients when the quagga clients have no BFD configuration. This can create stale BFD sessions in PTM when BFD is removed from quagga configuration before quagga is restarted. BFD client de-registrations from BGP/OSPF also go missing sometimes when quagga is restarted. This also will cause stale BFD sessions in PTM. Root Cause: BFD client registrations were being sent at the time of BGP/OSPF daemon initialization. But, they were being sent to zebra before the socket connection between zebra and BGP/OSPF was established. This causes the missing BFD client registrations. BFD client de-registrations are sent from zebra when zebra detects socket close for BGP/OSPF daemons. Based on the timing, the de-registrations may happen after socket between PTM and zebra is closed. This will result in missing de-registrations. Fix: Moved sending of BFD client registration messages to zebra connected callback to make sure that they are sent after the BGP/OSPF daemons connect with zebra. Added BFD client de-registrations for BGP/OSPF to be also sent when zebra daemon gets restart signal. They are sent from the signal handler only if it was not already handled in zebra client socket close callback.
2016-05-08zebra - BFD client de-registration supportradhika
CM-10680 Issue: When BGP daemon is stopped, all the BGP BFD sessions are not getting deleted from PTM. Root cause: BGP daemon stop causes BFD de-register message to be sent for every peer on which BFD is enabled. But, all the de-register messages from bgpd to zebra are not processed before the socket close. This results in some stale BGP BFD sessions. Fix: Support for client de-register message has been added in PTM/BFD. Changes in Quagga to support BFD client de-registrations: − The BFD clients de-registration is sent directly from zebra daemon when zebra client (bgpd, ospfd and ospf6d) socket close is detected. − Introduced a BFD flag for the zebra clients to prevent BFD de-registration messages from being sent to zebra daemon when the client is shutting down. This reduces the BFD messaging. CM-10540 Issue: Invalid ptm status “fail” instead of “n/a” being displayed for VRF interfaces. Root cause: ptm status is not being initialized to “unknown” status when VRF interface is added or changed. The uninitialized value is ‘0’ which is the value for “fail” Fix: Initialized the ptm status to the correct value. Signed-off-by: Radhika Mahankali <radhika@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Kanna Rajagopal <kanna@cumulusnetworks.com> Ticket: CM-10680, CM-10540 Reviewed By: CCR-4653 Testing Done: PTM smoke, BGP smoke and ptmd_test.py:TestMultipleAddrsIntfOspfBgp
2016-03-24bgpd, lib, ospfd, ospf6d: Fix bfd interface lookupDonald Sharp
bfd was receiving a callback with an interface name string but was ignoring the passed in vrf to find the ifp pointer. This commit fixes that code path in bfd. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Radhika Mahankali <radhika@cumulusnetworks.com>
2016-03-08Support for multi-client and client reg msgradhika
Ticket: CM-7615, CM-7773 Reviewed By: CCR-3610, CCR-3708 Testing Done: Unit, BGP Smoke and OSPF Smoke Changes (70790261926b17200c8c9377c4576cd3b486fcef) ported from 2.5 Issue (related to CM-7615): 1. CM-7615: There is mismatch in the client name between ptm display of client BFD sessions and the zebra logs. For example, if bgpd added BFD session, zebra logs will show the client as “bgp” but the ptm display will show it as “quagga” 2. Bigger problem is when 2 clients (for example OSPF and BGP) from Quagga register for same BFD session and only one client de-registers the BFD session. This results in BFD session deletion from PTM even though other client still has the BFD registration. Root Cause: Even though BGP, OSPF and OSPF6 are 3 different clients from Quagga that are trying to register/deregister BFD sessions with PTM, all 3 are represented as one client “quagga” from zebra. This makes it hard for PTM/BFD to distinguish between all three when BFD peer registration/deregistration happens from the clients. Fix: Send the actual client name bgp, ospf or ospf6 from zebra with BFD reg/dereg messages instead of one unified client name “quagga” CM-7773: BFD sessions are not getting cleaned from PTM even though no BGP peering exists in Quagga. Root Cause: PTM cleans up stale BFD sessions from a client when it finds a change in seq id advertised by the client. But, if PTM never detects a change in the seq id then the stale BFD sessions never get cleaned up. The test restarts the quagga without saving the configuration, which results in no BGP peering. No BGP peers are registered with PTM after restart and PTM does not detect a client seq id change resulting in stale BFD sessions. Fix: New client registration message was added in PTM. Every client that is interested in BFD monitoring will register with PTM with the client seq id. Client will register with a different seq id (typically pid) every time it restarts. This will help in detecting the change in seq id and cleanup of stale BFD sessions for a client. Code Changes: To support the new client registration message following changes have been made - Added support for client registration messaging in zebra for sending messages to PTM. - Added support for client registration messaging between zebra and clients (BGP, OSPF and OSPF6) in BFD library. - Expanded the reg/de reg peer messaging between zebra and clients to support client specific seq id to distinguish between multiple clients registering for BFD peer rather than one “quagga” client. - Changes in bgpd, ospfd and ospf6d to send client registrations at the time of daemon initialization and on receiving BFD peer replay message.
2015-11-27Merge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga ↵Donald Sharp
into cmaster
2015-11-23Quagga: prefix2str fixupDonald Sharp
During CR for nexthop upstream it was noticed that usage of prefix2str was not consistent. This fixes this problem Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-11-23Should be able to "no" the full text of any config lineDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Ticket: CM-5816
2015-11-03*: add VRF ID in the API message headerFeng Lu
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