diff options
author | David Cantrell <dcantrell@redhat.com> | 2007-09-05 14:52:02 +0000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2007-09-05 14:52:02 +0000 |
commit | 05f84e3164b2e997c968a2ca07e42d5c4728116b (patch) | |
tree | 73bd5f09de7d6522bed276d18d2772bbd880d432 /isys | |
parent | 5e226ea2fd15260a3bdb14c8e8d8c3e6b2d6e80a (diff) | |
download | anaconda-05f84e3164b2e997c968a2ca07e42d5c4728116b.tar.gz anaconda-05f84e3164b2e997c968a2ca07e42d5c4728116b.tar.xz anaconda-05f84e3164b2e997c968a2ca07e42d5c4728116b.zip |
* isys/nl.c (netlink_get_interface_ip): Do not read just 4K for each
recvfrom() loop iteration. This ensures we get the entire netlink
message and information about all NICs in the system, not just the
first 10 or 13 or so.
Diffstat (limited to 'isys')
-rw-r--r-- | isys/nl.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -257,7 +257,7 @@ int netlink_get_interface_ip(int index, int family, void *addr) { * @return 0 on succes, -1 on error. */ int netlink_init_interfaces_list(void) { - int sock, len, alen, r, bufsz, havemsg, namelen; + int sock, len, alen, r, bufsz, readsz, havemsg, namelen; char *buf = NULL; struct nlmsghdr *nlh; struct ifinfomsg *ifi; @@ -291,18 +291,20 @@ int netlink_init_interfaces_list(void) { } havemsg = 0; + readsz = BUFSZ; while (!havemsg) { - bufsz = recvfrom(sock, buf, BUFSZ, 0, NULL, 0); + bufsz = recvfrom(sock, buf, readsz, 0, NULL, 0); if (bufsz < 0) { perror("recvfrom in netlink_init_interfaces_list"); close(sock); return -1; - } else if (bufsz > BUFSZ) { + } else if (bufsz > readsz) { free(buf); buf = NULL; - if ((buf = calloc(bufsz, sizeof(char))) == NULL) { + readsz = bufsz; + if ((buf = calloc(readsz, sizeof(char))) == NULL) { perror("calloc on 2nd buf in netlink_init_interfaces_list"); close(sock); return -1; |