Skip to content

Commit

Permalink
Merge pull request #15984 from FRRouting/mergify/bp/stable/9.1/pr-15975
Browse files Browse the repository at this point in the history
pimd: fixes split off from #15969 (backport #15975)
  • Loading branch information
Jafaral committed May 9, 2024
2 parents 6b2d24b + 66e45b9 commit 629118a
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 33 deletions.
2 changes: 1 addition & 1 deletion doc/user/pim.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ is in a vrf, enter the interface command with the vrf keyword at the end.
messages. This is enabled by default. 'no' form of this command is used to
restrict processing of unicast bsm messages on this interface.

.. clicmd:: ip pim drpriority (1-4294967295)
.. clicmd:: ip pim drpriority (0-4294967295)

Set the DR Priority for the interface. This command is useful to allow the
user to influence what node becomes the DR for a lan segment.
Expand Down
2 changes: 1 addition & 1 deletion doc/user/pimv6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ is in a vrf, enter the interface command with the vrf keyword at the end.
command will not do anything if you do not have the underlying ability
of a mlag implementation.

.. clicmd:: ipv6 pim drpriority (1-4294967295)
.. clicmd:: ipv6 pim drpriority (0-4294967295)

Set the DR Priority for the interface. This command is useful to allow the
user to influence what node becomes the DR for a lan segment.
Expand Down
4 changes: 2 additions & 2 deletions pimd/pim6_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ DEFPY (interface_no_ipv6_pim,

DEFPY (interface_ipv6_pim_drprio,
interface_ipv6_pim_drprio_cmd,
"ipv6 pim drpriority (1-4294967295)",
"ipv6 pim drpriority (0-4294967295)",
IPV6_STR
PIM_STR
"Set the Designated Router Election Priority\n"
Expand All @@ -255,7 +255,7 @@ DEFPY (interface_ipv6_pim_drprio,

DEFPY (interface_no_ipv6_pim_drprio,
interface_no_ipv6_pim_drprio_cmd,
"no ipv6 pim drpriority [(1-4294967295)]",
"no ipv6 pim drpriority [(0-4294967295)]",
NO_STR
IPV6_STR
PIM_STR
Expand Down
4 changes: 2 additions & 2 deletions pimd/pim_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3953,7 +3953,7 @@ DEFUN (interface_no_ip_igmp_last_member_query_interval,

DEFUN (interface_ip_pim_drprio,
interface_ip_pim_drprio_cmd,
"ip pim drpriority (1-4294967295)",
"ip pim drpriority (0-4294967295)",
IP_STR
PIM_STR
"Set the Designated Router Election Priority\n"
Expand All @@ -3966,7 +3966,7 @@ DEFUN (interface_ip_pim_drprio,

DEFUN (interface_no_ip_pim_drprio,
interface_no_ip_pim_drprio_cmd,
"no ip pim drpriority [(1-4294967295)]",
"no ip pim drpriority [(0-4294967295)]",
NO_STR
IP_STR
PIM_STR
Expand Down
8 changes: 7 additions & 1 deletion pimd/pim_ifchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,13 @@ void pim_ifchannel_ifjoin_switch(const char *caller, struct pim_ifchannel *ch,
ch->sg_str, ch->interface->name);
}

/* pim_upstream_update_join_desired looks at up->channel_oil,
* but that's updated from pim_forward_stop(). Need this here
* so we correctly determine join_desired right below.
*/
if (new_state == PIM_IFJOIN_NOINFO)
pim_forward_stop(ch);

/*
Record uptime of state transition to/from NOINFO
*/
Expand Down Expand Up @@ -619,7 +626,6 @@ struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp, pim_sgaddr *sg,
static void ifjoin_to_noinfo(struct pim_ifchannel *ch)
{
pim_ifchannel_ifjoin_switch(__func__, ch, PIM_IFJOIN_NOINFO);
pim_forward_stop(ch);

PIM_UPSTREAM_FLAG_UNSET_SRC_PIM(ch->upstream->flags);

Expand Down
4 changes: 2 additions & 2 deletions pimd/pim_register.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ static void pim_reg_stop_upstream(struct pim_instance *pim,
up->reg_state = PIM_REG_PRUNE;
pim_channel_del_oif(up->channel_oil, pim->regiface,
PIM_OIF_FLAG_PROTO_PIM, __func__);
pim_upstream_start_register_stop_timer(up, 0);
pim_upstream_start_register_probe_timer(up);
pim_vxlan_update_sg_reg_state(pim, up, false);
break;
case PIM_REG_JOIN_PENDING:
up->reg_state = PIM_REG_PRUNE;
pim_upstream_start_register_stop_timer(up, 0);
pim_upstream_start_register_probe_timer(up);
return;
}
}
Expand Down
65 changes: 46 additions & 19 deletions pimd/pim_upstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,8 @@ const char *pim_reg_state2str(enum pim_reg_state reg_state, char *state_str,
return state_str;
}

static void pim_upstream_start_register_stop_timer(struct pim_upstream *up);

static void pim_upstream_register_stop_timer(struct event *t)
{
struct pim_interface *pim_ifp;
Expand Down Expand Up @@ -1733,7 +1735,7 @@ static void pim_upstream_register_stop_timer(struct event *t)
return;
}
up->reg_state = PIM_REG_JOIN_PENDING;
pim_upstream_start_register_stop_timer(up, 1);
pim_upstream_start_register_stop_timer(up);

if (((up->channel_oil->cc.lastused / 100)
> pim->keep_alive_time)
Expand All @@ -1751,34 +1753,59 @@ static void pim_upstream_register_stop_timer(struct event *t)
}
}

void pim_upstream_start_register_stop_timer(struct pim_upstream *up,
int null_register)
static void pim_upstream_start_register_stop_timer(struct pim_upstream *up)
{
uint32_t time;

EVENT_OFF(up->t_rs_timer);

if (!null_register) {
uint32_t lower = (0.5 * router->register_suppress_time);
uint32_t upper = (1.5 * router->register_suppress_time);
time = lower + (frr_weak_random() % (upper - lower + 1));
/* Make sure we don't wrap around */
if (time >= router->register_probe_time)
time -= router->register_probe_time;
else
time = 0;
} else
time = router->register_probe_time;
time = router->register_probe_time;

if (PIM_DEBUG_PIM_TRACE) {
zlog_debug(
"%s: (S,G)=%s Starting upstream register stop timer %d",
__func__, up->sg_str, time);
}
if (PIM_DEBUG_PIM_TRACE)
zlog_debug("%s: (S,G)=%s Starting upstream register stop timer %d",
__func__, up->sg_str, time);
event_add_timer(router->master, pim_upstream_register_stop_timer, up,
time, &up->t_rs_timer);
}

static void pim_upstream_register_probe_timer(struct event *t)
{
struct pim_upstream *up = EVENT_ARG(t);

if (!up->rpf.source_nexthop.interface ||
!up->rpf.source_nexthop.interface->info) {
if (PIM_DEBUG_PIM_REG)
zlog_debug("cannot send Null register for %pSG, no path to RP",
&up->sg);
} else
pim_null_register_send(up);

pim_upstream_start_register_stop_timer(up);
}

void pim_upstream_start_register_probe_timer(struct pim_upstream *up)
{
uint32_t time;

EVENT_OFF(up->t_rs_timer);

uint32_t lower = (0.5 * router->register_suppress_time);
uint32_t upper = (1.5 * router->register_suppress_time);
time = lower + (frr_weak_random() % (upper - lower + 1));
/* Make sure we don't wrap around */
if (time >= router->register_probe_time)
time -= router->register_probe_time;
else
time = 0;

if (PIM_DEBUG_PIM_TRACE)
zlog_debug("%s: (S,G)=%s Starting upstream register stop null probe timer %d",
__func__, up->sg_str, time);

event_add_timer(router->master, pim_upstream_register_probe_timer, up,
time, &up->t_rs_timer);
}

int pim_upstream_inherited_olist_decide(struct pim_instance *pim,
struct pim_upstream *up)
{
Expand Down
3 changes: 1 addition & 2 deletions pimd/pim_upstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ int pim_upstream_is_sg_rpt(struct pim_upstream *up);
void pim_upstream_set_sptbit(struct pim_upstream *up,
struct interface *incoming);

void pim_upstream_start_register_stop_timer(struct pim_upstream *up,
int null_register);
void pim_upstream_start_register_probe_timer(struct pim_upstream *up);

void pim_upstream_send_join(struct pim_upstream *up);

Expand Down
4 changes: 1 addition & 3 deletions yang/frr-pim.yang
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,7 @@ module frr-pim {
}

leaf dr-priority {
type uint32 {
range "1..max";
}
type uint32;
default 1;
description
"DR (Designated Router) priority";
Expand Down

0 comments on commit 629118a

Please sign in to comment.