diff options
author | Davide Caratti <dcaratti@redhat.com> | 2017-05-18 09:44:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-05-19 19:21:29 -0400 |
commit | 9617813dba5b6c112922c60cd2bc57c6e11ae907 (patch) | |
tree | ce7dfcb633751f2aaed7fe3b19988aa88f401270 | |
parent | 6f5b24eed0278136c29c27f2a7b3a2b6a202ac68 (diff) |
skbuff: add stub to help computing crc32c on SCTP packets
sctp_compute_checksum requires crc32c symbol (provided by libcrc32c), so
it can't be used in net core. Like it has been done previously with other
symbols (e.g. ipv6_dst_lookup), introduce a stub struct skb_checksum_ops
to allow computation of crc32c checksum in net core after sctp.ko (and thus
libcrc32c) has been loaded.
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/skbuff.h | 2 | ||||
-rw-r--r-- | net/core/skbuff.c | 26 | ||||
-rw-r--r-- | net/sctp/offload.c | 6 |
3 files changed, 34 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 7c0cb2ce8b01..b1f46a0d18e2 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -3076,6 +3076,8 @@ struct skb_checksum_ops { | |||
3076 | __wsum (*combine)(__wsum csum, __wsum csum2, int offset, int len); | 3076 | __wsum (*combine)(__wsum csum, __wsum csum2, int offset, int len); |
3077 | }; | 3077 | }; |
3078 | 3078 | ||
3079 | extern const struct skb_checksum_ops *crc32c_csum_stub __read_mostly; | ||
3080 | |||
3079 | __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len, | 3081 | __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len, |
3080 | __wsum csum, const struct skb_checksum_ops *ops); | 3082 | __wsum csum, const struct skb_checksum_ops *ops); |
3081 | __wsum skb_checksum(const struct sk_buff *skb, int offset, int len, | 3083 | __wsum skb_checksum(const struct sk_buff *skb, int offset, int len, |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 346d3e85dfbc..d5c98117cbce 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -2243,6 +2243,32 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, | |||
2243 | } | 2243 | } |
2244 | EXPORT_SYMBOL(skb_copy_and_csum_bits); | 2244 | EXPORT_SYMBOL(skb_copy_and_csum_bits); |
2245 | 2245 | ||
2246 | static __wsum warn_crc32c_csum_update(const void *buff, int len, __wsum sum) | ||
2247 | { | ||
2248 | net_warn_ratelimited( | ||
2249 | "%s: attempt to compute crc32c without libcrc32c.ko\n", | ||
2250 | __func__); | ||
2251 | return 0; | ||
2252 | } | ||
2253 | |||
2254 | static __wsum warn_crc32c_csum_combine(__wsum csum, __wsum csum2, | ||
2255 | int offset, int len) | ||
2256 | { | ||
2257 | net_warn_ratelimited( | ||
2258 | "%s: attempt to compute crc32c without libcrc32c.ko\n", | ||
2259 | __func__); | ||
2260 | return 0; | ||
2261 | } | ||
2262 | |||
2263 | static const struct skb_checksum_ops default_crc32c_ops = { | ||
2264 | .update = warn_crc32c_csum_update, | ||
2265 | .combine = warn_crc32c_csum_combine, | ||
2266 | }; | ||
2267 | |||
2268 | const struct skb_checksum_ops *crc32c_csum_stub __read_mostly = | ||
2269 | &default_crc32c_ops; | ||
2270 | EXPORT_SYMBOL(crc32c_csum_stub); | ||
2271 | |||
2246 | /** | 2272 | /** |
2247 | * skb_zerocopy_headlen - Calculate headroom needed for skb_zerocopy() | 2273 | * skb_zerocopy_headlen - Calculate headroom needed for skb_zerocopy() |
2248 | * @from: source buffer | 2274 | * @from: source buffer |
diff --git a/net/sctp/offload.c b/net/sctp/offload.c index 4f5a2b580aa5..b67198429db5 100644 --- a/net/sctp/offload.c +++ b/net/sctp/offload.c | |||
@@ -98,6 +98,11 @@ static const struct net_offload sctp6_offload = { | |||
98 | }, | 98 | }, |
99 | }; | 99 | }; |
100 | 100 | ||
101 | static const struct skb_checksum_ops crc32c_csum_ops = { | ||
102 | .update = sctp_csum_update, | ||
103 | .combine = sctp_csum_combine, | ||
104 | }; | ||
105 | |||
101 | int __init sctp_offload_init(void) | 106 | int __init sctp_offload_init(void) |
102 | { | 107 | { |
103 | int ret; | 108 | int ret; |
@@ -110,6 +115,7 @@ int __init sctp_offload_init(void) | |||
110 | if (ret) | 115 | if (ret) |
111 | goto ipv4; | 116 | goto ipv4; |
112 | 117 | ||
118 | crc32c_csum_stub = &crc32c_csum_ops; | ||
113 | return ret; | 119 | return ret; |
114 | 120 | ||
115 | ipv4: | 121 | ipv4: |