summaryrefslogtreecommitdiffstats
path: root/lib/if.h
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2021-06-23 16:35:44 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2021-11-17 11:17:44 +0100
commit1e9044be8d4325fa82f01d72eb6c8581dcd6fd06 (patch)
tree587f2a6a425b6328de693f0e39bd79c0e4e82d47 /lib/if.h
parentMerge pull request #10071 from donaldsharp/valgrind_supp_change (diff)
downloadfrr-1e9044be8d4325fa82f01d72eb6c8581dcd6fd06.tar.xz
frr-1e9044be8d4325fa82f01d72eb6c8581dcd6fd06.zip
*: clean up ifp-by-local-address function(s)
Most users of if_lookup_address_exact only cared about whether the address is any local address. Split that off into a separate function. For the users that actually need the ifp - which I'm about to add a few of - change it to prefer returning interfaces that are UP. (Function name changed due to slight change in behavior re. UP state, to avoid possible bugs from this change.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/if.h')
-rw-r--r--lib/if.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/if.h b/lib/if.h
index 1012bf555..5f0dc2755 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -511,7 +511,7 @@ extern void if_update_to_new_vrf(struct interface *, vrf_id_t vrf_id);
extern struct interface *if_lookup_by_index(ifindex_t, vrf_id_t vrf_id);
extern struct interface *if_vrf_lookup_by_index_next(ifindex_t ifindex,
vrf_id_t vrf_id);
-extern struct interface *if_lookup_exact_address(const void *matchaddr,
+extern struct interface *if_lookup_address_local(const void *matchaddr,
int family, vrf_id_t vrf_id);
extern struct connected *if_lookup_address(const void *matchaddr, int family,
vrf_id_t vrf_id);
@@ -520,6 +520,12 @@ extern struct interface *if_lookup_prefix(const struct prefix *prefix,
size_t if_lookup_by_hwaddr(const uint8_t *hw_addr, size_t addrsz,
struct interface ***result, vrf_id_t vrf_id);
+static inline bool if_address_is_local(const void *matchaddr, int family,
+ vrf_id_t vrf_id)
+{
+ return if_lookup_address_local(matchaddr, family, vrf_id) != NULL;
+}
+
struct vrf;
extern struct interface *if_lookup_by_name_vrf(const char *name, struct vrf *vrf);
extern struct interface *if_lookup_by_name(const char *ifname, vrf_id_t vrf_id);