netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jon Maloy <jon.maloy@ericsson.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: tipc-discussion@lists.sourceforge.net, hoang.h.le@dektech.com.au,
	mohan.krishna.ghanta.krishnamurthy@ericsson.com
Subject: [net-next 1/1] tipc: sockopt(TIPC_SO_RCVBUF) for setting receive buffer
Date: Tue, 27 Feb 2018 20:47:09 +0100	[thread overview]
Message-ID: <1519760829-21380-1-git-send-email-jon.maloy@ericsson.com> (raw)

From: Hoang Le <hoang.h.le@dektech.com.au>

We introduce a set/getsockopt for setting socket receive buffer per
individual socket. This has turned out to sometimes be necessary for
anycast and multicast receivers when used without flow control.

Signed-off-by: Hoang Le <hoang.h.le@dektech.com.au>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
---
 include/uapi/linux/tipc.h | 1 +
 net/tipc/socket.c         | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/include/uapi/linux/tipc.h b/include/uapi/linux/tipc.h
index 14bacc7..8ce4a69 100644
--- a/include/uapi/linux/tipc.h
+++ b/include/uapi/linux/tipc.h
@@ -233,6 +233,7 @@ struct sockaddr_tipc {
 #define TIPC_MCAST_REPLICAST    134     /* Default: TIPC selects. No arg */
 #define TIPC_GROUP_JOIN         135     /* Takes struct tipc_group_req* */
 #define TIPC_GROUP_LEAVE        136     /* No argument */
+#define TIPC_SO_RCVBUF          137     /* Range tipc_rmem_min:tipc_rmem_max */
 
 /*
  * Flag values
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 8b04e60..cfd519b 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -2829,6 +2829,7 @@ static int tipc_setsockopt(struct socket *sock, int lvl, int opt,
 	case TIPC_SRC_DROPPABLE:
 	case TIPC_DEST_DROPPABLE:
 	case TIPC_CONN_TIMEOUT:
+	case TIPC_SO_RCVBUF:
 		if (ol < sizeof(value))
 			return -EINVAL;
 		if (get_user(value, (u32 __user *)ov))
@@ -2877,6 +2878,10 @@ static int tipc_setsockopt(struct socket *sock, int lvl, int opt,
 	case TIPC_GROUP_LEAVE:
 		res = tipc_sk_leave(tsk);
 		break;
+	case TIPC_SO_RCVBUF:
+		value = max_t(int, value, sysctl_tipc_rmem[0]);
+		sk->sk_rcvbuf = min_t(int, value, sysctl_tipc_rmem[2]);
+		break;
 	default:
 		res = -EINVAL;
 	}
@@ -2945,6 +2950,9 @@ static int tipc_getsockopt(struct socket *sock, int lvl, int opt,
 			tipc_group_self(tsk->group, &seq, &scope);
 		value = seq.type;
 		break;
+	case TIPC_SO_RCVBUF:
+		value = sk->sk_rcvbuf;
+		break;
 	default:
 		res = -EINVAL;
 	}
-- 
2.1.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

             reply	other threads:[~2018-02-27 19:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-27 19:47 Jon Maloy [this message]
2018-02-28 16:35 ` [net-next 1/1] tipc: sockopt(TIPC_SO_RCVBUF) for setting receive buffer David Miller

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=1519760829-21380-1-git-send-email-jon.maloy@ericsson.com \
    --to=jon.maloy@ericsson.com \
    --cc=davem@davemloft.net \
    --cc=hoang.h.le@dektech.com.au \
    --cc=mohan.krishna.ghanta.krishnamurthy@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).