* bytes for Ethernet devices.
*
* If 'netdev' does not have an MTU (e.g. as some tunnels do not), then
- * this function should return EOPNOTSUPP. */
+ * this function should return EOPNOTSUPP. This function may be set to
+ * null if it would always return EOPNOTSUPP. */
int (*get_mtu)(const struct netdev *netdev, int *mtup);
/* Sets 'netdev''s MTU to 'mtu'.
*
* If 'netdev' does not have an MTU (e.g. as some tunnels do not), then
- * this function should return EOPNOTSUPP. */
+ * this function should return EOPNOTSUPP. This function may be set to
+ * null if it would always return EOPNOTSUPP. */
int (*set_mtu)(const struct netdev *netdev, int mtu);
/* Returns the ifindex of 'netdev', if successful, as a positive number.
return error;
}
-static int
-netdev_vport_get_mtu(const struct netdev *netdev OVS_UNUSED,
- int *mtup OVS_UNUSED)
-{
- return EOPNOTSUPP;
-}
-
-static int
-netdev_vport_set_mtu(const struct netdev *netdev OVS_UNUSED,
- int mtu OVS_UNUSED)
-{
- return EOPNOTSUPP;
-}
-
int
netdev_vport_get_stats(const struct netdev *netdev, struct netdev_stats *stats)
{
\
netdev_vport_set_etheraddr, \
netdev_vport_get_etheraddr, \
- netdev_vport_get_mtu, \
- netdev_vport_set_mtu, \
+ NULL, /* get_mtu */ \
+ NULL, /* set_mtu */ \
NULL, /* get_ifindex */ \
NULL, /* get_carrier */ \
NULL, /* get_miimon */ \
*
* 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;
}
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));