netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Carter <ncarter100@gmail.com>
To: netdev@vger.kernel.org, "Michał Mirosław" <mirqus@gmail.com>,
	"David Lamparter" <equinox@diac24.net>,
	"Stephen Hemminger" <shemminger@linux-foundation.org>
Cc: davem@davemloft.net
Subject: [PATCH] bridge: mask forwarding of IEEE 802 local multicast groups
Date: Fri, 1 Jul 2011 22:21:44 +0100	[thread overview]
Message-ID: <BANLkTi=jnxBu6WzAOTxHD+e_O1qYKE2m=g@mail.gmail.com> (raw)

Introduce sysfs ../bridge/group_fwd_mask attribute so users can
configure which group mac addresses are forwarded.

These diffs do not change the default behaviour of bridge.ko.  By
changing the group_fwd_mask value users can select any combination of
the 01-80-C2-00-00-00 - 01-80-C2-00-00-0F addresses to be forwarded.

Signed-off-by: Nick Carter <ncarter100@gmail.com>

diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index d9d1e2b..bb25e49 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -214,6 +214,7 @@ static struct net_device *new_bridge_dev(struct
net *net, const char *name)
 	br->topology_change = 0;
 	br->topology_change_detected = 0;
 	br->ageing_time = 300 * HZ;
+	br->group_fwd_mask = 0;

 	br_netfilter_rtable_init(br);

diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 90e985b..80b94f4 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -166,6 +166,9 @@ struct sk_buff *br_handle_frame(struct sk_buff *skb)
 		if (p->br->stp_enabled == BR_NO_STP && dest[5] == 0)
 			goto forward;

+		if (p->br->group_fwd_mask & (1 << dest[5]))
+			goto forward;
+
 		if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev,
 			    NULL, br_handle_local_finish))
 			return NULL;	/* frame consumed by filter */
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 4e1b620..d5aa164 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -244,6 +244,13 @@ struct net_bridge
 	struct timer_list		multicast_query_timer;
 #endif

+	/* Each bit used to match the LSB of the IEEE 802.1D group address
+	 * 01-80-C2-00-00-00 bit 0
+	 * ..
+	 * 01-80-C2-00-00-0F bit 15
+	 */
+	u16				group_fwd_mask;
+
 	struct timer_list		hello_timer;
 	struct timer_list		tcn_timer;
 	struct timer_list		topology_change_timer;
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index 5c1e555..f3cced5 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -679,6 +679,28 @@ static DEVICE_ATTR(nf_call_arptables, S_IRUGO | S_IWUSR,
 		   show_nf_call_arptables, store_nf_call_arptables);
 #endif

+static ssize_t show_group_fwd_mask(struct device *d, struct
device_attribute *attr,
+				char *buf)
+{
+	struct net_bridge *br = to_bridge(d);
+	return sprintf(buf, "%d\n", br->group_fwd_mask);
+}
+
+static int set_group_fwd_mask(struct net_bridge *br, unsigned long val)
+{
+	br->group_fwd_mask = (u16)val;
+	return 0;
+}
+
+static ssize_t store_group_fwd_mask(struct device *d,
+				 struct device_attribute *attr, const char *buf,
+				 size_t len)
+{
+	return store_bridge_parm(d, buf, len, set_group_fwd_mask);
+}
+static DEVICE_ATTR(group_fwd_mask, S_IRUGO | S_IWUSR, show_group_fwd_mask,
+		   store_group_fwd_mask);
+
 static struct attribute *bridge_attrs[] = {
 	&dev_attr_forward_delay.attr,
 	&dev_attr_hello_time.attr,
@@ -698,6 +720,7 @@ static struct attribute *bridge_attrs[] = {
 	&dev_attr_gc_timer.attr,
 	&dev_attr_group_addr.attr,
 	&dev_attr_flush.attr,
+	&dev_attr_group_fwd_mask.attr,
 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
 	&dev_attr_multicast_router.attr,
 	&dev_attr_multicast_snooping.attr,

             reply	other threads:[~2011-07-01 21:21 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-01 21:21 Nick Carter [this message]
2011-07-01 22:37 ` [PATCH] bridge: mask forwarding of IEEE 802 local multicast groups David Lamparter
2011-07-03 18:30   ` Nick Carter
2011-07-10 16:04 ` Nick Carter
2011-07-11 15:27   ` Stephen Hemminger
2011-07-12 11:36     ` David Lamparter
2011-07-15 15:44       ` Nick Carter
2011-07-15 16:03         ` David Lamparter
2011-07-15 16:33           ` David Lamparter
2011-07-27 11:17             ` David Lamparter
2011-07-28 15:41               ` Stephen Hemminger
2011-08-15 16:27                 ` Nick Carter
2011-08-15 18:25                   ` Stephen Hemminger
2011-08-31 20:41                     ` Nick Carter
2011-08-31 20:49                       ` Stephen Hemminger
2011-08-31 22:00                         ` Ed Swierk
2011-09-01  0:16                         ` David Lamparter
2011-09-13 19:29                 ` Benjamin Poirier
     [not found] <CAF5U64C+WgQhfJL3zfVnvzE7p=G61humQCObHGUxAvY2-MGAFQ@mail.gmail.com>
2011-08-12 22:37 ` Ed Swierk
2011-08-12 22:45   ` Stephen Hemminger
2011-08-13  5:43     ` Ed Swierk

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='BANLkTi=jnxBu6WzAOTxHD+e_O1qYKE2m=g@mail.gmail.com' \
    --to=ncarter100@gmail.com \
    --cc=davem@davemloft.net \
    --cc=equinox@diac24.net \
    --cc=mirqus@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@linux-foundation.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).