mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-02 12:52:10 +00:00
patch #8027: Completed HW checksuming for IPv4 and IPv6 ICMP's
This commit is contained in:
parent
8ae472821f
commit
018719d9d3
@ -6,6 +6,10 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2014-01-17: Jiri Engelthaler
|
||||||
|
* icmp, icmp6, opt.h: patch #8027: Completed HW checksuming for IPv4 and
|
||||||
|
IPv6 ICMP's
|
||||||
|
|
||||||
2012-03-25: Simon Goldschmidt (idea by Mason)
|
2012-03-25: Simon Goldschmidt (idea by Mason)
|
||||||
* posix/*: added posix-compatibility include files posix/netdb.h and posix/sys/socket.h
|
* posix/*: added posix-compatibility include files posix/netdb.h and posix/sys/socket.h
|
||||||
which are a simple wrapper to the correct lwIP include files.
|
which are a simple wrapper to the correct lwIP include files.
|
||||||
|
@ -133,6 +133,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
|||||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
|
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
|
||||||
goto lenerr;
|
goto lenerr;
|
||||||
}
|
}
|
||||||
|
#if CHECKSUM_CHECK_ICMP
|
||||||
if (inet_chksum_pbuf(p) != 0) {
|
if (inet_chksum_pbuf(p) != 0) {
|
||||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n"));
|
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n"));
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
@ -140,6 +141,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
|||||||
snmp_inc_icmpinerrors();
|
snmp_inc_icmpinerrors();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN
|
#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN
|
||||||
if (pbuf_header(p, (PBUF_IP_HLEN + PBUF_LINK_HLEN))) {
|
if (pbuf_header(p, (PBUF_IP_HLEN + PBUF_LINK_HLEN))) {
|
||||||
/* p is not big enough to contain link headers
|
/* p is not big enough to contain link headers
|
||||||
@ -324,7 +326,9 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
|
|||||||
|
|
||||||
/* calculate checksum */
|
/* calculate checksum */
|
||||||
icmphdr->chksum = 0;
|
icmphdr->chksum = 0;
|
||||||
|
#if CHECKSUM_GEN_ICMP
|
||||||
icmphdr->chksum = inet_chksum(icmphdr, q->len);
|
icmphdr->chksum = inet_chksum(icmphdr, q->len);
|
||||||
|
#endif
|
||||||
ICMP_STATS_INC(icmp.xmit);
|
ICMP_STATS_INC(icmp.xmit);
|
||||||
/* increase number of messages attempted to send */
|
/* increase number of messages attempted to send */
|
||||||
snmp_inc_icmpoutmsgs();
|
snmp_inc_icmpoutmsgs();
|
||||||
|
@ -578,7 +578,9 @@ ip_reass(struct pbuf *p)
|
|||||||
IPH_OFFSET_SET(fraghdr, 0);
|
IPH_OFFSET_SET(fraghdr, 0);
|
||||||
IPH_CHKSUM_SET(fraghdr, 0);
|
IPH_CHKSUM_SET(fraghdr, 0);
|
||||||
/* @todo: do we need to set calculate the correct checksum? */
|
/* @todo: do we need to set calculate the correct checksum? */
|
||||||
|
#if CHECKSUM_GEN_IP
|
||||||
IPH_CHKSUM_SET(fraghdr, inet_chksum(fraghdr, IP_HLEN));
|
IPH_CHKSUM_SET(fraghdr, inet_chksum(fraghdr, IP_HLEN));
|
||||||
|
#endif /* CHECKSUM_GEN_IP */
|
||||||
|
|
||||||
p = ipr->p;
|
p = ipr->p;
|
||||||
|
|
||||||
@ -818,7 +820,9 @@ ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest)
|
|||||||
IPH_OFFSET_SET(iphdr, htons(tmp));
|
IPH_OFFSET_SET(iphdr, htons(tmp));
|
||||||
IPH_LEN_SET(iphdr, htons(cop + IP_HLEN));
|
IPH_LEN_SET(iphdr, htons(cop + IP_HLEN));
|
||||||
IPH_CHKSUM_SET(iphdr, 0);
|
IPH_CHKSUM_SET(iphdr, 0);
|
||||||
|
#if CHECKSUM_GEN_IP
|
||||||
IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN));
|
IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN));
|
||||||
|
#endif /* CHECKSUM_GEN_IP */
|
||||||
|
|
||||||
#if IP_FRAG_USES_STATIC_BUF
|
#if IP_FRAG_USES_STATIC_BUF
|
||||||
if (last) {
|
if (last) {
|
||||||
|
@ -96,7 +96,7 @@ icmp6_input(struct pbuf *p, struct netif *inp)
|
|||||||
|
|
||||||
icmp6hdr = (struct icmp6_hdr *)p->payload;
|
icmp6hdr = (struct icmp6_hdr *)p->payload;
|
||||||
|
|
||||||
#if LWIP_ICMP6_CHECKSUM_CHECK
|
#if CHECKSUM_CHECK_ICMP6
|
||||||
if (ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->tot_len, ip6_current_src_addr(),
|
if (ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->tot_len, ip6_current_src_addr(),
|
||||||
ip6_current_dest_addr()) != 0) {
|
ip6_current_dest_addr()) != 0) {
|
||||||
/* Checksum failed */
|
/* Checksum failed */
|
||||||
@ -105,7 +105,7 @@ icmp6_input(struct pbuf *p, struct netif *inp)
|
|||||||
ICMP6_STATS_INC(icmp6.drop);
|
ICMP6_STATS_INC(icmp6.drop);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif /* LWIP_ICMP6_CHECKSUM_CHECK */
|
#endif /* CHECKSUM_CHECK_ICMP6 */
|
||||||
|
|
||||||
switch (icmp6hdr->type) {
|
switch (icmp6hdr->type) {
|
||||||
case ICMP6_TYPE_NA: /* Neighbor advertisement */
|
case ICMP6_TYPE_NA: /* Neighbor advertisement */
|
||||||
@ -179,8 +179,10 @@ icmp6_input(struct pbuf *p, struct netif *inp)
|
|||||||
/* Set fields in reply. */
|
/* Set fields in reply. */
|
||||||
((struct icmp6_echo_hdr *)(r->payload))->type = ICMP6_TYPE_EREP;
|
((struct icmp6_echo_hdr *)(r->payload))->type = ICMP6_TYPE_EREP;
|
||||||
((struct icmp6_echo_hdr *)(r->payload))->chksum = 0;
|
((struct icmp6_echo_hdr *)(r->payload))->chksum = 0;
|
||||||
|
#if CHECKSUM_GEN_ICMP6
|
||||||
((struct icmp6_echo_hdr *)(r->payload))->chksum = ip6_chksum_pseudo(r,
|
((struct icmp6_echo_hdr *)(r->payload))->chksum = ip6_chksum_pseudo(r,
|
||||||
IP6_NEXTH_ICMP6, r->tot_len, reply_src, ip6_current_src_addr());
|
IP6_NEXTH_ICMP6, r->tot_len, reply_src, ip6_current_src_addr());
|
||||||
|
#endif /* CHECKSUM_GEN_ICMP6 */
|
||||||
|
|
||||||
/* Send reply. */
|
/* Send reply. */
|
||||||
ICMP6_STATS_INC(icmp6.xmit);
|
ICMP6_STATS_INC(icmp6.xmit);
|
||||||
@ -327,8 +329,10 @@ icmp6_send_response(struct pbuf *p, u8_t code, u32_t data, u8_t type)
|
|||||||
|
|
||||||
/* calculate checksum */
|
/* calculate checksum */
|
||||||
icmp6hdr->chksum = 0;
|
icmp6hdr->chksum = 0;
|
||||||
|
#if CHECKSUM_GEN_ICMP6
|
||||||
icmp6hdr->chksum = ip6_chksum_pseudo(q, IP6_NEXTH_ICMP6, q->tot_len,
|
icmp6hdr->chksum = ip6_chksum_pseudo(q, IP6_NEXTH_ICMP6, q->tot_len,
|
||||||
reply_src, reply_dest);
|
reply_src, reply_dest);
|
||||||
|
#endif /* CHECKSUM_GEN_ICMP6 */
|
||||||
|
|
||||||
ICMP6_STATS_INC(icmp6.xmit);
|
ICMP6_STATS_INC(icmp6.xmit);
|
||||||
ip6_output_if(q, reply_src, reply_dest, LWIP_ICMP6_HL, 0, IP6_NEXTH_ICMP6, netif);
|
ip6_output_if(q, reply_src, reply_dest, LWIP_ICMP6_HL, 0, IP6_NEXTH_ICMP6, netif);
|
||||||
|
@ -563,8 +563,10 @@ mld6_send(struct mld_group *group, u8_t type)
|
|||||||
mld_hdr->reserved = 0;
|
mld_hdr->reserved = 0;
|
||||||
ip6_addr_set(&(mld_hdr->multicast_address), &(group->group_address));
|
ip6_addr_set(&(mld_hdr->multicast_address), &(group->group_address));
|
||||||
|
|
||||||
|
#if CHECKSUM_GEN_ICMP6
|
||||||
mld_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len,
|
mld_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len,
|
||||||
src_addr, &(group->group_address));
|
src_addr, &(group->group_address));
|
||||||
|
#endif /* CHECKSUM_GEN_ICMP6 */
|
||||||
|
|
||||||
/* Add hop-by-hop headers options: router alert with MLD value. */
|
/* Add hop-by-hop headers options: router alert with MLD value. */
|
||||||
ip6_options_add_hbh_ra(p, IP6_NEXTH_ICMP6, IP6_ROUTER_ALERT_VALUE_MLD);
|
ip6_options_add_hbh_ra(p, IP6_NEXTH_ICMP6, IP6_ROUTER_ALERT_VALUE_MLD);
|
||||||
|
@ -838,8 +838,10 @@ nd6_send_ns(struct netif * netif, ip6_addr_t * target_addr, u8_t flags)
|
|||||||
target_addr = &multicast_address;
|
target_addr = &multicast_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CHECKSUM_GEN_ICMP6
|
||||||
ns_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr,
|
ns_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr,
|
||||||
target_addr);
|
target_addr);
|
||||||
|
#endif /* CHECKSUM_GEN_ICMP6 */
|
||||||
|
|
||||||
/* Send the packet out. */
|
/* Send the packet out. */
|
||||||
ND6_STATS_INC(nd6.xmit);
|
ND6_STATS_INC(nd6.xmit);
|
||||||
@ -910,8 +912,10 @@ nd6_send_na(struct netif * netif, ip6_addr_t * target_addr, u8_t flags)
|
|||||||
dest_addr = ip6_current_src_addr();
|
dest_addr = ip6_current_src_addr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CHECKSUM_GEN_ICMP6
|
||||||
na_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr,
|
na_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr,
|
||||||
dest_addr);
|
dest_addr);
|
||||||
|
#endif /* CHECKSUM_GEN_ICMP6 */
|
||||||
|
|
||||||
/* Send the packet out. */
|
/* Send the packet out. */
|
||||||
ND6_STATS_INC(nd6.xmit);
|
ND6_STATS_INC(nd6.xmit);
|
||||||
@ -977,8 +981,10 @@ nd6_send_rs(struct netif * netif)
|
|||||||
SMEMCPY(lladdr_opt->addr, netif->hwaddr, netif->hwaddr_len);
|
SMEMCPY(lladdr_opt->addr, netif->hwaddr, netif->hwaddr_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CHECKSUM_GEN_ICMP6
|
||||||
rs_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr,
|
rs_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr,
|
||||||
&multicast_address);
|
&multicast_address);
|
||||||
|
#endif /* CHECKSUM_GEN_ICMP6 */
|
||||||
|
|
||||||
/* Send the packet out. */
|
/* Send the packet out. */
|
||||||
ND6_STATS_INC(nd6.xmit);
|
ND6_STATS_INC(nd6.xmit);
|
||||||
|
@ -1864,6 +1864,13 @@
|
|||||||
#define CHECKSUM_GEN_ICMP 1
|
#define CHECKSUM_GEN_ICMP 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CHECKSUM_GEN_ICMP6==1: Generate checksums in software for outgoing ICMP6 packets.
|
||||||
|
*/
|
||||||
|
#ifndef CHECKSUM_GEN_ICMP6
|
||||||
|
#define CHECKSUM_GEN_ICMP6 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.
|
* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.
|
||||||
*/
|
*/
|
||||||
@ -1885,6 +1892,20 @@
|
|||||||
#define CHECKSUM_CHECK_TCP 1
|
#define CHECKSUM_CHECK_TCP 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CHECKSUM_CHECK_ICMP==1: Check checksums in software for incoming ICMP packets.
|
||||||
|
*/
|
||||||
|
#ifndef CHECKSUM_CHECK_ICMP
|
||||||
|
#define CHECKSUM_CHECK_ICMP 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CHECKSUM_CHECK_ICMP6==1: Check checksums in software for incoming ICMPv6 packets
|
||||||
|
*/
|
||||||
|
#ifndef CHECKSUM_CHECK_ICMP6
|
||||||
|
#define CHECKSUM_CHECK_ICMP6 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LWIP_CHECKSUM_ON_COPY==1: Calculate checksum when copying data from
|
* LWIP_CHECKSUM_ON_COPY==1: Calculate checksum when copying data from
|
||||||
* application buffers to pbufs.
|
* application buffers to pbufs.
|
||||||
@ -1941,13 +1962,6 @@
|
|||||||
#define LWIP_ICMP6_HL 255
|
#define LWIP_ICMP6_HL 255
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* LWIP_ICMP6_CHECKSUM_CHECK==1: verify checksum on ICMPv6 packets
|
|
||||||
*/
|
|
||||||
#ifndef LWIP_ICMP6_CHECKSUM_CHECK
|
|
||||||
#define LWIP_ICMP6_CHECKSUM_CHECK 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LWIP_IPV6_MLD==1: Enable multicast listener discovery protocol.
|
* LWIP_IPV6_MLD==1: Enable multicast listener discovery protocol.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user