Skip to content

Instantly share code, notes, and snippets.

@krsna1729
Created March 3, 2021 06:21
Show Gist options
  • Save krsna1729/c187c7afb5a9bbceaec08d95f7e4cf50 to your computer and use it in GitHub Desktop.
Save krsna1729/c187c7afb5a9bbceaec08d95f7e4cf50 to your computer and use it in GitHub Desktop.
With ability to parse inner packet comes more headache for simple rx checksum offloading
diff --git a/patches/bess/0008-Enable-hardware-checksum-offload.patch b/patches/bess/0008-Enable-hardware-checksum-offload.patch
index be1c751..7926150 100644
--- a/patches/bess/0008-Enable-hardware-checksum-offload.patch
+++ b/patches/bess/0008-Enable-hardware-checksum-offload.patch
@@ -17,7 +17,7 @@ index 9b29fc85..1501ea94 100644
eth_conf.lpbk_mode = 1;
}
+ if (arg.hwcksum()) {
-+ eth_conf.rxmode.offloads = DEV_RX_OFFLOAD_IPV4_CKSUM |
++ eth_conf.rxmode.offloads = DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM | DEV_RX_OFFLOAD_IPV4_CKSUM |
+ DEV_RX_OFFLOAD_UDP_CKSUM |
+ DEV_RX_OFFLOAD_TCP_CKSUM;
+ }
diff --git a/patches/bess/0010-Add-hardware-rx-checksum-offload-option-for-checksum.patch b/patches/bess/0010-Add-hardware-rx-checksum-offload-option-for-checksum.patch
index 40c0714..c4ae58c 100644
--- a/patches/bess/0010-Add-hardware-rx-checksum-offload-option-for-checksum.patch
+++ b/patches/bess/0010-Add-hardware-rx-checksum-offload-option-for-checksum.patch
@@ -33,8 +33,8 @@ index ecaba24..47f86ba 100644
- EmitPacket(ctx, batch->pkts()[i], (VerifyIpv4Checksum(*ip)) ? FORWARD_GATE : FAIL_GATE);
+ if (hw_) {
+ struct rte_mbuf *m = (struct rte_mbuf *)batch->pkts()[i];
-+ if (unlikely((m->ol_flags & PKT_RX_IP_CKSUM_MASK) ==
-+ PKT_RX_IP_CKSUM_BAD))
++ if (unlikely((m->ol_flags & PKT_RX_EIP_CKSUM_BAD)))
++ //PKT_RX_IP_CKSUM_BAD))
+ EmitPacket(ctx, (bess::Packet *)m, FAIL_GATE);
+ else
+ EmitPacket(ctx, (bess::Packet *)m, FORWARD_GATE);
@@ -89,8 +89,8 @@ index 3ad1f23..20faa85 100644
- (VerifyIpv4UdpChecksum(*ip, *udp)) ? FORWARD_GATE : FAIL_GATE);
+ if (hw_) {
+ struct rte_mbuf *m = (struct rte_mbuf *)batch->pkts()[i];
-+ if (unlikely((m->ol_flags & PKT_RX_L4_CKSUM_MASK) ==
-+ PKT_RX_L4_CKSUM_BAD))
++ if (unlikely((m->ol_flags & PKT_RX_OUTER_L4_CKSUM_MASK) ==
++ PKT_RX_OUTER_L4_CKSUM_BAD))
+ EmitPacket(ctx, (bess::Packet *)m, FAIL_GATE);
+ else
+ EmitPacket(ctx, (bess::Packet *)m, FORWARD_GATE);
@@ -117,8 +117,8 @@ index 3ad1f23..20faa85 100644
+ if (verify_) {
+ if (hw_) {
+ struct rte_mbuf *m = (struct rte_mbuf *)batch->pkts()[i];
-+ if (unlikely((m->ol_flags & PKT_RX_L4_CKSUM_MASK) ==
-+ PKT_RX_L4_CKSUM_BAD))
++ if (unlikely((m->ol_flags & PKT_RX_OUTER_L4_CKSUM_MASK) ==
++ PKT_RX_OUTER_L4_CKSUM_BAD))
+ EmitPacket(ctx, (bess::Packet *)m, FAIL_GATE);
+ else
+ EmitPacket(ctx, (bess::Packet *)m, FORWARD_GATE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment