netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] tipc: small bugfix an support for datagram connect()
@ 2015-03-18  9:17 erik.hugne
  2015-03-18  9:17 ` [PATCH net-next 1/3] tipc: remove redundant call to tipc_node_remove_conn erik.hugne
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: erik.hugne @ 2015-03-18  9:17 UTC (permalink / raw)
  To: richard.alpe, jon.maloy, ying.xue, netdev; +Cc: tipc-discussion, Erik Hugne

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.

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

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

* [PATCH net-next 1/3] tipc: remove redundant call to tipc_node_remove_conn
  2015-03-18  9:17 [PATCH net-next 0/3] tipc: small bugfix an support for datagram connect() erik.hugne
@ 2015-03-18  9:17 ` erik.hugne
  2015-03-18  9:41   ` Ying Xue
  2015-03-18 15:27   ` Jon Maloy
  2015-03-18  9:17 ` [PATCH net-next 2/3] tipc: do not report -EHOSTUNREACH for failed local delivery erik.hugne
  2015-03-18  9:17 ` [PATCH net-next 3/3] tipc: add support for connect() on dgram/rdm sockets erik.hugne
  2 siblings, 2 replies; 9+ messages in thread
From: erik.hugne @ 2015-03-18  9:17 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>
---
 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] 9+ messages in thread

* [PATCH net-next 2/3] tipc: do not report -EHOSTUNREACH for failed local delivery
  2015-03-18  9:17 [PATCH net-next 0/3] tipc: small bugfix an support for datagram connect() erik.hugne
  2015-03-18  9:17 ` [PATCH net-next 1/3] tipc: remove redundant call to tipc_node_remove_conn erik.hugne
@ 2015-03-18  9:17 ` erik.hugne
  2015-03-18  9:41   ` Ying Xue
  2015-03-18 15:28   ` Jon Maloy
  2015-03-18  9:17 ` [PATCH net-next 3/3] tipc: add support for connect() on dgram/rdm sockets erik.hugne
  2 siblings, 2 replies; 9+ messages in thread
From: erik.hugne @ 2015-03-18  9:17 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>
---
 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] 9+ messages in thread

* [PATCH net-next 3/3] tipc: add support for connect() on dgram/rdm sockets
  2015-03-18  9:17 [PATCH net-next 0/3] tipc: small bugfix an support for datagram connect() erik.hugne
  2015-03-18  9:17 ` [PATCH net-next 1/3] tipc: remove redundant call to tipc_node_remove_conn erik.hugne
  2015-03-18  9:17 ` [PATCH net-next 2/3] tipc: do not report -EHOSTUNREACH for failed local delivery erik.hugne
@ 2015-03-18  9:17 ` erik.hugne
  2015-03-18 18:48   ` David Miller
  2 siblings, 1 reply; 9+ messages in thread
From: erik.hugne @ 2015-03-18  9:17 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..683e347 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] 9+ messages in thread

* Re: [PATCH net-next 1/3] tipc: remove redundant call to tipc_node_remove_conn
  2015-03-18  9:17 ` [PATCH net-next 1/3] tipc: remove redundant call to tipc_node_remove_conn erik.hugne
@ 2015-03-18  9:41   ` Ying Xue
  2015-03-18 15:27   ` Jon Maloy
  1 sibling, 0 replies; 9+ messages in thread
From: Ying Xue @ 2015-03-18  9:41 UTC (permalink / raw)
  To: erik.hugne, richard.alpe, jon.maloy, netdev; +Cc: tipc-discussion

On 03/18/2015 05:17 PM, erik.hugne@ericsson.com wrote:
> 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>

> ---
>  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);
>  
> 

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

* Re: [PATCH net-next 2/3] tipc: do not report -EHOSTUNREACH for failed local delivery
  2015-03-18  9:17 ` [PATCH net-next 2/3] tipc: do not report -EHOSTUNREACH for failed local delivery erik.hugne
@ 2015-03-18  9:41   ` Ying Xue
  2015-03-18 15:28   ` Jon Maloy
  1 sibling, 0 replies; 9+ messages in thread
From: Ying Xue @ 2015-03-18  9:41 UTC (permalink / raw)
  To: erik.hugne, richard.alpe, jon.maloy, netdev; +Cc: tipc-discussion

On 03/18/2015 05:17 PM, erik.hugne@ericsson.com wrote:
> 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>

> ---
>  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;
> 

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

* RE: [PATCH net-next 1/3] tipc: remove redundant call to tipc_node_remove_conn
  2015-03-18  9:17 ` [PATCH net-next 1/3] tipc: remove redundant call to tipc_node_remove_conn erik.hugne
  2015-03-18  9:41   ` Ying Xue
@ 2015-03-18 15:27   ` Jon Maloy
  1 sibling, 0 replies; 9+ messages in thread
From: Jon Maloy @ 2015-03-18 15:27 UTC (permalink / raw)
  To: Erik Hugne, Richard Alpe, ying.xue@windriver.com,
	netdev@vger.kernel.org
  Cc: tipc-discussion@lists.sourceforge.net



> -----Original Message-----
> From: Erik Hugne
> Sent: March-18-15 5:18 AM
> To: Richard Alpe; Jon Maloy; ying.xue@windriver.com;
> netdev@vger.kernel.org
> Cc: tipc-discussion@lists.sourceforge.net; Erik Hugne
> Subject: [PATCH net-next 1/3] tipc: remove redundant call to
> tipc_node_remove_conn
> 
> 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: 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	[flat|nested] 9+ messages in thread

* RE: [PATCH net-next 2/3] tipc: do not report -EHOSTUNREACH for failed local delivery
  2015-03-18  9:17 ` [PATCH net-next 2/3] tipc: do not report -EHOSTUNREACH for failed local delivery erik.hugne
  2015-03-18  9:41   ` Ying Xue
@ 2015-03-18 15:28   ` Jon Maloy
  1 sibling, 0 replies; 9+ messages in thread
From: Jon Maloy @ 2015-03-18 15:28 UTC (permalink / raw)
  To: Erik Hugne, Richard Alpe, ying.xue@windriver.com,
	netdev@vger.kernel.org
  Cc: tipc-discussion@lists.sourceforge.net



> -----Original Message-----
> From: Erik Hugne
> Sent: March-18-15 5:18 AM
> To: Richard Alpe; Jon Maloy; ying.xue@windriver.com;
> netdev@vger.kernel.org
> Cc: tipc-discussion@lists.sourceforge.net; Erik Hugne
> Subject: [PATCH net-next 2/3] tipc: do not report -EHOSTUNREACH for failed
> local delivery
> 
> 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: 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	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next 3/3] tipc: add support for connect() on dgram/rdm sockets
  2015-03-18  9:17 ` [PATCH net-next 3/3] tipc: add support for connect() on dgram/rdm sockets erik.hugne
@ 2015-03-18 18:48   ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2015-03-18 18:48 UTC (permalink / raw)
  To: erik.hugne; +Cc: richard.alpe, jon.maloy, ying.xue, netdev, tipc-discussion

From: <erik.hugne@ericsson.com>
Date: Wed, 18 Mar 2015 10:17:43 +0100

> +	} else if (unlikely(m->msg_namelen < sizeof(*dest)) ||
> +		     dest->family != AF_TIPC) {

This is not indented correctly.

The "dest->family" on the second line should start exactly at the first
column after the openning parenthesis of the if() statement on the
previous line.

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

end of thread, other threads:[~2015-03-18 18:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-18  9:17 [PATCH net-next 0/3] tipc: small bugfix an support for datagram connect() erik.hugne
2015-03-18  9:17 ` [PATCH net-next 1/3] tipc: remove redundant call to tipc_node_remove_conn erik.hugne
2015-03-18  9:41   ` Ying Xue
2015-03-18 15:27   ` Jon Maloy
2015-03-18  9:17 ` [PATCH net-next 2/3] tipc: do not report -EHOSTUNREACH for failed local delivery erik.hugne
2015-03-18  9:41   ` Ying Xue
2015-03-18 15:28   ` Jon Maloy
2015-03-18  9:17 ` [PATCH net-next 3/3] tipc: add support for connect() on dgram/rdm sockets erik.hugne
2015-03-18 18:48   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).