netpoll: prepare for ipv6
Subsystems (5)
PATCH v2 1/3 netpoll: prepare for ipv6
From: Cong Wang <[email protected]>
v2: use bool for ipv6 flag
fix !CONFIG_IPV6 case
This patch adjusts some struct and functions, to prepare for supporting IPv6.
--- drivers/net/netconsole.c | 12 +- include/linux/netpoll.h | 13 ++- net/core/netpoll.c | 402 ++++++++++++++++++++++++++-------------------- 3 files changed, 243 insertions(+), 184 deletions(-)
drivers/net/netconsole.c +8 -4
@@ -269,12 +269,14 @@ static ssize_t show_remote_port(struct netconsole_target *nt, char *buf)static ssize_t show_local_ip (struct netconsole_target *nt,char *buf) { -return snprintf (buf,PAGE_SIZE ,"%pI4\n" , &nt->np.local_ip); +if (!nt->np.ipv6) +return snprintf (buf,PAGE_SIZE ,"%pI4\n" , &nt->np.local_ip); }static ssize_t show_remote_ip (struct netconsole_target *nt,char *buf) { -return snprintf (buf,PAGE_SIZE ,"%pI4\n" , &nt->np.remote_ip); +if (!nt->np.ipv6) +return snprintf (buf,PAGE_SIZE ,"%pI4\n" , &nt->np.remote_ip); }static ssize_t show_local_mac (struct netconsole_target *nt,char *buf)
@@ -410,7 +412,8 @@ static ssize_t store_local_ip(struct netconsole_target *nt,return -EINVAL ; } - nt->np.local_ip =in_aton (buf); +if (!strnchr (buf, count,':' )) + nt->np.local_ip.ip =in_aton (buf);return strnlen (buf, count); }
@@ -426,7 +429,8 @@ static ssize_t store_remote_ip(struct netconsole_target *nt,return -EINVAL ; } - nt->np.remote_ip =in_aton (buf); +if (!strnchr (buf, count,':' )) + nt->np.remote_ip.ip =in_aton (buf);return strnlen (buf, count); }
include/linux/netpoll.h +11 -2
@@ -12,13 +12,22 @@#include <linux/rcupdate.h> #include <linux/list.h> +union inet_addr { +__u32 all[4 ]; +__be32 ip; +__be32 ip6[4 ]; +struct in_addr in; +struct in6_addr in6; +}; +struct netpoll {struct net_device *dev;char dev_name[IFNAMSIZ ];const char *name;void (*rx_hook)(struct netpoll *,int ,char *,int ); -__be32 local_ip, remote_ip; +union inet_addr local_ip, remote_ip; +bool ipv6;u16 local_port, remote_port;u8 remote_mac[ETH_ALEN ];
@@ -33,7 +42,7 @@ struct netpoll_info {spinlock_t rx_lock;struct list_head rx_np;/* netpolls that registered an rx_hook */ -struct sk_buff_head arp_tx;/* list of arp requests to reply to */ +struct sk_buff_head neigh_tx;/* list of neigh requests to reply to */ struct sk_buff_head txq;struct delayed_work tx_work;
net/core/netpoll.c +224 -178
540 lines not on this page · raw message
Signature · 1 line
1.7.7.6
PATCH v2 2/3 netpoll: add IPv6 support
From: Cong Wang <[email protected]>
Currently, netpoll only supports IPv4. This patch adds IPv6 support to netpoll so that we can run netconsole over IPv6 network.
--- drivers/net/netconsole.c | 44 +++++++- include/net/udp.h | 2 + net/core/netpoll.c | 251 ++++++++++++++++++++++++++++++++++++++++++++-- net/ipv6/udp.c | 3 +- 4 files changed, 282 insertions(+), 18 deletions(-)
drivers/net/netconsole.c +38 -6
@@ -269,13 +269,17 @@ static ssize_t show_remote_port(struct netconsole_target *nt, char *buf)static ssize_t show_local_ip (struct netconsole_target *nt,char *buf) { -if (!nt->np.ipv6) +if (nt->np.ipv6) +return snprintf (buf,PAGE_SIZE ,"%pI6c\n" , &nt->np.local_ip.in6); +else return snprintf (buf,PAGE_SIZE ,"%pI4\n" , &nt->np.local_ip); }static ssize_t show_remote_ip (struct netconsole_target *nt,char *buf) { -if (!nt->np.ipv6) +if (nt->np.ipv6) +return snprintf (buf,PAGE_SIZE ,"%pI6c\n" , &nt->np.remote_ip.in6); +else return snprintf (buf,PAGE_SIZE ,"%pI4\n" , &nt->np.remote_ip); }
@@ -412,8 +416,22 @@ static ssize_t store_local_ip(struct netconsole_target *nt,return -EINVAL ; } -if (!strnchr (buf, count,':' )) - nt->np.local_ip.ip =in_aton (buf); +if (strnchr (buf, count,':' )) { +const char *end; +if (in6_pton (buf, count, nt->np.local_ip.in6.s6_addr,-1 , &end) >0 ) { +if (*end && *end !='\n' ) { +printk (KERN_ERR "netconsole: invalid IPv6 address at: <%c>\n" , *end); +return -EINVAL ; + } + nt->np.ipv6 =1 ; + }else +return -EINVAL ; + }else { +if (!nt->np.ipv6) + nt->np.local_ip.ip =in_aton (buf); +else +return -EINVAL ; + }return strnlen (buf, count); }
@@ -429,8 +447,22 @@ static ssize_t store_remote_ip(struct netconsole_target *nt,return -EINVAL ; } -if (!strnchr (buf, count,':' )) - nt->np.remote_ip.ip =in_aton (buf); +if (strnchr (buf, count,':' )) { +const char *end; +if (in6_pton (buf, count, nt->np.remote_ip.in6.s6_addr,-1 , &end) >0 ) { +if (*end && *end !='\n' ) { +printk (KERN_ERR "netconsole: invalid IPv6 address at: <%c>\n" , *end); +return -EINVAL ; + } + nt->np.ipv6 =1 ; + }else +return -EINVAL ; + }else { +if (!nt->np.ipv6) + nt->np.remote_ip.ip =in_aton (buf); +else +return -EINVAL ; + }return strnlen (buf, count); }
include/net/udp.h +2 -0
@@ -156,6 +156,8 @@ static inline __wsum udp_csum(struct sk_buff *skb)return csum; } +extern int udp6_csum_init (struct sk_buff *skb,struct udphdr *uh,int proto); +/* hash routines shared between UDPv4/6 and UDP-Litev4/6 */ static inline void udp_lib_hash (struct sock *sk) {
net/core/netpoll.c +241 -10
325 lines not on this page · raw message
net/ipv6/udp.c +1 -2
@@ -752,8 +752,7 @@ static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb,return 0 ; } -static inline int udp6_csum_init (struct sk_buff *skb,struct udphdr *uh, -int proto) +int udp6_csum_init (struct sk_buff *skb,struct udphdr *uh,int proto) {int err;
Signature · 1 line
1.7.7.6
David Miller
maintainerRe: [PATCH net-next v2 2/3] netpoll: add IPv6 support
From: Cong Wang <[email protected]>
Date: Thu, 3 Jan 2013 12:50:22 +0800
Quoted 9 lines
net/ipv6/udp.c +1
-2-static inline int udp6_csum_init (struct sk_buff *skb,struct udphdr *uh, -int proto) +int udp6_csum_init (struct sk_buff *skb,struct udphdr *uh,int proto) {int err;Signature · 2 lines
-- 1.7.7.6
With IPV6=m and NETPOLL=y using this symbol will not work.
Re: [PATCH net-next v2 2/3] netpoll: add IPv6 support
Quoted 9 lines · David Miller
From: Cong Wang <[email protected]>
Date: Thu, 3 Jan 2013 12:50:22 +0800Quoted 6 lines
net/ipv6/udp.c +1
-2-static inline int udp6_csum_init (struct sk_buff *skb,struct udphdr *uh, -int proto) +int udp6_csum_init (struct sk_buff *skb,struct udphdr *uh,int proto) {int err;
Quoted 6 lines
Quoted 3 lines
Signature · 1 line
1.7.7.6With IPV6=m and NETPOLL=y using this symbol will not work.
Good point!
One solution is to introduce a new Kconfig option:
+config NETPOLL6
+ depends on (IPV6 || IPV6=n)
+ def_bool NETPOLL
+
and move these IPV6 code under #ifdef CONFIG_NETPOLL6.
PATCH v2 3/3 netconsole: add IPv6 example in doc
In reply to Cong WangFrom: Cong Wang <[email protected]>
Update the netconsole document as well.
iCc: David S. Miller <[email protected]>
--- Documentation/networking/netconsole.txt | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
Documentation/networking/netconsole.txt +6 -1
@@ -1,9 +1,10 @@ started by Ingo Molnar <[email protected]>, 2001.09.17 2.6 port and netpoll api by Matt Mackall <[email protected]>, Sep 9 2003 +IPv6 support by Cong Wang <[email protected]>, Jan 1 2013 Please send bug reports to Matt Mackall <[email protected]> -and Satyam Sharma <[email protected]> +Satyam Sharma <[email protected]>, and Cong Wang <[email protected]> Introduction: =============
@@ -41,6 +42,10 @@ Examples: insmod netconsole netconsole=@/,@10.0.0.2/ + or using IPv6 + + insmod netconsole netconsole=@/,@fd00:1:2:3::1/ + It also supports logging to multiple remote agents by specifying parameters for the multiple agents separated by semicolons and the complete string enclosed in "quotes", thusly:
Signature · 1 line
1.7.7.6