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 /ripd | |
| parent | af22ff0bd5c5340ca377a7c727057465e7e16bb9 (diff) | |
*: 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 'ripd')
| -rw-r--r-- | ripd/rip_interface.c | 22 | ||||
| -rw-r--r-- | ripd/ripd.c | 18 |
2 files changed, 14 insertions, 26 deletions
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 93494549cc..65afce8cb7 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -128,14 +128,12 @@ static void rip_request_interface_send(struct interface *ifp, uint8_t version) /* RIPv1 and non multicast interface. */ if (if_is_pointopoint(ifp) || if_is_broadcast(ifp)) { - struct listnode *cnode, *cnnode; struct connected *connected; if (IS_RIP_DEBUG_EVENT) zlog_debug("broadcast request to %s", ifp->name); - for (ALL_LIST_ELEMENTS(ifp->connected, cnode, cnnode, - connected)) { + frr_each (if_connected, ifp->connected, connected) { if (connected->address->family != AF_INET) continue; @@ -197,14 +195,13 @@ static void rip_request_interface(struct interface *ifp) /* Multicast packet receive socket. */ static int rip_multicast_join(struct interface *ifp, int sock) { - struct listnode *cnode; struct connected *ifc; if (if_is_operative(ifp) && if_is_multicast(ifp)) { if (IS_RIP_DEBUG_EVENT) zlog_debug("multicast join at %s", ifp->name); - for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, ifc)) { + frr_each (if_connected, ifp->connected, ifc) { struct prefix_ipv4 *p; struct in_addr group; @@ -228,14 +225,13 @@ static int rip_multicast_join(struct interface *ifp, int sock) /* Leave from multicast group. */ static void rip_multicast_leave(struct interface *ifp, int sock) { - struct listnode *cnode; struct connected *connected; if (if_is_up(ifp) && if_is_multicast(ifp)) { if (IS_RIP_DEBUG_EVENT) zlog_debug("multicast leave from %s", ifp->name); - for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) { + frr_each (if_connected, ifp->connected, connected) { struct prefix_ipv4 *p; struct in_addr group; @@ -256,11 +252,10 @@ static void rip_multicast_leave(struct interface *ifp, int sock) /* Is there and address on interface that I could use ? */ static int rip_if_ipv4_address_check(struct interface *ifp) { - struct listnode *nn; struct connected *connected; int count = 0; - for (ALL_LIST_ELEMENTS_RO(ifp->connected, nn, connected)) { + frr_each (if_connected, ifp->connected, connected) { struct prefix *p; p = connected->address; @@ -279,10 +274,9 @@ int if_check_address(struct rip *rip, struct in_addr addr) struct interface *ifp; FOR_ALL_INTERFACES (rip->vrf, ifp) { - struct listnode *cnode; struct connected *connected; - for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) { + frr_each (if_connected, ifp->connected, connected) { struct prefix_ipv4 *p; p = (struct prefix_ipv4 *)connected->address; @@ -596,14 +590,13 @@ static int rip_enable_network_lookup_if(struct interface *ifp) { struct rip_interface *ri = ifp->info; struct rip *rip = ri->rip; - struct listnode *node, *nnode; struct connected *connected; struct prefix_ipv4 address; if (!rip) return -1; - for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, connected)) { + frr_each (if_connected, ifp->connected, connected) { struct prefix *p; struct route_node *n; @@ -780,14 +773,13 @@ static void rip_connect_set(struct interface *ifp, int set) { struct rip_interface *ri = ifp->info; struct rip *rip = ri->rip; - struct listnode *node, *nnode; struct connected *connected; struct prefix_ipv4 address; struct nexthop nh; memset(&nh, 0, sizeof(nh)); - for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, connected)) { + frr_each (if_connected, ifp->connected, connected) { struct prefix *p; p = connected->address; diff --git a/ripd/ripd.c b/ripd/ripd.c index f197e389b2..a94dd96da0 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -404,7 +404,6 @@ static int rip_filter(int rip_distribute, struct prefix_ipv4 *p, static int rip_nexthop_check(struct rip *rip, struct in_addr *addr) { struct interface *ifp; - struct listnode *cnode; struct connected *ifc; struct prefix *p; @@ -412,7 +411,7 @@ static int rip_nexthop_check(struct rip *rip, struct in_addr *addr) invalid nexthop. */ FOR_ALL_INTERFACES (rip->vrf, ifp) { - for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, ifc)) { + frr_each (if_connected, ifp->connected, ifc) { p = ifc->address; if (p->family == AF_INET @@ -2213,8 +2212,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to, } if (!suppress && rinfo->type == ZEBRA_ROUTE_CONNECT) { - for (ALL_LIST_ELEMENTS_RO(ifc->ifp->connected, - listnode, tmp_ifc)) + frr_each (if_connected, ifc->ifp->connected, + tmp_ifc) if (prefix_match((struct prefix *)p, tmp_ifc->address)) { suppress = 1; @@ -2323,8 +2322,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to, if (rinfo->metric_out != RIP_METRIC_INFINITY && rinfo->type == ZEBRA_ROUTE_CONNECT) { - for (ALL_LIST_ELEMENTS_RO(ifc->ifp->connected, - listnode, tmp_ifc)) + frr_each (if_connected, ifc->ifp->connected, + tmp_ifc) if (prefix_match((struct prefix *)p, tmp_ifc->address)) { rinfo->metric_out = @@ -2437,7 +2436,6 @@ static void rip_update_interface(struct connected *ifc, uint8_t version, /* Update send to all interface and neighbor. */ static void rip_update_process(struct rip *rip, int route_type) { - struct listnode *ifnode, *ifnnode; struct connected *connected; struct interface *ifp; struct rip_interface *ri; @@ -2476,8 +2474,7 @@ static void rip_update_process(struct rip *rip, int route_type) ifp->ifindex); /* send update on each connected network */ - for (ALL_LIST_ELEMENTS(ifp->connected, ifnode, ifnnode, - connected)) { + frr_each (if_connected, ifp->connected, connected) { if (connected->address->family == AF_INET) { if (vsend & RIPv1) rip_update_interface(connected, RIPv1, @@ -2768,7 +2765,6 @@ int rip_request_send(struct sockaddr_in *to, struct interface *ifp, { struct rte *rte; struct rip_packet rip_packet; - struct listnode *node, *nnode; memset(&rip_packet, 0, sizeof(rip_packet)); @@ -2792,7 +2788,7 @@ int rip_request_send(struct sockaddr_in *to, struct interface *ifp, } /* send request on each connected network */ - for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, connected)) { + frr_each (if_connected, ifp->connected, connected) { struct prefix_ipv4 *p; p = (struct prefix_ipv4 *)connected->address; |
