Bug 1586782 - network ID: get rid of NL_DEBUG_LOG in NetlinkService r=valentin
authorMichal Novotny <michal.novotny@gmail.com>
Sat, 28 Dec 2019 14:42:03 +0000
changeset 508464 5cc2cb06d46cabd256afccb514f87318d97b591c
parent 508463 1837aaf09bda74374a6a7a89946c4ca8ec1d8a53
child 508465 054c4936aadb5f41d632ae9cac0dbe6ec21be5d3
push id104007
push usermnovotny@mozilla.com
push dateSat, 28 Dec 2019 15:31:05 +0000
treeherderautoland@5cc2cb06d46c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1586782
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1586782 - network ID: get rid of NL_DEBUG_LOG in NetlinkService r=valentin Differential Revision: https://phabricator.services.mozilla.com/D58347
netwerk/system/netlink/NetlinkService.cpp
netwerk/system/netlink/NetlinkService.h
--- a/netwerk/system/netlink/NetlinkService.cpp
+++ b/netwerk/system/netlink/NetlinkService.cpp
@@ -40,16 +40,19 @@ namespace net {
 
 // period during which to absorb subsequent network change events, in
 // milliseconds
 static const unsigned int kNetworkChangeCoalescingPeriod = 1000;
 
 static LazyLogModule gNlSvcLog("NetlinkService");
 #define LOG(args) MOZ_LOG(gNlSvcLog, mozilla::LogLevel::Debug, args)
 
+#undef LOG_ENABLED
+#define LOG_ENABLED() MOZ_LOG_TEST(gNlSvcLog, mozilla::LogLevel::Debug)
+
 typedef union {
   struct in_addr addr4;
   struct in6_addr addr6;
 } in_common_addr;
 
 static void GetAddrStr(const in_common_addr* aAddr, uint8_t aFamily,
                        nsACString& _retval) {
   char addr[INET6_ADDRSTRLEN];
@@ -166,17 +169,16 @@ class NetlinkNeighbor {
   NetlinkNeighbor() : mHasMAC(false) {}
 
   uint8_t Family() const { return mNeigh.ndm_family; }
   uint32_t GetIndex() const { return mNeigh.ndm_ifindex; }
   const in_common_addr* GetAddrPtr() const { return &mAddr; }
   const uint8_t* GetMACPtr() const { return mMAC; }
   bool HasMAC() const { return mHasMAC; };
 
-#ifdef NL_DEBUG_LOG
   void GetAsString(nsACString& _retval) const {
     nsAutoCString addrStr;
     _retval.Assign("addr=");
     GetAddrStr(&mAddr, mNeigh.ndm_family, addrStr);
     _retval.Append(addrStr);
     if (mNeigh.ndm_family == AF_INET) {
       _retval.Append(" family=AF_INET if=");
     } else {
@@ -185,17 +187,16 @@ class NetlinkNeighbor {
     _retval.AppendInt(mNeigh.ndm_ifindex);
     if (mHasMAC) {
       _retval.Append(" mac=");
       _retval.Append(nsPrintfCString("%02x:%02x:%02x:%02x:%02x:%02x", mMAC[0],
                                      mMAC[1], mMAC[2], mMAC[3], mMAC[4],
                                      mMAC[5]));
     }
   }
-#endif
 
   bool Init(struct nlmsghdr* aNlh) {
     struct ndmsg* neigh;
     struct rtattr* attr;
     int len;
 
     neigh = (ndmsg*)NLMSG_DATA(aNlh);
     len = aNlh->nlmsg_len - NLMSG_LENGTH(sizeof(*neigh));
@@ -362,17 +363,16 @@ class NetlinkRoute {
     if (mRtm.rtm_family != aAddress->Family()) {
       return false;
     }
     size_t addrSize = (mRtm.rtm_family == AF_INET) ? sizeof(mPrefSrcAddr.addr4)
                                                    : sizeof(mPrefSrcAddr.addr6);
     return memcmp(&mPrefSrcAddr, aAddress->GetAddrPtr(), addrSize) == 0;
   }
 
-#ifdef NL_DEBUG_LOG
   void GetAsString(nsACString& _retval) const {
     nsAutoCString addrStr;
     _retval.Assign("table=");
     _retval.AppendInt(mRtm.rtm_table);
     _retval.Append(" type=");
     _retval.AppendInt(mRtm.rtm_type);
     _retval.Append(" scope=");
     _retval.AppendInt(mRtm.rtm_scope);
@@ -403,17 +403,16 @@ class NetlinkRoute {
       _retval.Append(" oif=");
       _retval.AppendInt(mOif);
     }
     if (mHasPrio) {
       _retval.Append(" prio=");
       _retval.AppendInt(mPrio);
     }
   }
-#endif
 
   bool Init(struct nlmsghdr* aNlh) {
     struct rtmsg* rtm;
     struct rtattr* attr;
     int len;
 
     rtm = (rtmsg*)NLMSG_DATA(aNlh);
     len = RTM_PAYLOAD(aNlh);
@@ -597,21 +596,22 @@ bool NetlinkService::LinkInfo::UpdateSta
   mIsUp = false;
 
   if (!mLink->IsUp()) {
     // The link is not up or is a loopback
     LOG(("The link is down or is a loopback"));
   } else {
     // Link is up when there is non-local address associated with it.
     for (uint32_t i = 0; i < mAddresses.Length(); ++i) {
-#ifdef NL_DEBUG_LOG
-      nsAutoCString dbgStr;
-      GetAddrStr(mAddresses[i]->GetAddrPtr(), mAddresses[i]->Family(), dbgStr);
-      LOG(("checking address %s", dbgStr.get()));
-#endif
+      if (LOG_ENABLED()) {
+        nsAutoCString dbgStr;
+        GetAddrStr(mAddresses[i]->GetAddrPtr(), mAddresses[i]->Family(),
+                   dbgStr);
+        LOG(("checking address %s", dbgStr.get()));
+      }
       if (mAddresses[i]->ScopeIsUniverse()) {
         mIsUp = true;
         LOG(("global address found"));
         break;
       }
     }
   }
 
@@ -850,39 +850,35 @@ void NetlinkService::OnAddrMessage(struc
     linkInfo->mAddresses.AppendElement(address.forget());
   } else {
     // Remove all routes associated with this address
     for (uint32_t i = linkInfo->mDefaultRoutes.Length(); i-- > 0;) {
       MOZ_ASSERT(linkInfo->mDefaultRoutes[i]->GetGWAddrPtr(),
                  "Stored routes must have gateway!");
       if (linkInfo->mDefaultRoutes[i]->Family() == address->Family() &&
           address->ContainsAddr(linkInfo->mDefaultRoutes[i]->GetGWAddrPtr())) {
-#ifdef NL_DEBUG_LOG
-        nsAutoCString routeDbgStr;
-        linkInfo->mDefaultRoutes[i]->GetAsString(routeDbgStr);
-        LOG(("Removing default route: %s", routeDbgStr.get()));
-#else
-        LOG(("Removing default route"));
-#endif
+        if (LOG_ENABLED()) {
+          nsAutoCString routeDbgStr;
+          linkInfo->mDefaultRoutes[i]->GetAsString(routeDbgStr);
+          LOG(("Removing default route: %s", routeDbgStr.get()));
+        }
         linkInfo->mDefaultRoutes.RemoveElementAt(i);
       }
     }
 
     // Remove all neighbors associated with this address
     for (auto iter = linkInfo->mNeighbors.Iter(); !iter.Done(); iter.Next()) {
       NetlinkNeighbor* neigh = iter.Data();
       if (neigh->Family() == address->Family() &&
           address->ContainsAddr(neigh->GetAddrPtr())) {
-#ifdef NL_DEBUG_LOG
-        nsAutoCString neighDbgStr;
-        neigh->GetAsString(neighDbgStr);
-        LOG(("Removing neighbor %s", neighDbgStr.get()));
-#else
-        LOG(("Removing neighbor"));
-#endif
+        if (LOG_ENABLED()) {
+          nsAutoCString neighDbgStr;
+          neigh->GetAsString(neighDbgStr);
+          LOG(("Removing neighbor %s", neighDbgStr.get()));
+        }
         iter.Remove();
       }
     }
   }
 
   // Don't treat address changes during initial scan as a network change
   if (mInitialScanFinished) {
     // Send network event change regardless of whether the ID has changed or not
@@ -895,150 +891,138 @@ void NetlinkService::OnRouteMessage(stru
   LOG(("NetlinkService::OnRouteMessage [type=%s]",
        aNlh->nlmsg_type == RTM_NEWROUTE ? "new" : "del"));
 
   nsAutoPtr<NetlinkRoute> route(new NetlinkRoute());
   if (!route->Init(aNlh)) {
     return;
   }
 
-#ifdef NL_DEBUG_LOG
-  nsAutoCString routeDbgStr;
-  route->GetAsString(routeDbgStr);
-#endif
-
   if (!route->IsUnicast() || !route->ScopeIsUniverse()) {
     // Use only unicast routes
-#ifdef NL_DEBUG_LOG
-    LOG(("Not an unicast global route: %s", routeDbgStr.get()));
-#else
-    LOG(("Not an unicast global route"));
-#endif
+    if (LOG_ENABLED()) {
+      nsAutoCString routeDbgStr;
+      route->GetAsString(routeDbgStr);
+      LOG(("Not an unicast global route: %s", routeDbgStr.get()));
+    }
     return;
   }
 
   // Adding/removing any unicast route might change network ID
   TriggerNetworkIDCalculation();
 
   if (!route->IsDefault()) {
     // Store only default routes
-#ifdef NL_DEBUG_LOG
-    LOG(("Not a default route: %s", routeDbgStr.get()));
-#else
-    LOG(("Not a default route"));
-#endif
+    if (LOG_ENABLED()) {
+      nsAutoCString routeDbgStr;
+      route->GetAsString(routeDbgStr);
+      LOG(("Not a default route: %s", routeDbgStr.get()));
+    }
     return;
   }
 
   if (!route->HasOif()) {
-#ifdef NL_DEBUG_LOG
-    LOG(("There is no output interface in route: %s", routeDbgStr.get()));
-#else
-    LOG(("There is no output interface in the route."));
-#endif
+    if (LOG_ENABLED()) {
+      nsAutoCString routeDbgStr;
+      route->GetAsString(routeDbgStr);
+      LOG(("There is no output interface in route: %s", routeDbgStr.get()));
+    }
     return;
   }
 
   if (!route->GetGWAddrPtr()) {
     // We won't use the route if there is no gateway, so don't store it
-#ifdef NL_DEBUG_LOG
-    LOG(("There is no gateway in route: %s", routeDbgStr.get()));
-#else
-    LOG(("There is no gateway in the route."));
-#endif
+    if (LOG_ENABLED()) {
+      nsAutoCString routeDbgStr;
+      route->GetAsString(routeDbgStr);
+      LOG(("There is no gateway in route: %s", routeDbgStr.get()));
+    }
     return;
   }
 
   if (route->Family() == AF_INET6 &&
       net::utils::ipv6_scope((const unsigned char*)route->GetGWAddrPtr()) !=
           IPV6_SCOPE_GLOBAL) {
-#ifdef NL_DEBUG_LOG
-    LOG(("Scope of GW isn't global: %s", routeDbgStr.get()));
-#else
-    LOG(("Scope of GW isn't global."));
-#endif
+    if (LOG_ENABLED()) {
+      nsAutoCString routeDbgStr;
+      route->GetAsString(routeDbgStr);
+      LOG(("Scope of GW isn't global: %s", routeDbgStr.get()));
+    }
     return;
   }
 
   LinkInfo* linkInfo = nullptr;
   mLinks.Get(route->Oif(), &linkInfo);
   if (!linkInfo) {
     // This can happen during startup
-#ifdef NL_DEBUG_LOG
-    LOG(("Cannot find link info for route: %s", routeDbgStr.get()));
-#else
-    LOG(("Cannot find link [ifIdx=%u]", route->Oif()));
-#endif
+    if (LOG_ENABLED()) {
+      nsAutoCString routeDbgStr;
+      route->GetAsString(routeDbgStr);
+      LOG(("Cannot find link info for route: %s", routeDbgStr.get()));
+    }
     return;
   }
 
   for (uint32_t i = 0; i < linkInfo->mDefaultRoutes.Length(); ++i) {
     if (linkInfo->mDefaultRoutes[i]->Equals(route)) {
       // We shouldn't find equal route when adding a new one, but just in case
       // it can happen remove the old one to avoid duplicities.
-#ifdef NL_DEBUG_LOG
-      LOG(("Removing default route: %s", routeDbgStr.get()));
-#else
-      LOG(("Removing default route"));
-#endif
+      if (LOG_ENABLED()) {
+        nsAutoCString routeDbgStr;
+        route->GetAsString(routeDbgStr);
+        LOG(("Removing default route: %s", routeDbgStr.get()));
+      }
       linkInfo->mDefaultRoutes.RemoveElementAt(i);
       break;
     }
   }
 
   if (aNlh->nlmsg_type == RTM_NEWROUTE) {
-#ifdef NL_DEBUG_LOG
-    LOG(("Adding default route: %s", routeDbgStr.get()));
-#else
-    LOG(("Adding default route"));
-#endif
+    if (LOG_ENABLED()) {
+      nsAutoCString routeDbgStr;
+      route->GetAsString(routeDbgStr);
+      LOG(("Adding default route: %s", routeDbgStr.get()));
+    }
     linkInfo->mDefaultRoutes.AppendElement(route.forget());
   }
 }
 
 void NetlinkService::OnNeighborMessage(struct nlmsghdr* aNlh) {
   LOG(("NetlinkService::OnNeighborMessage [type=%s]",
        aNlh->nlmsg_type == RTM_NEWNEIGH ? "new" : "del"));
 
   nsAutoPtr<NetlinkNeighbor> neigh(new NetlinkNeighbor());
   if (!neigh->Init(aNlh)) {
     return;
   }
 
-#ifdef NL_DEBUG_LOG
-  nsAutoCString neighDbgStr;
-  neigh->GetAsString(neighDbgStr);
-#endif
-
-  nsAutoCString key;
-  GetAddrStr(neigh->GetAddrPtr(), neigh->Family(), key);
-
   LinkInfo* linkInfo = nullptr;
   mLinks.Get(neigh->GetIndex(), &linkInfo);
   if (!linkInfo) {
     // This can happen during startup
-#ifdef NL_DEBUG_LOG
-    LOG(("Cannot find link info for neighbor: %s", neighDbgStr.get()));
-#else
-    LOG(("Cannot find link info [ifIdx=%u, key=%s", neigh->GetIndex(),
-         key.get()));
-#endif
+    if (LOG_ENABLED()) {
+      nsAutoCString neighDbgStr;
+      neigh->GetAsString(neighDbgStr);
+      LOG(("Cannot find link info for neighbor: %s", neighDbgStr.get()));
+    }
     return;
   }
 
   if (!linkInfo->mLink->IsTypeEther()) {
-#ifdef NL_DEBUG_LOG
-    LOG(("Ignoring message on non-ethernet link: %s", neighDbgStr.get()));
-#else
-    LOG(("Ignoring message on non-ethernet link [ifIdx=%u, key=%s",
-         neigh->GetIndex(), key.get()));
-#endif
+    if (LOG_ENABLED()) {
+      nsAutoCString neighDbgStr;
+      neigh->GetAsString(neighDbgStr);
+      LOG(("Ignoring message on non-ethernet link: %s", neighDbgStr.get()));
+    }
     return;
   }
 
+  nsAutoCString key;
+  GetAddrStr(neigh->GetAddrPtr(), neigh->Family(), key);
+
   if (aNlh->nlmsg_type == RTM_NEWNEIGH) {
     if (!mRecalculateNetworkId && neigh->HasMAC()) {
       NetlinkNeighbor* oldNeigh = nullptr;
       linkInfo->mNeighbors.Get(key, &oldNeigh);
 
       if (!oldNeigh || !oldNeigh->HasMAC()) {
         // The MAC address was added, if it's a host from some of the saved
         // routing tables we should recalculate network ID
@@ -1052,75 +1036,67 @@ void NetlinkService::OnNeighborMessage(s
              mIPv4RouteCheckResult->GatewayEquals(neigh)) ||
             (mIPv6RouteCheckResult &&
              mIPv6RouteCheckResult->GatewayEquals(neigh))) {
           TriggerNetworkIDCalculation();
         }
       }
     }
 
-#ifdef NL_DEBUG_LOG
-    LOG(("Adding neighbor: %s", neighDbgStr.get()));
-#else
-    LOG(("Adding neighbor %s", key.get()));
-#endif
+    if (LOG_ENABLED()) {
+      nsAutoCString neighDbgStr;
+      neigh->GetAsString(neighDbgStr);
+      LOG(("Adding neighbor: %s", neighDbgStr.get()));
+    }
     linkInfo->mNeighbors.Put(key, neigh.forget());
   } else {
-#ifdef NL_DEBUG_LOG
-    LOG(("Removing neighbor %s", neighDbgStr.get()));
-#else
-    LOG(("Removing neighbor %s", key.get()));
-#endif
+    if (LOG_ENABLED()) {
+      nsAutoCString neighDbgStr;
+      neigh->GetAsString(neighDbgStr);
+      LOG(("Removing neighbor %s", neighDbgStr.get()));
+    }
     linkInfo->mNeighbors.Remove(key);
   }
 }
 
 void NetlinkService::OnRouteCheckResult(struct nlmsghdr* aNlh) {
   LOG(("NetlinkService::OnRouteCheckResult"));
   nsAutoPtr<NetlinkRoute> route;
 
-#ifdef NL_DEBUG_LOG
-  nsAutoCString routeDbgStr;
-#endif
-
   if (aNlh) {
     route = new NetlinkRoute();
     if (!route->Init(aNlh)) {
       route = nullptr;
     } else {
-#ifdef NL_DEBUG_LOG
-      route->GetAsString(routeDbgStr);
-#endif
-
       if (!route->IsUnicast() || !route->ScopeIsUniverse()) {
-#ifdef NL_DEBUG_LOG
-        LOG(("Not an unicast global route: %s", routeDbgStr.get()));
-#else
-        LOG(("Not an unicast global route"));
-#endif
+        if (LOG_ENABLED()) {
+          nsAutoCString routeDbgStr;
+          route->GetAsString(routeDbgStr);
+          LOG(("Not an unicast global route: %s", routeDbgStr.get()));
+        }
         route = nullptr;
       } else if (!route->HasOif()) {
-#ifdef NL_DEBUG_LOG
-        LOG(("There is no output interface in route: %s", routeDbgStr.get()));
-#else
-        LOG(("There is no output interface in the route."));
-#endif
+        if (LOG_ENABLED()) {
+          nsAutoCString routeDbgStr;
+          route->GetAsString(routeDbgStr);
+          LOG(("There is no output interface in route: %s", routeDbgStr.get()));
+        }
         route = nullptr;
       }
     }
   }
 
-  if (route) {
-#ifdef NL_DEBUG_LOG
-    LOG(("Storing route: %s", routeDbgStr.get()));
-#else
-    LOG(("Storing result for the check"));
-#endif
-  } else {
-    LOG(("Clearing result for the check"));
+  if (LOG_ENABLED()) {
+    if (route) {
+      nsAutoCString routeDbgStr;
+      route->GetAsString(routeDbgStr);
+      LOG(("Storing route: %s", routeDbgStr.get()));
+    } else {
+      LOG(("Clearing result for the check"));
+    }
   }
 
   if (mOutgoingMessages[0]->Family() == AF_INET) {
     mIPv4RouteCheckResult = route.forget();
   } else {
     mIPv6RouteCheckResult = route.forget();
   }
 }
@@ -1399,26 +1375,24 @@ bool NetlinkService::CalculateIDForFamil
       LOG((" %s is not ethernet link", linkName.get()));
       continue;
     }
 
     LOG((" checking link %s", linkName.get()));
 
     // Check all default routes and try to get MAC of the gateway
     for (uint32_t i = 0; i < linkInfo->mDefaultRoutes.Length(); ++i) {
-#ifdef NL_DEBUG_LOG
-      nsAutoCString routeDbgStr;
-      linkInfo->mDefaultRoutes[i]->GetAsString(routeDbgStr);
-      LOG(("Checking default route: %s", routeDbgStr.get()));
-#endif
+      if (LOG_ENABLED()) {
+        nsAutoCString routeDbgStr;
+        linkInfo->mDefaultRoutes[i]->GetAsString(routeDbgStr);
+        LOG(("Checking default route: %s", routeDbgStr.get()));
+      }
 
       if (linkInfo->mDefaultRoutes[i]->Family() != aFamily) {
-#ifdef NL_DEBUG_LOG
         LOG(("  skipping due to different family"));
-#endif
         continue;
       }
 
       MOZ_ASSERT(linkInfo->mDefaultRoutes[i]->GetGWAddrPtr(),
                  "Stored routes must have gateway!");
 
       nsAutoCString neighKey;
       GetAddrStr(linkInfo->mDefaultRoutes[i]->GetGWAddrPtr(), aFamily,
@@ -1448,21 +1422,21 @@ bool NetlinkService::CalculateIDForFamil
       gwNeighbors.AppendElement(neigh);
     }
   }
 
   // Sort them so we always have the same network ID on the same network
   gwNeighbors.Sort(NeighborComparator());
 
   for (uint32_t i = 0; i < gwNeighbors.Length(); ++i) {
-#ifdef NL_DEBUG_LOG
-    nsAutoCString neighDbgStr;
-    gwNeighbors[i]->GetAsString(neighDbgStr);
-    LOG(("Hashing MAC address of neighbor: %s", neighDbgStr.get()));
-#endif
+    if (LOG_ENABLED()) {
+      nsAutoCString neighDbgStr;
+      gwNeighbors[i]->GetAsString(neighDbgStr);
+      LOG(("Hashing MAC address of neighbor: %s", neighDbgStr.get()));
+    }
     aSHA1->update(gwNeighbors[i]->GetMACPtr(), ETH_ALEN);
     retval = true;
   }
 
   nsTArray<nsCString> linkNamesToHash;
   if (!gwNeighbors.Length()) {
     // If we don't know MAC of the gateway and link is up, it's probably not
     // an ethernet link. If the name of the link begins with "rmnet" then
@@ -1519,24 +1493,21 @@ bool NetlinkService::CalculateIDForFamil
   const in_common_addr* addrPtr = (*routeCheckResultPtr)->GetGWAddrPtr();
 
   if (routeCheckLinkInfo->mLink->IsTypeEther()) {
     // The traffic is routed through an ethernet device.
 
     if (!addrPtr) {
       // This shouldn't normally happen, missing next hop in case of ethernet
       // device would mean that the checked host is on the same network.
-#ifdef NL_DEBUG_LOG
-      nsAutoCString routeDbgStr;
-      (*routeCheckResultPtr)->GetAsString(routeDbgStr);
-      LOG(("There is no next hop in route: %s", routeDbgStr.get()));
-#else
-      LOG(("There is no next hop in route through an ethernet device %s",
-           routeCheckLinkName.get()));
-#endif
+      if (LOG_ENABLED()) {
+        nsAutoCString routeDbgStr;
+        (*routeCheckResultPtr)->GetAsString(routeDbgStr);
+        LOG(("There is no next hop in route: %s", routeDbgStr.get()));
+      }
       return retval;
     }
 
     // If we know MAC address of the next hop for mRouteCheckIPv4/6 host, hash
     // it even if it's MAC of some of the default routes we've checked above.
     // This ensures that if we have 2 different default routes and next hop for
     // mRouteCheckIPv4/6 changes from one default route to the other, we'll
     // detect it as a network change.
@@ -1551,23 +1522,21 @@ bool NetlinkService::CalculateIDForFamil
       return retval;
     }
 
     if (!neigh->HasMAC()) {
       LOG(("We have no MAC for neighbor %s.", neighKey.get()));
       return retval;
     }
 
-#ifdef NL_DEBUG_LOG
-    nsAutoCString neighDbgStr;
-    neigh->GetAsString(neighDbgStr);
-    LOG(("Hashing MAC address of neighbor: %s", neighDbgStr.get()));
-#else
-    LOG(("Hashing MAC address of neighbor %s", neighKey.get()));
-#endif
+    if (LOG_ENABLED()) {
+      nsAutoCString neighDbgStr;
+      neigh->GetAsString(neighDbgStr);
+      LOG(("Hashing MAC address of neighbor: %s", neighDbgStr.get()));
+    }
     aSHA1->update(neigh->GetMACPtr(), ETH_ALEN);
     retval = true;
   } else {
     // The traffic is routed through a non-ethernet device.
     if (addrPtr) {
       // The route contains next hop. Hash the name of the interface (e.g.
       // "tun1") and the IP address of the next hop.
 
@@ -1619,26 +1588,22 @@ bool NetlinkService::CalculateIDForFamil
           // We have no address yet or this one has smaller prefix length,
           // use it.
           linkAddress = routeCheckLinkInfo->mAddresses[i];
         }
       }
 
       if (!linkAddress) {
         // There is no address in our array?
-        nsAutoCString dbgStr;
-#ifdef NL_DEBUG_LOG
-        (*routeCheckResultPtr)->GetAsString(dbgStr);
-        LOG(("No address found for preferred source address in route: %s",
-             dbgStr.get()));
-#else
-        GetAddrStr((*routeCheckResultPtr)->GetPrefSrcAddrPtr(), aFamily,
-                   dbgStr);
-        LOG(("No address found for preferred source address %s", dbgStr.get()));
-#endif
+        if (LOG_ENABLED()) {
+          nsAutoCString dbgStr;
+          (*routeCheckResultPtr)->GetAsString(dbgStr);
+          LOG(("No address found for preferred source address in route: %s",
+               dbgStr.get()));
+        }
         return retval;
       }
 
       in_common_addr prefix;
       int32_t prefixSize = (aFamily == AF_INET) ? (int32_t)sizeof(prefix.addr4)
                                                 : (int32_t)sizeof(prefix.addr6);
       memcpy(&prefix, linkAddress->GetAddrPtr(), prefixSize);
       uint8_t maskit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe};
--- a/netwerk/system/netlink/NetlinkService.h
+++ b/netwerk/system/netlink/NetlinkService.h
@@ -15,20 +15,16 @@
 #include "mozilla/Mutex.h"
 #include "mozilla/TimeStamp.h"
 #include "nsClassHashtable.h"
 #include "mozilla/SHA1.h"
 
 namespace mozilla {
 namespace net {
 
-#if defined(NIGHTLY_BUILD) || defined(MOZ_DEV_EDITION) || defined(DEBUG)
-#  define NL_DEBUG_LOG
-#endif
-
 class NetlinkAddress;
 class NetlinkNeighbor;
 class NetlinkLink;
 class NetlinkRoute;
 class NetlinkMsg;
 
 class NetlinkServiceListener : public nsISupports {
  public: