Skip to contentSkip to conversation

net: udp4: move GSO functions to udp_offload

PATCH Applied Daniel Borkmann 3 participants 5 messages Jun 8, 2013 – Jun 24, 2013

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

PATCH 1/1 net: udp4: move GSO functions to udp_offload

Similarly to TCP offloading and UDPv6 offloading, move all related UDPv4 functions to udp_offload.c to make things more explicit. Also, by this, we can make those functions static.

---
 include/net/udp.h      |   7 ++--
 net/ipv4/Makefile      |   2 +-
 net/ipv4/af_inet.c     |   9 +----
 net/ipv4/udp.c         |  75 +------------------------------------
 net/ipv4/udp_offload.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 108 insertions(+), 85 deletions(-)
 create mode 100644 net/ipv4/udp_offload.c
include/net/udp.h +4 -3
index 065f379..b30a71a 100644
@@ -187,6 +187,8 @@ extern int udp_ioctl(struct sock *sk, int cmd, unsigned long arg);
 extern int udp_disconnect(struct sock *sk, int flags);
 extern unsigned int udp_poll(struct file *file, struct socket *sock,
 			     poll_table *wait);
+extern struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,
+					      netdev_features_t features);
 extern int udp_lib_getsockopt(struct sock *sk, int level, int optname,
 			      char __user *optval, int __user *optlen);
 extern int udp_lib_setsockopt(struct sock *sk, int level, int optname,
@@ -262,11 +264,10 @@ extern int udp4_proc_init(void);
 extern void udp4_proc_exit(void);
 #endif
 
+extern int udpv4_offload_init(void);
+
 extern void udp_init(void);
 
-extern int udp4_ufo_send_check(struct sk_buff *skb);
-extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
-	netdev_features_t features);
 extern void udp_encap_enable(void);
 #if IS_ENABLED(CONFIG_IPV6)
 extern void udpv6_encap_enable(void);
net/ipv4/Makefile +1 -1
index 4d3e138..a9dd333 100644
@@ -9,7 +9,7 @@ obj-y     := route.o inetpeer.o protocol.o \
 	     tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \
 	     tcp_minisocks.o tcp_cong.o tcp_metrics.o tcp_fastopen.o \
 	     tcp_offload.o datagram.o raw.o udp.o udplite.o \
-	     arp.o icmp.o devinet.o af_inet.o  igmp.o \
+	     udp_offload.o arp.o icmp.o devinet.o af_inet.o igmp.o \
 	     fib_frontend.o fib_semantics.o fib_trie.o \
 	     inet_fragment.o ping.o
 
net/ipv4/af_inet.c +1 -8
index 7b51429..5598b06 100644
@@ -1566,13 +1566,6 @@ static const struct net_protocol udp_protocol = {
 	.netns_ok =	1,
 };
 
-static const struct net_offload udp_offload = {
-	.callbacks = {
-		.gso_send_check = udp4_ufo_send_check,
-		.gso_segment = udp4_ufo_fragment,
-	},
-};
-
 static const struct net_protocol icmp_protocol = {
 	.handler =	icmp_rcv,
 	.err_handler =	icmp_err,
@@ -1672,7 +1665,7 @@ static int __init ipv4_offload_init(void)
 	/*
 	 * Add offloads
 	 */
-	if (inet_add_offload(&udp_offload, IPPROTO_UDP) < 0)
+	if (udpv4_offload_init() < 0)
 		pr_crit("%s: Cannot add UDP protocol offload\n", __func__);
 	if (tcpv4_offload_init() < 0)
 		pr_crit("%s: Cannot add TCP protocol offload\n", __func__);
net/ipv4/udp.c +2 -73

84 lines not on this page · raw message

net/ipv4/udp_offload.c new file +100 -0

100 lines not on this page · raw message

Signature · 1 line
1.7.11.7
maintainer Applied
#1 lore raw

From: Daniel Borkmann <[email protected]>
Date: Sat, 8 Jun 2013 12:56:03 +0200

Quoted 5 lines

Similarly to TCP offloading and UDPv6 offloading, move all related UDPv4 functions to udp_offload.c to make things more explicit. Also, by this, we can make those functions static.

Applied.

#2 lore raw
In reply to Daniel Borkmann
Quoted 5 lines · Daniel Borkmann

Similarly to TCP offloading and UDPv6 offloading, move all related UDPv4 functions to udp_offload.c to make things more explicit. Also, by this, we can make those functions static.

Quoted 8 lines
---
 include/net/udp.h      |   7 ++--
 net/ipv4/Makefile      |   2 +-
 net/ipv4/af_inet.c     |   9 +----
 net/ipv4/udp.c         |  75 +------------------------------------
 net/ipv4/udp_offload.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 108 insertions(+), 85 deletions(-)
 create mode 100644 net/ipv4/udp_offload.c

Daniel, the same could be done for GRE, ie moving GSO stuff into net/ipv4/gre_offload.c

Tell me if you do not have the time to do this, I will handle it.

Thanks

#3 lore raw
Quoted 15 lines · Eric Dumazet
Quoted 5 lines · Daniel Borkmann

Similarly to TCP offloading and UDPv6 offloading, move all related UDPv4 functions to udp_offload.c to make things more explicit. Also, by this, we can make those functions static.

Quoted 8 lines
---
  include/net/udp.h      |   7 ++--
  net/ipv4/Makefile      |   2 +-
  net/ipv4/af_inet.c     |   9 +----
  net/ipv4/udp.c         |  75 +------------------------------------
  net/ipv4/udp_offload.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++
  5 files changed, 108 insertions(+), 85 deletions(-)

create mode 100644 net/ipv4/udp_offload.c

Quoted 4 lines

Daniel, the same could be done for GRE, ie moving GSO stuff into net/ipv4/gre_offload.c

Tell me if you do not have the time to do this, I will handle it.

Ok, I can do this today.

Thanks,

Daniel

#4 lore raw
Quoted 8 lines · Daniel Borkmann
Quoted 5 lines · Eric Dumazet

Daniel, the same could be done for GRE, ie moving GSO stuff into net/ipv4/gre_offload.c

Tell me if you do not have the time to do this, I will handle it.

Ok, I can do this today.

Thanks !

Oh well, there is a bug in gre_gso_segment(), we need to fix it before considering this gre_offload.c separation.

if __skb_linearize() fails, kfree_skb(segs); is not really doing the right thing.