From: Shmulik Hen <shmulik@trego.co.il>
To: netdev@vger.kernel.org
Subject: System blocks (hangs) on ifconfig up
Date: Sun, 12 Dec 2010 17:08:44 +0200 [thread overview]
Message-ID: <4D04E57C.7020509@trego.co.il> (raw)
Hello,
My system is Ubuntu 10.04, running kernel 2.6.32-26-generic.
Whenever I try to bring up a specific ethernet interface for the second
time, my
system becomes unresponsive for 60 seconds - i.e. no mouse, no keyboard, no
screen refresh. etc.
Looking at the driver's code, I could see that it's dev->open() method
calls
wait_event_interruptible_timeout() with a timeout of 60 seconds - exactly
the delay I'm seeing.
I have narrowed the code to a bare minimum (see below - loosely based on
dummy.c), which only calls mdelay(10000) in it's dev->open() method, and
still, my system blocks for exactly 10 seconds when I run the following
sequence:
> sudo ifconfig shmulik0 up
> sudo ifconfig shmulik0 down
> sudo ifconfig shmulik0 up
At this point - the system is stuck for 10 seconds.
Thanks,
Shmulik.
------------------------------------------------------------------------------
shmulik.c:
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/skbuff.h>
MODULE_AUTHOR("Shmulik Hen");
MODULE_DESCRIPTION("Shmulik's sample network driver");
MODULE_LICENSE("GPL");
static struct net_device *g_dev = NULL;
static int shmulik_set_mac_address(struct net_device *dev, void *p)
{
struct sockaddr *sa = p;
if (!is_valid_ether_addr(sa->sa_data))
return -EADDRNOTAVAIL;
memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN);
return 0;
}
static netdev_tx_t shmulik_start_xmit(struct sk_buff *skb, struct
net_device *dev)
{
dev_kfree_skb(skb);
return NETDEV_TX_OK;
}
static int shmulik_open(struct net_device *dev)
{
mdelay(10000);
netif_carrier_on(dev);
netif_start_queue(dev);
return 0;
}
static int shmulik_close(struct net_device *dev)
{
netif_stop_queue(dev);
netif_carrier_off(dev);
return 0;
}
static const struct net_device_ops shmulik_drv_ops =
{
.ndo_open = shmulik_open,
.ndo_stop = shmulik_close,
.ndo_start_xmit = shmulik_start_xmit,
.ndo_set_mac_address = shmulik_set_mac_address,
};
static int __init shmulik_drv_init(void)
{
int rc;
struct net_device *dev;
if (g_dev)
return -EEXIST;
dev = alloc_etherdev(0);
if (!dev)
return -ENOMEM;
sprintf(dev->name, "%s%d" , "shmulik", 0);
dev->tx_queue_len = 0;
dev->flags |= IFF_NOARP;
dev->flags &= ~IFF_MULTICAST;
random_ether_addr(dev->dev_addr);
dev->netdev_ops = &shmulik_drv_ops;
rc = register_netdev(dev);
if (rc)
goto err_exit;
g_dev = dev;
return 0;
err_exit:
free_netdev(dev);
return rc;
}
static void __exit shmulik_drv_exit(void)
{
if (g_dev)
{
unregister_netdev(g_dev);
free_netdev(g_dev);
g_dev = NULL;
}
}
module_init(shmulik_drv_init);
module_exit(shmulik_drv_exit);
next reply other threads:[~2010-12-12 15:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-12 15:08 Shmulik Hen [this message]
2010-12-12 20:29 ` System blocks (hangs) on ifconfig up Eric Dumazet
2010-12-12 20:53 ` Eric Dumazet
-- strict thread matches above, loose matches on Subject: below --
2010-12-12 15:00 Shmulik Hen
2010-12-12 23:03 ` Ben Hutchings
2010-12-13 9:14 ` Shmulik Hen
2010-12-13 12:37 ` Eric Dumazet
2010-12-13 13:11 ` Shmulik Hen
2010-12-12 23:29 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D04E57C.7020509@trego.co.il \
--to=shmulik@trego.co.il \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.