Get the IP address of an interface with a given name

2007-11-20 Thread Giacomo
Good morning.

 I have written a kernel function which needs to get the IP address of
an active network interface
 given its name.

 The actual implementation i have done is like this
 but i suspect this does not always work.
 Is there any API already provided by the kernel to do the same?

 Thanks a lot

 Giacomo

 -- actual implementation: ---

 /* 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;
struct in_ifaddr* inet_ifaddr;

read_lock_bh(dev_base_lock);
 #if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,22)
pnet_device = dev_base;
 #else
pnet_device = first_net_device();
 #endif
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;
inet_ifaddr = pin_device-ifa_list;
if(inet_ifaddr == NULL)
{
printk(ifa_list is null!\n);
break;
}
/* ifa_local: ifa_address is the remote point in ppp */
*addr = (inet_ifaddr-ifa_local);
  read_unlock_bh(dev_base_lock);
return 1;
}
 #if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,22)
pnet_device = pnet_device-next;
 #else
pnet_device = next_net_device(pnet_device);
 #endif

}

read_unlock_bh(dev_base_lock);
return -1;  /* address not found! */
 }

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

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

IPFIREwall (http://www.giacomos.it/ipfire) viene presentato
all'Universita` degli Studi di Udine, il 28 ottobre, in occasione del
Linux Day 2006:
http://iglu.cc.uniud.it/linuxday

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

 . ''  `.
:   :':
 `.  ` '
`- Debian GNU/Linux -- The power of freedom
http://www.debian.org
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Get the IP address of an interface with a given name

2007-11-19 Thread Giacomo
 /* 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;
struct in_ifaddr* inet_ifaddr;

read_lock_bh(dev_base_lock);
 #if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,22)
pnet_device = dev_base;
 #else
pnet_device = first_net_device();
 #endif
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;
inet_ifaddr = pin_device-ifa_list;
if(inet_ifaddr == NULL)
{
printk(ifa_list is null!\n);
break;
}
/* ifa_local: ifa_address is the remote point in ppp */
*addr = (inet_ifaddr-ifa_local);
  read_unlock_bh(dev_base_lock);
return 1;
}
 #if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,22)
pnet_device = pnet_device-next;
 #else
pnet_device = next_net_device(pnet_device);
 #endif

}

read_unlock_bh(dev_base_lock);
return -1;  /* address not found! */
 }


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

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

IPFIREwall (http://www.giacomos.it/ipfire) viene presentato
all'Universita` degli Studi di Udine, il 28 ottobre, in occasione del
Linux Day 2006:
http://iglu.cc.uniud.it/linuxday

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

 . ''  `.
:   :':
 `.  ` '
`- Debian GNU/Linux -- The power of freedom
http://www.debian.org
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [BUG] New Kernel Bugs

2007-11-13 Thread Giacomo A. Catenazzi

Mark Lord wrote:

Ingo Molnar wrote:
..
This is all QA-101 that _cannot be argued against on a rational 
basis_, it's just that these sorts of things have been largely ignored 
for years, in favor of the all-too-easy open source means many 
eyeballs and that is our QA answer, which is a _good_ answer but by 
far not the most intelligent answer! Today many eyeballs is simply 
not good enough and nature (and other OS projects) will route us 
around if we dont change.

..

QA-101 and many eyeballs are not at all in opposition.
The latter is how we find out about bugs on uncommon hardware,
and the former is what we need to track them and overall quality.

A HUGE problem I have with current efforts, is that once someone
reports a bug, the onus seems to be 99% on the *reporter* to find
the exact line of code or commit.  Ghad what a repressive method.



As a long time kernel tester, I see some problem with the
newer new development model. In the short merge windows,
after to much time, there are to many patches.
So there are problem to bisect bugs, and to have attention
of developers. My impression is that in a week there are
many more messages in lkml and to much bugs to be
handled in these few days.

I've two proposal:

- better patch quality. I would like that every commit
would compile. So an automatic commit test and public
blames could increase the quality of first commits.
[bisecting with non compilable point it is not a trivial
task]

- a slow down the patch inclusion on the merge windows
(aka: not to much big changes in the first days).
As tester I prefer that some big changes would be
included in a secondary window (pre o rc release),
in an other period as the big patch rush.

ciao
cate
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: last git: BUG: unable to handle kernel paging request at virtual address 92184900

2007-10-29 Thread Giacomo Catenazzi
Andrew Morton wrote:
 On Tue, 23 Oct 2007 21:04:20 +0200 Giacomo Catenazzi [EMAIL PROTECTED] 
 wrote:
 
 Oct 23 20:20:05 catee kernel: BUG: unable to handle kernel paging request at 
 virtual address 92184900
 
 Is this still happening in the latest Linus tree?
 
 If so, please send some more oops traces so we can see if it's always 
 happening
 in the same place.

No, since few days I didn't have kernel crashes, so I think the
bug was solved.

ciao
cate
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: bonding: cannot remove certain named devices

2006-08-16 Thread Giacomo A. Catenazzi
David Miller wrote:
 From: Bodo Eggert [EMAIL PROTECTED]
 Date: Wed, 16 Aug 2006 02:02:03 +0200
 
 Stephen Hemminger [EMAIL PROTECTED] wrote:

 IMHO idiots who put space's in filenames should be ignored. As long as the
 bonding code doesn't throw a fatal error, it has every right to return
 No such device to the fool.
 Maybe you should limit device names to eight uppercase characters and up to
 three characters extension, too. NOT! There is no reason to artificially
 impose limitations on device names, so don't do that.
 
 Are you willing to work to add the special case code necessary to
 handle whitespace characters in the device name over all of the kernel
 code and also all of the userland tools too?

But if you don't handle spaces in userspace, you handle *, ?, [, ], $,
, ', \  in userspace? Should kernel disable also these (insane device
chars) chars?

ciao
cate
 
 No?  Great, I'm glad that's settled.

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: bonding: cannot remove certain named devices

2006-08-16 Thread Giacomo A. Catenazzi

Bill Nottingham wrote:
Giacomo A. Catenazzi ([EMAIL PROTECTED]) said: 

Are you willing to work to add the special case code necessary to
handle whitespace characters in the device name over all of the kernel
code and also all of the userland tools too?

But if you don't handle spaces in userspace, you handle *, ?, [, ], $,
, ', \  in userspace? Should kernel disable also these (insane device
chars) chars?


Don't forget unicode characters!

Seriously, while it might be insane to use some of these, I'm wondering
if trying to filter names is more work than fixing the tools.


Fixing tools in always the good approach, and I think in this case wrong
code is really a security problem. IMHO kernel cannot filter all bad 
strings.

So, if for the kernel part it is better to filter spaces, ok!
But we should use this user space problems as the motivation to filter
names.

ciao
cate

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Presentation question^^.

2006-01-31 Thread Giacomo Succi
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

- -BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi to everyone :)!
That's my first eMail on this ML.
I hope to do something valuable in the future^^.

For an university project I must implement a kernel module related to net stuff,
but I've a couple of questions...

How can I send a packet?
How can I enumerate the net interfaces in a machine?

I also need to write some file to the disk. In an IRC chat session someone told
me that the Kernel CANNOT write file.
So searching on the net I've found something useful... The IPC messages...
That's true or not? And if that's true, how can I use them practically for
saving the file? With an user space application?

Thanks a lot in advance :)!
Best regards.

See ya^^!
- - - --
Giacomo Succi

- - - -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Contacts:
eMail: [EMAIL PROTECTED]; AIM: Anandir82
Y!: anandir82; ICQ: 135781176
J: [EMAIL PROTECTED]; MSN: [EMAIL PROTECTED]

GPG:0x52CDCA27
GPG Server: http://sks.keyserver.penguin.de
- - - -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
- -BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFD3xsuUda2pFLNyicRAjE+AJ9eK/c6FtVu9/uni9koYUAFEDqm1wCgrFbF
8CqUrnFqOjMXrRg9fYY0DN8=
=KuTj
- -END PGP SIGNATURE-

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFD3x2/Uda2pFLNyicRAiy4AJ9I5HNdT3nBTHsaZmmPEbYqVd17YwCcDQH2
Lw9g2SY/LxC7EPfzkfNjag8=
=U/Qf
-END PGP SIGNATURE-
 

 

 --

 Email.it, the professional e-mail, gratis per te: http://www.email.it/f

 

 Sponsor:

 Grande Offerta di Benvenuto Cassine di Pietra:

* 36 bottiglie di ottimo vino veneto direttamente a casa tua!

* 

 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=3923d=31-1
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Presentation question^^.

2006-01-31 Thread Giacomo Succi
Hi to everyone :)!
That's my first eMail on this ML.
I hope to do something valuable in the future^^.

For an university project I must implement a kernel module related to net stuff,
but I've a couple of questions...

How can I send a packet?
How can I enumerate the net interfaces in a machine?

I also need to write some file to the disk. In an IRC chat session someone told
me that the Kernel CANNOT write file.
So searching on the net I've found something useful... The IPC messages...
That's true or not? And if that's true, how can I use them practically for
saving the file? With an user space application?

Thanks a lot in advance :)!
Best regards.

See ya^^!
- - - --
Giacomo Succi

- - - -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Contacts:
eMail: [EMAIL PROTECTED]; AIM: Anandir82
Y!: anandir82; ICQ: 135781176
J: [EMAIL PROTECTED]; MSN: [EMAIL PROTECTED]

GPG:0x52CDCA27
GPG Server: http://sks.keyserver.penguin.de
- - - -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
 

 

 --

 Email.it, the professional e-mail, gratis per te: http://www.email.it/f

 

 Sponsor:

 Sei in cerca dellÂ’amore? Non perdere tempo, iscriviti gratis a Meetic! Potrai 
chattare con migliaia di single in linea.

 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=4052d=31-1
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html