Skip to content

Conversation

@HedongGao
Copy link
Contributor

Summary

According to section 3.2.2.6 of RFC1122, An ICMP Echo Request destined to an IP broadcast or IP multicast address MAY be silently discarded.

Impact

Check src ip for icmp request message, and drop the request message if src ip is broadcast/multicast.

Testing

Set up a SIM environment, ping the SIM from the host side, and verify that normal ping can reply.
Then, write a Python script to construct a multicast/broadcast ICMP request message with the source IP address, where SIM does not respond.

`
from scapy.all import Ether, IP, ICMP, sendp

SRC_MAC = "fa:b1:d9:6d:a0:d3"
DST_MAC = "42:e1:c4:3f:48:dd"
SRC_IP = "224.0.0.1"
DST_IP = "10.0.1.2"
INTERFACE = "eth0"

def send_custom_icmp():
try:
ether_layer = Ether(src=SRC_MAC, dst=DST_MAC)
ip_layer = IP(src=SRC_IP, dst=DST_IP, ttl=64)
icmp_layer = ICMP(type=8, code=0)
full_packet = ether_layer / ip_layer / icmp_layer

    sendp(full_packet, iface=INTERFACE, verbose=True)
    print("\n✅ ICMP packet sent successfully!")
    print(f"📄 Packet details:")
    print(f"   Source MAC: {SRC_MAC} | Destination MAC: {DST_MAC}")
    print(f"   Source IP: {SRC_IP} (Multicast) | Destination IP: {DST_IP}")

except PermissionError:
    print("❌ Insufficient permissions! Run the script with administrator/root privileges (e.g., sudo python3 xxx.py)")
except Exception as e:
    print(f"❌ Failed to send packet: {str(e)}")
    print("💡 Please check: 1. Correct network interface name 2. Valid MAC/IP format 3. Normal network connection")

if name == "main":
send_custom_icmp()
`

@github-actions github-actions bot added Area: Networking Effects networking subsystem Size: S The size of the change in this PR is small labels Dec 25, 2025
@xiaoxiang781216
Copy link
Contributor

@HedongGao please fix:

Used config files:
    1: .codespellrc
/home/runner/work/nuttx/nuttx/nuttx/net/icmp/icmp_input.c:300: Accordding ==> According
/home/runner/work/nuttx/nuttx/nuttx/net/icmp/icmp_input.c:301: wihch ==> which
Some checks failed. For contributing guidelines, see:

acassis
acassis previously approved these changes Dec 25, 2025
@github-actions github-actions bot added Area: Documentation Improvements or additions to documentation Area: Drivers Drivers issues Area: Memory Management Memory Management issues Area: OS Components OS Components issues Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. labels Dec 26, 2025
@github-actions github-actions bot removed Area: Documentation Improvements or additions to documentation Area: Drivers Drivers issues Area: Memory Management Memory Management issues Area: OS Components OS Components issues labels Dec 26, 2025
@HedongGao
Copy link
Contributor Author

@HedongGao please fix:

Used config files:
    1: .codespellrc
/home/runner/work/nuttx/nuttx/nuttx/net/icmp/icmp_input.c:300: Accordding ==> According
/home/runner/work/nuttx/nuttx/nuttx/net/icmp/icmp_input.c:301: wihch ==> which
Some checks failed. For contributing guidelines, see:

DONE!

@HedongGao HedongGao force-pushed the c430efb branch 2 times, most recently from 1f58317 to a25ea8e Compare December 26, 2025 10:24
Check src ip for icmp request message. Drop the request message if src ip is broadcast/multicast.

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
@xiaoxiang781216 xiaoxiang781216 merged commit e1e6d88 into apache:master Dec 29, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Networking Effects networking subsystem Size: S The size of the change in this PR is small Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants