X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fnetdev.c;h=9fba077b6982c9f31e5db6cd1b5c54b1c61ed93f;hb=0ff2282245a87f253843bf357988d7230139888f;hp=12ac81d6edf0b67a0b263f25f142f7925efbf333;hpb=b53055f4da4f8de17c591ae07ddd782829d21cd8;p=openvswitch 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; }