pimd: Add ability to set DR Priority for an interface

From RFC 4601, Section 4.3.1:

The DR_Priority Option allows a network administrator to give
preference to a particular router in the DR election process by
giving it a numerically larger DR Priority.  The DR_Priority Option
SHOULD be included in every Hello message, even if no DR Priority is
explicitly configured on that interface.  This is necessary because
priority-based DR election is only enabled when all neighbors on an
interface advertise that they are capable of using the DR_Priority
Option.  The default priority is 1.

This modification allows the setting of the DR Priority on a per
interface basis.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2015-06-18 18:14:20 -07:00 committed by Donald Sharp
parent 6250610a59
commit dedccda63f
4 changed files with 82 additions and 7 deletions

View File

@ -563,10 +563,11 @@ static void pim_show_dr(struct vty *vty)
now = pim_time_monotonic_sec();
vty_out(vty,
"NonPri: Number of neighbors missing DR Priority hello option%s%s",
VTY_NEWLINE, VTY_NEWLINE);
"NonPri: Number of neighbors missing DR Priority hello option%s"
"DrPri: Designated Router Priority sent%s%s",
VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
vty_out(vty, "Interface Address DR Uptime Elections Changes NonPri%s", VTY_NEWLINE);
vty_out(vty, "Interface Address DR Uptime Elections Changes NonPri DrPri%s", VTY_NEWLINE);
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
struct pim_interface *pim_ifp;
@ -590,7 +591,7 @@ static void pim_show_dr(struct vty *vty)
pim_inet4_dump("<dr?>", pim_ifp->pim_dr_addr,
dr_str, sizeof(dr_str));
vty_out(vty, "%-9s %-15s %-15s %8s %9d %7d %6d%s",
vty_out(vty, "%-9s %-15s %-15s %8s %9d %7d %6d %10d%s",
ifp->name,
inet_ntoa(ifaddr),
dr_str,
@ -598,6 +599,7 @@ static void pim_show_dr(struct vty *vty)
pim_ifp->pim_dr_election_count,
pim_ifp->pim_dr_election_changes,
pim_ifp->pim_dr_num_nondrpri_neighbors,
pim_ifp->pim_dr_priority,
VTY_NEWLINE);
}
}
@ -3123,6 +3125,66 @@ DEFUN (interface_no_ip_igmp_query_max_response_time_dsec,
return CMD_SUCCESS;
}
DEFUN (interface_ip_pim_drprio,
interface_ip_pim_drprio_cmd,
"ip pim drpriority <1-4294967295>",
IP_STR
PIM_STR
"Set the Designated Router Election Priority\n"
"Value of the new DR Priority\n")
{
struct interface *ifp;
struct pim_interface *pim_ifp;
uint32_t old_dr_prio;
ifp = vty->index;
pim_ifp = ifp->info;
if (!pim_ifp) {
vty_out(vty, "Please enable PIM on interface, first%s", VTY_NEWLINE);
return CMD_WARNING;
}
old_dr_prio = pim_ifp->pim_dr_priority;
pim_ifp->pim_dr_priority = strtol(argv[0], NULL, 10);
if (old_dr_prio != pim_ifp->pim_dr_priority) {
if (pim_if_dr_election(ifp))
pim_hello_restart_now(ifp);
}
return CMD_SUCCESS;
}
DEFUN (interface_no_ip_pim_drprio,
interface_no_ip_pim_drprio_cmd,
"no ip pim drpriority {<1-4294967295>}",
IP_STR
PIM_STR
"Revert the Designated Router Priority to default\n"
"Old Value of the Priority\n")
{
struct interface *ifp;
struct pim_interface *pim_ifp;
ifp = vty->index;
pim_ifp = ifp->info;
if (!pim_ifp) {
vty_out(vty, "Pim no enabled on this interface%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) {
pim_ifp->pim_dr_priority = PIM_DEFAULT_DR_PRIORITY;
if (pim_if_dr_election(ifp))
pim_hello_restart_now(ifp);
}
return CMD_SUCCESS;
}
DEFUN (interface_ip_pim_ssm,
interface_ip_pim_ssm_cmd,
"ip pim ssm",
@ -4684,7 +4746,9 @@ void pim_cmd_init()
install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_dsec_cmd);
install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_dsec_cmd);
install_element (INTERFACE_NODE, &interface_ip_pim_ssm_cmd);
install_element (INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd);
install_element (INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd);
install_element (INTERFACE_NODE, &interface_ip_pim_drprio_cmd);
install_element (INTERFACE_NODE, &interface_no_ip_pim_drprio_cmd);
// Static mroutes NEB
install_element (INTERFACE_NODE, &interface_ip_mroute_cmd);

View File

@ -106,7 +106,7 @@ static void dr_election_by_pri(struct interface *ifp)
PIM Hello message is received, when a neighbor times out, or when a
router's own DR Priority changes.
*/
void pim_if_dr_election(struct interface *ifp)
int pim_if_dr_election(struct interface *ifp)
{
struct pim_interface *pim_ifp = ifp->info;
struct in_addr old_dr_addr;
@ -140,7 +140,10 @@ void pim_if_dr_election(struct interface *ifp)
pim_if_update_join_desired(pim_ifp);
pim_if_update_could_assert(ifp);
pim_if_update_assert_tracking_desired(ifp);
return 1;
}
return 0;
}
static void update_dr_priority(struct pim_neighbor *neigh,

View File

@ -69,6 +69,6 @@ void pim_neighbor_update(struct pim_neighbor *neigh,
struct list *addr_list);
struct prefix *pim_neighbor_find_secondary(struct pim_neighbor *neigh,
struct in_addr addr);
void pim_if_dr_election(struct interface *ifp);
int pim_if_dr_election(struct interface *ifp);
#endif /* PIM_NEIGHBOR_H */

View File

@ -32,6 +32,7 @@
#include "pim_cmd.h"
#include "pim_str.h"
#include "pim_ssmpingd.h"
#include "pim_pim.h"
int pim_debug_config_write(struct vty *vty)
{
@ -135,6 +136,13 @@ int pim_interface_config_write(struct vty *vty)
++writes;
}
/* IF ip pim drpriority */
if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) {
vty_out(vty, " ip pim drpriority %d%s", pim_ifp->pim_dr_priority,
VTY_NEWLINE);
++writes;
}
/* IF ip igmp */
if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
vty_out(vty, " ip igmp%s", VTY_NEWLINE);