aboutsummaryrefslogtreecommitdiff
path: root/lib/netdev.c
diff options
context:
space:
mode:
authorPravin Shelar <pshelar@nicira.com>2011-09-12 17:12:52 -0700
committerPravin Shelar <pshelar@nicira.com>2011-09-12 17:12:52 -0700
commit9b02078077b62e4277e84c7f39382ce09986cf6b (patch)
treeff856186d8a966ca69b98d669c655eef66723701 /lib/netdev.c
parent2f2df2f4dafada02f022c2900f7a17628af7a0d1 (diff)
datapath: Strip down vport interface : OVS_VPORT_ATTR_MTU
There is no need to have vport attribute MTU (OVS_VPORT_ATTR_MTU) as linux net-dev-ioctl can be used to get/set MTU for linux device. Following patch removes OVS_VPORT_ATTR_MTU from datapath protocol. This patch also adds netdev_set_mtu interface. So that MTU adjustments can be done from OVS userspace. get_mtu() interface is also changed, now get_mtu() returns EOPNOTSUPP rather than returning 0 and setting *pmtu to INT_MAX in case there is no MTU attribute for given device. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'lib/netdev.c')
-rw-r--r--lib/netdev.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/netdev.c b/lib/netdev.c
index 12ac81d6..9fba077b 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -510,19 +510,36 @@ netdev_get_name(const struct netdev *netdev)
* (and received) packets, in bytes, not including the hardware header; thus,
* this is typically 1500 bytes for Ethernet devices.
*
- * If successful, returns 0 and stores the MTU size in '*mtup'. Stores INT_MAX
- * in '*mtup' if 'netdev' does not have an MTU (as e.g. some tunnels do not).On
- * failure, returns a positive errno value and stores ETH_PAYLOAD_MAX (1500) in
- * '*mtup'. */
+ * If successful, returns 0 and stores the MTU size in '*mtup'. Returns
+ * EOPNOTSUPP if 'netdev' does not have an MTU (as e.g. some tunnels do not).
+ * On other failure, returns a positive errno value. */
int
netdev_get_mtu(const struct netdev *netdev, int *mtup)
{
int error = netdev_get_dev(netdev)->netdev_class->get_mtu(netdev, mtup);
- if (error) {
+ if (error && error != EOPNOTSUPP) {
+ VLOG_WARN_RL(&rl, "failed to retrieve MTU for network device %s: %s",
+ netdev_get_name(netdev), strerror(error));
+ }
+ return error;
+}
+
+/* Sets the MTU of 'netdev'. The MTU is the maximum size of transmitted
+ * (and received) packets, in bytes.
+ *
+ * If successful, returns 0. Returns EOPNOTSUPP if 'netdev' does not have an
+ * MTU (as e.g. some tunnels do not). On other failure, returns a positive
+ * errno value. */
+int
+netdev_set_mtu(const struct netdev *netdev, int mtu)
+{
+ int error = netdev_get_dev(netdev)->netdev_class->set_mtu(netdev, mtu);
+
+ if (error && error != EOPNOTSUPP) {
VLOG_WARN_RL(&rl, "failed to retrieve MTU for network device %s: %s",
netdev_get_name(netdev), strerror(error));
- *mtup = ETH_PAYLOAD_MAX;
}
+
return error;
}