Not able to setup a VLAN

Removed connman per section 4 systemd-networkd.

Set up vlan per Ethernet/Network (Linux) section 4.1.2 VLAN does not result in a vlan being created.

Created “vi /etc/systemd/network/wired.network”

[Match]
Name=eth0

[Network]
DHCP=ipv4

Restarted systemd-networkd “systemctl restart systemd-networkd” and eth0 acquired ip address

Setup VLAN

Modified wired.network by adding “VLAN=eth0.100”

[Match]
Name=eth0

[Network]
DHCP=ipv4
VLAN=eth0.100

Created “/etc/systemd/network/eth0.100.netdev”

[NetDev]
Name=eth0.100
Kind=vlan

[VLAN]
Id=100

Created “/etc/systemd/network/vlan100.network”

[Match]
Name=eth0.100

[Network]
DHCP=ipv4

Cycled power on board

Following is output of journalctl -b 0 -u systemd-networkd

root@colibri-imx6:~# journalctl -b 0 -u systemd-networkd

-- Logs begin at Mon 2020-04-20 18:17:34 UTC, end at Mon 2020-04-20 19:10:11 UTC. --
Apr 20 19:09:12 colibri-imx6 systemd[1]: Starting Network Service...
Apr 20 19:09:13 colibri-imx6 systemd-networkd[505]: Enumeration completed
Apr 20 19:09:13 colibri-imx6 systemd-networkd[505]: usb0: IPv6 successfully enabled
Apr 20 19:09:13 colibri-imx6 systemd[1]: Started Network Service.
Apr 20 19:09:13 colibri-imx6 systemd-networkd[505]: eth0: Could not join netdev: Operation not supported
Apr 20 19:09:13 colibri-imx6 systemd-networkd[505]: eth0: Failed
Apr 20 19:09:13 colibri-imx6 systemd-networkd[505]: usb0: Gained carrier
Apr 20 19:09:14 colibri-imx6 systemd-networkd[505]: usb0: Gained IPv6LL
Apr 20 19:09:26 colibri-imx6 systemd-networkd[505]: usb0: Configured
Are there any other steps besides the ones listed in section 4.1.2?

Did you remove conman as stated here - https://developer.toradex.com/knowledge-base/ethernet-network-(linux)#systemdnetworkd

I removed connman. Sorry for not specifying in original post. I updated the post.

HI @Jack

Thanks for updating the post.
Could you share the files you changed/created for the VLAN?
Is the network without VLAN working correctly?

Thanks and best regards,
Jaski

I added the modified files to the post. The network without VLAN is working correctly.

Hi @Jack

Thanks for the Information. We will try to reproduce this issue and come within one week to you.

Best regards,
Jaski

Similar Problem here using torizon on imx7d.

I ping the module on the configured VLAN from another device:

  • I am about 99% sure it worked yesterday and i did not change anything!
  • device eth0.2121 with IP is showing up (ip a)
  • no connman
  • tcpdump eth0 on the module shows the tagged packets coming in
  • tcpdump eth0.2121 shows the untagged packets coming in
  • nothing is going out
  • blank eth0 ip communication works
  • ifconfig packet stats show no errors or drops

Config:

wired.network

[Match]
Name=eth0

[Network]
#DHCP=ipv4
Address=192.168.118.100/24
Address=172.17.89.99/24
Gateway=172.17.89.254

VLAN=eth0.2121

eth0.netdev

[NetDev]
Name=eth0.2121
Kind=vlan

[VLAN]
Id=2121

eth0.2121.network

[Match]
Name=eth0.2121

[Network]
Address=192.168.21.1/24

CONFIG:

root@colibri-imx7-06476989:/etc/systemd/network# zcat /proc/config.gz | grep VLAN
CONFIG_BRIDGE_EBT_VLAN=m
# CONFIG_BRIDGE_VLAN_FILTERING is not set
CONFIG_VLAN_8021Q=m
# CONFIG_VLAN_8021Q_GVRP is not set
# CONFIG_VLAN_8021Q_MVRP is not set
CONFIG_MACVLAN=y
# CONFIG_IPVLAN is not set
root@colibri-imx7-06476989:/etc/systemd/network# lsmod | grep "q"
8021q                  28672  0

further debugging:
I found out that the vlan interface gets stuck sometimes in state configuring
(networkctl status -a output)

● 5: eth0.2121
       Link File: /usr/lib/systemd/network/99-default.link
    Network File: /etc/systemd/network/eth0.2121.network
            Type: vlan
           State: routable (configuring)
          Driver: 802.1Q VLAN Support
      HW Address: 00:14:2d:62:d4:bd (Toradex AG)
         Address: 192.168.21.1
                  fe80::214:2dff:fe62:d4bd

Sometimes it jumps to configured and works with dmesg of:

[  170.882615] 8021q: 802.1Q VLAN Support v1.8
[  170.927478] A link change request failed with some changes committed already. Interface eth0.2121 may have been left with an inconsistent configuration, please check.

Anyhow i also can proof that sometimes (reboots) ping doesn’t work even networkctl outputs “configured”

My issue is solved now - sorry for commenting this much debug info.
In my case the connection problems were caused of a restarting loop of a docker container (and therefore hard to find) configured with a conflicting bridge IP range.

Hopefully the infos provided with networkctl status -a will contribute to solve @Jack 's issue.

8021q is not listed in either ‘dmesg’ or ‘lsmod | grep “q”’. Adding 8021q with ‘modprobe 8021q’ gives following result ‘modprobe: FATAL: Module 8021q not found in directory /lib/modules/4.9.166-2.8.6+gd899927728be’

Hi @Jack

I checked the default kernel config in our regular Bsp, I can confirm that the needed configs are not setup correctly. Could you enable these configs and compile a custom kernel and the kernel modules and check if this helps?

# CONFIG_VLAN_8021Q 
# CONFIG_MACVLAN

Thanks and best regards,
Jaski

Hi @m.tellian

Thanks for your valuable Input.

Best regards,
Jaski

Compiled kernel with no changes and “make -j3 uImage LOADADDR=10008000 2>&1 | tee build.log” finished with “Kernel: arch/arm/boot/uImage is ready”.

Changed vlan from above to “…=y” and compile aborts at “802.1Q/802.1ad VLAN Support (VLAN_8021Q) [Y/n/m/?] y
GVRP (GARP VLAN Registration Protocol) support (VLAN_8021Q_GVRP) [N/y/?] (NEW) aborted!”

Hi @Jack

How did you change the config?
First you need to use the command make menuconfig or make menuconfig. Then in the dialog box you can enable the configs above with their subconfigs and launch the compilation.

Starting from Bsp 2.8, we change to zImage istead of uImage, thus the compilation command would be make -j8 zImage LOADADDR=0x80008000 2>&1 | tee build.log. We will update the Documentation.

Best regards,
Jaski

I now get a vlan but do not get a DHCPv4 address for eth0.100.

I followed the instructions above and now I get the vlan but the vlan does not have a DHCPv4 address.

May 11 17:21:42 colibri-imx6 systemd-networkd[677]: eth0: Gained IPv6LL
May 11 17:21:42 colibri-imx6 systemd-networkd[677]: Enumeration completed
May 11 17:21:42 colibri-imx6 systemd[1]: Started Network Service.
May 11 17:21:42 colibri-imx6 systemd-networkd[677]: eth0.100: netdev ready
May 11 17:21:42 colibri-imx6 systemd-networkd[677]: eth0: DHCPv4 address 192.168.1.5/24 via 192.168.1.1
May 11 17:21:42 colibri-imx6 systemd-networkd[677]: eth0.100: IPv6 successfully enabled
May 11 17:21:42 colibri-imx6 systemd-networkd[677]: eth0.100: Gained carrier
May 11 17:21:44 colibri-imx6 systemd-networkd[677]: eth0.100: Gained IPv6LL
May 11 17:34:55 colibri-imx6 systemd-networkd[677]: usb0: Lost carrier
May 11 17:34:58 colibri-imx6 systemd-networkd[677]: usb0: Gained carrier

Hi @Jack

May 11 17:21:42 colibri-imx6 systemd-networkd[677]: eth0: DHCPv4 address 10.0.1.21/22 via 10.0.0.74

What is this?

What is the output of ifconfig?

I am able to set a static ipv4 address for the vlan, but not a DHCP ipv4 address.
Here is the output of ifconfig:

eth0      Link encap:Ethernet  HWaddr 00:14:2D:A1:23:E7  
          inet addr:192.168.1.5  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::214:2dff:fea1:23e7%lo/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:23 errors:0 dropped:0 overruns:0 frame:0
          TX packets:96 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3067 (2.9 KiB)  TX bytes:16208 (15.8 KiB)

eth0.100  Link encap:Ethernet  HWaddr 00:14:2D:A1:23:E7  
          inet6 addr: fe80::214:2dff:fea1:23e7%lo/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:31 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:6166 (6.0 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1%1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:105 errors:0 dropped:0 overruns:0 frame:0
          TX packets:105 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:8098 (7.9 KiB)  TX bytes:8098 (7.9 KiB)

usb0      Link encap:Ethernet  HWaddr 00:14:2D:FF:FF:FF  
          inet addr:192.168.11.1  Bcast:192.168.11.255  Mask:255.255.255.0
          inet6 addr: fe80::214:2dff:feff:ffff%lo/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:136 errors:0 dropped:0 overruns:0 frame:0
          TX packets:123 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000

Could you check your DHCP Server settings?
Are other devices in the same VLAN getting ipv4 address in DHCP mode?