systemd / systemd

The systemd System and Service Manager
https://systemd.io
GNU General Public License v2.0
13.28k stars 3.8k forks source link

systemd-networkd doesn't work with the "ConfigureWithoutCarrier" setting. #33824

Closed panwarpankaj2005 closed 3 months ago

panwarpankaj2005 commented 3 months ago

systemd version the issue has been seen with

250.5

Used distribution

Yocto 4.0 (Kirkstone)

Linux kernel version used

5.15.137-intel-pk-standard

CPU architectures issue was seen on

x86_64

Component

systemd-networkd

Expected behaviour you didn't see

Systemd Version:

root@edge:~# systemctl --version
systemd 250 (250.5+)
-PAM -AUDIT -SELINUX -APPARMOR +IMA -SMACK +SECCOMP -GCRYPT -GNUTLS -OPENSSL +ACL +BLKID -CURL -ELFUTILS -FIDO2 -IDN2 -IDN -IPTC +KMOD -LIBCRYPTSETUP +LIBFDISK -PCRE2 -PWQUALITY -P11KIT -QRENCODE -BZIP2 -LZ4 -XZ -ZLIB +ZSTD -BPF_FRAMEWORK +XKBCOMMON +UTMP +SYSVINIT default-hierarchy=hybrid

I am using the below network file for configuring one of my ethernet ports.

root@edge:~# cat /etc/systemd/network/10-wired.network
[Match]
MACAddress=cc:82:7f:20:a2:b5

[Network]
Address=169.254.1.2/24
ConfigureWithoutCarrier=true
IgnoreCarrierLoss=true
KeepConfiguration=true

I was expecting that even if no cable (with active link) was connected to this ethernet port during bootup, the ip address 169.254.1.2 would still be assigned to this ethernet port due to the above configuration.

Unexpected behaviour you saw

If an active link cable isn't connected to this port during the boot, then no ip was assigned to this port which causes nginx server to fail to start as it needs that port to be up with the configured IP Address (with or without cable connected). Without nginx server up and running all other apps depending on nginx also fail.

Unfortunately, I don't have the control or power to change the current design of nginx needing this ip address to start.

Output of ifconfig:

enp3s0    Link encap:Ethernet  HWaddr CC:82:7F:20:A2:B5
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Memory:91100000-911fffff

Output of networkctl:

● 3: enp3s0
                     Link File: /lib/systemd/network/99-default.link
                  Network File: /etc/systemd/network/10-wired.network
                          Type: ether
                         State: no-carrier (configuring)
                  Online state: offline
                          Path: pci-0000:03:00.0
                        Driver: igb
                        Vendor: Intel Corporation
                         Model: I210 Gigabit Network Connection
              Hardware Address: cc:82:7f:20:a2:b5 (Advantech Technology (CHINA) Co., Ltd.)
                           MTU: 1500 (min: 68, max: 9216)
                         QDisc: mq
  IPv6 Address Generation Mode: eui64
          Queue Length (Tx/Rx): 8/8
              Auto negotiation: yes
                         Speed: n/a
                          Port: tp
             Activation Policy: up
           Required For Online: yes
             DHCP6 Client DUID: DUID-EN/Vendor:0000ab11766f6e3c29a641240000

Jul 23 18:02:11 edge systemd-networkd[324]: enp3s0: Link UP

Steps to reproduce the problem

No response

Additional program output to the terminal or log subsystem illustrating the issue

No response

yuwata commented 3 months ago

DuplicateAddressDetection= is enabled by default for IPv4 link-local addresses (169.254.0.0/16), and IPv4ACD requires the interface has its carrier. Please use something like the following:

[Address]
Address=169.254.1.2/24
DuplicateAddressDetection=none

See https://www.freedesktop.org/software/systemd/man/latest/systemd.network.html#DuplicateAddressDetection= .