[Olsr-dev] [PATCH v1 6/9] linux: netlink_process_link: compute up status only once

Ferry Huberts (spam-protected)
Wed Feb 10 14:35:45 CET 2016


From: Ferry Huberts <(spam-protected)>

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 src/linux/kernel_routes_nl.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/linux/kernel_routes_nl.c b/src/linux/kernel_routes_nl.c
index da9dd6e..c3a3f73 100644
--- a/src/linux/kernel_routes_nl.c
+++ b/src/linux/kernel_routes_nl.c
@@ -118,6 +118,7 @@ static void netlink_process_link(struct nlmsghdr *h)
   struct olsr_if *oif;
   char namebuffer[IF_NAMESIZE];
   char * ifaceName = NULL;
+  bool up;
 
   iface = if_ifwithindex(ifi->ifi_index);
 
@@ -128,24 +129,23 @@ static void netlink_process_link(struct nlmsghdr *h)
   }
 
   oif = ifaceName ? olsrif_ifwithname(ifaceName) : NULL;
+  up = ((ifi->ifi_flags & IFF_UP) != 0);
 
-  if (!iface && ((ifi->ifi_flags & IFF_UP) != 0)) {
+  if (!iface && up) {
     if (oif) {
       /* try to take interface up, will trigger ifchange */
       chk_if_up(oif, 3);
     }
-  }
-  else if (iface && ((ifi->ifi_flags & IFF_UP) == 0)) {
+  } else if (iface && !up) {
     /* try to take interface down, will trigger ifchange */
     olsr_remove_interface(iface->olsr_if);
   }
 
   if (!iface && !oif) {
     /* this is not an OLSR interface */
-    if ((ifi->ifi_flags & IFF_UP) != 0) {
+    if (up) {
       olsr_trigger_ifchange(ifi->ifi_index, NULL, IFCHG_IF_ADD);
-    }
-    else if ((ifi->ifi_flags & IFF_UP) == 0){
+    } else if (!up) {
       olsr_trigger_ifchange(ifi->ifi_index, NULL, IFCHG_IF_REMOVE);
     }
   }
-- 
2.5.0




More information about the Olsr-dev mailing list