X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=system-linux.c;h=b44eb7633dba561e6a47812cb7ce74f5ee9247fc;hb=5b29ffda0099c3bcb8d17a728e1e89dc21a2e68d;hp=6dc9acd82db704573a54a4ca53cd43ee722e7a1b;hpb=5cf30b59baa03db2448570c78e7e92873555d2ec;p=project%2Fnetifd.git diff --git a/system-linux.c b/system-linux.c index 6dc9acd..b44eb76 100644 --- a/system-linux.c +++ b/system-linux.c @@ -1019,6 +1019,10 @@ system_if_get_settings(struct device *dev, struct device_settings *s) s->flags |= DEV_OPT_MTU; } + s->mtu6 = system_update_ipv6_mtu(dev, 0); + if (s->mtu6 > 0) + s->flags |= DEV_OPT_MTU6; + if (ioctl(sock_ioctl, SIOCGIFTXQLEN, &ifr) == 0) { s->txqueuelen = ifr.ifr_qlen; s->flags |= DEV_OPT_TXQUEUELEN; @@ -1114,6 +1118,9 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, unsigned if (ioctl(sock_ioctl, SIOCSIFMTU, &ifr) < 0) s->flags &= ~DEV_OPT_MTU; } + if (s->flags & DEV_OPT_MTU6 & apply_mask) { + system_update_ipv6_mtu(dev, s->mtu6); + } if (s->flags & DEV_OPT_TXQUEUELEN & apply_mask) { ifr.ifr_qlen = s->txqueuelen; if (ioctl(sock_ioctl, SIOCSIFTXQLEN, &ifr) < 0) @@ -2163,19 +2170,18 @@ int system_update_ipv6_mtu(struct device *dev, int mtu) dev->ifname); int fd = open(buf, O_RDWR); - ssize_t len = read(fd, buf, sizeof(buf) - 1); - if (len < 0) - goto out; - buf[len] = 0; - ret = atoi(buf); + if (!mtu) { + ssize_t len = read(fd, buf, sizeof(buf) - 1); + if (len < 0) + goto out; - if (!mtu || ret <= mtu) - goto out; - - lseek(fd, 0, SEEK_SET); - if (write(fd, buf, snprintf(buf, sizeof(buf), "%i", mtu)) <= 0) - ret = -1; + buf[len] = 0; + ret = atoi(buf); + } else { + if (write(fd, buf, snprintf(buf, sizeof(buf), "%i", mtu)) > 0) + ret = mtu; + } out: close(fd);