mirror of
https://git.proxmox.com/git/mirror_frr
synced 2026-01-25 01:03:34 +00:00
pimd: Northbound implementation for mlag, register-accept-list commands
pim_register_accept_list
ip_pim_mlag
no_ip_pim_mlag
Yang Model:
augment /frr-routing:routing/frr-routing:control-plane-protocols/frr-routing:control-plane-protocol:
+--rw pim
+--rw address-family* [address-family]
+--rw address-family identityref
+--rw mlag!
| +--rw peerlink-rif? frr-interface:interface-ref
| +--rw reg-address? ietf-inet-types:ip-address
| +--rw my-role? enumeration <MLAG_ROLE_NONE>
| +--rw peer-state? boolean <false>
+--rw register-accept-list? plist-ref
Signed-off-by: Sarita Patra <saritap@vmware.com>
This commit is contained in:
parent
cf740d2e72
commit
0c949724d3
122
pimd/pim_cmd.c
122
pimd/pim_cmd.c
@ -6946,15 +6946,37 @@ DEFPY (pim_register_accept_list,
|
||||
"Only accept registers from a specific source prefix list\n"
|
||||
"Prefix-List name\n")
|
||||
{
|
||||
PIM_DECLVAR_CONTEXT(vrf, pim);
|
||||
const struct lyd_node *vrf_dnode;
|
||||
const char *vrfname;
|
||||
char reg_alist_xpath[XPATH_MAXLEN];
|
||||
|
||||
if (vty->xpath_index) {
|
||||
vrf_dnode =
|
||||
yang_dnode_get(vty->candidate_config->dnode,
|
||||
VTY_CURR_XPATH);
|
||||
if (!vrf_dnode) {
|
||||
vty_out(vty,
|
||||
"%% Failed to get vrf dnode in candidate db\n");
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
}
|
||||
vrfname = yang_dnode_get_string(vrf_dnode, "./name");
|
||||
} else
|
||||
vrfname = VRF_DEFAULT_NAME;
|
||||
|
||||
snprintf(reg_alist_xpath, sizeof(reg_alist_xpath),
|
||||
FRR_PIM_AF_XPATH, "frr-pim:pimd", "pim", vrfname,
|
||||
"frr-routing:ipv4");
|
||||
strlcat(reg_alist_xpath, "/register-accept-list",
|
||||
sizeof(reg_alist_xpath));
|
||||
|
||||
if (no)
|
||||
XFREE(MTYPE_PIM_PLIST_NAME, pim->register_plist);
|
||||
else {
|
||||
XFREE(MTYPE_PIM_PLIST_NAME, pim->register_plist);
|
||||
pim->register_plist = XSTRDUP(MTYPE_PIM_PLIST_NAME, word);
|
||||
}
|
||||
return CMD_SUCCESS;
|
||||
nb_cli_enqueue_change(vty, reg_alist_xpath,
|
||||
NB_OP_DESTROY, NULL);
|
||||
else
|
||||
nb_cli_enqueue_change(vty, reg_alist_xpath,
|
||||
NB_OP_MODIFY, word);
|
||||
|
||||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
DEFUN (ip_pim_joinprune_time,
|
||||
@ -10976,14 +10998,16 @@ DEFUN_HIDDEN (no_ip_pim_mlag,
|
||||
PIM_STR
|
||||
"MLAG\n")
|
||||
{
|
||||
struct in_addr addr;
|
||||
char mlag_xpath[XPATH_MAXLEN];
|
||||
|
||||
addr.s_addr = 0;
|
||||
pim_vxlan_mlag_update(true/*mlag_enable*/,
|
||||
false/*peer_state*/, MLAG_ROLE_NONE,
|
||||
NULL/*peerlink*/, &addr);
|
||||
snprintf(mlag_xpath, sizeof(mlag_xpath), FRR_PIM_AF_XPATH,
|
||||
"frr-pim:pimd", "pim", "default", "frr-routing:ipv4");
|
||||
strlcat(mlag_xpath, "/mlag", sizeof(mlag_xpath));
|
||||
|
||||
return CMD_SUCCESS;
|
||||
nb_cli_enqueue_change(vty, mlag_xpath, NB_OP_DESTROY, NULL);
|
||||
|
||||
|
||||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
DEFUN_HIDDEN (ip_pim_mlag,
|
||||
@ -11002,53 +11026,73 @@ DEFUN_HIDDEN (ip_pim_mlag,
|
||||
"configure PIP\n"
|
||||
"unique ip address\n")
|
||||
{
|
||||
struct interface *ifp;
|
||||
const char *peerlink;
|
||||
uint32_t role;
|
||||
int idx;
|
||||
bool peer_state;
|
||||
int result;
|
||||
struct in_addr reg_addr;
|
||||
char mlag_peerlink_rif_xpath[XPATH_MAXLEN];
|
||||
char mlag_my_role_xpath[XPATH_MAXLEN];
|
||||
char mlag_peer_state_xpath[XPATH_MAXLEN];
|
||||
char mlag_reg_address_xpath[XPATH_MAXLEN];
|
||||
|
||||
snprintf(mlag_peerlink_rif_xpath, sizeof(mlag_peerlink_rif_xpath),
|
||||
FRR_PIM_AF_XPATH,
|
||||
"frr-pim:pimd", "pim", "default", "frr-routing:ipv4");
|
||||
strlcat(mlag_peerlink_rif_xpath, "/mlag/peerlink-rif",
|
||||
sizeof(mlag_peerlink_rif_xpath));
|
||||
|
||||
idx = 3;
|
||||
peerlink = argv[idx]->arg;
|
||||
ifp = if_lookup_by_name(peerlink, VRF_DEFAULT);
|
||||
if (!ifp) {
|
||||
vty_out(vty, "No such interface name %s\n", peerlink);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
nb_cli_enqueue_change(vty, mlag_peerlink_rif_xpath, NB_OP_MODIFY,
|
||||
argv[idx]->arg);
|
||||
|
||||
snprintf(mlag_my_role_xpath, sizeof(mlag_my_role_xpath),
|
||||
FRR_PIM_AF_XPATH,
|
||||
"frr-pim:pimd", "pim", "default", "frr-routing:ipv4");
|
||||
strlcat(mlag_my_role_xpath, "/mlag/my-role",
|
||||
sizeof(mlag_my_role_xpath));
|
||||
|
||||
idx += 2;
|
||||
if (!strcmp(argv[idx]->arg, "primary")) {
|
||||
role = MLAG_ROLE_PRIMARY;
|
||||
nb_cli_enqueue_change(vty, mlag_my_role_xpath, NB_OP_MODIFY,
|
||||
"MLAG_ROLE_PRIMARY");
|
||||
|
||||
} else if (!strcmp(argv[idx]->arg, "secondary")) {
|
||||
role = MLAG_ROLE_SECONDARY;
|
||||
nb_cli_enqueue_change(vty, mlag_my_role_xpath, NB_OP_MODIFY,
|
||||
"MLAG_ROLE_SECONDARY");
|
||||
|
||||
} else {
|
||||
vty_out(vty, "unknown MLAG role %s\n", argv[idx]->arg);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
snprintf(mlag_peer_state_xpath, sizeof(mlag_peer_state_xpath),
|
||||
FRR_PIM_AF_XPATH,
|
||||
"frr-pim:pimd", "pim", "default", "frr-routing:ipv4");
|
||||
strlcat(mlag_peer_state_xpath, "/mlag/peer-state",
|
||||
sizeof(mlag_peer_state_xpath));
|
||||
|
||||
idx += 2;
|
||||
if (!strcmp(argv[idx]->arg, "up")) {
|
||||
peer_state = true;
|
||||
nb_cli_enqueue_change(vty, mlag_peer_state_xpath, NB_OP_MODIFY,
|
||||
"true");
|
||||
|
||||
} else if (strcmp(argv[idx]->arg, "down")) {
|
||||
peer_state = false;
|
||||
nb_cli_enqueue_change(vty, mlag_peer_state_xpath, NB_OP_MODIFY,
|
||||
"false");
|
||||
|
||||
} else {
|
||||
vty_out(vty, "unknown MLAG state %s\n", argv[idx]->arg);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
idx += 2;
|
||||
result = inet_pton(AF_INET, argv[idx]->arg, ®_addr);
|
||||
if (result <= 0) {
|
||||
vty_out(vty, "%% Bad reg address %s: errno=%d: %s\n",
|
||||
argv[idx]->arg,
|
||||
errno, safe_strerror(errno));
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
}
|
||||
pim_vxlan_mlag_update(true, peer_state, role, ifp, ®_addr);
|
||||
snprintf(mlag_reg_address_xpath, sizeof(mlag_reg_address_xpath),
|
||||
FRR_PIM_AF_XPATH,
|
||||
"frr-pim:pimd", "pim", "default", "frr-routing:ipv4");
|
||||
strlcat(mlag_reg_address_xpath, "/mlag/reg-address",
|
||||
sizeof(mlag_reg_address_xpath));
|
||||
|
||||
return CMD_SUCCESS;
|
||||
idx += 2;
|
||||
nb_cli_enqueue_change(vty, mlag_reg_address_xpath, NB_OP_MODIFY,
|
||||
argv[idx]->arg);
|
||||
|
||||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
void pim_cmd_init(void)
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#include "pim_static.h"
|
||||
#include "pim_ssm.h"
|
||||
#include "pim_ssmpingd.h"
|
||||
#include "pim_vxlan.h"
|
||||
|
||||
static void pim_if_membership_clear(struct interface *ifp)
|
||||
{
|
||||
@ -1404,7 +1405,6 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_ml
|
||||
case NB_EV_PREPARE:
|
||||
case NB_EV_ABORT:
|
||||
case NB_EV_APPLY:
|
||||
/* TODO: implement me. */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1413,18 +1413,52 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_ml
|
||||
|
||||
int routing_control_plane_protocols_control_plane_protocol_pim_address_family_mlag_destroy(struct nb_cb_destroy_args *args)
|
||||
{
|
||||
struct in_addr addr;
|
||||
|
||||
switch (args->event) {
|
||||
case NB_EV_VALIDATE:
|
||||
case NB_EV_PREPARE:
|
||||
case NB_EV_ABORT:
|
||||
case NB_EV_APPLY:
|
||||
/* TODO: implement me. */
|
||||
break;
|
||||
case NB_EV_APPLY:
|
||||
addr.s_addr = 0;
|
||||
pim_vxlan_mlag_update(true/*mlag_enable*/,
|
||||
false/*peer_state*/, MLAG_ROLE_NONE,
|
||||
NULL/*peerlink*/, &addr);
|
||||
}
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath:
|
||||
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-pim:pim/address-family/mlag
|
||||
*/
|
||||
void routing_control_plane_protocols_control_plane_protocol_pim_address_family_mlag_apply_finish(
|
||||
struct nb_cb_apply_finish_args *args)
|
||||
{
|
||||
const char *ifname;
|
||||
uint32_t role;
|
||||
bool peer_state;
|
||||
struct interface *ifp;
|
||||
struct ipaddr reg_addr;
|
||||
|
||||
ifname = yang_dnode_get_string(args->dnode, "./peerlink-rif");
|
||||
ifp = if_lookup_by_name(ifname, VRF_DEFAULT);
|
||||
if (!ifp) {
|
||||
snprintf(args->errmsg, args->errmsg_len,
|
||||
"No such interface name %s", ifname);
|
||||
return;
|
||||
}
|
||||
role = yang_dnode_get_enum(args->dnode, "./my-role");
|
||||
peer_state = yang_dnode_get_bool(args->dnode, "./peer-state");
|
||||
yang_dnode_get_ip(®_addr, args->dnode, "./reg-address");
|
||||
|
||||
pim_vxlan_mlag_update(true, peer_state, role, ifp,
|
||||
®_addr.ip._v4_addr);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* XPath: /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-pim:pim/address-family/mlag/peerlink-rif
|
||||
*/
|
||||
@ -1435,7 +1469,6 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_ml
|
||||
case NB_EV_PREPARE:
|
||||
case NB_EV_ABORT:
|
||||
case NB_EV_APPLY:
|
||||
/* TODO: implement me. */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1449,7 +1482,6 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_ml
|
||||
case NB_EV_PREPARE:
|
||||
case NB_EV_ABORT:
|
||||
case NB_EV_APPLY:
|
||||
/* TODO: implement me. */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1466,7 +1498,6 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_ml
|
||||
case NB_EV_PREPARE:
|
||||
case NB_EV_ABORT:
|
||||
case NB_EV_APPLY:
|
||||
/* TODO: implement me. */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1480,7 +1511,6 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_ml
|
||||
case NB_EV_PREPARE:
|
||||
case NB_EV_ABORT:
|
||||
case NB_EV_APPLY:
|
||||
/* TODO: implement me. */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1497,7 +1527,6 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_ml
|
||||
case NB_EV_PREPARE:
|
||||
case NB_EV_ABORT:
|
||||
case NB_EV_APPLY:
|
||||
/* TODO: implement me. */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1514,7 +1543,6 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_ml
|
||||
case NB_EV_PREPARE:
|
||||
case NB_EV_ABORT:
|
||||
case NB_EV_APPLY:
|
||||
/* TODO: implement me. */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1526,26 +1554,44 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_ml
|
||||
*/
|
||||
int routing_control_plane_protocols_control_plane_protocol_pim_address_family_register_accept_list_modify(struct nb_cb_modify_args *args)
|
||||
{
|
||||
struct vrf *vrf;
|
||||
struct pim_instance *pim;
|
||||
const char *plist;
|
||||
|
||||
switch (args->event) {
|
||||
case NB_EV_VALIDATE:
|
||||
case NB_EV_PREPARE:
|
||||
case NB_EV_ABORT:
|
||||
case NB_EV_APPLY:
|
||||
/* TODO: implement me. */
|
||||
break;
|
||||
}
|
||||
case NB_EV_PREPARE:
|
||||
case NB_EV_ABORT:
|
||||
break;
|
||||
case NB_EV_APPLY:
|
||||
vrf = nb_running_get_entry(args->dnode, NULL, true);
|
||||
pim = vrf->info;
|
||||
plist = yang_dnode_get_string(args->dnode, NULL);
|
||||
|
||||
return NB_OK;
|
||||
XFREE(MTYPE_PIM_PLIST_NAME, pim->register_plist);
|
||||
pim->register_plist = XSTRDUP(MTYPE_PIM_PLIST_NAME, plist);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
int routing_control_plane_protocols_control_plane_protocol_pim_address_family_register_accept_list_destroy(struct nb_cb_destroy_args *args)
|
||||
{
|
||||
struct vrf *vrf;
|
||||
struct pim_instance *pim;
|
||||
|
||||
switch (args->event) {
|
||||
case NB_EV_VALIDATE:
|
||||
case NB_EV_PREPARE:
|
||||
case NB_EV_ABORT:
|
||||
break;
|
||||
case NB_EV_APPLY:
|
||||
/* TODO: implement me. */
|
||||
vrf = nb_running_get_entry(args->dnode, NULL, true);
|
||||
pim = vrf->info;
|
||||
|
||||
XFREE(MTYPE_PIM_PLIST_NAME, pim->register_plist);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user