Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 22325
b: refs/heads/master
c: fda93d9
h: refs/heads/master
i:
  22323: ba901b6
v: v3
  • Loading branch information
Stephen Hemminger authored and David S. Miller committed Mar 21, 2006
1 parent 5f31a98 commit 353ca49
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cf0f02d04a830c8202e6a8f8bb37acc6c1629a91
refs/heads/master: fda93d92d7824159d8532995072dde2bee4bc4b3
7 changes: 4 additions & 3 deletions trunk/net/bridge/br_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#include <linux/netfilter_bridge.h>
#include "br_private.h"

const unsigned char bridge_ula[6] = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 };
/* Bridge group multicast address 802.1d (pg 51). */
const u8 br_group_address[ETH_ALEN] = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 };

static void br_pass_frame_up(struct net_bridge *br, struct sk_buff *skb)
{
Expand Down Expand Up @@ -108,9 +109,9 @@ static int br_handle_local_finish(struct sk_buff *skb)
/* Does address match the link local multicast address.
* 01:80:c2:00:00:0X
*/
static inline int is_link_local(const unsigned char *dest)
static inline int is_link_local(const const unsigned char *dest)
{
return memcmp(dest, bridge_ula, 5) == 0 && (dest[5] & 0xf0) == 0;
return memcmp(dest, br_group_address, 5) == 0 && (dest[5] & 0xf0) == 0;
}

/*
Expand Down
3 changes: 2 additions & 1 deletion trunk/net/bridge/br_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ struct net_bridge
unsigned long bridge_hello_time;
unsigned long bridge_forward_delay;

u8 group_addr[ETH_ALEN];
u16 root_port;
unsigned char stp_enabled;
unsigned char topology_change;
Expand All @@ -122,7 +123,7 @@ struct net_bridge
};

extern struct notifier_block br_device_notifier;
extern const unsigned char bridge_ula[6];
extern const u8 br_group_address[ETH_ALEN];

/* called under bridge lock */
static inline int br_is_root_bridge(const struct net_bridge *br)
Expand Down
4 changes: 2 additions & 2 deletions trunk/net/bridge/br_stp_bpdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static void br_send_bpdu(struct net_bridge_port *p, unsigned char *data, int len
skb->dev = dev;
skb->protocol = htons(ETH_P_802_2);
skb->mac.raw = skb_put(skb, size);
memcpy(skb->mac.raw, bridge_ula, ETH_ALEN);
memcpy(skb->mac.raw, p->br->group_addr, ETH_ALEN);
memcpy(skb->mac.raw+ETH_ALEN, dev->dev_addr, ETH_ALEN);
skb->mac.raw[2*ETH_ALEN] = 0;
skb->mac.raw[2*ETH_ALEN+1] = length;
Expand Down Expand Up @@ -171,7 +171,7 @@ int br_stp_rcv(struct sk_buff *skb, struct net_device *dev,
|| !(br->dev->flags & IFF_UP))
goto out;

if (compare_ether_addr(dest, bridge_ula) != 0)
if (compare_ether_addr(dest, br->group_addr) != 0)
goto out;

buf = skb_pull(skb, 3);
Expand Down
49 changes: 49 additions & 0 deletions trunk/net/bridge/br_sysfs_br.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,54 @@ static ssize_t show_gc_timer(struct class_device *cd, char *buf)
}
static CLASS_DEVICE_ATTR(gc_timer, S_IRUGO, show_gc_timer, NULL);

static ssize_t show_group_addr(struct class_device *cd, char *buf)
{
struct net_bridge *br = to_bridge(cd);
return sprintf(buf, "%x:%x:%x:%x:%x:%x\n",
br->group_addr[0], br->group_addr[1],
br->group_addr[2], br->group_addr[3],
br->group_addr[4], br->group_addr[5]);
}

static ssize_t store_group_addr(struct class_device *cd, const char *buf,
size_t len)
{
struct net_bridge *br = to_bridge(cd);
unsigned new_addr[6];
int i;

if (!capable(CAP_NET_ADMIN))
return -EPERM;

if (sscanf(buf, "%x:%x:%x:%x:%x:%x",
&new_addr[0], &new_addr[1], &new_addr[2],
&new_addr[3], &new_addr[4], &new_addr[5]) != 6)
return -EINVAL;

/* Must be 01:80:c2:00:00:0X */
for (i = 0; i < 5; i++)
if (new_addr[i] != br_group_address[i])
return -EINVAL;

if (new_addr[5] & ~0xf)
return -EINVAL;

if (new_addr[5] == 1 /* 802.3x Pause address */
|| new_addr[5] == 2 /* 802.3ad Slow protocols */
|| new_addr[5] == 3) /* 802.1X PAE address */
return -EINVAL;

spin_lock_bh(&br->lock);
for (i = 0; i < 6; i++)
br->group_addr[i] = new_addr[i];
spin_unlock_bh(&br->lock);
return len;
}

static CLASS_DEVICE_ATTR(group_addr, S_IRUGO | S_IWUSR,
show_group_addr, store_group_addr);


static struct attribute *bridge_attrs[] = {
&class_device_attr_forward_delay.attr,
&class_device_attr_hello_time.attr,
Expand All @@ -259,6 +307,7 @@ static struct attribute *bridge_attrs[] = {
&class_device_attr_tcn_timer.attr,
&class_device_attr_topology_change_timer.attr,
&class_device_attr_gc_timer.attr,
&class_device_attr_group_addr.attr,
NULL
};

Expand Down

0 comments on commit 353ca49

Please sign in to comment.