Commit graph

89 commits

Author SHA1 Message Date
Rafael Zalamena cacdff75a6 pimd: fix null memory access on IGMP source limit
When the IGMP group source limit is reached the function
`igmp_get_source_by_addr` won't return a `struct gm_source` so we must
test for that condition before attempting to access its fields.

Fixes coverity scan issue 1637406.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2025-02-28 11:34:36 -03:00
David Lamparter df9517c95a pimd: add IGMPv2/MLDv1 immediate-leave
(Somewhat) useful when dealing with an interface that has only one host
attached.  Only works for IGMPv2 and MLDv1, other protocol versions have
no leave message.

Co-authored-by: David Lamparter <equinox@opensourcerouting.org>
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2025-02-13 12:45:47 -03:00
David Lamparter f07d379b74 pimd: implement IGMP group/source count limit
For groups we can just look at the length of the list, for sources we
need to count them on a per-interface level.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-02-10 15:40:07 -03:00
Corey Siltala 8465ba1dde pimd: Convert boundary_oil_plist to struct prefix_list
Rather than storing the prefix-list name and looking it up every time we use it, store a pointer to the prefix-list itself.

Signed-off-by: Corey Siltala <csiltala@atcorp.com>
2024-12-06 14:44:52 -06:00
Corey Siltala 4de4017d64 pimd,yang: Extend multicast boundary functionality
Add new interface command ip multicast boundary ACCESSLIST4_NAME. This
allows filtering on both source and group using the extended access-list
syntax vs. group-only as with the existing "ip multicast boundary oil"
command, which uses prefix-lists. If both are configured, the prefix-
list is evaluated first. The default behavior for both prefix-lists and
access-lists remains "deny", so the prefix-list must have a terminating
"permit" statement in order to also evaluate against the access-list.

The following example denies groups in range 229.1.1.0/24 and groups in
range 232.1.1.0/24 with source 10.0.20.2:

!
ip prefix-list pim-oil-plist seq 10 deny 229.1.1.0/24
ip prefix-list pim-oil-plist seq 20 permit any
!
access-list pim-acl seq 10 deny ip host 10.0.20.2 232.1.1.0 0.0.0.255
access-list pim-acl seq 20 permit ip any any
!
interface r1-eth0
 ip address 10.0.20.1/24
 ip igmp
 ip pim
 ip multicast boundary oil pim-oil-plist
 ip multicast boundary pim-acl
!

Signed-off-by: Corey Siltala <csiltala@atcorp.com>
2024-12-06 14:44:17 -06:00
Jafar Al-Gharaibeh a951960a15 pimd: fix crash when mixing ssm/any-source joins
There is no reason to call `igmp_anysource_forward_stop()` inside a call to
`igmp_get_source_by_addr()`; not only it is not expected for a "get" function
to perform such an action, but also the decision to start/stop forwarding is
already handled correctly by pim outside `igmp_get_source_by_addr()`.
That call was left there from the days pim was initially imported into the sources.

The problem/crash was happening because `igmp_find_source_by_addr()` would fail to
find the group/source combo when mixing `(*, G)` and `(S, G)`. When having an existing
flow `(*, G)`, and a new `(S, G)` igmp is received, a new entry is correctly created.
`igmp_anysource_forward_stop(group)` always stops and eventually frees `(*, G)`, even
when the new igmp is `(S, G)`, leaving a bad state. I.e, the new entry for `(S, G)`
causes `(*, G)` to be deleted.

Tested the fix with multiple receivers on the same interface with several ssm and
any source senders and receivers with various combination of start/stop orders and
they all worked correctly.

Fixes: #15630

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2024-05-30 23:20:03 -05:00
Sarita Patra 8e595849fc pimd: remove api source_channel_oil_detach()
This API is no more in use.

Signed-off-by: Sarita Patra <saritap@vmware.com>
2023-06-04 22:23:56 -07:00
Sarita Patra cb809c0d6c pim6d: Clear channel_oil on prune
Receiver---LHR---RP

Problem:
In LHR, ipv6 pim state remains after MLD prune received.

Root Cause:
When LHR receives join, it creates (*,G) channel oil with
oil_ref_count = 2. The channel_oil is used by gm_sg sg->oil
and upstream->channel_oil.

When LHR receives prune, currently upstream->channel_oil is
deleted and gm_sg sg->oil still present. Due to this channel_oil
is still present with oil_ref_count = 1

Fix:
When LHR receives prune, upstream->channel_oil and pim_sg sg->oil
needs to be deleted.

Issue: #11249

Signed-off-by: Sarita Patra <saritap@vmware.com>
2023-06-04 22:23:56 -07:00
Donald Sharp e16d030c65 *: Convert THREAD_XXX macros to EVENT_XXX macros
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 907a2395f4 *: Convert thread_add_XXX functions to event_add_XXX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp e6685141aa *: Rename struct thread to struct event
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-24 08:32:17 -04: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
Abhishek N R a96d64b0d6 pimd, pim6d: Changing IGMP to GM in debug macros.
Changed PIM_DEBUG_IGMP_TRACE to PIM_DEBUG_GM_TRACE and
PIM_DEBUG_IGMP_TRACE_DETAIL to PIM_DEBUG_GM_TRACE_DETAIL.
Hence, these macros can be used for both v6 and v4.

Issue: #11895

Co-authored-by: Sai Gomathi N <nsaigomathi@vmware.com>
Signed-off-by: Abhishek N R <abnr@vmware.com>
2022-09-13 23:29:33 -07:00
Sai Gomathi N 55eb347de9 pimd,pim6d: Modifying IGMP to GM in PIM_DEBUG_IGMP_PACKETS to PIM_DEBUG_GM_PACKETS
Changing the macros to common so that it can be used for pimv6 debugs as well
to be used for both IGMP and MLD debugs.

Signed-off-by: Sai Gomathi N <nsaigomathi@vmware.com>
2022-09-04 22:46:09 -07:00
Sai Gomathi N 95b13dc512 pimd,pim6d: Modifying IGMP to GM in PIM_DEBUG_IGMP_EVENTS to PIM_DEBUG_GM_EVENTS
Changing the macros to common so that it can be used for pimv6 debugs as well
to be used for both IGMP and MLD debugs.

Signed-off-by: Sai Gomathi N <nsaigomathi@vmware.com>
2022-09-04 22:46:09 -07:00
Donald Sharp c7c5d685c0 pimd: Disable handling v3 igmp packets on an interface config'ed for v2
pimd is receiving v3 igmp packets on an interface that is setup as v2 and
causing the igmp group as configured on that interface to get a bit
wonky.

Add a check to receiving v3 packets and to drop the packet if the
igmp version configed on the interface is 2.

Fixes: #11105
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-25 20:05:49 -04: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
Mobashshera Rasool 14c7ac504f pimd: Set new to true in igmp_get_source_by_addr api
5421bf8 commit forgot to set the parameter "new" to true
when a new source is created, have fixed it.

igmp_get_source_by_addr api is currently setting the parameter
"new" to false always. This is not right. The caller apis are using
this field to decide and based on that take actions to create timers, etc.

Its need to be set to true when a new source is created.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-04-21 05:54:40 -07:00
Donald Sharp b97047ed11 *: Fix spelling of non-existant
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:16:45 -04:00
Donald Sharp 07b12758be pimd, zebra: Fix spelling of fowarding
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-02 07:46:19 -04:00
Donald Sharp 6ec6186af9
Merge pull request #10012 from AbhishekNR/upstream
pimd : Handling of Exclude mode IGMPv3 report messages for SSM aware group.
2022-03-15 07:54:04 -04:00
Donatas Abraitis 278912eabf pimd: Add additional IGMP stats (generic/group specific queries sent)
```
exit1-debian-11# sh ip igmp statistics
IGMP statistics
Interface            : global
V1 query             : 0
V2 query             : 0
V3 query             : 6
V2 leave             : 0
V1 report            : 0
V2 report            : 0
V3 report            : 14
mtrace response      : 0
mtrace request       : 0
unsupported          : 0
joins failed         : 0
joins sent           : 16
general queries sent : 6
group queries sent   : 4
total groups         : 5
total source groups  : 1
exit1-debian-11# sh ip igmp statistics json
{
  "global":{
    "name":"global",
    "queryV1":0,
    "queryV2":0,
    "queryV3":6,
    "leaveV2":0,
    "reportV1":0,
    "reportV2":0,
    "reportV3":18,
    "mtraceResponse":0,
    "mtraceRequest":0,
    "unsupported":0,
    "totalGroups":5,
    "totalSourceGroups":1,
    "joinsFailed":0,
    "joinsSent":16,
    "generalQueriesSent":6,
    "groupQueriesSent":4
  }
}
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-14 10:50:28 +02:00
Donatas Abraitis f2058cb425 pimd: Add IGMP join sent/failed statistics
```
exit1-debian-11# sh ip igmp statistics
IGMP statistics
Interface           : global
V1 query            : 0
V2 query            : 0
V3 query            : 0
V2 leave            : 0
V1 report           : 0
V2 report           : 0
V3 report           : 16
mtrace response     : 0
mtrace request      : 0
unsupported         : 0
joins failed        : 0
joins sent          : 11
total groups        : 4
total source groups : 0
exit1-debian-11# sh ip igmp statistics json
{
  "global":{
    "name":"global",
    "queryV1":0,
    "queryV2":0,
    "queryV3":0,
    "leaveV3":0,
    "reportV1":0,
    "reportV2":0,
    "reportV3":16,
    "mtraceResponse":0,
    "mtraceRequest":0,
    "unsupported":0,
    "totalGroups":4,
    "totalSourceGroups":0,
    "joinsFailed":0,
    "joinsSent":11
  }
}
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-13 19:31:34 +02:00
Donald Sharp cc9f21da22 *: Change thread->func to return void instead of int
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-23 19:56:04 -05:00
Abhishek N R f6053ff29d pimd : Handling of Exclude mode IGMPv3 report messages for SSM aware group.
Problem Statement:
==================

(rcv1)-----A----B---C
 v3 enabled with src 90.0.0.1
       |
(rcv2)--
 v3 enable with src none

rcv1 sends the packet in INCLUDE mode, rcv2 sends the IGMP report
in exclude mode. As per the state machine the group structure was
getting added and deleted. As group gets deleted the mroute for 90.0.0.1
and recreated back.
This effects the end to end trafiic.

Root Cause Analysis:
====================
As per state machine
INCLUDE (A) IS_EX (B) EXCLUDE (A*B,B-A) (B-A)=0
Delete (A-B)
Group Timer=GMI

EXCLUDE (X,Y) TO_EX (A) EXCLUDE (A-Y,Y*A) (A-X-Y)=Group Timer
Delete (X-A)
Delete (Y-A)
Send Q(G,A-Y)
Group Timer=GMI

The above equations were getiing calulated for IP address
90.0.0.1 and 0.0.0.0
This results in group creation deletion.

Fix:
====
As per RFC 4604.
drop the exclude mode, IGMP reports, if destnation group is
SSM based.
EXCLUDE
mode does not apply to SSM addresses, and an SSM-aware router will
ignore MODE_IS_EXCLUDE and CHANGE_TO_EXCLUDE_MODE requests in the SSM
range.

Signed-off-by: Abhishek N R <abnr@vmware.com>
Signed-off-by: Vishal Dhingra <rac.vishaldhingra@gmail.com>
2022-01-20 07:52:06 -08:00
David Lamparter 3ca68c9cf3 pimd: remove PIM_INADDR_IS[NOT]_ANY macros
These really don't serve much of a purpose, especially with how
inconsistently they're used.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-01-17 14:11:08 +01:00
Sai Gomathi 18adcff1c0 pimd: Modifying members of pim_interface to accommodate IPv6 changes
Modifying the members of pim_interface which are to be used
for both IPv4 and IPv6 to common names(for both MLD and IGMP).

Issues: #10023

Co-authored-by: Mobashshera Rasool <mrasool@vmware.com>
Co-authored-by: Sarita Patra <saritap@vmware.com>
Signed-off-by: Sai Gomathi <nsaigomathi@vmware.com>
2022-01-11 03:18:06 -08:00
Stephen Worley ad1229a077
Merge pull request #10215 from FRRouting/revert-10164-name_change
Revert "pimd: Modifying members of pim_interface to accommodate IPv6 changes"
2021-12-15 17:40:53 -05:00
David Lamparter 29e5822590
Revert "pimd: Modifying members of pim_interface to accommodate IPv6 changes" 2021-12-14 17:33:24 +01:00
Sai Gomathi c5f76fad1a pimd: Modifying struct igmp_sock to gm_sock for IPv6
Modifying name of struct igmp_sock to struct gm_sock, which is to be used
by both IPv4 and IPv6(for both MLD and IGMP).

Co-authored-by: Mobashshera Rasool <mrasool@vmware.com>
Co-authored-by: Sarita Patra <saritap@vmware.com>
Signed-off-by: Sai Gomathi <nsaigomathi@vmware.com>
2021-12-03 10:27:12 -08:00
Sai Gomathi a16db099e4 pimd: Modifying name of struct igmp_group to struct gm_group for IPv6.
Modifying name of struct igmp_group to struct gm_group, which is to be used
by both IPv4 and IPv6(for both MLD and IGMP).

Co-authored-by: Mobashshera Rasool <mrasool@vmware.com>
Co-authored-by: Sarita Patra <saritap@vmware.com>
Signed-off-by: Sai Gomathi <nsaigomathi@vmware.com>
2021-12-03 10:11:13 -08:00
Sai Gomathi 517001077f pimd: Modifying name of struct igmp_source to struct gm_source for IPv6.
Modifying name of struct igmp_source to struct gm_source, which is to be used
by both IPv4 and IPv6(for both MLD and IGMP).

Co-authored-by: Mobashshera Rasool <mrasool@vmware.com>
Co-authored-by: Sarita Patra <saritap@vmware.com>
Signed-off-by: Sai Gomathi <nsaigomathi@vmware.com>
2021-12-03 10:10:40 -08:00
Sai Gomathi ea7d74d702 pimd: Modifying members of pim_interface to accommodate IPv6 changes
Modifying the members of pim_interface which are to be used
for both IPv4 and IPv6 to common names(for both MLD and IGMP).

Issue: #10023

Co-authored-by: Mobashshera Rasool <mrasool@vmware.com>
Signed-off-by: Sai Gomathi <nsaigomathi@vmware.com>
2021-12-02 23:12:58 -08:00
David Lamparter 5421bf8f1d pimd: fuse source_new() and add_source_by_addr()
This makes a lot more sense semantically (and matches the way groups are
handled.)  Also allows placing additional restrictions on source
creation (e.g. limit on number of sources or ACLs.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-08-27 10:46:53 +02:00
David Lamparter a1a4295ade pimd: reformat after dropping indent levels
Intentionally separate here because the previous patch does a whole
bunch of "move stuff up 1 level of indentation", and reviewing that is
easier when you can use the ignore-whitespace option on diff.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-08-27 10:46:53 +02:00
David Lamparter dda4d23cca pimd: IGMP memberships are not querier specific
IGMP group/source memberships are a property of the interface;  the
particular IP address that the querier used to collect the data is
irrelevant.

... and IGMP packets get delivered only once to pimd anyway, since we
receive them on the "global" per-VRF IGMP socket.  (The one in igmp_sock
is only used for sending queries.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-08-27 10:42:53 +02:00
Jafar Al-Gharaibeh 26d0cbbb76 pimd: fix coverity/dead-code issue
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2021-08-25 15:10:32 -05:00
Sai Gomathi fcf5d4386a pimd: IGMP groups are not getting timeout
Problem :
=======
When all the groups from Ixia are stopped,
groups still keep refreshing and not getting timeout

RCA:
====
IGMP Report is coming in include mode without any source address, this problem will come.

Fix :
===
If the requested filter mode is INCLUDE *and* the requested
source list is empty, then the entry corresponding to the
requested interface and multicast address is deleted if present.
If no such entry is present, the request is ignored.

When an interface receives the IGMP report without any source, then the group is deleted.

Signed-off-by: Sai Gomathi <nsaigomathi@vmware.com>
2021-08-23 22:25:30 -07:00
Donatas Abraitis 12256b84a5 *: Convert numeric 32 into IPV4_MAX_BITLEN for prefixlen
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-01 23:50:39 +03:00
David Lamparter df5dfb77b5 pimd: zassert => assert
No point in having pimd use zassert() while everything else uses plain
assert().

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-23 12:25:47 +02:00
Mobashshera Rasool 9041c30ad1 pimd: checksum must be validated before accepting igmp packets
Issue: When an IGMPv2 leave packet is received, it did not validate
the checksum and hence the packet is accepted and group specific
query is sent out in response to this.

Due to this IGMP conformance test case 6.1 failed.

https://github.com/FRRouting/frr/issues/6868

Fix: Validate the checksum for all IGMP packets

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2020-11-17 13:34:12 +00:00
Mark Stapp ee2bbf7ce2 pimd: replace inet_ntoa
Replace all use of inet_ntoa, using %pI4 or inet_ntoa instead

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-22 10:13:56 -04:00
Quentin Young 772270f3b6 *: sprintf -> snprintf
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-04-20 19:14:33 -04:00
Donald Sharp 5e81f5dd1a *: Finish off the __PRETTY_FUNCTION__ to __func__
FINISH IT

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-06 09:23:22 -05:00
Donatas Abraitis 15569c58f8 *: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__
Just keep the code cool.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-05 20:23:23 +02:00
Donald Sharp c7e663d68a pimd: Cleanup igmp debugs a tiny bit
When receiving igmp packets we are spitting out a lot of
debugs.  Attempt to clean this up to allow us to understand
what is going on a bit better by just being able to look
at the log file.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-12 09:38:04 -05:00
Donald Sharp 8a3e7e9ed9 pimd: Add debugs for channel_oil creation and deletion
Add some debugs so we can see channel oil creation and deletion
events.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-14 19:22:43 -04:00
Sarita Patra 59115451a8 pimd: new cli to configure last-member-query-count & last-member-query-interval
Introduce new cli commands ip igmp last-member-query-count <1-7>
ip igmp last-member-query-interval <1-255> deciseconds.

Display the config in show running config and show ip igmp interface

Signed-off-by: Sarita Patra <saritap@vmware.com>
2019-05-29 20:36:16 -07:00
Donald Sharp 36417fcc20 pimd: Create a struct pim_router and move thread master into it
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>
2019-01-04 12:21:00 -05:00
Quentin Young 450971aa99 *: LIB_[ERR|WARN] -> EC_LIB
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:34:28 +00:00