]>
git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_ssm.c
2 * IP SSM ranges for FRR
3 * Copyright (C) 2017 Cumulus Networks, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <lib/linklist.h>
23 #include <lib/prefix.h>
26 #include <lib/plist.h>
30 #include "pim_zebra.h"
32 static void pim_ssm_range_reevaluate(struct pim_instance
*pim
)
34 /* 1. Setup register state for (S,G) entries if G has changed from SSM
37 * 2. check existing (*,G) IGMP registrations to see if they are
38 * still ASM. if they are now SSM delete them.
39 * 3. Allow channel setup for IGMP (*,G) members if G is now ASM
40 * 4. I could tear down all (*,G), (S,G,rpt) states. But that is an
41 * unnecessary sladge hammer and may not be particularly useful as it is
42 * likely the SPT switchover has already happened for flows along such
44 * As for the RPT states it seems that the best thing to do is let them
46 * out gracefully. As long as the FHR and LHR do the right thing RPTs
48 * disappear in time for SSM groups.
50 pim_upstream_register_reevaluate(pim
);
51 igmp_source_forward_reevaluate_all();
54 void pim_ssm_prefix_list_update(struct pim_instance
*pim
,
55 struct prefix_list
*plist
)
57 struct pim_ssm
*ssm
= pim
->ssm_info
;
60 || strcmp(ssm
->plist_name
, prefix_list_name(plist
))) {
65 pim_ssm_range_reevaluate(pim
);
68 static int pim_is_grp_standard_ssm(struct prefix
*group
)
71 static struct prefix group_ssm
;
74 str2prefix(PIM_SSM_STANDARD_RANGE
, &group_ssm
);
78 return prefix_match(&group_ssm
, group
);
81 int pim_is_grp_ssm(struct pim_instance
*pim
, struct in_addr group_addr
)
85 struct prefix_list
*plist
;
87 memset(&group
, 0, sizeof(group
));
88 group
.family
= AF_INET
;
89 group
.u
.prefix4
= group_addr
;
93 if (!ssm
->plist_name
) {
94 return pim_is_grp_standard_ssm(&group
);
97 plist
= prefix_list_lookup(AFI_IP
, ssm
->plist_name
);
101 return (prefix_list_apply(plist
, &group
) == PREFIX_PERMIT
);
104 int pim_ssm_range_set(struct pim_instance
*pim
, vrf_id_t vrf_id
,
105 const char *plist_name
)
110 if (vrf_id
!= pim
->vrf_id
)
111 return PIM_SSM_ERR_NO_VRF
;
115 if (ssm
->plist_name
) {
116 if (!strcmp(ssm
->plist_name
, plist_name
))
117 return PIM_SSM_ERR_DUP
;
118 XFREE(MTYPE_PIM_FILTER_NAME
, ssm
->plist_name
);
120 ssm
->plist_name
= XSTRDUP(MTYPE_PIM_FILTER_NAME
, plist_name
);
123 if (ssm
->plist_name
) {
125 XFREE(MTYPE_PIM_FILTER_NAME
, ssm
->plist_name
);
130 pim_ssm_range_reevaluate(pim
);
132 return PIM_SSM_ERR_NONE
;
135 void *pim_ssm_init(void)
139 ssm
= XCALLOC(MTYPE_PIM_SSM_INFO
, sizeof(*ssm
));
144 void pim_ssm_terminate(struct pim_ssm
*ssm
)
146 if (ssm
&& ssm
->plist_name
)
147 XFREE(MTYPE_PIM_FILTER_NAME
, ssm
->plist_name
);