The code will need to allocate twice as much ifaddr_storage structure to be able to return mac addresses in their own ifaddrs structure.
Signed-off-by: Benoît Canet <ben...@scylladb.com> --- libc/network/getifaddrs.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/libc/network/getifaddrs.c b/libc/network/getifaddrs.c index a14ac1b..7bab121 100644 --- a/libc/network/getifaddrs.c +++ b/libc/network/getifaddrs.c @@ -112,18 +112,27 @@ static void dealwithipv6(stor **list, stor** head) fclose(f); } +int allocate_and_add_ifaddrs(stor **list, stor **head, struct if_nameindex *ii) +{ + size_t i; + for(i = 0; ii[i].if_index || ii[i].if_name; i++) { + stor* curr = list_add(list, head, ii[i].if_name); + if(!curr) { + return 0; + } + } + return i; +} + int getifaddrs(struct ifaddrs **ifap) { stor *list = 0, *head = 0; struct if_nameindex* ii = if_nameindex(); if(!ii) return -1; size_t i; - for(i = 0; ii[i].if_index || ii[i].if_name; i++) { - stor* curr = list_add(&list, &head, ii[i].if_name); - if(!curr) { - if_freenameindex(ii); - goto err2; - } + if (!allocate_and_add_ifaddrs(&list, &head, ii)) { + if_freenameindex(ii); + goto err2; } if_freenameindex(ii); -- 2.7.4 -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.