#include "config.h"
#include "confile.h"
#include "confile_utils.h"
+#include <../include/netns_ifaddrs.h>
#include "log.h"
#include "lxcseccomp.h"
#include "network.h"
#include "storage.h"
#include "utils.h"
-#if HAVE_IFADDRS_H
-#include <ifaddrs.h>
-#else
-#include <../include/ifaddrs.h>
-#endif
-
#if HAVE_SYS_PERSONALITY_H
#include <sys/personality.h>
#endif
static int create_matched_ifnames(const char *value, struct lxc_conf *lxc_conf,
struct lxc_netdev *netdev)
{
- struct ifaddrs *ifaddr, *ifa;
+ struct netns_ifaddrs *ifaddr, *ifa;
int n;
int ret = 0;
const char *type_key = "lxc.net.type";
const char *link_key = "lxc.net.link";
const char *tmpvalue = "phys";
- if (getifaddrs(&ifaddr) == -1) {
+ if (netns_getifaddrs(&ifaddr, -1, &(bool){false}) < 0) {
SYSERROR("Get network interfaces failed");
return -1;
}
}
}
- freeifaddrs(ifaddr);
+ netns_freeifaddrs(ifaddr);
ifaddr = NULL;
return ret;
#include "confile_utils.h"
#include "criu.h"
#include "error.h"
+#include <../include/netns_ifaddrs.h>
#include "initutils.h"
#include "log.h"
#include "lxc.h"
#include <sys/mkdev.h>
#endif
-#if HAVE_IFADDRS_H
-#include <ifaddrs.h>
-#else
-#include <../include/ifaddrs.h>
-#endif
-
#if IS_BIONIC
#include <../include/lxcmntent.h>
#else
if (pid == 0) { /* child */
int ret = 1, nbytes;
- struct ifaddrs *interfaceArray = NULL, *tempIfAddr = NULL;
+ struct netns_ifaddrs *interfaceArray = NULL, *tempIfAddr = NULL;
/* close the read-end of the pipe */
close(pipefd[0]);
}
/* Grab the list of interfaces */
- if (getifaddrs(&interfaceArray)) {
+ if (netns_getifaddrs(&interfaceArray, -1, &(bool){false})) {
SYSERROR("Failed to get interfaces list");
goto out;
}
out:
if (interfaceArray)
- freeifaddrs(interfaceArray);
+ netns_freeifaddrs(interfaceArray);
/* close the write-end of the pipe, thus sending EOF to the reader */
close(pipefd[1]);
int ret = 1;
char *address = NULL;
void *tempAddrPtr = NULL;
- struct ifaddrs *interfaceArray = NULL, *tempIfAddr = NULL;
+ struct netns_ifaddrs *interfaceArray = NULL, *tempIfAddr = NULL;
/* close the read-end of the pipe */
close(pipefd[0]);
}
/* Grab the list of interfaces */
- if (getifaddrs(&interfaceArray)) {
+ if (netns_getifaddrs(&interfaceArray, -1, &(bool){false})) {
SYSERROR("Failed to get interfaces list");
goto out;
}
out:
if (interfaceArray)
- freeifaddrs(interfaceArray);
+ netns_freeifaddrs(interfaceArray);
/* close the write-end of the pipe, thus sending EOF to the reader */
close(pipefd[1]);
#include "af_unix.h"
#include "conf.h"
#include "config.h"
+#include <../include/netns_ifaddrs.h>
#include "file_utils.h"
#include "log.h"
#include "macro.h"
#include "nl.h"
#include "utils.h"
-#if HAVE_IFADDRS_H
-#include <ifaddrs.h>
-#else
-#include <../include/ifaddrs.h>
-#endif
-
#ifndef HAVE_STRLCPY
#include "include/strlcpy.h"
#endif
char *lxc_mkifname(char *template)
{
int ret;
- struct ifaddrs *ifa, *ifaddr;
+ struct netns_ifaddrs *ifa, *ifaddr;
char name[IFNAMSIZ];
bool exists = false;
size_t i = 0;
return NULL;
/* Get all the network interfaces. */
- ret = getifaddrs(&ifaddr);
+ ret = netns_getifaddrs(&ifaddr, -1, &(bool){false});
if (ret < 0) {
SYSERROR("Failed to get network interfaces");
return NULL;
break;
}
- freeifaddrs(ifaddr);
+ netns_freeifaddrs(ifaddr);
(void)strlcpy(template, name, strlen(template) + 1);
return template;
#include <lxc/lxccontainer.h>
#include "arguments.h"
+#include "../../include/netns_ifaddrs.h"
#include "log.h"
#include "utils.h"
-#if HAVE_IFADDRS_H
-#include <ifaddrs.h>
-#else
-#include "../include/ifaddrs.h"
-#endif
-
lxc_log_define(lxc_device, lxc);
static bool is_interface(const char *dev_name, pid_t pid);
}
if (p == 0) {
- struct ifaddrs *interfaceArray = NULL, *tempIfAddr = NULL;
+ struct netns_ifaddrs *interfaceArray = NULL, *tempIfAddr = NULL;
if (!switch_to_ns(pid, "net")) {
ERROR("Failed to enter netns of container");
}
/* Grab the list of interfaces */
- if (getifaddrs(&interfaceArray)) {
+ if (netns_getifaddrs(&interfaceArray, -1, &(bool){false})) {
ERROR("Failed to get interfaces list");
_exit(-1);
}