From: Phil Oester <kernel@linuxace.com>
To: Patrick McHardy <kaber@trash.net>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] Pkttype match mismatches in OUTPUT chain
Date: Wed, 3 Sep 2008 09:06:08 -0700 [thread overview]
Message-ID: <20080903160608.GB8460@linuxace.com> (raw)
In-Reply-To: <20080814120240.GA30222@linuxace.com>
[-- Attachment #1: Type: text/plain, Size: 771 bytes --]
On Thu, Aug 14, 2008 at 05:02:40AM -0700, Phil Oester wrote:
> On Wed, Aug 13, 2008 at 03:32:24PM +0200, Patrick McHardy wrote:
> > This is getting more and more kludgy, wouldn't it make more sense
> > to move the pkt_type initialisation from the device layer to the
> > protocol layer?
>
> It would, but that's a large-ish change, and unknown if DaveM would
> support it just to make an iptables match less kludgy.
>
> Unfortunately, it doesn't appear this match was tested very thoroughly
> prior to being added to the tree...
>
> Phil
Any further thoughts on this Patrick? Longer-term, your plan would help,
but perhaps in the interim we should get this queued up for 2.6.27 so
we have a working match for OUTPUT packets?
Original patch included below.
Phil
[-- Attachment #2: patch-pkttype-output --]
[-- Type: text/plain, Size: 1115 bytes --]
diff --git a/net/netfilter/xt_pkttype.c b/net/netfilter/xt_pkttype.c
index 7936f7e..7036d43 100644
--- a/net/netfilter/xt_pkttype.c
+++ b/net/netfilter/xt_pkttype.c
@@ -29,18 +29,21 @@ pkttype_mt(const struct sk_buff *skb, const struct net_device *in,
bool *hotdrop)
{
const struct xt_pkttype_info *info = matchinfo;
- u_int8_t type;
+ u_int8_t type = 0;
- if (skb->pkt_type != PACKET_LOOPBACK)
- type = skb->pkt_type;
- else if (match->family == AF_INET &&
- ipv4_is_multicast(ip_hdr(skb)->daddr))
- type = PACKET_MULTICAST;
- else if (match->family == AF_INET6 &&
+ if (match->family == AF_INET) {
+ struct net *net = dev_net(skb->dst->dev);
+ const struct iphdr *iph = ip_hdr(skb);
+ if (ipv4_is_multicast(iph->daddr))
+ type = PACKET_MULTICAST;
+ else if (inet_addr_type(net, iph->daddr) == RTN_BROADCAST)
+ type = PACKET_BROADCAST;
+ } else if (match->family == AF_INET6 &&
ipv6_hdr(skb)->daddr.s6_addr[0] == 0xFF)
type = PACKET_MULTICAST;
- else
- type = PACKET_BROADCAST;
+
+ if (!type)
+ type = skb->pkt_type;
return (type == info->pkttype) ^ info->invert;
}
prev parent reply other threads:[~2008-09-03 16:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-10 22:18 [PATCH] Pkttype match mismatches in OUTPUT chain Phil Oester
2008-08-10 22:53 ` Phil Oester
2008-08-13 13:32 ` Patrick McHardy
2008-08-14 12:02 ` Phil Oester
2008-09-03 16:06 ` Phil Oester [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=20080903160608.GB8460@linuxace.com \
--to=kernel@linuxace.com \
--cc=kaber@trash.net \
--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