canonical / lxd

Powerful system container and virtual machine manager
https://canonical.com/lxd
GNU Affero General Public License v3.0
4.38k stars 931 forks source link

Fail to generate lxdbr0 on lxd init #7207

Closed jyte closed 4 years ago

jyte commented 4 years ago

Required information

Issue description

Issue 1:

When I do lxd init it fails to create the bridge lxdbr0.

Extracted from syslog :

Apr 16 18:33:51 ubuntu lxd.daemon[8410]: t=2020-04-16T18:33:51+0000 lvl=warn msg="Failed getting list of tables from \"/proc/self/net/ip_tables_names\", assuming all requested tables exist"

I noticed I do not have a /proc/self/net/ip_tables_names file. But I have no clue how to get it, or if it is ok not to have it on ubuntu 20.04.

Issue 2:

Because creating the bridge failed, but it got registered in lxd, I have to do lxc network delete lxdbr0 before trying lxd init again or it tells me the device already exist. Which is wrong because as the creation failed, it never existed.

tomponline commented 4 years ago

That warning should not prevent the bridge from being created, in fact the fact it exists and you have to remove it suggests it is being created.

What is the actual error or problem that is occuring? Thanks

jyte commented 4 years ago

I have read that it can happen that the bridge does not exist, and yet be registered in lxd according to this thread and that is how i found about the lxc network delete command.

ip a doesn't list the bridge.

$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether dc:a6:32:6e:b2:bc brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.20/24 brd 192.168.0.255 scope global dynamic eth0
       valid_lft 86349sec preferred_lft 86349sec
    inet6 fe80::dea6:32ff:fe6e:b2bc/64 scope link 
       valid_lft forever preferred_lft forever

here is the full output of lxd init

$ lxd init
Would you like to use LXD clustering? (yes/no) [default=no]: 
Do you want to configure a new storage pool? (yes/no) [default=yes]: 

Name of the new storage pool [default=default]: Name of the storage backend to use (dir, lvm, ceph, btrfs) [default=btrfs]: 
Create a new BTRFS pool? (yes/no) [default=yes]: 
Would you like to use an existing block device? (yes/no) [default=no]: 
Size in GB of the new loop device (1GB minimum) [default=91GB]: 
Would you like to connect to a MAAS server? (yes/no) [default=no]: 
Would you like to create a new local network bridge? (yes/no) [default=yes]: 
What should the new bridge be called? [default=lxdbr0]: 
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: 
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: 
Would you like LXD to be available over the network? (yes/no) [default=no]: 
Would you like stale cached images to be updated automatically? (yes/no) [default=yes] 
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: 

Error: Failed to create network 'lxdbr0': Failed to list IPv4 rules for LXD network lxdbr0 (table filter)
tomponline commented 4 years ago

Thanks for that I will take a look. The error suggests you havent got iptables or nftables available though.

stgraber commented 4 years ago

Yeah, this suggests a kernel without the needed netfilter modules, LXD appears to be correct to fail in this case.

Closing as it's unlikely to be LXD bug, we can still chat about it though.

@jyte please run lxd.check-kernel

jyte commented 4 years ago
$ lxd.check-kernel
Kernel configuration not found at /proc/config.gz; searching...
Kernel configuration found at /boot/config-5.4.0-1008-raspi
--- Namespaces ---
Namespaces: enabled
Utsname namespace: enabled
Ipc namespace: enabled
Pid namespace: enabled
User namespace: enabled
newuidmap is not installed
newgidmap is not installed
Network namespace: enabled

--- Control groups ---
Cgroups: enabled

Cgroup v1 mount points: 
/sys/fs/cgroup/systemd
/sys/fs/cgroup/cpu,cpuacct
/sys/fs/cgroup/rdma
/sys/fs/cgroup/cpuset
/sys/fs/cgroup/net_cls,net_prio
/sys/fs/cgroup/blkio
/sys/fs/cgroup/devices
/sys/fs/cgroup/perf_event
/sys/fs/cgroup/pids
/sys/fs/cgroup/freezer

Cgroup v2 mount points: 
/sys/fs/cgroup/unified

Cgroup v1 clone_children flag: enabled
Cgroup device: enabled
Cgroup sched: enabled
Cgroup cpu account: enabled
Cgroup memory controller: enabled
Cgroup cpuset: enabled

--- Misc ---
Veth pair device: enabled, not loaded
Macvlan: enabled, not loaded
Vlan: enabled, not loaded
Bridges: enabled, not loaded
Advanced netfilter: enabled, not loaded
CONFIG_NF_NAT_IPV4: missing
CONFIG_NF_NAT_IPV6: missing
CONFIG_IP_NF_TARGET_MASQUERADE: enabled, not loaded
CONFIG_IP6_NF_TARGET_MASQUERADE: enabled, not loaded
CONFIG_NETFILTER_XT_TARGET_CHECKSUM: enabled, not loaded
CONFIG_NETFILTER_XT_MATCH_COMMENT: enabled, not loaded
FUSE (for use with lxcfs): enabled, not loaded

--- Checkpoint/Restore ---
checkpoint restore: enabled
CONFIG_FHANDLE: enabled
CONFIG_EVENTFD: enabled
CONFIG_EPOLL: enabled
CONFIG_UNIX_DIAG: enabled
CONFIG_INET_DIAG: enabled
CONFIG_PACKET_DIAG: enabled
CONFIG_NETLINK_DIAG: enabled
File capabilities: 

Note : Before booting a new kernel, you can check its configuration
usage : CONFIG=/path/to/config /snap/lxd/14659/bin/lxc-checkconfig
stgraber commented 4 years ago

Right so your current kernel has no support for ipv4/ipv6 NAT which is required for LXD bridges.

edacval commented 4 years ago

Right so your current kernel has no support for ipv4/ipv6 NAT which is required for LXD bridges.

lxc-checkconfig NAT detection is not working properly since this commit : uname -r 5.4.32-1-lts , lxc version 4.0.2

zgrep -i nf_nat /proc/config.gz
CONFIG_NF_NAT=m
CONFIG_NF_NAT_AMANDA=m
CONFIG_NF_NAT_FTP=m
CONFIG_NF_NAT_IRC=m
CONFIG_NF_NAT_SIP=m
CONFIG_NF_NAT_TFTP=m
CONFIG_NF_NAT_REDIRECT=y
CONFIG_NF_NAT_MASQUERADE=y
CONFIG_NF_NAT_SNMP_BASIC=m
CONFIG_NF_NAT_PPTP=m
CONFIG_NF_NAT_H323=m
CONFIG_IP_NF_NAT=m
CONFIG_IP6_NF_NAT=m
stgraber commented 4 years ago

Ah, good point.

Still the error above shows a lack of netfilter on the system.

@jyte can you show (all run as root):

jyte commented 4 years ago
# lsmod
Module                  Size  Used by
hid_generic            16384  0
usbhid                 73728  0
scsi_dh_rdac           16384  0
scsi_dh_emc            16384  0
scsi_dh_alua           24576  0
drm                   569344  0
btrfs                1425408  0
zstd_compress         163840  1 btrfs
raid10                 73728  0
raid456               192512  0
async_raid6_recov      20480  1 raid456
async_memcpy           20480  2 raid456,async_raid6_recov
async_pq               20480  2 raid456,async_raid6_recov
async_xor              20480  3 async_pq,raid456,async_raid6_recov
async_tx               20480  5 async_pq,async_memcpy,async_xor,raid456,async_raid6_recov
xor                    20480  2 async_xor,btrfs
xor_neon               16384  1 xor
raid6_pq              114688  4 async_pq,btrfs,raid456,async_raid6_recov
libcrc32c              16384  2 btrfs,raid456
raid1                  53248  0
raid0                  24576  0
multipath              24576  0
linear                 20480  0
crct10dif_ce           16384  1
spidev                 28672  0
phy_generic            20480  0
uas                    32768  0
usb_storage            81920  2 uas
aes_neon_bs            28672  1
aes_neon_blk           32768  1 aes_neon_bs
crypto_simd            20480  2 aes_neon_bs,aes_neon_blk
cryptd                 24576  1 crypto_simd
# iptables -L -n -v
modprobe: FATAL: Module ip_tables not found in directory /lib/modules/5.4.0-1008-raspi
iptables v1.8.4 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
# ip6tables -L -n -v
modprobe: FATAL: Module ip6_tables not found in directory /lib/modules/5.4.0-1008-raspi
ip6tables v1.8.4 (legacy): can't initialize ip6tables table `filter': Table does not exist (do you need to insmod?)
Perhaps ip6tables or your kernel needs to be upgraded.