mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-25 13:14:07 +08:00
net: sock: fix in-kernel mark setting
This patch fixes the in-kernel mark setting by doing an additional sk_dst_reset() which was introduced by commit50254256f3
("sock: Reset dst when changing sk_mark via setsockopt"). The code is now shared to avoid any further suprises when changing the socket mark value. Fixes:84d1c61740
("net: sock: add sock_set_mark") Reported-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: Alexander Aring <aahringo@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
4ef8d857b5
commit
dd9082f4a9
@ -815,10 +815,18 @@ void sock_set_rcvbuf(struct sock *sk, int val)
|
||||
}
|
||||
EXPORT_SYMBOL(sock_set_rcvbuf);
|
||||
|
||||
static void __sock_set_mark(struct sock *sk, u32 val)
|
||||
{
|
||||
if (val != sk->sk_mark) {
|
||||
sk->sk_mark = val;
|
||||
sk_dst_reset(sk);
|
||||
}
|
||||
}
|
||||
|
||||
void sock_set_mark(struct sock *sk, u32 val)
|
||||
{
|
||||
lock_sock(sk);
|
||||
sk->sk_mark = val;
|
||||
__sock_set_mark(sk, val);
|
||||
release_sock(sk);
|
||||
}
|
||||
EXPORT_SYMBOL(sock_set_mark);
|
||||
@ -1126,10 +1134,10 @@ set_sndbuf:
|
||||
case SO_MARK:
|
||||
if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) {
|
||||
ret = -EPERM;
|
||||
} else if (val != sk->sk_mark) {
|
||||
sk->sk_mark = val;
|
||||
sk_dst_reset(sk);
|
||||
break;
|
||||
}
|
||||
|
||||
__sock_set_mark(sk, val);
|
||||
break;
|
||||
|
||||
case SO_RXQ_OVFL:
|
||||
|
Loading…
Reference in New Issue
Block a user