public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Marco Dalla Torre <marco.dallato@gmail.com>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [B.A.T.M.A.N.] [RFCv2] batctl tcpdump: add IPv6 support to tcpdump parser
Date: Tue, 17 Sep 2013 18:35:02 +0200	[thread overview]
Message-ID: <523884B6.7080708@gmail.com> (raw)
In-Reply-To: <20130917155120.GD3053@neomailbox.net>

Antonio,

On 09/17/13 17:51, Antonio Quartulli wrote:
> On Tue, Sep 17, 2013 at 02:08:14PM +0200, Marco Dalla Torre wrote:
>> +	switch (iphdr->ip6_nxt) {
>> +	case IPPROTO_ICMPV6:
>> +		LEN_CHECK(
>> +			(size_t)buff_len - (size_t)(sizeof(struct ip6_hdr)),
>> +			sizeof(struct icmp6_hdr),
>> +			"ICMPv6");
>> +		icmphdr = (struct icmp6_hdr *)(packet_buff +
>> +					       sizeof(struct ip6_hdr));
>> +		inet_ntop(AF_INET6, &(iphdr->ip6_src), nd_ipv6_addr, 40);
>> +		printf("IPv6 %s > ", nd_ipv6_addr);
>> +		switch (icmphdr->icmp6_type) {
>> +		case ICMP6_DST_UNREACH:
>> +			if ((size_t)(buff_len) < IPV6_MIN_MTU) {
>> +				fprintf(stderr,
>> +					"Warning - dropping received 'ICMPv6 destination unreached' packet as it is bigger than maximum allowed size (%u): %zu\n",
>> +					IPV6_MIN_MTU, (size_t)(buff_len));
>
> Is the message wrong? should it be the other way around? "packet is smaller than
> minimum size" ? And why should _only_ this ICMP packet be bigger of IPV6_MIN_MTU
> ?
>
> Cheers,
>

Ehm, sort of... I believe the error is that the check is the other way 
around. If I remember correctly I included the guard after reading this 
from http://tools.ietf.org/html/rfc4443#section-2.4 :

"Every ICMPv6 error message (type < 128) MUST include as much of
the IPv6 offending (invoking) packet (the packet that caused the
error) as possible without making the error message packet exceed
the minimum IPv6 MTU"

With that in mind, the check should really be:

"((size_t)(buff_len) > IPV6_MIN_MTU"

The message should be ok.
And it should be done for all the error messages.

>>
>>>>> +
>>>>>  #define LEN_CHECK(buff_len, check_len, desc) \
>>>>>  if ((size_t)(buff_len) < (check_len)) { \
>>>>>  	fprintf(stderr, "Warning - dropping received %s packet as it is smaller than expected (%zu): %zu\n", \
>>>>> @@ -188,11 +192,210 @@ static void dump_arp(unsigned char *packet_buff, ssize_t buff_len,
>>>>>  	}
>>>>>  }
>>>>>
>>>>> +static void parse_tcp(
>>> Why don't you call this function dump_tcp like all the other dump_* ?
>>
>> Because, I wasn't aware of this rule. Now I know! :P
>
> They are all over in the same file
>

Yes, but there also was that very one "parse_eth_hdr" that must have 
completely captivated my attention :D
Jokes aside, I'll try to pay more attention to the semantics behind 
prefixes in names. Maybe the problem is that some OO-formed guys like me 
are just not used to have that inside function names... :)


Thanks,
Marco

      reply	other threads:[~2013-09-17 16:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-17 12:08 [B.A.T.M.A.N.] [RFCv2] batctl tcpdump: add IPv6 support to tcpdump parser Marco Dalla Torre
2013-09-17 12:31 ` Antonio Quartulli
2013-09-17 14:01   ` Marco Dalla Torre
2013-09-17 15:38     ` Antonio Quartulli
2013-09-17 15:51 ` Antonio Quartulli
2013-09-17 16:35   ` Marco Dalla Torre [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=523884B6.7080708@gmail.com \
    --to=marco.dallato@gmail.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox