All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/3] tipc: small bugfix an support for datagram connect()
@ 2015-03-19  8:02 erik.hugne
  2015-03-19  8:02 ` [PATCH net-next v2 1/3] tipc: remove redundant call to tipc_node_remove_conn erik.hugne
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: erik.hugne @ 2015-03-19  8:02 UTC (permalink / raw)
  To: richard.alpe, jon.maloy, ying.xue, netdev; +Cc: tipc-discussion

From: Erik Hugne <erik.hugne@ericsson.com>

Most notable in this series is patch#3 that allows programs to associate
a tipc address with a connectionless (RDM/DGRAM) socket.

v2: Fix indent issue in patch#3

Erik Hugne (3):
  tipc: remove redundant call to tipc_node_remove_conn
  tipc: do not report -EHOSTUNREACH for failed local delivery
  tipc: add support for connect() on dgram/rdm sockets

 net/tipc/link.c   |  6 ++++--
 net/tipc/socket.c | 39 ++++++++++++++++++++++++---------------
 2 files changed, 28 insertions(+), 17 deletions(-)

-- 
2.1.4


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 1/3] tipc: remove redundant call to tipc_node_remove_conn
  2015-03-19  8:02 [PATCH net-next v2 0/3] tipc: small bugfix an support for datagram connect() erik.hugne
@ 2015-03-19  8:02 ` erik.hugne
  2015-03-19  8:02 ` [PATCH net-next v2 2/3] tipc: do not report -EHOSTUNREACH for failed local delivery erik.hugne
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: erik.hugne @ 2015-03-19  8:02 UTC (permalink / raw)
  To: richard.alpe, jon.maloy, ying.xue, netdev; +Cc: tipc-discussion, Erik Hugne

From: Erik Hugne <erik.hugne@ericsson.com>

tipc_node_remove_conn may be called twice if shutdown() is
called on a socket that have messages in the receive queue.
Calling this function twice does no harm, but is unnecessary
and we remove the redundant call.

Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
---
 net/tipc/socket.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 813847d..b6295c0 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -2078,7 +2078,6 @@ restart:
 					     TIPC_CONN_SHUTDOWN))
 				tipc_link_xmit_skb(net, skb, dnode,
 						   tsk->portid);
-			tipc_node_remove_conn(net, dnode, tsk->portid);
 		} else {
 			dnode = tsk_peer_node(tsk);
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 2/3] tipc: do not report -EHOSTUNREACH for failed local delivery
  2015-03-19  8:02 [PATCH net-next v2 0/3] tipc: small bugfix an support for datagram connect() erik.hugne
  2015-03-19  8:02 ` [PATCH net-next v2 1/3] tipc: remove redundant call to tipc_node_remove_conn erik.hugne
@ 2015-03-19  8:02 ` erik.hugne
  2015-03-19  8:02 ` [PATCH net-next v2 3/3] tipc: add support for connect() on dgram/rdm sockets erik.hugne
  2015-03-19 16:26 ` [PATCH net-next v2 0/3] tipc: small bugfix an support for datagram connect() David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: erik.hugne @ 2015-03-19  8:02 UTC (permalink / raw)
  To: richard.alpe, jon.maloy, ying.xue, netdev; +Cc: tipc-discussion, Erik Hugne

From: Erik Hugne <erik.hugne@ericsson.com>

Since commit 1186adf7df04 ("tipc: simplify message forwarding and
rejection in socket layer") -EHOSTUNREACH is propagated back to
the sending process if we fail to deliver the message to another
socket local to the node.
This is wrong, host unreachable should only be reported when the
destination port/name does not exist in the cluster, and that
check is always done before sending the message. Also, this
introduces inconsistent sendmsg() behavior for local/remote
destinations. Errors occurring on the receiving side should not
trickle up to the sender. If message delivery fails TIPC should
either discard the packet or reject it back to the sender based
on the destination droppable option.

Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
---
 net/tipc/link.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/tipc/link.c b/net/tipc/link.c
index bc49120..8c98c4d 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -845,8 +845,10 @@ int tipc_link_xmit(struct net *net, struct sk_buff_head *list, u32 dnode,
 	if (link)
 		return rc;
 
-	if (likely(in_own_node(net, dnode)))
-		return tipc_sk_rcv(net, list);
+	if (likely(in_own_node(net, dnode))) {
+		tipc_sk_rcv(net, list);
+		return 0;
+	}
 
 	__skb_queue_purge(list);
 	return rc;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 3/3] tipc: add support for connect() on dgram/rdm sockets
  2015-03-19  8:02 [PATCH net-next v2 0/3] tipc: small bugfix an support for datagram connect() erik.hugne
  2015-03-19  8:02 ` [PATCH net-next v2 1/3] tipc: remove redundant call to tipc_node_remove_conn erik.hugne
  2015-03-19  8:02 ` [PATCH net-next v2 2/3] tipc: do not report -EHOSTUNREACH for failed local delivery erik.hugne
@ 2015-03-19  8:02 ` erik.hugne
  2015-03-19 16:26 ` [PATCH net-next v2 0/3] tipc: small bugfix an support for datagram connect() David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: erik.hugne @ 2015-03-19  8:02 UTC (permalink / raw)
  To: richard.alpe, jon.maloy, ying.xue, netdev; +Cc: tipc-discussion

From: Erik Hugne <erik.hugne@ericsson.com>

Following the example of ip4_datagram_connect, we store the
address in the socket structure for dgram/rdm sockets and use
that as the default destination for subsequent send() calls.
It is allowed to connect to any address types, and the behaviour
of send() will be the same as a normal sendto() with this address
provided. Binding to an AF_UNSPEC address clears the association.

Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
---
 net/tipc/socket.c | 38 ++++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index b6295c0..20b4f10 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -74,6 +74,7 @@
  * @link_cong: non-zero if owner must sleep because of link congestion
  * @sent_unacked: # messages sent by socket, and not yet acked by peer
  * @rcv_unacked: # messages read by user, but not yet acked back to peer
+ * @remote: 'connected' peer for dgram/rdm
  * @node: hash table node
  * @rcu: rcu struct for tipc_sock
  */
@@ -96,6 +97,7 @@ struct tipc_sock {
 	bool link_cong;
 	uint sent_unacked;
 	uint rcv_unacked;
+	struct sockaddr_tipc remote;
 	struct rhash_head node;
 	struct rcu_head rcu;
 };
@@ -854,22 +856,23 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dsz)
 	u32 dnode, dport;
 	struct sk_buff_head *pktchain = &sk->sk_write_queue;
 	struct sk_buff *skb;
-	struct tipc_name_seq *seq = &dest->addr.nameseq;
+	struct tipc_name_seq *seq;
 	struct iov_iter save;
 	u32 mtu;
 	long timeo;
 	int rc;
 
-	if (unlikely(!dest))
-		return -EDESTADDRREQ;
-
-	if (unlikely((m->msg_namelen < sizeof(*dest)) ||
-		     (dest->family != AF_TIPC)))
-		return -EINVAL;
-
 	if (dsz > TIPC_MAX_USER_MSG_SIZE)
 		return -EMSGSIZE;
-
+	if (unlikely(!dest)) {
+		if (tsk->connected && sock->state == SS_READY)
+			dest = &tsk->remote;
+		else
+			return -EDESTADDRREQ;
+	} else if (unlikely(m->msg_namelen < sizeof(*dest)) ||
+		   dest->family != AF_TIPC) {
+		return -EINVAL;
+	}
 	if (unlikely(sock->state != SS_READY)) {
 		if (sock->state == SS_LISTENING)
 			return -EPIPE;
@@ -882,7 +885,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dsz)
 			tsk->conn_instance = dest->addr.name.name.instance;
 		}
 	}
-
+	seq = &dest->addr.nameseq;
 	timeo = sock_sndtimeo(sk, m->msg_flags & MSG_DONTWAIT);
 
 	if (dest->addrtype == TIPC_ADDR_MCAST) {
@@ -1833,17 +1836,24 @@ static int tipc_connect(struct socket *sock, struct sockaddr *dest,
 			int destlen, int flags)
 {
 	struct sock *sk = sock->sk;
+	struct tipc_sock *tsk = tipc_sk(sk);
 	struct sockaddr_tipc *dst = (struct sockaddr_tipc *)dest;
 	struct msghdr m = {NULL,};
-	long timeout = (flags & O_NONBLOCK) ? 0 : tipc_sk(sk)->conn_timeout;
+	long timeout = (flags & O_NONBLOCK) ? 0 : tsk->conn_timeout;
 	socket_state previous;
-	int res;
+	int res = 0;
 
 	lock_sock(sk);
 
-	/* For now, TIPC does not allow use of connect() with DGRAM/RDM types */
+	/* DGRAM/RDM connect(), just save the destaddr */
 	if (sock->state == SS_READY) {
-		res = -EOPNOTSUPP;
+		if (dst->family == AF_UNSPEC) {
+			memset(&tsk->remote, 0, sizeof(struct sockaddr_tipc));
+			tsk->connected = 0;
+		} else {
+			memcpy(&tsk->remote, dest, destlen);
+			tsk->connected = 1;
+		}
 		goto exit;
 	}
 
-- 
2.1.4


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v2 0/3] tipc: small bugfix an support for datagram connect()
  2015-03-19  8:02 [PATCH net-next v2 0/3] tipc: small bugfix an support for datagram connect() erik.hugne
                   ` (2 preceding siblings ...)
  2015-03-19  8:02 ` [PATCH net-next v2 3/3] tipc: add support for connect() on dgram/rdm sockets erik.hugne
@ 2015-03-19 16:26 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2015-03-19 16:26 UTC (permalink / raw)
  To: erik.hugne; +Cc: richard.alpe, jon.maloy, ying.xue, netdev, tipc-discussion

From: <erik.hugne@ericsson.com>
Date: Thu, 19 Mar 2015 09:02:16 +0100

> Most notable in this series is patch#3 that allows programs to associate
> a tipc address with a connectionless (RDM/DGRAM) socket.
> 
> v2: Fix indent issue in patch#3

Series applied, thanks Erik.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-19 16:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-19  8:02 [PATCH net-next v2 0/3] tipc: small bugfix an support for datagram connect() erik.hugne
2015-03-19  8:02 ` [PATCH net-next v2 1/3] tipc: remove redundant call to tipc_node_remove_conn erik.hugne
2015-03-19  8:02 ` [PATCH net-next v2 2/3] tipc: do not report -EHOSTUNREACH for failed local delivery erik.hugne
2015-03-19  8:02 ` [PATCH net-next v2 3/3] tipc: add support for connect() on dgram/rdm sockets erik.hugne
2015-03-19 16:26 ` [PATCH net-next v2 0/3] tipc: small bugfix an support for datagram connect() David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.