2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

netdev: Allow get_mtu and set_mtu provider functions to be null.

Most netdev provider functions are allowed to be null if the implementation
does not support this feature.  This commit adds this feature for get_mtu
and set_mtu, and changes netdev-vport to take advantage of it.

Also, changes netdev_get_mtu() to report an MTU of 0 on error, instead of
leaving the MTU indeterminate.
This commit is contained in:
Ben Pfaff
2011-09-15 10:41:15 -07:00
parent 98fbd5b28b
commit 14622f22ab
3 changed files with 21 additions and 24 deletions

View File

@@ -531,14 +531,21 @@ netdev_get_name(const struct netdev *netdev)
*
* 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. */
* On other failure, returns a positive errno value. On failure, sets '*mtup'
* to 0. */
int
netdev_get_mtu(const struct netdev *netdev, int *mtup)
{
int error = netdev_get_dev(netdev)->netdev_class->get_mtu(netdev, mtup);
if (error && error != EOPNOTSUPP) {
VLOG_WARN_RL(&rl, "failed to retrieve MTU for network device %s: %s",
netdev_get_name(netdev), strerror(error));
const struct netdev_class *class = netdev_get_dev(netdev)->netdev_class;
int error;
error = class->get_mtu ? class->get_mtu(netdev, mtup) : EOPNOTSUPP;
if (error) {
*mtup = 0;
if (error != EOPNOTSUPP) {
VLOG_WARN_RL(&rl, "failed to retrieve MTU for network device %s: "
"%s", netdev_get_name(netdev), strerror(error));
}
}
return error;
}
@@ -552,8 +559,10 @@ netdev_get_mtu(const struct netdev *netdev, int *mtup)
int
netdev_set_mtu(const struct netdev *netdev, int mtu)
{
int error = netdev_get_dev(netdev)->netdev_class->set_mtu(netdev, mtu);
const struct netdev_class *class = netdev_get_dev(netdev)->netdev_class;
int error;
error = class->set_mtu ? class->set_mtu(netdev, mtu) : EOPNOTSUPP;
if (error && error != EOPNOTSUPP) {
VLOG_WARN_RL(&rl, "failed to retrieve MTU for network device %s: %s",
netdev_get_name(netdev), strerror(error));