我最近才開始使用 VLAN 核心功能,並發現了一個相當具有挑戰性的領域。
我以為我幾乎掌控了一切,但後來發現了一個我顯然無法解決的問題。
我有一些自動腳本負責創建和銷毀一些網路命名空間它必須將使用者網域彼此隔離。
在我的一台伺服器中,這個腳本已經正常工作了 2 個月,但今天突然開始以一種非常奇怪的方式出現異常。核心版本是3.13.0-24-通用運行在Ubuntu 14.04 LTS。
這是目前的情況:
cat /proc/net/vlan/config
VLAN Dev name | VLAN ID
Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
所以那裡什麼都沒有。
ip netns ls
TEST
那是我的命名空間仍然存在。
ip netns exec TEST cat /proc/net/vlan/config
VLAN Dev name | VLAN ID
Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
tap0.105 | 105 | tap0
我在此域中定義了一個虛擬標記接口,該接口已正確配置並正確運行。
ip netns exec TEST ip addr
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
92: tap0.105@if12: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
noqueue state UP group default
link/ether 5a:ff:b5:98:6f:c2 brd ff:ff:ff:ff:ff:ff
inet 172.16.51.1/32 scope global tap0.105
valid_lft forever preferred_lft forever
inet6 fe80::58ff:b5ff:fe98:6fc2/64 scope link
valid_lft forever preferred_lft forever
那麼問題來了:
vconfig add eth1 10
ERROR: trying to add VLAN #10 to IF -:eth1:- error: File exists
而且當然:
vconfig rem eth1.10
ERROR: trying to remove VLAN -:eth1.10:- error: No such device
我嘗試在網路上尋找類似的錯誤案例,但沒有成功。其他一些輸出:
ip netns pids TEST
沒有給出任何結果。
這是指令的 STACE:
root@d-intfw1:~# strace vconfig add eth1 10 execve("/sbin/vconfig", ["vconfig", "add", "eth1", "10"], [/* 17 vars */]) = 0 brk(0) = 0x1a2a000 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) = 0x7f361112c000 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=24418, ...}) = 0 mmap(NULL, 24418, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f3611126000 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, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\37\2\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=1845024, ...}) = 0 mmap(NULL, 3953344, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f3610b46000 mprotect(0x7f3610d02000, 2093056, PROT_NONE) = 0 mmap(0x7f3610f01000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bb000) = 0x7f3610f01000 mmap(0x7f3610f07000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f3610f07000 close(3) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3611125000 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3611123000 arch_prctl(ARCH_SET_FS, 0x7f3611123740) = 0 mprotect(0x7f3610f01000, 16384, PROT_READ) = 0 mprotect(0x601000, 4096, PROT_READ) = 0 mprotect(0x7f361112e000, 4096, PROT_READ) = 0 munmap(0x7f3611126000, 24418) = 0 open("/proc/net/vlan/config", O_RDONLY) = 3 close(3) = 0 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3 ioctl(3, SIOCSIFVLAN, 0x7fffeead1420) = -1 EEXIST (File exists) write(2, "ERROR: trying to add VLAN #10 to"..., 65ERROR: trying to add VLAN #10 to IF -:eth1:- error: File exists ) = 65 exit_group(3) = ? +++ exited with 3 +++
有誰知道這種行為的原因可能是什麼?多謝。