From patchwork Thu Oct 10 05:51:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "fan.du" X-Patchwork-Id: 282120 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 853192C012E for ; Thu, 10 Oct 2013 16:51:59 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753488Ab3JJFvz (ORCPT ); Thu, 10 Oct 2013 01:51:55 -0400 Received: from mail.windriver.com ([147.11.1.11]:40766 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752026Ab3JJFvy (ORCPT ); Thu, 10 Oct 2013 01:51:54 -0400 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail.windriver.com (8.14.5/8.14.3) with ESMTP id r9A5pZxK008912 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Wed, 9 Oct 2013 22:51:36 -0700 (PDT) Received: from iamroot-OptiPlex-780.corp.ad.wrs.com (128.224.162.162) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server id 14.2.347.0; Wed, 9 Oct 2013 22:51:35 -0700 From: Fan Du To: , , CC: , Subject: [PATCH net] {xfrm, sctp} Stick to software crc32 even if hardware is capable of that Date: Thu, 10 Oct 2013 13:51:36 +0800 Message-ID: <1381384296-1821-1-git-send-email-fan.du@windriver.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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 . */ 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; } /* IP layer ECN support