1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* IP SSM ranges for FRR
* Copyright (C) 2017 Cumulus Networks, Inc.
*/
#include <zebra.h>
#include <lib/linklist.h>
#include <lib/prefix.h>
#include <lib/vty.h>
#include <lib/vrf.h>
#include <lib/plist.h>
#include <lib/lib_errors.h>
#include "pimd.h"
#include "pim_instance.h"
#include "pim_ssm.h"
#include "pim_igmp.h"
static void pim_ssm_range_reevaluate(struct pim_instance *pim)
{
#if PIM_IPV == 4
/* 1. Setup register state for (S,G) entries if G has changed from SSM
* to
* ASM.
* 2. check existing (*,G) IGMP registrations to see if they are
* still ASM. if they are now SSM delete them.
* 3. Allow channel setup for IGMP (*,G) members if G is now ASM
* 4. I could tear down all (*,G), (S,G,rpt) states. But that is an
* unnecessary sladge hammer and may not be particularly useful as it is
* likely the SPT switchover has already happened for flows along such
* RPTs.
* As for the RPT states it seems that the best thing to do is let them
* age
* out gracefully. As long as the FHR and LHR do the right thing RPTs
* will
* disappear in time for SSM groups.
*/
pim_upstream_register_reevaluate(pim);
igmp_source_forward_reevaluate_all(pim);
#endif
}
void pim_ssm_prefix_list_update(struct pim_instance *pim,
struct prefix_list *plist)
{
struct pim_ssm *ssm = pim->ssm_info;
if (!ssm->plist_name
|| strcmp(ssm->plist_name, prefix_list_name(plist))) {
/* not ours */
return;
}
pim_ssm_range_reevaluate(pim);
}
static int pim_is_grp_standard_ssm(struct prefix *group)
{
pim_addr addr = pim_addr_from_prefix(group);
return pim_addr_ssm(addr);
}
int pim_is_grp_ssm(struct pim_instance *pim, pim_addr group_addr)
{
struct pim_ssm *ssm;
struct prefix group;
struct prefix_list *plist;
pim_addr_to_prefix(&group, group_addr);
ssm = pim->ssm_info;
if (!ssm->plist_name) {
return pim_is_grp_standard_ssm(&group);
}
plist = prefix_list_lookup(PIM_AFI, ssm->plist_name);
if (!plist)
return 0;
return (prefix_list_apply_ext(plist, NULL, &group, true) ==
PREFIX_PERMIT);
}
int pim_ssm_range_set(struct pim_instance *pim, vrf_id_t vrf_id,
const char *plist_name)
{
struct pim_ssm *ssm;
int change = 0;
if (vrf_id != pim->vrf->vrf_id)
return PIM_SSM_ERR_NO_VRF;
ssm = pim->ssm_info;
if (plist_name) {
if (ssm->plist_name) {
if (!strcmp(ssm->plist_name, plist_name))
return PIM_SSM_ERR_DUP;
XFREE(MTYPE_PIM_FILTER_NAME, ssm->plist_name);
}
ssm->plist_name = XSTRDUP(MTYPE_PIM_FILTER_NAME, plist_name);
change = 1;
} else {
if (ssm->plist_name) {
change = 1;
XFREE(MTYPE_PIM_FILTER_NAME, ssm->plist_name);
}
}
if (change)
pim_ssm_range_reevaluate(pim);
return PIM_SSM_ERR_NONE;
}
void *pim_ssm_init(void)
{
struct pim_ssm *ssm;
ssm = XCALLOC(MTYPE_PIM_SSM_INFO, sizeof(*ssm));
return ssm;
}
void pim_ssm_terminate(struct pim_ssm *ssm)
{
if (!ssm)
return;
XFREE(MTYPE_PIM_FILTER_NAME, ssm->plist_name);
XFREE(MTYPE_PIM_SSM_INFO, ssm);
}
|