Skip to contentSkip to conversation

net: minor: tcp: use tcp_skb_mss helper in tcp_tso_segment

PATCH Applied Daniel Borkmann 3 participants 5 messages Jun 7, 2013

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

PATCH 1/2 net: minor: tcp: use tcp_skb_mss helper in tcp_tso_segment

We have the minimal inline helper tcp_skb_mss to access skb_shinfo(skb)->gso_size, so also use it here to get mss.

---
 net/ipv4/tcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv4/tcp.c +2 -2
index b5d4ad9..6a1cf95 100644
@@ -2905,7 +2905,7 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb,
 	oldlen = (u16)~skb->len;
 	__skb_pull(skb, thlen);
 
-	mss = skb_shinfo(skb)->gso_size;
+	mss = tcp_skb_mss(skb);
 	if (unlikely(skb->len <= mss))
 		goto out;
 
@@ -3071,7 +3071,7 @@ found:
 		flush |= *(u32 *)((u8 *)th + i) ^
 			 *(u32 *)((u8 *)th2 + i);
 
-	mss = skb_shinfo(p)->gso_size;
+	mss = tcp_skb_mss(p);
 
 	flush |= (len - 1) >= mss;
 	flush |= (ntohl(th2->seq) + skb_gro_len(p)) ^ ntohl(th->seq);
Signature · 1 line
1.7.11.7
#1 lore raw

PATCH 2/2 net: tcp: move GRO/GSO functions to tcp_offload

Would be good to make things explicit and move those functions to a new file called tcp_offload.c, thus make this similar to tcpv6_offload.c. While moving all related functions into tcp_offload.c, we can also make some of them static, since they are only used there. Also, add an explicit registration function.

---
I'll also follow-up with a udp_offload.c very soon after we agreed on this one.

 include/net/tcp.h      |   9 +-
 net/ipv4/Makefile      |   2 +-
 net/ipv4/af_inet.c     |  13 +-
 net/ipv4/tcp.c         | 241 -----------------------------------
 net/ipv4/tcp_ipv4.c    |  66 +---------
 net/ipv4/tcp_offload.c | 332 +++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 341 insertions(+), 322 deletions(-)
 create mode 100644 net/ipv4/tcp_offload.c
include/net/tcp.h +5 -4
index bf1cc3d..0d637e9 100644
@@ -1541,15 +1541,14 @@ extern struct request_sock_ops tcp6_request_sock_ops;
 
 extern void tcp_v4_destroy_sock(struct sock *sk);
 
-extern int tcp_v4_gso_send_check(struct sk_buff *skb);
 extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb,
 				       netdev_features_t features);
 extern struct sk_buff **tcp_gro_receive(struct sk_buff **head,
 					struct sk_buff *skb);
-extern struct sk_buff **tcp4_gro_receive(struct sk_buff **head,
-					 struct sk_buff *skb);
 extern int tcp_gro_complete(struct sk_buff *skb);
-extern int tcp4_gro_complete(struct sk_buff *skb);
+
+extern void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr,
+				__be32 daddr);
 
 #ifdef CONFIG_PROC_FS
 extern int tcp4_proc_init(void);
@@ -1584,6 +1583,8 @@ struct tcp_request_sock_ops {
 #endif
 };
 
+extern int tcpv4_offload_init(void);
+
 extern void tcp_v4_init(void);
 extern void tcp_init(void);
 
net/ipv4/Makefile +1 -1
index 089cb9f..4d3e138 100644
@@ -8,7 +8,7 @@ obj-y     := route.o inetpeer.o protocol.o \
 	     inet_timewait_sock.o inet_connection_sock.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 \
-	     datagram.o raw.o udp.o udplite.o \
+	     tcp_offload.o datagram.o raw.o udp.o udplite.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 +2 -11
index 9c090c7..7b51429 100644
@@ -1559,15 +1559,6 @@ static const struct net_protocol tcp_protocol = {
 	.netns_ok	=	1,
 };
 
-static const struct net_offload tcp_offload = {
-	.callbacks = {
-		.gso_send_check	=	tcp_v4_gso_send_check,
-		.gso_segment	=	tcp_tso_segment,
-		.gro_receive	=	tcp4_gro_receive,
-		.gro_complete	=	tcp4_gro_complete,
-	},
-};
-
 static const struct net_protocol udp_protocol = {
 	.handler =	udp_rcv,
 	.err_handler =	udp_err,
@@ -1683,8 +1674,8 @@ static int __init ipv4_offload_init(void)
 	 */
 	if (inet_add_offload(&udp_offload, IPPROTO_UDP) < 0)
 		pr_crit("%s: Cannot add UDP protocol offload\n", __func__);
-	if (inet_add_offload(&tcp_offload, IPPROTO_TCP) < 0)
-		pr_crit("%s: Cannot add TCP protocol offlaod\n", __func__);
+	if (tcpv4_offload_init() < 0)
+		pr_crit("%s: Cannot add TCP protocol offload\n", __func__);
 
 	dev_add_offload(&ip_packet_offload);
 	return 0;
net/ipv4/tcp.c +0 -241

247 lines not on this page · raw message

net/ipv4/tcp_ipv4.c +1 -65

84 lines not on this page · raw message

net/ipv4/tcp_offload.c new file +332 -0

332 lines not on this page · raw message

Signature · 1 line
1.7.11.7
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH net-next 2/2] net: tcp: move GRO/GSO functions to tcp_offload

Quoted 10 lines · Daniel Borkmann

Would be good to make things explicit and move those functions to a new file called tcp_offload.c, thus make this similar to tcpv6_offload.c. While moving all related functions into tcp_offload.c, we can also make some of them static, since they are only used there. Also, add an explicit registration function.

---
I'll also follow-up with a udp_offload.c very soon after we agreed on this one.

LGTM, thanks !

maintainer Applied
#3 lore raw

Re: [PATCH net-next 2/2] net: tcp: move GRO/GSO functions to tcp_offload

In reply to Daniel Borkmann

From: Daniel Borkmann <[email protected]>
Date: Fri, 7 Jun 2013 17:11:46 +0200

Quoted 8 lines

Would be good to make things explicit and move those functions to a new file called tcp_offload.c, thus make this similar to tcpv6_offload.c. While moving all related functions into tcp_offload.c, we can also make some of them static, since they are only used there. Also, add an explicit registration function.

Applied.