summaryrefslogtreecommitdiffstats
path: root/lib/if.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:56:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:56:24 +0000
commit54de8bbe36d7d968c6367939277942518bd4e11f (patch)
tree924f8c16d9c8831679f355b88c620b9b356c9d5a /lib/if.c
parentAdding debian version 10.0.1-0.1. (diff)
downloadfrr-54de8bbe36d7d968c6367939277942518bd4e11f.tar.xz
frr-54de8bbe36d7d968c6367939277942518bd4e11f.zip
Merging upstream version 10.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/if.c')
-rw-r--r--lib/if.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/lib/if.c b/lib/if.c
index a8ceac7..8f15230 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -6,6 +6,12 @@
#include <zebra.h>
+#include <net/if.h>
+
+#ifdef GNU_LINUX
+#include <linux/if.h>
+#endif /* GNU_LINUX */
+
#include "linklist.h"
#include "vector.h"
#include "lib_errors.h"
@@ -668,21 +674,26 @@ int if_is_running(const struct interface *ifp)
if ptm checking is enabled, then ptm check has passed */
int if_is_operative(const struct interface *ifp)
{
- return ((ifp->flags & IFF_UP)
- && (((ifp->flags & IFF_RUNNING)
- && (ifp->ptm_status || !ifp->ptm_enable))
- || !CHECK_FLAG(ifp->status,
- ZEBRA_INTERFACE_LINKDETECTION)));
+ return ((ifp->flags & IFF_UP) &&
+ (((ifp->flags & IFF_RUNNING)
+#ifdef IFF_LOWER_UP
+ && (ifp->flags & IFF_LOWER_UP)
+#endif /* IFF_LOWER_UP */
+ && (ifp->ptm_status || !ifp->ptm_enable)) ||
+ !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)));
}
/* Is the interface operative, eg. either UP & RUNNING
or UP & !ZEBRA_INTERFACE_LINK_DETECTION, without PTM check */
int if_is_no_ptm_operative(const struct interface *ifp)
{
- return ((ifp->flags & IFF_UP)
- && ((ifp->flags & IFF_RUNNING)
- || !CHECK_FLAG(ifp->status,
- ZEBRA_INTERFACE_LINKDETECTION)));
+ return ((ifp->flags & IFF_UP) &&
+ (((ifp->flags & IFF_RUNNING)
+#ifdef IFF_LOWER_UP
+ && (ifp->flags & IFF_LOWER_UP)
+#endif /* IFF_LOWER_UP */
+ ) ||
+ !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)));
}
/* Is this loopback interface ? */
@@ -744,6 +755,9 @@ const char *if_flag_dump(unsigned long flag)
strlcpy(logbuf, "<", BUFSIZ);
IFF_OUT_LOG(IFF_UP, "UP");
+#ifdef IFF_LOWER_UP
+ IFF_OUT_LOG(IFF_LOWER_UP, "LOWER_UP");
+#endif /* IFF_LOWER_UP */
IFF_OUT_LOG(IFF_BROADCAST, "BROADCAST");
IFF_OUT_LOG(IFF_DEBUG, "DEBUG");
IFF_OUT_LOG(IFF_LOOPBACK, "LOOPBACK");
@@ -885,21 +899,6 @@ nbr_connected_log(struct nbr_connected *connected, char *str)
zlog_info("%s", logbuf);
}
-/* If two connected address has same prefix return 1. */
-static int connected_same_prefix(const struct prefix *p1,
- const struct prefix *p2)
-{
- if (p1->family == p2->family) {
- if (p1->family == AF_INET
- && IPV4_ADDR_SAME(&p1->u.prefix4, &p2->u.prefix4))
- return 1;
- if (p1->family == AF_INET6
- && IPV6_ADDR_SAME(&p1->u.prefix6, &p2->u.prefix6))
- return 1;
- }
- return 0;
-}
-
/* count the number of connected addresses that are in the given family */
unsigned int connected_count_by_family(struct interface *ifp, int family)
{
@@ -919,7 +918,7 @@ struct connected *connected_lookup_prefix_exact(struct interface *ifp,
struct connected *ifc;
frr_each (if_connected, ifp->connected, ifc) {
- if (connected_same_prefix(ifc->address, p))
+ if (prefix_same(ifc->address, p))
return ifc;
}
return NULL;
@@ -932,7 +931,7 @@ struct connected *connected_delete_by_prefix(struct interface *ifp,
/* In case of same prefix come, replace it with new one. */
frr_each_safe (if_connected, ifp->connected, ifc) {
- if (connected_same_prefix(ifc->address, p)) {
+ if (prefix_same(ifc->address, p)) {
if_connected_del(ifp->connected, ifc);
return ifc;
}