aboutsummaryrefslogtreecommitdiffstats
path: root/net/bridge/br_device.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /net/bridge/br_device.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'net/bridge/br_device.c')
-rw-r--r--net/bridge/br_device.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
new file mode 100644
index 000000000000..d9b72fde433c
--- /dev/null
+++ b/net/bridge/br_device.c
@@ -0,0 +1,104 @@
1/*
2 * Device handling code
3 * Linux ethernet bridge
4 *
5 * Authors:
6 * Lennert Buytenhek <buytenh@gnu.org>
7 *
8 * $Id: br_device.c,v 1.6 2001/12/24 00:59:55 davem Exp $
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15
16#include <linux/kernel.h>
17#include <linux/netdevice.h>
18#include <linux/module.h>
19#include <asm/uaccess.h>
20#include "br_private.h"
21
22static struct net_device_stats *br_dev_get_stats(struct net_device *dev)
23{
24 struct net_bridge *br;
25
26 br = dev->priv;
27
28 return &br->statistics;
29}
30
31int br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
32{
33 struct net_bridge *br = netdev_priv(dev);
34 const unsigned char *dest = skb->data;
35 struct net_bridge_fdb_entry *dst;
36
37 br->statistics.tx_packets++;
38 br->statistics.tx_bytes += skb->len;
39
40 skb->mac.raw = skb->data;
41 skb_pull(skb, ETH_HLEN);
42
43 rcu_read_lock();
44 if (dest[0] & 1)
45 br_flood_deliver(br, skb, 0);
46 else if ((dst = __br_fdb_get(br, dest)) != NULL)
47 br_deliver(dst->dst, skb);
48 else
49 br_flood_deliver(br, skb, 0);
50
51 rcu_read_unlock();
52 return 0;
53}
54
55static int br_dev_open(struct net_device *dev)
56{
57 netif_start_queue(dev);
58
59 br_stp_enable_bridge(dev->priv);
60
61 return 0;
62}
63
64static void br_dev_set_multicast_list(struct net_device *dev)
65{
66}
67
68static int br_dev_stop(struct net_device *dev)
69{
70 br_stp_disable_bridge(dev->priv);
71
72 netif_stop_queue(dev);
73
74 return 0;
75}
76
77static int br_change_mtu(struct net_device *dev, int new_mtu)
78{
79 if ((new_mtu < 68) || new_mtu > br_min_mtu(dev->priv))
80 return -EINVAL;
81
82 dev->mtu = new_mtu;
83 return 0;
84}
85
86void br_dev_setup(struct net_device *dev)
87{
88 memset(dev->dev_addr, 0, ETH_ALEN);
89
90 ether_setup(dev);
91
92 dev->do_ioctl = br_dev_ioctl;
93 dev->get_stats = br_dev_get_stats;
94 dev->hard_start_xmit = br_dev_xmit;
95 dev->open = br_dev_open;
96 dev->set_multicast_list = br_dev_set_multicast_list;
97 dev->change_mtu = br_change_mtu;
98 dev->destructor = free_netdev;
99 SET_MODULE_OWNER(dev);
100 dev->stop = br_dev_stop;
101 dev->tx_queue_len = 0;
102 dev->set_mac_address = NULL;
103 dev->priv_flags = IFF_EBRIDGE;
104}