Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9617813d authored by Davide Caratti's avatar Davide Caratti Committed by David S. Miller
Browse files

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: default avatarDavide Caratti <dcaratti@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6f5b24ee
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3076,6 +3076,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,
+26 −0
Original line number Diff line number Diff line
@@ -2243,6 +2243,32 @@ __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;
}

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;
EXPORT_SYMBOL(crc32c_csum_stub);

 /**
 *	skb_zerocopy_headlen - Calculate headroom needed for skb_zerocopy()
 *	@from: source buffer
+6 −0
Original line number Diff line number Diff line
@@ -98,6 +98,11 @@ static const struct net_offload sctp6_offload = {
	},
};

static const struct skb_checksum_ops crc32c_csum_ops = {
	.update  = sctp_csum_update,
	.combine = sctp_csum_combine,
};

int __init sctp_offload_init(void)
{
	int ret;
@@ -110,6 +115,7 @@ int __init sctp_offload_init(void)
	if (ret)
		goto ipv4;

	crc32c_csum_stub = &crc32c_csum_ops;
	return ret;

ipv4: