Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: Remove gso_send_check as an offload callback

The send_check logic was only interesting in cases of TCP offload and
UDP UFO where the checksum needed to be initialized to the pseudo
header checksum. Now we've moved that logic into the related
gso_segment functions so gso_send_check is no longer needed.

Signed-off-by: Tom Herbert <therbert@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Tom Herbert and committed by
David S. Miller
53e50398 f71470b3

+3 -113
-1
include/linux/netdevice.h
··· 1911 1911 struct offload_callbacks { 1912 1912 struct sk_buff *(*gso_segment)(struct sk_buff *skb, 1913 1913 netdev_features_t features); 1914 - int (*gso_send_check)(struct sk_buff *skb); 1915 1914 struct sk_buff **(*gro_receive)(struct sk_buff **head, 1916 1915 struct sk_buff *skb); 1917 1916 int (*gro_complete)(struct sk_buff *skb, int nhoff);
-10
net/core/dev.c
··· 2422 2422 rcu_read_lock(); 2423 2423 list_for_each_entry_rcu(ptype, &offload_base, list) { 2424 2424 if (ptype->type == type && ptype->callbacks.gso_segment) { 2425 - if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) { 2426 - int err; 2427 - 2428 - err = ptype->callbacks.gso_send_check(skb); 2429 - segs = ERR_PTR(err); 2430 - if (err || skb_gso_ok(skb, features)) 2431 - break; 2432 - __skb_push(skb, (skb->data - 2433 - skb_network_header(skb))); 2434 - } 2435 2425 segs = ptype->callbacks.gso_segment(skb, features); 2436 2426 break; 2437 2427 }
-36
net/ipv4/af_inet.c
··· 1197 1197 } 1198 1198 EXPORT_SYMBOL(inet_sk_rebuild_header); 1199 1199 1200 - static int inet_gso_send_check(struct sk_buff *skb) 1201 - { 1202 - const struct net_offload *ops; 1203 - const struct iphdr *iph; 1204 - int proto; 1205 - int ihl; 1206 - int err = -EINVAL; 1207 - 1208 - if (unlikely(!pskb_may_pull(skb, sizeof(*iph)))) 1209 - goto out; 1210 - 1211 - iph = ip_hdr(skb); 1212 - ihl = iph->ihl * 4; 1213 - if (ihl < sizeof(*iph)) 1214 - goto out; 1215 - 1216 - proto = iph->protocol; 1217 - 1218 - /* Warning: after this point, iph might be no longer valid */ 1219 - if (unlikely(!pskb_may_pull(skb, ihl))) 1220 - goto out; 1221 - __skb_pull(skb, ihl); 1222 - 1223 - skb_reset_transport_header(skb); 1224 - err = -EPROTONOSUPPORT; 1225 - 1226 - ops = rcu_dereference(inet_offloads[proto]); 1227 - if (likely(ops && ops->callbacks.gso_send_check)) 1228 - err = ops->callbacks.gso_send_check(skb); 1229 - 1230 - out: 1231 - return err; 1232 - } 1233 - 1234 1200 static struct sk_buff *inet_gso_segment(struct sk_buff *skb, 1235 1201 netdev_features_t features) 1236 1202 { ··· 1621 1655 static struct packet_offload ip_packet_offload __read_mostly = { 1622 1656 .type = cpu_to_be16(ETH_P_IP), 1623 1657 .callbacks = { 1624 - .gso_send_check = inet_gso_send_check, 1625 1658 .gso_segment = inet_gso_segment, 1626 1659 .gro_receive = inet_gro_receive, 1627 1660 .gro_complete = inet_gro_complete, ··· 1629 1664 1630 1665 static const struct net_offload ipip_offload = { 1631 1666 .callbacks = { 1632 - .gso_send_check = inet_gso_send_check, 1633 1667 .gso_segment = inet_gso_segment, 1634 1668 .gro_receive = inet_gro_receive, 1635 1669 .gro_complete = inet_gro_complete,
+3 -8
net/ipv4/gre_offload.c
··· 15 15 #include <net/protocol.h> 16 16 #include <net/gre.h> 17 17 18 - static int gre_gso_send_check(struct sk_buff *skb) 19 - { 20 - if (!skb->encapsulation) 21 - return -EINVAL; 22 - return 0; 23 - } 24 - 25 18 static struct sk_buff *gre_gso_segment(struct sk_buff *skb, 26 19 netdev_features_t features) 27 20 { ··· 37 44 SKB_GSO_GRE | 38 45 SKB_GSO_GRE_CSUM | 39 46 SKB_GSO_IPIP))) 47 + goto out; 48 + 49 + if (!skb->encapsulation) 40 50 goto out; 41 51 42 52 if (unlikely(!pskb_may_pull(skb, sizeof(*greh)))) ··· 252 256 253 257 static const struct net_offload gre_offload = { 254 258 .callbacks = { 255 - .gso_send_check = gre_gso_send_check, 256 259 .gso_segment = gre_gso_segment, 257 260 .gro_receive = gre_gro_receive, 258 261 .gro_complete = gre_gro_complete,
-6
net/ipv4/tcp_offload.c
··· 288 288 } 289 289 EXPORT_SYMBOL(tcp_gro_complete); 290 290 291 - static int tcp_v4_gso_send_check(struct sk_buff *skb) 292 - { 293 - return 0; 294 - } 295 - 296 291 static struct sk_buff **tcp4_gro_receive(struct sk_buff **head, struct sk_buff *skb) 297 292 { 298 293 /* Don't bother verifying checksum if we're going to flush anyway. */ ··· 315 320 316 321 static const struct net_offload tcpv4_offload = { 317 322 .callbacks = { 318 - .gso_send_check = tcp_v4_gso_send_check, 319 323 .gso_segment = tcp4_gso_segment, 320 324 .gro_receive = tcp4_gro_receive, 321 325 .gro_complete = tcp4_gro_complete,
-6
net/ipv4/udp_offload.c
··· 25 25 struct udp_offload_priv __rcu *next; 26 26 }; 27 27 28 - static int udp4_ufo_send_check(struct sk_buff *skb) 29 - { 30 - return 0; 31 - } 32 - 33 28 struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, 34 29 netdev_features_t features) 35 30 { ··· 341 346 342 347 static const struct net_offload udpv4_offload = { 343 348 .callbacks = { 344 - .gso_send_check = udp4_ufo_send_check, 345 349 .gso_segment = udp4_ufo_fragment, 346 350 .gro_receive = udp4_gro_receive, 347 351 .gro_complete = udp4_gro_complete,
-27
net/ipv6/ip6_offload.c
··· 53 53 return proto; 54 54 } 55 55 56 - static int ipv6_gso_send_check(struct sk_buff *skb) 57 - { 58 - const struct ipv6hdr *ipv6h; 59 - const struct net_offload *ops; 60 - int err = -EINVAL; 61 - 62 - if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h)))) 63 - goto out; 64 - 65 - ipv6h = ipv6_hdr(skb); 66 - __skb_pull(skb, sizeof(*ipv6h)); 67 - err = -EPROTONOSUPPORT; 68 - 69 - ops = rcu_dereference(inet6_offloads[ 70 - ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr)]); 71 - 72 - if (likely(ops && ops->callbacks.gso_send_check)) { 73 - skb_reset_transport_header(skb); 74 - err = ops->callbacks.gso_send_check(skb); 75 - } 76 - 77 - out: 78 - return err; 79 - } 80 - 81 56 static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, 82 57 netdev_features_t features) 83 58 { ··· 281 306 static struct packet_offload ipv6_packet_offload __read_mostly = { 282 307 .type = cpu_to_be16(ETH_P_IPV6), 283 308 .callbacks = { 284 - .gso_send_check = ipv6_gso_send_check, 285 309 .gso_segment = ipv6_gso_segment, 286 310 .gro_receive = ipv6_gro_receive, 287 311 .gro_complete = ipv6_gro_complete, ··· 289 315 290 316 static const struct net_offload sit_offload = { 291 317 .callbacks = { 292 - .gso_send_check = ipv6_gso_send_check, 293 318 .gso_segment = ipv6_gso_segment, 294 319 .gro_receive = ipv6_gro_receive, 295 320 .gro_complete = ipv6_gro_complete,
-6
net/ipv6/tcpv6_offload.c
··· 15 15 #include <net/ip6_checksum.h> 16 16 #include "ip6_offload.h" 17 17 18 - static int tcp_v6_gso_send_check(struct sk_buff *skb) 19 - { 20 - return 0; 21 - } 22 - 23 18 static struct sk_buff **tcp6_gro_receive(struct sk_buff **head, 24 19 struct sk_buff *skb) 25 20 { ··· 66 71 } 67 72 static const struct net_offload tcpv6_offload = { 68 73 .callbacks = { 69 - .gso_send_check = tcp_v6_gso_send_check, 70 74 .gso_segment = tcp6_gso_segment, 71 75 .gro_receive = tcp6_gro_receive, 72 76 .gro_complete = tcp6_gro_complete,
-6
net/ipv6/udp_offload.c
··· 17 17 #include <net/ip6_checksum.h> 18 18 #include "ip6_offload.h" 19 19 20 - static int udp6_ufo_send_check(struct sk_buff *skb) 21 - { 22 - return 0; 23 - } 24 - 25 20 static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb, 26 21 netdev_features_t features) 27 22 { ··· 161 166 162 167 static const struct net_offload udpv6_offload = { 163 168 .callbacks = { 164 - .gso_send_check = udp6_ufo_send_check, 165 169 .gso_segment = udp6_ufo_fragment, 166 170 .gro_receive = udp6_gro_receive, 167 171 .gro_complete = udp6_gro_complete,
-7
net/mpls/mpls_gso.c
··· 65 65 return segs; 66 66 } 67 67 68 - static int mpls_gso_send_check(struct sk_buff *skb) 69 - { 70 - return 0; 71 - } 72 - 73 68 static struct packet_offload mpls_mc_offload = { 74 69 .type = cpu_to_be16(ETH_P_MPLS_MC), 75 70 .callbacks = { 76 - .gso_send_check = mpls_gso_send_check, 77 71 .gso_segment = mpls_gso_segment, 78 72 }, 79 73 }; ··· 75 81 static struct packet_offload mpls_uc_offload = { 76 82 .type = cpu_to_be16(ETH_P_MPLS_UC), 77 83 .callbacks = { 78 - .gso_send_check = mpls_gso_send_check, 79 84 .gso_segment = mpls_gso_segment, 80 85 }, 81 86 };