Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: convert struct interface->connected to DLIST #14863

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ FixNamespaceComments: false
ForEachMacros:
# lib: outliers:
- 'FOR_ALL_INTERFACES'
- 'FOR_ALL_INTERFACES_ADDRESSES'
# libyang outliers:
- 'LY_FOR_KEYS'
- 'LY_LIST_FOR'
Expand Down
3 changes: 1 addition & 2 deletions babeld/babel_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,12 +739,11 @@ int
is_interface_ll_address(struct interface *ifp, const unsigned char *address)
{
struct connected *connected;
struct listnode *node;

if(!if_up(ifp))
return 0;

FOR_ALL_INTERFACES_ADDRESSES(ifp, connected, node) {
frr_each (if_connected, ifp->connected, connected) {
if (connected->address->family == AF_INET6
&& memcmp(&connected->address->u.prefix6, address,
IPV6_MAX_BYTELEN)
Expand Down
1 change: 0 additions & 1 deletion babeld/babel_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ static inline int
if_up(struct interface *ifp)
{
return (if_is_operative(ifp) &&
ifp->connected != NULL &&
CHECK_FLAG(babel_get_if_nfo(ifp)->flags, BABEL_IF_IS_UP));
}

Expand Down
3 changes: 1 addition & 2 deletions bgpd/bgp_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,6 @@ int bgp_update_address(struct interface *ifp, const union sockunion *dst,
{
struct prefix *p, *sel, d;
struct connected *connected;
struct listnode *node;
int common;

if (!sockunion2hostprefix(dst, &d))
Expand All @@ -702,7 +701,7 @@ int bgp_update_address(struct interface *ifp, const union sockunion *dst,
sel = NULL;
common = -1;

for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, connected)) {
frr_each (if_connected, ifp->connected, connected) {
p = connected->address;
if (p->family != d.family)
continue;
Expand Down
28 changes: 10 additions & 18 deletions bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ static void bgp_start_interface_nbrs(struct bgp *bgp, struct interface *ifp)

static void bgp_nbr_connected_add(struct bgp *bgp, struct nbr_connected *ifc)
{
struct listnode *node;
struct connected *connected;
struct interface *ifp;
struct prefix *p;
Expand All @@ -155,7 +154,7 @@ static void bgp_nbr_connected_add(struct bgp *bgp, struct nbr_connected *ifc)
* valid local address on the interface.
*/
ifp = ifc->ifp;
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, connected)) {
frr_each (if_connected, ifp->connected, connected) {
p = connected->address;
if (p->family == AF_INET6
&& IN6_IS_ADDR_LINKLOCAL(&p->u.prefix6))
Expand Down Expand Up @@ -227,7 +226,7 @@ static int bgp_ifp_up(struct interface *ifp)
if (!bgp)
return 0;

for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, c))
frr_each (if_connected, ifp->connected, c)
bgp_connected_add(bgp, c);

for (ALL_LIST_ELEMENTS(ifp->nbr_connected, node, nnode, nc))
Expand Down Expand Up @@ -258,7 +257,7 @@ static int bgp_ifp_down(struct interface *ifp)
if (!bgp)
return 0;

for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, c))
frr_each (if_connected, ifp->connected, c)
bgp_connected_delete(bgp, c);

for (ALL_LIST_ELEMENTS(ifp->nbr_connected, node, nnode, nc))
Expand Down Expand Up @@ -559,7 +558,6 @@ static int zebra_read_route(ZAPI_CALLBACK_ARGS)
struct interface *if_lookup_by_ipv4(struct in_addr *addr, vrf_id_t vrf_id)
{
struct vrf *vrf;
struct listnode *cnode;
struct interface *ifp;
struct connected *connected;
struct prefix_ipv4 p;
Expand All @@ -574,7 +572,7 @@ struct interface *if_lookup_by_ipv4(struct in_addr *addr, vrf_id_t vrf_id)
p.prefixlen = IPV4_MAX_BITLEN;

FOR_ALL_INTERFACES (vrf, ifp) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
frr_each (if_connected, ifp->connected, connected) {
cp = connected->address;

if (cp->family == AF_INET)
Expand All @@ -588,7 +586,6 @@ struct interface *if_lookup_by_ipv4(struct in_addr *addr, vrf_id_t vrf_id)
struct interface *if_lookup_by_ipv4_exact(struct in_addr *addr, vrf_id_t vrf_id)
{
struct vrf *vrf;
struct listnode *cnode;
struct interface *ifp;
struct connected *connected;
struct prefix *cp;
Expand All @@ -598,7 +595,7 @@ struct interface *if_lookup_by_ipv4_exact(struct in_addr *addr, vrf_id_t vrf_id)
return NULL;

FOR_ALL_INTERFACES (vrf, ifp) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
frr_each (if_connected, ifp->connected, connected) {
cp = connected->address;

if (cp->family == AF_INET)
Expand All @@ -613,7 +610,6 @@ struct interface *if_lookup_by_ipv6(struct in6_addr *addr, ifindex_t ifindex,
vrf_id_t vrf_id)
{
struct vrf *vrf;
struct listnode *cnode;
struct interface *ifp;
struct connected *connected;
struct prefix_ipv6 p;
Expand All @@ -628,7 +624,7 @@ struct interface *if_lookup_by_ipv6(struct in6_addr *addr, ifindex_t ifindex,
p.prefixlen = IPV6_MAX_BITLEN;

FOR_ALL_INTERFACES (vrf, ifp) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
frr_each (if_connected, ifp->connected, connected) {
cp = connected->address;

if (cp->family == AF_INET6)
Expand All @@ -649,7 +645,6 @@ struct interface *if_lookup_by_ipv6_exact(struct in6_addr *addr,
ifindex_t ifindex, vrf_id_t vrf_id)
{
struct vrf *vrf;
struct listnode *cnode;
struct interface *ifp;
struct connected *connected;
struct prefix *cp;
Expand All @@ -659,7 +654,7 @@ struct interface *if_lookup_by_ipv6_exact(struct in6_addr *addr,
return NULL;

FOR_ALL_INTERFACES (vrf, ifp) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
frr_each (if_connected, ifp->connected, connected) {
cp = connected->address;

if (cp->family == AF_INET6)
Expand All @@ -678,11 +673,10 @@ struct interface *if_lookup_by_ipv6_exact(struct in6_addr *addr,

static int if_get_ipv6_global(struct interface *ifp, struct in6_addr *addr)
{
struct listnode *cnode;
struct connected *connected;
struct prefix *cp;

for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
frr_each (if_connected, ifp->connected, connected) {
cp = connected->address;

if (cp->family == AF_INET6)
Expand All @@ -696,11 +690,10 @@ static int if_get_ipv6_global(struct interface *ifp, struct in6_addr *addr)

static bool if_get_ipv6_local(struct interface *ifp, struct in6_addr *addr)
{
struct listnode *cnode;
struct connected *connected;
struct prefix *cp;

for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
frr_each (if_connected, ifp->connected, connected) {
cp = connected->address;

if (cp->family == AF_INET6)
Expand All @@ -714,11 +707,10 @@ static bool if_get_ipv6_local(struct interface *ifp, struct in6_addr *addr)

static int if_get_ipv4_address(struct interface *ifp, struct in_addr *addr)
{
struct listnode *cnode;
struct connected *connected;
struct prefix *cp;

for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
frr_each (if_connected, ifp->connected, connected) {
cp = connected->address;
if ((cp->family == AF_INET)
&& !ipv4_martian(&(cp->u.prefix4))) {
Expand Down
6 changes: 2 additions & 4 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1610,12 +1610,11 @@ static int bgp_peer_conf_if_to_su_update_v4(struct peer_connection *connection,
struct connected *ifc;
struct prefix p;
uint32_t addr;
struct listnode *node;

/* If our IPv4 address on the interface is /30 or /31, we can derive the
* IPv4 address of the other end.
*/
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) {
frr_each (if_connected, ifp->connected, ifc) {
if (ifc->address && (ifc->address->family == AF_INET)) {
prefix_copy(&p, CONNECTED_PREFIX(ifc));
if (p.prefixlen == 30) {
Expand Down Expand Up @@ -8278,10 +8277,9 @@ static void bgp_if_finish(struct bgp *bgp)
return;

FOR_ALL_INTERFACES (vrf, ifp) {
struct listnode *c_node, *c_nnode;
struct connected *c;

for (ALL_LIST_ELEMENTS(ifp->connected, c_node, c_nnode, c))
frr_each_safe (if_connected, ifp->connected, c)
bgp_connected_delete(bgp, c);
}
}
Expand Down
4 changes: 1 addition & 3 deletions eigrpd/eigrp_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,11 @@ static void eigrp_network_run_interface(struct eigrp *eigrp, struct prefix *p,
struct interface *ifp)
{
struct eigrp_interface *ei;
struct listnode *cnode;
struct connected *co;

/* if interface prefix is match specified prefix,
then create socket and join multicast group. */
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, co)) {

frr_each (if_connected, ifp->connected, co) {
if (CHECK_FLAG(co->flags, ZEBRA_IFA_SECONDARY))
continue;

Expand Down
7 changes: 2 additions & 5 deletions isisd/isis_circuit.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@ static uint8_t isis_circuit_id_gen(struct isis *isis, struct interface *ifp)

void isis_circuit_if_add(struct isis_circuit *circuit, struct interface *ifp)
{
struct listnode *node, *nnode;
struct connected *conn;

if (if_is_broadcast(ifp)) {
Expand All @@ -509,20 +508,18 @@ void isis_circuit_if_add(struct isis_circuit *circuit, struct interface *ifp)
circuit->circ_type = CIRCUIT_T_UNKNOWN;
}

for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, conn))
frr_each (if_connected, ifp->connected, conn)
isis_circuit_add_addr(circuit, conn);

}

void isis_circuit_if_del(struct isis_circuit *circuit, struct interface *ifp)
{
struct listnode *node, *nnode;
struct connected *conn;

assert(circuit->interface == ifp);

/* destroy addresses */
for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, conn))
frr_each_safe (if_connected, ifp->connected, conn)
isis_circuit_del_addr(circuit, conn);

circuit->circ_type = CIRCUIT_T_UNKNOWN;
Expand Down
3 changes: 1 addition & 2 deletions isisd/isis_sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,6 @@ int sr_if_addr_update(struct interface *ifp)
struct isis_circuit *circuit;
struct isis_area *area;
struct connected *connected;
struct listnode *node;
bool need_lsp_regenerate = false;

/* Get corresponding circuit */
Expand All @@ -948,7 +947,7 @@ int sr_if_addr_update(struct interface *ifp)
if (!area)
return 0;

FOR_ALL_INTERFACES_ADDRESSES (ifp, connected, node) {
frr_each (if_connected, ifp->connected, connected) {
for (int i = 0; i < SR_ALGORITHM_COUNT; i++) {
pcfgs[i] = isis_sr_cfg_prefix_find(
area, connected->address, i);
Expand Down
8 changes: 3 additions & 5 deletions ldpd/ldp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ void
kif_redistribute(const char *ifname)
{
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct listnode *cnode;
struct interface *ifp;
struct connected *ifc;
struct kif kif;
Expand All @@ -343,7 +342,7 @@ kif_redistribute(const char *ifname)
ifp2kif(ifp, &kif);
main_imsg_compose_both(IMSG_IFSTATUS, &kif, sizeof(kif));

for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, ifc)) {
frr_each (if_connected, ifp->connected, ifc) {
ifc2kaddr(ifp, ifc, &ka);
main_imsg_compose_ldpe(IMSG_NEWADDR, 0, &ka, sizeof(ka));
}
Expand Down Expand Up @@ -400,7 +399,6 @@ ldp_ifp_destroy(struct interface *ifp)
static int
ldp_interface_status_change(struct interface *ifp)
{
struct listnode *node;
struct connected *ifc;
struct kif kif;
struct kaddr ka;
Expand All @@ -411,12 +409,12 @@ ldp_interface_status_change(struct interface *ifp)
main_imsg_compose_both(IMSG_IFSTATUS, &kif, sizeof(kif));

if (if_is_operative(ifp)) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) {
frr_each (if_connected, ifp->connected, ifc) {
ifc2kaddr(ifp, ifc, &ka);
main_imsg_compose_ldpe(IMSG_NEWADDR, 0, &ka, sizeof(ka));
}
} else {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) {
frr_each (if_connected, ifp->connected, ifc) {
ifc2kaddr(ifp, ifc, &ka);
main_imsg_compose_ldpe(IMSG_DELADDR, 0, &ka, sizeof(ka));
}
Expand Down
4 changes: 1 addition & 3 deletions lib/bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,6 @@ static bool bfd_source_cache_update(struct bfd_source_cache *source,
const struct zapi_nexthop *nh = &route->nexthops[nh_index];
const struct interface *interface;
const struct connected *connected;
const struct listnode *node;

interface = if_lookup_by_index(nh->ifindex, nh->vrf_id);
if (interface == NULL) {
Expand All @@ -1291,8 +1290,7 @@ static bool bfd_source_cache_update(struct bfd_source_cache *source,
continue;
}

for (ALL_LIST_ELEMENTS_RO(interface->connected, node,
connected)) {
frr_each (if_connected_const, interface->connected, connected) {
if (source->address.family !=
connected->address->family)
continue;
Expand Down
Loading
Loading