{"action":"closed","issue":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/2269","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/2269/labels{/name}","comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/2269/comments","events_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/2269/events","html_url":"https://github.com/RIOT-OS/RIOT/issues/2269","id":53759939,"number":2269,"title":"IPv6: upper layer checksum calculation broken?","user":{"login":"OlegHahm","id":1590423,"avatar_url":"https://avatars.githubusercontent.com/u/1590423?v=3","gravatar_id":"","url":"https://api.github.com/users/OlegHahm","html_url":"https://github.com/OlegHahm","followers_url":"https://api.github.com/users/OlegHahm/followers","following_url":"https://api.github.com/users/OlegHahm/following{/other_user}","gists_url":"https://api.github.com/users/OlegHahm/gists{/gist_id}","starred_url":"https://api.github.com/users/OlegHahm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OlegHahm/subscriptions","organizations_url":"https://api.github.com/users/OlegHahm/orgs","repos_url":"https://api.github.com/users/OlegHahm/repos","events_url":"https://api.github.com/users/OlegHahm/events{/privacy}","received_events_url":"https://api.github.com/users/OlegHahm/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RIOT-OS/RIOT/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/RIOT-OS/RIOT/labels/network","name":"network","color":"bfdadc"},{"url":"https://api.github.com/repos/RIOT-OS/RIOT/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":{"login":"authmillenon","id":675644,"avatar_url":"https://avatars.githubusercontent.com/u/675644?v=3","gravatar_id":"","url":"https://api.github.com/users/authmillenon","html_url":"https://github.com/authmillenon","followers_url":"https://api.github.com/users/authmillenon/followers","following_url":"https://api.github.com/users/authmillenon/following{/other_user}","gists_url":"https://api.github.com/users/authmillenon/gists{/gist_id}","starred_url":"https://api.github.com/users/authmillenon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/authmillenon/subscriptions","organizations_url":"https://api.github.com/users/authmillenon/orgs","repos_url":"https://api.github.com/users/authmillenon/repos","events_url":"https://api.github.com/users/authmillenon/events{/privacy}","received_events_url":"https://api.github.com/users/authmillenon/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/milestones/10","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/milestones/10/labels","id":871004,"number":10,"title":"Release NEXT MAJOR","description":"This is the next major milestone. It gets a valid name if we know the next date to release on.","creator":{"login":"OlegHahm","id":1590423,"avatar_url":"https://avatars.githubusercontent.com/u/1590423?v=3","gravatar_id":"","url":"https://api.github.com/users/OlegHahm","html_url":"https://github.com/OlegHahm","followers_url":"https://api.github.com/users/OlegHahm/followers","following_url":"https://api.github.com/users/OlegHahm/following{/other_user}","gists_url":"https://api.github.com/users/OlegHahm/gists{/gist_id}","starred_url":"https://api.github.com/users/OlegHahm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OlegHahm/subscriptions","organizations_url":"https://api.github.com/users/OlegHahm/orgs","repos_url":"https://api.github.com/users/OlegHahm/repos","events_url":"https://api.github.com/users/OlegHahm/events{/privacy}","received_events_url":"https://api.github.com/users/OlegHahm/received_events","type":"User","site_admin":false},"open_issues":58,"closed_issues":16,"state":"open","created_at":"2014-11-18T10:51:58Z","updated_at":"2015-01-08T15:35:09Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-01-08T15:07:02Z","updated_at":"2015-01-08T15:35:09Z","closed_at":"2015-01-08T15:35:09Z","body":"@haukepetersen just made me aware that according to [RFC 2460, 8.1](https://tools.ietf.org/html/rfc2460#section-8.1) the upper layer checksum is calculated over a pseudo header that contains source  **and** destination address.\r\nHowever, for the calculation in RIOT the source address is used twice while the destination address is completely ignored:\r\n```C\r\nuint16_t ipv6_csum(ipv6_hdr_t *ipv6_header, uint8_t *buf, uint16_t len, uint8_t proto)\r\n{\r\n    uint16_t sum = 0;\r\n    DEBUG(\"Calculate checksum over src: %s, dst: %s, len: %04X, buf: %p, proto: %u\\n\",\r\n               ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, &ipv6_header->srcaddr),\r\n               ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, &ipv6_header->destaddr),\r\n               len, buf, proto);\r\n    sum = len + proto;\r\n    sum = net_help_csum(sum, (uint8_t *) &ipv6_header->srcaddr, 2 * sizeof(ipv6_addr_t));\r\n    sum = net_help_csum(sum, buf, len);\r\n    return (sum == 0) ? 0xffff : HTONS(sum);\r\n}\r\n```\r\n(https://github.com/RIOT-OS/RIOT/blob/master/sys/net/network_layer/sixlowpan/ip.c#L888)\r\n\r\nApparently the thing is done in Contiki (https://github.com/contiki-os/contiki/blob/master/core/net/ipv6/uip6.c#L353), but I couldn't find no hint that anyone ever complained about this problem. That makes me wonder if I am missing something here or if we're a facing a bug in both network stacks that was silently ignored for years. If the latter: shouldn't we have seen errors in Wireshark for every UDP transmission then?"}}