mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 07:37:29 +00:00
vrrpd: add support for configuration writing
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
fc278f75f7
commit
f828842a69
@ -149,6 +149,7 @@ const char *node_names[] = {
|
|||||||
"bfd", /* BFD_NODE */
|
"bfd", /* BFD_NODE */
|
||||||
"bfd peer", /* BFD_PEER_NODE */
|
"bfd peer", /* BFD_PEER_NODE */
|
||||||
"openfabric", // OPENFABRIC_NODE
|
"openfabric", // OPENFABRIC_NODE
|
||||||
|
"vrrp", // VRRP_NODE
|
||||||
};
|
};
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
|
@ -147,6 +147,7 @@ enum node_type {
|
|||||||
BFD_NODE, /* BFD protocol mode. */
|
BFD_NODE, /* BFD protocol mode. */
|
||||||
BFD_PEER_NODE, /* BFD peer configuration mode. */
|
BFD_PEER_NODE, /* BFD peer configuration mode. */
|
||||||
OPENFABRIC_NODE, /* OpenFabric router configuration node */
|
OPENFABRIC_NODE, /* OpenFabric router configuration node */
|
||||||
|
VRRP_NODE, /* VRRP node */
|
||||||
NODE_TYPE_MAX, /* maximum */
|
NODE_TYPE_MAX, /* maximum */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
64
vrrpd/vrrp.c
64
vrrpd/vrrp.c
@ -29,6 +29,7 @@
|
|||||||
#include "lib/sockopt.h"
|
#include "lib/sockopt.h"
|
||||||
#include "lib/sockunion.h"
|
#include "lib/sockunion.h"
|
||||||
#include "lib/vrf.h"
|
#include "lib/vrf.h"
|
||||||
|
#include "lib/vty.h"
|
||||||
|
|
||||||
#include "vrrp.h"
|
#include "vrrp.h"
|
||||||
#include "vrrp_arp.h"
|
#include "vrrp_arp.h"
|
||||||
@ -1609,6 +1610,69 @@ void vrrp_autoconfig_off(void)
|
|||||||
|
|
||||||
/* Other ------------------------------------------------------------------- */
|
/* Other ------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int vrrp_config_write_interface(struct vty *vty)
|
||||||
|
{
|
||||||
|
struct list *vrs = hash_to_list(vrrp_vrouters_hash);
|
||||||
|
struct listnode *ln;
|
||||||
|
struct vrrp_vrouter *vr;
|
||||||
|
int writes = 0;
|
||||||
|
|
||||||
|
for (ALL_LIST_ELEMENTS_RO(vrs, ln, vr)) {
|
||||||
|
vty_frame(vty, "interface %s\n", vr->ifp->name);
|
||||||
|
++writes;
|
||||||
|
|
||||||
|
vty_out(vty, " vrrp %" PRIu8 "%s\n", vr->vrid,
|
||||||
|
vr->version == 2 ? " version 2" : "");
|
||||||
|
++writes;
|
||||||
|
|
||||||
|
if (!vr->preempt_mode && ++writes)
|
||||||
|
vty_out(vty, " no vrrp %" PRIu8 " preempt\n", vr->vrid);
|
||||||
|
|
||||||
|
if (vr->accept_mode && ++writes)
|
||||||
|
vty_out(vty, " vrrp %" PRIu8 " accept\n", vr->vrid);
|
||||||
|
|
||||||
|
if (vr->advertisement_interval != VRRP_DEFAULT_ADVINT
|
||||||
|
&& ++writes)
|
||||||
|
vty_out(vty,
|
||||||
|
" vrrp %" PRIu8
|
||||||
|
" advertisement-interval %" PRIu16 "\n",
|
||||||
|
vr->vrid, vr->advertisement_interval);
|
||||||
|
|
||||||
|
if (vr->priority != VRRP_DEFAULT_PRIORITY && ++writes)
|
||||||
|
vty_out(vty, " vrrp %" PRIu8 " priority %" PRIu8 "\n",
|
||||||
|
vr->vrid, vr->priority);
|
||||||
|
|
||||||
|
ln = NULL;
|
||||||
|
struct ipaddr *ip;
|
||||||
|
|
||||||
|
for (ALL_LIST_ELEMENTS_RO(vr->v4->addrs, ln, ip)) {
|
||||||
|
char ipbuf[INET6_ADDRSTRLEN];
|
||||||
|
ipaddr2str(ip, ipbuf, sizeof(ipbuf));
|
||||||
|
vty_out(vty, " vrrp %" PRIu8 " ip %s\n", vr->vrid,
|
||||||
|
ipbuf);
|
||||||
|
++writes;
|
||||||
|
}
|
||||||
|
for (ALL_LIST_ELEMENTS_RO(vr->v6->addrs, ln, ip)) {
|
||||||
|
char ipbuf[INET6_ADDRSTRLEN];
|
||||||
|
ipaddr2str(ip, ipbuf, sizeof(ipbuf));
|
||||||
|
vty_out(vty, " vrrp %" PRIu8 " ipv6 %s\n", vr->vrid,
|
||||||
|
ipbuf);
|
||||||
|
++writes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return writes;
|
||||||
|
}
|
||||||
|
|
||||||
|
int vrrp_config_write_global(struct vty *vty)
|
||||||
|
{
|
||||||
|
if (vrrp_autoconfig_is_on)
|
||||||
|
vty_out(vty, "vrrp autoconfigure%s\n",
|
||||||
|
vrrp_autoconfig_version == 2 ? " version 2" : "");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned int vrrp_hash_key(void *arg)
|
static unsigned int vrrp_hash_key(void *arg)
|
||||||
{
|
{
|
||||||
struct vrrp_vrouter *vr = arg;
|
struct vrrp_vrouter *vr = arg;
|
||||||
|
23
vrrpd/vrrp.h
23
vrrpd/vrrp.h
@ -30,6 +30,7 @@
|
|||||||
#include "lib/privs.h"
|
#include "lib/privs.h"
|
||||||
#include "lib/stream.h"
|
#include "lib/stream.h"
|
||||||
#include "lib/thread.h"
|
#include "lib/thread.h"
|
||||||
|
#include "lib/vty.h"
|
||||||
|
|
||||||
/* Global definitions */
|
/* Global definitions */
|
||||||
#define VRRP_DEFAULT_ADVINT 100
|
#define VRRP_DEFAULT_ADVINT 100
|
||||||
@ -558,6 +559,28 @@ int vrrp_autoconfig_if_address_del(struct interface *ifp);
|
|||||||
|
|
||||||
/* Other ------------------------------------------------------------------- */
|
/* Other ------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Write interface block-level configuration to vty.
|
||||||
|
*
|
||||||
|
* vty
|
||||||
|
* vty to write config to
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* # of lines written
|
||||||
|
*/
|
||||||
|
int vrrp_config_write_interface(struct vty *vty);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Write global level configuration to vty.
|
||||||
|
*
|
||||||
|
* vty
|
||||||
|
* vty to write config to
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* # of lines written
|
||||||
|
*/
|
||||||
|
int vrrp_config_write_global(struct vty *vty);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find VRRP Virtual Router by Virtual Router ID
|
* Find VRRP Virtual Router by Virtual Router ID
|
||||||
*/
|
*/
|
||||||
|
@ -89,7 +89,7 @@ static int vrrp_debug_config_write_helper(struct vty *vty, bool config)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vrrp_debug_config_write(struct vty *vty)
|
int vrrp_config_write_debug(struct vty *vty)
|
||||||
{
|
{
|
||||||
return vrrp_debug_config_write_helper(vty, true);
|
return vrrp_debug_config_write_helper(vty, true);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ void vrrp_debug_init(void);
|
|||||||
* vty
|
* vty
|
||||||
* VTY to print debugging configuration to.
|
* VTY to print debugging configuration to.
|
||||||
*/
|
*/
|
||||||
int vrrp_debug_config_write(struct vty *vty);
|
int vrrp_config_write_debug(struct vty *vty);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print VRRP debugging configuration, human readable form.
|
* Print VRRP debugging configuration, human readable form.
|
||||||
|
@ -416,17 +416,15 @@ DEFUN_NOSH (show_debugging_vrrp,
|
|||||||
|
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
static struct cmd_node interface_node = {
|
static struct cmd_node interface_node = {INTERFACE_NODE, "%s(config-if)# ", 1};
|
||||||
INTERFACE_NODE,
|
|
||||||
"%s(config-if)# ", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct cmd_node debug_node = {DEBUG_NODE, "", 1};
|
static struct cmd_node debug_node = {DEBUG_NODE, "", 1};
|
||||||
|
static struct cmd_node vrrp_node = {VRRP_NODE, "", 1};
|
||||||
|
|
||||||
void vrrp_vty_init(void)
|
void vrrp_vty_init(void)
|
||||||
{
|
{
|
||||||
install_node(&debug_node, vrrp_debug_config_write);
|
install_node(&debug_node, vrrp_config_write_debug);
|
||||||
install_node(&interface_node, NULL);
|
install_node(&interface_node, vrrp_config_write_interface);
|
||||||
|
install_node(&vrrp_node, vrrp_config_write_global);
|
||||||
if_cmd_init();
|
if_cmd_init();
|
||||||
|
|
||||||
install_element(VIEW_NODE, &vrrp_vrid_show_cmd);
|
install_element(VIEW_NODE, &vrrp_vrid_show_cmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user