All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: Martin KaFai Lau <kafai@fb.com>,
	Benjamin Herrenschmidt <benh@amazon.com>,
	Kuniyuki Iwashima <kuniyu@amazon.co.jp>,
	Kuniyuki Iwashima <kuni1840@gmail.com>, <bpf@vger.kernel.org>,
	<netdev@vger.kernel.org>
Subject: [PATCH bpf-next 2/6] bpf: Add SO_RCVBUF/SO_SNDBUF in _bpf_getsockopt().
Date: Tue, 4 Jan 2022 10:31:49 +0900	[thread overview]
Message-ID: <20220104013153.97906-3-kuniyu@amazon.co.jp> (raw)
In-Reply-To: <20220104013153.97906-1-kuniyu@amazon.co.jp>

This patch exposes SO_RCVBUF/SO_SNDBUF through bpf_getsockopt().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
---
 net/core/filter.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index 368fe28c8dc6..cac2be559ab0 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4969,6 +4969,12 @@ static int _bpf_getsockopt(struct sock *sk, int level, int optname,
 			goto err_clear;
 
 		switch (optname) {
+		case SO_RCVBUF:
+			*((int *)optval) = sk->sk_rcvbuf;
+			break;
+		case SO_SNDBUF:
+			*((int *)optval) = sk->sk_sndbuf;
+			break;
 		case SO_MARK:
 			*((int *)optval) = sk->sk_mark;
 			break;
-- 
2.30.2


  parent reply	other threads:[~2022-01-04  1:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-04  1:31 [PATCH bpf-next 0/6] bpf: Batching iter for AF_UNIX sockets Kuniyuki Iwashima
2022-01-04  1:31 ` [PATCH bpf-next 1/6] bpf: Fix SO_RCVBUF/SO_SNDBUF handling in _bpf_setsockopt() Kuniyuki Iwashima
2022-01-04  1:31 ` Kuniyuki Iwashima [this message]
2022-01-04  1:31 ` [PATCH bpf-next 3/6] bpf: af_unix: Use batching algorithm in bpf unix iter Kuniyuki Iwashima
2022-01-05 22:22   ` Alexei Starovoitov
2022-01-05 23:06     ` Kuniyuki Iwashima
2022-01-04  1:31 ` [PATCH bpf-next 4/6] bpf: Support bpf_(get|set)sockopt() " Kuniyuki Iwashima
2022-01-04  1:31 ` [PATCH bpf-next 5/6] selftest/bpf: Test batching and bpf_(get|set)sockopt " Kuniyuki Iwashima
2022-01-04  1:31 ` [PATCH bpf-next 6/6] selftest/bpf: Fix a stale comment Kuniyuki Iwashima

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=20220104013153.97906-3-kuniyu@amazon.co.jp \
    --to=kuniyu@amazon.co.jp \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=benh@amazon.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=kuni1840@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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 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.