Skip to content
Permalink
Browse files

net/udp: Computed checksum field should not be 0

From RFC 768, in "Fields":
"If the computed  checksum  is zero,  it is transmitted  as all ones"

Fixes #16379

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
  • Loading branch information...
tbursztyka authored and jukkar committed May 24, 2019
1 parent 1091b5b commit 770625826cd899fe923536dd934183a6ec1fe2dd
Showing with 8 additions and 1 deletion.
  1. +7 −0 subsys/net/ip/net_private.h
  2. +1 −1 subsys/net/ip/udp.c
@@ -108,6 +108,13 @@ static inline u16_t net_calc_chksum_icmpv4(struct net_pkt *pkt)
}

static inline u16_t net_calc_chksum_udp(struct net_pkt *pkt)
{
u16_t chksum = net_calc_chksum(pkt, IPPROTO_UDP);

return chksum == 0U ? 0xffff : chksum;
}

static inline u16_t net_calc_verify_chksum_udp(struct net_pkt *pkt)
{
return net_calc_chksum(pkt, IPPROTO_UDP);
}
@@ -150,7 +150,7 @@ struct net_udp_hdr *net_udp_input(struct net_pkt *pkt,

if (IS_ENABLED(CONFIG_NET_UDP_CHECKSUM) &&
net_if_need_calc_rx_checksum(net_pkt_iface(pkt)) &&
net_calc_chksum_udp(pkt) != 0U) {
net_calc_verify_chksum_udp(pkt) != 0U) {
NET_DBG("DROP: checksum mismatch");
goto drop;
}

0 comments on commit 7706258

Please sign in to comment.
You can’t perform that action at this time.