Commit 1b3fc771 authored by Maciej Żenczykowski's avatar Maciej Żenczykowski Committed by David S. Miller

inet_diag: add support for tw_mark

Timewait sockets have included mark since approx 4.18.

Cc: Eric Dumazet <edumazet@google.com>
Cc: Jon Maxwell <jmaxwell37@gmail.com>
Fixes: 00483690 ("tcp: Add mark for TIMEWAIT sockets")
Signed-off-by: default avatarMaciej Żenczykowski <maze@google.com>
Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
Reviewed-by: default avatarJon Maxwell <jmaxwell37@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1d0bbbf2
...@@ -416,7 +416,7 @@ EXPORT_SYMBOL_GPL(inet_sk_diag_fill); ...@@ -416,7 +416,7 @@ EXPORT_SYMBOL_GPL(inet_sk_diag_fill);
static int inet_twsk_diag_fill(struct sock *sk, static int inet_twsk_diag_fill(struct sock *sk,
struct sk_buff *skb, struct sk_buff *skb,
struct netlink_callback *cb, struct netlink_callback *cb,
u16 nlmsg_flags) u16 nlmsg_flags, bool net_admin)
{ {
struct inet_timewait_sock *tw = inet_twsk(sk); struct inet_timewait_sock *tw = inet_twsk(sk);
struct inet_diag_msg *r; struct inet_diag_msg *r;
...@@ -444,6 +444,12 @@ static int inet_twsk_diag_fill(struct sock *sk, ...@@ -444,6 +444,12 @@ static int inet_twsk_diag_fill(struct sock *sk,
r->idiag_uid = 0; r->idiag_uid = 0;
r->idiag_inode = 0; r->idiag_inode = 0;
if (net_admin && nla_put_u32(skb, INET_DIAG_MARK,
tw->tw_mark)) {
nlmsg_cancel(skb, nlh);
return -EMSGSIZE;
}
nlmsg_end(skb, nlh); nlmsg_end(skb, nlh);
return 0; return 0;
} }
...@@ -494,7 +500,7 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, ...@@ -494,7 +500,7 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,
u16 nlmsg_flags, bool net_admin) u16 nlmsg_flags, bool net_admin)
{ {
if (sk->sk_state == TCP_TIME_WAIT) if (sk->sk_state == TCP_TIME_WAIT)
return inet_twsk_diag_fill(sk, skb, cb, nlmsg_flags); return inet_twsk_diag_fill(sk, skb, cb, nlmsg_flags, net_admin);
if (sk->sk_state == TCP_NEW_SYN_RECV) if (sk->sk_state == TCP_NEW_SYN_RECV)
return inet_req_diag_fill(sk, skb, cb, nlmsg_flags, net_admin); return inet_req_diag_fill(sk, skb, cb, nlmsg_flags, net_admin);
...@@ -801,6 +807,8 @@ int inet_diag_bc_sk(const struct nlattr *bc, struct sock *sk) ...@@ -801,6 +807,8 @@ int inet_diag_bc_sk(const struct nlattr *bc, struct sock *sk)
entry.mark = sk->sk_mark; entry.mark = sk->sk_mark;
else if (sk->sk_state == TCP_NEW_SYN_RECV) else if (sk->sk_state == TCP_NEW_SYN_RECV)
entry.mark = inet_rsk(inet_reqsk(sk))->ir_mark; entry.mark = inet_rsk(inet_reqsk(sk))->ir_mark;
else if (sk->sk_state == TCP_TIME_WAIT)
entry.mark = inet_twsk(sk)->tw_mark;
else else
entry.mark = 0; entry.mark = 0;
#ifdef CONFIG_SOCK_CGROUP_DATA #ifdef CONFIG_SOCK_CGROUP_DATA
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment