diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2019-02-05 12:09:44 +0100 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2019-02-05 16:38:23 +0100 |
commit | 9f25dd8af76dc30e54ddcbb4a284058e598951d5 (patch) | |
tree | 63c568f94b71069bff3e25c59eed4a148f382a59 /src/ndp.c | |
parent | f21a0a7bbc31ff8b519e566087e5b425c39480c6 (diff) |
treewide: use avl tree to store interfaces
Store the interfaces in an avl tree iso a linear linked list
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/ndp.c')
-rw-r--r-- | src/ndp.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -284,6 +284,7 @@ static void handle_solicit(void *addr, void *data, size_t len, struct ip6_hdr *ip6 = data; struct nd_neighbor_solicit *req = (struct nd_neighbor_solicit*)&ip6[1]; struct sockaddr_ll *ll = addr; + struct interface *c; char ipbuf[INET6_ADDRSTRLEN]; uint8_t mac[6]; @@ -311,11 +312,11 @@ static void handle_solicit(void *addr, void *data, size_t len, if (!memcmp(ll->sll_addr, mac, sizeof(mac))) return; /* Looped back */ - struct interface *c; - list_for_each_entry(c, &interfaces, head) + avl_for_each_element(&interfaces, c, avl) { if (iface != c && c->ndp == MODE_RELAY && (ns_is_dad || !c->external)) ping6(&req->nd_ns_target, c); + } } /* Use rtnetlink to modify kernel routes */ @@ -340,7 +341,7 @@ static void setup_addr_for_relaying(struct in6_addr *addr, struct interface *ifa inet_ntop(AF_INET6, addr, ipbuf, sizeof(ipbuf)); - list_for_each_entry(c, &interfaces, head) { + avl_for_each_element(&interfaces, c, avl) { if (iface == c || (c->ndp != MODE_RELAY && !add)) continue; |