summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_packet.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* *: 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>
* ospfd: report the router IP with Opaque capability mismatchJafar Al-Gharaibeh2023-01-061-3/+4
| | | | Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
* ospfd: add advertising router IP to Opaque capability mismatch error messageJafar Al-Gharaibeh2022-12-251-2/+2
| | | | | Submitted-by Marc Boucher <marc@airvitesse.net> Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
* ospfd: catch and report runt LSAsLou Berger2022-10-291-0/+6
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* ospf: optimization for FRR's P2MP modeLou Berger2022-10-251-1/+2
| | | | | | | | | | | | | | FRR implements a non-standard, but compatible approach for sending update LSAs (it always send to 224.0.0.5) on P2MP interfaces. This change makes it so acks are also sent to 224.0.0.5. Since the acks are multicast, this allows an optimization where we don't send back out the incoming P2MP interface immediately allow time to rx multicast ack from neighbors on the same net that rx'ed the original (multicast) update. Signed-off-by: Lou Berger <lberger@labn.net>
* ospfd: changes for code maintainabilitysri-mohan12022-08-251-37/+37
| | | | | | these changes are for improving the code maintainability Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
* ospfd: Cleanup indentation surrounding oi->nbrDonald Sharp2022-08-111-99/+88
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* ospfd: Increase packets sent at one time in ospf_writeDonald Sharp2022-08-111-11/+2
| | | | | | | | | | | | | | ospf_write pulls an interface off the ospf->oi_write_q then writes one packet and places it back on the queue, keeping track of the first one sent. Then it will stop sending packets even if we get back to the first interface written too but before we have sent the full pkt_count. I do not believe this makes a whole bunch of sense and is very restrictive of how much data can be sent especially if you have a limited number of peers but large amounts of data. Why be so restrictive? Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* ospfd: Convert thread_cancel to THREAD_OFFDonald Sharp2022-07-211-1/+1
| | | | | | Just convert all uses of thread_cancel to THREAD_OFF. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* ospfd: Remove various macros that overlap THREAD_OFFDonald Sharp2022-07-211-1/+1
| | | | | | | | 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>
* *: Properly use memset() when zeroingDonatas Abraitis2022-05-111-2/+2
| | | | | | | Wrong: memset(&a, 0, sizeof(struct ...)); Good: memset(&a, 0, sizeof(a)); Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* *: Fix spelling of accomodateDonald Sharp2022-04-191-3/+3
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Fix spelling of atleastDonald Sharp2022-04-191-1/+1
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Change thread->func to return void instead of intDonald Sharp2022-02-241-29/+11
| | | | | | | 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>
* *: cleanup ifp->vrf_idIgor Ryzhov2021-11-221-1/+1
| | | | | | | Since f60a1188 we store a pointer to the VRF in the interface structure. There's no need anymore to store a separate vrf_id field. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* *: Cleanup some documentation from quagga->frrDonald Sharp2021-11-111-1/+1
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* Merge pull request #9368 from donaldsharp/ospf_ensure_lsa_lengthIgor Ryzhov2021-10-291-12/+12
|\ | | | | ospfd: Ensure we have some non header lsa data
| * ospfd: Add some small doc to what each one is for future peopleDonald Sharp2021-09-141-12/+12
| | | | | | | | | | | | | | | | min lsa packet sizes are not always directly corresponding to the actual LSA. Add a bit of comments so it's easier for future people to figure out. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
| * ospfd: Ensure we have some non header lsa dataDonald Sharp2021-09-141-3/+3
| | | | | | | | | | | | | | | | | | In some cases FRR is receiving a lsa data packet with a length set to the length of the header only. If we are expecting data from a peer in the form of lsa data. Let's enforce it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | Merge pull request #9813 from opensourcerouting/ospf-gr-fixesDonald Sharp2021-10-151-31/+33
|\ \ | | | | | | ospfd: more GR fixes
| * | ospfd: fix another DR election issue during graceful restartRenato Westphal2021-10-121-31/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 3551ee9e90304 introduced a regression that causes GR to fail under certain circumstances. In short, while ISM events should be ignored while acting as a helper for a restarting router, the DR/BDR fields of the neighbor structure should still be updated while processing a Hello packet. If that isn't done, it can cause the helper to elect the wrong DR while exiting from the helper mode, leading to a situation where there are two DRs for the same network segment (and a failed GR by consequence). Fix this. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* | | Merge pull request #9795 from opensourcerouting/ospf_get_nameIgor Ryzhov2021-10-141-8/+5
|\ \ \ | |/ / |/| | ospfd: use ospf_get_name() wherever possible
| * | ospfd: use ospf_get_name() wherever possibleRenato Westphal2021-10-101-8/+5
| | | | | | | | | | | | | | | | | | Small cleanup to reduce code duplication. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* | | Merge pull request #9781 from opensourcerouting/ospfd-gr-dr-fixRuss White2021-10-121-0/+15
|\ \ \ | |/ / |/| | ospfd: preserve DR status across graceful restarts
| * | ospfd: preserve DR status across graceful restartsRenato Westphal2021-10-081-0/+15
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RFC 3623 says: "If the restarting router determines that it was the Designated Router on a given segment prior to the restart, it elects itself as the Designated Router again. The restarting router knows that it was the Designated Router if, while the associated interface is in Waiting state, a Hello packet is received from a neighbor listing the router as the Designated Router". Implement that logic when processing Hello messages to ensure DR interfaces will preserve their DR status across a graceful restart. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* / ospfd: ospf nbr in full although mismatch in hello packet contentsMobashshera Rasool2021-10-061-13/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | Issue: =================== OSPF neighbors are not going down even after 10 mins when having a mismatch in hello and dead interval. First neighbors are formed and then a mismatch in the interval is created, it is observed that the neighbor is not going down. Root Cause Analysis: ==================== The event HelloReceived defined in RFC 2328 was named as PacketReceived and this event was scheduled whenever LS Update, LS Ack, LS Request, DD description packet or Hello packet is received. Although there is a mismatch in the Hello packet contents, the event PacketReceived gets triggered due to LS Update received and the dead timer gets reset and hence the neighbor was never going Down and remains FULL. Fix: ================== As per RFC 2328, the HelloReceived needs to be triggered only when valid OSPF Hello packet is received and not when other OSPF packets are received. Modified the function name as well. Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
* Merge pull request #9551 from mobash-rasool/ospfv2-bug-fixes-04Russ White2021-09-071-0/+19
|\ | | | | ospfd: GR Conformance fix in Hello packet DR election
| * ospfd: GR Conformance fix for Hello packet DR electionMobashshera Rasool2021-09-031-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem Statement: =================== DUT selecting itself as DR when RR goes for reload. Test Case 7.2 DUT (GR Helper) receives the Hello packet from the OSPF GR RESTARTER (ANVL here) with DR and BDR set to 0.0.0.0 and DUT in its hello neighbor list. DUT triggers the DR and BDR election although it is in the Helper mode for that neighbor. Root Cause Analysis: ==================== When hello packet is received with self router ID in the neighbor list, there is no check in the code to handle this scenario. Hence the DR/BDR election happens and it changes the DR although it is helper. Fix: =================== As per RFC 3623 Section 3. Operation of Helper Neighbor, below point, we need to maintain the DR relationship. Also, if X was the Designated Router on network segment S when the helping relationship began, Y maintains X as the Designated Router until the helping relationship is terminated. Adding the check when DUT is under neighbor helper mode, we need to avoid ISM state change when hello packet is received with DR/BDR set to 0.0.0.0. Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
* | ospfd: RFC conformance test case 25.23 issue fixMobashshera Rasool2021-09-031-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem Statement : =================== LSA with InitialSequenceNumber is not originated after MaxSequenceNumber. ANVL Test case 25.33 states: ============================ As soon as this flooding of a LSA with LS sequence number MaxSequenceNumber has been acknowledged by all adjacent neighbors, a new instance can be originated with sequence number of InitialSequenceNumber. RCA : ===== DUT did not originated LSA with INITIAL_SEQUENCE number even after receiving ACK for max sequence LSA. Code is not present to handle this situation in the lsa ack flow. Fix : ===== Add code to originate LSA with initial sequence number in the LSA ack flow in case of wrap around sequence number. Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
* | ospfd: ANVL Test case 25.22, 25.23 and 28.11 fixesMobashshera Rasool2021-09-031-4/+4
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ANVL Test case 28.11 If the database copy has LS age equal to MaxAge and LS sequence number equal to MaxSequenceNumber, simply discard the received LSA without acknowledging it. ANVL Test Case 25.22 When an attempt is made to increment the sequence number past the maximum value of N - 1 (0x7fffffff; also referred to as MaxSequenceNumber), the current instance of the LSA must first be flushed from the routing domain. ANVL Test Case 25.23 As soon as this flooding of a LSA with LS sequence number MaxSequenceNumber has been acknowledged by all adjacent neighbors, a new instance can be originated with sequence number of InitialSequenceNumber. RCA: When IXIA sent LS Seq num as MAX and LS Age as (MAX - 3), DUT dropped the packet instead of sending ACK. In function ospf_ls_upd, at Line 2106 the code is there to drop the LSA. Hence its failing. Fix: LSAs ACK must be sent when received LSA is having max sequence number but not max-aged. Considering /* CVE-2017-3224 */ issue, have corrected the existing code to prevent attacker from sending LSAs with max sequence number and higher checksum and blocking the flooding of the Max-sequence numbered LSAs. Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
* ospfd: introduce support for Graceful Restart (restarting mode)Renato Westphal2021-07-051-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RFC 3623 specifies the Graceful Restart enhancement to the OSPF routing protocol. This PR implements support for the restarting mode, whereas the helper mode was implemented by #6811. This work is based on #6782, which implemented the pre-restart part and settled the foundations for the post-restart part (behavioral changes, GR exit conditions, and on-exit actions). Here's a quick summary of how the GR restarting mode works: * GR can be enabled on a per-instance basis using the `graceful-restart [grace-period (1-1800)]` command; * To perform a graceful shutdown, the `graceful-restart prepare ospf` EXEC-level command needs to be issued before restarting the ospfd daemon (there's no specific requirement on how the daemon should be restarted); * `graceful-restart prepare ospf` will initiate the graceful restart for all GR-enabled instances by taking the following actions: o Flooding Grace-LSAs over all interfaces o Freezing the OSPF routes in the RIB o Saving the end of the grace period in non-volatile memory (a JSON file stored in `$frr_statedir`) * Once ospfd is started again, it will follow the procedures described in RFC 3623 until it detects it's time to exit the graceful restart (either successfully or unsuccessfully). Testing done: * New topotest featuring a multi-area OSPF topology (including stub and NSSA areas); * Successful interop tests against IOS-XR routers acting as helpers. Co-authored-by: GalaxyGorilla <sascha@netdef.org> Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ospfd: rename the graceful restart headerRenato Westphal2021-07-051-1/+1
| | | | | | | | | Both the GR helper code and the upcoming GR restarting code are going to share a lot of definitions. As such, rename ospf_gr_helper.h to ospf_gr.h, which will be the central point of all GR definitions and prototypes. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ospfd: adjust log config for GRGalaxyGorilla2021-07-051-1/+1
| | | | | | | | | | | | | | Remove previous log config debug ospf graceful-restart helper and just use debug ospf graceful-restart for everything related to OSPF GR. Signed-off-by: GalaxyGorilla <sascha@netdef.org>
* ospfd: print extra LSA information in some log messagesRenato Westphal2021-07-051-5/+4
| | | | | | | | | | | | Log the LSA advertising router in addition to the LSA type and ID in the places where that information is necessary to uniquely identify the LSA in the LSDB. This is useful, for example, to know exactly which LSA has changed when the router is exiting from the GR helper mode when a topology change was detected. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ospfd: fix wrong NSSA debug guardsRenato Westphal2021-06-081-1/+1
| | | | | | | Fix usage of NSSA debug guards in code paths that have nothing to do with NSSA areas. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* zebra, ospfd: fix typos in the graceful restart codeRenato Westphal2021-06-081-3/+3
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ospfd: Use _func__ instead of __PRETTY_FUNCTION__Donald Sharp2021-05-121-1/+1
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* ospfd: Suppress spurious write message when using ip nhrp map multicastReuben Dowle2021-04-051-1/+7
| | | | | | | | When ip nhrp map multicast is being used, this is usually accompanied by an iptables rule to block the original multicast packet. This causes sendmsg to return EPERM. Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
* ospfd: changes for PMP network /32 prefix lengthAmol Lad2021-04-051-1/+9
| | | | | | Operation with PMP network on /32 prefix is needed for DMVPN Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
* ospfd: Convert to using proper string formattingDonald Sharp2021-03-101-44/+15
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* ospfd: Prevent duplicate packet read in certain vrf situationsDonald Sharp2021-02-111-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently if the sysctl net.ipv4.raw_l3mdev_accept is 1, packets destined to a specific vrf also end up being delivered to the default vrf. We will see logs like this in ospf: 2021/02/10 21:17:05.245727 OSPF: ospf_recv_packet: fd 20(default) on interface 1265(swp1s1.26) 2021/02/10 21:17:05.245740 OSPF: Hello received from [9.9.36.12] via [swp1s1.26:200.254.26.13] 2021/02/10 21:17:05.245741 OSPF: src [200.254.26.14], 2021/02/10 21:17:05.245743 OSPF: dst [224.0.0.5] 2021/02/10 21:17:05.245769 OSPF: ospf_recv_packet: fd 45(vrf1036) on interface 1265(swp1s1.26) 2021/02/10 21:17:05.245774 OSPF: Hello received from [9.9.36.12] via [swp1s1.26:200.254.26.13] 2021/02/10 21:17:05.245775 OSPF: src [200.254.26.14], 2021/02/10 21:17:05.245777 OSPF: dst [224.0.0.5] This really really makes ospf unhappy in the vrf we are running in. I am approaching the problem by just dropping the packet if read in the default vrf because of: commit 0556fc33c7275c2a3b00047a536976f8dbf7cbb3 Author: Donald Sharp <sharpd@cumulusnetworks.com> Date: Fri Feb 1 11:54:59 2019 -0500 lib: Allow bgp to always create a listen socket for the vrf Effectively if we have `router ospf vrf BLUE` but no ospf running in the default vrf, we will not have a listener and that would require a fundamental change in our approach to handle the ospf->fd at a global level. I think this is less than ideal at the moment but it will get us moving again and allow FRR to work with a bunch of vrf's and ospf neighbors. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* * : update signature of thread_cancel apiMark Stapp2020-10-231-5/+1
| | | | | | | | Change thread_cancel to take a ** to an event, NULL-check before dereferencing, and NULL the caller's pointer. Update many callers to use the new signature. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* ospfd: replace inet_ntoaMark Stapp2020-10-221-141/+141
| | | | | | Stop using inet_ntoa, use %pI4 etc or inet_ntop instead Signed-off-by: Mark Stapp <mjs@voltanet.io>
* ospfd: GR Helper functionality changesrgirada2020-09-221-1/+17
| | | | | | | | | Description: 1. Skipping inactivity timer during graceful restart to make the RESTARTER active even after dead timer expiry. 2. Handling HELPER on unplanned outages. Signed-off-by: Rajesh Girada <rgirada@vmware.com>
* ospfd: make proactive ARP configurableJakub Urbańczyk2020-08-201-1/+1
| | | | | | | | | OSPFD sends ARP proactively to speed up convergence for /32 networks on a p2p connection. It is only an optimization, so it can be disabled. It is enabled by default. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
* ospfd: send ARP requests using zebraJakub Urbańczyk2020-08-121-12/+2
| | | | Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
* *: un-split strings across linesDavid Lamparter2020-07-141-45/+21
| | | | | | | | | | | | | | | | | Remove mid-string line breaks, cf. workflow doc: .. [#tool_style_conflicts] For example, lines over 80 characters are allowed for text strings to make it possible to search the code for them: please see `Linux kernel style (breaking long lines and strings) <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_ and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_. Scripted commit, idempotent to running: ``` python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'` ``` Signed-off-by: David Lamparter <equinox@diac24.net>
* Merge pull request #6218 from qlyoung/fix-ospf-router-lsa-missing-length-checkOlivier Dugeon2020-04-141-17/+23
|\ | | | | ospfd: router LSA link info missing length check
| * ospfd: router LSA link info missing length checkQuentin Young2020-04-141-17/+23
| | | | | | | | | | | | | | | | Fix - Modulo check on data length not inclusive enough - Garbage heap read when bounds checking Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* | ospfd: fix uaf upon rx of self-originated lsaQuentin Young2020-04-141-2/+2
|/ | | | | | | | ospf_opaque_self_originated_lsa_received decrements refcount which can result in a free, this is followed by a call to ospf_ls_ack_send which accesses the freed LSA Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>