The ndc command used didn't work on my Nvidia Shield (rooted with a 
custom-built kernel). The ip link command does work. I have only tested this on 
an Nvidia Shield (Android TV - Version 9.0 Pie).

I couldn't find a lot of documentation on ndc so it's possible my device/kernel 
is misconfigured. If you suspect this is the case, let me know.

Signed-off-by: Adam Irr <[email protected]>
---
 src/wg-quick/android.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/wg-quick/android.c b/src/wg-quick/android.c
index 326efa9..941c7b8 100644
--- a/src/wg-quick/android.c
+++ b/src/wg-quick/android.c
@@ -995,7 +995,7 @@ static void set_mtu(const char *iface, unsigned int mtu)
        int endpoint_mtu, next_mtu;
 
        if (mtu) {
-               cndc("interface setmtu %s %u", iface, mtu);
+               cmd("ip link set dev %s mtu %d", iface, mtu);
                return;
        }
 
@@ -1016,7 +1016,7 @@ static void set_mtu(const char *iface, unsigned int mtu)
                        endpoint_mtu = next_mtu;
        }
 
-       cndc("interface setmtu %s %d", iface, endpoint_mtu - 80);
+       cmd("ip link set dev %s mtu %d", iface, endpoint_mtu - 80);
 }
 
 static void add_route(const char *iface, unsigned int netid, const char *route)
-- 
2.25.1
From 1ffa6e6318dbeeaaaf56a916bbaa4994df89b599 Mon Sep 17 00:00:00 2001
From: Adam Irr <[email protected]>
Date: Sat, 2 Jan 2021 21:36:12 -0800
Subject: [PATCH] wg-quick: Android: Use ip link to set MTU

Signed-off-by: Adam Irr <[email protected]>
---
 src/wg-quick/android.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/wg-quick/android.c b/src/wg-quick/android.c
index 326efa9..941c7b8 100644
--- a/src/wg-quick/android.c
+++ b/src/wg-quick/android.c
@@ -995,7 +995,7 @@ static void set_mtu(const char *iface, unsigned int mtu)
 	int endpoint_mtu, next_mtu;
 
 	if (mtu) {
-		cndc("interface setmtu %s %u", iface, mtu);
+		cmd("ip link set dev %s mtu %d", iface, mtu);
 		return;
 	}
 
@@ -1016,7 +1016,7 @@ static void set_mtu(const char *iface, unsigned int mtu)
 			endpoint_mtu = next_mtu;
 	}
 
-	cndc("interface setmtu %s %d", iface, endpoint_mtu - 80);
+	cmd("ip link set dev %s mtu %d", iface, endpoint_mtu - 80);
 }
 
 static void add_route(const char *iface, unsigned int netid, const char *route)
-- 
2.25.1

Reply via email to