Skip to content

Commit cf53b1d

Browse files
shemmingerdavem330
authored andcommitted
Revert "net: Add driver helper functions to determine checksum offloadability"
This reverts commit 6ae23ad. 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>
1 parent 8eed1cd commit cf53b1d

2 files changed

Lines changed: 0 additions & 214 deletions

File tree

‎include/linux/netdevice.h‎

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,71 +2653,6 @@ static inline void skb_gro_remcsum_cleanup(struct sk_buff *skb,
26532653
remcsum_unadjust((__sum16 *)ptr, grc->delta);
26542654
}
26552655

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-
27212656
static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
27222657
unsigned short type,
27232658
const void *daddr, const void *saddr,
@@ -3961,19 +3896,6 @@ static inline bool can_checksum_protocol(netdev_features_t features,
39613896
}
39623897
}
39633898

3964-
/* Map an ethertype into IP protocol if possible */
3965-
static inline int eproto_to_ipproto(int eproto)
3966-
{
3967-
switch (eproto) {
3968-
case htons(ETH_P_IP):
3969-
return IPPROTO_IP;
3970-
case htons(ETH_P_IPV6):
3971-
return IPPROTO_IPV6;
3972-
default:
3973-
return -1;
3974-
}
3975-
}
3976-
39773899
#ifdef CONFIG_BUG
39783900
void netdev_rx_csum_fault(struct net_device *dev);
39793901
#else

‎net/core/dev.c‎

Lines changed: 0 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@
139139
#include <linux/errqueue.h>
140140
#include <linux/hrtimer.h>
141141
#include <linux/netfilter_ingress.h>
142-
#include <linux/sctp.h>
143142
#include <linux/crash_dump.h>
144143

145144
#include "net-sysfs.h"
@@ -2492,141 +2491,6 @@ int skb_checksum_help(struct sk_buff *skb)
24922491
}
24932492
EXPORT_SYMBOL(skb_checksum_help);
24942493

2495-
/* skb_csum_offload_check - Driver helper function to determine if a device
2496-
* with limited checksum offload capabilities is able to offload the checksum
2497-
* for a given packet.
2498-
*
2499-
* Arguments:
2500-
* skb - sk_buff for the packet in question
2501-
* spec - contains the description of what device can offload
2502-
* csum_encapped - returns true if the checksum being offloaded is
2503-
* encpasulated. That is it is checksum for the transport header
2504-
* in the inner headers.
2505-
* checksum_help - when set indicates that helper function should
2506-
* call skb_checksum_help if offload checks fail
2507-
*
2508-
* Returns:
2509-
* true: Packet has passed the checksum checks and should be offloadable to
2510-
* the device (a driver may still need to check for additional
2511-
* restrictions of its device)
2512-
* false: Checksum is not offloadable. If checksum_help was set then
2513-
* skb_checksum_help was called to resolve checksum for non-GSO
2514-
* packets and when IP protocol is not SCTP
2515-
*/
2516-
bool __skb_csum_offload_chk(struct sk_buff *skb,
2517-
const struct skb_csum_offl_spec *spec,
2518-
bool *csum_encapped,
2519-
bool csum_help)
2520-
{
2521-
struct iphdr *iph;
2522-
struct ipv6hdr *ipv6;
2523-
void *nhdr;
2524-
int protocol;
2525-
u8 ip_proto;
2526-
2527-
if (skb->protocol == htons(ETH_P_8021Q) ||
2528-
skb->protocol == htons(ETH_P_8021AD)) {
2529-
if (!spec->vlan_okay)
2530-
goto need_help;
2531-
}
2532-
2533-
/* We check whether the checksum refers to a transport layer checksum in
2534-
* the outermost header or an encapsulated transport layer checksum that
2535-
* corresponds to the inner headers of the skb. If the checksum is for
2536-
* something else in the packet we need help.
2537-
*/
2538-
if (skb_checksum_start_offset(skb) == skb_transport_offset(skb)) {
2539-
/* Non-encapsulated checksum */
2540-
protocol = eproto_to_ipproto(vlan_get_protocol(skb));
2541-
nhdr = skb_network_header(skb);
2542-
*csum_encapped = false;
2543-
if (spec->no_not_encapped)
2544-
goto need_help;
2545-
} else if (skb->encapsulation && spec->encap_okay &&
2546-
skb_checksum_start_offset(skb) ==
2547-
skb_inner_transport_offset(skb)) {
2548-
/* Encapsulated checksum */
2549-
*csum_encapped = true;
2550-
switch (skb->inner_protocol_type) {
2551-
case ENCAP_TYPE_ETHER:
2552-
protocol = eproto_to_ipproto(skb->inner_protocol);
2553-
break;
2554-
case ENCAP_TYPE_IPPROTO:
2555-
protocol = skb->inner_protocol;
2556-
break;
2557-
}
2558-
nhdr = skb_inner_network_header(skb);
2559-
} else {
2560-
goto need_help;
2561-
}
2562-
2563-
switch (protocol) {
2564-
case IPPROTO_IP:
2565-
if (!spec->ipv4_okay)
2566-
goto need_help;
2567-
iph = nhdr;
2568-
ip_proto = iph->protocol;
2569-
if (iph->ihl != 5 && !spec->ip_options_okay)
2570-
goto need_help;
2571-
break;
2572-
case IPPROTO_IPV6:
2573-
if (!spec->ipv6_okay)
2574-
goto need_help;
2575-
if (spec->no_encapped_ipv6 && *csum_encapped)
2576-
goto need_help;
2577-
ipv6 = nhdr;
2578-
nhdr += sizeof(*ipv6);
2579-
ip_proto = ipv6->nexthdr;
2580-
break;
2581-
default:
2582-
goto need_help;
2583-
}
2584-
2585-
ip_proto_again:
2586-
switch (ip_proto) {
2587-
case IPPROTO_TCP:
2588-
if (!spec->tcp_okay ||
2589-
skb->csum_offset != offsetof(struct tcphdr, check))
2590-
goto need_help;
2591-
break;
2592-
case IPPROTO_UDP:
2593-
if (!spec->udp_okay ||
2594-
skb->csum_offset != offsetof(struct udphdr, check))
2595-
goto need_help;
2596-
break;
2597-
case IPPROTO_SCTP:
2598-
if (!spec->sctp_okay ||
2599-
skb->csum_offset != offsetof(struct sctphdr, checksum))
2600-
goto cant_help;
2601-
break;
2602-
case NEXTHDR_HOP:
2603-
case NEXTHDR_ROUTING:
2604-
case NEXTHDR_DEST: {
2605-
u8 *opthdr = nhdr;
2606-
2607-
if (protocol != IPPROTO_IPV6 || !spec->ext_hdrs_okay)
2608-
goto need_help;
2609-
2610-
ip_proto = opthdr[0];
2611-
nhdr += (opthdr[1] + 1) << 3;
2612-
2613-
goto ip_proto_again;
2614-
}
2615-
default:
2616-
goto need_help;
2617-
}
2618-
2619-
/* Passed the tests for offloading checksum */
2620-
return true;
2621-
2622-
need_help:
2623-
if (csum_help && !skb_shinfo(skb)->gso_size)
2624-
skb_checksum_help(skb);
2625-
cant_help:
2626-
return false;
2627-
}
2628-
EXPORT_SYMBOL(__skb_csum_offload_chk);
2629-
26302494
__be16 skb_network_protocol(struct sk_buff *skb, int *depth)
26312495
{
26322496
__be16 type = skb->protocol;

0 commit comments

Comments
 (0)