netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] net: inet_diag: export IPV6_V6ONLY sockopt
@ 2015-06-24  9:02 Phil Sutter
  2015-06-24  9:51 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Sutter @ 2015-06-24  9:02 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Eric Dumazet

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>
---
Changes since v1:
- Commit message corrected.
- Patch based on current net-next.git.
- Eric's superior solution implemented.
---
 include/uapi/linux/inet_diag.h | 3 ++-
 net/ipv4/inet_diag.c           | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/inet_diag.h b/include/uapi/linux/inet_diag.h
index b629fc5..68a1f71 100644
--- a/include/uapi/linux/inet_diag.h
+++ b/include/uapi/linux/inet_diag.h
@@ -112,9 +112,10 @@ enum {
 	INET_DIAG_SHUTDOWN,
 	INET_DIAG_DCTCPINFO,
 	INET_DIAG_PROTOCOL,  /* response attribute only */
+	INET_DIAG_SKV6ONLY,
 };
 
-#define INET_DIAG_MAX INET_DIAG_PROTOCOL
+#define INET_DIAG_MAX INET_DIAG_SKV6ONLY
 
 /* INET_DIAG_MEM */
 
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 21985d8..653564d 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -151,6 +151,10 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
 			if (nla_put_u8(skb, INET_DIAG_TCLASS,
 				       inet6_sk(sk)->tclass) < 0)
 				goto errout;
+
+		if (ipv6_only_sock(sk) &&
+		    nla_put_u8(skb, INET_DIAG_SKV6ONLY, 1))
+			goto errout;
 	}
 #endif
 
-- 
2.1.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] net: inet_diag: export IPV6_V6ONLY sockopt
  2015-06-24  9:02 [PATCH v2] net: inet_diag: export IPV6_V6ONLY sockopt Phil Sutter
@ 2015-06-24  9:51 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-06-24  9:51 UTC (permalink / raw)
  To: phil; +Cc: netdev, eric.dumazet

From: Phil Sutter <phil@nwl.cc>
Date: Wed, 24 Jun 2015 11:02:51 +0200

> 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>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-24  9:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-24  9:02 [PATCH v2] net: inet_diag: export IPV6_V6ONLY sockopt Phil Sutter
2015-06-24  9:51 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).