3 * Linux ethernet bridge
6 * Lennert Buytenhek <buytenh@gnu.org>
8 * $Id: br_device.c,v 1.2 2000/02/24 19:48:06 davem Exp $
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.
16 #include <linux/kernel.h>
17 #include <linux/netdevice.h>
18 #include <linux/if_bridge.h>
19 #include <asm/uaccess.h>
20 #include "br_private.h"
22 static int br_dev_do_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
24 unsigned long args
[4];
27 if (cmd
!= SIOCDEVPRIVATE
)
30 data
= (unsigned long *)rq
->ifr_data
;
31 if (copy_from_user(args
, data
, 4*sizeof(unsigned long)))
34 return br_ioctl(dev
->priv
, args
[0], args
[1], args
[2], args
[3]);
37 static struct net_device_stats
*br_dev_get_stats(struct net_device
*dev
)
39 struct net_bridge
*br
;
43 return &br
->statistics
;
46 static int __br_dev_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
48 struct net_bridge
*br
;
50 struct net_bridge_fdb_entry
*dst
;
53 br
->statistics
.tx_packets
++;
54 br
->statistics
.tx_bytes
+= skb
->len
;
63 if ((dst
= br_fdb_get(br
, dest
)) != NULL
) {
64 br_forward(dst
->dst
, skb
);
73 static int br_dev_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
75 struct net_bridge
*br
;
80 ret
= __br_dev_xmit(skb
, dev
);
81 read_unlock(&br
->lock
);
86 static int br_dev_open(struct net_device
*dev
)
88 struct net_bridge
*br
;
90 netif_start_queue(dev
);
94 br_stp_enable_bridge(br
);
95 read_unlock(&br
->lock
);
100 static void br_dev_set_multicast_list(struct net_device
*dev
)
104 static int br_dev_stop(struct net_device
*dev
)
106 struct net_bridge
*br
;
109 read_lock(&br
->lock
);
110 br_stp_disable_bridge(br
);
111 read_unlock(&br
->lock
);
113 netif_stop_queue(dev
);
118 static int br_dev_accept_fastpath(struct net_device
*dev
, struct dst_entry
*dst
)
123 void br_dev_setup(struct net_device
*dev
)
125 memset(dev
->dev_addr
, 0, ETH_ALEN
);
127 dev
->do_ioctl
= br_dev_do_ioctl
;
128 dev
->get_stats
= br_dev_get_stats
;
129 dev
->hard_start_xmit
= br_dev_xmit
;
130 dev
->open
= br_dev_open
;
131 dev
->set_multicast_list
= br_dev_set_multicast_list
;
132 dev
->stop
= br_dev_stop
;
133 dev
->accept_fastpath
= br_dev_accept_fastpath
;
134 dev
->tx_queue_len
= 0;
135 dev
->set_mac_address
= NULL
;