Commit Graph

108 Commits

Author SHA1 Message Date
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
6ea4244514
Merge pull request #10399 from g-balaji1/pimv6-sock
pim6d: PIMv6 socket related changes
2022-03-13 10:03:45 -04:00
David Lamparter
cd6d285855 pimd: refactor/split IGMP integration
Try to untangle some spaghetti...

This is an 1:1 change that should not result in any functional
difference.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-12 22:47:08 +01:00
Balaji Gurudoss
023d3e4af8 pim6d: pim6d socket changes
socket changes to support IPv6 PIM

Signed-off-by: Balaji Gurudoss <G_Balaji1@dell.com>
[DL: cleaned up & refactored a whole bunch more.]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-12 15:59:01 +01:00
Mobashshera Rasool
baee5b57fc pimd: FRR drops IGMP packets for TOS value other than 0XC0
Currently the code is expecting the TOS value for received
packet to be 0xC0 and hence it is discarding packets having
TOS value other than 0xc0.

We need to make sure that we are sending the packet with
TOS 0xC0 and while receiving we can allow any TOS value.
Let's follow Postel's law.
Checked Cisco behavior as well. It also accepts all TOS values.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-02-24 22:10:52 -08: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
Mobashshera Rasool
5bc4a46b00 pimd: Querier to non-querier transistion to be ignored in a case
As per RFC 2236 section 3, when the leave message is received at a querier,
it starts sending Query messages for "last Member Query Interval*query count"
During this time there should not be any querier to non-querier
transition and the same router needs to send the remaning queries.

Fixes: #10422
Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-02-07 01:46:19 -08: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
Sai Gomathi
b850813975 pimd: removing no caller functions
Removing the no caller function declarations and definitions
in pimd directory.

Signed-off-by: Sai Gomathi <nsaigomathi@vmware.com>
2021-11-25 20:42:54 -08:00
Igor Ryzhov
096f7609f9 *: cleanup ifp->vrf_id
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-11-22 20:47:23 +03:00
David Lamparter
1e9044be8d *: clean up ifp-by-local-address function(s)
Most users of if_lookup_address_exact only cared about whether the
address is any local address.  Split that off into a separate function.

For the users that actually need the ifp - which I'm about to add a few
of - change it to prefer returning interfaces that are UP.

(Function name changed due to slight change in behavior re. UP state, to
avoid possible bugs from this change.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-11-17 11:17:44 +01:00
Donatas Abraitis
bf5335cf34 pimd: Do not explicitly set the thread pointer to NULL
FRR should only ever use the appropriate THREAD_ON/THREAD_OFF
semantics.  This is espacially true for the functions we
end up calling the thread for.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-04 19:29:06 +03: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
Donald Sharp
42589d2b72
Merge pull request #9194 from idryzhov/pim-bool-false
pimd: fix incorrect bool returns
2021-07-28 10:04:44 -04:00
Mobashshera Rasool
88ea79ad94 pimd: Validate the fields before accessing it
This commit is to correct the order in which the fields are
accessed while verifying it. First the fields should be
verified, and if it is valid then access it.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-07-27 02:12:30 -07:00
Igor Ryzhov
e748f180f5 pimd: fix incorrect bool returns
-1 is true when casted to bool.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-07-27 11:41:36 +03:00
Donald Sharp
d5b8e04651
Merge pull request #8986 from mobash-rasool/pim-upst-2
pimd: To print querierIP address on the querier and nonQuerier IGMP e…
2021-07-22 08:33:24 -04:00
Mobashshera Rasool
e39f74d04a pimd: Add TOS check for IGMP conformance
IGMPv3 packets with invalid TOS should be dropped.
Test Case ID: 4.10
TEST_DESCRIPTION
Every IGMP message described in this document is sent with
IP Precedence of Internetwork Control (e.g., Type of Service
0xc0)
(Tests that IGMPv3 Membership Query Message conforms to
above statement)
TEST_REFERENCE
NEGATIVE: RFC 3376, IGMP Version 3, s4 p7 Message Formats
Issue: #9071

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-07-19 19:46:10 +00:00
Mobashshera Rasool
54d7bf0cc6 pimd: Add TTL check for IGMP conformance
IGMPv3 packets with invalid TTL should be dropped.
Test Case ID: 4.10
TEST_DESCRIPTION
Every IGMP message described in this document is sent with an IP
Time-to-Live of 1 (Tests that IGMPv3 Membership Report Message
conforms to above statement)
TEST_REFERENCE
NEGATIVE: RFC 3376, IGMP Version 3, s4 p7 Message Formats
Issue: #9070

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-07-19 19:46:10 +00:00
Mobashshera Rasool
ff4ad8709b pimd: Abstracting header verification for igmp
Moving the header verification checks inside a function.

Signed-off-by: Mobashshera Rasool <mrassol@vmware.com>
2021-07-19 19:46:00 +00:00
github login name
9a7cee2673 pimd: To print querierIP address on the querier and nonQuerier IGMP enabled intf
1. Add the querierIP object to igmp_sock datastruct to save the IP address of the querier.
   Management of the querierIP object is added.
2. To show the querier IP address in the CLI "show ip igmp interface".
3. To add the json object querierIP for querier IP address in the json CLI "show ip igmp interface json".

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-07-06 00:14:28 -07:00
Donald Sharp
262649bd05 pimd: When bind fails give some extra data
When bind to a socket fails, let's give some color so we can
understand and fix the issue.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-19 14:48:11 -04: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
d1b61cb92d pimd: IGMP conformance 5.10 test case is failing
Test case 5.10 sends leave message to unicast address, the leave
packet is accepted and a query message is sent in response to this.
No validation for address is present in the function

Add check for addresses as per RFC. Leave messages are allowed only
sent to either ALL-ROUTERS (224.0.0.2) or group address.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2020-12-24 06:39:12 +00: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
Donald Sharp
28ef0ee121 *: Use proper semantics for turning off thread
We have this pattern in the code base:

if (thread)
	THREAD_OFF(thread);

If we look at THREAD_OFF we check to see if thread
is non-null too.  So we have a double check.
This is unnecessary.  Convert to just using THREAD_OFF

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-12 08:35:18 -04:00
Donald Sharp
2c85fdd4c3 pimd: When bind fails we could leave an open socket
Clean up the rare situation when bind fails to not
close the fd that was just opened and have the socket
leaked.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-24 08:12:49 -04:00
Donald Sharp
d12f46fa1a pimd: NULL not 0
When handling data pointers explicity use NULL not
0.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-24 08:10:26 -04:00
Nathan Bahr
bcdb04e68b pimd: fix IGMP querier election
Match by exact address rather than by prefix match to
determine if we generated the IGMPP query. Othwerwise
we will be ignoring IGMP queries coming from other
hosts on the same subnet.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
Reviewed-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2020-08-26 10:47:04 -05:00
Nathan Bahr
d05d3f7a6f pimd: fix IGMP source address on transmit
IGMP queries should contain the source address of the IGMP socket
they are being sent from.
Added binding the IGMP sockets to their specific source, otherwise
interfaces with multiple addresses will send multiple queries using
the same source, which is determined by the kernel.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
Reviewed-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2020-08-26 10:47:04 -05:00
David Lamparter
3efd0893d0 *: un-split strings across lines
Remove mid-string line breaks, cf. workflow doc:

  .. [#tool_style_conflicts] For example, lines over 80 characters are allowed
     for text strings to make it possible to search the code for them: please
     see `Linux kernel style (breaking long lines and strings)
     <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_
     and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_.

Scripted commit, idempotent to running:
```
python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'`
```

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 10:37:25 +02:00
David Lamparter
c334a16ef1
Merge pull request #6262 from qlyoung/remove-sprintf 2020-04-23 20:27:26 +02: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
saravanank
339f769530 pimd: Implement watermark warning for igmp group count and add igmp group count
This CLI will allow user to configure a igmp group limit which will generate
a watermark warning when reached.
Though watermark may not make sense without setting a limit, this
implementation shall serve as a base to implementing limit in future and helps
tracking a particular scale currently.

Testing:
=======

ip igmp watermark-warn <10-60000>

on reaching the configured number of group, pim will issue warning

2019/09/18 18:30:55 PIM: SCALE ALERT: igmp group count reached watermak limit: 210(vrf: default)

Also added group count and watermark limit configured on cli - show ip igmp groups [json]

<snip>

Sw3# sh ip igmp groups json
{
  "Total Groups":221,  <=====
  "Watermark limit":210, <=========
  "ens224":{
    "name":"ens224",
    "state":"up",
    "address":"40.0.0.1",
    "index":6,
    "flagMulticast":true,
    "flagBroadcast":true,
    "lanDelayEnabled":true,
    "groups":[
      {
        "source":"40.0.0.1",
        "group":"225.1.1.122",
        "timer":"00:03:56",
        "sourcesCount":1,
        "version":2,
        "uptime":"00:00:24"

<\snip>

<snip>

Sw3(config)# do sh ip igmp group
Total IGMP groups: 221
Watermark warn limit(Set) : 210
Interface        Address         Group           Mode Timer    Srcs V Uptime
ens224           40.0.0.1        225.1.1.122     ---- 00:04:06    1 2 00:13:22
ens224           40.0.0.1        225.1.1.144     ---- 00:04:02    1 2 00:13:22
ens224           40.0.0.1        225.1.1.57      ---- 00:04:01    1 2 00:13:22
ens224           40.0.0.1        225.1.1.210     ---- 00:04:06    1 2 00:13:22

<\snip>

Signed-off-by: Saravanan K <saravanank@vmware.com>
2020-04-08 21:39:13 -07: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
6b5122a0be pimd: Do not warn for common occurrence in igmp code
Do not warn when we receive a multicast address that
matches 224.0.0.0/24.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-01-03 08:41:46 -05:00
Quentin Young
f08e675074 pimd: readd iph length checks
Kernel might not hand us a bad packet, but better safe than sorry here.
Validate the IP header length field. Also adds an additional check that
the packet length is sufficient for an IGMP packet, and a check that we
actually have enough for an ip header at all.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-12-22 13:34:40 -05: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
26a0f1e2fe pimd: Ignore igmp queries from itself
We are seeing situations where PIM is sending a IGMP v3 query
and immediately receiving back up the pim kernel interface the
query from itself:

from `show int brief`:
swp7 up default 192.168.202.1/24

We are also receiving these debugs:
2019-11-11T20:52:40.452307+00:00 leaf02 pimd[1592]: Send IGMPv3 query to 224.4.0.8 on swp7 for group 224.4.0.8, sources=0 msg_size=12 s_flag=0 QRV=2 QQI=125 QQIC=7d
2019-11-11T20:52:40.452430+00:00 leaf02 pimd[1592]: pim_mroute_msg(default): igmp kernel upcall on swp7(0x55eaa7dc7dc0) for 192.168.202.1 -> 224.4.11.123
2019-11-11T20:52:40.452574+00:00 leaf02 pimd[1592]: Recv IP packet from 192.168.202.1 to 224.4.11.123 on swp7: size=40 ip_header_size=24 ip_proto=2
2019-11-11T20:52:40.452699+00:00 leaf02 pimd[1592]: Recv IGMP packet from 192.168.202.1 to 224.4.11.123 on swp7: ttl=1 msg_type=17 msg_size=16
2019-11-11T20:52:40.452824+00:00 leaf02 pimd[1592]: Recv IGMP query v3 from 192.168.202.1 on swp7 for group 224.4.11.123

This query is causing us to do some weird gyrations around the IGMP state machine for handling
queries.  Let's just prevent it from happening.

Ticket: CM-27247
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-12 07:56:06 -05:00
Donald Sharp
8890b440ac pimd: Dissallow query to be received from a non-connected source
When we receive an igmp query on a interface, ensure that the
source address of the packet is connected to the incoming
interface.  This will prevent a meanie from crafting a igmp
packet with a source address less than ours and causing
us to suspend query activities.

Fixes: #1692
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-25 00:30:11 -04:00
rgirada
6741a5bb4e pimd: Added cli to generate igmp query.
Fix details :
Added a utility cli to generate a igmp query on an interface.
This won't impact the existing query generation based on the
general query interval.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2019-06-24 03:15:10 -07:00
rgirada
4a5e6e7416 pimd: Re-deisgn the "clear ip mroute" command.
Made changes to clean up the all upstreams and ifchannels
in FRR apart from cleanup datapath mroutes when this command
issued.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2019-05-28 22:39:32 -07:00