aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/wireguard/wireguard_send.c
diff options
context:
space:
mode:
authorArtem Glazychev <artem.glazychev@xored.com>2022-10-25 18:48:40 +0700
committerFan Zhang <fanzhang.oss@gmail.com>2022-11-29 14:15:00 +0000
commitb9e391e7b08ed8f6f32401eae5d6525aab904737 (patch)
tree627fb55cfa24d47a0a643813d43f5977172d8831 /src/plugins/wireguard/wireguard_send.c
parent3f885f97f0bb812296cb549acd3c4b8fc17de0c9 (diff)
wireguard: compute checksum for outer ipv6 header
Type: fix Signed-off-by: Artem Glazychev <artem.glazychev@xored.com> Change-Id: I477e92712e441c91789afdf9be389d967acfa799
Diffstat (limited to 'src/plugins/wireguard/wireguard_send.c')
-rw-r--r--src/plugins/wireguard/wireguard_send.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/plugins/wireguard/wireguard_send.c b/src/plugins/wireguard/wireguard_send.c
index adfa5cac3de..72fa11034bf 100644
--- a/src/plugins/wireguard/wireguard_send.c
+++ b/src/plugins/wireguard/wireguard_send.c
@@ -41,7 +41,8 @@ ip46_enqueue_packet (vlib_main_t *vm, u32 bi0, int is_ip4)
}
static void
-wg_buffer_prepend_rewrite (vlib_buffer_t *b0, const u8 *rewrite, u8 is_ip4)
+wg_buffer_prepend_rewrite (vlib_main_t *vm, vlib_buffer_t *b0,
+ const u8 *rewrite, u8 is_ip4)
{
if (is_ip4)
{
@@ -72,6 +73,13 @@ wg_buffer_prepend_rewrite (vlib_buffer_t *b0, const u8 *rewrite, u8 is_ip4)
hdr6->ip6.payload_length = hdr6->udp.length =
clib_host_to_net_u16 (b0->current_length - sizeof (ip6_header_t));
+
+ /* IPv6 UDP checksum is mandatory */
+ int bogus = 0;
+ ip6_header_t *ip6_0 = &(hdr6->ip6);
+ hdr6->udp.checksum =
+ ip6_tcp_udp_icmp_compute_checksum (vm, b0, ip6_0, &bogus);
+ ASSERT (bogus == 0);
}
}
@@ -93,7 +101,7 @@ wg_create_buffer (vlib_main_t *vm, const u8 *rewrite, const u8 *packet,
b0->current_length = packet_len;
- wg_buffer_prepend_rewrite (b0, rewrite, is_ip4);
+ wg_buffer_prepend_rewrite (vm, b0, rewrite, is_ip4);
return true;
}