Commit 1648db97 authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

kerndat: check whether ipv6 is supported or not (v2)

v2: use a cached value to dump ipv6 interface addesses
    call get_ipv6() from kerndat_init_rst too
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c0bc79d9
......@@ -24,6 +24,7 @@ struct kerndat_s {
bool has_memfd;
bool has_fdinfo_lock;
unsigned long task_size;
bool ipv6;
};
extern struct kerndat_s kdat;
......
......@@ -333,6 +333,21 @@ out:
return exit_code;
}
static int get_ipv6()
{
if (access("/proc/sys/net/ipv6", F_OK) < 0) {
if (errno == ENOENT) {
pr_debug("ipv6 is disabled\n");
kdat.ipv6 = false;
return 0;
}
pr_perror("Unable to access /proc/sys/net/ipv6");
return -1;
}
kdat.ipv6 = true;
return 0;
}
int kerndat_init(void)
{
int ret;
......@@ -348,6 +363,8 @@ int kerndat_init(void)
ret = kerndat_fdinfo_has_lock();
if (!ret)
ret = get_task_size();
if (!ret)
ret = get_ipv6();
kerndat_lsm();
......@@ -371,6 +388,8 @@ int kerndat_init_rst(void)
ret = kerndat_has_memfd_create();
if (!ret)
ret = get_task_size();
if (!ret)
ret = get_ipv6();
kerndat_lsm();
......
......@@ -25,6 +25,8 @@
#include "pstree.h"
#include "string.h"
#include "sysctl.h"
#include "kerndat.h"
#include "protobuf.h"
#include "protobuf/netdev.pb-c.h"
......@@ -641,10 +643,8 @@ static inline int dump_route(struct cr_imgset *fds)
return -1;
/* If ipv6 is disabled, "ip -6 route dump" dumps all routes */
if (access("/proc/sys/net/ipv6/", F_OK)) {
pr_debug("ipv6 is disabled\n");
if (!kdat.ipv6)
return 0;
}
img = img_from_set(fds, CR_FD_ROUTE6);
if (run_ip_tool("-6", "route", "save", -1, img_raw_fd(img), 0))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment