diff mbox series

[net-next,1/3] tipc: set default MTU for UDP media

Message ID 1524128780-2550-2-git-send-email-mohan.krishna.ghanta.krishnamurthy@ericsson.com
State Accepted, archived
Delegated to: David Miller
Headers show
Series tipc: Confgiuration of MTU for media UDP | expand

Commit Message

GhantaKrishnamurthy MohanKrishna April 19, 2018, 9:06 a.m. UTC
Currently, all bearers are configured with MTU value same as the
underlying L2 device. However, in case of bearers with media type
UDP, higher throughput is possible with a fixed and higher emulated
MTU value than adapting to the underlying L2 MTU.

In this commit, we introduce a parameter mtu in struct tipc_media
and a default value is set for UDP. A default value of 14k
was determined by experimentation and found to have a higher throughput
than 16k. MTU for UDP bearers are assigned the above set value of
media MTU.

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>
---
 include/uapi/linux/tipc_config.h | 5 +++++
 net/tipc/udp_media.c             | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

Comments

kernel test robot April 20, 2018, 3:22 p.m. UTC | #1
Hi GhantaKrishnamurthy,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/GhantaKrishnamurthy-MohanKrishna/tipc-Confgiuration-of-MTU-for-media-UDP/20180420-224412
config: x86_64-randconfig-x018-201815 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

Note: the linux-review/GhantaKrishnamurthy-MohanKrishna/tipc-Confgiuration-of-MTU-for-media-UDP/20180420-224412 HEAD 5757244a45c9114ee8a7ed60e9b074107605f6eb builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

   net//tipc/udp_media.c: In function 'tipc_udp_enable':
>> net//tipc/udp_media.c:716:20: error: 'struct tipc_media' has no member named 'mtu'
      b->mtu = b->media->mtu;
                       ^~
   net//tipc/udp_media.c: At top level:
   net//tipc/udp_media.c:805:3: error: 'struct tipc_media' has no member named 'mtu'
     .mtu  = TIPC_DEF_LINK_UDP_MTU,
      ^~~

vim +716 net//tipc/udp_media.c

   632	
   633	/**
   634	 * tipc_udp_enable - callback to create a new udp bearer instance
   635	 * @net:	network namespace
   636	 * @b:		pointer to generic tipc_bearer
   637	 * @attrs:	netlink bearer configuration
   638	 *
   639	 * validate the bearer parameters and initialize the udp bearer
   640	 * rtnl_lock should be held
   641	 */
   642	static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
   643				   struct nlattr *attrs[])
   644	{
   645		int err = -EINVAL;
   646		struct udp_bearer *ub;
   647		struct udp_media_addr remote = {0};
   648		struct udp_media_addr local = {0};
   649		struct udp_port_cfg udp_conf = {0};
   650		struct udp_tunnel_sock_cfg tuncfg = {NULL};
   651		struct nlattr *opts[TIPC_NLA_UDP_MAX + 1];
   652		u8 node_id[NODE_ID_LEN] = {0,};
   653	
   654		ub = kzalloc(sizeof(*ub), GFP_ATOMIC);
   655		if (!ub)
   656			return -ENOMEM;
   657	
   658		INIT_LIST_HEAD(&ub->rcast.list);
   659	
   660		if (!attrs[TIPC_NLA_BEARER_UDP_OPTS])
   661			goto err;
   662	
   663		if (nla_parse_nested(opts, TIPC_NLA_UDP_MAX,
   664				     attrs[TIPC_NLA_BEARER_UDP_OPTS],
   665				     tipc_nl_udp_policy, NULL))
   666			goto err;
   667	
   668		if (!opts[TIPC_NLA_UDP_LOCAL] || !opts[TIPC_NLA_UDP_REMOTE]) {
   669			pr_err("Invalid UDP bearer configuration");
   670			err = -EINVAL;
   671			goto err;
   672		}
   673	
   674		err = tipc_parse_udp_addr(opts[TIPC_NLA_UDP_LOCAL], &local,
   675					  &ub->ifindex);
   676		if (err)
   677			goto err;
   678	
   679		err = tipc_parse_udp_addr(opts[TIPC_NLA_UDP_REMOTE], &remote, NULL);
   680		if (err)
   681			goto err;
   682	
   683		/* Autoconfigure own node identity if needed */
   684		if (!tipc_own_id(net)) {
   685			memcpy(node_id, local.ipv6.in6_u.u6_addr8, 16);
   686			tipc_net_init(net, node_id, 0);
   687		}
   688		if (!tipc_own_id(net)) {
   689			pr_warn("Failed to set node id, please configure manually\n");
   690			err = -EINVAL;
   691			goto err;
   692		}
   693	
   694		b->bcast_addr.media_id = TIPC_MEDIA_TYPE_UDP;
   695		b->bcast_addr.broadcast = TIPC_BROADCAST_SUPPORT;
   696		rcu_assign_pointer(b->media_ptr, ub);
   697		rcu_assign_pointer(ub->bearer, b);
   698		tipc_udp_media_addr_set(&b->addr, &local);
   699		if (local.proto == htons(ETH_P_IP)) {
   700			struct net_device *dev;
   701	
   702			dev = __ip_dev_find(net, local.ipv4.s_addr, false);
   703			if (!dev) {
   704				err = -ENODEV;
   705				goto err;
   706			}
   707			udp_conf.family = AF_INET;
   708			udp_conf.local_ip.s_addr = htonl(INADDR_ANY);
   709			udp_conf.use_udp_checksums = false;
   710			ub->ifindex = dev->ifindex;
   711			if (tipc_mtu_bad(dev, sizeof(struct iphdr) +
   712					      sizeof(struct udphdr))) {
   713				err = -EINVAL;
   714				goto err;
   715			}
 > 716			b->mtu = b->media->mtu;
   717	#if IS_ENABLED(CONFIG_IPV6)
   718		} else if (local.proto == htons(ETH_P_IPV6)) {
   719			udp_conf.family = AF_INET6;
   720			udp_conf.use_udp6_tx_checksums = true;
   721			udp_conf.use_udp6_rx_checksums = true;
   722			udp_conf.local_ip6 = in6addr_any;
   723			b->mtu = 1280;
   724	#endif
   725		} else {
   726			err = -EAFNOSUPPORT;
   727			goto err;
   728		}
   729		udp_conf.local_udp_port = local.port;
   730		err = udp_sock_create(net, &udp_conf, &ub->ubsock);
   731		if (err)
   732			goto err;
   733		tuncfg.sk_user_data = ub;
   734		tuncfg.encap_type = 1;
   735		tuncfg.encap_rcv = tipc_udp_recv;
   736		tuncfg.encap_destroy = NULL;
   737		setup_udp_tunnel_sock(net, ub->ubsock, &tuncfg);
   738	
   739		/**
   740		 * The bcast media address port is used for all peers and the ip
   741		 * is used if it's a multicast address.
   742		 */
   743		memcpy(&b->bcast_addr.value, &remote, sizeof(remote));
   744		if (tipc_udp_is_mcast_addr(&remote))
   745			err = enable_mcast(ub, &remote);
   746		else
   747			err = tipc_udp_rcast_add(b, &remote);
   748		if (err)
   749			goto err;
   750	
   751		return 0;
   752	err:
   753		if (ub->ubsock)
   754			udp_tunnel_sock_release(ub->ubsock);
   755		kfree(ub);
   756		return err;
   757	}
   758	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot April 20, 2018, 4:06 p.m. UTC | #2
Hi GhantaKrishnamurthy,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/GhantaKrishnamurthy-MohanKrishna/tipc-Confgiuration-of-MTU-for-media-UDP/20180420-224412
config: i386-randconfig-a0-201815 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

Note: the linux-review/GhantaKrishnamurthy-MohanKrishna/tipc-Confgiuration-of-MTU-for-media-UDP/20180420-224412 HEAD 5757244a45c9114ee8a7ed60e9b074107605f6eb builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

   net/tipc/udp_media.c: In function 'tipc_udp_enable':
   net/tipc/udp_media.c:716:20: error: 'struct tipc_media' has no member named 'mtu'
      b->mtu = b->media->mtu;
                       ^
   net/tipc/udp_media.c: At top level:
>> net/tipc/udp_media.c:805:2: error: unknown field 'mtu' specified in initializer
     .mtu  = TIPC_DEF_LINK_UDP_MTU,
     ^

vim +/mtu +805 net/tipc/udp_media.c

   632	
   633	/**
   634	 * tipc_udp_enable - callback to create a new udp bearer instance
   635	 * @net:	network namespace
   636	 * @b:		pointer to generic tipc_bearer
   637	 * @attrs:	netlink bearer configuration
   638	 *
   639	 * validate the bearer parameters and initialize the udp bearer
   640	 * rtnl_lock should be held
   641	 */
   642	static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
   643				   struct nlattr *attrs[])
   644	{
   645		int err = -EINVAL;
   646		struct udp_bearer *ub;
   647		struct udp_media_addr remote = {0};
   648		struct udp_media_addr local = {0};
   649		struct udp_port_cfg udp_conf = {0};
   650		struct udp_tunnel_sock_cfg tuncfg = {NULL};
   651		struct nlattr *opts[TIPC_NLA_UDP_MAX + 1];
   652		u8 node_id[NODE_ID_LEN] = {0,};
   653	
   654		ub = kzalloc(sizeof(*ub), GFP_ATOMIC);
   655		if (!ub)
   656			return -ENOMEM;
   657	
   658		INIT_LIST_HEAD(&ub->rcast.list);
   659	
   660		if (!attrs[TIPC_NLA_BEARER_UDP_OPTS])
   661			goto err;
   662	
   663		if (nla_parse_nested(opts, TIPC_NLA_UDP_MAX,
   664				     attrs[TIPC_NLA_BEARER_UDP_OPTS],
   665				     tipc_nl_udp_policy, NULL))
   666			goto err;
   667	
   668		if (!opts[TIPC_NLA_UDP_LOCAL] || !opts[TIPC_NLA_UDP_REMOTE]) {
   669			pr_err("Invalid UDP bearer configuration");
   670			err = -EINVAL;
   671			goto err;
   672		}
   673	
   674		err = tipc_parse_udp_addr(opts[TIPC_NLA_UDP_LOCAL], &local,
   675					  &ub->ifindex);
   676		if (err)
   677			goto err;
   678	
   679		err = tipc_parse_udp_addr(opts[TIPC_NLA_UDP_REMOTE], &remote, NULL);
   680		if (err)
   681			goto err;
   682	
   683		/* Autoconfigure own node identity if needed */
   684		if (!tipc_own_id(net)) {
   685			memcpy(node_id, local.ipv6.in6_u.u6_addr8, 16);
   686			tipc_net_init(net, node_id, 0);
   687		}
   688		if (!tipc_own_id(net)) {
   689			pr_warn("Failed to set node id, please configure manually\n");
   690			err = -EINVAL;
   691			goto err;
   692		}
   693	
   694		b->bcast_addr.media_id = TIPC_MEDIA_TYPE_UDP;
   695		b->bcast_addr.broadcast = TIPC_BROADCAST_SUPPORT;
   696		rcu_assign_pointer(b->media_ptr, ub);
   697		rcu_assign_pointer(ub->bearer, b);
   698		tipc_udp_media_addr_set(&b->addr, &local);
   699		if (local.proto == htons(ETH_P_IP)) {
   700			struct net_device *dev;
   701	
   702			dev = __ip_dev_find(net, local.ipv4.s_addr, false);
   703			if (!dev) {
   704				err = -ENODEV;
   705				goto err;
   706			}
   707			udp_conf.family = AF_INET;
   708			udp_conf.local_ip.s_addr = htonl(INADDR_ANY);
   709			udp_conf.use_udp_checksums = false;
   710			ub->ifindex = dev->ifindex;
   711			if (tipc_mtu_bad(dev, sizeof(struct iphdr) +
   712					      sizeof(struct udphdr))) {
   713				err = -EINVAL;
   714				goto err;
   715			}
 > 716			b->mtu = b->media->mtu;
   717	#if IS_ENABLED(CONFIG_IPV6)
   718		} else if (local.proto == htons(ETH_P_IPV6)) {
   719			udp_conf.family = AF_INET6;
   720			udp_conf.use_udp6_tx_checksums = true;
   721			udp_conf.use_udp6_rx_checksums = true;
   722			udp_conf.local_ip6 = in6addr_any;
   723			b->mtu = 1280;
   724	#endif
   725		} else {
   726			err = -EAFNOSUPPORT;
   727			goto err;
   728		}
   729		udp_conf.local_udp_port = local.port;
   730		err = udp_sock_create(net, &udp_conf, &ub->ubsock);
   731		if (err)
   732			goto err;
   733		tuncfg.sk_user_data = ub;
   734		tuncfg.encap_type = 1;
   735		tuncfg.encap_rcv = tipc_udp_recv;
   736		tuncfg.encap_destroy = NULL;
   737		setup_udp_tunnel_sock(net, ub->ubsock, &tuncfg);
   738	
   739		/**
   740		 * The bcast media address port is used for all peers and the ip
   741		 * is used if it's a multicast address.
   742		 */
   743		memcpy(&b->bcast_addr.value, &remote, sizeof(remote));
   744		if (tipc_udp_is_mcast_addr(&remote))
   745			err = enable_mcast(ub, &remote);
   746		else
   747			err = tipc_udp_rcast_add(b, &remote);
   748		if (err)
   749			goto err;
   750	
   751		return 0;
   752	err:
   753		if (ub->ubsock)
   754			udp_tunnel_sock_release(ub->ubsock);
   755		kfree(ub);
   756		return err;
   757	}
   758	
   759	/* cleanup_bearer - break the socket/bearer association */
   760	static void cleanup_bearer(struct work_struct *work)
   761	{
   762		struct udp_bearer *ub = container_of(work, struct udp_bearer, work);
   763		struct udp_replicast *rcast, *tmp;
   764	
   765		list_for_each_entry_safe(rcast, tmp, &ub->rcast.list, list) {
   766			list_del_rcu(&rcast->list);
   767			kfree_rcu(rcast, rcu);
   768		}
   769	
   770		if (ub->ubsock)
   771			udp_tunnel_sock_release(ub->ubsock);
   772		synchronize_net();
   773		kfree(ub);
   774	}
   775	
   776	/* tipc_udp_disable - detach bearer from socket */
   777	static void tipc_udp_disable(struct tipc_bearer *b)
   778	{
   779		struct udp_bearer *ub;
   780	
   781		ub = rcu_dereference_rtnl(b->media_ptr);
   782		if (!ub) {
   783			pr_err("UDP bearer instance not found\n");
   784			return;
   785		}
   786		if (ub->ubsock)
   787			sock_set_flag(ub->ubsock->sk, SOCK_DEAD);
   788		RCU_INIT_POINTER(ub->bearer, NULL);
   789	
   790		/* sock_release need to be done outside of rtnl lock */
   791		INIT_WORK(&ub->work, cleanup_bearer);
   792		schedule_work(&ub->work);
   793	}
   794	
   795	struct tipc_media udp_media_info = {
   796		.send_msg	= tipc_udp_send_msg,
   797		.enable_media	= tipc_udp_enable,
   798		.disable_media	= tipc_udp_disable,
   799		.addr2str	= tipc_udp_addr2str,
   800		.addr2msg	= tipc_udp_addr2msg,
   801		.msg2addr	= tipc_udp_msg2addr,
   802		.priority	= TIPC_DEF_LINK_PRI,
   803		.tolerance	= TIPC_DEF_LINK_TOL,
   804		.window		= TIPC_DEF_LINK_WIN,
 > 805		.mtu		= TIPC_DEF_LINK_UDP_MTU,

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/include/uapi/linux/tipc_config.h b/include/uapi/linux/tipc_config.h
index 3f29e3c8ed06..4b2c93b1934c 100644
--- a/include/uapi/linux/tipc_config.h
+++ b/include/uapi/linux/tipc_config.h
@@ -185,6 +185,11 @@ 
 #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 */
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index e7d91f5d5cae..9783101bc4a9 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -713,8 +713,7 @@  static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
 			err = -EINVAL;
 			goto err;
 		}
-		b->mtu = dev->mtu - sizeof(struct iphdr)
-			- sizeof(struct udphdr);
+		b->mtu = b->media->mtu;
 #if IS_ENABLED(CONFIG_IPV6)
 	} else if (local.proto == htons(ETH_P_IPV6)) {
 		udp_conf.family = AF_INET6;
@@ -803,6 +802,7 @@  struct tipc_media udp_media_info = {
 	.priority	= TIPC_DEF_LINK_PRI,
 	.tolerance	= TIPC_DEF_LINK_TOL,
 	.window		= TIPC_DEF_LINK_WIN,
+	.mtu		= TIPC_DEF_LINK_UDP_MTU,
 	.type_id	= TIPC_MEDIA_TYPE_UDP,
 	.hwaddr_len	= 0,
 	.name		= "udp"