Transmitting ICMP Messages
The two classes of ICMP messages introduced in the section "ICMP Header," errors and queries, are transmitted using two different routines:
-
icmp_send Used by the kernel to transmit ICMP error messages when specific conditions are detected.
-
icmp_reply Used by the ICMP protocol to reply to ingress ICMP request messages that require a response.
Both routines receive an skb buffer in input.
However, the one used as input to icmp_send represents
the ingress IP packet that triggered the transmission of the ICMP message, whereas the one
in input to icmp_reply represents an ingress ICMP
request message that requires a response.
The code in net/core/icmp.c processes incoming
ICMP messages, and therefore always uses icmp_reply to
transmit an ICMP message in response to another one received in input. Other kernel
network subsystems (i.e., routing, IP, etc.) use icmp_send when they need to generate ICMP messages, as shown in Figure 25-8.

Figure 25-8. Subsystems using icmp_send/icmp_reply
In both cases:
ip_route_output_keyis used to find the route to the destination (see Chapter 33).The two routines
ip_append_dataandip_push_pending_framesare used to request a transmission to the IP layer. These routines are described in Chapter 21.ICMP messages generated in kernel space are rate limited (if the kernel has been configured to do it via /proc) with
icmpv4_xrlim_allow(see ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access