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 /pimd | |
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 'pimd')
-rw-r--r-- | pimd/pim_hello.c | 2 | ||||
-rw-r--r-- | pimd/pim_iface.c | 25 | ||||
-rw-r--r-- | pimd/pim_igmp_mtrace.c | 3 | ||||
-rw-r--r-- | pimd/pim_pim.c | 15 | ||||
-rw-r--r-- | pimd/pim_tlv.c | 10 | ||||
-rw-r--r-- | pimd/pim_zebra.c | 3 |
6 files changed, 22 insertions, 36 deletions
diff --git a/pimd/pim_hello.c b/pimd/pim_hello.c index 978607d14..a0661ef36 100644 --- a/pimd/pim_hello.c +++ b/pimd/pim_hello.c @@ -440,7 +440,7 @@ int pim_hello_build_tlv(struct interface *ifp, uint8_t *tlv_buf, } /* Secondary Address List */ - if (ifp->connected->count) { + if (if_connected_count(ifp->connected)) { curr = pim_tlv_append_addrlist_ucast(curr, pastend, ifp, PIM_AF); if (!curr) { diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 7151fc6b3..5d7132c09 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -379,7 +379,7 @@ static int pim_sec_addr_update(struct interface *ifp) sec_addr->flags |= PIM_SEC_ADDRF_STALE; } - for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) { + frr_each (if_connected, ifp->connected, ifc) { pim_addr addr = pim_addr_from_prefix(ifc->address); if (pim_addr_is_any(addr)) @@ -723,13 +723,12 @@ void pim_if_addr_del(struct connected *ifc, int force_prim_as_any) if (pim_ifp && (!IPV6_ADDR_CMP(&ifc->address->u.prefix6, &pim_ifp->ll_lowest) || !IPV6_ADDR_CMP(&ifc->address->u.prefix6, &pim_ifp->ll_highest))) { - struct listnode *cnode; struct connected *cc; memset(&pim_ifp->ll_lowest, 0xff, sizeof(pim_ifp->ll_lowest)); memset(&pim_ifp->ll_highest, 0, sizeof(pim_ifp->ll_highest)); - for (ALL_LIST_ELEMENTS_RO(ifc->ifp->connected, cnode, cc)) { + frr_each (if_connected, ifc->ifp->connected, cc) { if (!IN6_IS_ADDR_LINKLOCAL(&cc->address->u.prefix6) && !IN6_IS_ADDR_LOOPBACK(&cc->address->u.prefix6)) continue; @@ -765,8 +764,6 @@ void pim_if_addr_del(struct connected *ifc, int force_prim_as_any) void pim_if_addr_add_all(struct interface *ifp) { struct connected *ifc; - struct listnode *node; - struct listnode *nextnode; int v4_addrs = 0; int v6_addrs = 0; struct pim_interface *pim_ifp = ifp->info; @@ -777,7 +774,7 @@ void pim_if_addr_add_all(struct interface *ifp) if (!pim_ifp) return; - for (ALL_LIST_ELEMENTS(ifp->connected, node, nextnode, ifc)) { + frr_each (if_connected, ifp->connected, ifc) { struct prefix *p = ifc->address; if (p->family != AF_INET) @@ -813,8 +810,6 @@ void pim_if_addr_add_all(struct interface *ifp) void pim_if_addr_del_all(struct interface *ifp) { struct connected *ifc; - struct listnode *node; - struct listnode *nextnode; struct pim_instance *pim; pim = ifp->vrf->info; @@ -825,7 +820,7 @@ void pim_if_addr_del_all(struct interface *ifp) if (!ifp->info) return; - for (ALL_LIST_ELEMENTS(ifp->connected, node, nextnode, ifc)) { + frr_each_safe (if_connected, ifp->connected, ifc) { struct prefix *p = ifc->address; if (p->family != PIM_AF) @@ -841,14 +836,12 @@ void pim_if_addr_del_all(struct interface *ifp) void pim_if_addr_del_all_igmp(struct interface *ifp) { struct connected *ifc; - struct listnode *node; - struct listnode *nextnode; /* PIM/IGMP enabled ? */ if (!ifp->info) return; - for (ALL_LIST_ELEMENTS(ifp->connected, node, nextnode, ifc)) { + frr_each_safe (if_connected, ifp->connected, ifc) { struct prefix *p = ifc->address; if (p->family != AF_INET) @@ -861,7 +854,6 @@ void pim_if_addr_del_all_igmp(struct interface *ifp) pim_addr pim_find_primary_addr(struct interface *ifp) { struct connected *ifc; - struct listnode *node; struct pim_interface *pim_ifp = ifp->info; if (pim_ifp && !pim_addr_is_any(pim_ifp->update_source)) @@ -873,7 +865,7 @@ pim_addr pim_find_primary_addr(struct interface *ifp) pim_addr best_addr = PIMADDR_ANY; - for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) { + frr_each (if_connected, ifp->connected, ifc) { pim_addr addr; if (ifc->address->family != AF_INET6) @@ -892,7 +884,7 @@ pim_addr pim_find_primary_addr(struct interface *ifp) int v6_addrs = 0; struct connected *promote_ifc = NULL; - for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) { + frr_each (if_connected, ifp->connected, ifc) { switch (ifc->address->family) { case AF_INET: v4_addrs++; @@ -1523,7 +1515,6 @@ void pim_if_create_pimreg(struct pim_instance *pim) struct prefix *pim_if_connected_to_source(struct interface *ifp, pim_addr src) { - struct listnode *cnode; struct connected *c; struct prefix p; @@ -1532,7 +1523,7 @@ struct prefix *pim_if_connected_to_source(struct interface *ifp, pim_addr src) pim_addr_to_prefix(&p, src); - for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) { + frr_each (if_connected, ifp->connected, c) { if (c->address->family != PIM_AF) continue; if (prefix_match(c->address, &p)) diff --git a/pimd/pim_igmp_mtrace.c b/pimd/pim_igmp_mtrace.c index 4d3f6022a..309da138d 100644 --- a/pimd/pim_igmp_mtrace.c +++ b/pimd/pim_igmp_mtrace.c @@ -21,7 +21,6 @@ static struct in_addr mtrace_primary_address(struct interface *ifp) { struct connected *ifc; - struct listnode *node; struct in_addr any; struct pim_interface *pim_ifp; @@ -32,7 +31,7 @@ static struct in_addr mtrace_primary_address(struct interface *ifp) any.s_addr = INADDR_ANY; - for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) { + frr_each (if_connected, ifp->connected, ifc) { struct prefix *p = ifc->address; if (p->family != AF_INET) diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c index a4c9178bb..1bc265b13 100644 --- a/pimd/pim_pim.c +++ b/pimd/pim_pim.c @@ -743,14 +743,13 @@ static int hello_send(struct interface *ifp, uint16_t holdtime) pim_ifp = ifp->info; if (PIM_DEBUG_PIM_HELLO) - zlog_debug( - "%s: to %pPA on %s: holdt=%u prop_d=%u overr_i=%u dis_join_supp=%d dr_prio=%u gen_id=%08x addrs=%d", - __func__, &qpim_all_pim_routers_addr, ifp->name, - holdtime, pim_ifp->pim_propagation_delay_msec, - pim_ifp->pim_override_interval_msec, - pim_ifp->pim_can_disable_join_suppression, - pim_ifp->pim_dr_priority, pim_ifp->pim_generation_id, - listcount(ifp->connected)); + zlog_debug("%s: to %pPA on %s: holdt=%u prop_d=%u overr_i=%u dis_join_supp=%d dr_prio=%u gen_id=%08x addrs=%zu", + __func__, &qpim_all_pim_routers_addr, ifp->name, + holdtime, pim_ifp->pim_propagation_delay_msec, + pim_ifp->pim_override_interval_msec, + pim_ifp->pim_can_disable_join_suppression, + pim_ifp->pim_dr_priority, pim_ifp->pim_generation_id, + if_connected_count(ifp->connected)); pim_tlv_size = pim_hello_build_tlv( ifp, pim_msg + PIM_PIM_MIN_LEN, diff --git a/pimd/pim_tlv.c b/pimd/pim_tlv.c index 80d60b862..c463fa227 100644 --- a/pimd/pim_tlv.c +++ b/pimd/pim_tlv.c @@ -217,18 +217,17 @@ int pim_encode_addr_group(uint8_t *buf, afi_t afi, int bidir, int scope, uint8_t *pim_tlv_append_addrlist_ucast(uint8_t *buf, const uint8_t *buf_pastend, struct interface *ifp, int family) { - struct listnode *node; uint16_t option_len = 0; uint8_t *curr; size_t uel; - struct list *ifconnected = ifp->connected; + struct connected *ifc; struct pim_interface *pim_ifp = ifp->info; pim_addr addr; - node = listhead(ifconnected); + ifc = if_connected_first(ifp->connected); /* Empty address list ? */ - if (!node) { + if (!ifc) { return buf; } @@ -239,8 +238,7 @@ uint8_t *pim_tlv_append_addrlist_ucast(uint8_t *buf, const uint8_t *buf_pastend, /* Scan secondary address list */ curr = buf + 4; /* skip T and L */ - for (; node; node = listnextnode(node)) { - struct connected *ifc = listgetdata(node); + for (; ifc; ifc = if_connected_next(ifp->connected, ifc)) { struct prefix *p = ifc->address; int l_encode; diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index 73c9df8f8..1da308426 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -55,12 +55,11 @@ static int pim_router_id_update_zebra(ZAPI_CALLBACK_ARGS) static void dump_if_address(struct interface *ifp) { struct connected *ifc; - struct listnode *node; zlog_debug("%s %s: interface %s addresses:", __FILE__, __func__, ifp->name); - for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) { + frr_each (if_connected, ifp->connected, ifc) { struct prefix *p = ifc->address; if (p->family != AF_INET) |