diff options
| author | Mobashshera Rasool <mrasool@vmware.com> | 2022-02-17 03:56:20 -0800 | 
|---|---|---|
| committer | Mobashshera Rasool <mrasool@vmware.com> | 2022-03-08 00:57:51 -0800 | 
| commit | c6ced47492ab55d04bc237727fd90fbffa3ed438 (patch) | |
| tree | d738d474359e6054c1713b20838dac3988c77176 | |
| parent | 49b7b2c4a83bd2d7f2a122d46df9d717943e0e05 (diff) | |
pim6d: Add pim_get_all_mcast_group api
Added this api to fill all multicast group address based on IP version.
For PIMv4 its 224.0.0.0/4, for PIMv6 its FF00::0/8.
Changed the code where its being used currently.
Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
| -rw-r--r-- | pimd/pim_bsm.c | 5 | ||||
| -rw-r--r-- | pimd/pim_nb_config.c | 7 | ||||
| -rw-r--r-- | pimd/pim_rp.c | 9 | ||||
| -rw-r--r-- | pimd/pim_util.c | 14 | ||||
| -rw-r--r-- | pimd/pim_util.h | 1 | 
5 files changed, 27 insertions, 9 deletions
diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c index 61e51c0170..21cbe09c4e 100644 --- a/pimd/pim_bsm.c +++ b/pimd/pim_bsm.c @@ -36,6 +36,7 @@  #include "pim_bsm.h"  #include "pim_time.h"  #include "pim_zebra.h" +#include "pim_util.h"  /* Functions forward declaration */  static void pim_bs_timer_start(struct bsm_scope *scope, int bs_timeout); @@ -416,7 +417,7 @@ static void pim_instate_pend_list(struct bsgrp_node *bsgrp_node)  	pend = bsm_rpinfos_first(bsgrp_node->partial_bsrp_list); -	if (!str2prefix("224.0.0.0/4", &group_all)) +	if (!pim_get_all_mcast_group(&group_all))  		return;  	rp_all = pim_rp_find_match_group(pim, &group_all); @@ -627,7 +628,7 @@ void pim_bsm_clear(struct pim_instance *pim)  		pim_delete_tracked_nexthop(pim, &nht_p, NULL, rp_info); -		if (!str2prefix("224.0.0.0/4", &g_all)) +		if (!pim_get_all_mcast_group(&g_all))  			return;  		rp_all = pim_rp_find_match_group(pim, &g_all); diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c index 629490408d..21f57e2d11 100644 --- a/pimd/pim_nb_config.c +++ b/pimd/pim_nb_config.c @@ -34,6 +34,7 @@  #include "pim_util.h"  #include "log.h"  #include "lib_errors.h" +#include "pim_util.h"  #if PIM_IPV == 6  #define pim6_msdp_err(funcname, argtype)                                       \ @@ -2359,7 +2360,7 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_rp  		else if (yang_dnode_get(args->dnode, "./prefix-list")) {  			plist = yang_dnode_get_string(args->dnode,  					"./prefix-list"); -			if (!str2prefix("224.0.0.0/4", &group)) { +			if (!pim_get_all_mcast_group(&group)) {  				flog_err(  					EC_LIB_DEVELOPMENT,  					"Unable to convert 224.0.0.0/4 to prefix"); @@ -2457,7 +2458,7 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_rp  		pim = vrf->info;  		plist = yang_dnode_get_string(args->dnode, NULL);  		yang_dnode_get_pimaddr(&rp_addr, args->dnode, "../rp-address"); -		if (!str2prefix("224.0.0.0/4", &group)) { +		if (!pim_get_all_mcast_group(&group)) {  			flog_err(EC_LIB_DEVELOPMENT,  				 "Unable to convert 224.0.0.0/4 to prefix");  			return NB_ERR_INCONSISTENCY; @@ -2488,7 +2489,7 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_rp  		pim = vrf->info;  		yang_dnode_get_pimaddr(&rp_addr, args->dnode, "../rp-address");  		plist = yang_dnode_get_string(args->dnode, NULL); -		if (!str2prefix("224.0.0.0/4", &group)) { +		if (!pim_get_all_mcast_group(&group)) {  			flog_err(EC_LIB_DEVELOPMENT,  				 "Unable to convert 224.0.0.0/4 to prefix");  			return NB_ERR_INCONSISTENCY; diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index 7368723e8a..251e82fc7b 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -48,6 +48,7 @@  #include "pim_oil.h"  #include "pim_zebra.h"  #include "pim_bsm.h" +#include "pim_util.h"  /* Cleanup pim->rpf_hash each node data */  void pim_rp_list_hash_clean(void *data) @@ -113,7 +114,7 @@ void pim_rp_init(struct pim_instance *pim)  	rp_info = XCALLOC(MTYPE_PIM_RP, sizeof(*rp_info)); -	if (!str2prefix("224.0.0.0/4", &rp_info->group)) { +	if (!pim_get_all_mcast_group(&rp_info->group)) {  		flog_err(EC_LIB_DEVELOPMENT,  			 "Unable to convert 224.0.0.0/4 to prefix");  		list_delete(&pim->rp_list); @@ -476,7 +477,7 @@ int pim_rp_new(struct pim_instance *pim, pim_addr rp_addr, struct prefix group,  		rp_info->plist = XSTRDUP(MTYPE_PIM_FILTER_NAME, plist);  	} else { -		if (!str2prefix("224.0.0.0/4", &group_all)) { +		if (!pim_get_all_mcast_group(&group_all)) {  			XFREE(MTYPE_PIM_RP, rp_info);  			return PIM_GROUP_BAD_ADDRESS;  		} @@ -652,7 +653,7 @@ void pim_rp_del_config(struct pim_instance *pim, pim_addr rp_addr,  	int result;  	if (group_range == NULL) -		result = str2prefix("224.0.0.0/4", &group); +		result = pim_get_all_mcast_group(&group);  	else  		result = str2prefix(group_range, &group); @@ -747,7 +748,7 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,  			   &nht_p);  	pim_delete_tracked_nexthop(pim, &nht_p, NULL, rp_info); -	if (!str2prefix("224.0.0.0/4", &g_all)) +	if (!pim_get_all_mcast_group(&g_all))  		return PIM_RP_BAD_ADDRESS;  	rp_all = pim_rp_find_match_group(pim, &g_all); diff --git a/pimd/pim_util.c b/pimd/pim_util.c index 8232d7205b..4b67dbf1b1 100644 --- a/pimd/pim_util.c +++ b/pimd/pim_util.c @@ -152,3 +152,17 @@ bool pim_is_group_filtered(struct pim_interface *pim_ifp, pim_addr *grp)  	pl = prefix_list_lookup(PIM_AFI, pim_ifp->boundary_oil_plist);  	return pl ? prefix_list_apply(pl, &grp_pfx) == PREFIX_DENY : false;  } + + +/* This function returns all multicast group */ +int pim_get_all_mcast_group(struct prefix *prefix) +{ +#if PIM_IPV == 4 +	if (!str2prefix("224.0.0.0/4", prefix)) +		return 0; +#else +	if (!str2prefix("FF00::0/8", prefix)) +		return 0; +#endif +	return 1; +} diff --git a/pimd/pim_util.h b/pimd/pim_util.h index b9c227996e..a4362bef90 100644 --- a/pimd/pim_util.h +++ b/pimd/pim_util.h @@ -36,4 +36,5 @@ void pim_pkt_dump(const char *label, const uint8_t *buf, int size);  int pim_is_group_224_0_0_0_24(struct in_addr group_addr);  int pim_is_group_224_4(struct in_addr group_addr);  bool pim_is_group_filtered(struct pim_interface *pim_ifp, pim_addr *grp); +int pim_get_all_mcast_group(struct prefix *prefix);  #endif /* PIM_UTIL_H */  | 
