summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsarita patra <saritap@vmware.com>2022-03-16 11:08:53 +0100
committerSarita Patra <saritap@vmware.com>2022-07-07 19:56:45 +0200
commit1407e40fc89812341f2dabc4d8a3105cefb3793f (patch)
treee92b13076841d12ed0b78df77353e5ab5e42a57a
parentpim6d: add pimv6 support for bsm_hdr (diff)
downloadfrr-1407e40fc89812341f2dabc4d8a3105cefb3793f.tar.xz
frr-1407e40fc89812341f2dabc4d8a3105cefb3793f.zip
pim6d: add pimv6 support for bsmmsg_rpinfo
Signed-off-by: sarita patra <saritap@vmware.com>
-rw-r--r--pimd/pim_bsm.c19
-rw-r--r--pimd/pim_bsm.h4
-rw-r--r--pimd/pim_cmd.c29
3 files changed, 25 insertions, 27 deletions
diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c
index 480445f20..ea6149569 100644
--- a/pimd/pim_bsm.c
+++ b/pimd/pim_bsm.c
@@ -130,11 +130,7 @@ int pim_bsm_rpinfo_cmp(const struct bsm_rpinfo *node1,
return 1;
if (node1->hash > node2->hash)
return -1;
- if (pim_addr_cmp(node1->rp_address, node2->rp_address) < 0)
- return 1;
- if (pim_addr_cmp(node1->rp_address, node2->rp_address) > 0)
- return -1;
- return 0;
+ return pim_addr_cmp(node2->rp_address, node1->rp_address);
}
static struct bsgrp_node *pim_bsm_new_bsgrp_node(struct route_table *rt,
@@ -1058,6 +1054,7 @@ static uint32_t hash_calc_on_grp_rp(struct prefix group, struct in_addr rp,
grpaddr = grpaddr & ((mask << (32 - hashmasklen)));
else
grpaddr = grpaddr & mask;
+
rp_add = ntohl(rp.s_addr);
temp = 1103515245 * ((1103515245 * (uint64_t)grpaddr + 12345) ^ rp_add)
+ 12345;
@@ -1077,8 +1074,7 @@ static bool pim_install_bsm_grp_rp(struct pim_instance *pim,
bsm_rpinfo->rp_prio = rp->rp_pri;
bsm_rpinfo->rp_holdtime = rp->rp_holdtime;
- memcpy(&bsm_rpinfo->rp_address, &rp->rpaddr.addr,
- sizeof(struct in_addr));
+ bsm_rpinfo->rp_address = rp->rpaddr.addr;
bsm_rpinfo->elapse_time = 0;
/* Back pointer to the group node. */
@@ -1243,13 +1239,12 @@ static bool pim_bsm_parse_install_g2rp(struct bsm_scope *scope, uint8_t *buf,
offset += sizeof(struct bsmmsg_rpinfo);
if (PIM_DEBUG_BSM) {
- char rp_str[INET_ADDRSTRLEN];
+ pim_addr rp_addr;
- pim_inet4_dump("<Rpaddr?>", rpinfo.rpaddr.addr,
- rp_str, sizeof(rp_str));
+ rp_addr = rpinfo.rpaddr.addr;
zlog_debug(
- "%s, Rp address - %s; pri:%d hold:%d",
- __func__, rp_str, rpinfo.rp_pri,
+ "%s, Rp address - %pPAs; pri:%d hold:%d",
+ __func__, &rp_addr, rpinfo.rp_pri,
rpinfo.rp_holdtime);
}
diff --git a/pimd/pim_bsm.h b/pimd/pim_bsm.h
index 6d1cbf7ef..04c9c2006 100644
--- a/pimd/pim_bsm.h
+++ b/pimd/pim_bsm.h
@@ -200,7 +200,11 @@ struct bsmmsg_grpinfo {
} __attribute__((packed));
struct bsmmsg_rpinfo {
+#if PIM_IPV == 4
struct pim_encoded_ipv4_unicast rpaddr;
+#else
+ struct pim_encoded_ipv6_unicast rpaddr;
+#endif
uint16_t rp_holdtime;
uint8_t rp_pri;
uint8_t reserved;
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 048530e64..602fac7a8 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -862,7 +862,7 @@ static void pim_show_bsm_db(struct pim_instance *pim, struct vty *vty, bool uj)
char grp_str[PREFIX_STRLEN];
char rp_str[INET_ADDRSTRLEN];
struct bsmmsg_grpinfo *group;
- struct bsmmsg_rpinfo *rpaddr;
+ struct bsmmsg_rpinfo *bsm_rpinfo;
struct prefix grp;
struct bsm_hdr *hdr;
uint32_t offset = 0;
@@ -951,31 +951,30 @@ static void pim_show_bsm_db(struct pim_instance *pim, struct vty *vty, bool uj)
"RpAddress HoldTime Priority\n");
while (frag_rp_cnt--) {
- rpaddr = (struct bsmmsg_rpinfo *)buf;
+ bsm_rpinfo = (struct bsmmsg_rpinfo *)buf;
buf += sizeof(struct bsmmsg_rpinfo);
offset += sizeof(struct bsmmsg_rpinfo);
- pim_inet4_dump("<Rp addr?>",
- rpaddr->rpaddr.addr, rp_str,
- sizeof(rp_str));
-
if (uj) {
json_row = json_object_new_object();
- json_object_string_add(
- json_row, "Rp Address", rp_str);
+ json_object_string_addf(
+ json_row, "Rp Address", "%pPA",
+ (pim_addr *)&bsm_rpinfo->rpaddr.addr);
json_object_int_add(
json_row, "Rp HoldTime",
- ntohs(rpaddr->rp_holdtime));
+ ntohs(bsm_rpinfo->rp_holdtime));
json_object_int_add(json_row,
"Rp Priority",
- rpaddr->rp_pri);
- json_object_object_add(
- json_group, rp_str, json_row);
+ bsm_rpinfo->rp_pri);
+ json_object_object_addf(
+ json_group, json_row, "%pPA",
+ (pim_addr *)&bsm_rpinfo->rpaddr.addr);
} else {
- vty_out(vty, "%-15s %-12d %d\n", rp_str,
- ntohs(rpaddr->rp_holdtime),
- rpaddr->rp_pri);
+ vty_out(vty, "%-15pPA %-12d %d\n",
+ (pim_addr *)&bsm_rpinfo->rpaddr.addr,
+ ntohs(bsm_rpinfo->rp_holdtime),
+ bsm_rpinfo->rp_pri);
}
}
vty_out(vty, "\n");