#include <linux/module.h>
#include <linux/inetdevice.h>
#include <linux/rtnetlink.h>
u32 get_default_ipaddr_by_devname(const char *devname)
{
u32 addr;
struct net_device *dev;
if (!devname) return 0;
/* find netdev by name, increment refcnt */
dev=dev_get_by_name(devname);
if (!dev) return 0;
/* get ip addr from rtable (global scope) */
addr = inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE);
/* decrement netdev refcnt */
dev_put(dev);
return addr;
}
How can we get address of bonding devices? For example, if I executed
above
^^^^^^^
code on my system, this is what I get:
oops.. I mean aliases.
bond0 device address is: 0x80000203 (128.0.2.3)
bond0:0 => no such device
eth0 device address is: 0x80000203 (128.0.2.3)
This is, ifconfig output:
bond0 Link encap:Ethernet HWaddr 02:00:00:00:01:00
inet addr:128.0.2.3 Bcast:128.0.7.255 Mask:255.255.248.0
inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:2500 Metric:1
bond0:0 Link encap:Ethernet HWaddr 02:00:00:00:01:00
inet addr:10.10.1.241 Bcast:10.10.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MASTER MULTICAST MTU:2500 Metric:1
eth0 Link encap:Ethernet HWaddr 02:00:00:00:01:00
inet addr:128.0.2.3 Bcast:128.0.7.255 Mask:255.255.248.0
inet6 addr: fe80::ff:fe00:100/64 Scope:Link
UP BROADCAST RUNNING SLAVE MULTICAST MTU:2500 Metric:1
-Mohan
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ