Skip to contentSkip to conversation

ipv6: Enable enough of the code to handle GSO when disabled.

PATCH In review Vlad Yasevich 3 participants 6 messages Oct 17, 2012

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ipv6: Enable enough of the code to handle GSO when disabled.

Changes:
- Fix spelling in description
- Removed obsolete stub definition from ipv.h

When a guest using virtio is attempting to use IPv6 on a host where the IPv6 module is administratively disabled, the tcp bulk transfer rate drops down to 10kbps. The problem is that when IPv6 is disabled, none of the protocol handlers are registered. When a guest attempts to send an IPv6 packet with GSO (which is the default), this packet is dropped by the host stack because there are no gso handlers registered. A retransmit is triggered for every GSO packet thus reducing the transfer rate.

This patch attempts to solve this by enabling just enough code so GSO is correctly processed. However, I should point out that if IPv6 is simply blacklisted or not built for the kernel, this problem will still persist.

This problem also exists for AF_PACKET sockets, so it is not limited to guests using virtio.

---
 include/linux/ipv6.h  |    1 +
 net/ipv6/af_inet6.c   |   69 +++++++++++++++++++++++++++++++++++++++++++++---
 net/ipv6/ip6_input.c  |    5 +++
 net/ipv6/reassembly.c |   11 +++++--
 net/ipv6/tcp_ipv6.c   |    9 +++++-
 net/ipv6/udp.c        |    6 +++-
 6 files changed, 90 insertions(+), 11 deletions(-)
include/linux/ipv6.h +1 -0
index 0b94e91..1d5e061 100644
@@ -176,6 +176,7 @@ struct ipv6_devconf {
 };
 
 struct ipv6_params {
+	__s32 disable_ipv6_mod;
 	__s32 disable_ipv6;
 	__s32 autoconf;
 };
net/ipv6/af_inet6.c +64 -5

102 lines not on this page · raw message

net/ipv6/ip6_input.c +5 -0
index a52d864..3e86ec3 100644
@@ -74,6 +74,11 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
 		return NET_RX_DROP;
 	}
 
+	if (ipv6_defaults.disable_ipv6_mod) {
+		kfree_skb(skb);
+		return NET_RX_DROP;
+	}
+
 	rcu_read_lock();
 
 	idev = __in6_dev_get(skb->dev);
net/ipv6/reassembly.c +8 -3
index da8a4e3..71a0e61 100644
@@ -705,6 +705,9 @@ int __init ipv6_frag_init(void)
 	if (ret)
 		goto out;
 
+	if (ipv6_defaults.disable_ipv6_mod)
+		goto out;
+
 	ret = ip6_frags_sysctl_register();
 	if (ret)
 		goto err_sysctl;
@@ -734,8 +737,10 @@ err_sysctl:
 
 void ipv6_frag_exit(void)
 {
-	inet_frags_fini(&ip6_frags);
-	ip6_frags_sysctl_unregister();
-	unregister_pernet_subsys(&ip6_frags_ops);
+	if (!ipv6_defaults.disable_ipv6_mod) {
+		inet_frags_fini(&ip6_frags);
+		ip6_frags_sysctl_unregister();
+		unregister_pernet_subsys(&ip6_frags_ops);
+	}
 	inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT);
 }
net/ipv6/tcp_ipv6.c +7 -2
index 49c8903..ebb297c 100644
@@ -2109,6 +2109,9 @@ int __init tcpv6_init(void)
 	if (ret)
 		goto out;
 
+	if (ipv6_defaults.disable_ipv6_mod)
+		goto out;
+
 	/* register inet6 protocol */
 	ret = inet6_register_protosw(&tcpv6_protosw);
 	if (ret)
@@ -2129,7 +2132,9 @@ out_tcpv6_protosw:
 
 void tcpv6_exit(void)
 {
-	unregister_pernet_subsys(&tcpv6_net_ops);
-	inet6_unregister_protosw(&tcpv6_protosw);
+	if (!ipv6_defaults.disable_ipv6_mod) {
+		unregister_pernet_subsys(&tcpv6_net_ops);
+		inet6_unregister_protosw(&tcpv6_protosw);
+	}
 	inet6_del_protocol(&tcpv6_protocol, IPPROTO_TCP);
 }
net/ipv6/udp.c +5 -1
index fc99972..2e8dddb 100644
@@ -1569,6 +1569,9 @@ int __init udpv6_init(void)
 	if (ret)
 		goto out;
 
+	if (ipv6_defaults.disable_ipv6_mod)
+		goto out;
+
 	ret = inet6_register_protosw(&udpv6_protosw);
 	if (ret)
 		goto out_udpv6_protocol;
@@ -1582,6 +1585,7 @@ out_udpv6_protocol:
 
 void udpv6_exit(void)
 {
-	inet6_unregister_protosw(&udpv6_protosw);
+	if (!ipv6_defaults.disable_ipv6_mod)
+		inet6_unregister_protosw(&udpv6_protosw);
 	inet6_del_protocol(&udpv6_protocol, IPPROTO_UDP);
 }
Signature · 1 line
1.7.7.6
#1 lore raw
Quoted 4 lines · Vlad Yasevich

This patch attempts to solve this by enabling just enough code so GSO is correctly processed. However, I should point out that if IPv6 is simply blacklisted or not built for the kernel, this problem will still persist.

So I guess this should be done in a different way ?

We currently use a single structure (struct packet_type) to hold pointers to different methods. (The .func() field, and the gso/gro stuff)

We probably need to split it in two parts, and make one part linked into kernel, even if CONFIG_IPV6=n, so that GRO/GSO is fully IPv4/IPv6 functional.

By the way, do we really need a hash table for this ?
It seems we only have IPv4 (ETH_P_IP) and IPv6 (ETH_P_IPV6) to take care of ?

This would remove some tests we currently have in GRO stack, and some RCU stuff as well.
(GRO is slower if we have many af_packet sockets)

list_for_each_entry_rcu(ptype, head, list) {
    if (ptype->type != type || ptype->dev || !ptype->gro_receive)
        continue;

...

Adding a hook/test in ipv6_rcv() is ugly.

#2 lore raw
Quoted 9 lines · Eric Dumazet
Quoted 4 lines · Vlad Yasevich

This patch attempts to solve this by enabling just enough code so GSO is correctly processed. However, I should point out that if IPv6 is simply blacklisted or not built for the kernel, this problem will still persist.

So I guess this should be done in a different way ?

Quoted 7 lines

We currently use a single structure (struct packet_type) to hold pointers to different methods. (The .func() field, and the gso/gro stuff)

We probably need to split it in two parts, and make one part linked into kernel, even if CONFIG_IPV6=n, so that GRO/GSO is fully IPv4/IPv6 functional.

[...]

Either that or make sure that we don't advertise IPv6 GSO when IPv6 is disabled.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#3 lore raw
Quoted 17 lines · Ben Hutchings
Quoted 9 lines · Eric Dumazet
Quoted 4 lines · Vlad Yasevich

This patch attempts to solve this by enabling just enough code so GSO is correctly processed. However, I should point out that if IPv6 is simply blacklisted or not built for the kernel, this problem will still persist.

So I guess this should be done in a different way ?

Quoted 7 lines

We currently use a single structure (struct packet_type) to hold pointers to different methods. (The .func() field, and the gso/gro stuff)

We probably need to split it in two parts, and make one part linked into kernel, even if CONFIG_IPV6=n, so that GRO/GSO is fully IPv4/IPv6 functional.

Quoted 7 lines

[...]

Either that or make sure that we don't advertise IPv6 GSO when IPv6 is disabled.

Ben.

this becomes a problem when migration or save/restore is used. since offload features may be different between systesm, we may not be able to migrate.

-vlad

#4 lore raw
In reply to Eric Dumazet
Quoted 9 lines · Eric Dumazet
Quoted 4 lines · Vlad Yasevich

This patch attempts to solve this by enabling just enough code so GSO is correctly processed. However, I should point out that if IPv6 is simply blacklisted or not built for the kernel, this problem will still persist.

So I guess this should be done in a different way ?

Quoted 7 lines

We currently use a single structure (struct packet_type) to hold pointers to different methods. (The .func() field, and the gso/gro stuff)

We probably need to split it in two parts, and make one part linked into kernel, even if CONFIG_IPV6=n, so that GRO/GSO is fully IPv4/IPv6 functional.

The thing about this approach is that if there are any other protocols that could have to provide their own segmentation functionality, such functionality would always have to be part of the kernel. I wasn't sure how much I liked that.

Quoted 4 lines

By the way, do we really need a hash table for this ?
It seems we only have IPv4 (ETH_P_IP) and IPv6 (ETH_P_IPV6) to take care of ?

Which hash are you talking about? I didn't add any hashes.

Quoted 5 lines

This would remove some tests we currently have in GRO stack, and some RCU stuff as well.
(GRO is slower if we have many af_packet sockets)

Quoted 7 lines
list_for_each_entry_rcu(ptype, head, list) {
     if (ptype->type != type || ptype->dev || !ptype->gro_receive)
         continue;

...

Adding a hook/test in ipv6_rcv() is ugly.

There already is one for device. I original had a stub ipv6_rcv that just dropped the packet. I could resurrect that if that's better...

-vlad

Quoted 7 lines

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 14 lines · Vlad Yasevich
Quoted 13 lines · Eric Dumazet
Quoted 4 lines · Vlad Yasevich

This patch attempts to solve this by enabling just enough code so GSO is correctly processed. However, I should point out that if IPv6 is simply blacklisted or not built for the kernel, this problem will still persist.

So I guess this should be done in a different way ?

We currently use a single structure (struct packet_type) to hold pointers to different methods. (The .func() field, and the gso/gro stuff)

Quoted 8 lines
Quoted 3 lines

We probably need to split it in two parts, and make one part linked into kernel, even if CONFIG_IPV6=n, so that GRO/GSO is fully IPv4/IPv6 functional.

The thing about this approach is that if there are any other protocols that could have to provide their own segmentation functionality, such functionality would always have to be part of the kernel. I wasn't sure how much I liked that.

Well, an hypervisor probably has to handle IPv6, at least to a certain extent.

Make this part a module of its own, or statically linked into vmlinux, instead of adding some stubs in IPv6 'module'

Quoted 7 lines
Quoted 5 lines

By the way, do we really need a hash table for this ?
It seems we only have IPv4 (ETH_P_IP) and IPv6 (ETH_P_IPV6) to take care of ?

Which hash are you talking about? I didn't add any hashes.

I suspect you didnt really understood what I said then.

packet_type structures are hashed into ptype_base[]

struct list_head *head = &ptype_base[ntohs(type) & PTYPE_HASH_MASK];

Now let say we split the structure into 2 parts.

ptype_base[] would be used for pre GRO/GSO stuff (packet handlers)

So we would need to add a second hash for the GRO/GSO stuff.