All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pkttype match mismatches on locally generated packets
@ 2006-07-18  1:06 Phil Oester
  2006-07-18  1:08 ` Phil Oester
  2006-07-20 16:20 ` Patrick McHardy
  0 siblings, 2 replies; 3+ messages in thread
From: Phil Oester @ 2006-07-18  1:06 UTC (permalink / raw)
  To: netfilter-devel

Locally generated broadcast and multicast packets have pkttype set to
PACKET_LOOPBACK instead of PACKET_BROADCAST or PACKET_MULTICAST.  This
causes the pkttype match to fail to match packets of either type.

The below patch remedies this by using the daddr as a hint as to
broadcast|multicast.  While not pretty, this seems like the only way
to solve the problem short of just noting this as a limitation of the match.

This resolves bug #484

Phil

Signed-off-by: Phil Oester <kernel@linuxace.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pkttype match mismatches on locally generated packets
  2006-07-18  1:06 [PATCH] pkttype match mismatches on locally generated packets Phil Oester
@ 2006-07-18  1:08 ` Phil Oester
  2006-07-20 16:20 ` Patrick McHardy
  1 sibling, 0 replies; 3+ messages in thread
From: Phil Oester @ 2006-07-18  1:08 UTC (permalink / raw)
  To: netfilter-devel

[-- Attachment #1: Type: text/plain, Size: 632 bytes --]

On Mon, Jul 17, 2006 at 06:06:42PM -0700, Phil Oester wrote:
> Locally generated broadcast and multicast packets have pkttype set to
> PACKET_LOOPBACK instead of PACKET_BROADCAST or PACKET_MULTICAST.  This
> causes the pkttype match to fail to match packets of either type.
> 
> The below patch remedies this by using the daddr as a hint as to
> broadcast|multicast.  While not pretty, this seems like the only way
> to solve the problem short of just noting this as a limitation of the match.
> 
> This resolves bug #484
> 
> Phil
> 
> Signed-off-by: Phil Oester <kernel@linuxace.com>

And this time the patch is attached...

Phil

[-- Attachment #2: patch-pkttype --]
[-- Type: text/plain, Size: 844 bytes --]

--- linux-dellfw/net/netfilter/xt_pkttype.c	2006-06-17 21:49:35.000000000 -0400
+++ linux-po/net/netfilter/xt_pkttype.c	2006-07-17 20:56:39.000000000 -0400
@@ -9,6 +9,8 @@
 #include <linux/skbuff.h>
 #include <linux/if_ether.h>
 #include <linux/if_packet.h>
+#include <linux/in.h>
+#include <linux/ip.h>
 
 #include <linux/netfilter/xt_pkttype.h>
 #include <linux/netfilter/x_tables.h>
@@ -28,9 +30,17 @@
       unsigned int protoff,
       int *hotdrop)
 {
+	u_int8_t type;
 	const struct xt_pkttype_info *info = matchinfo;
 
-	return (skb->pkt_type == info->pkttype) ^ info->invert;
+	if (skb->pkt_type == PACKET_LOOPBACK)
+		type = (MULTICAST(skb->nh.iph->daddr)
+			? PACKET_MULTICAST
+			: PACKET_BROADCAST);
+	else
+		type = skb->pkt_type;
+
+	return (type == info->pkttype) ^ info->invert;
 }
 
 static struct xt_match pkttype_match = {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pkttype match mismatches on locally generated packets
  2006-07-18  1:06 [PATCH] pkttype match mismatches on locally generated packets Phil Oester
  2006-07-18  1:08 ` Phil Oester
@ 2006-07-20 16:20 ` Patrick McHardy
  1 sibling, 0 replies; 3+ messages in thread
From: Patrick McHardy @ 2006-07-20 16:20 UTC (permalink / raw)
  To: Phil Oester; +Cc: netfilter-devel

Phil Oester wrote:
> Locally generated broadcast and multicast packets have pkttype set to
> PACKET_LOOPBACK instead of PACKET_BROADCAST or PACKET_MULTICAST.  This
> causes the pkttype match to fail to match packets of either type.
> 
> The below patch remedies this by using the daddr as a hint as to
> broadcast|multicast.  While not pretty, this seems like the only way
> to solve the problem short of just noting this as a limitation of the match.
> 
> This resolves bug #484

Thanks Phil. I thought about just adding PACKET_LOOPBACK support to
userspace, but this way seems better, so applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-07-20 16:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-18  1:06 [PATCH] pkttype match mismatches on locally generated packets Phil Oester
2006-07-18  1:08 ` Phil Oester
2006-07-20 16:20 ` Patrick McHardy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.