Skip to content

Commit ddf967b

Browse files
committed
Merge branch 'tipc-Confgiuration-of-MTU-for-media-UDP'
GhantaKrishnamurthy MohanKrishna says: ==================== tipc: Confgiuration of MTU for media UDP Systematic measurements have shown that an emulated MTU of 14k for UDP bearers is the optimal value for maximal throughput. Accordingly, the default MTU of UDP bearers is changed to 14k. We also provide users with a fallback option from this value, by providing support to configure MTU for UDP bearers. The following options are introduced which are symmetrical to the design of confguring link tolerance. - Configure media with new MTU value, which will take effect on links going up after the moment it was configured. Alternatively, the bearer has to be disabled and re-enabled, for existing links to reflect the configured value. - Configure bearer with new MTU value, which take effect on running links dynamically. Please note: - User has to change MTU at both endpoints, otherwise the link will fall back to smallest MTU after a reset. - Failover from a link with higher MTU to a link with lower MTU ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents cea395a + 682cd3c commit ddf967b

File tree

8 files changed

+63
-7
lines changed

8 files changed

+63
-7
lines changed

include/uapi/linux/tipc_config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@
185185
#define TIPC_DEF_LINK_WIN 50
186186
#define TIPC_MAX_LINK_WIN 8191
187187

188+
/*
189+
* Default MTU for UDP media
190+
*/
191+
192+
#define TIPC_DEF_LINK_UDP_MTU 14000
188193

189194
struct tipc_node_info {
190195
__be32 addr; /* network address of node */

include/uapi/linux/tipc_netlink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ enum {
266266
TIPC_NLA_PROP_PRIO, /* u32 */
267267
TIPC_NLA_PROP_TOL, /* u32 */
268268
TIPC_NLA_PROP_WIN, /* u32 */
269+
TIPC_NLA_PROP_MTU, /* u32 */
269270

270271
__TIPC_NLA_PROP_MAX,
271272
TIPC_NLA_PROP_MAX = __TIPC_NLA_PROP_MAX - 1

net/tipc/bearer.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,9 @@ static int __tipc_nl_add_bearer(struct tipc_nl_msg *msg,
697697
goto prop_msg_full;
698698
if (nla_put_u32(msg->skb, TIPC_NLA_PROP_WIN, bearer->window))
699699
goto prop_msg_full;
700+
if (bearer->media->type_id == TIPC_MEDIA_TYPE_UDP)
701+
if (nla_put_u32(msg->skb, TIPC_NLA_PROP_MTU, bearer->mtu))
702+
goto prop_msg_full;
700703

701704
nla_nest_end(msg->skb, prop);
702705

@@ -979,12 +982,23 @@ int __tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info)
979982

980983
if (props[TIPC_NLA_PROP_TOL]) {
981984
b->tolerance = nla_get_u32(props[TIPC_NLA_PROP_TOL]);
982-
tipc_node_apply_tolerance(net, b);
985+
tipc_node_apply_property(net, b, TIPC_NLA_PROP_TOL);
983986
}
984987
if (props[TIPC_NLA_PROP_PRIO])
985988
b->priority = nla_get_u32(props[TIPC_NLA_PROP_PRIO]);
986989
if (props[TIPC_NLA_PROP_WIN])
987990
b->window = nla_get_u32(props[TIPC_NLA_PROP_WIN]);
991+
if (props[TIPC_NLA_PROP_MTU]) {
992+
if (b->media->type_id != TIPC_MEDIA_TYPE_UDP)
993+
return -EINVAL;
994+
#ifdef CONFIG_TIPC_MEDIA_UDP
995+
if (tipc_udp_mtu_bad(nla_get_u32
996+
(props[TIPC_NLA_PROP_MTU])))
997+
return -EINVAL;
998+
b->mtu = nla_get_u32(props[TIPC_NLA_PROP_MTU]);
999+
tipc_node_apply_property(net, b, TIPC_NLA_PROP_MTU);
1000+
#endif
1001+
}
9881002
}
9891003

9901004
return 0;
@@ -1029,6 +1043,9 @@ static int __tipc_nl_add_media(struct tipc_nl_msg *msg,
10291043
goto prop_msg_full;
10301044
if (nla_put_u32(msg->skb, TIPC_NLA_PROP_WIN, media->window))
10311045
goto prop_msg_full;
1046+
if (media->type_id == TIPC_MEDIA_TYPE_UDP)
1047+
if (nla_put_u32(msg->skb, TIPC_NLA_PROP_MTU, media->mtu))
1048+
goto prop_msg_full;
10321049

10331050
nla_nest_end(msg->skb, prop);
10341051
nla_nest_end(msg->skb, attrs);
@@ -1158,6 +1175,16 @@ int __tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info)
11581175
m->priority = nla_get_u32(props[TIPC_NLA_PROP_PRIO]);
11591176
if (props[TIPC_NLA_PROP_WIN])
11601177
m->window = nla_get_u32(props[TIPC_NLA_PROP_WIN]);
1178+
if (props[TIPC_NLA_PROP_MTU]) {
1179+
if (m->type_id != TIPC_MEDIA_TYPE_UDP)
1180+
return -EINVAL;
1181+
#ifdef CONFIG_TIPC_MEDIA_UDP
1182+
if (tipc_udp_mtu_bad(nla_get_u32
1183+
(props[TIPC_NLA_PROP_MTU])))
1184+
return -EINVAL;
1185+
m->mtu = nla_get_u32(props[TIPC_NLA_PROP_MTU]);
1186+
#endif
1187+
}
11611188
}
11621189

11631190
return 0;

net/tipc/bearer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ struct tipc_bearer;
9494
* @priority: default link (and bearer) priority
9595
* @tolerance: default time (in ms) before declaring link failure
9696
* @window: default window (in packets) before declaring link congestion
97+
* @mtu: max packet size bearer can support for media type not dependent on
98+
* underlying device MTU
9799
* @type_id: TIPC media identifier
98100
* @hwaddr_len: TIPC media address len
99101
* @name: media name
@@ -118,6 +120,7 @@ struct tipc_media {
118120
u32 priority;
119121
u32 tolerance;
120122
u32 window;
123+
u32 mtu;
121124
u32 type_id;
122125
u32 hwaddr_len;
123126
char name[TIPC_MAX_MEDIA_NAME];

net/tipc/node.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,8 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b)
16811681
kfree_skb(skb);
16821682
}
16831683

1684-
void tipc_node_apply_tolerance(struct net *net, struct tipc_bearer *b)
1684+
void tipc_node_apply_property(struct net *net, struct tipc_bearer *b,
1685+
int prop)
16851686
{
16861687
struct tipc_net *tn = tipc_net(net);
16871688
int bearer_id = b->identity;
@@ -1696,8 +1697,13 @@ void tipc_node_apply_tolerance(struct net *net, struct tipc_bearer *b)
16961697
list_for_each_entry_rcu(n, &tn->node_list, list) {
16971698
tipc_node_write_lock(n);
16981699
e = &n->links[bearer_id];
1699-
if (e->link)
1700-
tipc_link_set_tolerance(e->link, b->tolerance, &xmitq);
1700+
if (e->link) {
1701+
if (prop == TIPC_NLA_PROP_TOL)
1702+
tipc_link_set_tolerance(e->link, b->tolerance,
1703+
&xmitq);
1704+
else if (prop == TIPC_NLA_PROP_MTU)
1705+
tipc_link_set_mtu(e->link, b->mtu);
1706+
}
17011707
tipc_node_write_unlock(n);
17021708
tipc_bearer_xmit(net, bearer_id, &xmitq, &e->maddr);
17031709
}

net/tipc/node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void tipc_node_check_dest(struct net *net, u32 onode, u8 *peer_id128,
6767
struct tipc_media_addr *maddr,
6868
bool *respond, bool *dupl_addr);
6969
void tipc_node_delete_links(struct net *net, int bearer_id);
70-
void tipc_node_apply_tolerance(struct net *net, struct tipc_bearer *b);
70+
void tipc_node_apply_property(struct net *net, struct tipc_bearer *b, int prop);
7171
int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 node,
7272
char *linkname, size_t len);
7373
int tipc_node_xmit(struct net *net, struct sk_buff_head *list, u32 dnode,

net/tipc/udp_media.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
713713
err = -EINVAL;
714714
goto err;
715715
}
716-
b->mtu = dev->mtu - sizeof(struct iphdr)
717-
- sizeof(struct udphdr);
716+
b->mtu = b->media->mtu;
718717
#if IS_ENABLED(CONFIG_IPV6)
719718
} else if (local.proto == htons(ETH_P_IPV6)) {
720719
udp_conf.family = AF_INET6;
@@ -803,6 +802,7 @@ struct tipc_media udp_media_info = {
803802
.priority = TIPC_DEF_LINK_PRI,
804803
.tolerance = TIPC_DEF_LINK_TOL,
805804
.window = TIPC_DEF_LINK_WIN,
805+
.mtu = TIPC_DEF_LINK_UDP_MTU,
806806
.type_id = TIPC_MEDIA_TYPE_UDP,
807807
.hwaddr_len = 0,
808808
.name = "udp"

net/tipc/udp_media.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,23 @@
3838
#ifndef _TIPC_UDP_MEDIA_H
3939
#define _TIPC_UDP_MEDIA_H
4040

41+
#include <linux/ip.h>
42+
#include <linux/udp.h>
43+
4144
int tipc_udp_nl_bearer_add(struct tipc_bearer *b, struct nlattr *attr);
4245
int tipc_udp_nl_add_bearer_data(struct tipc_nl_msg *msg, struct tipc_bearer *b);
4346
int tipc_udp_nl_dump_remoteip(struct sk_buff *skb, struct netlink_callback *cb);
4447

48+
/* check if configured MTU is too low for tipc headers */
49+
static inline bool tipc_udp_mtu_bad(u32 mtu)
50+
{
51+
if (mtu >= (TIPC_MIN_BEARER_MTU + sizeof(struct iphdr) +
52+
sizeof(struct udphdr)))
53+
return false;
54+
55+
pr_warn("MTU too low for tipc bearer\n");
56+
return true;
57+
}
58+
4559
#endif
4660
#endif

0 commit comments

Comments
 (0)