[Babel-users] [PATCH 1/2] Rename interface_up() to interface_updown()
Christof Schulze
christof.schulze at gmx.net
Wed Aug 7 19:24:14 BST 2019
interface_updown() sets the interface up or down, depending on the
second parameter being 1 or 0.
---
babeld.c | 6 +++---
interface.c | 17 +++++++----------
interface.h | 2 +-
kernel_netlink.c | 3 +++
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/babeld.c b/babeld.c
index ed272f0..0873115 100644
--- a/babeld.c
+++ b/babeld.c
@@ -805,7 +805,7 @@ main(int argc, char **argv)
usleep(roughly(10000));
gettime(&now);
- /* We need to flush so interface_up won't try to reinstall. */
+ /* We need to flush so interface_updown won't try to reinstall. */
flush_all_routes();
FOR_ALL_INTERFACES(ifp) {
@@ -828,7 +828,7 @@ main(int argc, char **argv)
flushbuf(&ifp->buf, ifp);
usleep(roughly(10000));
gettime(&now);
- interface_up(ifp, 0);
+ interface_updown(ifp, 0);
}
release_tables();
kernel_setup_socket(0);
@@ -885,7 +885,7 @@ main(int argc, char **argv)
FOR_ALL_INTERFACES(ifp) {
if(!if_up(ifp))
continue;
- interface_up(ifp, 0);
+ interface_updown(ifp, 0);
}
kernel_setup_socket(0);
kernel_setup(0);
diff --git a/interface.c b/interface.c
index f6cb2db..e74bd14 100644
--- a/interface.c
+++ b/interface.c
@@ -109,7 +109,7 @@ flush_interface(char *ifname)
if(ifp == NULL)
return 0;
- interface_up(ifp, 0);
+ interface_updown(ifp, 0);
if(prev)
prev->next = ifp->next;
else
@@ -271,7 +271,7 @@ check_link_local_addresses(struct interface *ifp)
}
int
-interface_up(struct interface *ifp, int up)
+interface_updown(struct interface *ifp, int up)
{
int mtu, rc, type;
struct ipv6_mreq mreq;
@@ -515,7 +515,7 @@ interface_up(struct interface *ifp, int up)
fail:
assert(up);
- interface_up(ifp, 0);
+ interface_updown(ifp, 0);
local_notify_interface(ifp, LOCAL_CHANGE);
return -1;
}
@@ -547,18 +547,15 @@ check_interfaces(void)
if(ifindex != ifp->ifindex) {
debugf("Noticed ifindex change for %s.\n", ifp->name);
ifp->ifindex = 0;
- interface_up(ifp, 0);
+ interface_updown(ifp, 0);
ifp->ifindex = ifindex;
ifindex_changed = 1;
}
- if(ifp->ifindex > 0)
- rc = kernel_interface_operational(ifp->name, ifp->ifindex);
- else
- rc = 0;
- if((rc > 0) != if_up(ifp)) {
+ int kernel_if_is_operational = (kernel_interface_operational(ifp->name, ifp->ifindex) > 0);
+ if (kernel_if_is_operational != if_up(ifp) ) {
debugf("Noticed status change for %s.\n", ifp->name);
- interface_up(ifp, rc > 0);
+ interface_updown(ifp, kernel_if_is_operational);
}
if(if_up(ifp)) {
diff --git a/interface.h b/interface.h
index 2b70a28..f311d74 100644
--- a/interface.h
+++ b/interface.h
@@ -149,6 +149,6 @@ int flush_interface(char *ifname);
unsigned jitter(struct buffered *buf, int urgent);
unsigned update_jitter(struct interface *ifp, int urgent);
void set_timeout(struct timeval *timeout, int msecs);
-int interface_up(struct interface *ifp, int up);
+int interface_updown(struct interface *ifp, int up);
int interface_ll_address(struct interface *ifp, const unsigned char *address);
void check_interfaces(void);
diff --git a/kernel_netlink.c b/kernel_netlink.c
index 8b7f75d..7a01f8e 100644
--- a/kernel_netlink.c
+++ b/kernel_netlink.c
@@ -715,6 +715,9 @@ kernel_setup_interface(int setup, const char *ifname, int ifindex)
int
kernel_interface_operational(const char *ifname, int ifindex)
{
+ if (!ifindex)
+ return 0;
+
struct ifreq req;
int rc;
int flags = link_detect ? (IFF_UP | IFF_RUNNING) : IFF_UP;
--
2.20.1
More information about the Babel-users
mailing list