From: Vlad Yasevich <vyasevich@gmail.com>
To: Fan Du <fan.du@windriver.com>,
nhorman@tuxdriver.com, steffen.klassert@secunet.com
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH net] {xfrm, sctp} Stick to software crc32 even if hardware is capable of that
Date: Thu, 10 Oct 2013 10:11:04 -0400 [thread overview]
Message-ID: <5256B578.8040101@gmail.com> (raw)
In-Reply-To: <1381384296-1821-1-git-send-email-fan.du@windriver.com>
On 10/10/2013 01:51 AM, Fan Du wrote:
> igb/ixgbe have hardware sctp checksum support, when this feature is enabled
> and also IPsec is armed to protect sctp traffic, ugly things happened as
> xfrm_output checks CHECKSUM_PARTIAL to do check sum operation(sum every thing
> up and pack the 16bits result in the checksum field). The result is fail
> establishment of sctp communication.
>
> And I saw another point in this part of code, when IPsec is not armed,
> sctp communication is good, however setting setting CHECKSUM_PARTIAL will
> make xfrm_output compute dummy checksum values which will be overwritten by
> hardware lately.
>
> So this patch try to solve above two issues together.
>
> Signed-off-by: Fan Du <fan.du@windriver.com>
> ---
> note:
> igb/ixgbe hardware is not handy on my side, so just build test only.
>
> ---
> net/sctp/output.c | 27 +++++++++++++++++++--------
> 1 file changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/net/sctp/output.c b/net/sctp/output.c
> index 0ac3a65..f0b9cc5 100644
> --- a/net/sctp/output.c
> +++ b/net/sctp/output.c
> @@ -372,6 +372,16 @@ static void sctp_packet_set_owner_w(struct sk_buff *skb, struct sock *sk)
> atomic_inc(&sk->sk_wmem_alloc);
> }
>
> +static int is_xfrm_armed(struct dst_entry *dst)
> +{
> +#ifdef CONFIG_XFRM
> + /* If dst->xfrm is valid, this skb needs to be transformed */
> + return dst->xfrm != NULL;
> +#else
> + return 0;
> +#endif
> +}
> +
> /* All packets are sent to the network through this function from
> * sctp_outq_tail().
> *
> @@ -536,20 +546,21 @@ int sctp_packet_transmit(struct sctp_packet *packet)
> * by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>.
> */
> if (!sctp_checksum_disable) {
> - if (!(dst->dev->features & NETIF_F_SCTP_CSUM)) {
> + if ((!(dst->dev->features & NETIF_F_SCTP_CSUM)) ||
> + is_xfrm_armed(dst)) {
> +
> __u32 crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len);
>
> /* 3) Put the resultant value into the checksum field in the
> * common header, and leave the rest of the bits unchanged.
> */
> sh->checksum = sctp_end_cksum(crc32);
> - } else {
> - /* no need to seed pseudo checksum for SCTP */
> - nskb->ip_summed = CHECKSUM_PARTIAL;
> - nskb->csum_start = (skb_transport_header(nskb) -
> - nskb->head);
> - nskb->csum_offset = offsetof(struct sctphdr, checksum);
> - }
> + } else
> + /* Mark skb as CHECKSUM_UNNECESSARY to let hardware compute
> + * the checksum, and also avoid xfrm_output to do unceccessary
> + * checksum.
> + */
> + nskb->ip_summed = CHECKSUM_UNNECESSARY;
> }
In addition to what Niel said, the use of CHECKSUM_UNNECESSARY is
incorrect as it will cause the nic to not compute the checksum.
The checksum offload depends on the use of CHECKSUM_PARTIAL.
-vlad
>
> /* IP layer ECN support
>
next prev parent reply other threads:[~2013-10-10 14:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-10 5:51 [PATCH net] {xfrm, sctp} Stick to software crc32 even if hardware is capable of that Fan Du
2013-10-10 13:11 ` Neil Horman
2013-10-11 7:02 ` Fan Du
2013-10-11 7:05 ` [PATCHv2 1/2 ] " Fan Du
2013-10-11 14:04 ` Vlad Yasevich
2013-10-11 17:12 ` Vlad Yasevich
2013-10-11 7:08 ` [PATCHv2 2/2] Don't compute checksum value for SCTP skb with, CHECKSUM_PARTIAL set Fan Du
2013-10-11 14:25 ` Vlad Yasevich
2013-10-12 9:45 ` Fan Du
2013-10-12 13:06 ` Vlad Yasevich
2013-10-14 7:16 ` Fan Du
2013-10-10 14:11 ` Vlad Yasevich [this message]
2013-10-11 7:02 ` [PATCH net] {xfrm, sctp} Stick to software crc32 even if hardware is capable of that Fan Du
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5256B578.8040101@gmail.com \
--to=vyasevich@gmail.com \
--cc=davem@davemloft.net \
--cc=fan.du@windriver.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=steffen.klassert@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).