mtu related changes
Subsystems (3)
cover mtu related changes
While looking at other MTU issues, noticed a couple oppurtunties for improving user experience.
Stephen Hemminger (3):
failover: change mtu has RTNL
net: report min and max mtu network device settings
net: report invalid mtu value via netlink extack
drivers/net/net_failover.c | 4 ++-- include/linux/netdevice.h | 2 ++ include/uapi/linux/if_link.h | 2 ++ net/core/dev.c | 23 +++++++++++++++++------ net/core/rtnetlink.c | 8 +++++++- 5 files changed, 30 insertions(+), 9 deletions(-)
Signature · 1 line
2.18.0
PATCH 1/3 failover: change mtu has RTNL
When changing MTU, RTNL is held so use rtnl_dereference instead of rcu_dereference.
--- drivers/net/net_failover.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/net_failover.c +2 -2
@@ -220,14 +220,14 @@ static int net_failover_change_mtu(struct net_device *dev, int new_mtu)struct net_device *primary_dev, *standby_dev;int ret =0 ; - primary_dev =rcu_dereference (nfo_info->primary_dev); + primary_dev =rtnl_dereference (nfo_info->primary_dev);if (primary_dev) { ret =dev_set_mtu (primary_dev, new_mtu);if (ret)return ret; } - standby_dev =rcu_dereference (nfo_info->standby_dev); + standby_dev =rtnl_dereference (nfo_info->standby_dev);if (standby_dev) { ret =dev_set_mtu (standby_dev, new_mtu);if (ret) {
Signature · 1 line
2.18.0
PATCH 2/3 net: report min and max mtu network device settings
In reply to Stephen HemmingerReport the minimum and maximum MTU allowed on a device via netlink so that it can be displayed by tools like ip link.
--- include/uapi/linux/if_link.h | 2 ++ net/core/rtnetlink.c | 6 ++++++ 2 files changed, 8 insertions(+)
include/uapi/linux/if_link.h +2 -0
@@ -164,6 +164,8 @@ enum {IFLA_CARRIER_UP_COUNT ,IFLA_CARRIER_DOWN_COUNT ,IFLA_NEW_IFINDEX , +IFLA_MIN_MTU , +IFLA_MAX_MTU , __IFLA_MAX };
net/core/rtnetlink.c +6 -0
@@ -1015,6 +1015,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, +nla_total_size (4 )/* IFLA_IF_NETNSID */ +nla_total_size (4 )/* IFLA_CARRIER_UP_COUNT */ +nla_total_size (4 )/* IFLA_CARRIER_DOWN_COUNT */ + +nla_total_size (4 )/* IFLA_MIN_MTU */ + +nla_total_size (4 )/* IFLA_MAX_MTU */ +0 ; }
@@ -1601,6 +1603,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, netif_running(dev) ? dev->operstate : IF_OPER_DOWN) ||nla_put_u8 (skb,IFLA_LINKMODE , dev->link_mode) ||nla_put_u32 (skb,IFLA_MTU , dev->mtu) || +nla_put_u32 (skb,IFLA_MIN_MTU , dev->min_mtu) || +nla_put_u32 (skb,IFLA_MAX_MTU , dev->max_mtu) ||nla_put_u32 (skb,IFLA_GROUP , dev->group) ||nla_put_u32 (skb,IFLA_PROMISCUITY , dev->promiscuity) || nla_put_u32(skb, IFLA_NUM_TX_QUEUES, dev->num_tx_queues) ||
@@ -1732,6 +1736,8 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { [IFLA_IF_NETNSID] = { .type = NLA_S32 }, [IFLA_CARRIER_UP_COUNT] = { .type = NLA_U32 }, [IFLA_CARRIER_DOWN_COUNT] = { .type = NLA_U32 }, + [IFLA_MIN_MTU] = { .type = NLA_U32 }, + [IFLA_MAX_MTU] = { .type = NLA_U32 }, };static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX +1 ] = {
Signature · 1 line
2.18.0
PATCH 3/3 net: report invalid mtu value via netlink extack
In reply to Stephen HemmingerIf an invalid MTU value is set through rtnetlink return extra error information instead of putting message in kernel log. For other cases where there is no visible API, keep the error report in the log.
Example:
# ip li set dev enp12s0 mtu 10000 Error: mtu greater than device maximum.
# ifconfig enp12s0 mtu 10000 SIOCSIFMTU: Invalid argument # dmesg | tail -1 [ 2047.795467] enp12s0: mtu greater than device maximum
--- include/linux/netdevice.h | 2 ++ net/core/dev.c | 23 +++++++++++++++++------ net/core/rtnetlink.c | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-)
include/linux/netdevice.h +2 -0
@@ -3546,6 +3546,8 @@ int dev_set_alias(struct net_device *, const char *, size_t);int dev_get_alias (const struct net_device *,char *,size_t );int dev_change_net_namespace (struct net_device *,struct net *,const char *);int __dev_set_mtu (struct net_device *,int ); +int dev_set_mtu_ext (struct net_device *dev,int mtu, +struct netlink_ext_ack *extack);int dev_set_mtu (struct net_device *,int );int dev_change_tx_queue_len (struct net_device *,unsigned long );void dev_set_group (struct net_device *,int );
net/core/dev.c +17 -6
@@ -7523,13 +7523,15 @@ int __dev_set_mtu(struct net_device *dev, int new_mtu)EXPORT_SYMBOL (__dev_set_mtu);/** -* dev_set_mtu - Change maximum transfer unit +* dev_set_mtu_ext - Change maximum transfer unit * @dev: device * @new_mtu: new transfer unit +* @extack: netlink extended ack * * Change the maximum transfer size of the network device. */ -int dev_set_mtu (struct net_device *dev,int new_mtu) +int dev_set_mtu_ext (struct net_device *dev,int new_mtu, +struct netlink_ext_ack *extack) {int err, orig_mtu;
@@ -7538,14 +7540,12 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)/* MTU must be positive, and in range */ if (new_mtu <0 || new_mtu < dev->min_mtu) { -net_err_ratelimited ("%s: Invalid MTU %d requested, hw min %d\n" , - dev->name, new_mtu, dev->min_mtu); +NL_SET_ERR_MSG (extack,"mtu less than device minimum" );return -EINVAL ; }if (dev->max_mtu >0 && new_mtu > dev->max_mtu) { -net_err_ratelimited ("%s: Invalid MTU %d requested, hw max %d\n" , - dev->name, new_mtu, dev->max_mtu); +NL_SET_ERR_MSG (extack,"mtu greater than device maximum" );return -EINVAL ; }
@@ -7573,6 +7573,17 @@ int dev_set_mtu(struct net_device *dev, int new_mtu) }return err; } + +int dev_set_mtu (struct net_device *dev,int new_mtu) +{ +struct netlink_ext_ack extack; +int err; + + err =dev_set_mtu_ext (dev, new_mtu, &extack); +if (err) +net_err_ratelimited ("%s: %s\n" , dev->name, extack._msg); +return err; +}EXPORT_SYMBOL (dev_set_mtu);/**
net/core/rtnetlink.c +1 -1
@@ -2382,7 +2382,7 @@ static int do_setlink(const struct sk_buff *skb, }if (tb[IFLA_MTU ]) { - err =dev_set_mtu (dev,nla_get_u32 (tb[IFLA_MTU ])); + err =dev_set_mtu_ext (dev,nla_get_u32 (tb[IFLA_MTU ]), extack);if (err <0 ) goto errout; status |=DO_SETLINK_MODIFIED ;
Signature · 1 line
2.18.0
David Miller
maintainerFrom: Stephen Hemminger <[email protected]>
Date: Fri, 27 Jul 2018 13:43:20 -0700
Quoted 2 lines
While looking at other MTU issues, noticed a couple oppurtunties for improving user experience.
Series applied, thanks.