Commit graph

153 commits

Author SHA1 Message Date
Mark Stapp aece400f10 pimd: clean up variable-shadow warnings
Clean up -Wshadow warnings in pimd

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:27 -04:00
Nathan Bahr e8d81ab5ce pimd: Implement rpf lookup mode as a list
Add the support to store lookup modes as a sorted list.
List is non-unique and sorts mode with both lists < modes with one list < global mode (no lists).
This way, when finding the right mode, we will match a lookup using a prefix list before the global mode.
Add passing group address into all lookups (using nht cache and/or synchronous lookup).
Many areas don't have a group address, use PIMADDR_ANY if no valid group is needed.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2025-01-09 21:58:22 +00:00
Nathan Bahr 8b00575fbb pimd,yang: Expand rpf-lookup-mode command
Add options for group-list and source-list, both of which take a prefix list name.
The prefix list is used to determine the lookup mode for specific sources and/or groups.
Any number of lookup modes can be configured as long as the combination of group
and source list is unique.
A global lookup mode (empty group and source lists) is always added and defaults to mrib-then-urib
as it currently functions. The global lookup mode can be changed as it current exists with the command
`rpf-lookup-mode MODE`.
When determinig which mode to use, match source (and group if provided) against the lists, if they are set.
If a lookup does not specify a group, then only use lookup modes that do not have a group list defined.
A lookup by definition will have a source, so no special handling there.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2025-01-09 21:58:22 +00:00
Nathan Bahr 6d30c8f6b5 pimd: Refactor pim NHT
Refactor the next hop tracking in PIM to fully support the configured RPF lookup mode.
Moved many NHT related functions to pim_nht.h/c
NHT now tracks both MRIB and URIB tables and makes nexthop decisions based on the configured lookup mode.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2024-12-13 17:36:34 +00:00
Jafar Al-Gharaibeh 8fbd88c5a7 pimd: allow resolving bsr via directly connected secondary address
This only matters to single hop nodes that are adjacent to the bsr. More common
with IPv6 where LL address is used in PIM as the primary address. If the BSR IP
happens to be an address on the same interface, the receiving pim router
rejects the BSR address because it expects the BSR IP to resolve via the LL address
even if we have a connected route for the same BSR IP subnet. Effectively, we want to
allow rpf to be resolved via secondary IPs with connected routes on the same interface,
and not limit them to primary addresses.

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2024-10-25 08:59:17 -05:00
Donald Sharp 9f8968fc5a *: Allow 16 bit size for nexthops
Currently FRR is limiting the nexthop count to a uint8_t not a
uint16_t.  This leads to issues when the nexthop count is 256
which results in the count to overflow to 0 causing problems
in the code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-08 09:26:57 -04:00
Jafar Al-Gharaibeh 569b1d41df pimd: make sure the bsr message is coming from the neighbor
This change re-adds an additional check bsr rpf that was removed
in 2c6a32f9be.

Without that check, bsr messages is resent (causing a loop) if we
have more than one pim neighbor on a link.

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2024-09-09 17:14:16 -05:00
David Lamparter b9a02da83b pimd: prepare NHT for tracking BSM C-RPs
For BSMs, we should track which of the RP candidates in the BSM message
are actually available, before trying to use them (which also puts them
in NHT for that).  This applies for both BSRs as well as BSM receivers.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-06-20 13:10:51 +02:00
David Lamparter ac18d56a0b pimd: use zclient->nexthop_update
Same as before, use shared nexthop decode function.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-20 11:24:28 +01:00
Igor Ryzhov 7d67b9ff28 build: add -Wimplicit-fallthrough
Also:
- replace all /* fallthrough */ comments with portable fallthrough;
pseudo keyword to accomodate both gcc and clang
- add missing break; statements as required by older versions of gcc
- cleanup some code to remove unnecessary fallthrough

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-10-12 21:23:18 +03:00
Donald Sharp 5385202399 pimd: Add whether or not the rpf succeeded or not to the debug
Hard to know what is going on if the debug doesn't tell us.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-14 11:08:00 -04:00
Donald Sharp 35c4790aa7 pimd: Allow more immediate null registers to be sent in the vxlan code
When a pim vxlan S,G is created, the code attempts to send out a NULL
register.  This is used to build the S,G tree from the RP to the
FHR.  Upon initial startup it is not unusual for the pim vxlan state
be fully ready to go but the RP is still not reachable.  Let's add
a bit of a pump prime that allows the vxlan code to re-attempt to
send the null register for vxlan S,G's that the RP's outgoing
interface changed from unknown to an actual interface.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-12 11:48:15 -04:00
anlan_cs 3d8814f827 pimd: Correct the wrong comment
Currently the function `pim_parse_nexthop_update()` clearly
updates nexthop interfaces even as PIM-disabled.

Just correct the wrong comments about those PIM-disabled interfaces
to avoid misleading.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-04-17 09:07:37 +08:00
David Lamparter 5903e49c7b pimd, doc: remove dead import check references
ZEBRA_IMPORT_CHECK_UPDATE has been gone for more than a year; remove
some leftover dead references to it.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-04-13 16:52:57 +02:00
Sarita Patra ae5bcac0ae pimd, pim6d: Fix RP Unknown IIF
When route to RP is having nexthop secndary address,
neighborship is built with primary address,
then pim_neighbor_find() fails, which causes RP IIF
Unknown.

Fix:
Verify pim neighborship on the RP connected interface.

Issue: #11526

Signed-off-by: Sarita Patra <saritap@vmware.com>
2023-02-24 04:40:38 -08:00
Sarita Patra 2c6a32f9be pimd, pim6d: Fix BSM packet process
Problem 1:
When route to BSR is having nexthop secondary address,
neighborship is built with primary address,
then pim_neighbor_find() fails, which cause drop of BSM
packet.

Fix 1:
Verify pim neighborship on the BSM received interface.
Problem 2:

Problem 2:
Source IP BSM address is primary address, where
as nexthop also can be primary or secondary address.

Fix 2:
Avoiding the check (nhaddr == src_ip) for PIMV6

Issue: #11957

Signed-off-by: Sarita Patra <saritap@vmware.com>
2023-02-24 04:40:38 -08:00
David Lamparter acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Donald Sharp da21ae9dc7 pimd: Add missing enums to switch statement
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-31 15:15:42 -05:00
Sarita Patra 31b66ed67d pimd, pim6d: Don't allow pim disabled interface as nexthop
While doing nexthop lookup, only allow the nexthop
interafce which is PIM enabled.

Issue: #10782
Issue: #11931

Signed-off-by: Sarita Patra <saritap@vmware.com>
2022-11-14 00:17:48 -08:00
Sarita Patra 93d4f4f0dd pimd, pim6d: Update upstream rpf disable/enable pim on interface
Problem:
When "no ip pim" is executed on source connected interface, its
ifp->info is set to NULL. But KAT on this interface is still
running, it wrongly dereferences NULL. This leads to crash.

Root Cause:
pim upstream IIF is still pointing towards the source connected
interface which is not pim enabled and Mroute is still present in
the kernel.

Fix:
When “no ip pim” command gets executed on source connected interface,
then loop through all the pnc->nexthop, if any new nexthop found,
then update the upstream IIF accordindly, if not found then update
the upstream IIF as Unknown and uninstall the mroute from kernel.

When “ip pim” command gets executed on source connected interface,
then also loop through all the pnc->nexthop  and update the upstream IIF,
install the mroute in kernel.

Issue: #10782
Issue: #11931

Signed-off-by: Sarita Patra <saritap@vmware.com>
2022-11-14 00:17:48 -08:00
Sai Gomathi N b6467a4274 pimd: Dereference before null check
In pim_ecmp_nexthop_search: All paths that lead to this null pointer comparison already dereference the pointer earlier
There may be a null pointer dereference, or else the comparison against null is unnecessary.

Coverity CID-1519749

Signed-off-by: Sai Gomathi N <nsaigomathi@vmware.com>
2022-10-27 03:58:18 -07:00
Sarita Patra f789683690 pimd: Update mroute IIF based on Nexthop received from Zebra
Topology:
R1(LHR) ---- R2 ----R4(FHR)
        ---- R3 ----

R2 = RP

Steps to reproduce:
1. R1(LHR) sends IGMP join, R4(FHR) sends multicast traffic.
   Verify traffic is flowing from FHR to LHR.
2. Restart R1(LHR).
3. Below sequence of events are happening after FRR restart in R1(LHR).
4. R1(LHR) Register RP address to Zebra.
5. R1(LHR) Receive update from Zebra that R2(RP) is reachable via R3.
6. R1(LHR) Receive IGMP join for group 225.1.1.1, will create pim upstream
   and (*,G) mroute with IIF towards R3.
7. R1(LHR) Receive update from Zebra that RP is reachable via R2(RP).
8. R1(LHR) Update the PIM upstream IIF, but not updating the (*,G) IIF
   even there is RPF change.
9. R1(LHR) receives IGMP join for group 225.1.1.2, will create (*,G) with
   IIF towards R2(RP), both upstream and (,G) created with IIF towards R2(RP).

Root Cause:
Mroute IIF is not getting updated when better route update
received. It is still pointing to the older nexthop.

Fix:
Update the mroute IIF when there is change in nexthop.

Fixing Issue #11675

Signed-off-by: Sarita Patra <saritap@vmware.com>
2022-07-28 13:03:46 -07:00
Jafar Al-Gharaibeh 6286ce45bc
Merge pull request #11536 from mobash-rasool/temp1
pimd: During prune pending, behave as NOINFO state (conformance issue)
2022-07-14 12:24:35 -05:00
sarita patra 53bbfd535a pim6d: bsr nht handling for IPV6
Signed-off-by: sarita patra <saritap@vmware.com>
2022-07-07 07:53:40 -07:00
Mobashshera Rasool 8d0f0b02f3 pimd: During prune pending, behave as NOINFO state
Fixed ANVL Conformance PIM-SM 16.3 test case.

When (S,G,rpt) prune is received, we were installing
the mroute immediately with none as OIF.
This leads to dropping the (S,G) traffic during prune
pending time as well.

Also we should not install the mroute if there is no
change in the rpf update.

These 2 things lead to the failure of the test case.

Fixed it by blocking the installation in this scenario.
When prune pending timer pops, it will take care of
installing the mroute with  none as OIF.

Fixes: #11535

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-07-06 05:18:38 -07:00
sarita patra e6e5300636 pim6d: Pass pim_addr for pim_nht callbacks.
For pim callbacks, we pass pim_addr as value, not pointer.
So making it consistent for pim_nht callbacks.

Signed-off-by: sarita patra <saritap@vmware.com>
2022-07-06 02:56:43 -07:00
sarita patra 6288ebcf22 pimd: Handle rpf_addr in pim nht
Signed-off-by: sarita patra <saritap@vmware.com>
2022-07-06 02:41:48 -07:00
Donald Sharp 75700af602 pimd: Limit pim's ecmp to what zebra tells us is the multipath
Zebra can be setup to use a value that is less than MULTIPATH_NUM.
When pimd connects to zebra, zebra will inform pim about the MULTIPATH_NUM
used.  Let's use that value for figuring out our multipath value.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-23 13:29:19 -04:00
Donatas Abraitis 6006b807b1 *: Properly use memset() when zeroing
Wrong: memset(&a, 0, sizeof(struct ...));
    Good:  memset(&a, 0, sizeof(a));

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-11 14:08:47 +03:00
David Lamparter 993e3d8e13 pimd: un-dependency-hell pim_instance.h
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>
2022-05-06 15:10:57 +02:00
anlan_cs 8e3aae66ce *: remove the checking returned value for hash_get()
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-05-03 00:41:48 +08:00
sarita patra dac86a0a2d pim6d: Handle mrib_nexthop_addr & pim_zlookup_nexthop in pim_nht
Signed-off-by: sarita patra <saritap@vmware.com>
2022-04-06 22:37:58 -07:00
David Lamparter f11bc92554 pim6d: fix mis-printed nexthop
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-04 14:48:54 +02:00
David Lamparter c13a82352b pimd, pim6d: clarify RFC5549 MRIB nexthop handling
The entire `case NEXTHOP_TYPE_IPV6_IFINDEX:` block here was a bit of a
tripwire to stumble over, since there was no indication at all that this
concerns RFC5549 nexthop handling.  So it got mis-adapted for PIM IPv6
support.

Clarify this a whole bunch that this is for v4-over-v6 nexthop mangling,
and nothing else.

This should really also use neighbor's secondary address lists for the
lookup, but that is probably going to break compatibility with other
boxes that don't include v6 addrs in v4 hellos and needs further
machinery to do properly, so for now just leave a breadcrumb.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-04 14:48:54 +02:00
David Lamparter eb3c9d9774 *: add SAFI argument to zclient_send_rnh
Just pushing that SAFI_UNICAST up 1 level to the caller.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-27 14:57:22 +02:00
Mobashshera Rasool 76bfa0302c pim6d: Parse BSM packet for PIMv6
Modify pim_bsm_process to accomodate v4 and v6 address
for parsing the received packet.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-03-25 03:57:19 -07:00
Donatas Abraitis 2efc3acd9e
Merge pull request #9476 from SaiGomathiN/pim-nht
pimd: Added new option "detail" in the "debug pim nht" CLI
2022-03-20 23:14:08 +02:00
David Lamparter 185754fe7c pimd: be more informative about missing neighbors
Much more useful to know what we were trying to find a neighbor for.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-12 22:57:28 +01:00
Donald Sharp 06e4e90132 *: When matching against a nexthop send and process what it matched against
Currently the nexthop tracking code is only sending to the requestor
what it was requested to match against.  When the nexthop tracking
code was simplified to not need an import check and a nexthop check
in b8210849b8 for bgpd.  It was not
noticed that a longer prefix could match but it would be seen
as a match because FRR was not sending up both the resolved
route prefix and the route FRR was asked to match against.

This code change causes the nexthop tracking code to pass
back up the matched requested route (so that the calling
protocol can figure out which one it is being told about )
as well as the actual prefix that was matched to.

Fixes: #10766
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-12 11:18:45 -05:00
Sai Gomathi 6d733f0dbc pimd: Added new option "detail" in the "debug pim nht" CLI
Problem Statement:
=================
PIM Logs are coming at interval of 1 minute although pim
is not enabled.

Root Cause Analysis:
====================
By default, RCPM configures the PIM debugs when router comes up
via script. The product cannot disable PIM even though it is not required.
Hence moving these logs under a new debug option which will not be
enabled by default.

Fix:
====
Added a new option "detail" in the cli:
debug pim nht detail

Co-author: Mobashshera Rasool <mrasool@vmware.com>
Signed-off-by: Sai Gomathi <nsaigomathi@vmware.com>
2022-03-03 22:33:20 -08:00
David Lamparter 0455229c5d pim6d: reenable NHT code
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-02 11:01:47 +01:00
David Lamparter bc97f40dff pim6d: fixup NHT code for IPv6
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-02 11:01:46 +01:00
David Lamparter 6564f5e5a5 Merge pull request #10657 from patrasar/pim_remove_in_addr_none
[manual merge to edit comment, didn't want to incur another cycle]

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-02 10:42:17 +01:00
sarita patra cc144e8b6b pimd: replace inaddr_none with PIMADDR_ANY
We can use PIMADDR_ANY instead of INADDR_NONE to initalize rp->rpf_addr
when there is no rp configured for group_all.

Signed-off-by: sarita patra <saritap@vmware.com>
2022-03-01 09:45:56 -08:00
sarita patra 3e394a7729 pim6d: Handling pim_rpf for IPV6
Signed-off-by: sarita patra <saritap@vmware.com>
2022-03-01 06:30:03 -08:00
sarita patra 113f29b90d pim6d: Handling last_lookup in pim_nexthop for IPV6
Signed-off-by: sarita patra <saritap@vmware.com>
2022-02-28 18:03:12 -08:00
sarita patra 90ab4458a1 pim6d: pim_nht changes for pimv6
Signed-off-by: sarita patra <saritap@vmware.com>
2022-02-28 13:36:02 -08:00
Donald Sharp 3bf65aa1ae
Merge pull request #10400 from opensourcerouting/pim6-compilefix
pim6d: get running with ipv6 types throughout
2022-02-26 08:03:06 -05:00
anlan_cs de674e9fc2 pimd: cosmetic change
Remove one empty line. And correct one word.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-02-21 21:33:04 +08:00
David Lamparter ae449dc594 pim6d: remove PIM_V6_TEMP_BREAK
It's no longer necessary, pim6d now compiles without this hack.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-02-16 16:40:56 +01:00