]> git.itanic.dy.fi Git - linux-stable/commitdiff
tipc: check the bearer min mtu properly when setting it by netlink
authorXin Long <lucien.xin@gmail.com>
Sun, 14 May 2023 19:52:29 +0000 (15:52 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 May 2023 16:32:46 +0000 (17:32 +0100)
[ Upstream commit 35a089b5d793d2bfd2cc7cfa6104545184de2ce7 ]

Checking the bearer min mtu with tipc_udp_mtu_bad() only works for
IPv4 UDP bearer, and IPv6 UDP bearer has a different value for the
min mtu. This patch checks with encap_hlen + TIPC_MIN_BEARER_MTU
for min mtu, which works for both IPv4 and IPv6 UDP bearer.

Note that tipc_udp_mtu_bad() is still used to check media min mtu
in __tipc_nl_media_set(), as m->mtu currently is only used by the
IPv4 UDP bearer as its default mtu value.

Fixes: 682cd3cf946b ("tipc: confgiure and apply UDP bearer MTU on running links")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Jon Maloy <jmaloy@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/tipc/bearer.c

index 0e9a29e1536b774933b7ab9f92c60846c00973dc..53881406e2006c0204e7e87e6604759a9f697c61 100644 (file)
@@ -1151,8 +1151,8 @@ int __tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info)
                                return -EINVAL;
                        }
 #ifdef CONFIG_TIPC_MEDIA_UDP
-                       if (tipc_udp_mtu_bad(nla_get_u32
-                                            (props[TIPC_NLA_PROP_MTU]))) {
+                       if (nla_get_u32(props[TIPC_NLA_PROP_MTU]) <
+                           b->encap_hlen + TIPC_MIN_BEARER_MTU) {
                                NL_SET_ERR_MSG(info->extack,
                                               "MTU value is out-of-range");
                                return -EINVAL;