From 153e54814d81cafa89bae451dbfa92a31910e5a6 Mon Sep 17 00:00:00 2001 From: Pravin B Shelar Date: Wed, 25 Jan 2012 15:44:26 -0800 Subject: [PATCH] netdev-linux: Add MTU check before setting MTU. Following patch check if current MTU needs to be changed before issuing set-mtu ioctl. Suggested-by: Jesse Gross Signed-off-by: Pravin B Shelar --- lib/netdev-linux.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 19a80fbe..49475360 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -1030,6 +1030,10 @@ netdev_linux_set_mtu(const struct netdev *netdev_, int mtu) struct ifreq ifr; int error; + if (netdev_dev->cache_valid & VALID_MTU && + netdev_dev->mtu == mtu) { + return 0; + } ifr.ifr_mtu = mtu; error = netdev_linux_do_ioctl(netdev_get_name(netdev_), &ifr, SIOCSIFMTU, "SIOCSIFMTU"); -- 2.30.2