>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 <[email protected]> --- pimd/pim_cmd.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++---- pimd/pim_neighbor.c | 5 +++- pimd/pim_neighbor.h | 2 +- pimd/pim_vty.c | 8 ++++++ 4 files changed, 82 insertions(+), 7 deletions(-) diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index fdb4f80..33523aa 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -562,10 +562,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(iflist, node, ifp)) { struct pim_interface *pim_ifp; @@ -589,7 +590,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, @@ -597,6 +598,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); } } @@ -3002,6 +3004,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", @@ -4342,7 +4404,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); install_element (VIEW_NODE, &show_ip_igmp_interface_cmd); install_element (VIEW_NODE, &show_ip_igmp_join_cmd); diff --git a/pimd/pim_neighbor.c b/pimd/pim_neighbor.c index a926317..72a3538 100644 --- a/pimd/pim_neighbor.c +++ b/pimd/pim_neighbor.c @@ -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, diff --git a/pimd/pim_neighbor.h b/pimd/pim_neighbor.h index 8f19c75..5b2172d 100644 --- a/pimd/pim_neighbor.h +++ b/pimd/pim_neighbor.h @@ -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 */ diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c index bcace95..e31e2d6 100644 --- a/pimd/pim_vty.c +++ b/pimd/pim_vty.c @@ -31,6 +31,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) { @@ -134,6 +135,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); -- 1.7.10.4 _______________________________________________ Quagga-dev mailing list [email protected] https://lists.quagga.net/mailman/listinfo/quagga-dev
