Message ID | 20210618110436.91700-1-toke@redhat.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 321827477360934dc040e9d3c626bf1de6c3ab3c |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net,v2,1/2] icmp: don't send out ICMP messages with a source address of 0.0.0.0 | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 5 of 5 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 5591 this patch: 5591 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | CHECK: No space is necessary after a cast WARNING: Prefer 'unsigned long' over 'unsigned long int' as the int is unnecessary WARNING: Unnecessary typecast of c90 int constant - '(unsigned long int) 0xc0000008' could be '0xc0000008UL' |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 5656 this patch: 5656 |
netdev/header_inline | success | Link |
Hello: This series was applied to netdev/net.git (refs/heads/master): On Fri, 18 Jun 2021 13:04:35 +0200 you wrote: > When constructing ICMP response messages, the kernel will try to pick a > suitable source address for the outgoing packet. However, if no IPv4 > addresses are configured on the system at all, this will fail and we end up > producing an ICMP message with a source address of 0.0.0.0. This can happen > on a box routing IPv4 traffic via v6 nexthops, for instance. > > Since 0.0.0.0 is not generally routable on the internet, there's a good > chance that such ICMP messages will never make it back to the sender of the > original packet that the ICMP message was sent in response to. This, in > turn, can create connectivity and PMTUd problems for senders. Fortunately, > RFC7600 reserves a dummy address to be used as a source for ICMP > messages (192.0.0.8/32), so let's teach the kernel to substitute that > address as a last resort if the regular source address selection procedure > fails. > > [...] Here is the summary with links: - [net,v2,1/2] icmp: don't send out ICMP messages with a source address of 0.0.0.0 https://git.kernel.org/netdev/net/c/321827477360 - [net,v2,2/2] selftests/net: Add icmp.sh for testing ICMP dummy address responses https://git.kernel.org/netdev/net/c/7e9838b7915e You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h index 7d6687618d80..d1b327036ae4 100644 --- a/include/uapi/linux/in.h +++ b/include/uapi/linux/in.h @@ -289,6 +289,9 @@ struct sockaddr_in { /* Address indicating an error return. */ #define INADDR_NONE ((unsigned long int) 0xffffffff) +/* Dummy address for src of ICMP replies if no real address is set (RFC7600). */ +#define INADDR_DUMMY ((unsigned long int) 0xc0000008) + /* Network number for local host loopback. */ #define IN_LOOPBACKNET 127 diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 7b6931a4d775..752e392083e6 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -759,6 +759,13 @@ void __icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info, icmp_param.data_len = room; icmp_param.head_len = sizeof(struct icmphdr); + /* if we don't have a source address at this point, fall back to the + * dummy address instead of sending out a packet with a source address + * of 0.0.0.0 + */ + if (!fl4.saddr) + fl4.saddr = htonl(INADDR_DUMMY); + icmp_push_reply(&icmp_param, &fl4, &ipc, &rt); ende: ip_rt_put(rt);