]>
git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_ssm.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * IP SSM ranges for FRR
4 * Copyright (C) 2017 Cumulus Networks, Inc.
9 #include <lib/linklist.h>
10 #include <lib/prefix.h>
13 #include <lib/plist.h>
14 #include <lib/lib_errors.h>
17 #include "pim_instance.h"
21 static void pim_ssm_range_reevaluate(struct pim_instance
*pim
)
24 /* 1. Setup register state for (S,G) entries if G has changed from SSM
27 * 2. check existing (*,G) IGMP registrations to see if they are
28 * still ASM. if they are now SSM delete them.
29 * 3. Allow channel setup for IGMP (*,G) members if G is now ASM
30 * 4. I could tear down all (*,G), (S,G,rpt) states. But that is an
31 * unnecessary sladge hammer and may not be particularly useful as it is
32 * likely the SPT switchover has already happened for flows along such
34 * As for the RPT states it seems that the best thing to do is let them
36 * out gracefully. As long as the FHR and LHR do the right thing RPTs
38 * disappear in time for SSM groups.
40 pim_upstream_register_reevaluate(pim
);
41 igmp_source_forward_reevaluate_all(pim
);
45 void pim_ssm_prefix_list_update(struct pim_instance
*pim
,
46 struct prefix_list
*plist
)
48 struct pim_ssm
*ssm
= pim
->ssm_info
;
51 || strcmp(ssm
->plist_name
, prefix_list_name(plist
))) {
56 pim_ssm_range_reevaluate(pim
);
59 static int pim_is_grp_standard_ssm(struct prefix
*group
)
61 pim_addr addr
= pim_addr_from_prefix(group
);
63 return pim_addr_ssm(addr
);
66 int pim_is_grp_ssm(struct pim_instance
*pim
, pim_addr group_addr
)
70 struct prefix_list
*plist
;
72 pim_addr_to_prefix(&group
, group_addr
);
75 if (!ssm
->plist_name
) {
76 return pim_is_grp_standard_ssm(&group
);
79 plist
= prefix_list_lookup(PIM_AFI
, ssm
->plist_name
);
83 return (prefix_list_apply_ext(plist
, NULL
, &group
, true) ==
87 int pim_ssm_range_set(struct pim_instance
*pim
, vrf_id_t vrf_id
,
88 const char *plist_name
)
93 if (vrf_id
!= pim
->vrf
->vrf_id
)
94 return PIM_SSM_ERR_NO_VRF
;
98 if (ssm
->plist_name
) {
99 if (!strcmp(ssm
->plist_name
, plist_name
))
100 return PIM_SSM_ERR_DUP
;
101 XFREE(MTYPE_PIM_FILTER_NAME
, ssm
->plist_name
);
103 ssm
->plist_name
= XSTRDUP(MTYPE_PIM_FILTER_NAME
, plist_name
);
106 if (ssm
->plist_name
) {
108 XFREE(MTYPE_PIM_FILTER_NAME
, ssm
->plist_name
);
113 pim_ssm_range_reevaluate(pim
);
115 return PIM_SSM_ERR_NONE
;
118 void *pim_ssm_init(void)
122 ssm
= XCALLOC(MTYPE_PIM_SSM_INFO
, sizeof(*ssm
));
127 void pim_ssm_terminate(struct pim_ssm
*ssm
)
132 XFREE(MTYPE_PIM_FILTER_NAME
, ssm
->plist_name
);
134 XFREE(MTYPE_PIM_SSM_INFO
, ssm
);