提交 0c2bf98c 编写于 作者: X Xin Long 提交者: Zheng Zengkai

net: igc: use skb_csum_is_sctp instead of protocol check

mainline inclusion
from mainline-v5.12-rc1-dontuse
commit 609d29a9
category: feature
bugzilla: 173966
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=609d29a9d2429a840a2f1f44e77b71d58e3e9a33

----------------------------------------------------------------------

Using skb_csum_is_sctp is a easier way to validate it's a SCTP CRC
checksum offload packet, and yet it also makes igc support SCTP
CRC checksum offload for UDP and GRE encapped packets, just as it
does in igb driver.
Signed-off-by: NXin Long <lucien.xin@gmail.com>
Reviewed-by: NAlexander Duyck <alexanderduyck@fb.com>
Signed-off-by: NJakub Kicinski <kuba@kernel.org>
Reviewed-by: NYongxin Li <liyongxin1@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 3b63ad2b
...@@ -948,15 +948,6 @@ static void igc_tx_ctxtdesc(struct igc_ring *tx_ring, ...@@ -948,15 +948,6 @@ static void igc_tx_ctxtdesc(struct igc_ring *tx_ring,
} }
} }
static inline bool igc_ipv6_csum_is_sctp(struct sk_buff *skb)
{
unsigned int offset = 0;
ipv6_find_hdr(skb, &offset, IPPROTO_SCTP, NULL, NULL);
return offset == skb_checksum_start_offset(skb);
}
static void igc_tx_csum(struct igc_ring *tx_ring, struct igc_tx_buffer *first) static void igc_tx_csum(struct igc_ring *tx_ring, struct igc_tx_buffer *first)
{ {
struct sk_buff *skb = first->skb; struct sk_buff *skb = first->skb;
...@@ -979,10 +970,7 @@ static void igc_tx_csum(struct igc_ring *tx_ring, struct igc_tx_buffer *first) ...@@ -979,10 +970,7 @@ static void igc_tx_csum(struct igc_ring *tx_ring, struct igc_tx_buffer *first)
break; break;
case offsetof(struct sctphdr, checksum): case offsetof(struct sctphdr, checksum):
/* validate that this is actually an SCTP request */ /* validate that this is actually an SCTP request */
if ((first->protocol == htons(ETH_P_IP) && if (skb_csum_is_sctp(skb)) {
(ip_hdr(skb)->protocol == IPPROTO_SCTP)) ||
(first->protocol == htons(ETH_P_IPV6) &&
igc_ipv6_csum_is_sctp(skb))) {
type_tucmd = IGC_ADVTXD_TUCMD_L4T_SCTP; type_tucmd = IGC_ADVTXD_TUCMD_L4T_SCTP;
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册