All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: davem@davemloft.net
Cc: netfilter-devel@lists.netfilter.org, Patrick McHardy <kaber@trash.net>
Subject: [NETFILTER 04/06]: xt_pkttype: fix mismatches on locally generated packets
Date: Tue, 25 Jul 2006 05:26:59 +0200 (MEST)	[thread overview]
Message-ID: <20060725032658.25063.92778.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20060725032653.25063.8139.sendpatchset@localhost.localdomain>

[NETFILTER]: xt_pkttype: fix mismatches on locally generated packets

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 netfilter bugzilla #484

Signed-off-by: Phil Oester <kernel@linuxace.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 9a713120692b6601fa2abf506862bc40c16459ba
tree 3dbfa7b16367fbe36adcd374b8f62dfde89769fa
parent 91ce3a69f0154c527da6e4a47c8784383981a222
author Phil Oester <kernel@linuxace.com> Tue, 25 Jul 2006 00:05:39 +0200
committer Patrick McHardy <kaber@trash.net> Tue, 25 Jul 2006 00:05:39 +0200

 net/netfilter/xt_pkttype.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/net/netfilter/xt_pkttype.c b/net/netfilter/xt_pkttype.c
index 3ac703b..d2f5320 100644
--- a/net/netfilter/xt_pkttype.c
+++ b/net/netfilter/xt_pkttype.c
@@ -9,6 +9,8 @@ #include <linux/module.h>
 #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 @@ static int match(const struct sk_buff *s
       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 = {

  parent reply	other threads:[~2006-07-25  3:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-25  3:26 [NETFILTER 00/06]: Netfilter fixes Patrick McHardy
2006-07-25  3:26 ` [NETFILTER 01/06]: nf_queue: handle NF_STOP and unknown verdicts in nf_reinject Patrick McHardy
2006-07-25  3:26 ` [NETFILTER 02/06]: conntrack: fix SYSCTL=n compile Patrick McHardy
2006-07-25  3:26 ` [NETFILTER 03/06]: SNMP NAT: fix byteorder confusion Patrick McHardy
2006-07-25  3:26 ` Patrick McHardy [this message]
2006-07-25  3:27 ` [NETFILTER 05/06]: bridge netfilter: add deferred output hooks to feature-removal-schedule Patrick McHardy
2006-07-25  3:27 ` [NETFILTER 06/06]: Demote xt_sctp to EXPERIMENTAL Patrick McHardy
2006-07-25  5:55 ` [NETFILTER 00/06]: Netfilter fixes David Miller

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=20060725032658.25063.92778.sendpatchset@localhost.localdomain \
    --to=kaber@trash.net \
    --cc=davem@davemloft.net \
    --cc=netfilter-devel@lists.netfilter.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 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.