Skip to contentSkip to conversation

net: ipv6: Implement /proc/net/icmp6.

PATCH In review Lorenzo Colitti 2 participants 6 messages May 29, 2013 – Jun 1, 2013 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH v3 1/3 net: ipv6: Unify {raw,udp}6_sock_seq_show.

udp6_sock_seq_show and raw6_sock_seq_show are identical, except the UDP version displays ports and the raw version displays the protocol. Refactor most of the code in these two functions into a new common ip6_dgram_sock_seq_show function, in preparation for using it to display ICMPv6 sockets as well.

Also reduce the indentation in parts of include/net/transp_v6.h to improve readability.

Compiles and displays reasonable results with CONFIG_IPV6={n,m,y}

---
 include/net/transp_v6.h | 73 +++++++++++++++++++++++++++++--------------------
 net/ipv6/datagram.c     | 27 ++++++++++++++++++
 net/ipv6/raw.c          | 45 ++++++------------------------
 net/ipv6/udp.c          | 49 ++++++---------------------------
 4 files changed, 87 insertions(+), 107 deletions(-)
include/net/transp_v6.h +43 -30
index eb40e71..841c33e 100644
@@ -16,38 +16,51 @@ extern struct proto pingv6_prot;
 struct flowi6;
 
 /* extension headers */
-extern int				ipv6_exthdrs_init(void);
-extern void				ipv6_exthdrs_exit(void);
-extern int				ipv6_frag_init(void);
-extern void				ipv6_frag_exit(void);
+extern int		ipv6_exthdrs_init(void);
+extern void		ipv6_exthdrs_exit(void);
+extern int		ipv6_frag_init(void);
+extern void		ipv6_frag_exit(void);
 
 /* transport protocols */
-extern int				pingv6_init(void);
-extern void				pingv6_exit(void);
-extern int				rawv6_init(void);
-extern void				rawv6_exit(void);
-extern int				udpv6_init(void);
-extern void				udpv6_exit(void);
-extern int 				udplitev6_init(void);
-extern void 				udplitev6_exit(void);
-extern int				tcpv6_init(void);
-extern void				tcpv6_exit(void);
-
-extern int				udpv6_connect(struct sock *sk,
-						      struct sockaddr *uaddr,
-						      int addr_len);
-
-extern int			ip6_datagram_recv_ctl(struct sock *sk,
-						      struct msghdr *msg,
-						      struct sk_buff *skb);
-
-extern int			ip6_datagram_send_ctl(struct net *net,
-						      struct sock *sk,
-						      struct msghdr *msg,
-						      struct flowi6 *fl6,
-						      struct ipv6_txoptions *opt,
-						      int *hlimit, int *tclass,
-						      int *dontfrag);
+extern int		pingv6_init(void);
+extern void		pingv6_exit(void);
+extern int		rawv6_init(void);
+extern void		rawv6_exit(void);
+extern int		udpv6_init(void);
+extern void		udpv6_exit(void);
+extern int		udplitev6_init(void);
+extern void		udplitev6_exit(void);
+extern int		tcpv6_init(void);
+extern void		tcpv6_exit(void);
+
+extern int		udpv6_connect(struct sock *sk,
+				      struct sockaddr *uaddr,
+				      int addr_len);
+
+extern int		ip6_datagram_recv_ctl(struct sock *sk,
+					      struct msghdr *msg,
+					      struct sk_buff *skb);
+
+extern int		ip6_datagram_send_ctl(struct net *net,
+					      struct sock *sk,
+					      struct msghdr *msg,
+					      struct flowi6 *fl6,
+					      struct ipv6_txoptions *opt,
+					      int *hlimit, int *tclass,
+					      int *dontfrag);
+
+#define IPV6_SEQ_DGRAM_HEADER \
+			   "  sl  "					\
+			   "local_address                         "	\
+			   "remote_address                        "	\
+			   "st tx_queue rx_queue tr tm->when retrnsmt"	\
+			   "   uid  timeout inode ref pointer drops\n"
+
+extern void		ip6_dgram_sock_seq_show(struct seq_file *seq,
+						struct sock *sp,
+						__u16 srcp,
+						__u16 destp,
+						int bucket);
 
 #define		LOOPBACK4_IPV6		cpu_to_be32(0x7f000006)
 
net/ipv6/datagram.c +27 -0
index 4b56cbb..197e6f4 100644
@@ -879,3 +879,30 @@ exit_f:
 	return err;
 }
 EXPORT_SYMBOL_GPL(ip6_datagram_send_ctl);
+
+void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
+			     __u16 srcp, __u16 destp, int bucket)
+{
+	struct ipv6_pinfo *np = inet6_sk(sp);
+	const struct in6_addr *dest, *src;
+
+	dest  = &np->daddr;
+	src   = &np->rcv_saddr;
+	seq_printf(seq,
+		   "%5d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
+		   "%02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %pK %d\n",
+		   bucket,
+		   src->s6_addr32[0], src->s6_addr32[1],
+		   src->s6_addr32[2], src->s6_addr32[3], srcp,
+		   dest->s6_addr32[0], dest->s6_addr32[1],
+		   dest->s6_addr32[2], dest->s6_addr32[3], destp,
+		   sp->sk_state,
+		   sk_wmem_alloc_get(sp),
+		   sk_rmem_alloc_get(sp),
+		   0, 0L, 0,
+		   from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
+		   0,
+		   sock_i_ino(sp),
+		   atomic_read(&sp->sk_refcnt), sp,
+		   atomic_read(&sp->sk_drops));
+}
net/ipv6/raw.c +8 -37

53 lines not on this page · raw message

net/ipv6/udp.c +9 -40

57 lines not on this page · raw message

Signature · 1 line
1.8.2.1
maintainer
#3 lore raw

Re: [PATCH v3 1/3] net: ipv6: Unify {raw,udp}6_sock_seq_show.

From: Lorenzo Colitti <[email protected]>
Date: Wed, 29 May 2013 14:47:37 +0900

Quoted 6 lines

udp6_sock_seq_show and raw6_sock_seq_show are identical, except the UDP version displays ports and the raw version displays the protocol. Refactor most of the code in these two functions into a new common ip6_dgram_sock_seq_show function, in preparation for using it to display ICMPv6 sockets as well.

Quoted 6 lines

Also reduce the indentation in parts of include/net/transp_v6.h to improve readability.

Compiles and displays reasonable results with CONFIG_IPV6={n,m,y}

Do not mix functional changes with unrelated whitespace and other cleanups.

Split this patch series up properly and resubmit this entire series.

#4 lore raw

Re: [PATCH v3 1/3] net: ipv6: Unify {raw,udp}6_sock_seq_show.

Quoted 3 lines · David Miller

Do not mix functional changes with unrelated whitespace and other cleanups.

Split this patch series up properly and resubmit this entire series.

Ok, new patch series coming up.

#5 lore raw

PATCH v3 2/3 net: ipv4: make the ping /proc code AF-independent

In reply to Lorenzo Colitti

Introduce a ping_seq_afinfo structure (similar to its UDP equivalent) and use it to make some of the ping /proc functions address-family independent. Rename the remaining ping /proc functions from ping_* to ping_v4_*.

Compiles and displays reasonable results with CONFIG_IPV6={n,m,y}

---
 include/net/ping.h |  8 ++++++
 net/ipv4/ping.c    | 73 +++++++++++++++++++++++++++++++++++-------------------
 2 files changed, 55 insertions(+), 26 deletions(-)
include/net/ping.h +8 -0
index 9242fa0..b9282f0 100644
@@ -49,6 +49,7 @@ struct ping_table {
 struct ping_iter_state {
 	struct seq_net_private  p;
 	int			bucket;
+	sa_family_t		family;
 };
 
 extern struct proto ping_prot;
@@ -87,6 +88,13 @@ int  ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
 void ping_rcv(struct sk_buff *skb);
 
 #ifdef CONFIG_PROC_FS
+struct ping_seq_afinfo {
+	char				*name;
+	sa_family_t			family;
+	const struct file_operations	*seq_fops;
+	const struct seq_operations	seq_ops;
+};
+
 extern int __init ping_proc_init(void);
 extern void ping_proc_exit(void);
 #endif
net/ipv4/ping.c +47 -26

152 lines not on this page · raw message

Signature · 1 line
1.8.2.1
#6 lore raw

PATCH v3 3/3 net: ipv6: Implement /proc/net/icmp6.

In reply to Lorenzo Colitti

The format is based on /proc/net/icmp and /proc/net/{udp,raw}6.

Compiles and displays reasonable results with CONFIG_IPV6={n,m,y} Couldn't figure out how to test without CONFIG_PROC_FS enabled.

---
 include/net/ping.h |   8 +++++
 net/ipv4/ping.c    |  21 ++++++-----
 net/ipv6/ping.c    | 102 +++++++++++++++++++++++++++++++++++++++++------------
 3 files changed, 99 insertions(+), 32 deletions(-)
include/net/ping.h +8 -0
index b9282f0..db04802 100644
@@ -95,6 +95,14 @@ struct ping_seq_afinfo {
 	const struct seq_operations	seq_ops;
 };
 
+extern const struct file_operations ping_seq_fops;
+
+void *ping_seq_start(struct seq_file *seq, loff_t *pos, sa_family_t family);
+void *ping_seq_next(struct seq_file *seq, void *v, loff_t *pos);
+void ping_seq_stop(struct seq_file *seq, void *v);
+int ping_proc_register(struct net *net, struct ping_seq_afinfo *afinfo);
+void ping_proc_unregister(struct net *net, struct ping_seq_afinfo *afinfo);
+
 extern int __init ping_proc_init(void);
 extern void ping_proc_exit(void);
 #endif
net/ipv4/ping.c +12 -9
index 8c2da9b..3552a45 100644
@@ -1035,8 +1035,7 @@ static struct sock *ping_get_idx(struct seq_file *seq, loff_t pos)
 	return pos ? NULL : sk;
 }
 
-static void *ping_seq_start(struct seq_file *seq, loff_t *pos,
-			    sa_family_t family)
+void *ping_seq_start(struct seq_file *seq, loff_t *pos, sa_family_t family)
 {
 	struct ping_iter_state *state = seq->private;
 	state->bucket = 0;
@@ -1046,13 +1045,14 @@ static void *ping_seq_start(struct seq_file *seq, loff_t *pos,
 
 	return *pos ? ping_get_idx(seq, *pos-1) : SEQ_START_TOKEN;
 }
+EXPORT_SYMBOL_GPL(ping_seq_start);
 
 static void *ping_v4_seq_start(struct seq_file *seq, loff_t *pos)
 {
 	return ping_seq_start(seq, pos, AF_INET);
 }
 
-static void *ping_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+void *ping_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
 	struct sock *sk;
 
@@ -1064,11 +1064,13 @@ static void *ping_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 	++*pos;
 	return sk;
 }
+EXPORT_SYMBOL_GPL(ping_seq_next);
 
-static void ping_seq_stop(struct seq_file *seq, void *v)
+void ping_seq_stop(struct seq_file *seq, void *v)
 {
 	read_unlock_bh(&ping_table.lock);
 }
+EXPORT_SYMBOL_GPL(ping_seq_stop);
 
 static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
 		int bucket, int *len)
@@ -1122,12 +1124,13 @@ static int ping_seq_open(struct inode *inode, struct file *file)
 			   sizeof(struct ping_iter_state));
 }
 
-static const struct file_operations ping_seq_fops = {
+const struct file_operations ping_seq_fops = {
 	.open		= ping_seq_open,
 	.read		= seq_read,
 	.llseek		= seq_lseek,
 	.release	= seq_release_net,
 };
+EXPORT_SYMBOL_GPL(ping_seq_fops);
 
 static struct ping_seq_afinfo ping_v4_seq_afinfo = {
 	.name		= "icmp",
@@ -1141,7 +1144,7 @@ static struct ping_seq_afinfo ping_v4_seq_afinfo = {
 	},
 };
 
-static int ping_proc_register(struct net *net, struct ping_seq_afinfo *afinfo)
+int ping_proc_register(struct net *net, struct ping_seq_afinfo *afinfo)
 {
 	struct proc_dir_entry *p;
 	p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net,
@@ -1150,13 +1153,13 @@ static int ping_proc_register(struct net *net, struct ping_seq_afinfo *afinfo)
 		return -ENOMEM;
 	return 0;
 }
+EXPORT_SYMBOL_GPL(ping_proc_register);
 
-static void ping_proc_unregister(struct net *net,
-				 struct ping_seq_afinfo *afinfo)
+void ping_proc_unregister(struct net *net, struct ping_seq_afinfo *afinfo)
 {
 	remove_proc_entry(afinfo->name, net->proc_net);
 }
-
+EXPORT_SYMBOL_GPL(ping_proc_unregister);
 
 static int __net_init ping_v4_proc_init_net(struct net *net)
 {
net/ipv6/ping.c +79 -23

111 lines not on this page · raw message

Signature · 1 line
1.8.2.1