netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Oskolkov <posk@google.com>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	netdev@vger.kernel.org
Cc: "Peter Oskolkov" <posk.devel@gmail.com>,
	"Peter Oskolkov" <posk@google.com>,
	"Maciej Żenczykowski" <maze@google.com>
Subject: [PATCH bpf-next] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes
Date: Wed, 16 Jan 2019 08:47:54 -0800	[thread overview]
Message-ID: <20190116164754.104170-1-posk@google.com> (raw)

In sock_setsockopt() (net/core/sock.h), when SO_MARK option is used
to change sk_mark, sk_dst_reset(sk) is called. The same should be done
in bpf_setsockopt.

Reported-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: Peter Oskolkov <posk@google.com>
---
 net/core/filter.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index 2b3b436ef545..0c1bc6ccfd7f 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4132,7 +4132,10 @@ BPF_CALL_5(bpf_setsockopt, struct bpf_sock_ops_kern *, bpf_sock,
 			sk->sk_rcvlowat = val ? : 1;
 			break;
 		case SO_MARK:
-			sk->sk_mark = val;
+			if (sk->sk_mark != val) {
+				sk->sk_mark = val;
+				sk_dst_reset(sk);
+			}
 			break;
 		default:
 			ret = -EINVAL;
-- 


             reply	other threads:[~2019-01-16 16:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-16 16:47 Peter Oskolkov [this message]
2019-01-16 18:09 ` [PATCH bpf-next] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes Martin Lau
2019-01-17  0:35   ` Maciej Żenczykowski
2019-01-17 15:50 ` Daniel Borkmann
2019-01-17 16:36   ` Peter Oskolkov
2019-01-17 23:34     ` Daniel Borkmann

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=20190116164754.104170-1-posk@google.com \
    --to=posk@google.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=maze@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=posk.devel@gmail.com \
    /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).