[prev in list] [next in list] [prev in thread] [next in thread] 

List:       netfilter-devel
Subject:    Question about a locking problem
From:       Giacomo <delleceste () gmail ! com>
Date:       2006-06-30 7:08:15
Message-ID: 885896af0606300008h341cd400mf66700400bba28e2 () mail ! gmail ! com
[Download RAW message or body]

Good morning.

Some time ago i wrote a module in kernel space which does some filtering.

While running `dhclient eth0'  and plugging/unplugging the ethernet cable
from the network card, kernel freezed saying the culprit was the following
function (EIP is at get_ifaddr_by_name() ) :

/* returns in *addr the internet address having the name ifname */
int get_ifaddr_by_name(const char *ifname, __u32 * addr)
{
	struct net_device *pnet_device;
	struct in_device *pin_device;

	read_lock_bh(&dev_base_lock);
	pnet_device = dev_base;
	while (pnet_device != NULL)
	  {
		  if ((netif_running(pnet_device))
		      && (pnet_device->ip_ptr != NULL)
		      && (strcmp(pnet_device->name, ifname) == 0))
		    {
			    pin_device =
				(struct in_device *) pnet_device->ip_ptr;
			    /* ifa_local: ifa_address is the remote point in ppp */
			    *addr = (pin_device->ifa_list->ifa_local);
			    read_unlock_bh(&dev_base_lock);
			    return 1;
		    }
		 pnet_device = pnet_device->next;
	  }
	  read_unlock_bh(&dev_base_lock);
	return -1;		/* address not found! */
}

What could be wrong?
I think the problem is that read_lock_bh is not correct, perhaps
i would need read_lock_irq instead??

Can anyone suggest if i am right.

Thanks a lot

Giacomo.


-- 
Giacomo S.
http://www.giacomos.it

- - - - - - - - - - - - - - - - - - - - - -

Proteggi il tuo PC provando il mio semplice FIREWALL:
http://www.giacomos.it/ipfire

mailto:
delleceste@gmail.com
giacomo.strangolino@elettra.trieste.it
jacum@libero.it

- - - - - - - - - - - - - - - - - - - - - -

 . ''  `.
:   :'    :
 `.  ` '
    `- Debian GNU/Linux -- The power of freedom
        http://www.debian.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic