From 8b23c0b0bd3470babe8702f54a47bb223f471b14 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 22 Nov 2023 19:05:41 +0100 Subject: *: 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 --- lib/if.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/if.h') diff --git a/lib/if.h b/lib/if.h index e93205758..dd67c32a6 100644 --- a/lib/if.h +++ b/lib/if.h @@ -204,6 +204,8 @@ struct if_link_params { #define INTERFACE_LINK_PARAMS_SIZE sizeof(struct if_link_params) #define HAS_LINK_PARAMS(ifp) ((ifp)->link_params != NULL) +PREDECL_DLIST(if_connected); + /* Interface structure */ struct interface { RB_ENTRY(interface) name_entry, index_entry; @@ -278,7 +280,7 @@ struct interface { void *distribute_out; /* Connected address list. */ - struct list *connected; + struct if_connected_head connected[1]; /* Neighbor connected address list. */ struct list *nbr_connected; @@ -373,9 +375,6 @@ DECLARE_QOBJ_TYPE(interface); if (vrf) \ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) -#define FOR_ALL_INTERFACES_ADDRESSES(ifp, connected, node) \ - for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, connected)) - /* called from the library code whenever interfaces are created/deleted * note: interfaces may not be fully realized at that point; also they * may not exist in the system (ifindex = IFINDEX_INTERNAL) @@ -410,6 +409,8 @@ DECLARE_KOOH(if_down, (struct interface *ifp), (ifp)); /* Connected address structure. */ struct connected { + struct if_connected_item item; + /* Attached interface. */ struct interface *ifp; @@ -459,6 +460,8 @@ struct connected { uint32_t metric; }; +DECLARE_DLIST(if_connected, struct connected, item); + /* Nbr Connected address structure. */ struct nbr_connected { /* Attached interface. */ -- cgit v1.2.3