Saturday, October 24, 2009

Section 25.10.  Passing Error Notifications to the Transport Layer










25.10. Passing Error Notifications to the Transport Layer










We saw in the section "L4 Protocol Registration" in Chapter 24 that when transport protocols register with the kernel, they provide an instance of an inet_protocol data structure. It includes one function pointer, err_handler, which is called by the ICMP protocol to propagate to the transport layer error notifications received with ingress ICMP messages. RFCs 1122 and 1256 specify, for hosts and routers, respectively, whether each ICMP message type should be propagated to the transport layer. All the error message types that require a notification to be sent to the transport layer are processed by icmp_unreach. At the end of that function, the transport layer is notified with err_handler.


When the transport layer processes the notification, it uses the icmp_err_convert array defined in net/ipv4/icmp.c to convert the ICMP_DEST_UNREACH code into an error code that is better understood by the socket layer (see udp_err in net/ipv4/udp.c for an example). The transport layer passes that error code to the socket associated with the error (which is identified thanks to the ICMP payload, as described in the section "ICMP Payload"). Raw IP sockets are notified as well, by means of raw_err. Table 25-10 shows the conversion that is applied by icmp_err_convert. Note that the err_handler routines registered by tunneling protocols such as IPIP and GRE may generate new ICMP messages (see ipip_err in net/ipv4/ipip.c for an example).


Table 25-10. Initialization of icmp_err_convert

Code

Kernel symbol

errno

Fatal (0=No, 1=Yes)

0

ICMP_NET_UNREACH

ENETUNREACH

0

1

ICMP_HOST_UNREACH

EHOSTUNREACH

0

2

ICMP_PROT_UNREACH

ENOPROTOOPT

1

3

ICMP_PORT_UNREACH

ECONNREFUSED

1

4

ICMP_FRAG_NEEDED

EMSGSIZE

0

5

ICMP_SR_FAILED

EOPNOTSUPP

0

6

ICMP_NET_UNKNOWN

ENETUNREACH

1

7

ICMP_HOST_UNKNOWN

EHOSTDOWN

1

8

ICMP_HOST_ISOLATED

ENONET

1

9

ICMP_NET_ANO

ENETUNREACH

1

10

ICMP_HOST_ANO

EHOSTUNREACH

1

11

ICMP_NET_UNR_TOS

ENETUNREACH

0

12

ICMP_HOST_UNR_TOS

EHOSTUNREACH

0

13

ICMP_PKT_FILTERED

EHOSTUNREACH

1

14

ICMP_PREC_VIOLATION

EHOSTUNREACH

1

15

ICMP_PREC_CUTOFF

EHOSTUNREACH

1













No comments:

Post a Comment