[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200721173221.4681-20-tparkin@katalix.com>
Date: Tue, 21 Jul 2020 18:32:11 +0100
From: Tom Parkin <tparkin@...alix.com>
To: netdev@...r.kernel.org
Cc: Tom Parkin <tparkin@...alix.com>
Subject: [PATCH 19/29] l2tp: use a function to render tunnel address in l2tp_debugfs
The L2TP tunnel socket address may be IPv4 or IPv6.
The conditionally compiled code for IPv6 support confused checkpatch's
indentation and brace checking.
To avoid the warning, and make the code somewhat easier to read, split
the address rendering out into a function where the conditional
compilation can be handled more cleanly.
Signed-off-by: Tom Parkin <tparkin@...alix.com>
---
net/l2tp/l2tp_debugfs.c | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/net/l2tp/l2tp_debugfs.c b/net/l2tp/l2tp_debugfs.c
index 800a17b988be..d8cddc82da4b 100644
--- a/net/l2tp/l2tp_debugfs.c
+++ b/net/l2tp/l2tp_debugfs.c
@@ -121,6 +121,25 @@ static void l2tp_dfs_seq_stop(struct seq_file *p, void *v)
}
}
+static void l2tp_dfs_seq_tunnel_show_addr(struct seq_file *m, struct l2tp_tunnel *tunnel)
+{
+ struct inet_sock *inet = inet_sk(tunnel->sock);
+
+#if IS_ENABLED(CONFIG_IPV6)
+ if (tunnel->sock->sk_family == AF_INET6) {
+ const struct ipv6_pinfo *np = inet6_sk(tunnel->sock);
+
+ seq_printf(m, " from %pI6c to %pI6c\n", &np->saddr, &tunnel->sock->sk_v6_daddr);
+ }
+#endif
+ if (tunnel->sock->sk_family == AF_INET)
+ seq_printf(m, " from %pI4 to %pI4\n", &inet->inet_saddr, &inet->inet_daddr);
+
+ if (tunnel->encap == L2TP_ENCAPTYPE_UDP)
+ seq_printf(m, " source port %hu, dest port %hu\n",
+ ntohs(inet->inet_sport), ntohs(inet->inet_dport));
+}
+
static void l2tp_dfs_seq_tunnel_show(struct seq_file *m, void *v)
{
struct l2tp_tunnel *tunnel = v;
@@ -144,23 +163,8 @@ static void l2tp_dfs_seq_tunnel_show(struct seq_file *m, void *v)
read_unlock_bh(&tunnel->hlist_lock);
seq_printf(m, "\nTUNNEL %u peer %u", tunnel->tunnel_id, tunnel->peer_tunnel_id);
- if (tunnel->sock) {
- struct inet_sock *inet = inet_sk(tunnel->sock);
-
-#if IS_ENABLED(CONFIG_IPV6)
- if (tunnel->sock->sk_family == AF_INET6) {
- const struct ipv6_pinfo *np = inet6_sk(tunnel->sock);
-
- seq_printf(m, " from %pI6c to %pI6c\n",
- &np->saddr, &tunnel->sock->sk_v6_daddr);
- } else
-#endif
- seq_printf(m, " from %pI4 to %pI4\n",
- &inet->inet_saddr, &inet->inet_daddr);
- if (tunnel->encap == L2TP_ENCAPTYPE_UDP)
- seq_printf(m, " source port %hu, dest port %hu\n",
- ntohs(inet->inet_sport), ntohs(inet->inet_dport));
- }
+ if (tunnel->sock)
+ l2tp_dfs_seq_tunnel_show_addr(m, tunnel);
seq_printf(m, " L2TPv%d, %s\n", tunnel->version,
tunnel->encap == L2TP_ENCAPTYPE_UDP ? "UDP" :
tunnel->encap == L2TP_ENCAPTYPE_IP ? "IP" :
--
2.17.1
Powered by blists - more mailing lists