vdpa: Warn if MTU configured is too low
PATCH 1/1 vdpa: Warn if MTU configured is too low
Following the recommendation in virio spec 1.1, a device offering VIRTIO_NET_F_MTU should set the mtu to at least 1280 bytes.
Print a warning if this recommendation is not met.
--- drivers/vdpa/vdpa.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/vdpa/vdpa.c +8 -1
@@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb) BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) | \ BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP)) +/* Recommended virtio spec 1.1 section 5.1.4.1 */ +#define VIRTIO_MIN_PREFERRED_MTU 1280 +static int vdpa_nl_cmd_dev_add_set_doit (struct sk_buff *skb,struct genl_info *info) {struct vdpa_dev_set_config config = {};
@@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i err =PTR_ERR (mdev); goto err; } +if ((mdev->supported_features &BIT_ULL (VIRTIO_NET_F_MTU )) && + (config.mask &BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MTU ) && + config.net.mtu <VIRTIO_MIN_PREFERRED_MTU )) +pr_warn ("MTU is below recommended value\n" );if ((config.mask & mdev->config_attr_mask) != config.mask) {NL_SET_ERR_MSG_MOD (info->extack,"All provided attributes are not supported" );
@@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = { [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING }, [VDPA_ATTR_DEV_NET_CFG_MACADDR ] =NLA_POLICY_ETH_ADDR , /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */ - [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68), + [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU), };static const struct genl_ops vdpa_nl_ops[] = {
Signature · 1 line
2.35.1
Quoted 7 lines · Eli Cohen
Following the recommendation in virio spec 1.1, a device offering
VIRTIO_NET_F_MTUshould set the mtu to at least 1280 bytes.Print a warning if this recommendation is not met.
Signed-off-by Eli Cohen <[email protected]>
I wonder why it's a must?
Quoted 19 lines
--- drivers/vdpa/vdpa.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/vdpa/vdpa.c +3
-0@@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb) BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) | \ BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP)) +/* Recommended virtio spec 1.1 section 5.1.4.1 */ +#define VIRTIO_MIN_PREFERRED_MTU 1280 +static int vdpa_nl_cmd_dev_add_set_doit (struct sk_buff *skb,struct genl_info *info) {struct vdpa_dev_set_config config = {};
drivers/vdpa/vdpa.c static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i · line 642
Quoted 6 lines
drivers/vdpa/vdpa.c +3
-0@@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i err =PTR_ERR (mdev); goto err; } +if ((mdev->supported_features &BIT_ULL (VIRTIO_NET_F_MTU )) && + (config.mask &BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MTU ) && + config.net.mtu <VIRTIO_MIN_PREFERRED_MTU ))
Should be <= ?
Thanks
Quoted 14 lines
drivers/vdpa/vdpa.c +2
-2+pr_warn ("MTU is below recommended value\n" );if ((config.mask & mdev->config_attr_mask) != config.mask) {NL_SET_ERR_MSG_MOD (info->extack,"All provided attributes are not supported" );@@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = { [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING }, [VDPA_ATTR_DEV_NET_CFG_MACADDR ] =NLA_POLICY_ETH_ADDR , /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */ - [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68), + [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU), };static const struct genl_ops vdpa_nl_ops[] = { --
Quoted 2 lines
2.35.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerQuoted 10 lines · Jason Wang
Quoted 7 lines · Eli Cohen
Following the recommendation in virio spec 1.1, a device offering
VIRTIO_NET_F_MTUshould set the mtu to at least 1280 bytes.Print a warning if this recommendation is not met.
Signed-off-by Eli Cohen <[email protected]>I wonder why it's a must?
It's a SHOULD in the spec. I guess 1280 is to allow IPv6.
Quoted 44 lines
Quoted 19 lines
--- drivers/vdpa/vdpa.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/vdpa/vdpa.c +3
-0@@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb) BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) | \ BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP)) +/* Recommended virtio spec 1.1 section 5.1.4.1 */ +#define VIRTIO_MIN_PREFERRED_MTU 1280 +static int vdpa_nl_cmd_dev_add_set_doit (struct sk_buff *skb,struct genl_info *info) {struct vdpa_dev_set_config config = {};drivers/vdpa/vdpa.c static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i · line 642
Quoted 6 lines
drivers/vdpa/vdpa.c +3
-0@@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i err =PTR_ERR (mdev); goto err; } +if ((mdev->supported_features &BIT_ULL (VIRTIO_NET_F_MTU )) && + (config.mask &BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MTU ) && + config.net.mtu <VIRTIO_MIN_PREFERRED_MTU ))Should be <= ?
Thanks
Quoted 12 lines
drivers/vdpa/vdpa.c +2
-1+pr_warn ("MTU is below recommended value\n" );if ((config.mask & mdev->config_attr_mask) != config.mask) {NL_SET_ERR_MSG_MOD (info->extack,"All provided attributes are not supported" );@@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = { [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING }, [VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,/* virtio spec 1.1 section 5.1.4.1 for valid MTU range */ - [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68), + [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU), };
Quoted 4 lines
Quoted 4 lines
drivers/vdpa/vdpa.c +0
-1static const struct genl_ops vdpa_nl_ops[] = { --2.35.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Jason Wang
Quoted 4 lines · Eli Cohen
Following the recommendation in virio spec 1.1, a device offering
VIRTIO_NET_F_MTUshould set the mtu to at least 1280 bytes.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Print a warning if this recommendation is not met.
Signed-off-by Eli Cohen <[email protected]>I wonder why it's a must?
It's a SHOULD in the spec. I guess 1280 is to allow IPv6.
Right, I see this.
Thanks
Quoted 45 lines
Quoted 45 lines
Quoted 20 lines
--- drivers/vdpa/vdpa.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/vdpa/vdpa.c +3
-0@@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb) BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) | \ BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP)) +/* Recommended virtio spec 1.1 section 5.1.4.1 */ +#define VIRTIO_MIN_PREFERRED_MTU 1280 +static int vdpa_nl_cmd_dev_add_set_doit (struct sk_buff *skb,struct genl_info *info) {struct vdpa_dev_set_config config = {};drivers/vdpa/vdpa.c static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i · line 642
Quoted 6 lines
drivers/vdpa/vdpa.c +3
-0@@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i err =PTR_ERR (mdev); goto err; } +if ((mdev->supported_features &BIT_ULL (VIRTIO_NET_F_MTU )) && + (config.mask &BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MTU ) && + config.net.mtu <VIRTIO_MIN_PREFERRED_MTU ))Should be <= ?
Thanks
Quoted 12 lines
drivers/vdpa/vdpa.c +2
-1+pr_warn ("MTU is below recommended value\n" );if ((config.mask & mdev->config_attr_mask) != config.mask) {NL_SET_ERR_MSG_MOD (info->extack,"All provided attributes are not supported" );@@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = { [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING }, [VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,/* virtio spec 1.1 section 5.1.4.1 for valid MTU range */ - [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68), + [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU), };
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
drivers/vdpa/vdpa.c +0
-1static const struct genl_ops vdpa_nl_ops[] = { --2.35.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 9 lines
From: Jason Wang <[email protected]>
Sent: Wednesday, May 11, 2022 12:34 PM
To: Eli Cohen <[email protected]>
Cc: mst <[email protected]>; virtualization <[email protected]>; linux-kernel <[email protected]>; Si- Wei Liu <[email protected]>
Subject: Re: [PATCH] vdpa: Warn if MTU configured is too lowQuoted 1 line · Eli Cohen
Quoted 8 lines
Quoted 6 lines
Following the recommendation in virio spec 1.1, a device offering
VIRTIO_NET_F_MTUshould set the mtu to at least 1280 bytes.Print a warning if this recommendation is not met.
Signed-off-by Eli Cohen <[email protected]>I wonder why it's a must?
It's definitely not a must but I thought if the spec says "should" it deserves a warning but we can drop this if you think the warning is not in place.
Quoted 13 lines
Quoted 13 lines
--- drivers/vdpa/vdpa.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/vdpa/vdpa.c +0
-0@@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MTU ) | \ BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))
Quoted 15 lines
drivers/vdpa/vdpa.c static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i · line 642
Quoted 13 lines
drivers/vdpa/vdpa.c +6
-0+/* Recommended virtio spec 1.1 section 5.1.4.1 */ +#define VIRTIO_MIN_PREFERRED_MTU 1280 +static int vdpa_nl_cmd_dev_add_set_doit (struct sk_buff *skb,struct genl_info *info) {struct vdpa_dev_set_config config = {};@@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i err =PTR_ERR (mdev); goto err; } +if ((mdev->supported_features &BIT_ULL (VIRTIO_NET_F_MTU )) && + (config.mask &BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MTU ) && + config.net.mtu <VIRTIO_MIN_PREFERRED_MTU ))Should be <= ?
I don't think so. If it equals 1280 you don't want to warn.
Quoted 19 lines
Thanks
Quoted 16 lines
drivers/vdpa/vdpa.c +2
-2+pr_warn ("MTU is below recommended value\n" );if ((config.mask & mdev->config_attr_mask) != config.mask) {NL_SET_ERR_MSG_MOD (info->extack,"All provided attributes are not supported" );@@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = { [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING }, [VDPA_ATTR_DEV_NET_CFG_MACADDR ] =NLA_POLICY_ETH_ADDR , /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */ - [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68), + [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU), };static const struct genl_ops vdpa_nl_ops[] = { --2.35.1
Quoted 13 lines · Eli Cohen
Quoted 13 lines
From: Jason Wang <[email protected]>
Sent: Wednesday, May 11, 2022 12:34 PM
To: Eli Cohen <[email protected]>
Cc: mst <[email protected]>; virtualization <[email protected]>; linux-kernel <[email protected]>; Si- Wei Liu <[email protected]>
Subject: Re: [PATCH] vdpa: Warn if MTU configured is too lowQuoted 4 lines · Eli Cohen
Following the recommendation in virio spec 1.1, a device offering
VIRTIO_NET_F_MTUshould set the mtu to at least 1280 bytes.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Print a warning if this recommendation is not met.
Signed-off-by Eli Cohen <[email protected]>I wonder why it's a must?
It's definitely not a must but I thought if the spec says "should" it deserves a warning
Right.
Quoted 1 line
but we can drop this if you think the warning is not in place.
I remember netlink has an extra log buffer, I wonder if it's better to warn there?
Quoted 30 lines
Quoted 14 lines
Quoted 14 lines
--- drivers/vdpa/vdpa.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/vdpa/vdpa.c +0
-0@@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MTU ) | \ BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))Quoted 15 lines
drivers/vdpa/vdpa.c static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i · line 642
Quoted 13 lines
drivers/vdpa/vdpa.c +6
-0+/* Recommended virtio spec 1.1 section 5.1.4.1 */ +#define VIRTIO_MIN_PREFERRED_MTU 1280 +static int vdpa_nl_cmd_dev_add_set_doit (struct sk_buff *skb,struct genl_info *info) {struct vdpa_dev_set_config config = {};@@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i err =PTR_ERR (mdev); goto err; } +if ((mdev->supported_features &BIT_ULL (VIRTIO_NET_F_MTU )) && + (config.mask &BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MTU ) && + config.net.mtu <VIRTIO_MIN_PREFERRED_MTU ))Should be <= ?
Quoted 1 line
I don't think so. If it equals 1280 you don't want to warn.
Yes, you're right.
Thanks
Quoted 16 lines
Quoted 16 lines
Thanks
Quoted 12 lines
drivers/vdpa/vdpa.c +2
-1+pr_warn ("MTU is below recommended value\n" );if ((config.mask & mdev->config_attr_mask) != config.mask) {NL_SET_ERR_MSG_MOD (info->extack,"All provided attributes are not supported" );@@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = { [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING }, [VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,/* virtio spec 1.1 section 5.1.4.1 for valid MTU range */ - [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68), + [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU), };
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
drivers/vdpa/vdpa.c +0
-1static const struct genl_ops vdpa_nl_ops[] = { --2.35.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 28 lines
-----Original Message-----
From: Jason Wang <[email protected]>
Sent: Wednesday, May 11, 2022 1:19 PM
To: Eli Cohen <[email protected]>
Cc: mst <[email protected]>; virtualization <[email protected]>; linux-kernel <[email protected]>; Si- Wei Liu <[email protected]>
Subject: Re: [PATCH] vdpa: Warn if MTU configured is too lowQuoted 19 lines · Eli Cohen
Quoted 18 lines
From: Jason Wang <[email protected]>
Sent: Wednesday, May 11, 2022 12:34 PM
To: Eli Cohen <[email protected]>
Cc: mst <[email protected]>; virtualization <[email protected]>; linux-kernel <[email protected]>; Si- Wei Liu <[email protected]>
Subject: Re: [PATCH] vdpa: Warn if MTU configured is too lowQuoted 7 lines · Eli Cohen
Following the recommendation in virio spec 1.1, a device offering
VIRTIO_NET_F_MTUshould set the mtu to at least 1280 bytes.Print a warning if this recommendation is not met.
Signed-off-by Eli Cohen <[email protected]>I wonder why it's a must?
Quoted 9 lines
Quoted 1 line
It's definitely not a must but I thought if the spec says "should" it deserves a warning
Right.
Quoted 1 line
but we can drop this if you think the warning is not in place.
I remember netlink has an extra log buffer, I wonder if it's better to warn there?
You mean use NL_SET_ERR_MSG_MOD(info->extack, "MTU is below recommended value\n") ? dmesg stays clean but the user gets a warning
Quoted 57 lines
Quoted 30 lines
Quoted 14 lines
Quoted 14 lines
--- drivers/vdpa/vdpa.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/vdpa/vdpa.c +0
-0@@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MTU ) | \ BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))Quoted 15 lines
drivers/vdpa/vdpa.c static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i · line 642
Quoted 13 lines
drivers/vdpa/vdpa.c +6
-0+/* Recommended virtio spec 1.1 section 5.1.4.1 */ +#define VIRTIO_MIN_PREFERRED_MTU 1280 +static int vdpa_nl_cmd_dev_add_set_doit (struct sk_buff *skb,struct genl_info *info) {struct vdpa_dev_set_config config = {};@@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i err =PTR_ERR (mdev); goto err; } +if ((mdev->supported_features &BIT_ULL (VIRTIO_NET_F_MTU )) && + (config.mask &BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MTU ) && + config.net.mtu <VIRTIO_MIN_PREFERRED_MTU ))Should be <= ?
Quoted 1 line
I don't think so. If it equals 1280 you don't want to warn.
Yes, you're right.
Thanks
Quoted 21 lines
Quoted 20 lines
Thanks
Quoted 16 lines
drivers/vdpa/vdpa.c +2
-2+pr_warn ("MTU is below recommended value\n" );if ((config.mask & mdev->config_attr_mask) != config.mask) {NL_SET_ERR_MSG_MOD (info->extack,"All provided attributes are not supported" );@@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = { [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING }, [VDPA_ATTR_DEV_NET_CFG_MACADDR ] =NLA_POLICY_ETH_ADDR , /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */ - [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68), + [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU), };static const struct genl_ops vdpa_nl_ops[] = { --2.35.1