summaryrefslogtreecommitdiff
path: root/vrrpd/vrrp.c
AgeCommit message (Collapse)Author
2023-11-22*: convert `struct interface->connected` to DLISTDavid Lamparter
Replace `struct list *` with `DLIST(if_connected, ...)`. NB: while converting this, I found multiple places using connected prefixes assuming they were IPv4 without checking: - vrrpd/vrrp.c: vrrp_socket() - zebra/irdp_interface.c: irdp_get_prefix(), irdp_if_start(), irdp_advert_off() (these fixes are really hard to split off into separate commits as that would require going back and reapplying the change but with the old list handling) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-06-13vrrp: check return value for turning off multicast for v6Loganaden Velvindron
CID1519841: check return value and set error Signed-off-by: Loganaden Velvindron <logan@cyberstorm.mu>
2023-03-24*: Convert THREAD_XXX macros to EVENT_XXX macrosDonald Sharp
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-03-21*: Add a hash_clean_and_free() functionDonald Sharp
Add a hash_clean_and_free() function as well as convert the code to use it. This function also takes a double pointer to the hash to set it NULL. Also it cleanly does nothing if the pointer is NULL( as a bunch of code tested for ). Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-17Merge pull request #12780 from opensourcerouting/spdx-license-idDonald Sharp
*: convert to SPDX License identifiers
2023-02-10vrrpd: give null when using null ifp to lookup vrQuentin Young
This is still causing crashes somehow. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.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-11-25vrrpd: add IPv4 pseudoheader option for VRRPv3Siger Yang
This commit adds a new option to control whether a VRRPv3 group accepts / computes its checksum with a prepended IPv4 pseudoheader. This should improve interoperability with other devices. Signed-off-by: Siger Yang <siger.yang@outlook.com>
2022-07-21lib, vrrpd: Use THREAD_ARGDonald Sharp
Don't auto set the thread->arg pointer. It is private and should be only accessed through the THREAD_ARG pointer. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-03*: remove the checking returned value for hash_get()anlan_cs
Firstly, *keep no change* for `hash_get()` with NULL `alloc_func`. Only focus on cases with non-NULL `alloc_func` of `hash_get()`. Since `hash_get()` with non-NULL `alloc_func` parameter shall not fail, just ignore the returned value of it. The returned value must not be NULL. So in this case, remove the unnecessary checking NULL or not for the returned value and add `void` in front of it. Importantly, also *keep no change* for the two cases with non-NULL `alloc_func` - 1) Use `assert(<returned_data> == <searching_data>)` to ensure it is a created node, not a found node. Refer to `isis_vertex_queue_insert()` of isisd, there are many examples of this case in isid. 2) Use `<returned_data> != <searching_data>` to judge it is a found node, then free <searching_data>. Refer to `aspath_intern()` of bgpd, there are many examples of this case in bgpd. Here, <returned_data> is the returned value from `hash_get()`, and <searching_data> is the data, which is to be put into hash table. Signed-off-by: anlan_cs <vic.lan@pica8.com>
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>
2022-02-08*: use ipaddr_cmp instead of memcmpIgor Ryzhov
Using memcmp is wrong because struct ipaddr may contain unitialized padding bytes that should not be compared. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-12-21*: rework renaming the default VRFIgor Ryzhov
Currently, it is possible to rename the default VRF either by passing `-o` option to zebra or by creating a file in `/var/run/netns` and binding it to `/proc/self/ns/net`. In both cases, only zebra knows about the rename and other daemons learn about it only after they connect to zebra. This is a problem, because daemons may read their config before they connect to zebra. To handle this rename after the config is read, we have some special code in every single daemon, which is not very bad but not desirable in my opinion. But things are getting worse when we need to handle this in northbound layer as we have to manually rewrite the config nodes. This approach is already hacky, but still works as every daemon handles its own NB structures. But it is completely incompatible with the central management daemon architecture we are aiming for, as mgmtd doesn't even have a connection with zebra to learn from it. And it shouldn't have it, because operational state changes should never affect configuration. To solve the problem and simplify the code, I propose to expand the `-o` option to all daemons. By using the startup option, we let daemons know about the rename before they read their configs so we don't need any special code to deal with it. There's an easy way to pass the option to all daemons by using `frr_global_options` variable. Unfortunately, the second way of renaming by creating a file in `/var/run/netns` is incompatible with the new mgmtd architecture. Theoretically, we could force daemons to read their configs only after they connect to zebra, but it means adding even more code to handle a very specific use-case. And anyway this won't work for mgmtd as it doesn't have a connection with zebra. So I had to remove this option. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-22*: cleanup ifp->vrf_idIgor Ryzhov
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>
2021-03-17*: require semicolon after DEFINE_MTYPE & coDavid Lamparter
Back when I put this together in 2015, ISO C11 was still reasonably new and we couldn't require it just yet. Without ISO C11, there is no "good" way (only bad hacks) to require a semicolon after a macro that ends with a function definition. And if you added one anyway, you'd get "spurious semicolon" warnings on some compilers... With C11, `_Static_assert()` at the end of a macro will make it so that the semicolon is properly required, consumed, and not warned about. Consistently requiring semicolons after "file-level" macros matches Linux kernel coding style and helps some editors against mis-syntax'ing these macros. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-14*: remove tabs & newlines from log messagesDavid Lamparter
Neither tabs nor newlines are acceptable in syslog messages. They also break line-based parsing of file logs. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-10-15vrrpd: Convert to using %pFXPat Ruddy
Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-07-26vrrpd: Make clang 11 happyDonald Sharp
Recent changes to remove PRIu... in commit: 6cde4b45528e52819c803de92d10d4be3abddf29 causes clang 11 to be unhappy, with length of field warnings. Modify the offending code to compile properly using that compiler. I've tested against clang 11 and gcc 9.3 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-07-14*: remove PRI[udx](8|16|32)David Lamparter
These are completely pointless and break coccinelle string replacements. Scripted commit, idempotent to running: ``` python3 tools/stringmangle.py --pri8-16-32 `git ls-files | egrep '\.[ch]$'` ``` Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-05vrrpd: search all vr's for mvl_ifp to nullQuentin Young
Previous patch was not sufficient to make sure the pointers get nulled. Reason being is that vrrp_lookup_by_if_mvl() follows the link_ifindex on the provided interface to acquire the base ifp, which is then used to lookup the VR. However, because FRR's interface management is straight up insane, it's possible that we delete the base interface before its children. When this happens, link_ifindex is still valid for the macvlan device but we have no interface corresponding to that ifindex, so our lookup will fail. Consequently vrrp_lookup_by_if_mvl() can't be used if we are handling deletion of any sort. Instead we have to loop through every VR and check the pointers. Also, there's no null check on the mvl_ifp pointer in vrrp_shutdown(), and even though we log that we're returning early from it, we actually don't. Do both of these things. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-03-05vrrpd: always null mvl_ifp ptr when mvl is deletedQuentin Young
When we get a deletion notification for the macvlan device, we need to do two things. First, down the VRRP session if it's up. Second, since the mvl device is dynamic (i.e. not explicitly configured by FRR) it will be deleted upon return from the callback, so we need to drop the pointer to it. The checks for the first and second one were one check so the pointer was only nulled when the session was already up, leading to a later heap UAF on the mvl ifp. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-03-04*: Return bool type for bool functionsDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-04*: Use short version of bool expressionsDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-01-07Merge pull request #5314 from qlyoung/yang-vrrpRenato Westphal
VRRP northbound conversion
2019-12-18vrrpd: support namespace vrf tooQuentin Young
-.- Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-12-09vrrpd, yang: cleanup vrrp nb conversionQuentin Young
- Use correct units and conversions in model & code - Fix incorrect CLI help string for V6 virtual addrs - Fix nb get-entry callback for virtual router - Fix a couple style nits - Simplify some CLI code - Remove unused code - Remove unused YANG definitions - Update sighup() to handle reloads - Update interface level config writer to use NB callbacks - Add simplified `no` forms for priority and advertisement-interval commands Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-12-09vrrpd: northbound conversionQuentin Young
Convert VRRPD to use the northbound API. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-12-09vrrpd: allow vrrp_shutdown() on shutdown rtrQuentin Young
No need for a state check before the call, although still a good idea Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-12-09vrrpd: const vrrp_lookup()Quentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-12-09vrrpd: make vrrp_[add|del]_ip not insaneQuentin Young
For some reason I made these functions require you to pass the correct (v4 or v6) router when we could determine it from the type of address passed; fix this Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-12-09vrrpd: add vrf supportQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-12-09vrrpd: handle failure to lookup parent ifaceQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.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-10-30vrrpd: some more error logging fixesQuentin Young
- Give the correct log message when refusing to start because the vr is already started - Fix a couple other : whynot; cases missed Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-10-29vrrpd: only count ipv4 addresses on check startGhasem Naddaf
Signed-off-by: Ghasem Naddaf <ghasem.naddaf@gmail.com>
2019-10-21vrrpd: fix startup error message reportingQuentin Young
Due to some extremely shoddy programming on my part, the error messages for certain errors was pretty much always wrong. We would start with the correct error message, then on the next check, regardless of whether it passed or failed, we would null out the error message, then on the next one set it again (to the wrong message), then null it, and just keep alternating. So errors were sometimes not being reported, sometimes being reported correctly (if the condition parity happened to match the appropriate condition), and sometimes being reported correctly. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-10-17vrrpd: use CS2MS instead of constant 10 everywhereGhasem Naddaf
Signed-off-by: Ghasem Naddaf <ghasem.naddaf@gmail.com> vrrpd: use CS2MS instead of constant 10 everywhere Signed-off-by: Ghasem Naddaf <ghasem.naddaf@gmail.com>
2019-09-03*: frr_elevate_privs -> frr_with_privsDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-08-05vrrpd: eliminate potential null derefQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-08-02vrrpd: try to bind interfaces on if_down notificationsQuentin Young
Normally we only opportunistically try to bind interfaces to VRRP instances upon getting if_add and if_up notifications; now that Zebra sends if_down notifications when interfaces change while they are down, we should try to bind when we get those as well. This solves a bug where VRRP would not bind and activate virtual routers to valid interfaces because their MACs were changed to VRRP macs while the interface was down. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-08-02vrrpd: add more dbg logs around interfacesQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-06-21vrrpd: use MTYPE_STATICDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-05-17vrrpd: fix coverity warningsQuentin Young
* Suppress false positive on out of bounds access * Suppress false positive on unchecked str2sockunion * Remove self assignment * Initialze struct msghdr to zero Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17vrrpd: const vrrp_hash_keyQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17vrrpd: fix some clang-analyze warningsQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17vrrpd, zebra: fix checkpatch warningsQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17vrrpd: fix memleak during config writeQuentin Young
Forgot to free a list created in the course of writing our config. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17vrrpd: convert defaults command to millisecondsQuentin Young
Missed this in the conversion from centiseconds to milliseconds. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>