Re: netfilter: ipt_LOG/ip6t_LOG: add option to print decoded MAC header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux