summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2006-09-11 19:53:51 +0000
committerDavid Cantrell <dcantrell@redhat.com>2006-09-11 19:53:51 +0000
commit54be3abf970de019fe00cf528d37176cbff1be6f (patch)
tree277b6b27f6126e9cd201f5fccfa17a60aeafe29c
parentee06f5b63e7dbeb74356212473ecec751da9dec6 (diff)
downloadanaconda-54be3abf970de019fe00cf528d37176cbff1be6f.tar.gz
anaconda-54be3abf970de019fe00cf528d37176cbff1be6f.tar.xz
anaconda-54be3abf970de019fe00cf528d37176cbff1be6f.zip
* isys/nl.c: Only collect IPv4 and IPv6 addresses for IFF_RUNNING
interfaces.
-rw-r--r--ChangeLog5
-rw-r--r--isys/nl.c29
2 files changed, 23 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index dcbfc5d52..b8794745a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,11 @@
2006-09-11 David Cantrell <dcantrell@redhat.com>
+ * isys/nl.c: Only collect IPv4 and IPv6 addresses for IFF_RUNNING
+ interfaces.
+
+2006-09-11 David Cantrell <dcantrell@redhat.com>
+
* scripts/mk-images.s390: Use the size of the actual initrd.img for
the value in initrd.size.
diff --git a/isys/nl.c b/isys/nl.c
index 293be19f9..a6ccc93f0 100644
--- a/isys/nl.c
+++ b/isys/nl.c
@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
+#include <linux/if.h>
#include <arpa/inet.h>
#include <net/if_arp.h>
@@ -207,7 +208,7 @@ int netlink_get_interface_ip(int index, int family, void *addr) {
/* RTM_NEWADDR */
ifa = NLMSG_DATA(nlh);
rta = IFA_RTA(ifa);
- len = NLMSG_PAYLOAD(nlh, 0); /* IFA_PAYLOAD(nlh) ???? */
+ len = IFA_PAYLOAD(nlh);
if (ifa->ifa_family != family) {
nlh = NLMSG_NEXT(nlh, ret);
@@ -224,12 +225,13 @@ int netlink_get_interface_ip(int index, int family, void *addr) {
/* write the address */
if (tb[IFA_ADDRESS] && ifa->ifa_index == index) {
- memset(addr, 0, sizeof(*addr));
switch (family) {
case AF_INET:
+ memset(addr, 0, sizeof(struct in_addr));
memcpy(addr, (struct in_addr *)RTA_DATA(tb[IFA_ADDRESS]), alen);
break;
case AF_INET6:
+ memset(addr, 0, sizeof(struct in6_addr));
memcpy(addr, (struct in6_addr *)RTA_DATA(tb[IFA_ADDRESS]), alen);
break;
}
@@ -340,15 +342,20 @@ int netlink_init_interfaces_list(void) {
/* copy the MAC addr */
memcpy(&intfinfo->mac, RTA_DATA(tb[IFLA_ADDRESS]), alen);
- /* get the IPv4 address of this interface (if any) */
- r = netlink_get_interface_ip(intfinfo->i, AF_INET, &intfinfo->ip_addr);
- if (r == -1)
- intfinfo->ip_addr.s_addr = 0;
-
- /* get the IPv6 address of this interface (if any) */
- r = netlink_get_interface_ip(intfinfo->i,AF_INET6,&intfinfo->ip6_addr);
- if (r == -1)
- memset(intfinfo->ip6_addr.s6_addr, 0, sizeof(intfinfo->ip6_addr.s6_addr));
+ if (ifi->ifi_flags & IFF_RUNNING) {
+ /* get the IPv4 address of this interface (if any) */
+ r = netlink_get_interface_ip(intfinfo->i, AF_INET, &intfinfo->ip_addr);
+ if (r == -1)
+ memset(&intfinfo->ip_addr, 0, sizeof(struct in_addr));
+
+ /* get the IPv6 address of this interface (if any) */
+ r = netlink_get_interface_ip(intfinfo->i, AF_INET6, &intfinfo->ip6_addr);
+ if (r == -1)
+ memset(&intfinfo->ip6_addr, 0, sizeof(struct in6_addr));
+ } else {
+ memset(&intfinfo->ip_addr, 0, sizeof(struct in_addr));
+ memset(&intfinfo->ip6_addr, 0, sizeof(struct in6_addr));
+ }
/* add this interface */
interfaces = g_slist_append(interfaces, intfinfo);