summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-12-08 23:52:28 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-12-08 23:52:28 +0100
commitb3b4397734e2845d9fa0f994550dc960ad1900d1 (patch)
treeb8f3b3b6aaa18f5ec4c15a8dc1f6d12978fd5def /src
parent6b6099a630510cab290a6115ebf4100e630cd497 (diff)
downloadfastd-b3b4397734e2845d9fa0f994550dc960ad1900d1.tar
fastd-b3b4397734e2845d9fa0f994550dc960ad1900d1.zip
Only try to set MTU when it isn't correct
This allows fastd to run completely without root privileges when the TUN/TAP device is pre-created
Diffstat (limited to 'src')
-rw-r--r--src/fastd.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/fastd.c b/src/fastd.c
index 3b8531f..af9ba6e 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -308,9 +308,14 @@ static void init_tuntap(fastd_context *ctx) {
if (ctl_sock < 0)
exit_errno(ctx, "socket");
- ifr.ifr_mtu = ctx->conf->mtu;
- if (ioctl(ctl_sock, SIOCSIFMTU, &ifr) < 0)
- exit_errno(ctx, "SIOCSIFMTU ioctl failed");
+ if (ioctl(ctl_sock, SIOCGIFMTU, &ifr) < 0)
+ exit_errno(ctx, "SIOCGIFMTU ioctl failed");
+
+ if (ifr.ifr_mtu != ctx->conf->mtu) {
+ ifr.ifr_mtu = ctx->conf->mtu;
+ if (ioctl(ctl_sock, SIOCSIFMTU, &ifr) < 0)
+ exit_errno(ctx, "SIOCSIFMTU ioctl failed");
+ }
if (close(ctl_sock))
pr_error_errno(ctx, "close");