netdev-linux: Add MTU check before setting MTU.
authorPravin B Shelar <pshelar@nicira.com>
Wed, 25 Jan 2012 23:44:26 +0000 (15:44 -0800)
committerPravin B Shelar <pshelar@nicira.com>
Wed, 25 Jan 2012 23:44:26 +0000 (15:44 -0800)
Following patch check if current MTU needs to be changed before
issuing set-mtu ioctl.

Suggested-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
lib/netdev-linux.c

index 19a80fbe14e1f4587c7aa615bd167a37b2b1faa2..49475360db0344bf834bd6847c9006a3280b7855 100644 (file)
@@ -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");