Message ID | 970ffbc429b9297c3038f12f4b9cad1afbdbc375.1494946940.git.dcaratti@redhat.com |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
From: Davide Caratti <dcaratti@redhat.com> Date: Tue, 16 May 2017 18:27:45 +0200 > @@ -2243,6 +2243,30 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, > } > EXPORT_SYMBOL(skb_copy_and_csum_bits); > > +static __wsum warn_crc32c_csum_update(const void *buff, int len, __wsum sum) > +{ > + net_warn_ratelimited( > + "%s: attempt to compute crc32c without libcrc32c.ko\n", > + __func__); > + return 0; > +} > + > +static __wsum warn_crc32c_csum_combine(__wsum csum, __wsum csum2, > + int offset, int len) > +{ > + net_warn_ratelimited( > + "%s: attempt to compute crc32c without libcrc32c.ko\n", > + __func__); > + return 0; > +} > + > +const struct skb_checksum_ops *crc32c_csum_stub __read_mostly = > + &(struct skb_checksum_ops) { > + .update = warn_crc32c_csum_update, > + .combine = warn_crc32c_csum_combine, > +}; > +EXPORT_SYMBOL(crc32c_csum_stub); Please, if you are going to do this, declare things in a more traditional and canonical way: static const struct skb_checksum_ops default_crc32c_ops = { .update = warn_crc32c_csum_update, .combine = warn_crc32c_csum_combine, }; const struct skb_checksum_ops *crc32c_csum_stub __read_mostly = &default_crc32c_ops; > +static const struct skb_checksum_ops *crc32c_csum_ops __read_mostly = > + &(struct skb_checksum_ops) { > + .update = sctp_csum_update, > + .combine = sctp_csum_combine, > +}; Likewise.
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index a098d95..884a197 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3129,6 +3129,8 @@ struct skb_checksum_ops { __wsum (*combine)(__wsum csum, __wsum csum2, int offset, int len); }; +extern const struct skb_checksum_ops *crc32c_csum_stub __read_mostly; + __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum, const struct skb_checksum_ops *ops); __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 346d3e8..12e3cb7 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -2243,6 +2243,30 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, } EXPORT_SYMBOL(skb_copy_and_csum_bits); +static __wsum warn_crc32c_csum_update(const void *buff, int len, __wsum sum) +{ + net_warn_ratelimited( + "%s: attempt to compute crc32c without libcrc32c.ko\n", + __func__); + return 0; +} + +static __wsum warn_crc32c_csum_combine(__wsum csum, __wsum csum2, + int offset, int len) +{ + net_warn_ratelimited( + "%s: attempt to compute crc32c without libcrc32c.ko\n", + __func__); + return 0; +} + +const struct skb_checksum_ops *crc32c_csum_stub __read_mostly = + &(struct skb_checksum_ops) { + .update = warn_crc32c_csum_update, + .combine = warn_crc32c_csum_combine, +}; +EXPORT_SYMBOL(crc32c_csum_stub); + /** * skb_zerocopy_headlen - Calculate headroom needed for skb_zerocopy() * @from: source buffer diff --git a/net/sctp/offload.c b/net/sctp/offload.c index 4f5a2b5..378f462 100644 --- a/net/sctp/offload.c +++ b/net/sctp/offload.c @@ -98,6 +98,12 @@ static const struct net_offload sctp6_offload = { }, }; +static const struct skb_checksum_ops *crc32c_csum_ops __read_mostly = + &(struct skb_checksum_ops) { + .update = sctp_csum_update, + .combine = sctp_csum_combine, +}; + int __init sctp_offload_init(void) { int ret; @@ -110,6 +116,7 @@ int __init sctp_offload_init(void) if (ret) goto ipv4; + crc32c_csum_stub = crc32c_csum_ops; return ret; ipv4: