mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-10 01:23:48 +08:00
lwip: fix broken default ICMPv6 handling of checksums.
ICMPv6 should always have checksum generated for it as per RFC 3542
chapter 3.1.
(cherry picked from commit 5e9df2c698)
This commit is contained in:
committed by
goldsimon
parent
cb97e27120
commit
2694486309
@@ -53,6 +53,7 @@
|
||||
#include "lwip/dns.h"
|
||||
#include "lwip/mld6.h"
|
||||
#include "lwip/priv/tcpip_priv.h"
|
||||
#include "lwip/sockets.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -562,6 +563,13 @@ pcb_new(struct api_msg *msg)
|
||||
case NETCONN_RAW:
|
||||
msg->conn->pcb.raw = raw_new_ip_type(iptype, msg->msg.n.proto);
|
||||
if (msg->conn->pcb.raw != NULL) {
|
||||
#if LWIP_IPV6
|
||||
/* ICMPv6 packets should always have checksum calculated by the stack as per RFC 3542 chapter 3.1 */
|
||||
if (NETCONNTYPE_ISIPV6(msg->conn->type) && msg->conn->pcb.raw->protocol == IPPROTO_ICMPV6) {
|
||||
msg->conn->pcb.raw->chksum_reqd = 1;
|
||||
msg->conn->pcb.raw->chksum_offset = 2;
|
||||
}
|
||||
#endif /* LWIP_IPV6 */
|
||||
raw_recv(msg->conn->pcb.raw, recv_raw, msg->conn);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2574,6 +2574,12 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
|
||||
switch (optname) {
|
||||
#if LWIP_IPV6 && LWIP_RAW
|
||||
case IPV6_CHECKSUM:
|
||||
/* It should not be possible to disable the checksum generation with ICMPv6
|
||||
* as per RFC 3542 chapter 3.1 */
|
||||
if(sock->conn->pcb.raw->protocol == IPPROTO_ICMPV6) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, int, NETCONN_RAW);
|
||||
if (*(const int *)optval < 0) {
|
||||
sock->conn->pcb.raw->chksum_reqd = 0;
|
||||
|
||||
Reference in New Issue
Block a user