summaryrefslogtreecommitdiff
path: root/pimd/pim_instance.c
AgeCommit message (Collapse)Author
2025-02-25Merge pull request #18252 from nabahr/pr-18226-10.2-backport-fixedDonald Sharp
pim: Fix vrf binding of autorp and mroute socket (backport #18226)
2025-02-24pim: Fix vrf binding of autorp and mroute socketNathan Bahr
Bind the autorp socket to the vrf device. Also fixed mroute socket to use vrf_bind instead of directly setting the socket option. Signed-off-by: Nathan Bahr <nbahr@atcorp.com> (cherry picked from commit 7e181a771c2e525aeda6e8f6c2d58e9ee2503949) Fixed merge conflicts
2025-02-24pimd: Fix PIM VRF support (send register/register stop in VRF)Martin Buck
In 946195391406269003275850e1a4d550ea8db38b and 8ebcc02328c6b63ecf85e44fdfbf3365be27c127, transmission of PIM register and register stop messages was changed to use a separate socket. However, that socket is not bound to a possible VRF, so the messages were sent in the default VRF instead. Call vrf_bind() once after socket creation and when the VRF is ready to ensure transmission in the correct VRF. vrf_bind() handles the non-VRF case (i.e. VRF_DEFAULT) automatically, so it may be called unconditionally. Signed-off-by: Martin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org> (cherry picked from commit 5a01011e0d2db538a8ba523904bd4f08b786edfb)
2024-09-24pimd: Add AutoRP functionality to PIMDNathan Bahr
Perform AutoRP discovery and candidate RP announcements using the AutoRP protocol. Mapping agent is not yet implemented, but this feature is not necessary for FRR to support AutoRP as we only need one AutoRP mapping agent in the network. Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2024-09-09pimd: Candidate-BSR supportJafar Al-Gharaibeh
Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2024-07-16pimd, lib, vtysh: Added new 'router pim[6] [vrf NAME]' config nodeNathan Bahr
Moved all existing global/vrf PIM config to the new subnode. Existing configuration updated to be hidden and deprecated. Both versions of configuration still work together. Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2023-05-30pimd: Fix wrong creating order for pimreganlan_cs
`pim_if_create_pimreg()` need use the `mroute_socket`, so adjust the order. First call `pim_mroute_socket_enable()`, then call `pim_if_create_pimreg()`. Signed-off-by: anlan_cs <vic.lan@pica8.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-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-08-04pimd, pim6d: Send register msg via register socketMobashshera Rasool
The problem here is when the same node is FHR as well as RP, then the node keeps on sending the register packet. Register-stop is not sent as well. This problem has occurred because the RP is the same node and there is no socket created on loopback interface, so the packet is never send out and never received back on the same node, so register recv could not be processed on the node and hence no register-stop is sent. Since register packets are unicast packets, its better to handle the send of register packet via a separate register socket. This fixes the problem mentioned above as well. Fixes: #11331 Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-06-24Merge pull request #11471 from mobash-rasool/fixesDonald Sharp
pimd: Clean up mroute_socket when pim terminates.
2022-06-24pimd: fix invalid memory access join_timer_stopSarita Patra
Issue: ==16837== Invalid read of size 8 ==16837== at 0x17971C: pim_neighbor_find (pim_neighbor.c:431) ==16837== by 0x186439: join_timer_stop (pim_upstream.c:348) ==16837== by 0x186794: pim_upstream_del (pim_upstream.c:231) ==16837== by 0x189A66: pim_upstream_terminate (pim_upstream.c:1951) ==16837== by 0x17111B: pim_instance_terminate (pim_instance.c:54) ==16837== by 0x17111B: pim_vrf_delete (pim_instance.c:172) ==16837== by 0x4F1D6C8: vrf_delete (vrf.c:264) ==16837== by 0x19006F: pim_terminate (pimd.c:160) ==16837== by 0x1B2E4D: pim_sigterm (pim_signals.c:51) ==16837== by 0x4F08FA2: frr_sigevent_process (sigevent.c:130) ==16837== by 0x4F1A2CC: thread_fetch (thread.c:1771) ==16837== by 0x4ED4F92: frr_run (libfrr.c:1197) ==16837== by 0x15D81A: main (pim_main.c:176) Root Cause: In the pim_terminate flow, the interface is deleted before the pim_interface clean up. Because of this, the pim_interface is having garbage value. Fix: Release the pim interface memory and then delete the interface. Signed-off-by: Sarita Patra <saritap@vmware.com>
2022-06-24pimd: Clean up mroute_socket when pim terminates.Mobashshera Rasool
pim_mroute_socket_disable api is present but nowhere called. This should be called when pim instance is terminated. Fixed it. Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-05-17Merge pull request #10775 from opensourcerouting/pim6-mld-prDonald Sharp
pim6d: MLD code
2022-05-06pim6d: change MLD socket to be per VRFDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-05-06pimd: un-dependency-hell `pim_instance.h`David Lamparter
This is causing build issues on BSD by including (transitively) `linux/mroute6.h` - try to address by disentangling the headers a bunch. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
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-08-27Merge pull request #9496 from idryzhov/vrf-cmd-init-unused-argDavid Lamparter
lib: remove unused argument from vrf_cmd_init
2021-08-26lib: remove unused argument from vrf_cmd_initIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-23*: explicitly print "exit" at the end of every node configIgor Ryzhov
There is a possibility that the same line can be matched as a command in some node and its parent node. In this case, when reading the config, this line is always executed as a command of the child node. For example, with the following config: ``` router ospf network 193.168.0.0/16 area 0 ! mpls ldp discovery hello interval 111 ! ``` Line `mpls ldp` is processed as command `mpls ldp-sync` inside the `router ospf` node. This leads to a complete loss of `mpls ldp` node configuration. To eliminate this issue and all possible similar issues, let's print an explicit "exit" at the end of every node config. This commit also changes indentation for a couple of existing exit commands so that all existing commands are on the same level as their corresponding node-entering commands. Fixes #9206. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-07-01pimd: support MSDP global timers configurationRafael Zalamena
Users can now configure: * Hold time * Keep alive * Connection retry Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-05-12pimd: Remove pim->vrf_id and use pim->vrf->vrf_idDonald Sharp
VRF creation can happen from either cli or from knowledged about the vrf learned from zebra. In the case where we learn about the vrf from the cli, the vrf id is UNKNOWN. Upon actual creation of the vrf, lib/vrf.c touches up the vrf_id and calls pim_vrf_enable to turn it on properly. At this point in time we have a pim->vrf_id of UNKNOWN and the vrf->vrf_id of the right value. There is no point in duplicating this data. So just remove all pim->vrf_id and use the vrf->vrf_id instead since we keep a copy of the pim->vrf pointer. This will remove some crashes where we expect the pim->vrf_id to be usable and it's not. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-12pimd: There exists a path where on vrf bringup we do not create the pimregDonald Sharp
When creating configuration for a vrf *Before* the vrf has been created, pim will not properly create the pimreg device and we will promptly crash when we try to pass data. Put some code checks in place to ensure that the pimreg is created for vrf's. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-26pimd: Prevent use after freeDonald Sharp
Valgrind is reporting this: ==22220== Invalid read of size 4 ==22220== at 0x11DC2B: pim_if_delete (pim_iface.c:215) ==22220== by 0x11DD71: pim_if_terminate (pim_iface.c:76) ==22220== by 0x128E03: pim_instance_terminate (pim_instance.c:66) ==22220== by 0x128E03: pim_vrf_delete (pim_instance.c:159) ==22220== by 0x48E0010: vrf_delete (vrf.c:251) ==22220== by 0x48E0010: vrf_delete (vrf.c:225) ==22220== by 0x48E02FE: vrf_terminate (vrf.c:551) ==22220== by 0x149495: pim_terminate (pimd.c:142) ==22220== by 0x13C61B: pim_sigint (pim_signals.c:44) ==22220== by 0x48CF862: quagga_sigevent_process (sigevent.c:103) ==22220== by 0x48DD324: thread_fetch (thread.c:1404) ==22220== by 0x48A926A: frr_run (libfrr.c:1122) ==22220== by 0x11B85E: main (pim_main.c:167) ==22220== Address 0x5912160 is 1,200 bytes inside a block of size 1,624 free'd ==22220== at 0x48369AB: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==22220== by 0x128E52: pim_instance_terminate (pim_instance.c:74) ==22220== by 0x128E52: pim_vrf_delete (pim_instance.c:159) ==22220== by 0x48E0010: vrf_delete (vrf.c:251) ==22220== by 0x48E0010: vrf_delete (vrf.c:225) ==22220== by 0x48F1353: zclient_vrf_delete (zclient.c:1896) ==22220== by 0x48F1353: zclient_read (zclient.c:3511) ==22220== by 0x48DD826: thread_call (thread.c:1585) ==22220== by 0x48A925F: frr_run (libfrr.c:1123) ==22220== by 0x11B85E: main (pim_main.c:167) ==22220== Block was alloc'd at ==22220== at 0x4837B65: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==22220== by 0x48ADA4F: qcalloc (memory.c:110) ==22220== by 0x128B9B: pim_instance_init (pim_instance.c:82) ==22220== by 0x128B9B: pim_vrf_new (pim_instance.c:142) ==22220== by 0x48E0C5A: vrf_get (vrf.c:217) ==22220== by 0x48F13C9: zclient_vrf_add (zclient.c:1863) ==22220== by 0x48F13C9: zclient_read (zclient.c:3508) ==22220== by 0x48DD826: thread_call (thread.c:1585) ==22220== by 0x48A925F: frr_run (libfrr.c:1123) ==22220== by 0x11B85E: main (pim_main.c:167) On pim vrf deletion, ensure that the vrf->info pointers are NULL as well as the free'd pim pointer for ->vrf is NULL as well. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-04-20*: sprintf -> snprintfQuentin Young
Replace sprintf with snprintf where straightforward to do so. - sprintf's into local scope buffers of known size are replaced with the equivalent snprintf call - snprintf's into local scope buffers of known size that use the buffer size expression now use sizeof(buffer) - sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp buffer followed by strlcat Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-03-23Merge pull request #6008 from sarav511/max_vifDonald Sharp
pimd: Do not allow to configure multicast on more than MAXVIF interfaces
2020-03-16pimd: Do not allow to configure multicast on more than MAXVIF interfacessaravanank
RCA: When configured more than 32(MAXVIS), the inerfaces that are configured after 32nd interfaces have the value of MAXVIF. This is used as index to access the free vif tracker of array size 32(MAXVIFS). So the channel oil list pointer which is present as the next field in pim structure get corrupt, when updating free vif. This gets accessed during rpf update resulting in crash. Fix: Refrain from allocating mcast interface structure and throw config error when more than MAXVIFS are attempted to configure. Max vif checks are exempted for vrf device and pimreg as vrf device will be the first interface and not expected to fail and pimreg has reserved vif. vxlan tunnel termination device creation has this check and throw warning on max vif. All other creation are through CLI. Signed-off-by: Saravanan K <saravanank@vmware.com>
2020-03-06pimd: Add `ip pim register-accept-list PLIST` commandDonald Sharp
When pim receives a register packet, we will apply the received source to the prefix list. If accepted normal processing continues. If denied we will send a register stop message to the source. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-06pimd: Rename the PIM_SPT_PLIST_NAME to PIM_PLIST_NAMEDonald Sharp
The memory type PIM_SPT_PLIST_NAME is specific to SPT but we are going to store more prefix-list names in pim, make it generic to allow for less confusion in the future. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-06pimd: the spt infinity prefix-list memory was not being freedDonald Sharp
On shutdown the string storing the prefix-list was not being properly freed. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-05*: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__Donatas Abraitis
Just keep the code cool. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-11-13pimd : Add support for MLAG Register & Un-registerSatheesh Kumar K
when ever a FRR Client wants to send any data to another node using MLAG Channel, uses below mechanisam. 1. sends a MLAG Registration to zebra with interested messages that it is intended to receive from peer. 2. In response to this request, Zebra opens communication channel with MLAG. and also in Rx. diretion zebra forwards only those messages which client shown interest during registration 3. when client is no-longer interested in communicating with MLAG, client posts De-register to Zebra 4. if this is the last client which is interested for MLAG Communication, zebra closes the channel. why PIM Needs MLAG Communication ================================ 1. In general on LAN Networks elecetd DR will send the Join towards Multicast RP in case of a LHR and Register in case of FHR. 2. But in case DR Goes down, traffic will be re-converged only after the New DR is elected, but this can take time based on Hold Timer to detect the DR down. 3. this can be optimised by using MLAG Mecganisam. 4. and also Traffic can be forwarded more efficiently by knowing the cost towards RP using MLAG Signed-off-by: Satheesh Kumar K <sathk@cumulusnetworks.com>
2019-10-14Revert "Merge pull request #4885 from satheeshkarra/pim_mlag"Quentin Young
This reverts commit d563896dada99f3474d428f928786cbfde936fee, reversing changes made to 09ea1a40386f02a13cdb0462cc55af0d03f0c277.
2019-09-16pimd : Add support for MLAG Register & Un-registerSatheesh Kumar K
when ever a FRR Client wants to send any data to another node using MLAG Channel, uses below mechanisam. 1. sends a MLAG Registration to zebra with interested messages that it is intended to receive from peer. 2. In response to this request, Zebra opens communication channel with MLAG. and also in Rx. diretion zebra forwards only those messages which client shown interest during registration 3. when client is no-longer interested in communicating with MLAG, client posts De-register to Zebra 4. if this is the last client which is interested for MLAG Communication, zebra closes the channel. why PIM Needs MLAG Communication ================================ 1. In general on LAN Networks elecetd DR will send the Join towards Multicast RP in case of a LHR and Register in case of FHR. 2. But in case DR Goes down, traffic will be re-converged only after the New DR is elected, but this can take time based on Hold Timer to detect the DR down. 3. this can be optimised by using MLAG Mecganisam. 4. and also Traffic can be forwarded more efficiently by knowing the cost towards RP using MLAG Signed-off-by: Satheesh Kumar K <sathk@cumulusnetworks.com>
2019-05-14pimd: PIM BSM Processing datastructure definition/initialization/deinitsaravanank
Apart from datastructure, bsm scope initialization and deinitialiation routines called during pim instance init and deinit. Also makefile changes. Signed-off-by: Saravanan K <saravanank@vmware.com>
2019-04-21pim: fix order of vxlan mroutes cleanup when pimd is shutdownAnuradha Karuppiah
1. vxlan instance cleanup needs to be done before the upstream entries are force-flushed. 2. also vxlan callbacks need to be ignored post instance-cleanup. Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-04-20pimd: initial infrastructure to maintain VxLAN SG databaseAnuradha Karuppiah
These entries will be used over the subsequent commits for 1. vxlan-tunnel-termination handling - setup MDT to rx VxLAN encapsulated BUM traffic. 2. vxlan-tunnel-origination handling - register local-vtep-ip as a multicast source. Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-01-04pimd: Remove pimgDonald Sharp
The pimg data structure is only used in one spot to send the default vrf id to zebra upon startup. Add the default vrf id to the struct pim_router data structure and remove the pimg pointer. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-04pimd: Create a `struct pim_router` and move thread master into itDonald Sharp
Create a `struct pim_router` and move the thread master into it. Future commits will further move global varaibles into the pim_router structure. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-23vtysh: fix exit-vrf printingQuentin Young
Resolves issue with exit-vrf being placed at the end of zebra's portion of a vrf block, but before other daemons' portions of the same config block. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-10-02*: list_delete_and_null() -> list_delete()David Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-24pimd: Fix several address sanitizer issuesDonald Sharp
This commit fixes two issues during pim shutdown. 1) The rp_info structure was being freed before the outgoing notifications that depended on it's information was sent out as part of shutdown. 2) The pim->upstream_list shutdown involved iterating over the list via ALL_LIST_ELEMENTS. This typically is enough but pim will auto delete child nodes as well as itself when it goes away and they depend on it. As such the node and nnode could possibly already have been freed. So change the way we look at all the data in the upstream_list Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-28*: add a vrf update hook to be informed of the vrf namePhilippe Guibert
The Vrf aliases can be known with a specific hook. That hook will then, from zebra propagate the information to the relevant zapi clients. The registration hook function is the same for all daemons. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-14pimd: Convert over to use LIB_ERR_XXX for zlog_errDonald Sharp
Convert, where appropriate, the zlog_err functions to zlog_ferr for the LIB_ERR_XXX enums Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-02pimd: Fix crash on shutdown in oilDonald Sharp
When shutting down, do not free oil information after interface information since we use the data there to do so. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-08pimd: Remove unnecessary alloc failuresDonald Sharp
Remove from pim unnecessary alloc failure testing as that alloc failure will cause an assert. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-07pimd: Fix ecmp_enable and ecmp_rebalance_enableDonald Sharp
These commands were being accepted in all vrf's and affecting all vrf's behavior globally, since they were global variables. Modify the code to make these two commands work on a per-vrf basis. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-11pimd: Clean up rpf_hash *after* upstream cleanupDonald Sharp
Cleanup the pim->rpf_hash after upstream cleanup is done since upstream cleanup uses the rpf_hash to cleanup itself. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-17pimd: Move some data tracking variables per VRFDonald Sharp
There were a few more global variables that needed to be per vrf. So move them over. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-13lib: privileges are granted to vty netns commandPhilippe Guibert
Vty commands that link netns context to a vrf is requiring some privileges. The change consists in retrieving the privileges at the vrf_cmd_init() called by the relevant daemon. Then use it. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>