Skip to content

Commit 447f3ad

Browse files
matttbeintel-lab-lkp
authored andcommitted
tcp: ulp: diag: always print the name if any
Since its introduction in commit 61723b3 ("tcp: ulp: add functions to dump ulp-specific information"), the ULP diag info have been exported only if the requester had CAP_NET_ADMIN. At least the ULP name can be exported without CAP_NET_ADMIN. This will already help identifying which layer is being used, e.g. which TCP connections are in fact MPTCP subflow. Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
1 parent 62dab9e commit 447f3ad

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

net/ipv4/tcp_diag.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static int tcp_diag_put_md5sig(struct sk_buff *skb,
8383
#endif
8484

8585
static int tcp_diag_put_ulp(struct sk_buff *skb, struct sock *sk,
86-
const struct tcp_ulp_ops *ulp_ops)
86+
const struct tcp_ulp_ops *ulp_ops, bool net_admin)
8787
{
8888
struct nlattr *nest;
8989
int err;
@@ -96,7 +96,7 @@ static int tcp_diag_put_ulp(struct sk_buff *skb, struct sock *sk,
9696
if (err)
9797
goto nla_failure;
9898

99-
if (ulp_ops->get_info)
99+
if (net_admin && ulp_ops->get_info)
100100
err = ulp_ops->get_info(sk, skb);
101101
if (err)
102102
goto nla_failure;
@@ -113,6 +113,7 @@ static int tcp_diag_get_aux(struct sock *sk, bool net_admin,
113113
struct sk_buff *skb)
114114
{
115115
struct inet_connection_sock *icsk = inet_csk(sk);
116+
const struct tcp_ulp_ops *ulp_ops;
116117
int err = 0;
117118

118119
#ifdef CONFIG_TCP_MD5SIG
@@ -129,15 +130,13 @@ static int tcp_diag_get_aux(struct sock *sk, bool net_admin,
129130
}
130131
#endif
131132

132-
if (net_admin) {
133-
const struct tcp_ulp_ops *ulp_ops;
134-
135-
ulp_ops = icsk->icsk_ulp_ops;
136-
if (ulp_ops)
137-
err = tcp_diag_put_ulp(skb, sk, ulp_ops);
138-
if (err)
133+
ulp_ops = icsk->icsk_ulp_ops;
134+
if (ulp_ops) {
135+
err = tcp_diag_put_ulp(skb, sk, ulp_ops, net_admin);
136+
if (err < 0)
139137
return err;
140138
}
139+
141140
return 0;
142141
}
143142

@@ -164,14 +163,14 @@ static size_t tcp_diag_get_aux_size(struct sock *sk, bool net_admin)
164163
}
165164
#endif
166165

167-
if (net_admin && sk_fullsock(sk)) {
166+
if (sk_fullsock(sk)) {
168167
const struct tcp_ulp_ops *ulp_ops;
169168

170169
ulp_ops = icsk->icsk_ulp_ops;
171170
if (ulp_ops) {
172171
size += nla_total_size(0) +
173172
nla_total_size(TCP_ULP_NAME_MAX);
174-
if (ulp_ops->get_info_size)
173+
if (net_admin && ulp_ops->get_info_size)
175174
size += ulp_ops->get_info_size(sk);
176175
}
177176
}

0 commit comments

Comments
 (0)