netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Oester <kernel@linuxace.com>
To: netfilter-devel@vger.kernel.org
Cc: pablo@netfilter.org
Subject: [PATCH] netfilter: xt_pkttype: IPv6 has no broadcast
Date: Thu, 11 Jul 2013 12:03:43 -0700	[thread overview]
Message-ID: <20130711190343.GA25293@linuxace.com> (raw)

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

As stated in RFC 4291:

   There are no broadcast addresses in IPv6, their function being
   superseded by multicast addresses.

As such, the pkttype match should not allow IPv6 rules to be added
which attempt to match broadcast packets.  The addrtype match already
rejects such attempts.

Phil

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



[-- Attachment #2: patch-ipv6-no-broadcast --]
[-- Type: text/plain, Size: 1147 bytes --]

diff --git a/net/netfilter/xt_pkttype.c b/net/netfilter/xt_pkttype.c
index 5b645cb..4c0b0e1 100644
--- a/net/netfilter/xt_pkttype.c
+++ b/net/netfilter/xt_pkttype.c
@@ -42,13 +42,29 @@ pkttype_mt(const struct sk_buff *skb, struct xt_action_param *par)
 	return (type == info->pkttype) ^ info->invert;
 }
 
+static int pkttype_mt_checkentry(const struct xt_mtchk_param *par)
+{
+	const struct xt_pkttype_info *info = par->matchinfo;
+
+#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
+	if (par->family == NFPROTO_IPV6) {
+		if (info->pkttype == PACKET_BROADCAST) {
+			pr_err("IPv6 does not support BROADCAST packets\n");
+			return -EINVAL;
+		}
+	}
+#endif
+	return 0;
+}
+
 static struct xt_match pkttype_mt_reg __read_mostly = {
-	.name      = "pkttype",
-	.revision  = 0,
-	.family    = NFPROTO_UNSPEC,
-	.match     = pkttype_mt,
-	.matchsize = sizeof(struct xt_pkttype_info),
-	.me        = THIS_MODULE,
+	.name		= "pkttype",
+	.revision	= 0,
+	.family		= NFPROTO_UNSPEC,
+	.checkentry	= pkttype_mt_checkentry,
+	.match		= pkttype_mt,
+	.matchsize	= sizeof(struct xt_pkttype_info),
+	.me		= THIS_MODULE,
 };
 
 static int __init pkttype_mt_init(void)

             reply	other threads:[~2013-07-11 19:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-11 19:03 Phil Oester [this message]
2013-07-15 11:16 ` [PATCH] netfilter: xt_pkttype: IPv6 has no broadcast Pablo Neira Ayuso

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=20130711190343.GA25293@linuxace.com \
    --to=kernel@linuxace.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@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 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).