summaryrefslogtreecommitdiffstats
path: root/pimd
diff options
context:
space:
mode:
authorMartin Winter <mwinter@opensourcerouting.org>2021-05-20 18:49:56 +0200
committerGitHub <noreply@github.com>2021-05-20 18:49:56 +0200
commit202af4abaa299951c599909960b495d455cea271 (patch)
tree9bb10cdbd4102c13d3f3a367cac6f53e9306e8bd /pimd
parentMerge pull request #8666 from idryzhov/bgp-replace-as (diff)
parentpimd: Remove pim->vrf_id and use pim->vrf->vrf_id (diff)
downloadfrr-202af4abaa299951c599909960b495d455cea271.tar.xz
frr-202af4abaa299951c599909960b495d455cea271.zip
Merge pull request #8616 from donaldsharp/pim_ordering
pimd: There exists a path where on vrf bringup we do not create the p…
Diffstat (limited to 'pimd')
-rw-r--r--pimd/pim_bsm.c2
-rw-r--r--pimd/pim_cmd.c4
-rw-r--r--pimd/pim_iface.c16
-rw-r--r--pimd/pim_igmp_mtrace.c2
-rw-r--r--pimd/pim_instance.c12
-rw-r--r--pimd/pim_instance.h2
-rw-r--r--pimd/pim_mroute.c4
-rw-r--r--pimd/pim_msdp_socket.c10
-rw-r--r--pimd/pim_nb_config.c8
-rw-r--r--pimd/pim_nht.c19
-rw-r--r--pimd/pim_pim.c2
-rw-r--r--pimd/pim_rp.c4
-rw-r--r--pimd/pim_rpf.c2
-rw-r--r--pimd/pim_ssm.c2
-rw-r--r--pimd/pim_ssmpingd.c2
-rw-r--r--pimd/pim_vty.c4
-rw-r--r--pimd/pim_vxlan.c4
-rw-r--r--pimd/pim_zlookup.c3
18 files changed, 62 insertions, 40 deletions
diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c
index 3fbe3317b..ad5257630 100644
--- a/pimd/pim_bsm.c
+++ b/pimd/pim_bsm.c
@@ -1320,7 +1320,7 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,
}
}
} else if (if_lookup_exact_address(&ip_hdr->ip_dst, AF_INET,
- pim->vrf_id)) {
+ pim->vrf->vrf_id)) {
/* Unicast BSM received - if ucast bsm not enabled on
* the interface, drop it
*/
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 548c866e4..f6072b177 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -810,7 +810,7 @@ static void igmp_show_interface_join(struct pim_instance *pim, struct vty *vty,
if (uj) {
json = json_object_new_object();
json_object_string_add(json, "vrf",
- vrf_id_to_name(pim->vrf_id));
+ vrf_id_to_name(pim->vrf->vrf_id));
} else {
vty_out(vty,
"Interface Address Source Group Socket Uptime \n");
@@ -2971,7 +2971,7 @@ static int pim_print_pnc_cache_walkcb(struct hash_bucket *bucket, void *arg)
for (nh_node = pnc->nexthop; nh_node; nh_node = nh_node->next) {
first_ifindex = nh_node->ifindex;
- ifp = if_lookup_by_index(first_ifindex, pim->vrf_id);
+ ifp = if_lookup_by_index(first_ifindex, pim->vrf->vrf_id);
vty_out(vty, "%-15s ", inet_ntop(AF_INET,
&pnc->rpf.rpf_addr.u.prefix4,
diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c
index 834399053..353f13300 100644
--- a/pimd/pim_iface.c
+++ b/pimd/pim_iface.c
@@ -1050,7 +1050,7 @@ int pim_if_find_vifindex_by_ifindex(struct pim_instance *pim, ifindex_t ifindex)
struct pim_interface *pim_ifp;
struct interface *ifp;
- ifp = if_lookup_by_index(ifindex, pim->vrf_id);
+ ifp = if_lookup_by_index(ifindex, pim->vrf->vrf_id);
if (!ifp || !ifp->info)
return -1;
pim_ifp = ifp->info;
@@ -1477,13 +1477,13 @@ void pim_if_create_pimreg(struct pim_instance *pim)
char pimreg_name[INTERFACE_NAMSIZ];
if (!pim->regiface) {
- if (pim->vrf_id == VRF_DEFAULT)
+ if (pim->vrf->vrf_id == VRF_DEFAULT)
strlcpy(pimreg_name, "pimreg", sizeof(pimreg_name));
else
snprintf(pimreg_name, sizeof(pimreg_name), "pimreg%u",
pim->vrf->data.l.table_id);
- pim->regiface = if_create_name(pimreg_name, pim->vrf_id);
+ pim->regiface = if_create_name(pimreg_name, pim->vrf->vrf_id);
pim->regiface->ifindex = PIM_OIF_PIM_REGISTER_VIF;
pim_if_new(pim->regiface, false, false, true,
@@ -1566,6 +1566,16 @@ int pim_ifp_create(struct interface *ifp)
if (pim_ifp)
pim_ifp->pim = pim;
pim_if_addr_add_all(ifp);
+
+ /*
+ * Due to ordering issues based upon when
+ * a command is entered we should ensure that
+ * the pim reg is created for this vrf if we
+ * have configuration for it already.
+ *
+ * this is a no-op if it's already been done.
+ */
+ pim_if_create_pimreg(pim);
}
/*
diff --git a/pimd/pim_igmp_mtrace.c b/pimd/pim_igmp_mtrace.c
index d36a275f8..73af44fc4 100644
--- a/pimd/pim_igmp_mtrace.c
+++ b/pimd/pim_igmp_mtrace.c
@@ -597,7 +597,7 @@ int igmp_mtrace_recv_qry_req(struct igmp_sock *igmp, struct ip *ip_hdr,
*/
if (!IPV4_CLASS_DE(ntohl(ip_hdr->ip_dst.s_addr)))
if (!if_lookup_exact_address(&ip_hdr->ip_dst, AF_INET,
- pim->vrf_id))
+ pim->vrf->vrf_id))
return mtrace_forward_packet(pim, ip_hdr);
if (igmp_msg_len < (int)sizeof(struct igmp_mtrace)) {
diff --git a/pimd/pim_instance.c b/pimd/pim_instance.c
index 019048abf..47358f38e 100644
--- a/pimd/pim_instance.c
+++ b/pimd/pim_instance.c
@@ -92,7 +92,6 @@ static struct pim_instance *pim_instance_init(struct vrf *vrf)
pim->ecmp_enable = false;
pim->ecmp_rebalance_enable = false;
- pim->vrf_id = vrf->vrf_id;
pim->vrf = vrf;
pim->spt.switchover = PIM_SPT_IMMEDIATE;
@@ -175,8 +174,17 @@ static int pim_vrf_delete(struct vrf *vrf)
static int pim_vrf_enable(struct vrf *vrf)
{
struct pim_instance *pim = (struct pim_instance *)vrf->info;
+ struct interface *ifp;
- zlog_debug("%s: for %s", __func__, vrf->name);
+ zlog_debug("%s: for %s %u", __func__, vrf->name, vrf->vrf_id);
+
+ FOR_ALL_INTERFACES (vrf, ifp) {
+ if (!ifp->info)
+ continue;
+
+ pim_if_create_pimreg(pim);
+ break;
+ }
pim_mroute_socket_enable(pim);
diff --git a/pimd/pim_instance.h b/pimd/pim_instance.h
index 2b76da21b..72c726690 100644
--- a/pimd/pim_instance.h
+++ b/pimd/pim_instance.h
@@ -127,7 +127,7 @@ struct pim_router {
/* Per VRF PIM DB */
struct pim_instance {
- vrf_id_t vrf_id;
+ // vrf_id_t vrf_id;
struct vrf *vrf;
struct {
diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c
index afd38face..ab6d8c17d 100644
--- a/pimd/pim_mroute.c
+++ b/pimd/pim_mroute.c
@@ -56,7 +56,7 @@ static int pim_mroute_set(struct pim_instance *pim, int enable)
/*
* We need to create the VRF table for the pim mroute_socket
*/
- if (pim->vrf_id != VRF_DEFAULT) {
+ if (pim->vrf->vrf_id != VRF_DEFAULT) {
frr_with_privs(&pimd_privs) {
data = pim->vrf->data.l.table_id;
@@ -609,7 +609,7 @@ static int pim_mroute_msg(struct pim_instance *pim, const char *buf,
* the source
* of the IP packet.
*/
- ifp = if_lookup_by_index(ifindex, pim->vrf_id);
+ ifp = if_lookup_by_index(ifindex, pim->vrf->vrf_id);
if (!ifp || !ifp->info)
return 0;
diff --git a/pimd/pim_msdp_socket.c b/pimd/pim_msdp_socket.c
index 9c3cdb271..78a8265a1 100644
--- a/pimd/pim_msdp_socket.c
+++ b/pimd/pim_msdp_socket.c
@@ -156,9 +156,9 @@ int pim_msdp_sock_listen(struct pim_instance *pim)
sockopt_reuseaddr(sock);
sockopt_reuseport(sock);
- if (pim->vrf_id != VRF_DEFAULT) {
+ if (pim->vrf->vrf_id != VRF_DEFAULT) {
struct interface *ifp =
- if_lookup_by_name(pim->vrf->name, pim->vrf_id);
+ if_lookup_by_name(pim->vrf->name, pim->vrf->vrf_id);
if (!ifp) {
flog_err(EC_LIB_INTERFACE,
"%s: Unable to lookup vrf interface: %s",
@@ -243,9 +243,9 @@ int pim_msdp_sock_connect(struct pim_msdp_peer *mp)
return -1;
}
- if (mp->pim->vrf_id != VRF_DEFAULT) {
- struct interface *ifp =
- if_lookup_by_name(mp->pim->vrf->name, mp->pim->vrf_id);
+ if (mp->pim->vrf->vrf_id != VRF_DEFAULT) {
+ struct interface *ifp = if_lookup_by_name(mp->pim->vrf->name,
+ mp->pim->vrf->vrf_id);
if (!ifp) {
flog_err(EC_LIB_INTERFACE,
"%s: Unable to lookup vrf interface: %s",
diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c
index 003a9947e..11e8da3b8 100644
--- a/pimd/pim_nb_config.c
+++ b/pimd/pim_nb_config.c
@@ -220,7 +220,7 @@ static int pim_cmd_spt_switchover(struct pim_instance *pim,
static int pim_ssm_cmd_worker(struct pim_instance *pim, const char *plist,
char *errmsg, size_t errmsg_len)
{
- int result = pim_ssm_range_set(pim, pim->vrf_id, plist);
+ int result = pim_ssm_range_set(pim, pim->vrf->vrf_id, plist);
int ret = NB_ERR;
if (result == PIM_SSM_ERR_NONE)
@@ -2398,7 +2398,7 @@ int lib_interface_pim_address_family_mroute_destroy(
pim = pim_iifp->pim;
oifname = yang_dnode_get_string(args->dnode, "./oif");
- oif = if_lookup_by_name(oifname, pim->vrf_id);
+ oif = if_lookup_by_name(oifname, pim->vrf->vrf_id);
if (!oif) {
snprintf(args->errmsg, args->errmsg_len,
@@ -2457,7 +2457,7 @@ int lib_interface_pim_address_family_mroute_oif_modify(
pim = pim_iifp->pim;
oifname = yang_dnode_get_string(args->dnode, NULL);
- oif = if_lookup_by_name(oifname, pim->vrf_id);
+ oif = if_lookup_by_name(oifname, pim->vrf->vrf_id);
if (oif && (iif->ifindex == oif->ifindex)) {
strlcpy(args->errmsg,
@@ -2476,7 +2476,7 @@ int lib_interface_pim_address_family_mroute_oif_modify(
pim = pim_iifp->pim;
oifname = yang_dnode_get_string(args->dnode, NULL);
- oif = if_lookup_by_name(oifname, pim->vrf_id);
+ oif = if_lookup_by_name(oifname, pim->vrf->vrf_id);
if (!oif) {
snprintf(args->errmsg, args->errmsg_len,
"No such interface name %s",
diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c
index 68e0a4569..23ba3498a 100644
--- a/pimd/pim_nht.c
+++ b/pimd/pim_nht.c
@@ -54,7 +54,7 @@ void pim_sendmsg_zebra_rnh(struct pim_instance *pim, struct zclient *zclient,
int ret;
p = &(pnc->rpf.rpf_addr);
- ret = zclient_send_rnh(zclient, command, p, false, pim->vrf_id);
+ ret = zclient_send_rnh(zclient, command, p, false, pim->vrf->vrf_id);
if (ret == ZCLIENT_SEND_FAILURE)
zlog_warn("sendmsg_nexthop: zclient_send_message() failed");
@@ -266,7 +266,7 @@ bool pim_nexthop_match(struct pim_instance *pim, struct in_addr addr,
while (i < num_ifindex) {
first_ifindex = nexthop_tab[i].ifindex;
- ifp = if_lookup_by_index(first_ifindex, pim->vrf_id);
+ ifp = if_lookup_by_index(first_ifindex, pim->vrf->vrf_id);
if (!ifp) {
if (PIM_DEBUG_ZEBRA) {
char addr_str[INET_ADDRSTRLEN];
@@ -344,7 +344,7 @@ bool pim_nexthop_match_nht_cache(struct pim_instance *pim, struct in_addr addr,
for (nh_node = pnc->nexthop; nh_node; nh_node = nh_node->next) {
first_ifindex = nh_node->ifindex;
- ifp = if_lookup_by_index(first_ifindex, pim->vrf_id);
+ ifp = if_lookup_by_index(first_ifindex, pim->vrf->vrf_id);
if (!ifp) {
if (PIM_DEBUG_PIM_NHT) {
char addr_str[INET_ADDRSTRLEN];
@@ -590,7 +590,8 @@ static int pim_ecmp_nexthop_search(struct pim_instance *pim,
*/
for (nh_node = pnc->nexthop, i = 0; nh_node;
nh_node = nh_node->next, i++) {
- ifps[i] = if_lookup_by_index(nh_node->ifindex, pim->vrf_id);
+ ifps[i] =
+ if_lookup_by_index(nh_node->ifindex, pim->vrf->vrf_id);
if (ifps[i]) {
nbrs[i] = pim_neighbor_find(ifps[i],
nh_node->gate.ipv4);
@@ -774,7 +775,7 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)
break;
case NEXTHOP_TYPE_IPV6_IFINDEX:
ifp1 = if_lookup_by_index(nexthop->ifindex,
- pim->vrf_id);
+ pim->vrf->vrf_id);
if (!ifp1)
nbr = NULL;
@@ -793,7 +794,8 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)
break;
}
- ifp = if_lookup_by_index(nexthop->ifindex, pim->vrf_id);
+ ifp = if_lookup_by_index(nexthop->ifindex,
+ pim->vrf->vrf_id);
if (!ifp) {
if (PIM_DEBUG_PIM_NHT) {
char buf[NEXTHOP_STRLEN];
@@ -940,7 +942,7 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim,
*/
for (i = 0; i < num_ifindex; i++) {
ifps[i] = if_lookup_by_index(nexthop_tab[i].ifindex,
- pim->vrf_id);
+ pim->vrf->vrf_id);
if (ifps[i]) {
nbrs[i] = pim_neighbor_find(
ifps[i], nexthop_tab[i].nexthop_addr.u.prefix4);
@@ -1076,7 +1078,8 @@ int pim_ecmp_fib_lookup_if_vif_index(struct pim_instance *pim,
if (PIM_DEBUG_PIM_NHT)
zlog_debug(
"%s: found nexthop ifindex=%d (interface %s(%s)) for address %s",
- __func__, ifindex, ifindex2ifname(ifindex, pim->vrf_id),
+ __func__, ifindex,
+ ifindex2ifname(ifindex, pim->vrf->vrf_id),
pim->vrf->name, addr_str);
vif_index = pim_if_find_vifindex_by_ifindex(pim, ifindex);
diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c
index 4ba08a19d..e7ac0d4e5 100644
--- a/pimd/pim_pim.c
+++ b/pimd/pim_pim.c
@@ -369,7 +369,7 @@ static int pim_sock_read(struct thread *t)
* the right ifindex, so just use it. We know
* it's the right interface because we bind to it
*/
- ifp = if_lookup_by_index(ifindex, pim_ifp->pim->vrf_id);
+ ifp = if_lookup_by_index(ifindex, pim_ifp->pim->vrf->vrf_id);
if (!ifp || !ifp->info) {
if (PIM_DEBUG_PIM_PACKETS)
zlog_debug(
diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c
index feaeea929..a31fec036 100644
--- a/pimd/pim_rp.c
+++ b/pimd/pim_rp.c
@@ -1159,7 +1159,7 @@ int pim_rp_config_write(struct pim_instance *pim, struct vty *vty,
bool pim_rp_check_is_my_ip_address(struct pim_instance *pim,
struct in_addr dest_addr)
{
- if (if_lookup_exact_address(&dest_addr, AF_INET, pim->vrf_id))
+ if (if_lookup_exact_address(&dest_addr, AF_INET, pim->vrf->vrf_id))
return true;
return false;
@@ -1323,7 +1323,7 @@ void pim_resolve_rp_nh(struct pim_instance *pim, struct pim_neighbor *nbr)
continue;
struct interface *ifp1 = if_lookup_by_index(
- nh_node->ifindex, pim->vrf_id);
+ nh_node->ifindex, pim->vrf->vrf_id);
if (nbr->interface != ifp1)
continue;
diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c
index 043ccdb84..98944e8fe 100644
--- a/pimd/pim_rpf.c
+++ b/pimd/pim_rpf.c
@@ -112,7 +112,7 @@ bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,
while (!found && (i < num_ifindex)) {
first_ifindex = nexthop_tab[i].ifindex;
- ifp = if_lookup_by_index(first_ifindex, pim->vrf_id);
+ ifp = if_lookup_by_index(first_ifindex, pim->vrf->vrf_id);
if (!ifp) {
if (PIM_DEBUG_ZEBRA) {
char addr_str[INET_ADDRSTRLEN];
diff --git a/pimd/pim_ssm.c b/pimd/pim_ssm.c
index 8d3e04f5d..6c5883aeb 100644
--- a/pimd/pim_ssm.c
+++ b/pimd/pim_ssm.c
@@ -112,7 +112,7 @@ int pim_ssm_range_set(struct pim_instance *pim, vrf_id_t vrf_id,
struct pim_ssm *ssm;
int change = 0;
- if (vrf_id != pim->vrf_id)
+ if (vrf_id != pim->vrf->vrf_id)
return PIM_SSM_ERR_NO_VRF;
ssm = pim->ssm_info;
diff --git a/pimd/pim_ssmpingd.c b/pimd/pim_ssmpingd.c
index 03e77de16..abd95e648 100644
--- a/pimd/pim_ssmpingd.c
+++ b/pimd/pim_ssmpingd.c
@@ -267,7 +267,7 @@ static int ssmpingd_read_msg(struct ssmpingd_sock *ss)
return -1;
}
- ifp = if_lookup_by_index(ifindex, ss->pim->vrf_id);
+ ifp = if_lookup_by_index(ifindex, ss->pim->vrf->vrf_id);
if (buf[0] != PIM_SSMPINGD_REQUEST) {
char source_str[INET_ADDRSTRLEN];
diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c
index 929d35101..c049ef402 100644
--- a/pimd/pim_vty.c
+++ b/pimd/pim_vty.c
@@ -171,7 +171,7 @@ int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
struct pim_ssm *ssm = pim->ssm_info;
char spaces[10];
- if (pim->vrf_id == VRF_DEFAULT)
+ if (pim->vrf->vrf_id == VRF_DEFAULT)
snprintf(spaces, sizeof(spaces), "%s", "");
else
snprintf(spaces, sizeof(spaces), "%s", " ");
@@ -186,7 +186,7 @@ int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
writes += pim_rp_config_write(pim, vty, spaces);
- if (pim->vrf_id == VRF_DEFAULT) {
+ if (pim->vrf->vrf_id == VRF_DEFAULT) {
if (router->register_suppress_time
!= PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) {
vty_out(vty, "%sip pim register-suppress-time %d\n",
diff --git a/pimd/pim_vxlan.c b/pimd/pim_vxlan.c
index 6a12c7fb1..5d5ea1bfe 100644
--- a/pimd/pim_vxlan.c
+++ b/pimd/pim_vxlan.c
@@ -1076,7 +1076,7 @@ void pim_vxlan_add_vif(struct interface *ifp)
struct pim_interface *pim_ifp = ifp->info;
struct pim_instance *pim = pim_ifp->pim;
- if (pim->vrf_id != VRF_DEFAULT)
+ if (pim->vrf->vrf_id != VRF_DEFAULT)
return;
if (if_is_loopback_or_vrf(ifp))
@@ -1095,7 +1095,7 @@ void pim_vxlan_del_vif(struct interface *ifp)
struct pim_interface *pim_ifp = ifp->info;
struct pim_instance *pim = pim_ifp->pim;
- if (pim->vrf_id != VRF_DEFAULT)
+ if (pim->vrf->vrf_id != VRF_DEFAULT)
return;
if (pim->vxlan.default_iif == ifp)
diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c
index 72505a699..9ccf1fedd 100644
--- a/pimd/pim_zlookup.c
+++ b/pimd/pim_zlookup.c
@@ -544,7 +544,8 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil)
return -1;
stream_reset(s);
- zclient_create_header(s, ZEBRA_IPMR_ROUTE_STATS, c_oil->pim->vrf_id);
+ zclient_create_header(s, ZEBRA_IPMR_ROUTE_STATS,
+ c_oil->pim->vrf->vrf_id);
stream_put_in_addr(s, &c_oil->oil.mfcc_origin);
stream_put_in_addr(s, &c_oil->oil.mfcc_mcastgrp);
stream_putl(s, ifp->ifindex);