Instead of using 14000 for ipv4/udp mtu, and 1280 for ipv6/udp
mtu, this patch to set mtu according to the lower device's mtu
at the beginning. The pmtu will be determined by the PLPMTUD
probe in the following patches.

Signed-off-by: Xin Long <lucien....@gmail.com>
---
 include/uapi/linux/tipc_config.h | 6 ------
 net/tipc/udp_media.c             | 8 ++++----
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/include/uapi/linux/tipc_config.h b/include/uapi/linux/tipc_config.h
index 4dfc05651c98..7e23b7f438b4 100644
--- a/include/uapi/linux/tipc_config.h
+++ b/include/uapi/linux/tipc_config.h
@@ -185,12 +185,6 @@
 #define TIPC_DEF_LINK_WIN 50
 #define TIPC_MAX_LINK_WIN 8191
 
-/*
- * Default MTU for UDP media
- */
-
-#define TIPC_DEF_LINK_UDP_MTU 14000
-
 struct tipc_node_info {
        __be32 addr;                    /* network address of node */
        __be32 up;                      /* 0=down, 1= up */
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index c2bb818704c8..dc4bae965549 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -661,7 +661,7 @@ int tipc_udp_nl_bearer_add(struct tipc_bearer *b, struct 
nlattr *attr)
 static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
                           struct nlattr *attrs[])
 {
-       int err = -EINVAL;
+       int err = -EINVAL, hlen;
        struct udp_bearer *ub;
        struct udp_media_addr remote = {0};
        struct udp_media_addr local = {0};
@@ -743,7 +743,7 @@ static int tipc_udp_enable(struct net *net, struct 
tipc_bearer *b,
                        err = -EINVAL;
                        goto err;
                }
-               b->mtu = b->media->mtu;
+               hlen = sizeof(struct iphdr);
 #if IS_ENABLED(CONFIG_IPV6)
        } else if (local.proto == htons(ETH_P_IPV6)) {
                dev = ub->ifindex ? __dev_get_by_index(net, ub->ifindex) : NULL;
@@ -760,12 +760,13 @@ static int tipc_udp_enable(struct net *net, struct 
tipc_bearer *b,
                else
                        udp_conf.local_ip6 = local.ipv6;
                ub->ifindex = dev->ifindex;
-               b->mtu = 1280;
+               hlen = sizeof(struct ipv6hdr);
 #endif
        } else {
                err = -EAFNOSUPPORT;
                goto err;
        }
+       b->mtu = b->media->mtu ?: dev->mtu - hlen - sizeof(struct udphdr);
        udp_conf.local_udp_port = local.port;
        err = udp_sock_create(net, &udp_conf, &ub->ubsock);
        if (err)
@@ -851,7 +852,6 @@ struct tipc_media udp_media_info = {
        .tolerance      = TIPC_DEF_LINK_TOL,
        .min_win        = TIPC_DEF_LINK_WIN,
        .max_win        = TIPC_DEF_LINK_WIN,
-       .mtu            = TIPC_DEF_LINK_UDP_MTU,
        .type_id        = TIPC_MEDIA_TYPE_UDP,
        .hwaddr_len     = 0,
        .name           = "udp"
-- 
2.27.0



_______________________________________________
tipc-discussion mailing list
tipc-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tipc-discussion

Reply via email to