Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

GhantaKrishnamurthy MohanKrishna and committed by
David S. Miller
901271e0 a4dfa72d

+31
+1
include/uapi/linux/tipc_netlink.h
··· 266 266 TIPC_NLA_PROP_PRIO, /* u32 */ 267 267 TIPC_NLA_PROP_TOL, /* u32 */ 268 268 TIPC_NLA_PROP_WIN, /* u32 */ 269 + TIPC_NLA_PROP_MTU, /* u32 */ 269 270 270 271 __TIPC_NLA_PROP_MAX, 271 272 TIPC_NLA_PROP_MAX = __TIPC_NLA_PROP_MAX - 1
+13
net/tipc/bearer.c
··· 1029 1029 goto prop_msg_full; 1030 1030 if (nla_put_u32(msg->skb, TIPC_NLA_PROP_WIN, media->window)) 1031 1031 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; 1032 1035 1033 1036 nla_nest_end(msg->skb, prop); 1034 1037 nla_nest_end(msg->skb, attrs); ··· 1161 1158 m->priority = nla_get_u32(props[TIPC_NLA_PROP_PRIO]); 1162 1159 if (props[TIPC_NLA_PROP_WIN]) 1163 1160 m->window = nla_get_u32(props[TIPC_NLA_PROP_WIN]); 1161 + if (props[TIPC_NLA_PROP_MTU]) { 1162 + if (m->type_id != TIPC_MEDIA_TYPE_UDP) 1163 + return -EINVAL; 1164 + #ifdef CONFIG_TIPC_MEDIA_UDP 1165 + if (tipc_udp_mtu_bad(nla_get_u32 1166 + (props[TIPC_NLA_PROP_MTU]))) 1167 + return -EINVAL; 1168 + m->mtu = nla_get_u32(props[TIPC_NLA_PROP_MTU]); 1169 + #endif 1170 + } 1164 1171 } 1165 1172 1166 1173 return 0;
+3
net/tipc/bearer.h
··· 94 94 * @priority: default link (and bearer) priority 95 95 * @tolerance: default time (in ms) before declaring link failure 96 96 * @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 97 99 * @type_id: TIPC media identifier 98 100 * @hwaddr_len: TIPC media address len 99 101 * @name: media name ··· 120 118 u32 priority; 121 119 u32 tolerance; 122 120 u32 window; 121 + u32 mtu; 123 122 u32 type_id; 124 123 u32 hwaddr_len; 125 124 char name[TIPC_MAX_MEDIA_NAME];
+14
net/tipc/udp_media.h
··· 38 38 #ifndef _TIPC_UDP_MEDIA_H 39 39 #define _TIPC_UDP_MEDIA_H 40 40 41 + #include <linux/ip.h> 42 + #include <linux/udp.h> 43 + 41 44 int tipc_udp_nl_bearer_add(struct tipc_bearer *b, struct nlattr *attr); 42 45 int tipc_udp_nl_add_bearer_data(struct tipc_nl_msg *msg, struct tipc_bearer *b); 43 46 int tipc_udp_nl_dump_remoteip(struct sk_buff *skb, struct netlink_callback *cb); 47 + 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 + } 44 58 45 59 #endif 46 60 #endif