pimd, lib, vtysh: Added new 'router pim[6] [vrf NAME]' config node

Moved all existing global/vrf PIM config to the new subnode.
Existing configuration updated to be hidden and deprecated.
Both versions of configuration still work together.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
This commit is contained in:
Nathan Bahr 2024-06-12 16:26:48 +00:00
parent 66de92184f
commit fd8edc3dfb
15 changed files with 3537 additions and 889 deletions

View file

@ -182,6 +182,8 @@ enum node_type {
ISIS_SRV6_NODE_MSD_NODE, /* ISIS SRv6 Node MSDs node */ ISIS_SRV6_NODE_MSD_NODE, /* ISIS SRv6 Node MSDs node */
MGMTD_NODE, /* MGMTD node. */ MGMTD_NODE, /* MGMTD node. */
RPKI_VRF_NODE, /* RPKI node for VRF */ RPKI_VRF_NODE, /* RPKI node for VRF */
PIM_NODE, /* PIM protocol mode */
PIM6_NODE, /* PIM protocol for IPv6 mode */
NODE_TYPE_MAX, /* maximum */ NODE_TYPE_MAX, /* maximum */
}; };
/* clang-format on */ /* clang-format on */

File diff suppressed because it is too large Load diff

View file

@ -26,6 +26,7 @@ typedef struct prefix_ipv4 prefix_pim;
#define PIM_MAX_BITLEN IPV4_MAX_BITLEN #define PIM_MAX_BITLEN IPV4_MAX_BITLEN
#define PIM_AF_NAME "ip" #define PIM_AF_NAME "ip"
#define PIM_AF_DBG "pim" #define PIM_AF_DBG "pim"
#define PIM_AF_ROUTER "pim"
#define GM_AF_DBG "igmp" #define GM_AF_DBG "igmp"
#define PIM_MROUTE_DBG "mroute" #define PIM_MROUTE_DBG "mroute"
#define PIMREG "pimreg" #define PIMREG "pimreg"
@ -58,6 +59,7 @@ typedef struct prefix_ipv6 prefix_pim;
#define PIM_MAX_BITLEN IPV6_MAX_BITLEN #define PIM_MAX_BITLEN IPV6_MAX_BITLEN
#define PIM_AF_NAME "ipv6" #define PIM_AF_NAME "ipv6"
#define PIM_AF_DBG "pimv6" #define PIM_AF_DBG "pimv6"
#define PIM_AF_ROUTER "pim6"
#define GM_AF_DBG "mld" #define GM_AF_DBG "mld"
#define PIM_MROUTE_DBG "mroute6" #define PIM_MROUTE_DBG "mroute6"
#define PIMREG "pim6reg" #define PIMREG "pim6reg"

File diff suppressed because it is too large Load diff

View file

@ -100,25 +100,13 @@ int pim_process_no_join_prune_cmd(struct vty *vty)
int pim_process_spt_switchover_infinity_cmd(struct vty *vty) int pim_process_spt_switchover_infinity_cmd(struct vty *vty)
{ {
const char *vrfname;
char spt_plist_xpath[XPATH_MAXLEN]; char spt_plist_xpath[XPATH_MAXLEN];
char spt_action_xpath[XPATH_MAXLEN]; char spt_action_xpath[XPATH_MAXLEN];
vrfname = pim_cli_get_vrf_name(vty);
if (vrfname == NULL)
return CMD_WARNING_CONFIG_FAILED;
snprintf(spt_plist_xpath, sizeof(spt_plist_xpath), snprintf(spt_plist_xpath, sizeof(spt_plist_xpath),
FRR_PIM_VRF_XPATH, "frr-pim:pimd", "pim", vrfname, "%s/spt-switchover/spt-infinity-prefix-list", VTY_CURR_XPATH);
FRR_PIM_AF_XPATH_VAL);
strlcat(spt_plist_xpath, "/spt-switchover/spt-infinity-prefix-list",
sizeof(spt_plist_xpath));
snprintf(spt_action_xpath, sizeof(spt_action_xpath), snprintf(spt_action_xpath, sizeof(spt_action_xpath),
FRR_PIM_VRF_XPATH, "frr-pim:pimd", "pim", vrfname, "%s/spt-switchover/spt-action", VTY_CURR_XPATH);
FRR_PIM_AF_XPATH_VAL);
strlcat(spt_action_xpath, "/spt-switchover/spt-action",
sizeof(spt_action_xpath));
if (yang_dnode_exists(vty->candidate_config->dnode, spt_plist_xpath)) if (yang_dnode_exists(vty->candidate_config->dnode, spt_plist_xpath))
nb_cli_enqueue_change(vty, spt_plist_xpath, NB_OP_DESTROY, nb_cli_enqueue_change(vty, spt_plist_xpath, NB_OP_DESTROY,
@ -132,55 +120,30 @@ int pim_process_spt_switchover_infinity_cmd(struct vty *vty)
int pim_process_spt_switchover_prefixlist_cmd(struct vty *vty, int pim_process_spt_switchover_prefixlist_cmd(struct vty *vty,
const char *plist) const char *plist)
{ {
const char *vrfname;
char spt_plist_xpath[XPATH_MAXLEN]; char spt_plist_xpath[XPATH_MAXLEN];
char spt_action_xpath[XPATH_MAXLEN]; char spt_action_xpath[XPATH_MAXLEN];
vrfname = pim_cli_get_vrf_name(vty);
if (vrfname == NULL)
return CMD_WARNING_CONFIG_FAILED;
snprintf(spt_plist_xpath, sizeof(spt_plist_xpath), snprintf(spt_plist_xpath, sizeof(spt_plist_xpath),
FRR_PIM_VRF_XPATH, "frr-pim:pimd", "pim", vrfname, "./spt-switchover/spt-infinity-prefix-list");
FRR_PIM_AF_XPATH_VAL);
strlcat(spt_plist_xpath, "/spt-switchover/spt-infinity-prefix-list",
sizeof(spt_plist_xpath));
snprintf(spt_action_xpath, sizeof(spt_action_xpath), snprintf(spt_action_xpath, sizeof(spt_action_xpath),
FRR_PIM_VRF_XPATH, "frr-pim:pimd", "pim", vrfname, "./spt-switchover/spt-action");
FRR_PIM_AF_XPATH_VAL);
strlcat(spt_action_xpath, "/spt-switchover/spt-action",
sizeof(spt_action_xpath));
nb_cli_enqueue_change(vty, spt_action_xpath, NB_OP_MODIFY, nb_cli_enqueue_change(vty, spt_action_xpath, NB_OP_MODIFY,
"PIM_SPT_INFINITY"); "PIM_SPT_INFINITY");
nb_cli_enqueue_change(vty, spt_plist_xpath, NB_OP_MODIFY, nb_cli_enqueue_change(vty, spt_plist_xpath, NB_OP_MODIFY, plist);
plist);
return nb_cli_apply_changes(vty, NULL); return nb_cli_apply_changes(vty, NULL);
} }
int pim_process_no_spt_switchover_cmd(struct vty *vty) int pim_process_no_spt_switchover_cmd(struct vty *vty)
{ {
const char *vrfname;
char spt_plist_xpath[XPATH_MAXLEN]; char spt_plist_xpath[XPATH_MAXLEN];
char spt_action_xpath[XPATH_MAXLEN]; char spt_action_xpath[XPATH_MAXLEN];
vrfname = pim_cli_get_vrf_name(vty);
if (vrfname == NULL)
return CMD_WARNING_CONFIG_FAILED;
snprintf(spt_plist_xpath, sizeof(spt_plist_xpath), snprintf(spt_plist_xpath, sizeof(spt_plist_xpath),
FRR_PIM_VRF_XPATH, "frr-pim:pimd", "pim", vrfname, "./spt-switchover/spt-infinity-prefix-list");
FRR_PIM_AF_XPATH_VAL);
strlcat(spt_plist_xpath, "/spt-switchover/spt-infinity-prefix-list",
sizeof(spt_plist_xpath));
snprintf(spt_action_xpath, sizeof(spt_action_xpath), snprintf(spt_action_xpath, sizeof(spt_action_xpath),
FRR_PIM_VRF_XPATH, "frr-pim:pimd", "pim", vrfname, "./spt-switchover/spt-action");
FRR_PIM_AF_XPATH_VAL);
strlcat(spt_action_xpath, "/spt-switchover/spt-action",
sizeof(spt_action_xpath));
nb_cli_enqueue_change(vty, spt_plist_xpath, NB_OP_DESTROY, NULL); nb_cli_enqueue_change(vty, spt_plist_xpath, NB_OP_DESTROY, NULL);
nb_cli_enqueue_change(vty, spt_action_xpath, NB_OP_MODIFY, nb_cli_enqueue_change(vty, spt_action_xpath, NB_OP_MODIFY,
@ -217,35 +180,20 @@ int pim_process_no_pim_packet_cmd(struct vty *vty)
int pim_process_keepalivetimer_cmd(struct vty *vty, const char *kat) int pim_process_keepalivetimer_cmd(struct vty *vty, const char *kat)
{ {
const char *vrfname;
char ka_timer_xpath[XPATH_MAXLEN]; char ka_timer_xpath[XPATH_MAXLEN];
vrfname = pim_cli_get_vrf_name(vty); snprintf(ka_timer_xpath, sizeof(ka_timer_xpath), "./keep-alive-timer");
if (vrfname == NULL)
return CMD_WARNING_CONFIG_FAILED;
snprintf(ka_timer_xpath, sizeof(ka_timer_xpath), FRR_PIM_VRF_XPATH, nb_cli_enqueue_change(vty, ka_timer_xpath, NB_OP_MODIFY, kat);
"frr-pim:pimd", "pim", vrfname, FRR_PIM_AF_XPATH_VAL);
strlcat(ka_timer_xpath, "/keep-alive-timer", sizeof(ka_timer_xpath));
nb_cli_enqueue_change(vty, ka_timer_xpath, NB_OP_MODIFY,
kat);
return nb_cli_apply_changes(vty, NULL); return nb_cli_apply_changes(vty, NULL);
} }
int pim_process_no_keepalivetimer_cmd(struct vty *vty) int pim_process_no_keepalivetimer_cmd(struct vty *vty)
{ {
const char *vrfname;
char ka_timer_xpath[XPATH_MAXLEN]; char ka_timer_xpath[XPATH_MAXLEN];
vrfname = pim_cli_get_vrf_name(vty); snprintf(ka_timer_xpath, sizeof(ka_timer_xpath), "./keep-alive-timer");
if (vrfname == NULL)
return CMD_WARNING_CONFIG_FAILED;
snprintf(ka_timer_xpath, sizeof(ka_timer_xpath), FRR_PIM_VRF_XPATH,
"frr-pim:pimd", "pim", vrfname, FRR_PIM_AF_XPATH_VAL);
strlcat(ka_timer_xpath, "/keep-alive-timer", sizeof(ka_timer_xpath));
nb_cli_enqueue_change(vty, ka_timer_xpath, NB_OP_DESTROY, NULL); nb_cli_enqueue_change(vty, ka_timer_xpath, NB_OP_DESTROY, NULL);
@ -254,35 +202,25 @@ int pim_process_no_keepalivetimer_cmd(struct vty *vty)
int pim_process_rp_kat_cmd(struct vty *vty, const char *rpkat) int pim_process_rp_kat_cmd(struct vty *vty, const char *rpkat)
{ {
const char *vrfname;
char rp_ka_timer_xpath[XPATH_MAXLEN]; char rp_ka_timer_xpath[XPATH_MAXLEN];
vrfname = pim_cli_get_vrf_name(vty);
if (vrfname == NULL)
return CMD_WARNING_CONFIG_FAILED;
snprintf(rp_ka_timer_xpath, sizeof(rp_ka_timer_xpath), snprintf(rp_ka_timer_xpath, sizeof(rp_ka_timer_xpath),
FRR_PIM_VRF_XPATH, "frr-pim:pimd", "pim", vrfname, "./rp-keep-alive-timer");
FRR_PIM_AF_XPATH_VAL);
strlcat(rp_ka_timer_xpath, "/rp-keep-alive-timer",
sizeof(rp_ka_timer_xpath));
nb_cli_enqueue_change(vty, rp_ka_timer_xpath, NB_OP_MODIFY, nb_cli_enqueue_change(vty, rp_ka_timer_xpath, NB_OP_MODIFY, rpkat);
rpkat);
return nb_cli_apply_changes(vty, NULL); return nb_cli_apply_changes(vty, NULL);
} }
int pim_process_no_rp_kat_cmd(struct vty *vty) int pim_process_no_rp_kat_cmd(struct vty *vty)
{ {
const char *vrfname;
char rp_ka_timer[6]; char rp_ka_timer[6];
char rp_ka_timer_xpath[XPATH_MAXLEN]; char rp_ka_timer_xpath[XPATH_MAXLEN];
uint v; uint v;
char rs_timer_xpath[XPATH_MAXLEN]; char rs_timer_xpath[XPATH_MAXLEN];
snprintf(rs_timer_xpath, sizeof(rs_timer_xpath), snprintf(rs_timer_xpath, sizeof(rs_timer_xpath), FRR_PIM_ROUTER_XPATH,
FRR_PIM_ROUTER_XPATH, FRR_PIM_AF_XPATH_VAL); FRR_PIM_AF_XPATH_VAL);
strlcat(rs_timer_xpath, "/register-suppress-time", strlcat(rs_timer_xpath, "/register-suppress-time",
sizeof(rs_timer_xpath)); sizeof(rs_timer_xpath));
@ -301,18 +239,10 @@ int pim_process_no_rp_kat_cmd(struct vty *vty)
v = UINT16_MAX; v = UINT16_MAX;
snprintf(rp_ka_timer, sizeof(rp_ka_timer), "%u", v); snprintf(rp_ka_timer, sizeof(rp_ka_timer), "%u", v);
vrfname = pim_cli_get_vrf_name(vty);
if (vrfname == NULL)
return CMD_WARNING_CONFIG_FAILED;
snprintf(rp_ka_timer_xpath, sizeof(rp_ka_timer_xpath), snprintf(rp_ka_timer_xpath, sizeof(rp_ka_timer_xpath),
FRR_PIM_VRF_XPATH, "frr-pim:pimd", "pim", vrfname, "./rp-keep-alive-timer");
FRR_PIM_AF_XPATH_VAL);
strlcat(rp_ka_timer_xpath, "/rp-keep-alive-timer",
sizeof(rp_ka_timer_xpath));
nb_cli_enqueue_change(vty, rp_ka_timer_xpath, NB_OP_MODIFY, nb_cli_enqueue_change(vty, rp_ka_timer_xpath, NB_OP_MODIFY, rp_ka_timer);
rp_ka_timer);
return nb_cli_apply_changes(vty, NULL); return nb_cli_apply_changes(vty, NULL);
} }
@ -531,9 +461,7 @@ int pim_process_no_ip_mroute_cmd(struct vty *vty, const char *interface,
int pim_process_rp_cmd(struct vty *vty, const char *rp_str, int pim_process_rp_cmd(struct vty *vty, const char *rp_str,
const char *group_str) const char *group_str)
{ {
const char *vrfname;
char group_xpath[XPATH_MAXLEN]; char group_xpath[XPATH_MAXLEN];
char rp_xpath[XPATH_MAXLEN];
int printed; int printed;
int result = 0; int result = 0;
struct prefix group; struct prefix group;
@ -575,14 +503,9 @@ int pim_process_rp_cmd(struct vty *vty, const char *rp_str,
} }
#endif #endif
vrfname = pim_cli_get_vrf_name(vty);
if (vrfname == NULL)
return CMD_WARNING_CONFIG_FAILED;
snprintf(rp_xpath, sizeof(rp_xpath), FRR_PIM_STATIC_RP_XPATH,
"frr-pim:pimd", "pim", vrfname, FRR_PIM_AF_XPATH_VAL, rp_str);
printed = snprintf(group_xpath, sizeof(group_xpath), printed = snprintf(group_xpath, sizeof(group_xpath),
"%s/group-list[.='%s']", rp_xpath, group_str); "./" FRR_PIM_STATIC_RP_XPATH "/group-list[.='%s']",
rp_str, group_str);
if (printed >= (int)(sizeof(group_xpath))) { if (printed >= (int)(sizeof(group_xpath))) {
vty_out(vty, "Xpath too long (%d > %u)", printed + 1, vty_out(vty, "Xpath too long (%d > %u)", printed + 1,
@ -601,15 +524,10 @@ int pim_process_no_rp_cmd(struct vty *vty, const char *rp_str,
char group_xpath[XPATH_MAXLEN]; char group_xpath[XPATH_MAXLEN];
char rp_xpath[XPATH_MAXLEN]; char rp_xpath[XPATH_MAXLEN];
int printed; int printed;
const char *vrfname;
const struct lyd_node *group_dnode; const struct lyd_node *group_dnode;
vrfname = pim_cli_get_vrf_name(vty); snprintf(rp_xpath, sizeof(rp_xpath), "%s/" FRR_PIM_STATIC_RP_XPATH,
if (vrfname == NULL) VTY_CURR_XPATH, rp_str);
return CMD_WARNING_CONFIG_FAILED;
snprintf(rp_xpath, sizeof(rp_xpath), FRR_PIM_STATIC_RP_XPATH,
"frr-pim:pimd", "pim", vrfname, FRR_PIM_AF_XPATH_VAL, rp_str);
printed = snprintf(group_xpath, sizeof(group_xpath), printed = snprintf(group_xpath, sizeof(group_xpath),
"%s/group-list[.='%s']", rp_xpath, group_str); "%s/group-list[.='%s']", rp_xpath, group_str);
@ -636,16 +554,10 @@ int pim_process_no_rp_cmd(struct vty *vty, const char *rp_str,
int pim_process_rp_plist_cmd(struct vty *vty, const char *rp_str, int pim_process_rp_plist_cmd(struct vty *vty, const char *rp_str,
const char *prefix_list) const char *prefix_list)
{ {
const char *vrfname;
char rp_plist_xpath[XPATH_MAXLEN]; char rp_plist_xpath[XPATH_MAXLEN];
vrfname = pim_cli_get_vrf_name(vty);
if (vrfname == NULL)
return CMD_WARNING_CONFIG_FAILED;
snprintf(rp_plist_xpath, sizeof(rp_plist_xpath), snprintf(rp_plist_xpath, sizeof(rp_plist_xpath),
FRR_PIM_STATIC_RP_XPATH, "frr-pim:pimd", "pim", vrfname, "./" FRR_PIM_STATIC_RP_XPATH, rp_str);
FRR_PIM_AF_XPATH_VAL, rp_str);
strlcat(rp_plist_xpath, "/prefix-list", sizeof(rp_plist_xpath)); strlcat(rp_plist_xpath, "/prefix-list", sizeof(rp_plist_xpath));
nb_cli_enqueue_change(vty, rp_plist_xpath, NB_OP_MODIFY, prefix_list); nb_cli_enqueue_change(vty, rp_plist_xpath, NB_OP_MODIFY, prefix_list);
@ -658,19 +570,12 @@ int pim_process_no_rp_plist_cmd(struct vty *vty, const char *rp_str,
{ {
char rp_xpath[XPATH_MAXLEN]; char rp_xpath[XPATH_MAXLEN];
char plist_xpath[XPATH_MAXLEN]; char plist_xpath[XPATH_MAXLEN];
const char *vrfname;
const struct lyd_node *plist_dnode; const struct lyd_node *plist_dnode;
const char *plist; const char *plist;
vrfname = pim_cli_get_vrf_name(vty); snprintf(rp_xpath, sizeof(rp_xpath), "%s/" FRR_PIM_STATIC_RP_XPATH,
if (vrfname == NULL) VTY_CURR_XPATH, rp_str);
return CMD_WARNING_CONFIG_FAILED; snprintf(plist_xpath, sizeof(plist_xpath), "%s", rp_xpath);
snprintf(rp_xpath, sizeof(rp_xpath), FRR_PIM_STATIC_RP_XPATH,
"frr-pim:pimd", "pim", vrfname, FRR_PIM_AF_XPATH_VAL, rp_str);
snprintf(plist_xpath, sizeof(plist_xpath), FRR_PIM_STATIC_RP_XPATH,
"frr-pim:pimd", "pim", vrfname, FRR_PIM_AF_XPATH_VAL, rp_str);
strlcat(plist_xpath, "/prefix-list", sizeof(plist_xpath)); strlcat(plist_xpath, "/prefix-list", sizeof(plist_xpath));
plist_dnode = yang_dnode_get(vty->candidate_config->dnode, plist_xpath); plist_dnode = yang_dnode_get(vty->candidate_config->dnode, plist_xpath);
@ -679,7 +584,7 @@ int pim_process_no_rp_plist_cmd(struct vty *vty, const char *rp_str,
return NB_OK; return NB_OK;
} }
plist = yang_dnode_get_string(plist_dnode, "%s", plist_xpath); plist = yang_dnode_get_string(plist_dnode, NULL);
if (strcmp(prefix_list, plist)) { if (strcmp(prefix_list, plist)) {
vty_out(vty, "%% Unable to find specified RP\n"); vty_out(vty, "%% Unable to find specified RP\n");
return NB_OK; return NB_OK;
@ -3408,21 +3313,11 @@ int gm_process_no_last_member_query_interval_cmd(struct vty *vty)
int pim_process_ssmpingd_cmd(struct vty *vty, enum nb_operation operation, int pim_process_ssmpingd_cmd(struct vty *vty, enum nb_operation operation,
const char *src_str) const char *src_str)
{ {
const char *vrfname;
char ssmpingd_ip_xpath[XPATH_MAXLEN];
char ssmpingd_src_ip_xpath[XPATH_MAXLEN]; char ssmpingd_src_ip_xpath[XPATH_MAXLEN];
int printed; int printed;
vrfname = pim_cli_get_vrf_name(vty);
if (vrfname == NULL)
return CMD_WARNING_CONFIG_FAILED;
snprintf(ssmpingd_ip_xpath, sizeof(ssmpingd_ip_xpath),
FRR_PIM_VRF_XPATH, "frr-pim:pimd", "pim", vrfname,
FRR_PIM_AF_XPATH_VAL);
printed = snprintf(ssmpingd_src_ip_xpath, sizeof(ssmpingd_src_ip_xpath), printed = snprintf(ssmpingd_src_ip_xpath, sizeof(ssmpingd_src_ip_xpath),
"%s/ssm-pingd-source-ip[.='%s']", ssmpingd_ip_xpath, "./ssm-pingd-source-ip[.='%s']", src_str);
src_str);
if (printed >= (int)sizeof(ssmpingd_src_ip_xpath)) { if (printed >= (int)sizeof(ssmpingd_src_ip_xpath)) {
vty_out(vty, "Xpath too long (%d > %u)", printed + 1, vty_out(vty, "Xpath too long (%d > %u)", printed + 1,
XPATH_MAXLEN); XPATH_MAXLEN);
@ -5705,3 +5600,34 @@ int pim_show_bsm_db_helper(const char *vrf, struct vty *vty, bool uj)
return CMD_SUCCESS; return CMD_SUCCESS;
} }
int pim_router_config_write(struct vty *vty)
{
struct vrf *vrf;
struct pim_instance *pim;
int writes = 0;
char framestr[64] = { 0 };
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
pim = vrf->info;
if (!pim)
continue;
snprintfrr(framestr, sizeof(framestr), "router %s",
PIM_AF_ROUTER);
if (vrf->vrf_id != VRF_DEFAULT) {
strlcat(framestr, " vrf ", sizeof(framestr));
strlcat(framestr, vrf->name, sizeof(framestr));
}
vty_frame(vty, "%s\n", framestr);
++writes;
writes += pim_global_config_write_worker(pim, vty);
vty_endframe(vty, "exit\n");
++writes;
}
return writes;
}

View file

@ -182,6 +182,8 @@ int pim_show_interface_traffic_helper(const char *vrf, const char *if_name,
void clear_pim_interfaces(struct pim_instance *pim); void clear_pim_interfaces(struct pim_instance *pim);
void pim_show_bsr(struct pim_instance *pim, struct vty *vty, bool uj); void pim_show_bsr(struct pim_instance *pim, struct vty *vty, bool uj);
int pim_show_bsr_helper(const char *vrf, struct vty *vty, bool uj); int pim_show_bsr_helper(const char *vrf, struct vty *vty, bool uj);
int pim_router_config_write(struct vty *vty);
/* /*
* Special Macro to allow us to get the correct pim_instance; * Special Macro to allow us to get the correct pim_instance;
*/ */

View file

@ -201,6 +201,7 @@ static int pim_vrf_config_write(struct vty *vty)
{ {
struct vrf *vrf; struct vrf *vrf;
struct pim_instance *pim; struct pim_instance *pim;
char spaces[10];
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
pim = vrf->info; pim = vrf->info;
@ -208,10 +209,24 @@ static int pim_vrf_config_write(struct vty *vty)
if (!pim) if (!pim)
continue; continue;
if (vrf->vrf_id != VRF_DEFAULT) if (vrf->vrf_id != VRF_DEFAULT) {
vty_frame(vty, "vrf %s\n", vrf->name); vty_frame(vty, "vrf %s\n", vrf->name);
snprintf(spaces, sizeof(spaces), "%s", " ");
} else {
snprintf(spaces, sizeof(spaces), "%s", "");
}
pim_global_config_write_worker(pim, vty); /* Global IGMP/MLD configuration */
if (pim->gm_watermark_limit != 0) {
#if PIM_IPV == 4
vty_out(vty,
"%s" PIM_AF_NAME " igmp watermark-warn %u\n",
spaces, pim->gm_watermark_limit);
#else
vty_out(vty, "%s" PIM_AF_NAME " mld watermark-warn %u\n",
spaces, pim->gm_watermark_limit);
#endif
}
if (vrf->vrf_id != VRF_DEFAULT) if (vrf->vrf_id != VRF_DEFAULT)
vty_endframe(vty, "exit-vrf\n!\n"); vty_endframe(vty, "exit-vrf\n!\n");

View file

@ -1276,8 +1276,7 @@ static void pim_msdp_src_del(struct pim_msdp_mg *mg)
} }
/*********************** MSDP feature APIs *********************************/ /*********************** MSDP feature APIs *********************************/
int pim_msdp_config_write(struct pim_instance *pim, struct vty *vty, int pim_msdp_config_write(struct pim_instance *pim, struct vty *vty)
const char *spaces)
{ {
struct pim_msdp_mg *mg; struct pim_msdp_mg *mg;
struct listnode *mbrnode; struct listnode *mbrnode;
@ -1292,14 +1291,14 @@ int pim_msdp_config_write(struct pim_instance *pim, struct vty *vty,
if (mg->src_ip.s_addr != INADDR_ANY) { if (mg->src_ip.s_addr != INADDR_ANY) {
pim_inet4_dump("<src?>", mg->src_ip, src_str, pim_inet4_dump("<src?>", mg->src_ip, src_str,
sizeof(src_str)); sizeof(src_str));
vty_out(vty, "%sip msdp mesh-group %s source %s\n", vty_out(vty, " msdp mesh-group %s source %s\n",
spaces, mg->mesh_group_name, src_str); mg->mesh_group_name, src_str);
++count; ++count;
} }
for (ALL_LIST_ELEMENTS_RO(mg->mbr_list, mbrnode, mbr)) { for (ALL_LIST_ELEMENTS_RO(mg->mbr_list, mbrnode, mbr)) {
vty_out(vty, "%sip msdp mesh-group %s member %pI4\n", vty_out(vty, " msdp mesh-group %s member %pI4\n",
spaces, mg->mesh_group_name, &mbr->mbr_ip); mg->mesh_group_name, &mbr->mbr_ip);
++count; ++count;
} }
} }
@ -1307,8 +1306,7 @@ int pim_msdp_config_write(struct pim_instance *pim, struct vty *vty,
return count; return count;
} }
bool pim_msdp_peer_config_write(struct vty *vty, struct pim_instance *pim, bool pim_msdp_peer_config_write(struct vty *vty, struct pim_instance *pim)
const char *spaces)
{ {
struct pim_msdp_peer *mp; struct pim_msdp_peer *mp;
struct listnode *node; struct listnode *node;
@ -1319,8 +1317,8 @@ bool pim_msdp_peer_config_write(struct vty *vty, struct pim_instance *pim,
if (mp->flags & PIM_MSDP_PEERF_IN_GROUP) if (mp->flags & PIM_MSDP_PEERF_IN_GROUP)
continue; continue;
vty_out(vty, "%sip msdp peer %pI4 source %pI4\n", spaces, vty_out(vty, " msdp peer %pI4 source %pI4\n", &mp->peer,
&mp->peer, &mp->local); &mp->local);
written = true; written = true;
} }

View file

@ -228,10 +228,8 @@ void pim_msdp_peer_pkt_rxed(struct pim_msdp_peer *mp);
void pim_msdp_peer_stop_tcp_conn(struct pim_msdp_peer *mp, bool chg_state); void pim_msdp_peer_stop_tcp_conn(struct pim_msdp_peer *mp, bool chg_state);
void pim_msdp_peer_reset_tcp_conn(struct pim_msdp_peer *mp, const char *rc_str); void pim_msdp_peer_reset_tcp_conn(struct pim_msdp_peer *mp, const char *rc_str);
void pim_msdp_write(struct event *thread); void pim_msdp_write(struct event *thread);
int pim_msdp_config_write(struct pim_instance *pim, struct vty *vty, int pim_msdp_config_write(struct pim_instance *pim, struct vty *vty);
const char *spaces); bool pim_msdp_peer_config_write(struct vty *vty, struct pim_instance *pim);
bool pim_msdp_peer_config_write(struct vty *vty, struct pim_instance *pim,
const char *spaces);
void pim_msdp_peer_pkt_txed(struct pim_msdp_peer *mp); void pim_msdp_peer_pkt_txed(struct pim_msdp_peer *mp);
void pim_msdp_sa_ref(struct pim_instance *pim, struct pim_msdp_peer *mp, void pim_msdp_sa_ref(struct pim_instance *pim, struct pim_msdp_peer *mp,
pim_sgaddr *sg, struct in_addr rp); pim_sgaddr *sg, struct in_addr rp);
@ -339,14 +337,13 @@ static inline void pim_msdp_sa_local_del(struct pim_instance *pim,
} }
static inline int pim_msdp_config_write(struct pim_instance *pim, static inline int pim_msdp_config_write(struct pim_instance *pim,
struct vty *vty, const char *spaces) struct vty *vty)
{ {
return 0; return 0;
} }
static inline bool pim_msdp_peer_config_write(struct vty *vty, static inline bool pim_msdp_peer_config_write(struct vty *vty,
struct pim_instance *pim, struct pim_instance *pim)
const char *spaces)
{ {
return false; return false;
} }

View file

@ -207,9 +207,6 @@ int routing_control_plane_protocols_name_validate(
"./frr-pim:pim/address-family[address-family='%s']/" \ "./frr-pim:pim/address-family[address-family='%s']/" \
"mroute[source-addr='%s'][group-addr='%s']" "mroute[source-addr='%s'][group-addr='%s']"
#define FRR_PIM_STATIC_RP_XPATH \ #define FRR_PIM_STATIC_RP_XPATH \
"/frr-routing:routing/control-plane-protocols/" \
"control-plane-protocol[type='%s'][name='%s'][vrf='%s']/" \
"frr-pim:pim/address-family[address-family='%s']/" \
"frr-pim-rp:rp/static-rp/rp-list[rp-address='%s']" "frr-pim-rp:rp/static-rp/rp-list[rp-address='%s']"
#define FRR_GMP_INTERFACE_XPATH \ #define FRR_GMP_INTERFACE_XPATH \
"./frr-gmp:gmp/address-family[address-family='%s']" "./frr-gmp:gmp/address-family[address-family='%s']"
@ -218,6 +215,5 @@ int routing_control_plane_protocols_name_validate(
#define FRR_GMP_JOIN_XPATH \ #define FRR_GMP_JOIN_XPATH \
"./frr-gmp:gmp/address-family[address-family='%s']/" \ "./frr-gmp:gmp/address-family[address-family='%s']/" \
"static-group[group-addr='%s'][source-addr='%s']" "static-group[group-addr='%s'][source-addr='%s']"
#define FRR_PIM_MSDP_XPATH FRR_PIM_VRF_XPATH "/msdp"
#endif /* _FRR_PIM_NB_H_ */ #endif /* _FRR_PIM_NB_H_ */

View file

@ -1129,8 +1129,7 @@ int pim_rp_set_upstream_addr(struct pim_instance *pim, pim_addr *up,
return 1; return 1;
} }
int pim_rp_config_write(struct pim_instance *pim, struct vty *vty, int pim_rp_config_write(struct pim_instance *pim, struct vty *vty)
const char *spaces)
{ {
struct listnode *node; struct listnode *node;
struct rp_info *rp_info; struct rp_info *rp_info;
@ -1146,13 +1145,11 @@ int pim_rp_config_write(struct pim_instance *pim, struct vty *vty,
rp_addr = rp_info->rp.rpf_addr; rp_addr = rp_info->rp.rpf_addr;
if (rp_info->plist) if (rp_info->plist)
vty_out(vty, vty_out(vty, " rp %pPA prefix-list %s\n", &rp_addr,
"%s" PIM_AF_NAME rp_info->plist);
" pim rp %pPA prefix-list %s\n",
spaces, &rp_addr, rp_info->plist);
else else
vty_out(vty, "%s" PIM_AF_NAME " pim rp %pPA %pFX\n", vty_out(vty, " rp %pPA %pFX\n", &rp_addr,
spaces, &rp_addr, &rp_info->group); &rp_info->group);
count++; count++;
} }

View file

@ -46,8 +46,7 @@ int pim_rp_change(struct pim_instance *pim, pim_addr new_rp_addr,
void pim_rp_prefix_list_update(struct pim_instance *pim, void pim_rp_prefix_list_update(struct pim_instance *pim,
struct prefix_list *plist); struct prefix_list *plist);
int pim_rp_config_write(struct pim_instance *pim, struct vty *vty, int pim_rp_config_write(struct pim_instance *pim, struct vty *vty);
const char *spaces);
void pim_rp_setup(struct pim_instance *pim); void pim_rp_setup(struct pim_instance *pim);

View file

@ -172,89 +172,66 @@ int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
{ {
int writes = 0; int writes = 0;
struct pim_ssm *ssm = pim->ssm_info; struct pim_ssm *ssm = pim->ssm_info;
char spaces[10];
if (pim->vrf->vrf_id == VRF_DEFAULT) writes += pim_msdp_peer_config_write(vty, pim);
snprintf(spaces, sizeof(spaces), "%s", ""); writes += pim_msdp_config_write(pim, vty);
else
snprintf(spaces, sizeof(spaces), "%s", " ");
writes += pim_msdp_peer_config_write(vty, pim, spaces);
writes += pim_msdp_config_write(pim, vty, spaces);
if (!pim->send_v6_secondary) { if (!pim->send_v6_secondary) {
vty_out(vty, "%sno ip pim send-v6-secondary\n", spaces); vty_out(vty, " no send-v6-secondary\n");
++writes; ++writes;
} }
writes += pim_rp_config_write(pim, vty, spaces); writes += pim_rp_config_write(pim, vty);
if (pim->vrf->vrf_id == VRF_DEFAULT) { if (pim->vrf->vrf_id == VRF_DEFAULT) {
if (router->register_suppress_time if (router->register_suppress_time
!= PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) { != PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) {
vty_out(vty, "%s" PIM_AF_NAME " pim register-suppress-time %d\n", vty_out(vty, " register-suppress-time %d\n",
spaces, router->register_suppress_time); router->register_suppress_time);
++writes; ++writes;
} }
if (router->t_periodic != PIM_DEFAULT_T_PERIODIC) { if (router->t_periodic != PIM_DEFAULT_T_PERIODIC) {
vty_out(vty, "%s" PIM_AF_NAME " pim join-prune-interval %d\n", vty_out(vty, " join-prune-interval %d\n",
spaces, router->t_periodic); router->t_periodic);
++writes; ++writes;
} }
if (router->packet_process != PIM_DEFAULT_PACKET_PROCESS) { if (router->packet_process != PIM_DEFAULT_PACKET_PROCESS) {
vty_out(vty, "%s" PIM_AF_NAME " pim packets %d\n", spaces, vty_out(vty, " packets %d\n", router->packet_process);
router->packet_process);
++writes; ++writes;
} }
} }
if (pim->keep_alive_time != PIM_KEEPALIVE_PERIOD) { if (pim->keep_alive_time != PIM_KEEPALIVE_PERIOD) {
vty_out(vty, "%s" PIM_AF_NAME " pim keep-alive-timer %d\n", vty_out(vty, " keep-alive-timer %d\n", pim->keep_alive_time);
spaces, pim->keep_alive_time);
++writes; ++writes;
} }
if (pim->rp_keep_alive_time != (unsigned int)PIM_RP_KEEPALIVE_PERIOD) { if (pim->rp_keep_alive_time != (unsigned int)PIM_RP_KEEPALIVE_PERIOD) {
vty_out(vty, "%s" PIM_AF_NAME " pim rp keep-alive-timer %d\n", vty_out(vty, " rp keep-alive-timer %d\n",
spaces, pim->rp_keep_alive_time); pim->rp_keep_alive_time);
++writes; ++writes;
} }
if (ssm->plist_name) { if (ssm->plist_name) {
vty_out(vty, "%sip pim ssm prefix-list %s\n", spaces, vty_out(vty, " ssm prefix-list %s\n", ssm->plist_name);
ssm->plist_name);
++writes; ++writes;
} }
if (pim->register_plist) { if (pim->register_plist) {
vty_out(vty, "%sip pim register-accept-list %s\n", spaces, vty_out(vty, " register-accept-list %s\n", pim->register_plist);
pim->register_plist);
++writes; ++writes;
} }
if (pim->spt.switchover == PIM_SPT_INFINITY) { if (pim->spt.switchover == PIM_SPT_INFINITY) {
if (pim->spt.plist) if (pim->spt.plist)
vty_out(vty, vty_out(vty,
"%s" PIM_AF_NAME " pim spt-switchover infinity-and-beyond prefix-list %s\n", " spt-switchover infinity-and-beyond prefix-list %s\n",
spaces, pim->spt.plist); pim->spt.plist);
else else
vty_out(vty, vty_out(vty, " spt-switchover infinity-and-beyond\n");
"%s" PIM_AF_NAME " pim spt-switchover infinity-and-beyond\n",
spaces);
++writes; ++writes;
} }
if (pim->ecmp_rebalance_enable) { if (pim->ecmp_rebalance_enable) {
vty_out(vty, "%sip pim ecmp rebalance\n", spaces); vty_out(vty, " ecmp rebalance\n");
++writes; ++writes;
} else if (pim->ecmp_enable) { } else if (pim->ecmp_enable) {
vty_out(vty, "%sip pim ecmp\n", spaces); vty_out(vty, " ecmp\n");
++writes;
}
if (pim->gm_watermark_limit != 0) {
#if PIM_IPV == 4
vty_out(vty, "%s" PIM_AF_NAME " igmp watermark-warn %u\n",
spaces, pim->gm_watermark_limit);
#else
vty_out(vty, "%s" PIM_AF_NAME " mld watermark-warn %u\n",
spaces, pim->gm_watermark_limit);
#endif
++writes; ++writes;
} }
@ -263,8 +240,7 @@ int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
struct ssmpingd_sock *ss; struct ssmpingd_sock *ss;
++writes; ++writes;
for (ALL_LIST_ELEMENTS_RO(pim->ssmpingd_list, node, ss)) { for (ALL_LIST_ELEMENTS_RO(pim->ssmpingd_list, node, ss)) {
vty_out(vty, "%s" PIM_AF_NAME " ssmpingd %pPA\n", vty_out(vty, " ssmpingd %pPA\n", &ss->source_addr);
spaces, &ss->source_addr);
++writes; ++writes;
} }
} }
@ -272,8 +248,8 @@ int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
if (pim->msdp.hold_time != PIM_MSDP_PEER_HOLD_TIME if (pim->msdp.hold_time != PIM_MSDP_PEER_HOLD_TIME
|| pim->msdp.keep_alive != PIM_MSDP_PEER_KA_TIME || pim->msdp.keep_alive != PIM_MSDP_PEER_KA_TIME
|| pim->msdp.connection_retry != PIM_MSDP_PEER_CONNECT_RETRY_TIME) { || pim->msdp.connection_retry != PIM_MSDP_PEER_CONNECT_RETRY_TIME) {
vty_out(vty, "%sip msdp timers %u %u", spaces, vty_out(vty, " msdp timers %u %u", pim->msdp.hold_time,
pim->msdp.hold_time, pim->msdp.keep_alive); pim->msdp.keep_alive);
if (pim->msdp.connection_retry if (pim->msdp.connection_retry
!= PIM_MSDP_PEER_CONNECT_RETRY_TIME) != PIM_MSDP_PEER_CONNECT_RETRY_TIME)
vty_out(vty, " %u", pim->msdp.connection_retry); vty_out(vty, " %u", pim->msdp.connection_retry);

View file

@ -1677,6 +1677,24 @@ static struct cmd_node bfd_profile_node = {
}; };
#endif /* HAVE_BFDD */ #endif /* HAVE_BFDD */
#ifdef HAVE_PIMD
static struct cmd_node pim_node = {
.name = "pim",
.node = PIM_NODE,
.parent_node = CONFIG_NODE,
.prompt = "%s(config-pim)# ",
};
#endif /* HAVE_PIMD */
#ifdef HAVE_PIM6D
static struct cmd_node pim6_node = {
.name = "pim6",
.node = PIM6_NODE,
.parent_node = CONFIG_NODE,
.prompt = "%s(config-pim6)# ",
};
#endif /* HAVE_PIM6D */
/* Defined in lib/vty.c */ /* Defined in lib/vty.c */
extern struct cmd_node vty_node; extern struct cmd_node vty_node;
@ -2413,6 +2431,30 @@ DEFUNSH(VTYSH_BFDD, bfd_profile_enter, bfd_profile_enter_cmd,
} }
#endif /* HAVE_BFDD */ #endif /* HAVE_BFDD */
#ifdef HAVE_PIMD
DEFUNSH(VTYSH_PIMD, router_pim, router_pim_cmd,
"router pim [vrf NAME]",
ROUTER_STR
"Start PIM configuration\n"
VRF_CMD_HELP_STR)
{
vty->node = PIM_NODE;
return CMD_SUCCESS;
}
#endif /* HAVE_PIMD */
#ifdef HAVE_PIM6D
DEFUNSH(VTYSH_PIM6D, router_pim6, router_pim6_cmd,
"router pim6 [vrf NAME]",
ROUTER_STR
"Start PIMv6 configuration\n"
VRF_CMD_HELP_STR)
{
vty->node = PIM6_NODE;
return CMD_SUCCESS;
}
#endif /* HAVE_PIM6D*/
DEFUNSH(VTYSH_ALL, vtysh_line_vty, vtysh_line_vty_cmd, "line vty", DEFUNSH(VTYSH_ALL, vtysh_line_vty, vtysh_line_vty_cmd, "line vty",
"Configure a terminal line\n" "Configure a terminal line\n"
"Virtual terminal\n") "Virtual terminal\n")
@ -2826,6 +2868,34 @@ DEFUNSH(VTYSH_PATHD, vtysh_quit_pathd, vtysh_quit_pathd_cmd, "quit",
} }
#endif /* HAVE_PATHD */ #endif /* HAVE_PATHD */
#ifdef HAVE_PIMD
DEFUNSH(VTYSH_PIMD, vtysh_exit_pimd, vtysh_exit_pimd_cmd, "exit",
"Exit current mode and down to previous mode\n")
{
return vtysh_exit(vty);
}
DEFUNSH(VTYSH_PIMD, vtysh_quit_pimd, vtysh_quit_pimd_cmd, "quit",
"Exit current mode and down to previous mode\n")
{
return vtysh_exit_pimd(self, vty, argc, argv);
}
#endif /* HAVE_PIMD */
#ifdef HAVE_PIM6D
DEFUNSH(VTYSH_PIM6D, vtysh_exit_pim6d, vtysh_exit_pim6d_cmd, "exit",
"Exit current mode and down to previous mode\n")
{
return vtysh_exit(vty);
}
DEFUNSH(VTYSH_PIM6D, vtysh_quit_pim6d, vtysh_quit_pim6d_cmd, "quit",
"Exit current mode and down to previous mode\n")
{
return vtysh_exit_pim6d(self, vty, argc, argv);
}
#endif /* HAVE_PIM6D */
DEFUNSH(VTYSH_ALL, vtysh_exit_line_vty, vtysh_exit_line_vty_cmd, "exit", DEFUNSH(VTYSH_ALL, vtysh_exit_line_vty, vtysh_exit_line_vty_cmd, "exit",
"Exit current mode and down to previous mode\n") "Exit current mode and down to previous mode\n")
{ {
@ -5293,6 +5363,25 @@ void vtysh_init_vty(void)
install_element(INTERFACE_NODE, &vtysh_exit_interface_cmd); install_element(INTERFACE_NODE, &vtysh_exit_interface_cmd);
install_element(INTERFACE_NODE, &vtysh_quit_interface_cmd); install_element(INTERFACE_NODE, &vtysh_quit_interface_cmd);
/* pimd */
#ifdef HAVE_PIMD
install_node(&pim_node);
install_element(CONFIG_NODE, &router_pim_cmd);
install_element(PIM_NODE, &vtysh_exit_pimd_cmd);
install_element(PIM_NODE, &vtysh_quit_pimd_cmd);
install_element(PIM_NODE, &vtysh_end_all_cmd);
#endif /* HAVE_PIMD */
/* pim6d */
#ifdef HAVE_PIM6D
install_node(&pim6_node);
install_element(CONFIG_NODE, &router_pim6_cmd);
install_element(PIM6_NODE, &vtysh_exit_pim6d_cmd);
install_element(PIM6_NODE, &vtysh_quit_pim6d_cmd);
install_element(PIM6_NODE, &vtysh_end_all_cmd);
#endif /* HAVE_PIM6D */
/* zebra and all, cont. */
install_node(&link_params_node); install_node(&link_params_node);
install_element(INTERFACE_NODE, &vtysh_link_params_cmd); install_element(INTERFACE_NODE, &vtysh_link_params_cmd);
install_element(LINK_PARAMS_NODE, &no_link_params_enable_cmd); install_element(LINK_PARAMS_NODE, &no_link_params_enable_cmd);

View file

@ -497,6 +497,11 @@ void vtysh_config_parse_line(void *arg, const char *line)
config = config_get(BFD_NODE, line); config = config_get(BFD_NODE, line);
else if (strncmp(line, "rpki", strlen("rpki")) == 0) else if (strncmp(line, "rpki", strlen("rpki")) == 0)
config = config_get(RPKI_NODE, line); config = config_get(RPKI_NODE, line);
else if (strncmp(line, "router pim", strlen("router pim")) == 0)
config = config_get(PIM_NODE, line);
else if (strncmp(line, "router pim6", strlen("router pim6")) ==
0)
config = config_get(PIM6_NODE, line);
else { else {
if (strncmp(line, "log", strlen("log")) == 0 || if (strncmp(line, "log", strlen("log")) == 0 ||
strncmp(line, "hostname", strlen("hostname")) == 0 || strncmp(line, "hostname", strlen("hostname")) == 0 ||