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

Revert "net: Add driver helper functions to determine checksum offloadability"

This reverts commit 6ae23ad36253a8033c5714c52b691b84456487c5.

The code has been in kernel since 4.4 but there are no in tree
code that uses. Unused code is broken code, remove it.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

stephen hemminger and committed by
David S. Miller
cf53b1da 8eed1cd4

-214
-78
include/linux/netdevice.h
··· 2653 2653 remcsum_unadjust((__sum16 *)ptr, grc->delta); 2654 2654 } 2655 2655 2656 - struct skb_csum_offl_spec { 2657 - __u16 ipv4_okay:1, 2658 - ipv6_okay:1, 2659 - encap_okay:1, 2660 - ip_options_okay:1, 2661 - ext_hdrs_okay:1, 2662 - tcp_okay:1, 2663 - udp_okay:1, 2664 - sctp_okay:1, 2665 - vlan_okay:1, 2666 - no_encapped_ipv6:1, 2667 - no_not_encapped:1; 2668 - }; 2669 - 2670 - bool __skb_csum_offload_chk(struct sk_buff *skb, 2671 - const struct skb_csum_offl_spec *spec, 2672 - bool *csum_encapped, 2673 - bool csum_help); 2674 - 2675 - static inline bool skb_csum_offload_chk(struct sk_buff *skb, 2676 - const struct skb_csum_offl_spec *spec, 2677 - bool *csum_encapped, 2678 - bool csum_help) 2679 - { 2680 - if (skb->ip_summed != CHECKSUM_PARTIAL) 2681 - return false; 2682 - 2683 - return __skb_csum_offload_chk(skb, spec, csum_encapped, csum_help); 2684 - } 2685 - 2686 - static inline bool skb_csum_offload_chk_help(struct sk_buff *skb, 2687 - const struct skb_csum_offl_spec *spec) 2688 - { 2689 - bool csum_encapped; 2690 - 2691 - return skb_csum_offload_chk(skb, spec, &csum_encapped, true); 2692 - } 2693 - 2694 - static inline bool skb_csum_off_chk_help_cmn(struct sk_buff *skb) 2695 - { 2696 - static const struct skb_csum_offl_spec csum_offl_spec = { 2697 - .ipv4_okay = 1, 2698 - .ip_options_okay = 1, 2699 - .ipv6_okay = 1, 2700 - .vlan_okay = 1, 2701 - .tcp_okay = 1, 2702 - .udp_okay = 1, 2703 - }; 2704 - 2705 - return skb_csum_offload_chk_help(skb, &csum_offl_spec); 2706 - } 2707 - 2708 - static inline bool skb_csum_off_chk_help_cmn_v4_only(struct sk_buff *skb) 2709 - { 2710 - static const struct skb_csum_offl_spec csum_offl_spec = { 2711 - .ipv4_okay = 1, 2712 - .ip_options_okay = 1, 2713 - .tcp_okay = 1, 2714 - .udp_okay = 1, 2715 - .vlan_okay = 1, 2716 - }; 2717 - 2718 - return skb_csum_offload_chk_help(skb, &csum_offl_spec); 2719 - } 2720 - 2721 2656 static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev, 2722 2657 unsigned short type, 2723 2658 const void *daddr, const void *saddr, ··· 3893 3958 return !!(features & NETIF_F_IPV6_CSUM); 3894 3959 default: 3895 3960 return false; 3896 - } 3897 - } 3898 - 3899 - /* Map an ethertype into IP protocol if possible */ 3900 - static inline int eproto_to_ipproto(int eproto) 3901 - { 3902 - switch (eproto) { 3903 - case htons(ETH_P_IP): 3904 - return IPPROTO_IP; 3905 - case htons(ETH_P_IPV6): 3906 - return IPPROTO_IPV6; 3907 - default: 3908 - return -1; 3909 3961 } 3910 3962 } 3911 3963
-136
net/core/dev.c
··· 139 139 #include <linux/errqueue.h> 140 140 #include <linux/hrtimer.h> 141 141 #include <linux/netfilter_ingress.h> 142 - #include <linux/sctp.h> 143 142 #include <linux/crash_dump.h> 144 143 145 144 #include "net-sysfs.h" ··· 2490 2491 return ret; 2491 2492 } 2492 2493 EXPORT_SYMBOL(skb_checksum_help); 2493 - 2494 - /* skb_csum_offload_check - Driver helper function to determine if a device 2495 - * with limited checksum offload capabilities is able to offload the checksum 2496 - * for a given packet. 2497 - * 2498 - * Arguments: 2499 - * skb - sk_buff for the packet in question 2500 - * spec - contains the description of what device can offload 2501 - * csum_encapped - returns true if the checksum being offloaded is 2502 - * encpasulated. That is it is checksum for the transport header 2503 - * in the inner headers. 2504 - * checksum_help - when set indicates that helper function should 2505 - * call skb_checksum_help if offload checks fail 2506 - * 2507 - * Returns: 2508 - * true: Packet has passed the checksum checks and should be offloadable to 2509 - * the device (a driver may still need to check for additional 2510 - * restrictions of its device) 2511 - * false: Checksum is not offloadable. If checksum_help was set then 2512 - * skb_checksum_help was called to resolve checksum for non-GSO 2513 - * packets and when IP protocol is not SCTP 2514 - */ 2515 - bool __skb_csum_offload_chk(struct sk_buff *skb, 2516 - const struct skb_csum_offl_spec *spec, 2517 - bool *csum_encapped, 2518 - bool csum_help) 2519 - { 2520 - struct iphdr *iph; 2521 - struct ipv6hdr *ipv6; 2522 - void *nhdr; 2523 - int protocol; 2524 - u8 ip_proto; 2525 - 2526 - if (skb->protocol == htons(ETH_P_8021Q) || 2527 - skb->protocol == htons(ETH_P_8021AD)) { 2528 - if (!spec->vlan_okay) 2529 - goto need_help; 2530 - } 2531 - 2532 - /* We check whether the checksum refers to a transport layer checksum in 2533 - * the outermost header or an encapsulated transport layer checksum that 2534 - * corresponds to the inner headers of the skb. If the checksum is for 2535 - * something else in the packet we need help. 2536 - */ 2537 - if (skb_checksum_start_offset(skb) == skb_transport_offset(skb)) { 2538 - /* Non-encapsulated checksum */ 2539 - protocol = eproto_to_ipproto(vlan_get_protocol(skb)); 2540 - nhdr = skb_network_header(skb); 2541 - *csum_encapped = false; 2542 - if (spec->no_not_encapped) 2543 - goto need_help; 2544 - } else if (skb->encapsulation && spec->encap_okay && 2545 - skb_checksum_start_offset(skb) == 2546 - skb_inner_transport_offset(skb)) { 2547 - /* Encapsulated checksum */ 2548 - *csum_encapped = true; 2549 - switch (skb->inner_protocol_type) { 2550 - case ENCAP_TYPE_ETHER: 2551 - protocol = eproto_to_ipproto(skb->inner_protocol); 2552 - break; 2553 - case ENCAP_TYPE_IPPROTO: 2554 - protocol = skb->inner_protocol; 2555 - break; 2556 - } 2557 - nhdr = skb_inner_network_header(skb); 2558 - } else { 2559 - goto need_help; 2560 - } 2561 - 2562 - switch (protocol) { 2563 - case IPPROTO_IP: 2564 - if (!spec->ipv4_okay) 2565 - goto need_help; 2566 - iph = nhdr; 2567 - ip_proto = iph->protocol; 2568 - if (iph->ihl != 5 && !spec->ip_options_okay) 2569 - goto need_help; 2570 - break; 2571 - case IPPROTO_IPV6: 2572 - if (!spec->ipv6_okay) 2573 - goto need_help; 2574 - if (spec->no_encapped_ipv6 && *csum_encapped) 2575 - goto need_help; 2576 - ipv6 = nhdr; 2577 - nhdr += sizeof(*ipv6); 2578 - ip_proto = ipv6->nexthdr; 2579 - break; 2580 - default: 2581 - goto need_help; 2582 - } 2583 - 2584 - ip_proto_again: 2585 - switch (ip_proto) { 2586 - case IPPROTO_TCP: 2587 - if (!spec->tcp_okay || 2588 - skb->csum_offset != offsetof(struct tcphdr, check)) 2589 - goto need_help; 2590 - break; 2591 - case IPPROTO_UDP: 2592 - if (!spec->udp_okay || 2593 - skb->csum_offset != offsetof(struct udphdr, check)) 2594 - goto need_help; 2595 - break; 2596 - case IPPROTO_SCTP: 2597 - if (!spec->sctp_okay || 2598 - skb->csum_offset != offsetof(struct sctphdr, checksum)) 2599 - goto cant_help; 2600 - break; 2601 - case NEXTHDR_HOP: 2602 - case NEXTHDR_ROUTING: 2603 - case NEXTHDR_DEST: { 2604 - u8 *opthdr = nhdr; 2605 - 2606 - if (protocol != IPPROTO_IPV6 || !spec->ext_hdrs_okay) 2607 - goto need_help; 2608 - 2609 - ip_proto = opthdr[0]; 2610 - nhdr += (opthdr[1] + 1) << 3; 2611 - 2612 - goto ip_proto_again; 2613 - } 2614 - default: 2615 - goto need_help; 2616 - } 2617 - 2618 - /* Passed the tests for offloading checksum */ 2619 - return true; 2620 - 2621 - need_help: 2622 - if (csum_help && !skb_shinfo(skb)->gso_size) 2623 - skb_checksum_help(skb); 2624 - cant_help: 2625 - return false; 2626 - } 2627 - EXPORT_SYMBOL(__skb_csum_offload_chk); 2628 2494 2629 2495 __be16 skb_network_protocol(struct sk_buff *skb, int *depth) 2630 2496 {