Skip to content

Commit 2046215

Browse files
Phil Sutterdavem330
authored andcommitted
net: inet_diag: export IPV6_V6ONLY sockopt
For AF_INET6 sockets, the value of struct ipv6_pinfo.ipv6only is exported to userspace. It indicates whether a socket bound to in6addr_any listens on IPv4 as well as IPv6. Since the socket is natively IPv6, it is not listed by e.g. 'ss -l -4'. This patch is accompanied by an appropriate one for iproute2 to enable the additional information in 'ss -e'. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f389a40 commit 2046215

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

include/uapi/linux/inet_diag.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ enum {
112112
INET_DIAG_SHUTDOWN,
113113
INET_DIAG_DCTCPINFO,
114114
INET_DIAG_PROTOCOL, /* response attribute only */
115+
INET_DIAG_SKV6ONLY,
115116
};
116117

117-
#define INET_DIAG_MAX INET_DIAG_PROTOCOL
118+
#define INET_DIAG_MAX INET_DIAG_SKV6ONLY
118119

119120
/* INET_DIAG_MEM */
120121

net/ipv4/inet_diag.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
151151
if (nla_put_u8(skb, INET_DIAG_TCLASS,
152152
inet6_sk(sk)->tclass) < 0)
153153
goto errout;
154+
155+
if (ipv6_only_sock(sk) &&
156+
nla_put_u8(skb, INET_DIAG_SKV6ONLY, 1))
157+
goto errout;
154158
}
155159
#endif
156160

0 commit comments

Comments
 (0)