net: Verify L4 checksum unconditionally for reassembled packets
In case of reassembled IP packets, we cannot rely on checksum offloading as the drivers/HW has no means to verify L4 checksum before the fragment is reassembled. Therefore, for such packets, verify L4 checksum in the software unconditionally. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
76a256ea57
commit
24abc4307b
|
@ -610,7 +610,8 @@ enum net_verdict net_icmpv4_input(struct net_pkt *pkt,
|
||||||
return NET_DROP;
|
return NET_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_if_need_calc_rx_checksum(net_pkt_iface(pkt))) {
|
if (net_if_need_calc_rx_checksum(net_pkt_iface(pkt)) ||
|
||||||
|
net_pkt_is_ip_reassembled(pkt)) {
|
||||||
if (net_calc_chksum_icmpv4(pkt) != 0U) {
|
if (net_calc_chksum_icmpv4(pkt) != 0U) {
|
||||||
NET_DBG("DROP: Invalid checksum");
|
NET_DBG("DROP: Invalid checksum");
|
||||||
goto drop;
|
goto drop;
|
||||||
|
|
|
@ -342,7 +342,8 @@ enum net_verdict net_icmpv6_input(struct net_pkt *pkt,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (net_if_need_calc_rx_checksum(net_pkt_iface(pkt))) {
|
if (net_if_need_calc_rx_checksum(net_pkt_iface(pkt)) ||
|
||||||
|
net_pkt_is_ip_reassembled(pkt)) {
|
||||||
if (net_calc_chksum_icmpv6(pkt) != 0U) {
|
if (net_calc_chksum_icmpv6(pkt) != 0U) {
|
||||||
NET_DBG("DROP: invalid checksum");
|
NET_DBG("DROP: invalid checksum");
|
||||||
goto drop;
|
goto drop;
|
||||||
|
|
|
@ -3609,7 +3609,8 @@ struct net_tcp_hdr *net_tcp_input(struct net_pkt *pkt,
|
||||||
struct net_tcp_hdr *tcp_hdr;
|
struct net_tcp_hdr *tcp_hdr;
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_NET_TCP_CHECKSUM) &&
|
if (IS_ENABLED(CONFIG_NET_TCP_CHECKSUM) &&
|
||||||
net_if_need_calc_rx_checksum(net_pkt_iface(pkt)) &&
|
(net_if_need_calc_rx_checksum(net_pkt_iface(pkt)) ||
|
||||||
|
net_pkt_is_ip_reassembled(pkt)) &&
|
||||||
net_calc_chksum_tcp(pkt) != 0U) {
|
net_calc_chksum_tcp(pkt) != 0U) {
|
||||||
NET_DBG("DROP: checksum mismatch");
|
NET_DBG("DROP: checksum mismatch");
|
||||||
goto drop;
|
goto drop;
|
||||||
|
|
|
@ -164,7 +164,8 @@ struct net_udp_hdr *net_udp_input(struct net_pkt *pkt,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_NET_UDP_CHECKSUM) &&
|
if (IS_ENABLED(CONFIG_NET_UDP_CHECKSUM) &&
|
||||||
net_if_need_calc_rx_checksum(net_pkt_iface(pkt))) {
|
(net_if_need_calc_rx_checksum(net_pkt_iface(pkt)) ||
|
||||||
|
net_pkt_is_ip_reassembled(pkt))) {
|
||||||
if (!udp_hdr->chksum) {
|
if (!udp_hdr->chksum) {
|
||||||
if (IS_ENABLED(CONFIG_NET_UDP_MISSING_CHECKSUM) &&
|
if (IS_ENABLED(CONFIG_NET_UDP_MISSING_CHECKSUM) &&
|
||||||
net_pkt_family(pkt) == AF_INET) {
|
net_pkt_family(pkt) == AF_INET) {
|
||||||
|
|
Loading…
Reference in a new issue