2015-02-04 07:01:14 +01:00
|
|
|
/*
|
2017-05-13 10:25:29 +02:00
|
|
|
* PIM for Quagga
|
|
|
|
* Copyright (C) 2008 Everton da Silva Marques
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; see the file COPYING; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
#ifndef PIM_IGMP_H
|
|
|
|
#define PIM_IGMP_H
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
#include "vty.h"
|
|
|
|
#include "linklist.h"
|
2018-05-04 13:25:38 +02:00
|
|
|
#include "pim_igmp_stats.h"
|
2021-12-14 08:12:29 +01:00
|
|
|
#include "pim_str.h"
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
The following sizes are likely to support
|
|
|
|
any message sent within local MTU.
|
|
|
|
*/
|
|
|
|
#define PIM_IGMP_BUFSIZE_READ (20000)
|
|
|
|
#define PIM_IGMP_BUFSIZE_WRITE (20000)
|
|
|
|
|
|
|
|
#define PIM_IGMP_MEMBERSHIP_QUERY (0x11)
|
|
|
|
#define PIM_IGMP_V1_MEMBERSHIP_REPORT (0x12)
|
|
|
|
#define PIM_IGMP_V2_MEMBERSHIP_REPORT (0x16)
|
|
|
|
#define PIM_IGMP_V2_LEAVE_GROUP (0x17)
|
2018-02-12 23:41:33 +01:00
|
|
|
#define PIM_IGMP_MTRACE_RESPONSE (0x1E)
|
|
|
|
#define PIM_IGMP_MTRACE_QUERY_REQUEST (0x1F)
|
2015-02-04 07:01:14 +01:00
|
|
|
#define PIM_IGMP_V3_MEMBERSHIP_REPORT (0x22)
|
|
|
|
|
|
|
|
#define IGMP_V3_REPORT_HEADER_SIZE (8)
|
|
|
|
#define IGMP_V3_GROUP_RECORD_MIN_SIZE (8)
|
|
|
|
#define IGMP_V3_MSG_MIN_SIZE \
|
|
|
|
(IGMP_V3_REPORT_HEADER_SIZE + IGMP_V3_GROUP_RECORD_MIN_SIZE)
|
|
|
|
#define IGMP_V12_MSG_SIZE (8)
|
|
|
|
|
|
|
|
#define IGMP_V3_GROUP_RECORD_TYPE_OFFSET (0)
|
|
|
|
#define IGMP_V3_GROUP_RECORD_AUXDATALEN_OFFSET (1)
|
|
|
|
#define IGMP_V3_GROUP_RECORD_NUMSOURCES_OFFSET (2)
|
|
|
|
#define IGMP_V3_GROUP_RECORD_GROUP_OFFSET (4)
|
|
|
|
#define IGMP_V3_GROUP_RECORD_SOURCE_OFFSET (8)
|
2016-10-20 15:34:29 +02:00
|
|
|
#define IGMP_CHECKSUM_OFFSET (2)
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
/* RFC 3376: 8.1. Robustness Variable - Default: 2 */
|
|
|
|
#define IGMP_DEFAULT_ROBUSTNESS_VARIABLE (2)
|
|
|
|
|
|
|
|
/* RFC 3376: 8.2. Query Interval - Default: 125 seconds */
|
|
|
|
#define IGMP_GENERAL_QUERY_INTERVAL (125)
|
|
|
|
|
|
|
|
/* RFC 3376: 8.3. Query Response Interval - Default: 100 deciseconds */
|
|
|
|
#define IGMP_QUERY_MAX_RESPONSE_TIME_DSEC (100)
|
|
|
|
|
|
|
|
/* RFC 3376: 8.8. Last Member Query Interval - Default: 10 deciseconds */
|
|
|
|
#define IGMP_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC (10)
|
|
|
|
|
2016-10-20 15:34:29 +02:00
|
|
|
#define IGMP_DEFAULT_VERSION (3)
|
|
|
|
|
2020-10-14 15:51:32 +02:00
|
|
|
#define IGMP_GET_INT16(ptr, output) \
|
|
|
|
do { \
|
|
|
|
output = *(ptr) << 8; \
|
|
|
|
output |= *((ptr) + 1); \
|
|
|
|
} while (0)
|
|
|
|
|
2021-12-03 18:25:20 +01:00
|
|
|
struct gm_join {
|
2021-12-14 08:12:29 +01:00
|
|
|
pim_addr group_addr;
|
|
|
|
pim_addr source_addr;
|
2015-02-04 07:01:14 +01:00
|
|
|
int sock_fd;
|
|
|
|
time_t sock_creation;
|
|
|
|
};
|
|
|
|
|
2021-12-03 19:23:23 +01:00
|
|
|
struct gm_sock {
|
2015-02-04 07:01:14 +01:00
|
|
|
int fd;
|
|
|
|
struct interface *interface;
|
2021-12-14 13:25:40 +01:00
|
|
|
pim_addr ifaddr;
|
2015-02-04 07:01:14 +01:00
|
|
|
time_t sock_creation;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
struct thread *t_igmp_read; /* read: IGMP sockets */
|
|
|
|
struct thread
|
|
|
|
*t_igmp_query_timer; /* timer: issue IGMP general queries */
|
|
|
|
struct thread *t_other_querier_timer; /* timer: other querier present */
|
2021-12-14 13:25:40 +01:00
|
|
|
pim_addr querier_addr; /* IP address of the querier */
|
2021-07-05 18:24:19 +02:00
|
|
|
int querier_query_interval; /* QQI */
|
2015-02-04 07:01:14 +01:00
|
|
|
int querier_robustness_variable; /* QRV */
|
|
|
|
int startup_query_count;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-02-27 23:16:45 +01:00
|
|
|
bool mtrace_only;
|
|
|
|
|
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-10 17:10:43 +01:00
|
|
|
struct igmp_stats igmp_stats;
|
2015-02-04 07:01:14 +01:00
|
|
|
};
|
|
|
|
|
2021-08-24 15:25:48 +02:00
|
|
|
struct pim_interface;
|
|
|
|
|
2022-01-18 11:37:56 +01:00
|
|
|
#if PIM_IPV == 4
|
2021-08-24 15:25:48 +02:00
|
|
|
void pim_igmp_if_init(struct pim_interface *pim_ifp, struct interface *ifp);
|
|
|
|
void pim_igmp_if_reset(struct pim_interface *pim_ifp);
|
|
|
|
void pim_igmp_if_fini(struct pim_interface *pim_ifp);
|
|
|
|
|
2021-12-03 19:23:23 +01:00
|
|
|
struct gm_sock *pim_igmp_sock_lookup_ifaddr(struct list *igmp_sock_list,
|
|
|
|
struct in_addr ifaddr);
|
|
|
|
struct gm_sock *pim_igmp_sock_add(struct list *igmp_sock_list,
|
|
|
|
struct in_addr ifaddr, struct interface *ifp,
|
|
|
|
bool mtrace_only);
|
|
|
|
void igmp_sock_delete(struct gm_sock *igmp);
|
|
|
|
void igmp_sock_free(struct gm_sock *igmp);
|
2016-10-28 02:35:22 +02:00
|
|
|
void igmp_sock_delete_all(struct interface *ifp);
|
2021-12-03 19:23:23 +01:00
|
|
|
int pim_igmp_packet(struct gm_sock *igmp, char *buf, size_t len);
|
2021-07-26 15:35:31 +02:00
|
|
|
bool pim_igmp_verify_header(struct ip *ip_hdr, size_t len, size_t *ip_hlen);
|
2021-12-03 19:23:23 +01:00
|
|
|
void pim_igmp_general_query_on(struct gm_sock *igmp);
|
|
|
|
void pim_igmp_general_query_off(struct gm_sock *igmp);
|
|
|
|
void pim_igmp_other_querier_timer_on(struct gm_sock *igmp);
|
|
|
|
void pim_igmp_other_querier_timer_off(struct gm_sock *igmp);
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2020-10-14 15:51:32 +02:00
|
|
|
int igmp_validate_checksum(char *igmp_msg, int igmp_msg_len);
|
|
|
|
|
2022-01-18 11:37:56 +01:00
|
|
|
#else /* PIM_IPV != 4 */
|
2022-03-10 13:10:37 +01:00
|
|
|
static inline void pim_igmp_if_init(struct pim_interface *pim_ifp,
|
|
|
|
struct interface *ifp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void pim_igmp_if_fini(struct pim_interface *pim_ifp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-01-18 11:37:56 +01:00
|
|
|
static inline void pim_igmp_general_query_on(struct gm_sock *igmp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void pim_igmp_general_query_off(struct gm_sock *igmp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void pim_igmp_other_querier_timer_on(struct gm_sock *igmp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void pim_igmp_other_querier_timer_off(struct gm_sock *igmp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif /* PIM_IPV == 4 */
|
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
#define IGMP_SOURCE_MASK_FORWARDING (1 << 0)
|
|
|
|
#define IGMP_SOURCE_MASK_DELETE (1 << 1)
|
|
|
|
#define IGMP_SOURCE_MASK_SEND (1 << 2)
|
|
|
|
#define IGMP_SOURCE_TEST_FORWARDING(flags) ((flags) & IGMP_SOURCE_MASK_FORWARDING)
|
|
|
|
#define IGMP_SOURCE_TEST_DELETE(flags) ((flags) & IGMP_SOURCE_MASK_DELETE)
|
|
|
|
#define IGMP_SOURCE_TEST_SEND(flags) ((flags) & IGMP_SOURCE_MASK_SEND)
|
|
|
|
#define IGMP_SOURCE_DO_FORWARDING(flags) ((flags) |= IGMP_SOURCE_MASK_FORWARDING)
|
|
|
|
#define IGMP_SOURCE_DO_DELETE(flags) ((flags) |= IGMP_SOURCE_MASK_DELETE)
|
|
|
|
#define IGMP_SOURCE_DO_SEND(flags) ((flags) |= IGMP_SOURCE_MASK_SEND)
|
|
|
|
#define IGMP_SOURCE_DONT_FORWARDING(flags) ((flags) &= ~IGMP_SOURCE_MASK_FORWARDING)
|
|
|
|
#define IGMP_SOURCE_DONT_DELETE(flags) ((flags) &= ~IGMP_SOURCE_MASK_DELETE)
|
|
|
|
#define IGMP_SOURCE_DONT_SEND(flags) ((flags) &= ~IGMP_SOURCE_MASK_SEND)
|
|
|
|
|
2021-12-03 18:33:53 +01:00
|
|
|
struct gm_source {
|
2021-12-14 11:02:48 +01:00
|
|
|
pim_addr source_addr;
|
2015-02-04 07:01:14 +01:00
|
|
|
struct thread *t_source_timer;
|
2021-12-03 18:41:52 +01:00
|
|
|
struct gm_group *source_group; /* back pointer */
|
2015-02-04 07:01:14 +01:00
|
|
|
time_t source_creation;
|
|
|
|
uint32_t source_flags;
|
|
|
|
struct channel_oil *source_channel_oil;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
/*
|
|
|
|
RFC 3376: 6.6.3.2. Building and Sending Group and Source Specific
|
|
|
|
Queries
|
|
|
|
*/
|
|
|
|
int source_query_retransmit_count;
|
|
|
|
};
|
|
|
|
|
2021-12-03 18:41:52 +01:00
|
|
|
struct gm_group {
|
2015-02-04 07:01:14 +01:00
|
|
|
/*
|
|
|
|
RFC 3376: 6.2.2. Definition of Group Timers
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
The group timer is only used when a group is in EXCLUDE mode and it
|
|
|
|
represents the time for the *filter-mode* of the group to expire and
|
|
|
|
switch to INCLUDE mode.
|
|
|
|
*/
|
|
|
|
struct thread *t_group_timer;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
/* Shared between group-specific and
|
|
|
|
group-and-source-specific retransmissions */
|
|
|
|
struct thread *t_group_query_retransmit_timer;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
/* Counter exclusive for group-specific retransmissions
|
|
|
|
(not used by group-and-source-specific retransmissions,
|
|
|
|
since sources have their counters) */
|
|
|
|
int group_specific_query_retransmit_count;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-10-20 15:34:29 +02:00
|
|
|
/* compatibility mode - igmp v1, v2 or v3 */
|
|
|
|
int igmp_version;
|
2021-12-13 15:03:31 +01:00
|
|
|
pim_addr group_addr;
|
2015-02-04 07:01:14 +01:00
|
|
|
int group_filtermode_isexcl; /* 0=INCLUDE, 1=EXCLUDE */
|
2021-12-03 18:33:53 +01:00
|
|
|
struct list *group_source_list; /* list of struct gm_source */
|
2015-02-04 07:01:14 +01:00
|
|
|
time_t group_creation;
|
2021-08-24 15:25:48 +02:00
|
|
|
struct interface *interface;
|
2015-02-04 07:01:14 +01:00
|
|
|
int64_t last_igmp_v1_report_dsec;
|
|
|
|
int64_t last_igmp_v2_report_dsec;
|
|
|
|
};
|
|
|
|
|
2022-01-18 11:37:56 +01:00
|
|
|
#if PIM_IPV == 4
|
2022-02-28 11:42:48 +01:00
|
|
|
struct pim_instance;
|
|
|
|
|
|
|
|
void igmp_anysource_forward_start(struct pim_instance *pim,
|
|
|
|
struct gm_group *group);
|
|
|
|
void igmp_anysource_forward_stop(struct gm_group *group);
|
|
|
|
|
|
|
|
void igmp_source_forward_start(struct pim_instance *pim,
|
|
|
|
struct gm_source *source);
|
|
|
|
void igmp_source_forward_stop(struct gm_source *source);
|
|
|
|
void igmp_source_forward_reevaluate_all(struct pim_instance *pim);
|
|
|
|
|
2021-12-03 19:23:23 +01:00
|
|
|
struct gm_group *find_group_by_addr(struct gm_sock *igmp,
|
2021-12-03 18:41:52 +01:00
|
|
|
struct in_addr group_addr);
|
2021-12-03 19:23:23 +01:00
|
|
|
struct gm_group *igmp_add_group_by_addr(struct gm_sock *igmp,
|
2021-12-03 18:41:52 +01:00
|
|
|
struct in_addr group_addr);
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2021-12-03 18:41:52 +01:00
|
|
|
struct gm_source *igmp_get_source_by_addr(struct gm_group *group,
|
|
|
|
struct in_addr src_addr,
|
|
|
|
bool *created);
|
2021-08-24 18:17:05 +02:00
|
|
|
|
2021-12-03 18:41:52 +01:00
|
|
|
void igmp_group_delete_empty_include(struct gm_group *group);
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2021-12-03 19:23:23 +01:00
|
|
|
void igmp_startup_mode_on(struct gm_sock *igmp);
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2021-12-03 18:41:52 +01:00
|
|
|
void igmp_group_timer_on(struct gm_group *group, long interval_msec,
|
2015-02-04 07:01:14 +01:00
|
|
|
const char *ifname);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
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 08:26:22 +01:00
|
|
|
void igmp_send_query(int igmp_version, struct gm_group *group, char *query_buf,
|
|
|
|
int query_buf_size, int num_sources,
|
|
|
|
struct in_addr dst_addr, struct in_addr group_addr,
|
2016-10-20 15:34:29 +02:00
|
|
|
int query_max_response_time_dsec, uint8_t s_flag,
|
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 08:26:22 +01:00
|
|
|
struct gm_sock *igmp);
|
2021-12-03 18:41:52 +01:00
|
|
|
void igmp_group_delete(struct gm_group *group);
|
2019-06-13 19:21:37 +02:00
|
|
|
|
|
|
|
void igmp_send_query_on_intf(struct interface *ifp, int igmp_ver);
|
2022-01-18 11:37:56 +01:00
|
|
|
|
|
|
|
#else /* PIM_IPV != 4 */
|
|
|
|
static inline void igmp_startup_mode_on(struct gm_sock *igmp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif /* PIM_IPV != 4 */
|
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
#endif /* PIM_IGMP_H */
|