aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/loopback.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-09-29 02:03:42 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-29 02:03:42 -0400
commit3dcbbcda7c5b77c400791b26facd6593c5b176e0 (patch)
tree2e7b844c4d450cf43810a6ed0ddd5c702c245a88 /drivers/net/loopback.c
parentc972398b7871d9fb58c6a317786065a7cc6ca4be (diff)
parent6fbe59b9569b2c8d5522d182263935c6c86fc40a (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6: (160 commits) [ETHTOOL]: Remove some entries from non-root command list. [Bluetooth]: Fix section mismatch of bt_sysfs_cleanup() [Bluetooth]: Don't update disconnect timer for incoming connections [ETHTOOL]: let mortals use ethtool [NetLabel]: add audit support for configuration changes [TCP]: Fix and simplify microsecond rtt sampling [TCP] tcp-lp: prevent chance for oops [SUNRPC]: Remove unnecessary check in net/sunrpc/svcsock.c [IPVS] bug: endianness breakage in ip_vs_ftp [IPVS]: ipvs annotations [NETFILTER]: h323 annotations [NETFILTER]: ipt annotations [NETFILTER]: NAT annotations [NETFILTER]: conntrack annotations [NETFILTER]: netfilter misc annotations [NET]: Annotate dst_ops protocol [NET]: is it Andy or Andi ?? [IPVS]: Make sure ip_vs_ftp ports are valid: module_param_array approach [IPVS]: Reverse valid ip_vs_ftp ports fix: port check approach [IrDA] stir4200: removing undocumented bits handling ...
Diffstat (limited to 'drivers/net/loopback.c')
-rw-r--r--drivers/net/loopback.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index f429b19bf620..4178b4b1d2df 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -161,15 +161,13 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
161 return(0); 161 return(0);
162} 162}
163 163
164static struct net_device_stats loopback_stats;
165
164static struct net_device_stats *get_stats(struct net_device *dev) 166static struct net_device_stats *get_stats(struct net_device *dev)
165{ 167{
166 struct net_device_stats *stats = dev->priv; 168 struct net_device_stats *stats = &loopback_stats;
167 int i; 169 int i;
168 170
169 if (!stats) {
170 return NULL;
171 }
172
173 memset(stats, 0, sizeof(struct net_device_stats)); 171 memset(stats, 0, sizeof(struct net_device_stats));
174 172
175 for_each_possible_cpu(i) { 173 for_each_possible_cpu(i) {
@@ -185,19 +183,28 @@ static struct net_device_stats *get_stats(struct net_device *dev)
185 return stats; 183 return stats;
186} 184}
187 185
188static u32 loopback_get_link(struct net_device *dev) 186static u32 always_on(struct net_device *dev)
189{ 187{
190 return 1; 188 return 1;
191} 189}
192 190
193static const struct ethtool_ops loopback_ethtool_ops = { 191static const struct ethtool_ops loopback_ethtool_ops = {
194 .get_link = loopback_get_link, 192 .get_link = always_on,
195 .get_tso = ethtool_op_get_tso, 193 .get_tso = ethtool_op_get_tso,
196 .set_tso = ethtool_op_set_tso, 194 .set_tso = ethtool_op_set_tso,
195 .get_tx_csum = always_on,
196 .get_sg = always_on,
197 .get_rx_csum = always_on,
197}; 198};
198 199
200/*
201 * The loopback device is special. There is only one instance and
202 * it is statically allocated. Don't do this for other devices.
203 */
199struct net_device loopback_dev = { 204struct net_device loopback_dev = {
200 .name = "lo", 205 .name = "lo",
206 .get_stats = &get_stats,
207 .priv = &loopback_stats,
201 .mtu = (16 * 1024) + 20 + 20 + 12, 208 .mtu = (16 * 1024) + 20 + 20 + 12,
202 .hard_start_xmit = loopback_xmit, 209 .hard_start_xmit = loopback_xmit,
203 .hard_header = eth_header, 210 .hard_header = eth_header,
@@ -221,16 +228,6 @@ struct net_device loopback_dev = {
221/* Setup and register the loopback device. */ 228/* Setup and register the loopback device. */
222int __init loopback_init(void) 229int __init loopback_init(void)
223{ 230{
224 struct net_device_stats *stats;
225
226 /* Can survive without statistics */
227 stats = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
228 if (stats) {
229 memset(stats, 0, sizeof(struct net_device_stats));
230 loopback_dev.priv = stats;
231 loopback_dev.get_stats = &get_stats;
232 }
233
234 return register_netdev(&loopback_dev); 231 return register_netdev(&loopback_dev);
235}; 232};
236 233