From 91d41d9cd676103ae3ef228466557a834301df6e Mon Sep 17 00:00:00 2001
From: Povilas Staniulis <wdmonster@gmail.com>
Date: Mon, 28 May 2017 23:10:59 +0300
Subject: [PATCH] HACK: netd: disable output interface result validation

The cause of these issues appears to be Android's netd daemon not
playing well with the latest kernel. I wasn't able to find the root
cause, but I did hack netd to enable networking to work.

WiFi now works fine on my T100TA
---
 server/RouteController.cpp | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/server/RouteController.cpp b/server/RouteController.cpp
index fa39c89..e331ecd 100644
--- a/server/RouteController.cpp
+++ b/server/RouteController.cpp
@@ -756,17 +756,28 @@ WARN_UNUSED_RESULT int modifyPhysicalNetwork(unsigned netId, const char* interfa
     }
 
     if (int ret = modifyIncomingPacketMark(netId, interface, permission, add)) {
+        ALOGE("DDS: modifyIncomingPacketMark failed with error: %s", strerror(-ret));
         return ret;
     }
     if (int ret = modifyExplicitNetworkRule(netId, table, permission, INVALID_UID, INVALID_UID,
                                             add)) {
-        return ret;
+        ALOGE("DDS: modifyExplicitNetworkRule failed with error: %s", strerror(-ret));
+	return ret;
     }
-    if (int ret = modifyOutputInterfaceRules(interface, table, permission, INVALID_UID, INVALID_UID,
+   /* DDS: HACK ! This can sometimes fail on latest kernels, leading to a non-working network. Disable validation for now, until we find a better fix. */
+   if (int ret = modifyOutputInterfaceRules(interface, table, permission, INVALID_UID, INVALID_UID,
                                             add)) {
-        return ret;
+        ALOGE("DDS: modifyOutputInterfaceRules failed with error: %s, ignoring this.", strerror(-ret));
+    //  return ret;
     }
-    return modifyImplicitNetworkRule(netId, table, permission, add);
+
+   int ret2 = modifyImplicitNetworkRule(netId, table, permission, add);
+
+   if (ret2) {
+      ALOGE("DDS: modifyImplicitNetworkRule failed with error: %s", strerror(-ret2));
+   }
+
+   return ret2;
 }
 
 WARN_UNUSED_RESULT int modifyRejectNonSecureNetworkRule(const UidRanges& uidRanges, bool add) {
-- 
2.11.0

