# How to disable udp checksum control in kernel

**URL:** <https://linux-tips.com/t/how-to-disable-udp-checksum-control-in-kernel/362>\
**Category:** Programming\
**Created:** [July 8, 2016, 10:01am UTC](https://linux-tips.com/t/how-to-disable-udp-checksum-control-in-kernel/362 "2016-07-08T10:01:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![demirten](https://linux-tips.com/user_avatar/linux-tips.com/demirten/32/64_2.png) [@demirten](https://linux-tips.com/u/demirten)\
**Post date:** [July 8, 2016, 10:01am UTC](https://linux-tips.com/t/how-to-disable-udp-checksum-control-in-kernel/362/1 "2016-07-08T10:01:25Z")

</div>

If you can’t receive udp packets in your udp server application while you’re seeing packets in tcpdump/wireshark session, you should think about UDP checksum control in Linux kernel.

Linux kernel calculates checksum value of all received udp packets and if calculated checksum not equal with the checksum in packet, kernel drops entire packet (according to RFC1122) and adds an entry to kernel log.

You can see kernel udp checksum error logs with `dmesg` command as:

```auto
$ dmesg
...
[1277.642155] UDP: bad checksum. From 172.16.0.4:6467 to 172.16.6.2:1500 ulen 72
[1277.742133] UDP: bad checksum. From 172.16.0.4:6467 to 172.16.6.2:1500 ulen 72
[1277.842167] UDP: bad checksum. From 172.16.0.4:6467 to 172.16.6.2:1500 ulen 72

```

If you have the same problem and you want to disable UDP checksum control only for your udp server application not the kernel in general, you can use `SO_NO_CHECK` socket option to related udp socket fd in your application as below:

```auto
int disable = 1;
if (setsockopt(sock, SOL_SOCKET, SO_NO_CHECK, (void*)&disable, sizeof(disable)) < 0) {
    perror("setsockopt failed");
}

```

> NOTE: It is not possible to disable udp checksum control in **IPv6** packets. This is a big topic and there is a specific RFC6936 document about it: [RFC 6936 - Applicability Statement for the Use of IPv6 UDP Datagrams with Zero Checksums](https://tools.ietf.org/html/rfc6936)

---

<div class="post-metadata">

**Author:** ![Mahmoud\_Bahnasy](https://linux-tips.com/user_avatar/linux-tips.com/mahmoud_bahnasy/32/172_2.png) [@Mahmoud\_Bahnasy](https://linux-tips.com/u/Mahmoud_Bahnasy)\
**Post date:** [July 17, 2019, 8:34pm UTC](https://linux-tips.com/t/how-to-disable-udp-checksum-control-in-kernel/362/2 "2019-07-17T20:34:44Z")

</div>

For Ipv6, there’s UDP-Lite that could be set to verify checksum for a part of the payload, see this page for more details [https://en.wikipedia.org/wiki/UDP-Lite](https://en.wikipedia.org/wiki/UDP-Lite)
