mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-09-28 23:00:50 +00: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:
parent
cb97e27120
commit
2694486309
@ -53,6 +53,7 @@
|
|||||||
#include "lwip/dns.h"
|
#include "lwip/dns.h"
|
||||||
#include "lwip/mld6.h"
|
#include "lwip/mld6.h"
|
||||||
#include "lwip/priv/tcpip_priv.h"
|
#include "lwip/priv/tcpip_priv.h"
|
||||||
|
#include "lwip/sockets.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -562,6 +563,13 @@ pcb_new(struct api_msg *msg)
|
|||||||
case NETCONN_RAW:
|
case NETCONN_RAW:
|
||||||
msg->conn->pcb.raw = raw_new_ip_type(iptype, msg->msg.n.proto);
|
msg->conn->pcb.raw = raw_new_ip_type(iptype, msg->msg.n.proto);
|
||||||
if (msg->conn->pcb.raw != NULL) {
|
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);
|
raw_recv(msg->conn->pcb.raw, recv_raw, msg->conn);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2574,6 +2574,12 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
|
|||||||
switch (optname) {
|
switch (optname) {
|
||||||
#if LWIP_IPV6 && LWIP_RAW
|
#if LWIP_IPV6 && LWIP_RAW
|
||||||
case IPV6_CHECKSUM:
|
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);
|
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, int, NETCONN_RAW);
|
||||||
if (*(const int *)optval < 0) {
|
if (*(const int *)optval < 0) {
|
||||||
sock->conn->pcb.raw->chksum_reqd = 0;
|
sock->conn->pcb.raw->chksum_reqd = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user