[ipxe-devel] [PATCH 1/7] icmpv6: Decode error codes

Hannes Reinecke hare at suse.de
Wed Apr 1 07:26:15 UTC 2015


ICMPv6 might be sending some error codes, which we should decode
into the correct error numbers.

Signed-off-by: Hannes Reinecke <hare at suse.de>
---
 src/net/icmpv6.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/net/icmpv6.c b/src/net/icmpv6.c
index 45a3444..99e61ee 100644
--- a/src/net/icmpv6.c
+++ b/src/net/icmpv6.c
@@ -148,8 +148,28 @@ static int icmpv6_rx ( struct io_buffer *iobuf, struct net_device *netdev,
 	/* Identify handler */
 	handler = icmpv6_handler ( icmp->type );
 	if ( ! handler ) {
-		DBGC ( netdev, "ICMPv6 unrecognised type %d\n", icmp->type );
-		rc = -ENOTSUP;
+		switch (icmp->type) {
+		case 1:
+			DBGC ( netdev, "ICMPv6 destination unreachable\n" );
+			rc = -ENETUNREACH;
+			break;
+		case 2:
+			DBGC ( netdev, "ICMPv6 packet too big\n" );
+			rc = -EOVERFLOW;
+			break;
+		case 3:
+			DBGC ( netdev, "ICMPv6 timer exceeded\n" );
+			rc = -ETIME;
+			break;
+		case 4:
+			DBGC ( netdev, "ICMPv6 parameter problem\n" );
+			rc = -EINVAL;
+			break;
+		default:
+			DBGC ( netdev, "ICMPv6 unrecognised type %d\n",
+			       icmp->type );
+			rc = -ENOTSUP;
+		}
 		goto done;
 	}
 
-- 
1.8.4.5




More information about the ipxe-devel mailing list