[IPV4]: Correct rp_filter help text.
[linux-2.6/verdex.git] / net / bridge / br_device.c
blob5e1892d8d874a0eaa8a95c5a697285b11dc25163
1 /*
2 * Device handling code
3 * Linux ethernet bridge
5 * Authors:
6 * Lennert Buytenhek <buytenh@gnu.org>
8 * $Id: br_device.c,v 1.6 2001/12/24 00:59:55 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/etherdevice.h>
19 #include <linux/ethtool.h>
21 #include <asm/uaccess.h>
22 #include "br_private.h"
24 static struct net_device_stats *br_dev_get_stats(struct net_device *dev)
26 struct net_bridge *br = netdev_priv(dev);
27 return &br->statistics;
30 /* net device transmit always called with no BH (preempt_disabled) */
31 int br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
33 struct net_bridge *br = netdev_priv(dev);
34 const unsigned char *dest = skb->data;
35 struct net_bridge_fdb_entry *dst;
37 br->statistics.tx_packets++;
38 br->statistics.tx_bytes += skb->len;
40 skb_reset_mac_header(skb);
41 skb_pull(skb, ETH_HLEN);
43 if (dest[0] & 1)
44 br_flood_deliver(br, skb, 0);
45 else if ((dst = __br_fdb_get(br, dest)) != NULL)
46 br_deliver(dst->dst, skb);
47 else
48 br_flood_deliver(br, skb, 0);
50 return 0;
53 static int br_dev_open(struct net_device *dev)
55 struct net_bridge *br = netdev_priv(dev);
57 br_features_recompute(br);
58 netif_start_queue(dev);
59 br_stp_enable_bridge(br);
61 return 0;
64 static void br_dev_set_multicast_list(struct net_device *dev)
68 static int br_dev_stop(struct net_device *dev)
70 br_stp_disable_bridge(netdev_priv(dev));
72 netif_stop_queue(dev);
74 return 0;
77 static int br_change_mtu(struct net_device *dev, int new_mtu)
79 if (new_mtu < 68 || new_mtu > br_min_mtu(netdev_priv(dev)))
80 return -EINVAL;
82 dev->mtu = new_mtu;
83 return 0;
86 /* Allow setting mac address to any valid ethernet address. */
87 static int br_set_mac_address(struct net_device *dev, void *p)
89 struct net_bridge *br = netdev_priv(dev);
90 struct sockaddr *addr = p;
92 if (!is_valid_ether_addr(addr->sa_data))
93 return -EINVAL;
95 spin_lock_bh(&br->lock);
96 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
97 br_stp_change_bridge_id(br, addr->sa_data);
98 spin_unlock_bh(&br->lock);
100 return 0;
103 static void br_getinfo(struct net_device *dev, struct ethtool_drvinfo *info)
105 strcpy(info->driver, "bridge");
106 strcpy(info->version, BR_VERSION);
107 strcpy(info->fw_version, "N/A");
108 strcpy(info->bus_info, "N/A");
111 static int br_set_sg(struct net_device *dev, u32 data)
113 struct net_bridge *br = netdev_priv(dev);
115 if (data)
116 br->feature_mask |= NETIF_F_SG;
117 else
118 br->feature_mask &= ~NETIF_F_SG;
120 br_features_recompute(br);
121 return 0;
124 static int br_set_tso(struct net_device *dev, u32 data)
126 struct net_bridge *br = netdev_priv(dev);
128 if (data)
129 br->feature_mask |= NETIF_F_TSO;
130 else
131 br->feature_mask &= ~NETIF_F_TSO;
133 br_features_recompute(br);
134 return 0;
137 static int br_set_tx_csum(struct net_device *dev, u32 data)
139 struct net_bridge *br = netdev_priv(dev);
141 if (data)
142 br->feature_mask |= NETIF_F_NO_CSUM;
143 else
144 br->feature_mask &= ~NETIF_F_ALL_CSUM;
146 br_features_recompute(br);
147 return 0;
150 static struct ethtool_ops br_ethtool_ops = {
151 .get_drvinfo = br_getinfo,
152 .get_link = ethtool_op_get_link,
153 .get_sg = ethtool_op_get_sg,
154 .set_sg = br_set_sg,
155 .get_tx_csum = ethtool_op_get_tx_csum,
156 .set_tx_csum = br_set_tx_csum,
157 .get_tso = ethtool_op_get_tso,
158 .set_tso = br_set_tso,
161 void br_dev_setup(struct net_device *dev)
163 memset(dev->dev_addr, 0, ETH_ALEN);
165 ether_setup(dev);
167 dev->do_ioctl = br_dev_ioctl;
168 dev->get_stats = br_dev_get_stats;
169 dev->hard_start_xmit = br_dev_xmit;
170 dev->open = br_dev_open;
171 dev->set_multicast_list = br_dev_set_multicast_list;
172 dev->change_mtu = br_change_mtu;
173 dev->destructor = free_netdev;
174 SET_MODULE_OWNER(dev);
175 SET_ETHTOOL_OPS(dev, &br_ethtool_ops);
176 dev->stop = br_dev_stop;
177 dev->tx_queue_len = 0;
178 dev->set_mac_address = br_set_mac_address;
179 dev->priv_flags = IFF_EBRIDGE;
181 dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA |
182 NETIF_F_TSO | NETIF_F_NO_CSUM | NETIF_F_GSO_ROBUST;