netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
To: <netdev@vger.kernel.org>
Cc: jon.maloy@ericsson.com, tipc-discussion@lists.sourceforge.net
Subject: [PATCH net-next v1 04/16] tipc: rename struct tipc_skb_cb member handle to bytes_read
Date: Thu, 27 Oct 2016 16:22:25 +0200	[thread overview]
Message-ID: <1477578157-13256-5-git-send-email-parthasarathy.bhuvaragan@ericsson.com> (raw)
In-Reply-To: <1477578157-13256-1-git-send-email-parthasarathy.bhuvaragan@ericsson.com>

In this commit, we rename handle to bytes_read indicating the
purpose of the member.

Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
---
 net/tipc/msg.h    |  2 +-
 net/tipc/socket.c | 18 ++++++++++--------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index c3832cdf2278..a2aa01b442ef 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -95,7 +95,7 @@ struct plist;
 #define TIPC_MEDIA_INFO_OFFSET	5
 
 struct tipc_skb_cb {
-	void *handle;
+	u32 bytes_read;
 	struct sk_buff *tail;
 	bool validated;
 	bool wakeup_pending;
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 82aec2eb8497..6e3774a7c831 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -465,7 +465,7 @@ static int tipc_release(struct socket *sock)
 		skb = __skb_dequeue(&sk->sk_receive_queue);
 		if (skb == NULL)
 			break;
-		if (TIPC_SKB_CB(skb)->handle != NULL)
+		if (TIPC_SKB_CB(skb)->bytes_read)
 			kfree_skb(skb);
 		else {
 			if ((sock->state == SS_CONNECTING) ||
@@ -1435,7 +1435,7 @@ static int tipc_recv_stream(struct socket *sock, struct msghdr *m,
 	struct tipc_msg *msg;
 	long timeo;
 	unsigned int sz;
-	int sz_to_copy, target, needed;
+	int target;
 	int sz_copied = 0;
 	u32 err;
 	int res = 0, hlen;
@@ -1483,11 +1483,13 @@ static int tipc_recv_stream(struct socket *sock, struct msghdr *m,
 
 	/* Capture message data (if valid) & compute return value (always) */
 	if (!err) {
-		u32 offset = (u32)(unsigned long)(TIPC_SKB_CB(buf)->handle);
+		u32 offset = (u32)(TIPC_SKB_CB(buf)->bytes_read);
+		u32 needed;
+		int sz_to_copy;
 
 		sz -= offset;
 		needed = (buf_len - sz_copied);
-		sz_to_copy = (sz <= needed) ? sz : needed;
+		sz_to_copy = min(sz, needed);
 
 		res = skb_copy_datagram_msg(buf, hlen + offset, m, sz_to_copy);
 		if (res)
@@ -1497,8 +1499,8 @@ static int tipc_recv_stream(struct socket *sock, struct msghdr *m,
 
 		if (sz_to_copy < sz) {
 			if (!(flags & MSG_PEEK))
-				TIPC_SKB_CB(buf)->handle =
-				(void *)(unsigned long)(offset + sz_to_copy);
+				TIPC_SKB_CB(buf)->bytes_read =
+					offset + sz_to_copy;
 			goto exit;
 		}
 	} else {
@@ -1742,7 +1744,7 @@ static bool filter_rcv(struct sock *sk, struct sk_buff *skb,
 	}
 
 	/* Enqueue message */
-	TIPC_SKB_CB(skb)->handle = NULL;
+	TIPC_SKB_CB(skb)->bytes_read = 0;
 	__skb_queue_tail(&sk->sk_receive_queue, skb);
 	skb_set_owner_r(skb, sk);
 
@@ -2177,7 +2179,7 @@ static int tipc_shutdown(struct socket *sock, int how)
 		/* Disconnect and send a 'FIN+' or 'FIN-' message to peer */
 		skb = __skb_dequeue(&sk->sk_receive_queue);
 		if (skb) {
-			if (TIPC_SKB_CB(skb)->handle != NULL) {
+			if (TIPC_SKB_CB(skb)->bytes_read) {
 				kfree_skb(skb);
 				goto restart;
 			}
-- 
2.1.4


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik

  parent reply	other threads:[~2016-10-27 14:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-27 14:22 [PATCH net-next v1 00/16] tipc: socket layer improvements Parthasarathy Bhuvaragan
2016-10-27 14:22 ` [PATCH net-next v1 01/16] tipc: return early for non-blocking sockets at link congestion Parthasarathy Bhuvaragan
2016-10-27 14:22 ` [PATCH net-next v1 02/16] tipc: wakeup sleeping users at disconnect Parthasarathy Bhuvaragan
2016-10-27 14:22 ` [PATCH net-next v1 03/16] tipc: set kern=0 in sk_alloc() during tipc_accept() Parthasarathy Bhuvaragan
2016-10-27 14:22 ` Parthasarathy Bhuvaragan [this message]
2016-10-29 21:01   ` [PATCH net-next v1 04/16] tipc: rename struct tipc_skb_cb member handle to bytes_read David Miller
2016-10-27 14:22 ` [PATCH net-next v1 05/16] tipc: rename tsk->remote to tsk->peer for consistent naming Parthasarathy Bhuvaragan
2016-10-27 14:22 ` [PATCH net-next v1 06/16] tipc: remove tsk->connected for connectionless sockets Parthasarathy Bhuvaragan
2016-10-27 14:22 ` [PATCH net-next v1 07/16] tipc: remove tsk->connected from tipc_sock Parthasarathy Bhuvaragan
2016-10-27 14:22 ` [PATCH net-next v1 08/16] tipc: remove probing_intv " Parthasarathy Bhuvaragan
2016-10-27 14:22 ` [PATCH net-next v1 09/16] tipc: remove socket state SS_READY Parthasarathy Bhuvaragan
2016-10-27 14:22 ` [PATCH net-next v1 10/16] tipc: create TIPC_LISTEN as a new sk_state Parthasarathy Bhuvaragan
2016-10-27 14:22 ` [PATCH net-next v1 11/16] tipc: create TIPC_PROBING/TIPC_ESTABLISHED as new sk_states Parthasarathy Bhuvaragan
2016-10-27 14:22 ` [PATCH net-next v1 12/16] tipc: create TIPC_OPEN as a new sk_state Parthasarathy Bhuvaragan
2016-10-27 14:22 ` [PATCH net-next v1 13/16] tipc: create TIPC_DISCONNECTING " Parthasarathy Bhuvaragan
2016-10-27 15:03   ` Eric Dumazet
2016-10-28 11:14     ` Parthasarathy Bhuvaragan
2016-10-27 14:22 ` [PATCH net-next v1 14/16] tipc: create TIPC_CLOSING " Parthasarathy Bhuvaragan
2016-10-27 14:22 ` [PATCH net-next v1 15/16] tipc: create TIPC_CONNECTING " Parthasarathy Bhuvaragan
2016-10-27 14:22 ` [PATCH net-next v1 16/16] tipc: remove SS_CONNECTED sock state Parthasarathy Bhuvaragan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1477578157-13256-5-git-send-email-parthasarathy.bhuvaragan@ericsson.com \
    --to=parthasarathy.bhuvaragan@ericsson.com \
    --cc=jon.maloy@ericsson.com \
    --cc=netdev@vger.kernel.org \
    --cc=tipc-discussion@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).