net: icmp: skip checksum calculation when possible
Skip IP header checksum calculation when the network interface reports support for this feature. Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
parent
d29e34c7c9
commit
0a3bf289b6
|
@ -65,7 +65,10 @@ int net_icmpv4_finalize(struct net_pkt *pkt)
|
|||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
icmp_hdr->chksum = net_calc_chksum_icmpv4(pkt);
|
||||
icmp_hdr->chksum = 0U;
|
||||
if (net_if_need_calc_tx_checksum(net_pkt_iface(pkt))) {
|
||||
icmp_hdr->chksum = net_calc_chksum_icmpv4(pkt);
|
||||
}
|
||||
|
||||
return net_pkt_set_data(pkt, &icmpv4_access);
|
||||
}
|
||||
|
@ -688,9 +691,11 @@ enum net_verdict net_icmpv4_input(struct net_pkt *pkt,
|
|||
return NET_DROP;
|
||||
}
|
||||
|
||||
if (net_calc_chksum_icmpv4(pkt) != 0U) {
|
||||
NET_DBG("DROP: Invalid checksum");
|
||||
goto drop;
|
||||
if (net_if_need_calc_rx_checksum(net_pkt_iface(pkt))) {
|
||||
if (net_calc_chksum_icmpv4(pkt) != 0U) {
|
||||
NET_DBG("DROP: Invalid checksum");
|
||||
goto drop;
|
||||
}
|
||||
}
|
||||
|
||||
if (net_ipv4_is_addr_bcast(net_pkt_iface(pkt),
|
||||
|
|
|
@ -79,7 +79,10 @@ int net_icmpv6_finalize(struct net_pkt *pkt)
|
|||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
icmp_hdr->chksum = net_calc_chksum_icmpv6(pkt);
|
||||
icmp_hdr->chksum = 0U;
|
||||
if (net_if_need_calc_rx_checksum(net_pkt_iface(pkt))) {
|
||||
icmp_hdr->chksum = net_calc_chksum_icmpv6(pkt);
|
||||
}
|
||||
|
||||
return net_pkt_set_data(pkt, &icmp_access);
|
||||
}
|
||||
|
@ -409,9 +412,12 @@ enum net_verdict net_icmpv6_input(struct net_pkt *pkt,
|
|||
return NET_DROP;
|
||||
}
|
||||
|
||||
if (net_calc_chksum_icmpv6(pkt) != 0U) {
|
||||
NET_DBG("DROP: invalid checksum");
|
||||
goto drop;
|
||||
|
||||
if (net_if_need_calc_rx_checksum(net_pkt_iface(pkt))) {
|
||||
if (net_calc_chksum_icmpv6(pkt) != 0U) {
|
||||
NET_DBG("DROP: invalid checksum");
|
||||
goto drop;
|
||||
}
|
||||
}
|
||||
|
||||
net_pkt_acknowledge_data(pkt, &icmp_access);
|
||||
|
|
Loading…
Reference in a new issue