netpoll: add IPv6 support
Subsystems (5)
v4 cover netpoll: add IPv6 support
v4: remove ndisc_parse_options(), ignore ICMP options there
make udp6_csum_init() inline so that we don't rely on IPV6=y fix a conflict with Jiri's patchset
v3: fix CONFIG_IPV6=m case
v2: use bool for ipv6 flag
fix !CONFIG_IPV6 case
This patchset implements netpoll over IPv6.
Cong Wang (3):
netpoll: prepare for ipv6
netpoll: add IPv6 support
netconsole: add IPv6 example in doc
Documentation/networking/netconsole.txt | 7 +- drivers/net/netconsole.c | 46 ++- include/linux/netpoll.h | 13 +- include/net/udp.h | 34 ++ net/core/netpoll.c | 617 ++++++++++++++++++++++--------- net/ipv6/udp.c | 34 -- 6 files changed, 534 insertions(+), 217 deletions(-)
Signature · 1 line
1.7.7.6
PATCH v4 1/3 netpoll: prepare for ipv6
From: Cong Wang <[email protected]>
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 v4 2/3 netpoll: add IPv6 support
In reply to Cong WangFrom: 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 | 46 ++++++++- include/net/udp.h | 34 +++++++ net/core/netpoll.c | 239 ++++++++++++++++++++++++++++++++++++++++++++-- net/ipv6/udp.c | 34 ------- 4 files changed, 303 insertions(+), 50 deletions(-)
drivers/net/netconsole.c +40 -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,23 @@ 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 = true; + }else +return -EINVAL ; + }else { +if (!nt->np.ipv6) { + nt->np.local_ip.ip =in_aton (buf); + nt->np.ipv6 = false; + }else +return -EINVAL ; + }return strnlen (buf, count); }
@@ -429,8 +448,23 @@ 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 = true; + }else +return -EINVAL ; + }else { +if (!nt->np.ipv6) { + nt->np.remote_ip.ip =in_aton (buf); + nt->np.ipv6 = false; + }else +return -EINVAL ; + }return strnlen (buf, count); }
include/net/udp.h +34 -0
@@ -156,6 +156,40 @@ static inline __wsum udp_csum(struct sk_buff *skb)return csum; } +#include <net/udplite.h> +static inline int udp6_csum_init (struct sk_buff *skb,struct udphdr *uh,int proto) +{ +int err; + +UDP_SKB_CB (skb)->partial_cov =0 ; +UDP_SKB_CB (skb)->cscov = skb->len; + +if (proto ==IPPROTO_UDPLITE ) { + err =udplite_checksum_init (skb, uh); +if (err) +return err; + } + +if (uh->check ==0 ) { +/* RFC 2460 section 8.1 says that we SHOULD log +this error. Well, it is reasonable. +*/ +LIMIT_NETDEBUG (KERN_INFO "IPv6: udp checksum is 0\n" ); +return 1 ; + } +if (skb->ip_summed ==CHECKSUM_COMPLETE && + !csum_ipv6_magic (&ipv6_hdr (skb)->saddr, &ipv6_hdr (skb)->daddr, + skb->len, proto, skb->csum)) + skb->ip_summed =CHECKSUM_UNNECESSARY ; + +if (!skb_csum_unnecessary (skb)) + skb->csum = ~csum_unfold (csum_ipv6_magic (&ipv6_hdr (skb)->saddr, + &ipv6_hdr (skb)->daddr, + skb->len, proto,0 )); + +return 0 ; +} +/* hash routines shared between UDPv4/6 and UDP-Litev4/6 */ static inline void udp_lib_hash (struct sock *sk) {
net/core/netpoll.c +229 -10
313 lines not on this page · raw message
net/ipv6/udp.c +0 -34
@@ -752,40 +752,6 @@ 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 err; - -UDP_SKB_CB (skb)->partial_cov =0 ; -UDP_SKB_CB (skb)->cscov = skb->len; - -if (proto ==IPPROTO_UDPLITE ) { - err =udplite_checksum_init (skb, uh); -if (err) -return err; - } - -if (uh->check ==0 ) { -/* RFC 2460 section 8.1 says that we SHOULD log -this error. Well, it is reasonable. -*/ -LIMIT_NETDEBUG (KERN_INFO "IPv6: udp checksum is 0\n" ); -return 1 ; - } -if (skb->ip_summed ==CHECKSUM_COMPLETE && - !csum_ipv6_magic (&ipv6_hdr (skb)->saddr, &ipv6_hdr (skb)->daddr, - skb->len, proto, skb->csum)) - skb->ip_summed =CHECKSUM_UNNECESSARY ; - -if (!skb_csum_unnecessary (skb)) - skb->csum = ~csum_unfold (csum_ipv6_magic (&ipv6_hdr (skb)->saddr, - &ipv6_hdr (skb)->daddr, - skb->len, proto,0 )); - -return 0 ; -} -int __udp6_lib_rcv (struct sk_buff *skb,struct udp_table *udptable,int proto) {
Signature · 1 line
1.7.7.6
PATCH v4 3/3 netconsole: add IPv6 example in doc
In reply to Cong WangFrom: Cong Wang <[email protected]>
Update the netconsole document as well.
--- 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
David Miller
maintainerFrom: Cong Wang <[email protected]>
Date: Mon, 7 Jan 2013 15:17:13 +0800
Quoted 3 lines
v4: remove
ndisc_parse_options(), ignore ICMP options there
makeudp6_csum_init()inline so that we don't rely on IPV6=y fix a conflict with Jiri's patchset
Where did I say to inline this function?
I said to put it into a seperate static library that gets linked into the kernel statically, regardless of whether IPV6 is 'm' or 'y'.
I've said this _3_ times and I'm really starting to get frustrated with the fact that you can't seem to read what I write.
What part of the "obj-y +=" rules in net/ipv6/Makefile are you unable to see?
Quoted 13 lines · David Miller
From: Cong Wang <[email protected]>
Date: Mon, 7 Jan 2013 15:17:13 +0800Quoted 3 lines
v4: remove
ndisc_parse_options(), ignore ICMP options there
makeudp6_csum_init()inline so that we don't rely on IPV6=y fix a conflict with Jiri's patchsetWhere did I say to inline this function?
I said to put it into a seperate static library that gets linked into the kernel statically, regardless of whether IPV6 is 'm' or 'y'.
Quoted 6 lines
I've said this _3_ times and I'm really starting to get frustrated with the fact that you can't seem to read what I write.
What part of the "obj-y +=" rules in
net/ipv6/Makefileare you unable to see?
I knew.
Our goal is to make it work for IPV6=m, so why inline is not a solution while putting it into a static library is? udp6_csum_init() is not a big function, so I see no reason why it can't be inlined.
And AFAIK, udp6_csum_init() can't fit into any of these obj-y files in net/ipv6/.
Am I still missing anything?
Thanks.
David Miller
maintainerFrom: Cong Wang <[email protected]>
Date: Tue, 08 Jan 2013 11:55:51 +0800
Quoted 2 lines
udp6_csum_init()is not a big function, so I see no reason why it can't be inlined.
I say it is.
Quoted 7 lines · David Miller
From: Cong Wang <[email protected]>
Date: Tue, 08 Jan 2013 11:55:51 +0800Quoted 2 lines
udp6_csum_init()is not a big function, so I see no reason why it can't be inlined.I say it is.
Ok. Then I will create a new file to put udp6_csum_init().
Thanks!
David Miller
maintainerFrom: Cong Wang <[email protected]>
Date: Tue, 08 Jan 2013 11:55:51 +0800
Quoted 2 lines
And AFAIK,
udp6_csum_init()can't fit into any of these obj-y files innet/ipv6/.
So, uhm, like make a new one?