summaryrefslogtreecommitdiff
path: root/lib/if.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2024-05-29 00:01:20 +0300
committerGitHub <noreply@github.com>2024-05-29 00:01:20 +0300
commitf8abf9644063aa8817dc434bc70a6a505672a6eb (patch)
treeed222e25fa38a5aba3668a9d6636a3fd486fde91 /lib/if.c
parent7ac981384c71b76b6d034c4b7d4e1d7f948917aa (diff)
parentbb46027596524707480a423bd6ef63bad0a8ce0e (diff)
Merge pull request #15082 from louis-6wind/fix-iff-lower-up
lib: take into account the Linux IFF_LOWER_UP flag
Diffstat (limited to 'lib/if.c')
-rw-r--r--lib/if.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/lib/if.c b/lib/if.c
index bf14baaa5e..8f15230f23 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");