Interface perdida após a remoção do namespace

2

Após a remoção do namespace, o Ubuntu não possui uma interface de rede, que foi anexada ao container. Não há namespaces no meu ambiente:

$ ls -la /var/run/netns/
total 0
drwxr-xr-x  2 root root  40 Sep 18 13:11 .
drwxr-xr-x 23 root root 940 Sep 18 13:21 ..

No entanto, a interface não pode ser criada:

$ sudo vconfig add eth1 268
ERROR: trying to add VLAN #268 to IF -:eth1:-  error: File exists

$ sudo ip link show eth1.268
Device "eth1.268" does not exist.

Alguma ideia de como encontrar a interface perdida? Claro que é minha culpa que eu esqueci de atribuir a interface do namespace para o netns 1 (sistema host), mas eu não acredito que tenha ido embora ...

Strace não é muito informativo:

# strace vconfig add eth1 268
execve("/sbin/vconfig", ["vconfig", "add", "eth1", "268"], [/* 16 vars */]) = 0
brk(0)                                  = 0x1742000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe6bb754000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=53226, ...}) = 0
mmap(NULL, 53226, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fe6bb747000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "7ELF
$ ls -la /var/run/netns/
total 0
drwxr-xr-x  2 root root  40 Sep 18 13:11 .
drwxr-xr-x 23 root root 940 Sep 18 13:21 ..
$ sudo vconfig add eth1 268
ERROR: trying to add VLAN #268 to IF -:eth1:-  error: File exists

$ sudo ip link show eth1.268
Device "eth1.268" does not exist.
# strace vconfig add eth1 268
execve("/sbin/vconfig", ["vconfig", "add", "eth1", "268"], [/* 16 vars */]) = 0
brk(0)                                  = 0x1742000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe6bb754000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=53226, ...}) = 0
mmap(NULL, 53226, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fe6bb747000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "7ELF%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%>%pre%%pre%%pre%%pre%P %pre%%pre%%pre%%pre%%pre%"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1840928, ...}) = 0
mmap(NULL, 3949248, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe6bb16f000
mprotect(0x7fe6bb329000, 2097152, PROT_NONE) = 0
mmap(0x7fe6bb529000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ba000) = 0x7fe6bb529000
mmap(0x7fe6bb52f000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe6bb52f000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe6bb746000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe6bb744000
arch_prctl(ARCH_SET_FS, 0x7fe6bb744740) = 0
mprotect(0x7fe6bb529000, 16384, PROT_READ) = 0
mprotect(0x601000, 4096, PROT_READ)     = 0
mprotect(0x7fe6bb756000, 4096, PROT_READ) = 0
munmap(0x7fe6bb747000, 53226)           = 0
open("/proc/net/vlan/config", O_RDONLY) = 3
close(3)                                = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
ioctl(3, SIOCSIFVLAN, 0x7ffc432b83c0)   = -1 EEXIST (File exists)
write(2, "ERROR: trying to add VLAN #268 t"..., 66ERROR: trying to add VLAN #268 to IF -:eth1:-  error: File exists
) = 66
exit_group(3)                           = ?
+++ exited with 3 +++
%pre%%pre%%pre%%pre%%pre%%pre%%pre%>%pre%%pre%%pre%%pre%P %pre%%pre%%pre%%pre%%pre%"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=1840928, ...}) = 0 mmap(NULL, 3949248, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe6bb16f000 mprotect(0x7fe6bb329000, 2097152, PROT_NONE) = 0 mmap(0x7fe6bb529000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ba000) = 0x7fe6bb529000 mmap(0x7fe6bb52f000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe6bb52f000 close(3) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe6bb746000 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe6bb744000 arch_prctl(ARCH_SET_FS, 0x7fe6bb744740) = 0 mprotect(0x7fe6bb529000, 16384, PROT_READ) = 0 mprotect(0x601000, 4096, PROT_READ) = 0 mprotect(0x7fe6bb756000, 4096, PROT_READ) = 0 munmap(0x7fe6bb747000, 53226) = 0 open("/proc/net/vlan/config", O_RDONLY) = 3 close(3) = 0 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3 ioctl(3, SIOCSIFVLAN, 0x7ffc432b83c0) = -1 EEXIST (File exists) write(2, "ERROR: trying to add VLAN #268 t"..., 66ERROR: trying to add VLAN #268 to IF -:eth1:- error: File exists ) = 66 exit_group(3) = ? +++ exited with 3 +++
    
por Mancubus 18.09.2016 / 15:31

1 resposta

1

Isso acontece quando um processo é deixado em execução no namespace depois que o namespace é removido. Você precisa parar / matar este processo antes de adicionar a mesma interface novamente. Se você não encontrar o processo, você pode procurar o nome da interface com o / proc, por exemplo:

root@linx:~# vconfig add enp1s0 10
ERROR: trying to add VLAN #10 to IF -:enp1s0:-  error: File exists

root@linx:~# find /proc/ -name enp1s0.10
/proc/18557/task/18557/net/vlan/enp1s0.10
/proc/18557/task/18557/net/dev_snmp6/enp1s0.10
/proc/18557/net/vlan/enp1s0.10
/proc/18557/net/dev_snmp6/enp1s0.10

root@linx:~# kill -9 18557

root@linx:~# vconfig add enp1s0 10
Added VLAN with VID == 10 to IF -:enp1s0:-
    
por lavira 29.11.2016 / 08:51

Tags