summaryrefslogtreecommitdiffstats
path: root/vrrpd/vrrp.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* *: convert `struct interface->connected` to DLISTDavid Lamparter2023-11-221-7/+11
| | | | | | | | | | | | | | | | | 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>
* vrrp: check return value for turning off multicast for v6Loganaden Velvindron2023-06-131-1/+7
| | | | | | CID1519841: check return value and set error Signed-off-by: Loganaden Velvindron <logan@cyberstorm.mu>
* *: Convert THREAD_XXX macros to EVENT_XXX macrosDonald Sharp2023-03-241-13/+13
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert thread_add_XXX functions to event_add_XXXDonald Sharp2023-03-241-27/+27
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Rename `struct thread` to `struct event`Donald Sharp2023-03-241-5/+5
| | | | | | | | | 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>
* *: Add a hash_clean_and_free() functionDonald Sharp2023-03-211-2/+1
| | | | | | | | | | 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>
* Merge pull request #12780 from opensourcerouting/spdx-license-idDonald Sharp2023-02-171-14/+1
|\ | | | | *: convert to SPDX License identifiers
| * *: auto-convert to SPDX License IDsDavid Lamparter2023-02-091-14/+1
| | | | | | | | | | | | Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* | vrrpd: give null when using null ifp to lookup vrQuentin Young2023-02-101-0/+3
|/ | | | | | This is still causing crashes somehow. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* vrrpd: add IPv4 pseudoheader option for VRRPv3Siger Yang2022-11-251-3/+16
| | | | | | | | 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>
* lib, vrrpd: Use THREAD_ARGDonald Sharp2022-07-211-3/+3
| | | | | | | 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>
* *: remove the checking returned value for hash_get()anlan_cs2022-05-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* *: Change thread->func to return void instead of intDonald Sharp2022-02-241-11/+5
| | | | | | | 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>
* *: use ipaddr_cmp instead of memcmpIgor Ryzhov2022-02-081-3/+3
| | | | | | | 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>
* *: rework renaming the default VRFIgor Ryzhov2021-12-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* *: cleanup ifp->vrf_idIgor Ryzhov2021-11-221-6/+6
| | | | | | | 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>
* *: require semicolon after DEFINE_MTYPE & coDavid Lamparter2021-03-171-2/+2
| | | | | | | | | | | | | | | | | 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>
* *: remove tabs & newlines from log messagesDavid Lamparter2021-02-141-1/+1
| | | | | | | 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>
* vrrpd: Convert to using %pFXPat Ruddy2020-10-151-15/+6
| | | | Signed-off-by: Pat Ruddy <pat@voltanet.io>
* vrrpd: Make clang 11 happyDonald Sharp2020-07-271-2/+2
| | | | | | | | | | | 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>
* *: remove PRI[udx](8|16|32)David Lamparter2020-07-141-15/+9
| | | | | | | | | | | 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>
* vrrpd: search all vr's for mvl_ifp to nullQuentin Young2020-03-051-32/+44
| | | | | | | | | | | | | | | | | | | 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>
* vrrpd: always null mvl_ifp ptr when mvl is deletedQuentin Young2020-03-051-8/+40
| | | | | | | | | | | | 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>
* *: Return bool type for bool functionsDonatas Abraitis2020-03-041-3/+3
| | | | Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* *: Use short version of bool expressionsDonatas Abraitis2020-03-041-3/+3
| | | | Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* Merge pull request #5314 from qlyoung/yang-vrrpRenato Westphal2020-01-081-80/+23
|\ | | | | VRRP northbound conversion
| * vrrpd, yang: cleanup vrrp nb conversionQuentin Young2019-12-091-67/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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>
| * vrrpd: northbound conversionQuentin Young2019-12-091-4/+8
| | | | | | | | | | | | Convert VRRPD to use the northbound API. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
| * vrrpd: allow vrrp_shutdown() on shutdown rtrQuentin Young2019-12-091-2/+3
| | | | | | | | | | | | No need for a state check before the call, although still a good idea Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
| * vrrpd: const vrrp_lookup()Quentin Young2019-12-091-2/+2
| | | | | | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
| * vrrpd: make vrrp_[add|del]_ip not insaneQuentin Young2019-12-091-7/+12
| | | | | | | | | | | | | | | | 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>
* | vrrpd: support namespace vrf tooQuentin Young2019-12-181-2/+4
| | | | | | | | | | | | -.- Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* | vrrpd: add vrf supportQuentin Young2019-12-091-7/+33
| | | | | | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* | vrrpd: handle failure to lookup parent ifaceQuentin Young2019-12-091-0/+9
|/ | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: generously apply constDavid Lamparter2019-12-021-4/+4
| | | | | | const const const your boat, merrily down the stream... Signed-off-by: David Lamparter <equinox@diac24.net>
* vrrpd: some more error logging fixesQuentin Young2019-10-301-3/+9
| | | | | | | | - 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>
* vrrpd: only count ipv4 addresses on check startGhasem Naddaf2019-10-291-6/+6
| | | | Signed-off-by: Ghasem Naddaf <ghasem.naddaf@gmail.com>
* vrrpd: fix startup error message reportingQuentin Young2019-10-211-9/+11
| | | | | | | | | | | | | 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>
* vrrpd: use CS2MS instead of constant 10 everywhereGhasem Naddaf2019-10-181-8/+8
| | | | | | | | 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>
* *: frr_elevate_privs -> frr_with_privsDavid Lamparter2019-09-031-6/+3
| | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* vrrpd: eliminate potential null derefQuentin Young2019-08-051-3/+3
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* vrrpd: try to bind interfaces on if_down notificationsQuentin Young2019-08-021-0/+4
| | | | | | | | | | | | | 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>
* vrrpd: add more dbg logs around interfacesQuentin Young2019-08-021-1/+22
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* vrrpd: use MTYPE_STATICDavid Lamparter2019-06-211-2/+4
| | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* vrrpd: fix coverity warningsQuentin Young2019-05-171-3/+2
| | | | | | | | | * 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>
* vrrpd: const vrrp_hash_keyQuentin Young2019-05-171-2/+2
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* vrrpd: fix some clang-analyze warningsQuentin Young2019-05-171-1/+3
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* vrrpd, zebra: fix checkpatch warningsQuentin Young2019-05-171-4/+5
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* vrrpd: fix memleak during config writeQuentin Young2019-05-171-0/+2
| | | | | | Forgot to free a list created in the course of writing our config. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* vrrpd: convert defaults command to millisecondsQuentin Young2019-05-171-1/+1
| | | | | | Missed this in the conversion from centiseconds to milliseconds. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>