Skip to content

Commit 901271e

Browse files
GhantaKrishnamurthy MohanKrishnadavem330
authored andcommitted
tipc: implement configuration of UDP media MTU
In previous commit, we changed the default emulated MTU for UDP bearers to 14k. This commit adds the functionality to set/change the default value by configuring new MTU for UDP media. UDP bearer(s) have to be disabled and enabled back for the new MTU to take effect. Acked-by: Ying Xue <ying.xue@windriver.com> Acked-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: GhantaKrishnamurthy MohanKrishna <mohan.krishna.ghanta.krishnamurthy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a4dfa72 commit 901271e

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,9 @@ static int __tipc_nl_add_media(struct tipc_nl_msg *msg,
10291029
goto prop_msg_full;
10301030
if (nla_put_u32(msg->skb, TIPC_NLA_PROP_WIN, media->window))
10311031
goto prop_msg_full;
1032+
if (media->type_id == TIPC_MEDIA_TYPE_UDP)
1033+
if (nla_put_u32(msg->skb, TIPC_NLA_PROP_MTU, media->mtu))
1034+
goto prop_msg_full;
10321035

10331036
nla_nest_end(msg->skb, prop);
10341037
nla_nest_end(msg->skb, attrs);
@@ -1158,6 +1161,16 @@ int __tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info)
11581161
m->priority = nla_get_u32(props[TIPC_NLA_PROP_PRIO]);
11591162
if (props[TIPC_NLA_PROP_WIN])
11601163
m->window = nla_get_u32(props[TIPC_NLA_PROP_WIN]);
1164+
if (props[TIPC_NLA_PROP_MTU]) {
1165+
if (m->type_id != TIPC_MEDIA_TYPE_UDP)
1166+
return -EINVAL;
1167+
#ifdef CONFIG_TIPC_MEDIA_UDP
1168+
if (tipc_udp_mtu_bad(nla_get_u32
1169+
(props[TIPC_NLA_PROP_MTU])))
1170+
return -EINVAL;
1171+
m->mtu = nla_get_u32(props[TIPC_NLA_PROP_MTU]);
1172+
#endif
1173+
}
11611174
}
11621175

11631176
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/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)