Skip to contentSkip to conversation

rds: IPv6 support

PATCH Superseded Ka-Cheong Poon 5 participants 18 messages Jun 25, 2018 – Jun 27, 2018

Subsystems (3)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover rds: IPv6 support

This patch set adds IPv6 support to the kernel RDS and related modules. Existing RDS apps using IPv4 address continue to run without any problem. New RDS apps which want to use IPv6 address can do so by passing the address in struct sockaddr_in6 to bind(), connect() or sendmsg(). And those apps also need to use the new IPv6 equivalents of some of the existing socket options as the existing options use a 32 bit integer to store IP address.

All RDS code now use struct in6_addr to store IP address. IPv4 address is stored as an IPv4 mapped address.

Header file changes

There are many data structures (RDS socket options) used by RDS apps which use a 32 bit integer to store IP address. To support IPv6, struct in6_addr needs to be used. To ensure backward compatibility, a new data structure is introduced for each of those data structures which use a 32 bit integer to represent an IP address. And new socket options are introduced to use those new structures. This means that existing apps should work without a problem with the new RDS module. For apps which want to use IPv6, those new data structures and socket options can be used. IPv4 mapped address is used to represent IPv4 address in the new data structures.

Internally, all RDS data structures which contain an IP address are changed to use struct in6_addr to store the address. IPv4 address is stored as an IPv4 mapped address. All the functions which take an IP address as argument are also changed to use struct in6_addr.

RDS/RDMA/IB uses a private data (struct rds_ib_connect_private) exchange between endpoints at RDS connection establishment time to support RDMA. This private data exchange uses a 32 bit integer to represent an IP address. This needs to be changed in order to support IPv6. A new private data struct rds6_ib_connect_private is introduced to handle this. To ensure backward compatibility, an IPv6 capable RDS stack uses another RDMA listener port (RDS_CM_PORT) to accept IPv6 connection. And it continues to use the original RDS_PORT for IPv4 RDS connections. When it needs to communicate with an IPv6 peer, it uses the RDS_TCP_PORT to send the connection set up request.

RDS/TCP changes

TCP related code is changed to support IPv6. Note that only an IPv6 TCP listener on port RDS_TCP_PORT is created as it can accept both IPv4 and IPv6 connection requests.

IB/RDMA changes

The initial private data exchange between IB endpoints using RDMA is changed to support IPv6 address instead, if the peer address is IPv6. To ensure backward compatibility, annother RDMA listener port (RDS_CM_PORT) is used to accept IPv6 connection. An IPv6 capable RDS module continues to use the original RDS_PORT for IPv4 RDS connections. When it needs to communicate with an IPv6 peer, it uses the RDS_CM_PORT to send the connection set up request.

Ka-Cheong Poon (3):
rds: Changing IP address internal representation to struct in6_addr
rds: Enable RDS IPv6 support
rds: Extend RDS API for IPv6 support

 include/uapi/linux/rds.h |  71 ++++++++++-
 net/rds/af_rds.c         | 138 ++++++++++++++++------
 net/rds/bind.c           | 106 ++++++++++++-----
 net/rds/cong.c           |  23 ++--
 net/rds/connection.c     | 246 ++++++++++++++++++++++++++++----------
 net/rds/ib.c             | 114 ++++++++++++++++--
 net/rds/ib.h             |  45 +++++--
 net/rds/ib_cm.c          | 301 +++++++++++++++++++++++++++++++++++------------
 net/rds/ib_mr.h          |   2 +
 net/rds/ib_rdma.c        |  24 ++--
 net/rds/ib_recv.c        |  18 +--
 net/rds/ib_send.c        |  10 +-
 net/rds/loop.c           |   7 +-
 net/rds/rdma.c           |   6 +-
 net/rds/rdma_transport.c |  84 ++++++++++---
 net/rds/rdma_transport.h |   2 +
 net/rds/rds.h            |  85 ++++++++-----
 net/rds/recv.c           |  76 +++++++++---
 net/rds/send.c           |  86 +++++++++++---
 net/rds/tcp.c            | 129 ++++++++++++++++----
 net/rds/tcp.h            |   4 +-
 net/rds/tcp_connect.c    |  68 ++++++++---
 net/rds/tcp_listen.c     |  58 ++++++---
 net/rds/tcp_recv.c       |   9 +-
 net/rds/tcp_send.c       |   4 +-
 net/rds/threads.c        |  69 +++++++++--
 net/rds/transport.c      |  15 ++-
 27 files changed, 1378 insertions(+), 422 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/3 rds: Changing IP address internal representation to struct in6_addr

This patch changes the internal representation of an IP address to use struct in6_addr. IPv4 address is stored as an IPv4 mapped address. All the functions which take an IP address as argument are also changed to use struct in6_addr. But RDS socket layer is not modified such that it still does not accept IPv6 address from an application. And RDS layer does not accept nor initiate IPv6 connections.

---
 net/rds/af_rds.c         | 138 ++++++++++++++++------
 net/rds/bind.c           |  91 +++++++++-----
 net/rds/cong.c           |  23 ++--
 net/rds/connection.c     | 132 +++++++++++++--------
 net/rds/ib.c             |  17 +--
 net/rds/ib.h             |  45 +++++--
 net/rds/ib_cm.c          | 300 +++++++++++++++++++++++++++++++++++------------
 net/rds/ib_rdma.c        |  15 +--
 net/rds/ib_recv.c        |  18 +--
 net/rds/ib_send.c        |  10 +-
 net/rds/loop.c           |   7 +-
 net/rds/rdma.c           |   6 +-
 net/rds/rdma_transport.c |  56 ++++++---
 net/rds/rds.h            |  69 +++++++----
 net/rds/recv.c           |  51 +++++---
 net/rds/send.c           |  67 ++++++++---
 net/rds/tcp.c            |  33 +++++-
 net/rds/tcp_connect.c    |  34 +++---
 net/rds/tcp_listen.c     |  18 +--
 net/rds/tcp_recv.c       |   9 +-
 net/rds/tcp_send.c       |   4 +-
 net/rds/threads.c        |  69 +++++++++--
 net/rds/transport.c      |  15 ++-
 23 files changed, 858 insertions(+), 369 deletions(-)
net/rds/af_rds.c +99 -39
index ab751a1..75241ed 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 Oracle.  All rights reserved.
+ * Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -35,6 +35,7 @@
 #include <linux/kernel.h>
 #include <linux/gfp.h>
 #include <linux/in.h>
+#include <linux/ipv6.h>
 #include <linux/poll.h>
 #include <net/sock.h>
 
@@ -113,26 +114,63 @@ void rds_wake_sk_sleep(struct rds_sock *rs)
 static int rds_getname(struct socket *sock, struct sockaddr *uaddr,
 		       int peer)
 {
-	struct sockaddr_in *sin = (struct sockaddr_in *)uaddr;
 	struct rds_sock *rs = rds_sk_to_rs(sock->sk);
-
-	memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
+	struct sockaddr_in6 *sin6;
+	struct sockaddr_in *sin;
+	int uaddr_len;
 
 	/* racey, don't care */
 	if (peer) {
-		if (!rs->rs_conn_addr)
+		if (ipv6_addr_any(&rs->rs_conn_addr))
 			return -ENOTCONN;
 
-		sin->sin_port = rs->rs_conn_port;
-		sin->sin_addr.s_addr = rs->rs_conn_addr;
+		if (ipv6_addr_v4mapped(&rs->rs_conn_addr)) {
+			sin = (struct sockaddr_in *)uaddr;
+			memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
+			sin->sin_family = AF_INET;
+			sin->sin_port = rs->rs_conn_port;
+			sin->sin_addr.s_addr = rs->rs_conn_addr_v4;
+			uaddr_len = sizeof(*sin);
+		} else {
+			sin6 = (struct sockaddr_in6 *)uaddr;
+			sin6->sin6_family = AF_INET6;
+			sin6->sin6_port = rs->rs_conn_port;
+			sin6->sin6_addr = rs->rs_conn_addr;
+			sin6->sin6_flowinfo = 0;
+			/* scope_id is the same as in the bound address. */
+			sin6->sin6_scope_id = rs->rs_bound_scope_id;
+			uaddr_len = sizeof(*sin6);
+		}
 	} else {
-		sin->sin_port = rs->rs_bound_port;
-		sin->sin_addr.s_addr = rs->rs_bound_addr;
+		/* If socket is not yet bound, set the return address family
+		 * to be AF_UNSPEC (value 0) and the address size to be that
+		 * of an IPv4 address.
+		 */
+		if (ipv6_addr_any(&rs->rs_bound_addr)) {
+			sin = (struct sockaddr_in *)uaddr;
+			memset(sin, 0, sizeof(*sin));
+			sin->sin_family = AF_UNSPEC;
+			return sizeof(*sin);
+		}
+		if (ipv6_addr_v4mapped(&rs->rs_bound_addr)) {
+			sin = (struct sockaddr_in *)uaddr;
+			memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
+			sin->sin_family = AF_INET;
+			sin->sin_port = rs->rs_bound_port;
+			sin->sin_addr.s_addr = rs->rs_bound_addr_v4;
+			uaddr_len = sizeof(*sin);
+		} else {
+			sin6 = (struct sockaddr_in6 *)uaddr;
+			sin6->sin6_family = AF_INET6;
+			sin6->sin6_port = rs->rs_bound_port;
+			sin6->sin6_addr = rs->rs_bound_addr;
+			sin6->sin6_flowinfo = 0;
+			sin6->sin6_scope_id = rs->rs_bound_scope_id;
+			uaddr_len = sizeof(*sin6);
+		}
 	}
 
-	sin->sin_family = AF_INET;
-
-	return sizeof(*sin);
+	return uaddr_len;
 }
 
 /*
@@ -203,11 +241,12 @@ static int rds_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 static int rds_cancel_sent_to(struct rds_sock *rs, char __user *optval,
 			      int len)
 {
+	struct sockaddr_in6 sin6;
 	struct sockaddr_in sin;
 	int ret = 0;
 
 	/* racing with another thread binding seems ok here */
-	if (rs->rs_bound_addr == 0) {
+	if (ipv6_addr_any(&rs->rs_bound_addr)) {
 		ret = -ENOTCONN; /* XXX not a great errno */
 		goto out;
 	}
@@ -215,14 +254,23 @@ static int rds_cancel_sent_to(struct rds_sock *rs, char __user *optval,
 	if (len < sizeof(struct sockaddr_in)) {
 		ret = -EINVAL;
 		goto out;
+	} else if (len < sizeof(struct sockaddr_in6)) {
+		/* Assume IPv4 */
+		if (copy_from_user(&sin, optval, sizeof(struct sockaddr_in))) {
+			ret = -EFAULT;
+			goto out;
+		}
+		ipv6_addr_set_v4mapped(sin.sin_addr.s_addr, &sin6.sin6_addr);
+		sin6.sin6_port = sin.sin_port;
+	} else {
+		if (copy_from_user(&sin6, optval,
+				   sizeof(struct sockaddr_in6))) {
+			ret = -EFAULT;
+			goto out;
+		}
 	}
 
-	if (copy_from_user(&sin, optval, sizeof(sin))) {
-		ret = -EFAULT;
-		goto out;
-	}
-
-	rds_send_drop_to(rs, &sin);
+	rds_send_drop_to(rs, &sin6);
 out:
 	return ret;
 }
@@ -435,31 +483,41 @@ static int rds_connect(struct socket *sock, struct sockaddr *uaddr,
 		       int addr_len, int flags)
 {
 	struct sock *sk = sock->sk;
-	struct sockaddr_in *sin = (struct sockaddr_in *)uaddr;
+	struct sockaddr_in *sin;
 	struct rds_sock *rs = rds_sk_to_rs(sk);
 	int ret = 0;
 
 	lock_sock(sk);
 
-	if (addr_len != sizeof(struct sockaddr_in)) {
-		ret = -EINVAL;
-		goto out;
-	}
+	switch (addr_len) {
+	case sizeof(struct sockaddr_in):
+		sin = (struct sockaddr_in *)uaddr;
+		if (sin->sin_family != AF_INET) {
+			ret = -EAFNOSUPPORT;
+			break;
+		}
+		if (sin->sin_addr.s_addr == INADDR_ANY) {
+			ret = -EDESTADDRREQ;
+			break;
+		}
+		if (IN_MULTICAST(ntohl(sin->sin_addr.s_addr)) ||
+		    sin->sin_addr.s_addr == INADDR_BROADCAST) {
+			ret = -EINVAL;
+			break;
+		}
+		ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &rs->rs_conn_addr);
+		rs->rs_conn_port = sin->sin_port;
+		break;
 
-	if (sin->sin_family != AF_INET) {
-		ret = -EAFNOSUPPORT;
-		goto out;
-	}
+	case sizeof(struct sockaddr_in6):
+		ret = -EPROTONOSUPPORT;
+		break;
 
-	if (sin->sin_addr.s_addr == htonl(INADDR_ANY)) {
-		ret = -EDESTADDRREQ;
-		goto out;
+	default:
+		ret = -EINVAL;
+		break;
 	}
 
-	rs->rs_conn_addr = sin->sin_addr.s_addr;
-	rs->rs_conn_port = sin->sin_port;
-
-out:
 	release_sock(sk);
 	return ret;
 }
@@ -578,8 +636,10 @@ static void rds_sock_inc_info(struct socket *sock, unsigned int len,
 		list_for_each_entry(inc, &rs->rs_recv_queue, i_item) {
 			total++;
 			if (total <= len)
-				rds_inc_info_copy(inc, iter, inc->i_saddr,
-						  rs->rs_bound_addr, 1);
+				rds_inc_info_copy(inc, iter,
+						  inc->i_saddr.s6_addr32[3],
+						  rs->rs_bound_addr_v4,
+						  1);
 		}
 
 		read_unlock(&rs->rs_recv_lock);
@@ -608,8 +668,8 @@ static void rds_sock_info(struct socket *sock, unsigned int len,
 	list_for_each_entry(rs, &rds_sock_list, rs_item) {
 		sinfo.sndbuf = rds_sk_sndbuf(rs);
 		sinfo.rcvbuf = rds_sk_rcvbuf(rs);
-		sinfo.bound_addr = rs->rs_bound_addr;
-		sinfo.connected_addr = rs->rs_conn_addr;
+		sinfo.bound_addr = rs->rs_bound_addr_v4;
+		sinfo.connected_addr = rs->rs_conn_addr_v4;
 		sinfo.bound_port = rs->rs_bound_port;
 		sinfo.connected_port = rs->rs_conn_port;
 		sinfo.inum = sock_i_ino(rds_rs_to_sk(rs));
net/rds/bind.c +63 -28

192 lines not on this page · raw message

net/rds/cong.c +13 -10
index 63da9d2..ccdff09 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007 Oracle.  All rights reserved.
+ * Copyright (c) 2007, 2017 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -101,7 +101,7 @@
 static DEFINE_SPINLOCK(rds_cong_lock);
 static struct rb_root rds_cong_tree = RB_ROOT;
 
-static struct rds_cong_map *rds_cong_tree_walk(__be32 addr,
+static struct rds_cong_map *rds_cong_tree_walk(const struct in6_addr *addr,
 					       struct rds_cong_map *insert)
 {
 	struct rb_node **p = &rds_cong_tree.rb_node;
@@ -109,12 +109,15 @@ static struct rds_cong_map *rds_cong_tree_walk(__be32 addr,
 	struct rds_cong_map *map;
 
 	while (*p) {
+		int diff;
+
 		parent = *p;
 		map = rb_entry(parent, struct rds_cong_map, m_rb_node);
 
-		if (addr < map->m_addr)
+		diff = rds_addr_cmp(addr, &map->m_addr);
+		if (diff < 0)
 			p = &(*p)->rb_left;
-		else if (addr > map->m_addr)
+		else if (diff > 0)
 			p = &(*p)->rb_right;
 		else
 			return map;
@@ -132,7 +135,7 @@ static struct rds_cong_map *rds_cong_tree_walk(__be32 addr,
  * these bitmaps in the process getting pointers to them.  The bitmaps are only
  * ever freed as the module is removed after all connections have been freed.
  */
-static struct rds_cong_map *rds_cong_from_addr(__be32 addr)
+static struct rds_cong_map *rds_cong_from_addr(const struct in6_addr *addr)
 {
 	struct rds_cong_map *map;
 	struct rds_cong_map *ret = NULL;
@@ -144,7 +147,7 @@ static struct rds_cong_map *rds_cong_from_addr(__be32 addr)
 	if (!map)
 		return NULL;
 
-	map->m_addr = addr;
+	map->m_addr = *addr;
 	init_waitqueue_head(&map->m_waitq);
 	INIT_LIST_HEAD(&map->m_conn_list);
 
@@ -171,7 +174,7 @@ static struct rds_cong_map *rds_cong_from_addr(__be32 addr)
 		kfree(map);
 	}
 
-	rdsdebug("map %p for addr %x\n", ret, be32_to_cpu(addr));
+	rdsdebug("map %p for addr %pI6c\n", ret, addr);
 
 	return ret;
 }
@@ -202,8 +205,8 @@ void rds_cong_remove_conn(struct rds_connection *conn)
 
 int rds_cong_get_maps(struct rds_connection *conn)
 {
-	conn->c_lcong = rds_cong_from_addr(conn->c_laddr);
-	conn->c_fcong = rds_cong_from_addr(conn->c_faddr);
+	conn->c_lcong = rds_cong_from_addr(&conn->c_laddr);
+	conn->c_fcong = rds_cong_from_addr(&conn->c_faddr);
 
 	if (!(conn->c_lcong && conn->c_fcong))
 		return -ENOMEM;
@@ -353,7 +356,7 @@ void rds_cong_remove_socket(struct rds_sock *rs)
 
 	/* update congestion map for now-closed port */
 	spin_lock_irqsave(&rds_cong_lock, flags);
-	map = rds_cong_tree_walk(rs->rs_bound_addr, NULL);
+	map = rds_cong_tree_walk(&rs->rs_bound_addr, NULL);
 	spin_unlock_irqrestore(&rds_cong_lock, flags);
 
 	if (map && rds_cong_test_bit(map, rs->rs_bound_port)) {
net/rds/connection.c +81 -51

255 lines not on this page · raw message

net/rds/ib.c +9 -8
index b6ad38e..c712a84 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 Oracle.  All rights reserved.
+ * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -296,8 +296,8 @@ static int rds_ib_conn_info_visitor(struct rds_connection *conn,
 	if (conn->c_trans != &rds_ib_transport)
 		return 0;
 
-	iinfo->src_addr = conn->c_laddr;
-	iinfo->dst_addr = conn->c_faddr;
+	iinfo->src_addr = conn->c_laddr.s6_addr32[3];
+	iinfo->dst_addr = conn->c_faddr.s6_addr32[3];
 
 	memset(&iinfo->src_gid, 0, sizeof(iinfo->src_gid));
 	memset(&iinfo->dst_gid, 0, sizeof(iinfo->dst_gid));
@@ -341,7 +341,8 @@ static void rds_ib_ic_info(struct socket *sock, unsigned int len,
  * allowed to influence which paths have priority.  We could call userspace
  * asserting this policy "routing".
  */
-static int rds_ib_laddr_check(struct net *net, __be32 addr)
+static int rds_ib_laddr_check(struct net *net, const struct in6_addr *addr,
+			      __u32 scope_id)
 {
 	int ret;
 	struct rdma_cm_id *cm_id;
@@ -357,7 +358,7 @@ static int rds_ib_laddr_check(struct net *net, __be32 addr)
 
 	memset(&sin, 0, sizeof(sin));
 	sin.sin_family = AF_INET;
-	sin.sin_addr.s_addr = addr;
+	sin.sin_addr.s_addr = addr->s6_addr32[3];
 
 	/* rdma_bind_addr will only succeed for IB & iWARP devices */
 	ret = rdma_bind_addr(cm_id, (struct sockaddr *)&sin);
@@ -367,9 +368,9 @@ static int rds_ib_laddr_check(struct net *net, __be32 addr)
 	    cm_id->device->node_type != RDMA_NODE_IB_CA)
 		ret = -EADDRNOTAVAIL;
 
-	rdsdebug("addr %pI4 ret %d node type %d\n",
-		&addr, ret,
-		cm_id->device ? cm_id->device->node_type : -1);
+	rdsdebug("addr %pI6c ret %d node type %d\n",
+		 addr, ret,
+		 cm_id->device ? cm_id->device->node_type : -1);
 
 	rdma_destroy_id(cm_id);
 
net/rds/ib.h +34 -11

65 lines not on this page · raw message

net/rds/ib_cm.c +222 -78

459 lines not on this page · raw message

net/rds/ib_rdma.c +8 -7
index e678699..0ec9df0 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 Oracle.  All rights reserved.
+ * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -100,18 +100,19 @@ static void rds_ib_remove_ipaddr(struct rds_ib_device *rds_ibdev, __be32 ipaddr)
 		kfree_rcu(to_free, rcu);
 }
 
-int rds_ib_update_ipaddr(struct rds_ib_device *rds_ibdev, __be32 ipaddr)
+int rds_ib_update_ipaddr(struct rds_ib_device *rds_ibdev,
+			 struct in6_addr *ipaddr)
 {
 	struct rds_ib_device *rds_ibdev_old;
 
-	rds_ibdev_old = rds_ib_get_device(ipaddr);
+	rds_ibdev_old = rds_ib_get_device(ipaddr->s6_addr32[3]);
 	if (!rds_ibdev_old)
-		return rds_ib_add_ipaddr(rds_ibdev, ipaddr);
+		return rds_ib_add_ipaddr(rds_ibdev, ipaddr->s6_addr32[3]);
 
 	if (rds_ibdev_old != rds_ibdev) {
-		rds_ib_remove_ipaddr(rds_ibdev_old, ipaddr);
+		rds_ib_remove_ipaddr(rds_ibdev_old, ipaddr->s6_addr32[3]);
 		rds_ib_dev_put(rds_ibdev_old);
-		return rds_ib_add_ipaddr(rds_ibdev, ipaddr);
+		return rds_ib_add_ipaddr(rds_ibdev, ipaddr->s6_addr32[3]);
 	}
 	rds_ib_dev_put(rds_ibdev_old);
 
@@ -544,7 +545,7 @@ void *rds_ib_get_mr(struct scatterlist *sg, unsigned long nents,
 	struct rds_ib_connection *ic = rs->rs_conn->c_transport_data;
 	int ret;
 
-	rds_ibdev = rds_ib_get_device(rs->rs_bound_addr);
+	rds_ibdev = rds_ib_get_device(rs->rs_bound_addr.s6_addr32[3]);
 	if (!rds_ibdev) {
 		ret = -ENODEV;
 		goto out;
net/rds/ib_recv.c +9 -9
index b4e421a..f101bed 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 Oracle.  All rights reserved.
+ * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -266,7 +266,7 @@ static struct rds_ib_incoming *rds_ib_refill_one_inc(struct rds_ib_connection *i
 		rds_ib_stats_inc(s_ib_rx_total_incs);
 	}
 	INIT_LIST_HEAD(&ibinc->ii_frags);
-	rds_inc_init(&ibinc->ii_inc, ic->conn, ic->conn->c_faddr);
+	rds_inc_init(&ibinc->ii_inc, ic->conn, &ic->conn->c_faddr);
 
 	return ibinc;
 }
@@ -420,7 +420,7 @@ void rds_ib_recv_refill(struct rds_connection *conn, int prefill, gfp_t gfp)
 		ret = ib_post_recv(ic->i_cm_id->qp, &recv->r_wr, &failed_wr);
 		if (ret) {
 			rds_ib_conn_error(conn, "recv post on "
-			       "%pI4 returned %d, disconnecting and "
+			       "%pI6c returned %d, disconnecting and "
 			       "reconnecting\n", &conn->c_faddr,
 			       ret);
 			break;
@@ -850,7 +850,7 @@ static void rds_ib_process_recv(struct rds_connection *conn,
 
 	if (data_len < sizeof(struct rds_header)) {
 		rds_ib_conn_error(conn, "incoming message "
-		       "from %pI4 didn't include a "
+		       "from %pI6c didn't include a "
 		       "header, disconnecting and "
 		       "reconnecting\n",
 		       &conn->c_faddr);
@@ -863,7 +863,7 @@ static void rds_ib_process_recv(struct rds_connection *conn,
 	/* Validate the checksum. */
 	if (!rds_message_verify_checksum(ihdr)) {
 		rds_ib_conn_error(conn, "incoming message "
-		       "from %pI4 has corrupted header - "
+		       "from %pI6c has corrupted header - "
 		       "forcing a reconnect\n",
 		       &conn->c_faddr);
 		rds_stats_inc(s_recv_drop_bad_checksum);
@@ -943,10 +943,10 @@ static void rds_ib_process_recv(struct rds_connection *conn,
 		ic->i_recv_data_rem = 0;
 		ic->i_ibinc = NULL;
 
-		if (ibinc->ii_inc.i_hdr.h_flags == RDS_FLAG_CONG_BITMAP)
+		if (ibinc->ii_inc.i_hdr.h_flags == RDS_FLAG_CONG_BITMAP) {
 			rds_ib_cong_recv(conn, ibinc);
-		else {
-			rds_recv_incoming(conn, conn->c_faddr, conn->c_laddr,
+		} else {
+			rds_recv_incoming(conn, &conn->c_faddr, &conn->c_laddr,
 					  &ibinc->ii_inc, GFP_ATOMIC);
 			state->ack_next = be64_to_cpu(hdr->h_sequence);
 			state->ack_next_valid = 1;
@@ -990,7 +990,7 @@ void rds_ib_recv_cqe_handler(struct rds_ib_connection *ic,
 	} else {
 		/* We expect errors as the qp is drained during shutdown */
 		if (rds_conn_up(conn) || rds_conn_connecting(conn))
-			rds_ib_conn_error(conn, "recv completion on <%pI4,%pI4> had status %u (%s), disconnecting and reconnecting\n",
+			rds_ib_conn_error(conn, "recv completion on <%pI6c,%pI6c> had status %u (%s), disconnecting and reconnecting\n",
 					  &conn->c_laddr, &conn->c_faddr,
 					  wc->status,
 					  ib_wc_status_msg(wc->status));
net/rds/ib_send.c +5 -5
index 8557a1c..c4cdfe49 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 Oracle.  All rights reserved.
+ * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -305,7 +305,7 @@ void rds_ib_send_cqe_handler(struct rds_ib_connection *ic, struct ib_wc *wc)
 
 	/* We expect errors as the qp is drained during shutdown */
 	if (wc->status != IB_WC_SUCCESS && rds_conn_up(conn)) {
-		rds_ib_conn_error(conn, "send completion on <%pI4,%pI4> had status %u (%s), disconnecting and reconnecting\n",
+		rds_ib_conn_error(conn, "send completion on <%pI6c,%pI6c> had status %u (%s), disconnecting and reconnecting\n",
 				  &conn->c_laddr, &conn->c_faddr, wc->status,
 				  ib_wc_status_msg(wc->status));
 	}
@@ -730,7 +730,7 @@ int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm,
 		 first, &first->s_wr, ret, failed_wr);
 	BUG_ON(failed_wr != &first->s_wr);
 	if (ret) {
-		printk(KERN_WARNING "RDS/IB: ib_post_send to %pI4 "
+		printk(KERN_WARNING "RDS/IB: ib_post_send to %pI6c "
 		       "returned %d\n", &conn->c_faddr, ret);
 		rds_ib_ring_unalloc(&ic->i_send_ring, work_alloc);
 		rds_ib_sub_signaled(ic, nr_sig);
@@ -827,7 +827,7 @@ int rds_ib_xmit_atomic(struct rds_connection *conn, struct rm_atomic_op *op)
 		 send, &send->s_atomic_wr, ret, failed_wr);
 	BUG_ON(failed_wr != &send->s_atomic_wr.wr);
 	if (ret) {
-		printk(KERN_WARNING "RDS/IB: atomic ib_post_send to %pI4 "
+		printk(KERN_WARNING "RDS/IB: atomic ib_post_send to %pI6c "
 		       "returned %d\n", &conn->c_faddr, ret);
 		rds_ib_ring_unalloc(&ic->i_send_ring, work_alloc);
 		rds_ib_sub_signaled(ic, nr_sig);
@@ -967,7 +967,7 @@ int rds_ib_xmit_rdma(struct rds_connection *conn, struct rm_rdma_op *op)
 		 first, &first->s_rdma_wr.wr, ret, failed_wr);
 	BUG_ON(failed_wr != &first->s_rdma_wr.wr);
 	if (ret) {
-		printk(KERN_WARNING "RDS/IB: rdma ib_post_send to %pI4 "
+		printk(KERN_WARNING "RDS/IB: rdma ib_post_send to %pI6c "
 		       "returned %d\n", &conn->c_faddr, ret);
 		rds_ib_ring_unalloc(&ic->i_send_ring, work_alloc);
 		rds_ib_sub_signaled(ic, nr_sig);
net/rds/loop.c +4 -3
index dac6218..0dca895 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 Oracle.  All rights reserved.
+ * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -33,6 +33,7 @@
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/in.h>
+#include <linux/ipv6.h>
 
 #include "rds_single_path.h"
 #include "rds.h"
@@ -75,11 +76,11 @@ static int rds_loop_xmit(struct rds_connection *conn, struct rds_message *rm,
 
 	BUG_ON(hdr_off || sg || off);
 
-	rds_inc_init(&rm->m_inc, conn, conn->c_laddr);
+	rds_inc_init(&rm->m_inc, conn, &conn->c_laddr);
 	/* For the embedded inc. Matching put is in loop_inc_free() */
 	rds_message_addref(rm);
 
-	rds_recv_incoming(conn, conn->c_laddr, conn->c_faddr, &rm->m_inc,
+	rds_recv_incoming(conn, &conn->c_laddr, &conn->c_faddr, &rm->m_inc,
 			  GFP_KERNEL);
 
 	rds_send_drop_acked(conn, be64_to_cpu(rm->m_inc.i_hdr.h_sequence),
net/rds/rdma.c +3 -3
index 634cfcb..7b39980 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007 Oracle.  All rights reserved.
+ * Copyright (c) 2007, 2017 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -183,7 +183,7 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,
 	long i;
 	int ret;
 
-	if (rs->rs_bound_addr == 0 || !rs->rs_transport) {
+	if (ipv6_addr_any(&rs->rs_bound_addr) || !rs->rs_transport) {
 		ret = -ENOTCONN; /* XXX not a great errno */
 		goto out;
 	}
@@ -574,7 +574,7 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm,
 
 	args = CMSG_DATA(cmsg);
 
-	if (rs->rs_bound_addr == 0) {
+	if (ipv6_addr_any(&rs->rs_bound_addr)) {
 		ret = -ENOTCONN; /* XXX not a great errno */
 		goto out_ret;
 	}
net/rds/rdma_transport.c +40 -16

122 lines not on this page · raw message

net/rds/rds.h +46 -23

162 lines not on this page · raw message

net/rds/recv.c +34 -17

126 lines not on this page · raw message

net/rds/send.c +52 -15

125 lines not on this page · raw message

net/rds/tcp.c +30 -3
index 351a284..beaff17 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 Oracle.  All rights reserved.
+ * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -37,6 +37,8 @@
 #include <net/tcp.h>
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
+#include <net/tcp.h>
+#include <net/addrconf.h>
 
 #include "rds.h"
 #include "tcp.h"
@@ -262,9 +264,34 @@ static void rds_tcp_tc_info(struct socket *rds_sock, unsigned int len,
 	spin_unlock_irqrestore(&rds_tcp_tc_list_lock, flags);
 }
 
-static int rds_tcp_laddr_check(struct net *net, __be32 addr)
+static int rds_tcp_laddr_check(struct net *net, const struct in6_addr *addr,
+			       __u32 scope_id)
 {
-	if (inet_addr_type(net, addr) == RTN_LOCAL)
+	struct net_device *dev = NULL;
+	int ret;
+
+	if (ipv6_addr_v4mapped(addr)) {
+		if (inet_addr_type(net, addr->s6_addr32[3]) == RTN_LOCAL)
+			return 0;
+		return -EADDRNOTAVAIL;
+	}
+
+	/* If the scope_id is specified, check only those addresses
+	 * hosted on the specified interface.
+	 */
+	if (scope_id != 0) {
+		rcu_read_lock();
+		dev = dev_get_by_index_rcu(net, scope_id);
+		/* scope_id is not valid... */
+		if (!dev) {
+			rcu_read_unlock();
+			return -EADDRNOTAVAIL;
+		}
+	}
+	ret = ipv6_chk_addr(net, addr, dev, 0);
+	if (scope_id != 0)
+		rcu_read_unlock();
+	if (ret)
 		return 0;
 	return -EADDRNOTAVAIL;
 }
net/rds/tcp_connect.c +20 -14
index d999e70..0101033 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 Oracle.  All rights reserved.
+ * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -66,7 +66,8 @@ void rds_tcp_state_change(struct sock *sk)
 		 * RDS connection as RDS_CONN_UP until the reconnect,
 		 * to avoid RDS datagram loss.
 		 */
-		if (!IS_CANONICAL(cp->cp_conn->c_laddr, cp->cp_conn->c_faddr) &&
+		if (rds_addr_cmp(&cp->cp_conn->c_laddr,
+				 &cp->cp_conn->c_faddr) >= 0 &&
 		    rds_conn_path_transition(cp, RDS_CONN_CONNECTING,
 					     RDS_CONN_ERROR)) {
 			rds_conn_path_drop(cp, false);
@@ -88,7 +89,9 @@ void rds_tcp_state_change(struct sock *sk)
 int rds_tcp_conn_path_connect(struct rds_conn_path *cp)
 {
 	struct socket *sock = NULL;
-	struct sockaddr_in src, dest;
+	struct sockaddr_in sin;
+	struct sockaddr *addr;
+	int addrlen;
 	int ret;
 	struct rds_connection *conn = cp->cp_conn;
 	struct rds_tcp_connection *tc = cp->cp_transport_data;
@@ -112,30 +115,33 @@ int rds_tcp_conn_path_connect(struct rds_conn_path *cp)
 
 	rds_tcp_tune(sock);
 
-	src.sin_family = AF_INET;
-	src.sin_addr.s_addr = (__force u32)conn->c_laddr;
-	src.sin_port = (__force u16)htons(0);
+	sin.sin_family = AF_INET;
+	sin.sin_addr.s_addr = (__force u32)conn->c_laddr.s6_addr32[3];
+	sin.sin_port = (__force u16)htons(0);
+	addr = (struct sockaddr *)&sin;
+	addrlen = sizeof(sin);
 
-	ret = sock->ops->bind(sock, (struct sockaddr *)&src, sizeof(src));
+	ret = sock->ops->bind(sock, addr, addrlen);
 	if (ret) {
-		rdsdebug("bind failed with %d at address %pI4\n",
+		rdsdebug("bind failed with %d at address %pI6c\n",
 			 ret, &conn->c_laddr);
 		goto out;
 	}
 
-	dest.sin_family = AF_INET;
-	dest.sin_addr.s_addr = (__force u32)conn->c_faddr;
-	dest.sin_port = (__force u16)htons(RDS_TCP_PORT);
+	sin.sin_family = AF_INET;
+	sin.sin_addr.s_addr = (__force u32)conn->c_faddr.s6_addr32[3];
+	sin.sin_port = (__force u16)htons(RDS_TCP_PORT);
+	addr = (struct sockaddr *)&sin;
+	addrlen = sizeof(sin);
 
 	/*
 	 * once we call connect() we can start getting callbacks and they
 	 * own the socket
 	 */
 	rds_tcp_set_callbacks(sock, cp);
-	ret = sock->ops->connect(sock, (struct sockaddr *)&dest, sizeof(dest),
-				 O_NONBLOCK);
+	ret = sock->ops->connect(sock, addr, addrlen, O_NONBLOCK);
 
-	rdsdebug("connect to address %pI4 returned %d\n", &conn->c_faddr, ret);
+	rdsdebug("connect to address %pI6c returned %d\n", &conn->c_faddr, ret);
 	if (ret == -EINPROGRESS)
 		ret = 0;
 	if (ret == 0) {
net/rds/tcp_listen.c +10 -8
index 2257118..4fdf5b3 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2018 Oracle.  All rights reserved.
+ * Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -83,13 +83,12 @@ int rds_tcp_keepalive(struct socket *sock)
 struct rds_tcp_connection *rds_tcp_accept_one_path(struct rds_connection *conn)
 {
 	int i;
-	bool peer_is_smaller = IS_CANONICAL(conn->c_faddr, conn->c_laddr);
 	int npaths = max_t(int, 1, conn->c_npaths);
 
 	/* for mprds, all paths MUST be initiated by the peer
 	 * with the smaller address.
 	 */
-	if (!peer_is_smaller) {
+	if (rds_addr_cmp(&conn->c_faddr, &conn->c_laddr) >= 0) {
 		/* Make sure we initiate at least one path if this
 		 * has not already been done; rds_start_mprds() will
 		 * take care of additional paths, if necessary.
@@ -164,13 +163,16 @@ int rds_tcp_accept_one(struct socket *sock)
 
 	inet = inet_sk(new_sock->sk);
 
-	rdsdebug("accepted tcp %pI4:%u -> %pI4:%u\n",
-		 &inet->inet_saddr, ntohs(inet->inet_sport),
-		 &inet->inet_daddr, ntohs(inet->inet_dport));
+	rdsdebug("accepted tcp %pI6c:%u -> %pI6c:%u\n",
+		 &new_sock->sk->sk_v6_rcv_saddr, ntohs(inet->inet_sport),
+		 &new_sock->sk->sk_v6_daddr, ntohs(inet->inet_dport));
 
 	conn = rds_conn_create(sock_net(sock->sk),
-			       inet->inet_saddr, inet->inet_daddr,
-			       &rds_tcp_transport, GFP_KERNEL);
+			       &new_sock->sk->sk_v6_rcv_saddr,
+			       &new_sock->sk->sk_v6_daddr,
+			       &rds_tcp_transport, GFP_KERNEL,
+			       new_sock->sk->sk_bound_dev_if);
+
 	if (IS_ERR(conn)) {
 		ret = PTR_ERR(conn);
 		goto out;
net/rds/tcp_recv.c +5 -4
index b9fbd2e..42c5ff1 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 Oracle.  All rights reserved.
+ * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -179,7 +179,7 @@ static int rds_tcp_data_recv(read_descriptor_t *desc, struct sk_buff *skb,
 			tc->t_tinc = tinc;
 			rdsdebug("alloced tinc %p\n", tinc);
 			rds_inc_path_init(&tinc->ti_inc, cp,
-					  cp->cp_conn->c_faddr);
+					  &cp->cp_conn->c_faddr);
 			tinc->ti_inc.i_rx_lat_trace[RDS_MSG_RX_HDR] =
 					local_clock();
 
@@ -239,8 +239,9 @@ static int rds_tcp_data_recv(read_descriptor_t *desc, struct sk_buff *skb,
 			if (tinc->ti_inc.i_hdr.h_flags == RDS_FLAG_CONG_BITMAP)
 				rds_tcp_cong_recv(conn, tinc);
 			else
-				rds_recv_incoming(conn, conn->c_faddr,
-						  conn->c_laddr, &tinc->ti_inc,
+				rds_recv_incoming(conn, &conn->c_faddr,
+						  &conn->c_laddr,
+						  &tinc->ti_inc,
 						  arg->gfp);
 
 			tc->t_tinc_hdr_rem = sizeof(struct rds_header);
net/rds/tcp_send.c +2 -2
index 7df869d..78a2554 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 Oracle.  All rights reserved.
+ * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -153,7 +153,7 @@ int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm,
 			 * an incoming RST.
 			 */
 			if (rds_conn_path_up(cp)) {
-				pr_warn("RDS/tcp: send to %pI4 on cp [%d]"
+				pr_warn("RDS/tcp: send to %pI6c on cp [%d]"
 					"returned %d, "
 					"disconnecting and reconnecting\n",
 					&conn->c_faddr, cp->cp_index, ret);
net/rds/threads.c +58 -11

108 lines not on this page · raw message

net/rds/transport.c +11 -4
index 0b188dd..c9788db 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 Oracle.  All rights reserved.
+ * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -33,6 +33,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/in.h>
+#include <linux/ipv6.h>
 
 #include "rds.h"
 #include "loop.h"
@@ -75,20 +76,26 @@ void rds_trans_put(struct rds_transport *trans)
 		module_put(trans->t_owner);
 }
 
-struct rds_transport *rds_trans_get_preferred(struct net *net, __be32 addr)
+struct rds_transport *rds_trans_get_preferred(struct net *net,
+					      const struct in6_addr *addr,
+					      __u32 scope_id)
 {
 	struct rds_transport *ret = NULL;
 	struct rds_transport *trans;
 	unsigned int i;
 
-	if (IN_LOOPBACK(ntohl(addr)))
+	if (ipv6_addr_v4mapped(addr)) {
+		if (*(u_int8_t *)&addr->s6_addr32[3] == IN_LOOPBACKNET)
+			return &rds_loop_transport;
+	} else if (ipv6_addr_loopback(addr)) {
 		return &rds_loop_transport;
+	}
 
 	down_read(&rds_trans_sem);
 	for (i = 0; i < RDS_TRANS_COUNT; i++) {
 		trans = transports[i];
 
-		if (trans && (trans->laddr_check(net, addr) == 0) &&
+		if (trans && (trans->laddr_check(net, addr, scope_id) == 0) &&
 		    (!trans->t_owner || try_module_get(trans->t_owner))) {
 			ret = trans;
 			break;
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [PATCH net-next 1/3] rds: Changing IP address internal representation to struct in6_addr

Thank you for the patch! Perhaps something to improve:

Hi Ka-Cheong,

Thank you for the patch! Perhaps something to improve:

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

url: https://github.com/0day-ci/linux/commits/Ka-Cheong-Poon/rds-IPv6-support/20180625-190047
reproduce:

        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__

sparse warnings: (new ones prefixed by >>)

>> net/rds/rdma_transport.c:42:5: sparse: symbol 'rds_rdma_cm_event_handler_cmn' was not declared. Should it be static?

--
net/rds/ib_cm.c:205:17: sparse: expression using sizeof(void) net/rds/ib_cm.c:205:17: sparse: expression using sizeof(void) net/rds/ib_cm.c:207:17: sparse: expression using sizeof(void) net/rds/ib_cm.c:207:17: sparse: expression using sizeof(void) net/rds/ib_cm.c:208:35: sparse: expression using sizeof(void) include/linux/overflow.h:220:13: sparse: undefined identifier '__builtin_mul_overflow' include/linux/overflow.h:220:13: sparse: incorrect type in conditional
include/linux/overflow.h:220:13: got void
include/linux/overflow.h:220:13: sparse: not a function <noident> include/linux/overflow.h:220:13: sparse: incorrect type in conditional
include/linux/overflow.h:220:13: got void

>> net/rds/ib_cm.c:908:31: sparse: incorrect type in assignment (different base types) @@    expected restricted __be16 [usertype] sin_port @@    got unsignedrestricted __be16 [usertype] sin_port @@
   net/rds/ib_cm.c:908:31:    expected restricted __be16 [usertype] sin_port
   net/rds/ib_cm.c:908:31:    got unsigned short [unsigned] [usertype] <noident>
   net/rds/ib_cm.c:913:31: sparse: incorrect type in assignment (different base types) @@    expected restricted __be16 [usertype] sin_port @@    got unsignedrestricted __be16 [usertype] sin_port @@
   net/rds/ib_cm.c:913:31:    expected restricted __be16 [usertype] sin_port
   net/rds/ib_cm.c:913:31:    got unsigned short [unsigned] [usertype] <noident>
>> net/rds/ib_cm.c:920:33: sparse: incorrect type in assignment (different base types) @@    expected restricted __be16 [usertype] sin6_port @@    got unsignedrestricted __be16 [usertype] sin6_port @@

net/rds/ib_cm.c:920:33: expected restricted __be16 [usertype] sin6_port
net/rds/ib_cm.c:920:33: got unsigned short [unsigned] [usertype] <noident>
net/rds/ib_cm.c:926:33: sparse: incorrect type in assignment (different base types) @@ expected restricted __be16 [usertype] sin6_port @@ got unsignedrestricted __be16 [usertype] sin6_port @@
net/rds/ib_cm.c:926:33: expected restricted __be16 [usertype] sin6_port
net/rds/ib_cm.c:926:33: got unsigned short [unsigned] [usertype] <noident>
include/linux/overflow.h:220:13: sparse: call with no type!
--

>> net/rds/tcp.c:294:9: sparse: context imbalance in 'rds_tcp_laddr_check' - different lock contexts for basic block

--
net/rds/tcp_connect.c:119:29: sparse: incorrect type in assignment (different base types) @@ expected restricted __be32 [assigned] [usertype] s_addr @@ got icted __be32 [assigned] [usertype] s_addr @@
net/rds/tcp_connect.c:119:29: expected restricted __be32 [assigned] [usertype] s_addr
net/rds/tcp_connect.c:119:29: got unsigned int [unsigned] [usertype] <noident>
net/rds/tcp_connect.c:120:22: sparse: incorrect type in assignment (different base types) @@ expected restricted __be16 [assigned] [usertype] sin_port @@ got tricted __be16 [assigned] [usertype] sin_port @@
net/rds/tcp_connect.c:120:22: expected restricted __be16 [assigned] [usertype] sin_port
net/rds/tcp_connect.c:120:22: got unsigned short [unsigned] [usertype] <noident>

>> net/rds/tcp_connect.c:132:29: sparse: incorrect type in assignment (different base types) @@    expected restricted __be32 [addressable] [assigned] [usertype] s_addr @@    got addressable] [assigned] [usertype] s_addr @@
   net/rds/tcp_connect.c:132:29:    expected restricted __be32 [addressable] [assigned] [usertype] s_addr
   net/rds/tcp_connect.c:132:29:    got unsigned int [unsigned] [usertype] <noident>
>> net/rds/tcp_connect.c:133:22: sparse: incorrect type in assignment (different base types) @@    expected restricted __be16 [addressable] [assigned] [usertype] sin_port @@    got  [addressable] [assigned] [usertype] sin_port @@

net/rds/tcp_connect.c:133:22: expected restricted __be16 [addressable] [assigned] [usertype] sin_port
net/rds/tcp_connect.c:133:22: got unsigned short [unsigned] [usertype] <noident>
--
net/rds/af_rds.c:226:22: sparse: invalid assignment: |=
net/rds/af_rds.c:226:22: left side has type restricted __poll_t
net/rds/af_rds.c:226:22: right side has type int

>> net/rds/af_rds.c:499:34: sparse: restricted __be32 degrades to integer
   net/rds/af_rds.c:504:34: sparse: restricted __be32 degrades to integer
--
   net/rds/bind.c:105:25: sparse: expression using sizeof(void)
>> net/rds/bind.c:177:34: sparse: restricted __be32 degrades to integer

--
net/rds/send.c:363:39: sparse: expression using sizeof(void) net/rds/send.c:363:39: sparse: expression using sizeof(void) net/rds/send.c:372:39: sparse: expression using sizeof(void) net/rds/send.c:372:39: sparse: expression using sizeof(void)
net/rds/send.c:1015:24: sparse: incorrect type in argument 1 (different base types) @@ expected unsigned int [unsigned] [usertype] a @@ got ed int [unsigned] [usertype] a @@
net/rds/send.c:1015:24: expected unsigned int [unsigned] [usertype] a
net/rds/send.c:1015:24: got restricted __be16 [usertype] sin6_port
net/rds/send.c:1017:24: sparse: incorrect type in argument 1 (different base types) @@ expected unsigned int [unsigned] [usertype] a @@ got ed int [unsigned] [usertype] a @@
net/rds/send.c:1017:24: expected unsigned int [unsigned] [usertype] a
net/rds/send.c:1017:24: got restricted __be16 [usertype] sin6_port

>> net/rds/send.c:1097:43: sparse: restricted __be32 degrades to integer

net/rds/send.c:1098:43: sparse: restricted __be32 degrades to integer net/rds/send.c:1149:13: sparse: expression using sizeof(void) net/rds/send.c:1149:13: sparse: expression using sizeof(void)
net/rds/send.c:1352:30: sparse: incorrect type in initializer (different base types) @@ expected unsigned short [unsigned] [usertype] npaths @@ got short [unsigned] [usertype] npaths @@
net/rds/send.c:1352:30: expected unsigned short [unsigned] [usertype] npaths
net/rds/send.c:1352:30: got restricted __be16 [usertype] <noident>
net/rds/send.c:1353:34: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] my_gen_num @@ got ed int [unsigned] [usertype] my_gen_num @@
net/rds/send.c:1353:34: expected unsigned int [unsigned] [usertype] my_gen_num
net/rds/send.c:1353:34: got restricted __be32 [usertype] <noident>

#3 lore raw

[RFC PATCH] rds: rds_rdma_cm_event_handler_cmn() can be static

In reply to Ka-Cheong Poon
Fixes: f58dbee41d61 ("rds: Changing IP address internal representation to struct in6_addr")
Fixes f58dbee41d61 ("rds: Changing IP address internal representation to struct in6_addr")
---
 rdma_transport.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/rds/rdma_transport.c +3 -3
index d7da115..3634ed5 100644
@@ -39,9 +39,9 @@
 
 static struct rdma_cm_id *rds_rdma_listen_id;
 
-int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
-				  struct rdma_cm_event *event,
-				  bool isv6)
+static int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
+					 struct rdma_cm_event *event,
+					 bool isv6)
 {
 	/* this can be null in the listening path */
 	struct rds_connection *conn = cm_id->context;
#4 lore raw

PATCH 2/3 rds: Enable RDS IPv6 support

In reply to Ka-Cheong Poon

This patch enables RDS to use IPv6 addresses. For RDS/TCP, the listener is now an IPv6 endpoint which accepts both IPv4 and IPv6 connection requests. RDS/RDMA/IB uses a private data (struct rds_ib_connect_private) exchange between endpoints at RDS connection establishment time to support RDMA. This private data exchange uses a 32 bit integer to represent an IP address. This needs to be changed in order to support IPv6. A new private data struct rds6_ib_connect_private is introduced to handle this. To ensure backward compatibility, an IPv6 capable RDS stack uses another RDMA listener port (RDS_CM_PORT) to accept IPv6 connection. And it continues to use the original RDS_PORT for IPv4 RDS connections. When it needs to communicate with an IPv6 peer, it uses the RDS_CM_PORT to send the connection set up request.

---
 net/rds/bind.c           | 21 +++++++++++++++---
 net/rds/connection.c     | 43 ++++++++++++++++++++++++-------------
 net/rds/ib.c             | 55 +++++++++++++++++++++++++++++++++++++++++-------
 net/rds/ib_cm.c          | 15 +++++++------
 net/rds/rdma_transport.c | 32 ++++++++++++++++++++++++++--
 net/rds/rdma_transport.h |  2 ++
 net/rds/rds.h            | 12 ++++++-----
 net/rds/send.c           | 23 ++++++++++++++++++--
 net/rds/tcp.c            | 54 +++++++++++++++++++++++++++++------------------
 net/rds/tcp.h            |  4 +---
 net/rds/tcp_connect.c    | 54 ++++++++++++++++++++++++++++++++++++-----------
 net/rds/tcp_listen.c     | 40 +++++++++++++++++++++++++++--------
 12 files changed, 269 insertions(+), 86 deletions(-)
net/rds/bind.c +18 -3
index 3a1097e..4c2bf9c 100644
@@ -164,11 +164,12 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 	struct in6_addr v6addr, *binding_addr;
 	struct rds_transport *trans;
 	__u32 scope_id = 0;
+	int addr_type;
 	int ret = 0;
 	__be16 port;
 
-	/* We only allow an RDS socket to be bound to and IPv4 address. IPv6
-	 * address support will be added later.
+	/* We allow an RDS socket to be bound to either IPv4 or IPv6
+	 * address.
 	 */
 	if (addr_len == sizeof(struct sockaddr_in)) {
 		struct sockaddr_in *sin = (struct sockaddr_in *)uaddr;
@@ -180,7 +181,21 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 		binding_addr = &v6addr;
 		port = sin->sin_port;
 	} else if (addr_len == sizeof(struct sockaddr_in6)) {
-		return -EPROTONOSUPPORT;
+		struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)uaddr;
+
+		addr_type = ipv6_addr_type(&sin6->sin6_addr);
+		if (sin6->sin6_family != AF_INET6 ||
+		    !(addr_type & IPV6_ADDR_UNICAST)) {
+			return -EINVAL;
+		}
+		/* The scope ID must be specified for link local address. */
+		if (addr_type & IPV6_ADDR_LINKLOCAL) {
+			if (sin6->sin6_scope_id == 0)
+				return -EINVAL;
+			scope_id = sin6->sin6_scope_id;
+		}
+		binding_addr = &sin6->sin6_addr;
+		port = sin6->sin6_port;
 	} else {
 		return -EINVAL;
 	}
net/rds/connection.c +28 -15

73 lines not on this page · raw message

net/rds/ib.c +47 -8

99 lines not on this page · raw message

net/rds/ib_cm.c +8 -7
index 31ffa70..03279f3 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -40,7 +40,6 @@
 #include "rds_single_path.h"
 #include "rds.h"
 #include "ib.h"
-#include "tcp.h"
 
 /*
  * Set the selected protocol version
@@ -679,7 +678,7 @@ static u32 rds_ib_protocol_compatible(struct rdma_cm_event *event, bool isv6)
 	return version;
 }
 
-/* Given an IPv6 address, find the IB net_device which hosts that address and
+/* Given an IPv6 address, find the net_device which hosts that address and
  * return its index.  This is used by the rds_ib_cm_handle_connect() code to
  * find the interface index of where an incoming request comes from when
  * the request is using a link local address.
@@ -696,8 +695,7 @@ static u32 __rds_find_ifindex(struct net *net, const struct in6_addr *addr)
 
 	rcu_read_lock();
 	for_each_netdev_rcu(net, dev) {
-		if (dev->type == ARPHRD_INFINIBAND &&
-		    ipv6_chk_addr(net, addr, dev, 0)) {
+		if (ipv6_chk_addr(net, addr, dev, 0)) {
 			idx = dev->ifindex;
 			break;
 		}
@@ -887,7 +885,10 @@ int rds_ib_conn_path_connect(struct rds_conn_path *cp)
 
 	/* XXX I wonder what affect the port space has */
 	/* delegate cm event handler to rdma_transport */
-	handler = rds_rdma_cm_event_handler;
+	if (conn->c_isv6)
+		handler = rds6_rdma_cm_event_handler;
+	else
+		handler = rds_rdma_cm_event_handler;
 	ic->i_cm_id = rdma_create_id(&init_net, handler, conn,
 				     RDMA_PS_TCP, IB_QPT_RC);
 	if (IS_ERR(ic->i_cm_id)) {
@@ -923,7 +924,7 @@ int rds_ib_conn_path_connect(struct rds_conn_path *cp)
 		sin6 = (struct sockaddr_in6 *)&dest;
 		sin6->sin6_family = AF_INET6;
 		sin6->sin6_addr = conn->c_faddr;
-		sin6->sin6_port = (__force u16)htons(RDS_TCP_PORT);
+		sin6->sin6_port = (__force u16)htons(RDS_CM_PORT);
 		sin6->sin6_scope_id = conn->c_dev_if;
 	}
 
net/rds/rdma_transport.c +30 -2
index d7da115..6a696b8 100644
@@ -37,7 +37,9 @@
 #include "rdma_transport.h"
 #include "ib.h"
 
+/* Global IPv4 and IPv6 RDS RDMA listener cm_id */
 static struct rdma_cm_id *rds_rdma_listen_id;
+static struct rdma_cm_id *rds6_rdma_listen_id;
 
 int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
 				  struct rdma_cm_event *event,
@@ -153,6 +155,12 @@ int rds_rdma_cm_event_handler(struct rdma_cm_id *cm_id,
 	return rds_rdma_cm_event_handler_cmn(cm_id, event, false);
 }
 
+int rds6_rdma_cm_event_handler(struct rdma_cm_id *cm_id,
+			       struct rdma_cm_event *event)
+{
+	return rds_rdma_cm_event_handler_cmn(cm_id, event, true);
+}
+
 static int rds_rdma_listen_init_common(rdma_cm_event_handler handler,
 				       struct sockaddr *sa,
 				       struct rdma_cm_id **ret_cm_id)
@@ -199,13 +207,14 @@ static int rds_rdma_listen_init_common(rdma_cm_event_handler handler,
 
 /* Initialize the RDS RDMA listeners.  We create two listeners for
  * compatibility reason.  The one on RDS_PORT is used for IPv4
- * requests only.  The one on RDS_TCP_PORT is used for IPv6 requests
+ * requests only.  The one on RDS_CM_PORT is used for IPv6 requests
  * only.  So only IPv6 enabled RDS module will communicate using this
  * port.
  */
 static int rds_rdma_listen_init(void)
 {
 	int ret;
+	struct sockaddr_in6 sin6;
 	struct sockaddr_in sin;
 
 	sin.sin_family = PF_INET;
@@ -214,7 +223,21 @@ static int rds_rdma_listen_init(void)
 	ret = rds_rdma_listen_init_common(rds_rdma_cm_event_handler,
 					  (struct sockaddr *)&sin,
 					  &rds_rdma_listen_id);
-	return ret;
+	if (ret != 0)
+		return ret;
+
+	sin6.sin6_family = PF_INET6;
+	sin6.sin6_addr = in6addr_any;
+	sin6.sin6_port = htons(RDS_CM_PORT);
+	sin6.sin6_scope_id = 0;
+	sin6.sin6_flowinfo = 0;
+	ret = rds_rdma_listen_init_common(rds6_rdma_cm_event_handler,
+					  (struct sockaddr *)&sin6,
+					  &rds6_rdma_listen_id);
+	/* Keep going even when IPv6 is not enabled in the system. */
+	if (ret != 0)
+		rdsdebug("Cannot set up IPv6 RDMA listener\n");
+	return 0;
 }
 
 static void rds_rdma_listen_stop(void)
@@ -224,6 +247,11 @@ static void rds_rdma_listen_stop(void)
 		rdma_destroy_id(rds_rdma_listen_id);
 		rds_rdma_listen_id = NULL;
 	}
+	if (rds6_rdma_listen_id) {
+		rdsdebug("cm %p\n", rds6_rdma_listen_id);
+		rdma_destroy_id(rds6_rdma_listen_id);
+		rds6_rdma_listen_id = NULL;
+	}
 }
 
 static int rds_rdma_init(void)
net/rds/rdma_transport.h +2 -0
index d309c44..bc3c639 100644
@@ -11,6 +11,8 @@
 int rds_rdma_conn_connect(struct rds_connection *conn);
 int rds_rdma_cm_event_handler(struct rdma_cm_id *cm_id,
 			      struct rdma_cm_event *event);
+int rds6_rdma_cm_event_handler(struct rdma_cm_id *cm_id,
+			       struct rdma_cm_event *event);
 
 /* from ib.c */
 extern struct rds_transport rds_ib_transport;
net/rds/rds.h +7 -5
index 859808a..f5f99d1 100644
@@ -24,13 +24,15 @@
 #define RDS_PROTOCOL_MINOR(v)	((v) & 255)
 #define RDS_PROTOCOL(maj, min)	(((maj) << 8) | min)
 
-/*
- * XXX randomly chosen, but at least seems to be unused:
- * #               18464-18768 Unassigned
- * We should do better.  We want a reserved port to discourage unpriv'ed
- * userspace from listening.
+/* The following ports, 16385, 18634, 18635, are registered with IANA as
+ * the ports to be used for RDS over TCP and UDP.  18634 is the historical
+ * value used for the RDMA_CM listener port.  RDS/TCP uses port 16385.  After
+ * IPv6 work, RDMA_CM also uses 16385 as the listener port.  18634 is kept
+ * to ensure compatibility with older RDS modules.
  */
 #define RDS_PORT	18634
+#define RDS_CM_PORT	16385
+#define RDS_TCP_PORT	RDS_CM_PORT
 
 #ifdef ATOMIC64_INIT
 #define KERNEL_HAS_ATOMIC64
net/rds/send.c +21 -2
index cc91860..3bc806b 100644
@@ -1105,8 +1105,27 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
 			break;
 
 		case sizeof(*sin6): {
-			ret = -EPROTONOSUPPORT;
-			goto out;
+			int addr_type;
+
+			if (sin6->sin6_family != AF_INET6) {
+				ret = -EINVAL;
+				goto out;
+			}
+			addr_type = ipv6_addr_type(&sin6->sin6_addr);
+			if (!(addr_type & IPV6_ADDR_UNICAST)) {
+				ret = -EINVAL;
+				goto out;
+			}
+			if (addr_type & IPV6_ADDR_LINKLOCAL &&
+			    sin6->sin6_scope_id == 0) {
+				ret = -EINVAL;
+				goto out;
+			}
+
+			daddr = sin6->sin6_addr;
+			dport = sin6->sin6_port;
+			scope_id = sin6->sin6_scope_id;
+			break;
 		}
 
 		default:
net/rds/tcp.c +34 -20

103 lines not on this page · raw message

net/rds/tcp.h +1 -3
index c6fa080..6a948c1 100644
@@ -2,8 +2,6 @@
 #ifndef _RDS_TCP_H
 #define _RDS_TCP_H
 
-#define RDS_TCP_PORT	16385
-
 struct rds_tcp_incoming {
 	struct rds_incoming	ti_inc;
 	struct sk_buff_head	ti_skb_list;
@@ -67,7 +65,7 @@ void rds_tcp_restore_callbacks(struct socket *sock,
 void rds_tcp_state_change(struct sock *sk);
 
 /* tcp_listen.c */
-struct socket *rds_tcp_listen_init(struct net *);
+struct socket *rds_tcp_listen_init(struct net *net, bool isv6);
 void rds_tcp_listen_stop(struct socket *sock, struct work_struct *acceptor);
 void rds_tcp_listen_data_ready(struct sock *sk);
 int rds_tcp_accept_one(struct socket *sock);
net/rds/tcp_connect.c +42 -12

80 lines not on this page · raw message

net/rds/tcp_listen.c +31 -9
index 4fdf5b3..0f996e4 100644
@@ -256,15 +256,22 @@ void rds_tcp_listen_data_ready(struct sock *sk)
 		ready(sk);
 }
 
-struct socket *rds_tcp_listen_init(struct net *net)
+struct socket *rds_tcp_listen_init(struct net *net, bool isv6)
 {
-	struct sockaddr_in sin;
 	struct socket *sock = NULL;
+	struct sockaddr_storage ss;
+	struct sockaddr_in6 *sin6;
+	struct sockaddr_in *sin;
+	int addr_len;
 	int ret;
 
-	ret = sock_create_kern(net, PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
-	if (ret < 0)
+	ret = sock_create_kern(net, isv6 ? PF_INET6 : PF_INET, SOCK_STREAM,
+			       IPPROTO_TCP, &sock);
+	if (ret < 0) {
+		rdsdebug("could not create %s listener socket: %d\n",
+			 isv6 ? "IPv6" : "IPv4", ret);
 		goto out;
+	}
 
 	sock->sk->sk_reuse = SK_CAN_REUSE;
 	rds_tcp_nonagle(sock);
@@ -274,13 +281,28 @@ struct socket *rds_tcp_listen_init(struct net *net)
 	sock->sk->sk_data_ready = rds_tcp_listen_data_ready;
 	write_unlock_bh(&sock->sk->sk_callback_lock);
 
-	sin.sin_family = PF_INET;
-	sin.sin_addr.s_addr = (__force u32)htonl(INADDR_ANY);
-	sin.sin_port = (__force u16)htons(RDS_TCP_PORT);
+	if (isv6) {
+		sin6 = (struct sockaddr_in6 *)&ss;
+		sin6->sin6_family = PF_INET6;
+		sin6->sin6_addr = in6addr_any;
+		sin6->sin6_port = (__force u16)htons(RDS_TCP_PORT);
+		sin6->sin6_scope_id = 0;
+		sin6->sin6_flowinfo = 0;
+		addr_len = sizeof(*sin6);
+	} else {
+		sin = (struct sockaddr_in *)&ss;
+		sin->sin_family = PF_INET;
+		sin->sin_addr.s_addr = INADDR_ANY;
+		sin->sin_port = (__force u16)htons(RDS_TCP_PORT);
+		addr_len = sizeof(*sin);
+	}
 
-	ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin));
-	if (ret < 0)
+	ret = sock->ops->bind(sock, (struct sockaddr *)&ss, addr_len);
+	if (ret < 0) {
+		rdsdebug("could not bind %s listener socket: %d\n",
+			 isv6 ? "IPv6" : "IPv4", ret);
 		goto out;
+	}
 
 	ret = sock->ops->listen(sock, 64);
 	if (ret < 0)
Signature · 1 line
1.8.3.1
#5 lore raw

Re: [PATCH net-next 2/3] rds: Enable RDS IPv6 support

Thank you for the patch! Perhaps something to improve:

Hi Ka-Cheong,

Thank you for the patch! Perhaps something to improve:

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

url: https://github.com/0day-ci/linux/commits/Ka-Cheong-Poon/rds-IPv6-support/20180625-190047
reproduce:

        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__

sparse warnings: (new ones prefixed by >>)

net/rds/tcp_listen.c:86:22: sparse: expression using sizeof(void)

>> net/rds/tcp_listen.c:288:33: sparse: incorrect type in assignment (different base types) @@    expected restricted __be16 [usertype] sin6_port @@    got unsignedrestricted __be16 [usertype] sin6_port @@
   net/rds/tcp_listen.c:288:33:    expected restricted __be16 [usertype] sin6_port
   net/rds/tcp_listen.c:288:33:    got unsigned short [unsigned] [usertype] <noident>
>> net/rds/tcp_listen.c:295:38: sparse: incorrect type in assignment (different base types) @@    expected restricted __be32 [usertype] s_addr @@    got ricted __be32 [usertype] s_addr @@
   net/rds/tcp_listen.c:295:38:    expected restricted __be32 [usertype] s_addr
   net/rds/tcp_listen.c:295:38:    got unsigned long [unsigned] <noident>
>> net/rds/tcp_listen.c:296:31: sparse: incorrect type in assignment (different base types) @@    expected restricted __be16 [usertype] sin_port @@    got unsignedrestricted __be16 [usertype] sin_port @@

net/rds/tcp_listen.c:296:31: expected restricted __be16 [usertype] sin_port
net/rds/tcp_listen.c:296:31: got unsigned short [unsigned] [usertype] <noident>

vim +288 net/rds/tcp_listen.c

258
259 struct socket *rds_tcp_listen_init(struct net *net, bool isv6)
260 {
261 struct socket *sock = NULL;
262 struct sockaddr_storage ss;
263 struct sockaddr_in6 *sin6;
264 struct sockaddr_in *sin;
265 int addr_len;
266 int ret;
267
268 ret = sock_create_kern(net, isv6 ? PF_INET6 : PF_INET, SOCK_STREAM,
269 IPPROTO_TCP, &sock);
270 if (ret < 0) {
271 rdsdebug("could not create %s listener socket: %d\n",
272 isv6 ? "IPv6" : "IPv4", ret);
273 goto out;
274 }
275
276 sock->sk->sk_reuse = SK_CAN_REUSE;
277 rds_tcp_nonagle(sock);
278
279 write_lock_bh(&sock->sk->sk_callback_lock);
280 sock->sk->sk_user_data = sock->sk->sk_data_ready;
281 sock->sk->sk_data_ready = rds_tcp_listen_data_ready;
282 write_unlock_bh(&sock->sk->sk_callback_lock);
283
284 if (isv6) {
285 sin6 = (struct sockaddr_in6 *)&ss;
286 sin6->sin6_family = PF_INET6;
287 sin6->sin6_addr = in6addr_any;

 > 288			sin6->sin6_port = (__force u16)htons(RDS_TCP_PORT);
   289			sin6->sin6_scope_id = 0;
   290			sin6->sin6_flowinfo = 0;
   291			addr_len = sizeof(*sin6);
   292		} else {
   293			sin = (struct sockaddr_in *)&ss;
   294			sin->sin_family = PF_INET;
 > 295			sin->sin_addr.s_addr = INADDR_ANY;
 > 296			sin->sin_port = (__force u16)htons(RDS_TCP_PORT);

297 addr_len = sizeof(*sin);
298 }
299
300 ret = sock->ops->bind(sock, (struct sockaddr *)&ss, addr_len);
301 if (ret < 0) {
302 rdsdebug("could not bind %s listener socket: %d\n",
303 isv6 ? "IPv6" : "IPv4", ret);
304 goto out;
305 }
306
307 ret = sock->ops->listen(sock, 64);
308 if (ret < 0)
309 goto out;
310
311 return sock;
312 out:
313 if (sock)
314 sock_release(sock);
315 return NULL;
316 }
317

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

#6 lore raw

Re: [PATCH net-next 2/3] rds: Enable RDS IPv6 support

In reply to Ka-Cheong Poon

net/rds/send.c int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) · line 1108

Quoted 7 lines · Ka-Cheong Poon
net/rds/send.c +1 -2
@@ -1105,8 +1105,27 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
 			break;
 
 		case sizeof(*sin6): {
-			ret = -EPROTONOSUPPORT;
-			goto out;
+			int addr_type;
                         :
                         :

net/rds/send.c int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) · line 1129

Quoted 5 lines
net/rds/send.c +4 -0
+			daddr = sin6->sin6_addr;
+			dport = sin6->sin6_port;
+			scope_id = sin6->sin6_scope_id;
+			break;
 		}

In rds_sendmsg, the scopeid passed to rds_conn_create_outgoing may come from the msg_name (if msg_name is a link-local) or may come from the rs_bound_scope_id (for connected socket, change made in Patch 1 of the series).

This sounds inconsistent.

If I bind to scopeid if1 and then send to fe80::1%if2 (without connect()), we'd create an rds_connection with dev_if set to if2.
(first off, its a bit unexpected to be sending to fe80::1%if2 when you are bound to a link-local on if1!)

But then, if we got back a response from fe80::1%if2, I think we would not find a matching conn in rds_recv_incoming?

And this is even more confusing because the fastpath in rds_sendmsg does not take the bound_scope_id into consideration at all:
1213 if (rs->rs_conn && ipv6_addr_equal(&rs->rs_conn->c_faddr, &daddr))
1214 conn = rs->rs_conn;
1215 else {
1216 conn = rds_conn_create_outgoing( /* .. */, scope_id)
so if I erroneously passed a msg_name on a connected rds socket, what would happen? (see also question about rds_connect() itself, below)

Should we always use rs_bound_scope_id for creating the outgoing rds_connection? (you may need something deterministic for this, like "if bound addr is linklocal, return error if daddr has a different scopeid, else use the bound addr's scopeid", plus, "if bound addr is not global, and daddr is link-local, we need a conn with the daddr's scopeid")

Also, why is there no IPv6 support in rds_connect?

(still looking through the rds-tcp changes, but wanted to get these questions clarified first).

--Sowmini

#7 lore raw

Re: [PATCH net-next 2/3] rds: Enable RDS IPv6 support

Quoted 23 lines · Sowmini Varadhan

net/rds/send.c int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) · line 1108

Quoted 7 lines · Ka-Cheong Poon
net/rds/send.c +1 -2
@@ -1105,8 +1105,27 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
  			break;
 
  		case sizeof(*sin6): {
-			ret = -EPROTONOSUPPORT;
-			goto out;
+			int addr_type;
                          :
                          :

net/rds/send.c int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) · line 1129

Quoted 5 lines
net/rds/send.c +4 -0
+			daddr = sin6->sin6_addr;
+			dport = sin6->sin6_port;
+			scope_id = sin6->sin6_scope_id;
+			break;
  		}

In rds_sendmsg, the scopeid passed to rds_conn_create_outgoing may come from the msg_name (if msg_name is a link-local) or may come from the rs_bound_scope_id (for connected socket, change made in Patch 1 of the series).

This sounds inconsistent.

Quoted 7 lines

If I bind to scopeid if1 and then send to fe80::1%if2 (without connect()), we'd create an rds_connection with dev_if set to if2.
(first off, its a bit unexpected to be sending to fe80::1%if2 when you are bound to a link-local on if1!)

But then, if we got back a response from fe80::1%if2, I think we would not find a matching conn in rds_recv_incoming?

Yes, I think if the socket is bound, it should check the scope_id in msg_name (if not NULL) to make sure that they match. A bound RDS socket can send to multiple peers. But if the bound local address is link local, it should only be allowed to send to peers on the same link.

Quoted 8 lines

And this is even more confusing because the fastpath in rds_sendmsg does not take the bound_scope_id into consideration at all:
1213 if (rs->rs_conn && ipv6_addr_equal(&rs->rs_conn->c_faddr, &daddr))
1214 conn = rs->rs_conn;
1215 else {
1216 conn = rds_conn_create_outgoing( /* .. */, scope_id)
so if I erroneously passed a msg_name on a connected rds socket, what would happen? (see also question about rds_connect() itself, below)

The check added above takes care of this. The scope_id should match.

Quoted 6 lines

Should we always use rs_bound_scope_id for creating the outgoing rds_connection? (you may need something deterministic for this, like "if bound addr is linklocal, return error if daddr has a different scopeid, else use the bound addr's scopeid", plus, "if bound addr is not global, and daddr is link-local, we need a conn with the daddr's scopeid")

If a socket is bound, I guess the scope_id should be used. So if a socket is not bound to a link local address and the socket is used to sent to a link local peer, it should fail.

Quoted 1 line

Also, why is there no IPv6 support in rds_connect?

Oops, I missed this when I ported the internal version to the net-next version. Will add it back.

Signature · 2 lines
K. Poon
[email protected]
#8 lore raw

Re: [PATCH net-next 2/3] rds: Enable RDS IPv6 support

Quoted 6 lines · Ka-Cheong Poon

Yes, I think if the socket is bound, it should check the scope_id in msg_name (if not NULL) to make sure that they match. A bound RDS socket can send to multiple peers. But if the bound local address is link local, it should only be allowed to send to peers on the same link.

agree.

Quoted 3 lines

If a socket is bound, I guess the scope_id should be used. So if a socket is not bound to a link local address and the socket is used to sent to a link local peer, it should fail.

PF_RDS sockets *MUST* alwasy be bound. See Documentation/networking/rds.txt:
" Sockets must be bound before you can send or receive data.
This is needed because binding also selects a transport and attaches it to the socket. Once bound, the transport assignment does not change."

Also, rds_sendmsg checks this (from net-next, your version has the equivalent ipv6_addr_any etc check):

        if (daddr == 0 || rs->rs_bound_addr == 0) {
                release_sock(sk);
                ret = -ENOTCONN; /* XXX not a great errno */
                goto out;
        }
Quoted 6 lines
Quoted 2 lines

Also, why is there no IPv6 support in rds_connect?

Oops, I missed this when I ported the internal version to the net-next version. Will add it back.

Ok

--Sowmini

#9 lore raw

Re: [PATCH net-next 2/3] rds: Enable RDS IPv6 support

Quoted 9 lines · Sowmini Varadhan
Quoted 6 lines · Ka-Cheong Poon

Yes, I think if the socket is bound, it should check the scope_id in msg_name (if not NULL) to make sure that they match. A bound RDS socket can send to multiple peers. But if the bound local address is link local, it should only be allowed to send to peers on the same link.

agree.

Yep. Its inline with RDS bind behavior.

Quoted 6 lines
Quoted 5 lines

If a socket is bound, I guess the scope_id should be used. So if a socket is not bound to a link local address and the socket is used to sent to a link local peer, it should fail.

Quoted 7 lines

PF_RDS sockets *MUST* alwasy be bound. See Documentation/networking/rds.txt:
" Sockets must be bound before you can send or receive data.
This is needed because binding also selects a transport and attaches it to the socket. Once bound, the transport assignment does not change."

In any case link local or not, the socket needs to be bound before any data can be sent as documented. Send path already enforces it.

Quoted 6 lines
Quoted 5 lines
Quoted 1 line

Also, why is there no IPv6 support in rds_connect?

Oops, I missed this when I ported the internal version to the net-next version. Will add it back.

So the net-next wasn't tested? IPv6 connections itself wouldn't be formed with this missing. As mentioned already, please test v2 before posting on list.

Regards,
Santosh

#10 lore raw

Re: [PATCH net-next 2/3] rds: Enable RDS IPv6 support

In reply to Sowmini Varadhan
Quoted 11 lines · Sowmini Varadhan
Quoted 3 lines

If a socket is bound, I guess the scope_id should be used. So if a socket is not bound to a link local address and the socket is used to sent to a link local peer, it should fail.

PF_RDS sockets *MUST* alwasy be bound. See Documentation/networking/rds.txt:
" Sockets must be bound before you can send or receive data.
This is needed because binding also selects a transport and attaches it to the socket. Once bound, the transport assignment does not change."

Quoted 8 lines

Also, rds_sendmsg checks this (from net-next, your version has the equivalent ipv6_addr_any etc check):

         if (daddr == 0 || rs->rs_bound_addr == 0) {
                 release_sock(sk);
                 ret = -ENOTCONN; /* XXX not a great errno */
                 goto out;
         }

I think you misunderstood what I wrote. The above is in response to your original question:

--

Quoted 8 lines

And this is even more confusing because the fastpath in rds_sendmsg does not take the bound_scope_id into consideration at all:
1213 if (rs->rs_conn && ipv6_addr_equal(&rs->rs_conn->c_faddr, &daddr))
1214 conn = rs->rs_conn;
1215 else {
1216 conn = rds_conn_create_outgoing( /* .. */, scope_id)
so if I erroneously passed a msg_name on a connected rds socket, what would happen? (see also question about rds_connect() itself, below)

#11 lore raw

Re: [PATCH net-next 2/3] rds: Enable RDS IPv6 support

Quoted 5 lines · Ka-Cheong Poon

My answer to this is that if a socket is not bound to a link local address (meaning it is bound to a non-link local address) and it is used to send to a link local peer, I think it should fail.

Hmm, I'm not sure I agree. I dont think this is forbidden by RFC 6724 - yes, such a packet cannot be forwarded, but if everything is on the same link, and the dest only has a link-local, you should not need to (create and) bind another socket to a link-local to talk to this destination..

Quoted 6 lines

This is consistent with the scope_id check I mentioned in
the previous mail. If the socket is not bound to a link local address, the bound_scope_id is 0. So if the socket is used to send to a link local address (which has a non-zero scope_id), the check will catch it and fail the call. A new conn should not be created in this case.

#12 lore raw

Re: [PATCH net-next 2/3] rds: Enable RDS IPv6 support

Quoted 7 lines · Sowmini Varadhan
Quoted 5 lines · Ka-Cheong Poon

My answer to this is that if a socket is not bound to a link local address (meaning it is bound to a non-link local address) and it is used to send to a link local peer, I think it should fail.

Quoted 5 lines

Hmm, I'm not sure I agree. I dont think this is forbidden by RFC 6724 - yes, such a packet cannot be forwarded, but if everything is on the same link, and the dest only has a link-local, you should not need to (create and) bind another socket to a link-local to talk to this destination..

In this case, RFC 6724 prefers link local address as source. While using non-link local address (say ULA) is not forbidden, doing this can easily cause inter-operability issues (does the app really know that the non-link local source and the link local destination addresses are really on the same link?). I think it is prudent to disallow this in RDS unless there is a very clear and important reason to do so. BTW, if it is really needed, it can be added in future.

Quoted 7 lines
Quoted 6 lines

This is consistent with the scope_id check I mentioned in
the previous mail. If the socket is not bound to a link local address, the bound_scope_id is 0. So if the socket is used to send to a link local address (which has a non-zero scope_id), the check will catch it and fail the call. A new conn should not be created in this case.

Signature · 2 lines
K. Poon
[email protected]
#13 lore raw

Re: [PATCH net-next 2/3] rds: Enable RDS IPv6 support

Quoted 2 lines · Ka-Cheong Poon

In this case, RFC 6724 prefers link local address as source.

the keyword is "prefers".

Quoted 6 lines

While using non-link local address (say ULA) is not forbidden, doing this can easily cause inter-operability issues (does the app really know that the non-link local source and the link local destination addresses are really on the same link?). I think it is prudent to disallow this in RDS unless there is a very clear and important reason to do so.

I remember the issues that triggered 6724. The "interop" issue is that when you send from Link-local to global, and need forwarding, it may not work.

but I dont think an RDS application today expects to deal with the case that "oh I got back and error when I tried to send to address X on rds socket rs1, let me go and check what I am bound to, and maybe create another socket, and bind it to link-local"

You're not doing this for IPv4 and RDS today (you dont have to do this for UDP, afaik)

This is especially true if "X" is a hostname that got resovled using DNS

Quoted 1 line

BTW, if it is really > needed, it can be added in future.

shrug. You are introducing a new error return.

--Sowmini

#14 lore raw

Re: [PATCH net-next 2/3] rds: Enable RDS IPv6 support

Quoted 5 lines · Sowmini Varadhan
Quoted 2 lines · Ka-Cheong Poon

In this case, RFC 6724 prefers link local address as source.

the keyword is "prefers".

There is a reason for that. It is the way folks expect how IPv6 addresses are being used.

Quoted 10 lines
Quoted 6 lines

While using non-link local address (say ULA) is not forbidden, doing this can easily cause inter-operability issues (does the app really know that the non-link local source and the link local destination addresses are really on the same link?). I think it is prudent to disallow this in RDS unless there is a very clear and important reason to do so.

I remember the issues that triggered 6724. The "interop" issue is that when you send from Link-local to global, and need forwarding, it may not work.

It is not just forwarding. The simple case is that one picks a global address in a different link and then use it to send to a link local address in another link. This does not work. And the RDS connection created will be stuck forever. I don't think this is a good idea to have such stuck connections.

Quoted 4 lines

but I dont think an RDS application today expects to deal with the case that "oh I got back and error when I tried to send to address X on rds socket rs1, let me go and check what I am bound to, and maybe create another socket, and bind it to link-local"

I don't expect RDS apps will want to use link local address in the first place. In fact, most normal network apps don't.

Quoted 2 lines

You're not doing this for IPv4 and RDS today (you dont have to do this for UDP, afaik)

Do you know of any IPv4 RDS app which uses IPv4 link local address? In fact, IPv4 link local address is explicitly disallowed for active active bonding.

Quoted 1 line

This is especially true if "X" is a hostname that got resovled using DNS

Can you explain why DNS name resolution will return an IPv6 link local address? I'm surprised if it actually does.

Quoted 3 lines
Quoted 1 line

BTW, if it is really > needed, it can be added in future.

shrug. You are introducing a new error return.

An error needs to be returned because it is not allowed.

Signature · 2 lines
K. Poon
[email protected]
#15 lore raw

Re: [PATCH net-next 2/3] rds: Enable RDS IPv6 support

Quoted 3 lines · Ka-Cheong Poon

There is a reason for that. It is the way folks expect how IPv6 addresses are being used.

have you tried "traceoute6 -s abc::2 fe80::2" on linux?

Quoted 3 lines

It is not just forwarding. The simple case is that one picks a global address in a different link and then use it to send to a link local address in another link.

This is actually not any different than ipv4's strong/weak ES model.

Global addresses are supposed to be globally routable. For your above example, if yuu do that, it is assumed that your routing table has been set up suitably.

To state what may be well-known:
This does not work for link-locals, becuase, as the name suggests, those are local to the link and you may have the same link-local on multiple links

Quoted 2 lines

This does not work. And the RDS connection created will be stuck forever.

that is a different problem in the RDS implementation (that it does not backoff and timeout a failing reconnect)

As you can see from the traceroute6 example, global <-> link-local is supported for udp (and probably also tcp sockets, I have not checked that case)

Quoted 2 lines

I don't expect RDS apps will want to use link local address in the first place. In fact, most normal network apps don't.

:

Quoted 3 lines

Do you know of any IPv4 RDS app which uses IPv4 link local address? In fact, IPv4 link local address is explicitly disallowed for active active bonding.

Are we talking about "why this ok for my particular use of link-local, so I can slide my patch forward" or, "why this is correct IPv6 behavior"?

Quoted 2 lines

Can you explain why DNS name resolution will return an IPv6 link local address? I'm surprised if it actually does.

It depends on how you set up your DNS.

It seems like this is all about "I dont want to deal with this now", so I dont want to continue this discussion which is really going nowhere.

Thanks

--Sowmini

#16 lore raw

Re: [PATCH net-next 2/3] rds: Enable RDS IPv6 support

In reply to Ka-Cheong Poon
Quoted 2 lines · Ka-Cheong Poon
Quoted 1 line · Sowmini Varadhan

On (06/26/18 21:02), Ka-Cheong Poon wrote:

[...]

Quoted 5 lines

I don't expect RDS apps will want to use link local address in the first place.  In fact, most normal network apps don't.

This is not true.

Quoted 9 lines
Quoted 3 lines

You're not doing this for IPv4 and RDS today (you dont have to do this for UDP, afaik)

Do you know of any IPv4 RDS app which uses IPv4 link local address?  In fact, IPv4 link local address is explicitly disallowed for active active bonding.

Yes. Cluster-ware HAIP makes use of link local addresses. That check was mainly because of RDMA CM issues but that only means active-active isn't used. The bonding works just fine and if needed cluster-ware can also use TCP transport.

Lets not add this new behavior for link local and its actually not relevant to really v6 addressing support.

Regards,
Santosh

#17 lore raw

PATCH 3/3 rds: Extend RDS API for IPv6 support

In reply to Ka-Cheong Poon

There are many data structures (RDS socket options) used by RDS apps which use a 32 bit integer to store IP address. To support IPv6, struct in6_addr needs to be used. To ensure backward compatibility, a new data structure is introduced for each of those data structures which use a 32 bit integer to represent an IP address. And new socket options are introduced to use those new structures. This means that existing apps should work without a problem with the new RDS module. For apps which want to use IPv6, those new data structures and socket options can be used. IPv4 mapped address is used to represent IPv4 address in the new data structures.

---
 include/uapi/linux/rds.h | 71 +++++++++++++++++++++++++++++++++--
 net/rds/connection.c     | 97 ++++++++++++++++++++++++++++++++++++++++++++----
 net/rds/ib.c             | 52 ++++++++++++++++++++++++++
 net/rds/ib_mr.h          |  2 +
 net/rds/ib_rdma.c        | 11 +++++-
 net/rds/rds.h            |  4 ++
 net/rds/recv.c           | 25 +++++++++++++
 net/rds/tcp.c            | 44 ++++++++++++++++++++++
 8 files changed, 295 insertions(+), 11 deletions(-)
include/uapi/linux/rds.h +68 -3
index 20c6bd0..518d40f 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
 /*
- * Copyright (c) 2008 Oracle.  All rights reserved.
+ * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -52,7 +52,7 @@
 #define RDS_RECVERR			5
 #define RDS_CONG_MONITOR		6
 #define RDS_GET_MR_FOR_DEST		7
-#define SO_RDS_TRANSPORT		8
+#define SO_RDS_TRANSPORT		9
 
 /* Socket option to tap receive path latency
  *	SO_RDS: SO_RDS_MSG_RXPATH_LATENCY
@@ -118,7 +118,17 @@
 #define RDS_INFO_IB_CONNECTIONS		10008
 #define RDS_INFO_CONNECTION_STATS	10009
 #define RDS_INFO_IWARP_CONNECTIONS	10010
-#define RDS_INFO_LAST			10010
+
+/* PF_RDS6 options */
+#define RDS6_INFO_CONNECTIONS		10011
+#define RDS6_INFO_SEND_MESSAGES		10012
+#define RDS6_INFO_RETRANS_MESSAGES	10013
+#define RDS6_INFO_RECV_MESSAGES		10014
+#define RDS6_INFO_SOCKETS		10015
+#define RDS6_INFO_TCP_SOCKETS		10016
+#define RDS6_INFO_IB_CONNECTIONS	10017
+
+#define RDS_INFO_LAST			10017
 
 struct rds_info_counter {
 	__u8	name[32];
@@ -140,6 +150,15 @@ struct rds_info_connection {
 	__u8		flags;
 } __attribute__((packed));
 
+struct rds6_info_connection {
+	__u64		next_tx_seq;
+	__u64		next_rx_seq;
+	struct in6_addr	laddr;
+	struct in6_addr	faddr;
+	__u8		transport[TRANSNAMSIZ];		/* null term ascii */
+	__u8		flags;
+} __attribute__((packed));
+
 #define RDS_INFO_MESSAGE_FLAG_ACK               0x01
 #define RDS_INFO_MESSAGE_FLAG_FAST_ACK          0x02
 
@@ -153,6 +172,17 @@ struct rds_info_message {
 	__u8		flags;
 } __attribute__((packed));
 
+struct rds6_info_message {
+	__u64	seq;
+	__u32	len;
+	struct in6_addr	laddr;
+	struct in6_addr	faddr;
+	__be16		lport;
+	__be16		fport;
+	__u8		flags;
+	__u8		tos;
+} __attribute__((packed));
+
 struct rds_info_socket {
 	__u32		sndbuf;
 	__be32		bound_addr;
@@ -163,6 +193,16 @@ struct rds_info_socket {
 	__u64		inum;
 } __attribute__((packed));
 
+struct rds6_info_socket {
+	__u32		sndbuf;
+	struct in6_addr	bound_addr;
+	struct in6_addr	connected_addr;
+	__be16		bound_port;
+	__be16		connected_port;
+	__u32		rcvbuf;
+	__u64		inum;
+} __attribute__((packed));
+
 struct rds_info_tcp_socket {
 	__be32          local_addr;
 	__be16          local_port;
@@ -175,6 +215,18 @@ struct rds_info_tcp_socket {
 	__u32           last_seen_una;
 } __attribute__((packed));
 
+struct rds6_info_tcp_socket {
+	struct in6_addr	local_addr;
+	__be16		local_port;
+	struct in6_addr	peer_addr;
+	__be16		peer_port;
+	__u64		hdr_rem;
+	__u64		data_rem;
+	__u32		last_sent_nxt;
+	__u32		last_expected_una;
+	__u32		last_seen_una;
+} __attribute__((packed));
+
 #define RDS_IB_GID_LEN	16
 struct rds_info_rdma_connection {
 	__be32		src_addr;
@@ -189,6 +241,19 @@ struct rds_info_rdma_connection {
 	__u32		rdma_mr_size;
 };
 
+struct rds6_info_rdma_connection {
+	struct in6_addr	src_addr;
+	struct in6_addr	dst_addr;
+	__u8		src_gid[RDS_IB_GID_LEN];
+	__u8		dst_gid[RDS_IB_GID_LEN];
+
+	__u32		max_send_wr;
+	__u32		max_recv_wr;
+	__u32		max_send_sge;
+	__u32		rdma_mr_max;
+	__u32		rdma_mr_size;
+};
+
 /* RDS message Receive Path Latency points */
 enum rds_message_rxpath_latency {
 	RDS_MSG_RX_HDR_TO_DGRAM_START = 0,
net/rds/connection.c +90 -7

169 lines not on this page · raw message

net/rds/ib.c +52 -0

76 lines not on this page · raw message

net/rds/ib_mr.h +2 -0
index 0ea4ab0..f440ace 100644
@@ -113,6 +113,8 @@ struct rds_ib_mr_pool *rds_ib_create_mr_pool(struct rds_ib_device *rds_dev,
 					     int npages);
 void rds_ib_get_mr_info(struct rds_ib_device *rds_ibdev,
 			struct rds_info_rdma_connection *iinfo);
+void rds6_ib_get_mr_info(struct rds_ib_device *rds_ibdev,
+			 struct rds6_info_rdma_connection *iinfo6);
 void rds_ib_destroy_mr_pool(struct rds_ib_mr_pool *);
 void *rds_ib_get_mr(struct scatterlist *sg, unsigned long nents,
 		    struct rds_sock *rs, u32 *key_ret);
net/rds/ib_rdma.c +10 -1
index 0ec9df0..e3c8bbb 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -180,6 +180,15 @@ void rds_ib_get_mr_info(struct rds_ib_device *rds_ibdev, struct rds_info_rdma_co
 	iinfo->rdma_mr_size = pool_1m->fmr_attr.max_pages;
 }
 
+void rds6_ib_get_mr_info(struct rds_ib_device *rds_ibdev,
+			 struct rds6_info_rdma_connection *iinfo6)
+{
+	struct rds_ib_mr_pool *pool_1m = rds_ibdev->mr_1m_pool;
+
+	iinfo6->rdma_mr_max = pool_1m->max_items;
+	iinfo6->rdma_mr_size = pool_1m->fmr_attr.max_pages;
+}
+
 struct rds_ib_mr *rds_ib_reuse_mr(struct rds_ib_mr_pool *pool)
 {
 	struct rds_ib_mr *ibmr = NULL;
net/rds/rds.h +4 -0
index f5f99d1..fd63b86 100644
@@ -875,6 +875,10 @@ int rds_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
 void rds_inc_info_copy(struct rds_incoming *inc,
 		       struct rds_info_iterator *iter,
 		       __be32 saddr, __be32 daddr, int flip);
+void rds6_inc_info_copy(struct rds_incoming *inc,
+			struct rds_info_iterator *iter,
+			struct in6_addr *saddr, struct in6_addr *daddr,
+			int flip);
 
 /* send.c */
 int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len);
net/rds/recv.c +25 -0
index 4217961..10a2d0f 100644
@@ -792,3 +792,28 @@ void rds_inc_info_copy(struct rds_incoming *inc,
 
 	rds_info_copy(iter, &minfo, sizeof(minfo));
 }
+
+void rds6_inc_info_copy(struct rds_incoming *inc,
+			struct rds_info_iterator *iter,
+			struct in6_addr *saddr, struct in6_addr *daddr,
+			int flip)
+{
+	struct rds6_info_message minfo6;
+
+	minfo6.seq = be64_to_cpu(inc->i_hdr.h_sequence);
+	minfo6.len = be32_to_cpu(inc->i_hdr.h_len);
+
+	if (flip) {
+		minfo6.laddr = *daddr;
+		minfo6.faddr = *saddr;
+		minfo6.lport = inc->i_hdr.h_dport;
+		minfo6.fport = inc->i_hdr.h_sport;
+	} else {
+		minfo6.laddr = *saddr;
+		minfo6.faddr = *daddr;
+		minfo6.lport = inc->i_hdr.h_sport;
+		minfo6.fport = inc->i_hdr.h_dport;
+	}
+
+	rds_info_copy(iter, &minfo6, sizeof(minfo6));
+}
net/rds/tcp.c +44 -0

62 lines not on this page · raw message

Signature · 1 line
1.8.3.1