bpf: bpf_setsockopt: reset sock dst on SO_MARK changes
Subsystems (4)
PATCH 1/1 bpf: bpf_setsockopt: reset sock dst on SO_MARK changes
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.
--- net/core/filter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/core/filter.c +4 -1
@@ -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 ;
Quoted 6 lines · Peter Oskolkov
In
sock_setsockopt()(net/core/sock.h), whenSO_MARKoption is used to changesk_mark,sk_dst_reset(sk)is called. The same should be done inbpf_setsockopt.Reported-by Maciej Żenczykowski <[email protected]>Signed-off-by Peter Oskolkov <[email protected]>
Maciej Żenczykowski
Reviewed-byQuoted 7 lines · Martin Lau
Quoted 6 lines
In
sock_setsockopt()(net/core/sock.h), whenSO_MARKoption is used to changesk_mark,sk_dst_reset(sk)is called. The same should be done inbpf_setsockopt.Reported-by Maciej Żenczykowski <[email protected]>Signed-off-by Peter Oskolkov <[email protected]>Acked-by Martin KaFai Lau <[email protected]>
Daniel Borkmann
maintainerQuoted 6 lines · Peter Oskolkov
In
sock_setsockopt()(net/core/sock.h), whenSO_MARKoption is used to changesk_mark,sk_dst_reset(sk)is called. The same should be done inbpf_setsockopt.Reported-by Maciej Żenczykowski <[email protected]>Signed-off-by Peter Oskolkov <[email protected]>
Given this is a fix, I'm inclined to apply to bpf tree. Objections?
Thanks,
Daniel
Quoted 10 lines · Daniel Borkmann
Quoted 6 lines · Peter Oskolkov
In
sock_setsockopt()(net/core/sock.h), whenSO_MARKoption is used to changesk_mark,sk_dst_reset(sk)is called. The same should be done inbpf_setsockopt.Reported-by Maciej Żenczykowski <[email protected]>Signed-off-by Peter Oskolkov <[email protected]>Given this is a fix, I'm inclined to apply to bpf tree. Objections?
Up to the maintainer... :)
Quoted 3 lines
Thanks,
Daniel
Quoted 7 lines · Peter Oskolkov
Quoted 6 lines · Daniel Borkmann
Quoted 4 lines · Peter Oskolkov
In
sock_setsockopt()(net/core/sock.h), whenSO_MARKoption is used to changesk_mark,sk_dst_reset(sk)is called. The same should be done inbpf_setsockopt.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Reported-by Maciej Żenczykowski <[email protected]>Signed-off-by Peter Oskolkov <[email protected]>Given this is a fix, I'm inclined to apply to bpf tree. Objections?
Up to the maintainer... :)
Applied to bpf, thanks!