diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2023-11-22 19:05:41 +0100 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2023-11-22 23:00:30 +0100 |
commit | 8b23c0b0bd3470babe8702f54a47bb223f471b14 (patch) | |
tree | 07e92fbef506de160930385036fd69901b59e6a6 /vrrpd | |
parent | Merge pull request #14830 from fdumontet6WIND/snmpv2 (diff) | |
download | frr-8b23c0b0bd3470babe8702f54a47bb223f471b14.tar.xz frr-8b23c0b0bd3470babe8702f54a47bb223f471b14.zip |
*: convert `struct interface->connected` to DLIST
Replace `struct list *` with `DLIST(if_connected, ...)`.
NB: while converting this, I found multiple places using connected
prefixes assuming they were IPv4 without checking:
- vrrpd/vrrp.c: vrrp_socket()
- zebra/irdp_interface.c: irdp_get_prefix(), irdp_if_start(),
irdp_advert_off()
(these fixes are really hard to split off into separate commits as that
would require going back and reapplying the change but with the old list
handling)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'vrrpd')
-rw-r--r-- | vrrpd/vrrp.c | 18 | ||||
-rw-r--r-- | vrrpd/vrrp_zebra.c | 3 |
2 files changed, 12 insertions, 9 deletions
diff --git a/vrrpd/vrrp.c b/vrrpd/vrrp.c index b14a6ecc4..017387924 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_zebra.c b/vrrpd/vrrp_zebra.c index 10394752e..009432b21 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", |