summaryrefslogtreecommitdiffstats
path: root/vrrpd
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vrrpd/vrrp.c18
-rw-r--r--vrrpd/vrrp_main.c22
-rw-r--r--vrrpd/vrrp_northbound.c4
-rw-r--r--vrrpd/vrrp_vty.c18
-rw-r--r--vrrpd/vrrp_zebra.c9
5 files changed, 44 insertions, 27 deletions
diff --git a/vrrpd/vrrp.c b/vrrpd/vrrp.c
index b14a6ec..0173879 100644
--- a/vrrpd/vrrp.c
+++ b/vrrpd/vrrp.c
@@ -700,10 +700,9 @@ static int vrrp_bind_to_primary_connected(struct vrrp_router *r)
*/
ifp = r->family == AF_INET ? r->vr->ifp : r->mvl_ifp;
- struct listnode *ln;
struct connected *c = NULL;
- for (ALL_LIST_ELEMENTS_RO(ifp->connected, ln, c))
+ frr_each (if_connected, ifp->connected, c)
if (c->address->family == r->family) {
if (r->family == AF_INET6
&& IN6_IS_ADDR_LINKLOCAL(&c->address->u.prefix6))
@@ -1171,9 +1170,15 @@ static int vrrp_socket(struct vrrp_router *r)
r->vr->vrid, family2str(r->family));
/* Join Rx socket to VRRP IPv4 multicast group */
- assert(listhead(r->vr->ifp->connected));
- struct connected *c = listhead(r->vr->ifp->connected)->data;
- struct in_addr v4 = c->address->u.prefix4;
+ struct connected *c;
+ struct in_addr v4;
+
+ frr_each (if_connected, r->vr->ifp->connected, c)
+ if (c->address->family == AF_INET)
+ break;
+
+ assert(c);
+ v4 = c->address->u.prefix4;
ret = setsockopt_ipv4_multicast(r->sock_rx, IP_ADD_MEMBERSHIP,
v4, htonl(VRRP_MCASTV4_GROUP),
@@ -1703,7 +1708,6 @@ int vrrp_event(struct vrrp_router *r, int event)
*/
static void vrrp_autoconfig_autoaddrupdate(struct vrrp_router *r)
{
- struct listnode *ln;
struct connected *c = NULL;
bool is_v6_ll;
@@ -1714,7 +1718,7 @@ static void vrrp_autoconfig_autoaddrupdate(struct vrrp_router *r)
VRRP_LOGPFX VRRP_LOGPFX_VRID VRRP_LOGPFX_FAM
"Setting Virtual IP list to match IPv4 addresses on %s",
r->vr->vrid, family2str(r->family), r->mvl_ifp->name);
- for (ALL_LIST_ELEMENTS_RO(r->mvl_ifp->connected, ln, c)) {
+ frr_each (if_connected, r->mvl_ifp->connected, c) {
is_v6_ll = (c->address->family == AF_INET6
&& IN6_IS_ADDR_LINKLOCAL(&c->address->u.prefix6));
if (c->address->family == r->family && !is_v6_ll) {
diff --git a/vrrpd/vrrp_main.c b/vrrpd/vrrp_main.c
index 5245c74..e9af3d9 100644
--- a/vrrpd/vrrp_main.c
+++ b/vrrpd/vrrp_main.c
@@ -107,16 +107,20 @@ static const struct frr_yang_module_info *const vrrp_yang_modules[] = {
&frr_vrrpd_info,
};
-#define VRRP_VTY_PORT 2619
-
-FRR_DAEMON_INFO(vrrpd, VRRP, .vty_port = VRRP_VTY_PORT,
- .proghelp = "Virtual Router Redundancy Protocol",
- .signals = vrrp_signals,
- .n_signals = array_size(vrrp_signals),
- .privs = &vrrp_privs,
- .yang_modules = vrrp_yang_modules,
- .n_yang_modules = array_size(vrrp_yang_modules),
+/* clang-format off */
+FRR_DAEMON_INFO(vrrpd, VRRP,
+ .vty_port = VRRP_VTY_PORT,
+ .proghelp = "Virtual Router Redundancy Protocol",
+
+ .signals = vrrp_signals,
+ .n_signals = array_size(vrrp_signals),
+
+ .privs = &vrrp_privs,
+
+ .yang_modules = vrrp_yang_modules,
+ .n_yang_modules = array_size(vrrp_yang_modules),
);
+/* clang-format on */
int main(int argc, char **argv, char **envp)
{
diff --git a/vrrpd/vrrp_northbound.c b/vrrpd/vrrp_northbound.c
index 1f8da4c..2947a41 100644
--- a/vrrpd/vrrp_northbound.c
+++ b/vrrpd/vrrp_northbound.c
@@ -27,8 +27,8 @@ static int lib_interface_vrrp_vrrp_group_create(struct nb_cb_create_args *args)
uint8_t version = 3;
struct vrrp_vrouter *vr;
- vrid = yang_dnode_get_uint8(args->dnode, "./virtual-router-id");
- version = yang_dnode_get_enum(args->dnode, "./version");
+ vrid = yang_dnode_get_uint8(args->dnode, "virtual-router-id");
+ version = yang_dnode_get_enum(args->dnode, "version");
switch (args->event) {
case NB_EV_VALIDATE:
diff --git a/vrrpd/vrrp_vty.c b/vrrpd/vrrp_vty.c
index 9971df5..fd6cbc8 100644
--- a/vrrpd/vrrp_vty.c
+++ b/vrrpd/vrrp_vty.c
@@ -62,11 +62,11 @@ DEFPY_YANG(vrrp_vrid,
void cli_show_vrrp(struct vty *vty, const struct lyd_node *dnode, bool show_defaults)
{
- const char *vrid = yang_dnode_get_string(dnode, "./virtual-router-id");
- const char *ver = yang_dnode_get_string(dnode, "./version");
+ const char *vrid = yang_dnode_get_string(dnode, "virtual-router-id");
+ const char *ver = yang_dnode_get_string(dnode, "version");
vty_out(vty, " vrrp %s", vrid);
- if (show_defaults || !yang_dnode_is_default(dnode, "./version"))
+ if (show_defaults || !yang_dnode_is_default(dnode, "version"))
vty_out(vty, " version %s", ver);
vty_out(vty, "\n");
}
@@ -200,7 +200,11 @@ DEFPY_YANG(vrrp_ip,
VRRP_IP_STR)
{
int op = no ? NB_OP_DESTROY : NB_OP_CREATE;
- nb_cli_enqueue_change(vty, "./v4/virtual-address", op, ip_str);
+ char xpath[XPATH_MAXLEN];
+
+ snprintf(xpath, sizeof(xpath), "./v4/virtual-address[.='%s']", ip_str);
+
+ nb_cli_enqueue_change(vty, xpath, op, NULL);
return nb_cli_apply_changes(vty, VRRP_XPATH_ENTRY, vrid);
}
@@ -228,7 +232,11 @@ DEFPY_YANG(vrrp_ip6,
VRRP_IP_STR)
{
int op = no ? NB_OP_DESTROY : NB_OP_CREATE;
- nb_cli_enqueue_change(vty, "./v6/virtual-address", op, ipv6_str);
+ char xpath[XPATH_MAXLEN];
+
+ snprintf(xpath, sizeof(xpath), "./v6/virtual-address[.='%s']", ipv6_str);
+
+ nb_cli_enqueue_change(vty, xpath, op, NULL);
return nb_cli_apply_changes(vty, VRRP_XPATH_ENTRY, vrid);
}
diff --git a/vrrpd/vrrp_zebra.c b/vrrpd/vrrp_zebra.c
index 6d753d2..009432b 100644
--- a/vrrpd/vrrp_zebra.c
+++ b/vrrpd/vrrp_zebra.c
@@ -36,11 +36,10 @@ static void vrrp_zebra_debug_if_dump_address(struct interface *ifp,
const char *func)
{
struct connected *ifc;
- struct listnode *node;
DEBUGD(&vrrp_dbg_zebra, "%s: interface %s addresses:", func, ifp->name);
- for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) {
+ frr_each (if_connected, ifp->connected, ifc) {
struct prefix *p = ifc->address;
DEBUGD(&vrrp_dbg_zebra, "%s: interface %s address %pFX %s",
@@ -183,8 +182,10 @@ static zclient_handler *const vrrp_handlers[] = {
void vrrp_zebra_init(void)
{
- if_zapi_callbacks(vrrp_ifp_create, vrrp_ifp_up,
- vrrp_ifp_down, vrrp_ifp_destroy);
+ hook_register_prio(if_real, 0, vrrp_ifp_create);
+ hook_register_prio(if_up, 0, vrrp_ifp_up);
+ hook_register_prio(if_down, 0, vrrp_ifp_down);
+ hook_register_prio(if_unreal, 0, vrrp_ifp_destroy);
/* Socket for receiving updates from Zebra daemon */
zclient = zclient_new(master, &zclient_options_default, vrrp_handlers,