aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2017-07-25 11:35:44 -0700
committerDamjan Marion <dmarion.lists@gmail.com>2017-07-26 14:43:15 +0000
commit7c35f191eb3d40facc17c938171f4ff3958649f2 (patch)
tree3441605068878c1b646db10e631320553860d135
parent30af5da7522b38e9d4a4e9c906fd5f1c05088212 (diff)
Fix lisp udp checksum
Change-Id: I16c3f5a97c45e504eec94ce131e854d7da9cd0e3 Signed-off-by: Florin Coras <fcoras@cisco.com>
-rw-r--r--src/vnet/lisp-cp/packets.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/vnet/lisp-cp/packets.c b/src/vnet/lisp-cp/packets.c
index f24024f1500..a3d6f1cdf06 100644
--- a/src/vnet/lisp-cp/packets.c
+++ b/src/vnet/lisp-cp/packets.c
@@ -167,6 +167,8 @@ pkt_push_ip (vlib_main_t * vm, vlib_buffer_t * b, ip_address_t * src,
return 0;
}
+#define UDP_CHECKSUM_OFFLOAD 1
+
void *
pkt_push_udp_and_ip (vlib_main_t * vm, vlib_buffer_t * b, u16 sp, u16 dp,
ip_address_t * sip, ip_address_t * dip)
@@ -179,14 +181,24 @@ pkt_push_udp_and_ip (vlib_main_t * vm, vlib_buffer_t * b, u16 sp, u16 dp,
ih = pkt_push_ip (vm, b, sip, dip, IP_PROTOCOL_UDP);
- udpsum = udp_checksum (uh, clib_net_to_host_u16 (uh->length), ih,
- ip_addr_version (sip));
- if (udpsum == (u16) ~ 0)
+ if (UDP_CHECKSUM_OFFLOAD)
{
- clib_warning ("Failed UDP checksum! Discarding");
- return 0;
+ b->flags |= VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
+ vnet_buffer (b)->l3_hdr_offset = (u8 *) ih - b->data;
+ vnet_buffer (b)->l4_hdr_offset = (u8 *) uh - b->data;
+ uh->checksum = 0;
+ }
+ else
+ {
+ udpsum = udp_checksum (uh, clib_net_to_host_u16 (uh->length), ih,
+ ip_addr_version (sip));
+ if (udpsum == (u16) ~ 0)
+ {
+ clib_warning ("Failed UDP checksum! Discarding");
+ return 0;
+ }
+ uh->checksum = udpsum;
}
- uh->checksum = udpsum;
return ih;
}