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

Hannes Reinecke hare at suse.de
Mon Apr 27 12:11:25 UTC 2015


On 04/24/2015 06:52 PM, Michael Brown wrote:
> On 01/04/15 08:26, Hannes Reinecke wrote:
>> 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;
>>       }
> 
> This would be a perfect candidate for using EUNIQ() (which would
> avoid the need for the switch() and allow for reporting any number
> of ICMP error types without further increasing the code size).  See
> e.g. the use of EPROTO_STATUS() in crypto/ocsp.c for a reference
> implementation.
> 
Okay, will be doing so.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		               zSeries & Storage
hare at suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)



More information about the ipxe-devel mailing list