summaryrefslogtreecommitdiffstats
path: root/pimd
diff options
context:
space:
mode:
authorJafar Al-Gharaibeh <jafar@atcorp.com>2024-12-13 16:37:07 +0100
committerGitHub <noreply@github.com>2024-12-13 16:37:07 +0100
commit27b01ce68c2b508d460b7af4ef887d1a741b932b (patch)
treecac45ed5be59813f2d4b753f83aa1123a93c22a5 /pimd
parentMerge pull request #17635 from opensourcerouting/pim6-embedded-crash (diff)
parentpimd,pim6d: optimize multicast prefix generation (diff)
downloadfrr-27b01ce68c2b508d460b7af4ef887d1a741b932b.tar.xz
frr-27b01ce68c2b508d460b7af4ef887d1a741b932b.zip
Merge pull request #17642 from opensourcerouting/pim-cs
pimd,pim6d: optimize multicast prefix generation and fix coverity scan defect
Diffstat (limited to 'pimd')
-rw-r--r--pimd/pim_bsm.c8
-rw-r--r--pimd/pim_nb_config.c20
-rw-r--r--pimd/pim_rp.c26
-rw-r--r--pimd/pim_util.c17
-rw-r--r--pimd/pim_util.h2
5 files changed, 24 insertions, 49 deletions
diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c
index 75104141a..1efdebdee 100644
--- a/pimd/pim_bsm.c
+++ b/pimd/pim_bsm.c
@@ -480,9 +480,7 @@ static void pim_instate_pend_list(struct bsgrp_node *bsgrp_node)
pend = bsm_rpinfos_first(bsgrp_node->partial_bsrp_list);
- if (!pim_get_all_mcast_group(&group_all))
- return;
-
+ pim_get_all_mcast_group(&group_all);
rp_all = pim_rp_find_match_group(pim, &group_all);
rn = route_node_lookup(pim->rp_table, &bsgrp_node->group);
@@ -729,9 +727,7 @@ void pim_bsm_clear(struct pim_instance *pim)
pim_delete_tracked_nexthop(pim, nht_p, NULL, rp_info);
- if (!pim_get_all_mcast_group(&g_all))
- return;
-
+ pim_get_all_mcast_group(&g_all);
rp_all = pim_rp_find_match_group(pim, &g_all);
if (rp_all == rp_info) {
diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c
index 30895e037..cf9ae21cc 100644
--- a/pimd/pim_nb_config.c
+++ b/pimd/pim_nb_config.c
@@ -2825,13 +2825,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 (!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;
- }
-
+ pim_get_all_mcast_group(&group);
result = pim_no_rp_cmd_worker(pim, rp_addr, group,
plist, args->errmsg,
args->errmsg_len);
@@ -2923,11 +2917,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 (!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;
- }
+ pim_get_all_mcast_group(&group);
return pim_rp_cmd_worker(pim, rp_addr, group, plist,
args->errmsg, args->errmsg_len);
}
@@ -2954,11 +2944,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 (!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;
- }
+ pim_get_all_mcast_group(&group);
return pim_no_rp_cmd_worker(pim, rp_addr, group, plist,
args->errmsg, args->errmsg_len);
break;
diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c
index 6266f4259..44cc00622 100644
--- a/pimd/pim_rp.c
+++ b/pimd/pim_rp.c
@@ -97,14 +97,7 @@ void pim_rp_init(struct pim_instance *pim)
rp_info = XCALLOC(MTYPE_PIM_RP, sizeof(*rp_info));
- if (!pim_get_all_mcast_group(&rp_info->group)) {
- flog_err(EC_LIB_DEVELOPMENT,
- "Unable to convert all-multicast prefix");
- list_delete(&pim->rp_list);
- route_table_finish(pim->rp_table);
- XFREE(MTYPE_PIM_RP, rp_info);
- return;
- }
+ pim_get_all_mcast_group(&rp_info->group);
rp_info->rp.rpf_addr = PIMADDR_ANY;
listnode_add(pim->rp_list, rp_info);
@@ -524,11 +517,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 (!pim_get_all_mcast_group(&group_all)) {
- XFREE(MTYPE_PIM_RP, rp_info);
- return PIM_GROUP_BAD_ADDRESS;
- }
+ pim_get_all_mcast_group(&group_all);
rp_all = pim_rp_find_match_group(pim, &group_all);
/*
@@ -708,9 +697,10 @@ void pim_rp_del_config(struct pim_instance *pim, pim_addr rp_addr,
struct prefix group;
int result;
- if (group_range == NULL)
- result = pim_get_all_mcast_group(&group);
- else
+ if (group_range == NULL) {
+ result = 0;
+ pim_get_all_mcast_group(&group);
+ } else
result = str2prefix(group_range, &group);
if (!result) {
@@ -789,9 +779,7 @@ int pim_rp_del(struct pim_instance *pim, pim_addr rp_addr, struct prefix group,
&nht_p);
pim_delete_tracked_nexthop(pim, nht_p, NULL, rp_info);
- if (!pim_get_all_mcast_group(&g_all))
- return PIM_RP_BAD_ADDRESS;
-
+ pim_get_all_mcast_group(&g_all);
rp_all = pim_rp_find_match_group(pim, &g_all);
if (rp_all == rp_info) {
diff --git a/pimd/pim_util.c b/pimd/pim_util.c
index 40404714e..0aea24058 100644
--- a/pimd/pim_util.c
+++ b/pimd/pim_util.c
@@ -213,16 +213,21 @@ bool pim_is_group_filtered(struct pim_interface *pim_ifp, pim_addr *grp, pim_add
/* This function returns all multicast group */
-int pim_get_all_mcast_group(struct prefix *prefix)
+void pim_get_all_mcast_group(struct prefix *prefix)
{
+ memset(prefix, 0, sizeof(*prefix));
+
#if PIM_IPV == 4
- if (!str2prefix("224.0.0.0/4", prefix))
- return 0;
+ /* Precomputed version of: `str2prefix("224.0.0.0/4", prefix);` */
+ prefix->family = AF_INET;
+ prefix->prefixlen = 4;
+ prefix->u.prefix4.s_addr = htonl(0xe0000000);
#else
- if (!str2prefix("FF00::0/8", prefix))
- return 0;
+ /* Precomputed version of: `str2prefix("FF00::0/8", prefix)` */
+ prefix->family = AF_INET6;
+ prefix->prefixlen = 8;
+ prefix->u.prefix6.s6_addr[0] = 0xff;
#endif
- return 1;
}
bool pim_addr_is_multicast(pim_addr addr)
diff --git a/pimd/pim_util.h b/pimd/pim_util.h
index dda93110b..a3d944b82 100644
--- a/pimd/pim_util.h
+++ b/pimd/pim_util.h
@@ -26,6 +26,6 @@ int pim_is_group_224_4(struct in_addr group_addr);
enum filter_type pim_access_list_apply(struct access_list *access, const struct in_addr *source,
const struct in_addr *group);
bool pim_is_group_filtered(struct pim_interface *pim_ifp, pim_addr *grp, pim_addr *src);
-int pim_get_all_mcast_group(struct prefix *prefix);
+void pim_get_all_mcast_group(struct prefix *prefix);
bool pim_addr_is_multicast(pim_addr addr);
#endif /* PIM_UTIL_H */