From: Patrick McHardy <kaber@trash.net>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: Netfilter Developer Mailing List <netfilter-devel@vger.kernel.org>
Subject: Re: netfilter: ipt_LOG/ip6t_LOG: add option to print decoded MAC header
Date: Wed, 23 Jun 2010 19:03:29 +0200 [thread overview]
Message-ID: <4C223E61.2030804@trash.net> (raw)
In-Reply-To: <alpine.LSU.2.01.1006231840180.21618@obet.zrqbmnf.qr>
Jan Engelhardt wrote:
> On Wednesday 2010-06-23 18:11, Patrick McHardy wrote:
>
>
>> + switch (dev->type) {
>> + case ARPHRD_ETHER:
>> + printk("MACSRC=%pM MACDST=%pM MACPROTO=%.4x ",
>> + eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest,
>> + ntohs(eth_hdr(skb)->h_proto));
>>
>
> Why not just the standard %04x? [Same applies to v6]
>
I guess that would be more consistent with the existing printks.
>> + printk("MAC=");
>> + if (dev->hard_header_len &&
>> + skb->mac_header != skb->network_header) {
>> + const unsigned char *p = skb_mac_header(skb);
>> + unsigned int i;
>> +
>> + for (i = 0; i < dev->hard_header_len; i++, p++)
>> + printk("%02x%c", *p,
>> + i == dev->hard_header_len - 1 ? ' ' : ':');
>>
>
> if (dev->hard_header_len > 0)
> printk("%02x", *p++);
> for (i = 1; i < dev->hard_header_len; ++i)
> printk(":%02x", *p++);
>
> I like better for getting rid of the comparison inside the loop.
>
Looks fine, I'll change that in a seperate patch.
>> + /* MAC logging for input chain only. */
>>
>
> "input path".
>
Correct.
>> + if (in && !out)
>> + dump_mac_header(loginfo, skb);
>>
>> dump_packet(loginfo, skb, 0);
>>
>
> # ipv6
>
>> printk("\n");
>> + if (dev->hard_header_len &&
>> + skb->mac_header != skb->network_header) {
>> + const unsigned char *p = skb_mac_header(skb);
>> + unsigned int len = dev->hard_header_len;
>> + unsigned int i;
>> +
>> + if (dev->type == ARPHRD_SIT &&
>> + (p -= ETH_HLEN) < skb->head)
>> + p = NULL;
>>
>
> What is the purpose of this? If the device is a sit, there is no
> guarantee that there's any ethernet header in the skb.
>
Correct, that's what the test is determining. This is all existing
code that has just been moved around.
prev parent reply other threads:[~2010-06-23 17:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-23 16:11 netfilter: ipt_LOG/ip6t_LOG: add option to print decoded MAC header Patrick McHardy
2010-06-23 16:47 ` Jan Engelhardt
2010-06-23 17:03 ` Patrick McHardy [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=4C223E61.2030804@trash.net \
--to=kaber@trash.net \
--cc=jengelh@medozas.de \
--cc=netfilter-devel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).