2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-10-15 18:02:50 +02:00
|
|
|
/*
|
|
|
|
* PIM for Quagga
|
|
|
|
* Copyright (C) 2015 Cumulus Networks, Inc.
|
|
|
|
* Donald Sharp
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
|
|
|
#include "log.h"
|
|
|
|
#include "if.h"
|
2023-03-07 20:22:48 +01:00
|
|
|
#include "frrevent.h"
|
2016-07-14 16:12:25 +02:00
|
|
|
#include "prefix.h"
|
2016-09-13 21:41:33 +02:00
|
|
|
#include "vty.h"
|
|
|
|
#include "plist.h"
|
2015-10-15 18:02:50 +02:00
|
|
|
|
|
|
|
#include "pimd.h"
|
2015-10-29 19:27:39 +01:00
|
|
|
#include "pim_mroute.h"
|
|
|
|
#include "pim_iface.h"
|
|
|
|
#include "pim_msg.h"
|
|
|
|
#include "pim_pim.h"
|
2015-10-15 18:02:50 +02:00
|
|
|
#include "pim_str.h"
|
|
|
|
#include "pim_rp.h"
|
|
|
|
#include "pim_register.h"
|
2015-10-20 17:42:16 +02:00
|
|
|
#include "pim_upstream.h"
|
2016-06-27 20:51:04 +02:00
|
|
|
#include "pim_rpf.h"
|
|
|
|
#include "pim_oil.h"
|
|
|
|
#include "pim_zebra.h"
|
|
|
|
#include "pim_join.h"
|
2016-07-14 16:12:25 +02:00
|
|
|
#include "pim_util.h"
|
2017-03-17 19:51:13 +01:00
|
|
|
#include "pim_ssm.h"
|
2019-03-22 21:38:50 +01:00
|
|
|
#include "pim_vxlan.h"
|
2022-03-07 05:38:31 +01:00
|
|
|
#include "pim_addr.h"
|
2015-10-15 18:02:50 +02:00
|
|
|
|
2022-03-01 22:18:12 +01:00
|
|
|
struct event *send_test_packet_timer = NULL;
|
2015-10-15 18:02:50 +02:00
|
|
|
|
2017-03-17 19:51:13 +01:00
|
|
|
void pim_register_join(struct pim_upstream *up)
|
|
|
|
{
|
2017-05-21 15:18:09 +02:00
|
|
|
struct pim_instance *pim = up->channel_oil->pim;
|
|
|
|
|
2017-05-21 15:30:02 +02:00
|
|
|
if (pim_is_grp_ssm(pim, up->sg.grp)) {
|
2017-03-17 19:51:13 +01:00
|
|
|
if (PIM_DEBUG_PIM_EVENTS)
|
|
|
|
zlog_debug("%s register setup skipped as group is SSM",
|
|
|
|
up->sg_str);
|
2017-03-31 22:50:08 +02:00
|
|
|
return;
|
2017-03-17 19:51:13 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-21 15:18:09 +02:00
|
|
|
pim_channel_add_oif(up->channel_oil, pim->regiface,
|
2019-11-15 17:47:33 +01:00
|
|
|
PIM_OIF_FLAG_PROTO_PIM, __func__);
|
2017-03-17 19:51:13 +01:00
|
|
|
up->reg_state = PIM_REG_JOIN;
|
2020-03-20 04:08:55 +01:00
|
|
|
pim_vxlan_update_sg_reg_state(pim, up, true);
|
2017-03-17 19:51:13 +01:00
|
|
|
}
|
|
|
|
|
2022-03-07 05:38:31 +01:00
|
|
|
void pim_register_stop_send(struct interface *ifp, pim_sgaddr *sg, pim_addr src,
|
|
|
|
pim_addr originator)
|
2015-10-15 18:02:50 +02:00
|
|
|
{
|
2016-07-14 16:12:25 +02:00
|
|
|
struct pim_interface *pinfo;
|
2016-10-04 00:42:59 +02:00
|
|
|
unsigned char buffer[10000];
|
2016-07-14 16:12:25 +02:00
|
|
|
unsigned int b1length = 0;
|
|
|
|
unsigned int length;
|
|
|
|
uint8_t *b1;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-08-03 03:44:29 +02:00
|
|
|
if (PIM_DEBUG_PIM_REG) {
|
2022-03-07 05:38:31 +01:00
|
|
|
zlog_debug("Sending Register stop for %pSG to %pPA on %s", sg,
|
2022-01-04 21:24:48 +01:00
|
|
|
&originator, ifp->name);
|
2016-08-03 03:44:29 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-10-04 00:42:59 +02:00
|
|
|
memset(buffer, 0, 10000);
|
2016-07-14 16:12:25 +02:00
|
|
|
b1 = (uint8_t *)buffer + PIM_MSG_REGISTER_STOP_LEN;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-08-02 10:38:11 +02:00
|
|
|
length = pim_encode_addr_group(b1, AFI_IP, 0, 0, sg->grp);
|
2016-07-14 16:12:25 +02:00
|
|
|
b1length += length;
|
|
|
|
b1 += length;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-01-14 16:38:41 +01:00
|
|
|
length = pim_encode_addr_ucast(b1, sg->src);
|
2016-07-14 16:12:25 +02:00
|
|
|
b1length += length;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-03-27 11:50:40 +02:00
|
|
|
pim_msg_build_header(src, originator, buffer,
|
|
|
|
b1length + PIM_MSG_REGISTER_STOP_LEN,
|
2019-05-04 14:07:39 +02:00
|
|
|
PIM_MSG_TYPE_REG_STOP, false);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-07-14 16:12:25 +02:00
|
|
|
pinfo = (struct pim_interface *)ifp->info;
|
|
|
|
if (!pinfo) {
|
|
|
|
if (PIM_DEBUG_PIM_TRACE)
|
2020-03-05 19:17:54 +01:00
|
|
|
zlog_debug("%s: No pinfo!", __func__);
|
2016-07-14 16:12:25 +02:00
|
|
|
return;
|
|
|
|
}
|
2023-06-12 15:07:22 +02:00
|
|
|
if (pim_msg_send(pinfo->pim->reg_sock, src, originator, buffer,
|
2022-04-04 13:13:07 +02:00
|
|
|
b1length + PIM_MSG_REGISTER_STOP_LEN, ifp)) {
|
2015-10-29 19:27:39 +01:00
|
|
|
if (PIM_DEBUG_PIM_TRACE) {
|
2016-09-15 16:18:28 +02:00
|
|
|
zlog_debug(
|
2016-07-14 16:12:25 +02:00
|
|
|
"%s: could not send PIM register stop message on interface %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, ifp->name);
|
2016-07-14 16:12:25 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2022-04-04 13:13:07 +02:00
|
|
|
|
|
|
|
if (!pinfo->pim_passive_enable)
|
|
|
|
++pinfo->pim_ifstat_reg_stop_send;
|
2015-10-15 18:02:50 +02:00
|
|
|
}
|
|
|
|
|
2020-03-20 04:08:55 +01:00
|
|
|
static void pim_reg_stop_upstream(struct pim_instance *pim,
|
|
|
|
struct pim_upstream *up)
|
|
|
|
{
|
|
|
|
switch (up->reg_state) {
|
|
|
|
case PIM_REG_NOINFO:
|
|
|
|
case PIM_REG_PRUNE:
|
|
|
|
return;
|
|
|
|
case PIM_REG_JOIN:
|
|
|
|
up->reg_state = PIM_REG_PRUNE;
|
|
|
|
pim_channel_del_oif(up->channel_oil, pim->regiface,
|
|
|
|
PIM_OIF_FLAG_PROTO_PIM, __func__);
|
2023-04-17 11:47:08 +02:00
|
|
|
pim_upstream_start_register_probe_timer(up);
|
2020-03-20 04:08:55 +01:00
|
|
|
pim_vxlan_update_sg_reg_state(pim, up, false);
|
|
|
|
break;
|
|
|
|
case PIM_REG_JOIN_PENDING:
|
|
|
|
up->reg_state = PIM_REG_PRUNE;
|
2023-04-17 11:47:08 +02:00
|
|
|
pim_upstream_start_register_probe_timer(up);
|
2020-03-20 04:08:55 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-20 19:54:31 +02:00
|
|
|
int pim_register_stop_recv(struct interface *ifp, uint8_t *buf, int buf_size)
|
2016-07-14 16:30:37 +02:00
|
|
|
{
|
2017-05-20 19:54:31 +02:00
|
|
|
struct pim_interface *pim_ifp = ifp->info;
|
|
|
|
struct pim_instance *pim = pim_ifp->pim;
|
2020-03-20 04:08:55 +01:00
|
|
|
struct pim_upstream *up = NULL;
|
|
|
|
struct pim_rpf *rp;
|
2022-01-04 17:54:44 +01:00
|
|
|
pim_sgaddr sg;
|
2020-03-20 04:08:55 +01:00
|
|
|
struct listnode *up_node;
|
|
|
|
struct pim_upstream *child;
|
2022-01-14 16:38:41 +01:00
|
|
|
bool wrong_af = false;
|
2020-03-20 04:08:55 +01:00
|
|
|
bool handling_star = false;
|
2016-07-15 21:42:09 +02:00
|
|
|
int l;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-04-07 09:05:36 +02:00
|
|
|
if (pim_ifp->pim_passive_enable) {
|
|
|
|
if (PIM_DEBUG_PIM_PACKETS)
|
|
|
|
zlog_debug(
|
|
|
|
"skip receiving PIM message on passive interface %s",
|
|
|
|
ifp->name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-03-03 10:46:36 +01:00
|
|
|
++pim_ifp->pim_ifstat_reg_stop_recv;
|
|
|
|
|
2022-01-04 17:54:44 +01:00
|
|
|
memset(&sg, 0, sizeof(sg));
|
2016-11-07 21:40:08 +01:00
|
|
|
l = pim_parse_addr_group(&sg, buf, buf_size);
|
2016-07-15 21:42:09 +02:00
|
|
|
buf += l;
|
|
|
|
buf_size -= l;
|
2022-01-14 16:38:41 +01:00
|
|
|
pim_parse_addr_ucast(&sg.src, buf, buf_size, &wrong_af);
|
|
|
|
|
|
|
|
if (wrong_af) {
|
|
|
|
zlog_err("invalid AF in Register-Stop on %s", ifp->name);
|
2022-03-14 20:51:13 +01:00
|
|
|
return -1;
|
2022-01-14 16:38:41 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
|
2016-11-17 14:17:25 +01:00
|
|
|
if (PIM_DEBUG_PIM_REG)
|
2020-03-20 04:08:55 +01:00
|
|
|
zlog_debug("Received Register stop for %pSG", &sg);
|
|
|
|
|
|
|
|
rp = RP(pim_ifp->pim, sg.grp);
|
|
|
|
if (rp) {
|
2022-06-07 14:41:37 +02:00
|
|
|
/* As per RFC 7761, Section 4.9.4:
|
|
|
|
* A special wildcard value consisting of an address field of
|
|
|
|
* all zeros can be used to indicate any source.
|
|
|
|
*/
|
2022-04-27 10:30:16 +02:00
|
|
|
if ((pim_addr_cmp(sg.src, rp->rpf_addr) == 0) ||
|
2022-06-07 14:41:37 +02:00
|
|
|
pim_addr_is_any(sg.src)) {
|
2020-03-20 04:08:55 +01:00
|
|
|
handling_star = true;
|
|
|
|
sg.src = PIMADDR_ANY;
|
|
|
|
}
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-03-20 04:08:55 +01:00
|
|
|
/*
|
|
|
|
* RFC 7761 Sec 4.4.1
|
|
|
|
* Handling Register-Stop(*,G) Messages at the DR:
|
|
|
|
* A Register-Stop(*,G) should be treated as a
|
|
|
|
* Register-Stop(S,G) for all (S,G) Register state
|
|
|
|
* machines that are not in the NoInfo state.
|
|
|
|
*/
|
|
|
|
up = pim_upstream_find(pim, &sg);
|
|
|
|
if (up) {
|
|
|
|
/*
|
|
|
|
* If the upstream find actually found a particular
|
|
|
|
* S,G then we *know* that the following for loop
|
|
|
|
* is not going to execute and this is ok
|
|
|
|
*/
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(up->sources, up_node, child)) {
|
|
|
|
if (PIM_DEBUG_PIM_REG)
|
pimd: Fix for data packet loss when FHR is LHR and RP
Topology:
A single router is acting as the First Hop Router (FHR), Last Hop Router (LHR), and RP.
RC and Issue:
When an upstream S,G is in join state, it sends a register message to the RP.
If the RP has the receiver, it sends a register stop message and switches to the shortest path.
When the register stop message is processed, it removes pimreg, moves to prune,
and starts the reg stop timer.
When the reg stop timer expires, PIM changes S,G state to Join Pending and sends out a NULL
register message to RP. RP receives it and fails to send Reg stop because SPT is not set at that point.
The problem is when the register stop timer pops and state is in Join Pending.
According to https://www.rfc-editor.org/rfc/rfc4601#section-4.4.1,
we need to put back the pimreg reg tunnel into the S,G mroute.
This causes data to be sent to the control plane and subsequently interrupts the line rate.
Fix:
If the router is FHR and RP to the group,
ignore SPT status and send out a register stop message back to the DR (in this context, the same router).
Ticket: #3506780
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>
2023-08-17 22:11:42 +02:00
|
|
|
zlog_debug(
|
|
|
|
"Executing Reg stop for upstream child %s",
|
|
|
|
child->sg_str);
|
2020-03-20 04:08:55 +01:00
|
|
|
|
|
|
|
pim_reg_stop_upstream(pim, child);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PIM_DEBUG_PIM_REG)
|
|
|
|
zlog_debug("Executing Reg stop for %s", up->sg_str);
|
|
|
|
pim_reg_stop_upstream(pim, up);
|
|
|
|
} else {
|
|
|
|
if (!handling_star)
|
|
|
|
return 0;
|
|
|
|
/*
|
|
|
|
* Unfortunately pim was unable to find a *,G
|
|
|
|
* but pim may still actually have individual
|
|
|
|
* S,G's that need to be processed. In that
|
|
|
|
* case pim must do the expensive walk to find
|
|
|
|
* and stop
|
|
|
|
*/
|
|
|
|
frr_each (rb_pim_upstream, &pim->upstream_head, up) {
|
|
|
|
if (pim_addr_cmp(up->sg.grp, sg.grp) == 0) {
|
|
|
|
if (PIM_DEBUG_PIM_REG)
|
pimd: Fix for data packet loss when FHR is LHR and RP
Topology:
A single router is acting as the First Hop Router (FHR), Last Hop Router (LHR), and RP.
RC and Issue:
When an upstream S,G is in join state, it sends a register message to the RP.
If the RP has the receiver, it sends a register stop message and switches to the shortest path.
When the register stop message is processed, it removes pimreg, moves to prune,
and starts the reg stop timer.
When the reg stop timer expires, PIM changes S,G state to Join Pending and sends out a NULL
register message to RP. RP receives it and fails to send Reg stop because SPT is not set at that point.
The problem is when the register stop timer pops and state is in Join Pending.
According to https://www.rfc-editor.org/rfc/rfc4601#section-4.4.1,
we need to put back the pimreg reg tunnel into the S,G mroute.
This causes data to be sent to the control plane and subsequently interrupts the line rate.
Fix:
If the router is FHR and RP to the group,
ignore SPT status and send out a register stop message back to the DR (in this context, the same router).
Ticket: #3506780
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>
2023-08-17 22:11:42 +02:00
|
|
|
zlog_debug(
|
|
|
|
"Executing Reg stop for upstream %s",
|
|
|
|
up->sg_str);
|
2020-03-20 04:08:55 +01:00
|
|
|
pim_reg_stop_upstream(pim, up);
|
|
|
|
}
|
|
|
|
}
|
2016-07-15 21:42:09 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-07-14 16:30:37 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-05-25 06:31:09 +02:00
|
|
|
#if PIM_IPV == 6
|
|
|
|
struct in6_addr pim_register_get_unicast_v6_addr(struct pim_interface *p_ifp)
|
|
|
|
{
|
|
|
|
struct listnode *node;
|
|
|
|
struct listnode *nextnode;
|
|
|
|
struct pim_secondary_addr *sec_addr;
|
|
|
|
struct pim_interface *pim_ifp;
|
|
|
|
struct interface *ifp;
|
|
|
|
struct pim_instance *pim = p_ifp->pim;
|
|
|
|
|
|
|
|
/* Trying to get the unicast address from the RPF interface first */
|
|
|
|
for (ALL_LIST_ELEMENTS(p_ifp->sec_addr_list, node, nextnode,
|
|
|
|
sec_addr)) {
|
|
|
|
if (!is_ipv6_global_unicast(&sec_addr->addr.u.prefix6))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
return sec_addr->addr.u.prefix6;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Loop through all the pim interface and try to return a global
|
|
|
|
* unicast ipv6 address
|
|
|
|
*/
|
|
|
|
FOR_ALL_INTERFACES (pim->vrf, ifp) {
|
|
|
|
pim_ifp = ifp->info;
|
|
|
|
|
|
|
|
if (!pim_ifp)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS(pim_ifp->sec_addr_list, node, nextnode,
|
|
|
|
sec_addr)) {
|
|
|
|
if (!is_ipv6_global_unicast(&sec_addr->addr.u.prefix6))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
return sec_addr->addr.u.prefix6;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
zlog_warn("No global address found for use to send register message");
|
|
|
|
return PIMADDR_ANY;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-03-07 05:38:31 +01:00
|
|
|
void pim_register_send(const uint8_t *buf, int buf_size, pim_addr src,
|
2016-11-17 01:20:33 +01:00
|
|
|
struct pim_rpf *rpg, int null_register,
|
|
|
|
struct pim_upstream *up)
|
2015-10-29 19:27:39 +01:00
|
|
|
{
|
2016-10-04 00:42:59 +02:00
|
|
|
unsigned char buffer[10000];
|
2015-10-29 19:27:39 +01:00
|
|
|
unsigned char *b1;
|
|
|
|
struct pim_interface *pinfo;
|
|
|
|
struct interface *ifp;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-08-03 03:44:29 +02:00
|
|
|
if (PIM_DEBUG_PIM_REG) {
|
2022-03-07 05:38:31 +01:00
|
|
|
zlog_debug("Sending %s %sRegister Packet to %pPA", up->sg_str,
|
2022-04-27 10:30:16 +02:00
|
|
|
null_register ? "NULL " : "", &rpg->rpf_addr);
|
2016-08-03 03:44:29 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-10-29 19:27:39 +01:00
|
|
|
ifp = rpg->source_nexthop.interface;
|
2016-09-15 16:18:28 +02:00
|
|
|
if (!ifp) {
|
|
|
|
if (PIM_DEBUG_PIM_REG)
|
|
|
|
zlog_debug("%s: No interface to transmit register on",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__);
|
2016-09-15 16:18:28 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-10-29 19:27:39 +01:00
|
|
|
pinfo = (struct pim_interface *)ifp->info;
|
|
|
|
if (!pinfo) {
|
2016-09-15 16:18:28 +02:00
|
|
|
if (PIM_DEBUG_PIM_REG)
|
|
|
|
zlog_debug(
|
2020-03-24 19:15:04 +01:00
|
|
|
"%s: Interface: %s not configured for pim to transmit on!",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, ifp->name);
|
2015-10-29 19:27:39 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
pimd: Pim Nexthop Tracking support with ECMP
In this patch, PIM nexthop tracking uses locally populated nexthop cached list
to determine ECMP based nexthop (w/ ECMP knob enabled), otherwise picks
the first nexthop as RPF.
Introduced '[no] ip pim ecmp' command to enable/disable PIM ECMP knob.
By default, PIM ECMP is disabled.
Intorudced '[no] ip pim ecmp rebalance' command to provide existing mcache
entry to switch new path based on hash chosen path.
Introduced, show command to display pim registered addresses and respective nexthops.
Introuduce, show command to find nexthop and out interface for (S,G) or (RP,G).
Re-Register an address with nexthop when Interface UP event received,
to ensure the PIM nexthop cache is updated (being PIM enabled).
During PIM neighbor UP, traverse all RPs and Upstreams nexthop and determine, if
any of nexthop's IPv4 address changes/resolves due to neigbor UP event.
Testing Done: Run various LHR, RP and FHR related cases to resolve RPF using
nexthop cache with ECMP knob disabled, performed interface/PIM neighbor flap events.
Executed pim-smoke with knob disabled.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
(cherry picked from commit cba444817883b8b3b22a7ed9958dc9ed77f76230)
2017-04-05 22:14:12 +02:00
|
|
|
if (PIM_DEBUG_PIM_REG) {
|
2022-03-07 05:38:31 +01:00
|
|
|
zlog_debug("%s: Sending %s %sRegister Packet to %pPA on %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, up->sg_str, null_register ? "NULL " : "",
|
2022-04-27 10:30:16 +02:00
|
|
|
&rpg->rpf_addr, ifp->name);
|
pimd: Pim Nexthop Tracking support with ECMP
In this patch, PIM nexthop tracking uses locally populated nexthop cached list
to determine ECMP based nexthop (w/ ECMP knob enabled), otherwise picks
the first nexthop as RPF.
Introduced '[no] ip pim ecmp' command to enable/disable PIM ECMP knob.
By default, PIM ECMP is disabled.
Intorudced '[no] ip pim ecmp rebalance' command to provide existing mcache
entry to switch new path based on hash chosen path.
Introduced, show command to display pim registered addresses and respective nexthops.
Introuduce, show command to find nexthop and out interface for (S,G) or (RP,G).
Re-Register an address with nexthop when Interface UP event received,
to ensure the PIM nexthop cache is updated (being PIM enabled).
During PIM neighbor UP, traverse all RPs and Upstreams nexthop and determine, if
any of nexthop's IPv4 address changes/resolves due to neigbor UP event.
Testing Done: Run various LHR, RP and FHR related cases to resolve RPF using
nexthop cache with ECMP knob disabled, performed interface/PIM neighbor flap events.
Executed pim-smoke with knob disabled.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
(cherry picked from commit cba444817883b8b3b22a7ed9958dc9ed77f76230)
2017-04-05 22:14:12 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-10-04 00:42:59 +02:00
|
|
|
memset(buffer, 0, 10000);
|
2016-07-18 02:18:33 +02:00
|
|
|
b1 = buffer + PIM_MSG_HEADER_LEN;
|
2016-08-04 18:58:47 +02:00
|
|
|
*b1 |= null_register << 6;
|
2015-10-29 19:27:39 +01:00
|
|
|
b1 = buffer + PIM_MSG_REGISTER_LEN;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-07-18 02:18:33 +02:00
|
|
|
memcpy(b1, (const unsigned char *)buf, buf_size);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-05-25 06:31:09 +02:00
|
|
|
#if PIM_IPV == 6
|
|
|
|
/* While sending Register message to RP, we cannot use link-local
|
|
|
|
* address therefore using unicast ipv6 address here, choosing it
|
|
|
|
* from the RPF Interface
|
|
|
|
*/
|
|
|
|
src = pim_register_get_unicast_v6_addr(pinfo);
|
|
|
|
#endif
|
2022-04-27 10:30:16 +02:00
|
|
|
pim_msg_build_header(src, rpg->rpf_addr, buffer,
|
|
|
|
buf_size + PIM_MSG_REGISTER_LEN,
|
2019-05-04 14:07:39 +02:00
|
|
|
PIM_MSG_TYPE_REGISTER, false);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-04-04 13:13:07 +02:00
|
|
|
if (!pinfo->pim_passive_enable)
|
|
|
|
++pinfo->pim_ifstat_reg_send;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-08-02 08:12:53 +02:00
|
|
|
if (pim_msg_send(pinfo->pim->reg_sock, src, rpg->rpf_addr, buffer,
|
2022-04-04 13:13:07 +02:00
|
|
|
buf_size + PIM_MSG_REGISTER_LEN, ifp)) {
|
2015-10-29 19:27:39 +01:00
|
|
|
if (PIM_DEBUG_PIM_TRACE) {
|
|
|
|
zlog_debug(
|
|
|
|
"%s: could not send PIM register message on interface %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, ifp->name);
|
2015-10-29 19:27:39 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-07 05:38:31 +01:00
|
|
|
#if PIM_IPV == 4
|
2019-03-22 18:01:40 +01:00
|
|
|
void pim_null_register_send(struct pim_upstream *up)
|
|
|
|
{
|
|
|
|
struct ip ip_hdr;
|
|
|
|
struct pim_interface *pim_ifp;
|
|
|
|
struct pim_rpf *rpg;
|
2022-03-07 05:38:31 +01:00
|
|
|
pim_addr src;
|
2019-03-22 18:01:40 +01:00
|
|
|
|
|
|
|
pim_ifp = up->rpf.source_nexthop.interface->info;
|
|
|
|
if (!pim_ifp) {
|
2019-11-12 14:02:06 +01:00
|
|
|
if (PIM_DEBUG_PIM_TRACE)
|
2019-03-22 18:01:40 +01:00
|
|
|
zlog_debug(
|
|
|
|
"%s: Cannot send null-register for %s no valid iif",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, up->sg_str);
|
2019-03-22 18:01:40 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rpg = RP(pim_ifp->pim, up->sg.grp);
|
|
|
|
if (!rpg) {
|
2019-11-12 14:02:06 +01:00
|
|
|
if (PIM_DEBUG_PIM_TRACE)
|
2019-03-22 18:01:40 +01:00
|
|
|
zlog_debug(
|
|
|
|
"%s: Cannot send null-register for %s no RPF to the RP",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, up->sg_str);
|
2019-03-22 18:01:40 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&ip_hdr, 0, sizeof(ip_hdr));
|
2019-03-22 18:01:40 +01:00
|
|
|
ip_hdr.ip_p = PIM_IP_PROTO_PIM;
|
|
|
|
ip_hdr.ip_hl = 5;
|
|
|
|
ip_hdr.ip_v = 4;
|
|
|
|
ip_hdr.ip_src = up->sg.src;
|
|
|
|
ip_hdr.ip_dst = up->sg.grp;
|
|
|
|
ip_hdr.ip_len = htons(20);
|
|
|
|
|
|
|
|
/* checksum is broken */
|
|
|
|
src = pim_ifp->primary_address;
|
2019-03-25 01:15:39 +01:00
|
|
|
if (PIM_UPSTREAM_FLAG_TEST_SRC_VXLAN_ORIG(up->flags)) {
|
|
|
|
if (!pim_vxlan_get_register_src(pim_ifp->pim, up, &src)) {
|
2019-11-12 14:02:06 +01:00
|
|
|
if (PIM_DEBUG_PIM_TRACE)
|
2019-03-25 01:15:39 +01:00
|
|
|
zlog_debug(
|
|
|
|
"%s: Cannot send null-register for %s vxlan-aa PIP unavailable",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, up->sg_str);
|
2019-03-25 01:15:39 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2022-03-07 05:38:31 +01:00
|
|
|
pim_register_send((uint8_t *)&ip_hdr, sizeof(struct ip), src, rpg, 1,
|
|
|
|
up);
|
2019-03-22 18:01:40 +01:00
|
|
|
}
|
2022-03-07 05:38:31 +01:00
|
|
|
#else
|
|
|
|
void pim_null_register_send(struct pim_upstream *up)
|
|
|
|
{
|
|
|
|
struct ip6_hdr ip6_hdr;
|
|
|
|
struct pim_msg_header pim_msg_header;
|
|
|
|
struct pim_interface *pim_ifp;
|
|
|
|
struct pim_rpf *rpg;
|
|
|
|
pim_addr src;
|
|
|
|
unsigned char buffer[sizeof(ip6_hdr) + sizeof(pim_msg_header)];
|
|
|
|
struct ipv6_ph ph;
|
|
|
|
|
|
|
|
pim_ifp = up->rpf.source_nexthop.interface->info;
|
|
|
|
if (!pim_ifp) {
|
|
|
|
if (PIM_DEBUG_PIM_TRACE)
|
|
|
|
zlog_debug(
|
|
|
|
"Cannot send null-register for %s no valid iif",
|
|
|
|
up->sg_str);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rpg = RP(pim_ifp->pim, up->sg.grp);
|
|
|
|
if (!rpg) {
|
|
|
|
if (PIM_DEBUG_PIM_TRACE)
|
|
|
|
zlog_debug(
|
|
|
|
"Cannot send null-register for %s no RPF to the RP",
|
|
|
|
up->sg_str);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&ip6_hdr, 0, sizeof(ip6_hdr));
|
|
|
|
ip6_hdr.ip6_nxt = PIM_IP_PROTO_PIM;
|
|
|
|
ip6_hdr.ip6_plen = PIM_MSG_HEADER_LEN;
|
|
|
|
ip6_hdr.ip6_vfc = 6 << 4;
|
|
|
|
ip6_hdr.ip6_hlim = MAXTTL;
|
|
|
|
ip6_hdr.ip6_src = up->sg.src;
|
|
|
|
ip6_hdr.ip6_dst = up->sg.grp;
|
|
|
|
|
|
|
|
memset(buffer, 0, (sizeof(ip6_hdr) + sizeof(pim_msg_header)));
|
|
|
|
memcpy(buffer, &ip6_hdr, sizeof(ip6_hdr));
|
|
|
|
|
2023-10-17 06:40:05 +02:00
|
|
|
memset(&pim_msg_header, 0, sizeof(pim_msg_header));
|
|
|
|
memset(&ph, 0, sizeof(ph));
|
2022-03-07 05:38:31 +01:00
|
|
|
|
|
|
|
ph.src = up->sg.src;
|
|
|
|
ph.dst = up->sg.grp;
|
|
|
|
ph.ulpl = htonl(PIM_MSG_HEADER_LEN);
|
|
|
|
ph.next_hdr = IPPROTO_PIM;
|
|
|
|
pim_msg_header.checksum =
|
|
|
|
in_cksum_with_ph6(&ph, &pim_msg_header, PIM_MSG_HEADER_LEN);
|
|
|
|
|
|
|
|
memcpy(buffer + sizeof(ip6_hdr), &pim_msg_header, PIM_MSG_HEADER_LEN);
|
|
|
|
|
|
|
|
|
|
|
|
src = pim_ifp->primary_address;
|
|
|
|
pim_register_send((uint8_t *)buffer,
|
|
|
|
sizeof(ip6_hdr) + PIM_MSG_HEADER_LEN, src, rpg, 1,
|
|
|
|
up);
|
|
|
|
}
|
|
|
|
#endif
|
2019-03-22 18:01:40 +01:00
|
|
|
|
2015-10-15 18:02:50 +02:00
|
|
|
/*
|
|
|
|
* 4.4.2 Receiving Register Messages at the RP
|
|
|
|
*
|
|
|
|
* When an RP receives a Register message, the course of action is
|
|
|
|
* decided according to the following pseudocode:
|
|
|
|
*
|
|
|
|
* packet_arrives_on_rp_tunnel( pkt ) {
|
|
|
|
* if( outer.dst is not one of my addresses ) {
|
|
|
|
* drop the packet silently.
|
|
|
|
* # Note: this may be a spoofing attempt
|
|
|
|
* }
|
|
|
|
* if( I_am_RP(G) AND outer.dst == RP(G) ) {
|
2019-07-01 19:26:05 +02:00
|
|
|
* sentRegisterStop = false;
|
|
|
|
* if ( register.borderbit == true ) {
|
2015-10-15 18:02:50 +02:00
|
|
|
* if ( PMBR(S,G) == unknown ) {
|
|
|
|
* PMBR(S,G) = outer.src
|
|
|
|
* } else if ( outer.src != PMBR(S,G) ) {
|
|
|
|
* send Register-Stop(S,G) to outer.src
|
|
|
|
* drop the packet silently.
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* if ( SPTbit(S,G) OR
|
|
|
|
* ( SwitchToSptDesired(S,G) AND
|
|
|
|
* ( inherited_olist(S,G) == NULL ))) {
|
|
|
|
* send Register-Stop(S,G) to outer.src
|
2019-07-01 19:26:05 +02:00
|
|
|
* sentRegisterStop = true;
|
2015-10-15 18:02:50 +02:00
|
|
|
* }
|
|
|
|
* if ( SPTbit(S,G) OR SwitchToSptDesired(S,G) ) {
|
2019-07-01 19:26:05 +02:00
|
|
|
* if ( sentRegisterStop == true ) {
|
2015-10-15 18:02:50 +02:00
|
|
|
* set KeepaliveTimer(S,G) to RP_Keepalive_Period;
|
|
|
|
* } else {
|
|
|
|
* set KeepaliveTimer(S,G) to Keepalive_Period;
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* if( !SPTbit(S,G) AND ! pkt.NullRegisterBit ) {
|
|
|
|
* decapsulate and forward the inner packet to
|
|
|
|
* inherited_olist(S,G,rpt) # Note (+)
|
|
|
|
* }
|
|
|
|
* } else {
|
|
|
|
* send Register-Stop(S,G) to outer.src
|
|
|
|
* # Note (*)
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
*/
|
2022-02-28 18:50:58 +01:00
|
|
|
int pim_register_recv(struct interface *ifp, pim_addr dest_addr,
|
|
|
|
pim_addr src_addr, uint8_t *tlv_buf, int tlv_buf_size)
|
2015-10-15 18:02:50 +02:00
|
|
|
{
|
2015-10-20 17:36:37 +02:00
|
|
|
int sentRegisterStop = 0;
|
2022-02-28 18:50:58 +01:00
|
|
|
const void *ip_hdr;
|
2022-01-04 17:54:44 +01:00
|
|
|
pim_sgaddr sg;
|
2015-10-20 17:36:37 +02:00
|
|
|
uint32_t *bits;
|
2016-09-19 19:09:38 +02:00
|
|
|
int i_am_rp = 0;
|
2020-02-20 17:59:10 +01:00
|
|
|
struct pim_interface *pim_ifp = ifp->info;
|
|
|
|
struct pim_instance *pim = pim_ifp->pim;
|
2022-02-28 18:50:58 +01:00
|
|
|
pim_addr rp_addr;
|
2023-08-29 20:59:34 +02:00
|
|
|
struct pim_rpf *rpg;
|
2017-05-19 22:41:25 +02:00
|
|
|
|
2022-04-07 09:04:21 +02:00
|
|
|
if (pim_ifp->pim_passive_enable) {
|
|
|
|
if (PIM_DEBUG_PIM_PACKETS)
|
|
|
|
zlog_debug(
|
|
|
|
"skip receiving PIM message on passive interface %s",
|
|
|
|
ifp->name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-05 15:07:46 +02:00
|
|
|
#define PIM_MSG_REGISTER_BIT_RESERVED_LEN 4
|
2022-02-28 18:50:58 +01:00
|
|
|
ip_hdr = (tlv_buf + PIM_MSG_REGISTER_BIT_RESERVED_LEN);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-02-28 18:50:58 +01:00
|
|
|
if (!if_address_is_local(&dest_addr, PIM_AF, pim->vrf->vrf_id)) {
|
|
|
|
if (PIM_DEBUG_PIM_REG)
|
2015-10-15 18:02:50 +02:00
|
|
|
zlog_debug(
|
2022-02-28 18:50:58 +01:00
|
|
|
"%s: Received Register message for destination address: %pPA that I do not own",
|
|
|
|
__func__, &dest_addr);
|
2015-10-15 18:02:50 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-04-03 22:11:58 +02:00
|
|
|
++pim_ifp->pim_ifstat_reg_recv;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-10-20 17:36:37 +02:00
|
|
|
/*
|
|
|
|
* Please note this is not drawn to get the correct bit/data size
|
|
|
|
*
|
|
|
|
* The entirety of the REGISTER packet looks like this:
|
|
|
|
* -------------------------------------------------------------
|
|
|
|
* | Ver | Type | Reserved | Checksum |
|
|
|
|
* |-----------------------------------------------------------|
|
|
|
|
* |B|N| Reserved 2 |
|
|
|
|
* |-----------------------------------------------------------|
|
|
|
|
* | Encap | IP HDR |
|
2017-07-17 14:03:14 +02:00
|
|
|
* | Mcast | |
|
2015-10-20 17:36:37 +02:00
|
|
|
* | Packet |--------------------------------------------------|
|
|
|
|
* | | Mcast Data |
|
|
|
|
* | | |
|
2017-07-17 14:03:14 +02:00
|
|
|
* ...
|
|
|
|
*
|
2015-10-20 17:36:37 +02:00
|
|
|
* tlv_buf when received from the caller points at the B bit
|
|
|
|
* We need to know the inner source and dest
|
2017-07-17 14:03:14 +02:00
|
|
|
*/
|
2015-10-20 17:36:37 +02:00
|
|
|
bits = (uint32_t *)tlv_buf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
/*
|
2015-10-20 17:36:37 +02:00
|
|
|
* tlv_buf points to the start of the |B|N|... Reserved
|
|
|
|
* Line above. So we need to add 4 bytes to get to the
|
|
|
|
* start of the actual Encapsulated data.
|
|
|
|
*/
|
2022-01-04 17:54:44 +01:00
|
|
|
memset(&sg, 0, sizeof(sg));
|
2022-02-28 18:50:58 +01:00
|
|
|
sg = pim_sgaddr_from_iphdr(ip_hdr);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-03-07 05:38:31 +01:00
|
|
|
#if PIM_IPV == 6
|
|
|
|
/*
|
|
|
|
* According to RFC section 4.9.3, If Dummy PIM Header is included
|
|
|
|
* in NULL Register as a payload there would be two PIM headers.
|
|
|
|
* The inner PIM Header's checksum field should also be validated
|
|
|
|
* in addition to the outer PIM Header's checksum. Validation of
|
|
|
|
* inner PIM header checksum is done here.
|
|
|
|
*/
|
|
|
|
if ((*bits & PIM_REGISTER_NR_BIT) &&
|
|
|
|
((tlv_buf_size - PIM_MSG_REGISTER_BIT_RESERVED_LEN) >
|
|
|
|
(int)sizeof(struct ip6_hdr))) {
|
|
|
|
uint16_t computed_checksum;
|
|
|
|
uint16_t received_checksum;
|
|
|
|
struct ipv6_ph ph;
|
|
|
|
struct pim_msg_header *header;
|
|
|
|
|
|
|
|
header = (struct pim_msg_header
|
|
|
|
*)(tlv_buf +
|
|
|
|
PIM_MSG_REGISTER_BIT_RESERVED_LEN +
|
|
|
|
sizeof(struct ip6_hdr));
|
|
|
|
ph.src = sg.src;
|
|
|
|
ph.dst = sg.grp;
|
|
|
|
ph.ulpl = htonl(PIM_MSG_HEADER_LEN);
|
|
|
|
ph.next_hdr = IPPROTO_PIM;
|
|
|
|
|
|
|
|
received_checksum = header->checksum;
|
|
|
|
|
|
|
|
header->checksum = 0;
|
|
|
|
computed_checksum = in_cksum_with_ph6(
|
|
|
|
&ph, header, htonl(PIM_MSG_HEADER_LEN));
|
|
|
|
|
|
|
|
if (computed_checksum != received_checksum) {
|
|
|
|
if (PIM_DEBUG_PIM_PACKETS)
|
|
|
|
zlog_debug(
|
|
|
|
"Ignoring Null Register message%pSG from %pPA due to bad checksum in Encapsulated dummy PIM header",
|
|
|
|
&sg, &src_addr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2020-02-20 17:59:10 +01:00
|
|
|
i_am_rp = I_am_RP(pim, sg.grp);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-02-28 18:50:58 +01:00
|
|
|
if (PIM_DEBUG_PIM_REG)
|
|
|
|
zlog_debug(
|
|
|
|
"Received Register message%pSG from %pPA on %s, rp: %d",
|
|
|
|
&sg, &src_addr, ifp->name, i_am_rp);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-10-26 14:55:23 +02:00
|
|
|
if (pim_is_grp_ssm(pim_ifp->pim, sg.grp)) {
|
2022-01-04 21:48:13 +01:00
|
|
|
if (pim_addr_is_any(sg.src)) {
|
2021-10-26 14:55:23 +02:00
|
|
|
zlog_warn(
|
2022-01-05 19:29:11 +01:00
|
|
|
"%s: Received Register message for Group(%pPA) is now in SSM, dropping the packet",
|
2021-11-05 23:05:21 +01:00
|
|
|
__func__, &sg.grp);
|
2021-10-26 14:55:23 +02:00
|
|
|
/* Drop Packet Silently */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-29 20:59:34 +02:00
|
|
|
rpg = RP(pim, sg.grp);
|
|
|
|
if (!rpg) {
|
|
|
|
zlog_warn("%s: Received Register Message %pSG from %pPA on %s where the RP could not be looked up",
|
|
|
|
__func__, &sg, &src_addr, ifp->name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
rp_addr = rpg->rpf_addr;
|
2022-02-28 18:50:58 +01:00
|
|
|
if (i_am_rp && (!pim_addr_cmp(dest_addr, rp_addr))) {
|
2015-10-20 17:36:37 +02:00
|
|
|
sentRegisterStop = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-02-20 18:14:03 +01:00
|
|
|
if (pim->register_plist) {
|
|
|
|
struct prefix_list *plist;
|
|
|
|
struct prefix src;
|
|
|
|
|
2022-01-14 16:55:12 +01:00
|
|
|
plist = prefix_list_lookup(PIM_AFI,
|
|
|
|
pim->register_plist);
|
2020-02-20 18:14:03 +01:00
|
|
|
|
2022-01-14 16:55:12 +01:00
|
|
|
pim_addr_to_prefix(&src, sg.src);
|
2020-02-20 18:14:03 +01:00
|
|
|
|
2022-11-04 16:55:55 +01:00
|
|
|
if (prefix_list_apply_ext(plist, NULL, &src, true) ==
|
|
|
|
PREFIX_DENY) {
|
2020-02-20 18:14:03 +01:00
|
|
|
pim_register_stop_send(ifp, &sg, dest_addr,
|
|
|
|
src_addr);
|
2022-02-28 18:50:58 +01:00
|
|
|
if (PIM_DEBUG_PIM_PACKETS)
|
2022-01-04 16:50:53 +01:00
|
|
|
zlog_debug(
|
2022-02-28 18:50:58 +01:00
|
|
|
"%s: Sending register-stop to %pPA for %pSG due to prefix-list denial, dropping packet",
|
|
|
|
__func__, &src_addr, &sg);
|
2020-02-20 18:14:03 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-20 17:36:37 +02:00
|
|
|
if (*bits & PIM_REGISTER_BORDER_BIT) {
|
2015-10-15 18:02:50 +02:00
|
|
|
if (PIM_DEBUG_PIM_PACKETS)
|
|
|
|
zlog_debug(
|
2022-10-13 21:54:43 +02:00
|
|
|
"%s: Received Register message with Border bit set, ignoring",
|
2015-10-15 18:02:50 +02:00
|
|
|
__func__);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-10-20 17:36:37 +02:00
|
|
|
/* Drop Packet Silently */
|
2022-10-13 21:54:43 +02:00
|
|
|
return 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:59:10 +01:00
|
|
|
struct pim_upstream *upstream = pim_upstream_find(pim, &sg);
|
2017-07-17 14:03:14 +02:00
|
|
|
/*
|
2015-10-20 17:36:37 +02:00
|
|
|
* If we don't have a place to send ignore the packet
|
|
|
|
*/
|
2016-06-24 02:42:19 +02:00
|
|
|
if (!upstream) {
|
|
|
|
upstream = pim_upstream_add(
|
2020-02-20 17:59:10 +01:00
|
|
|
pim, &sg, ifp,
|
2020-03-05 19:17:54 +01:00
|
|
|
PIM_UPSTREAM_FLAG_MASK_SRC_STREAM, __func__,
|
|
|
|
NULL);
|
2016-06-24 02:42:19 +02:00
|
|
|
if (!upstream) {
|
|
|
|
zlog_warn("Failure to create upstream state");
|
2016-08-02 10:38:11 +02:00
|
|
|
return 1;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
|
2016-08-02 10:38:11 +02:00
|
|
|
upstream->upstream_register = src_addr;
|
2017-06-16 21:23:49 +02:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If the FHR has set a very very fast register timer
|
|
|
|
* there exists a possibility that the incoming NULL
|
|
|
|
* register
|
|
|
|
* is happening before we set the spt bit. If so
|
|
|
|
* Do a quick check to update the counters and
|
|
|
|
* then set the spt bit as appropriate
|
|
|
|
*/
|
|
|
|
if (upstream->sptbit != PIM_UPSTREAM_SPTBIT_TRUE) {
|
|
|
|
pim_mroute_update_counters(
|
|
|
|
upstream->channel_oil);
|
|
|
|
/*
|
|
|
|
* Have we seen packets?
|
|
|
|
*/
|
|
|
|
if (upstream->channel_oil->cc.oldpktcnt
|
|
|
|
< upstream->channel_oil->cc.pktcnt)
|
|
|
|
pim_upstream_set_sptbit(
|
|
|
|
upstream,
|
|
|
|
upstream->rpf.source_nexthop
|
|
|
|
.interface);
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
|
pimd: Fix for data packet loss when FHR is LHR and RP
Topology:
A single router is acting as the First Hop Router (FHR), Last Hop Router (LHR), and RP.
RC and Issue:
When an upstream S,G is in join state, it sends a register message to the RP.
If the RP has the receiver, it sends a register stop message and switches to the shortest path.
When the register stop message is processed, it removes pimreg, moves to prune,
and starts the reg stop timer.
When the reg stop timer expires, PIM changes S,G state to Join Pending and sends out a NULL
register message to RP. RP receives it and fails to send Reg stop because SPT is not set at that point.
The problem is when the register stop timer pops and state is in Join Pending.
According to https://www.rfc-editor.org/rfc/rfc4601#section-4.4.1,
we need to put back the pimreg reg tunnel into the S,G mroute.
This causes data to be sent to the control plane and subsequently interrupts the line rate.
Fix:
If the router is FHR and RP to the group,
ignore SPT status and send out a register stop message back to the DR (in this context, the same router).
Ticket: #3506780
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>
2023-08-17 22:11:42 +02:00
|
|
|
if ((upstream->sptbit == PIM_UPSTREAM_SPTBIT_TRUE) ||
|
|
|
|
(PIM_UPSTREAM_FLAG_TEST_FHR(upstream->flags) && i_am_rp) ||
|
|
|
|
((SwitchToSptDesiredOnRp(pim, &sg)) &&
|
|
|
|
pim_upstream_inherited_olist(pim, upstream) == 0)) {
|
|
|
|
zlog_debug("sending pim register stop message : %s ",
|
|
|
|
upstream->sg_str);
|
2016-09-19 19:09:38 +02:00
|
|
|
pim_register_stop_send(ifp, &sg, dest_addr, src_addr);
|
|
|
|
sentRegisterStop = 1;
|
2017-07-17 14:03:14 +02:00
|
|
|
} else {
|
2016-11-01 01:01:16 +01:00
|
|
|
if (PIM_DEBUG_PIM_REG)
|
|
|
|
zlog_debug("(%s) sptbit: %d", upstream->sg_str,
|
|
|
|
upstream->sptbit);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2016-11-01 01:01:16 +01:00
|
|
|
if ((upstream->sptbit == PIM_UPSTREAM_SPTBIT_TRUE)
|
2020-02-20 17:59:10 +01:00
|
|
|
|| (SwitchToSptDesiredOnRp(pim, &sg))) {
|
2016-11-01 01:01:16 +01:00
|
|
|
if (sentRegisterStop) {
|
|
|
|
pim_upstream_keep_alive_timer_start(
|
2020-02-20 17:59:10 +01:00
|
|
|
upstream, pim->rp_keep_alive_time);
|
2017-07-17 14:03:14 +02:00
|
|
|
} else {
|
2016-11-01 01:01:16 +01:00
|
|
|
pim_upstream_keep_alive_timer_start(
|
2020-02-20 17:59:10 +01:00
|
|
|
upstream, pim->keep_alive_time);
|
2016-11-01 01:01:16 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
|
2016-09-19 19:09:38 +02:00
|
|
|
if (!(upstream->sptbit == PIM_UPSTREAM_SPTBIT_TRUE)
|
2016-05-26 02:36:10 +02:00
|
|
|
&& !(*bits & PIM_REGISTER_NR_BIT)) {
|
2016-07-23 06:35:35 +02:00
|
|
|
// decapsulate and forward the iner packet to
|
2016-06-27 20:51:04 +02:00
|
|
|
// inherited_olist(S,G,rpt)
|
2016-07-23 06:35:35 +02:00
|
|
|
// This is taken care of by the kernel for us
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2024-12-11 15:53:36 +01:00
|
|
|
|
|
|
|
#if PIM_IPV == 4
|
2016-07-23 06:35:35 +02:00
|
|
|
pim_upstream_msdp_reg_timer_start(upstream);
|
2024-12-11 15:53:36 +01:00
|
|
|
#endif /* PIM_IPV == 4 */
|
2017-07-17 14:03:14 +02:00
|
|
|
} else {
|
2015-10-15 18:02:50 +02:00
|
|
|
if (PIM_DEBUG_PIM_REG) {
|
2016-09-19 19:09:38 +02:00
|
|
|
if (!i_am_rp)
|
2022-01-04 21:24:48 +01:00
|
|
|
zlog_debug("Received Register packet for %pSG, Rejecting packet because I am not the RP configured for group",
|
|
|
|
&sg);
|
2017-07-17 14:03:14 +02:00
|
|
|
else
|
2022-01-04 21:24:48 +01:00
|
|
|
zlog_debug("Received Register packet for %pSG, Rejecting packet because the dst ip address is not the actual RP",
|
|
|
|
&sg);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2016-08-22 15:10:05 +02:00
|
|
|
pim_register_stop_send(ifp, &sg, dest_addr, src_addr);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
|
2017-01-24 23:58:59 +01:00
|
|
|
return 0;
|
2015-10-15 18:02:50 +02:00
|
|
|
}
|
2020-03-20 02:05:11 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This routine scan all upstream and update register state and remove pimreg
|
|
|
|
* when couldreg becomes false.
|
|
|
|
*/
|
|
|
|
void pim_reg_del_on_couldreg_fail(struct interface *ifp)
|
|
|
|
{
|
|
|
|
struct pim_interface *pim_ifp = ifp->info;
|
|
|
|
struct pim_instance *pim;
|
|
|
|
struct pim_upstream *up;
|
|
|
|
|
|
|
|
if (!pim_ifp)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pim = pim_ifp->pim;
|
|
|
|
|
|
|
|
frr_each (rb_pim_upstream, &pim->upstream_head, up) {
|
|
|
|
if (ifp != up->rpf.source_nexthop.interface)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!pim_upstream_could_register(up)
|
|
|
|
&& (up->reg_state != PIM_REG_NOINFO)) {
|
|
|
|
pim_channel_del_oif(up->channel_oil, pim->regiface,
|
|
|
|
PIM_OIF_FLAG_PROTO_PIM, __func__);
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(up->t_rs_timer);
|
2020-03-20 02:05:11 +01:00
|
|
|
up->reg_state = PIM_REG_NOINFO;
|
pim, pim6d: pimreg interface is not getting added in a certain scenario
Problem:
When ipv6 pim configuration is removed from the IIF on FHR node,
if we wait for RST timer to expire and then add the ipv6 pim configuration on the IIF again,
it is seen that pimreg is not getting added due to which null register wont be sent,
the register flag state also remains NO_INFO forever instead of RegPrune.
The reason for this is, when RST timer expires and IIF is unknown for the (S,G) upstream,
the FHR state is not reset due to which when the RP becomes reachable,
upstream state changes from NotJoined to Join but the register suppress timer could not be started
since we see there is no change in FHR state.
Fix:
When the Register Timer expires and the reg state is set to PIM_REG_NOINFO,reset the FHR flag,
so that when the RP becomes reachable can be because of config change or RP not reachable,
it is able to resume its duty.
Signed-off-by: Sai Gomathi N <nsaigomathi@vmware.com>
2023-06-21 11:53:09 +02:00
|
|
|
PIM_UPSTREAM_FLAG_UNSET_FHR(up->flags);
|
2020-03-20 02:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|