summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-02-17 18:50:50 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-02-17 19:48:07 +0100
commitbb3b08ad983a15fe948e20443376ddbf0cab6ce7 (patch)
tree47311832eb6174fce622191db0a389ec61d03e5f /src
parenttree-wide: use in_addr_is_set() or friends (diff)
downloadsystemd-bb3b08ad983a15fe948e20443376ddbf0cab6ce7.tar.xz
systemd-bb3b08ad983a15fe948e20443376ddbf0cab6ce7.zip
resolve: make manager_find_ifindex() or friends return earlier
Diffstat (limited to '')
-rw-r--r--src/resolve/resolved-link.c6
-rw-r--r--src/resolve/resolved-manager.c12
2 files changed, 18 insertions, 0 deletions
diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c
index d9192d99f6..18dc3d29e9 100644
--- a/src/resolve/resolved-link.c
+++ b/src/resolve/resolved-link.c
@@ -697,6 +697,12 @@ LinkAddress *link_find_address(Link *l, int family, const union in_addr_union *i
assert(l);
+ if (!IN_SET(family, AF_INET, AF_INET6))
+ return NULL;
+
+ if (!in_addr)
+ return NULL;
+
LIST_FOREACH(addresses, a, l->addresses)
if (a->family == family && in_addr_equal(family, &a->in_addr, in_addr))
return a;
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index a2a2cf4954..6cc3a5d56f 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -1153,6 +1153,12 @@ int manager_find_ifindex(Manager *m, int family, const union in_addr_union *in_a
assert(m);
+ if (!IN_SET(family, AF_INET, AF_INET6))
+ return 0;
+
+ if (!in_addr)
+ return 0;
+
a = manager_find_link_address(m, family, in_addr);
if (a)
return a->link->ifindex;
@@ -1248,6 +1254,12 @@ LinkAddress* manager_find_link_address(Manager *m, int family, const union in_ad
assert(m);
+ if (!IN_SET(family, AF_INET, AF_INET6))
+ return NULL;
+
+ if (!in_addr)
+ return NULL;
+
HASHMAP_FOREACH(l, m->links) {
LinkAddress *a;