diff options
| author | Christian Breunig <christian@breunig.cc> | 2025-11-07 22:05:59 +0100 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2026-03-19 22:37:45 +0100 |
| commit | b84bdbf8dd25995aa564081632de6251ecf5ad4e (patch) | |
| tree | 86452996c6cdbe5b17e6fb3187b6aa176e096e9a /src/systemd | |
| parent | 653857bfa8dcf8290da0daddfe231127befc271b (diff) | |
| download | vyos-1x-b84bdbf8dd25995aa564081632de6251ecf5ad4e.tar.gz vyos-1x-b84bdbf8dd25995aa564081632de6251ecf5ad4e.zip | |
vyos-netlinkd: T8047: replace netplugd
Implementing a daemon that listens for netlink messages in Python was discussed
for many years. This is a proof-of-concept implementation how we can listen for
netlink messages and process them in Python.
Python 3.10 minimum is required due to the use of case statements which mimics
C-style switch/case instructions.
Add example:
set interfaces ethernet eth1 vif 21 address dhcp
set interfaces ethernet eth1 vif 21 address dhcpv6
commit
If network cable is unplugged:
vyos-netlinkd[12681]: RTM_NEWLINK -> eth3.10, state=DOWN, mac=00:50:56:b3:9d:8e
vyos-netlinkd[12681]: Stopping dhclient@eth3.10.service...
vyos-netlinkd[12681]: Stopping dhcp6c@eth3.10.service...
If cable is plugged back in:
vyos-netlinkd[12681]: RTM_NEWLINK -> eth3.10, state=DOWN, mac=00:50:56:b3:9d:8e
vyos-netlinkd[12681]: RTM_NEWLINK -> eth3.10, state=UP, mac=00:50:56:b3:9d:8e
vyos-netlinkd[12681]: Restarting dhclient@eth3.10.service...
vyos-netlinkd[12681]: Restarting dhcp6c@eth3.10.service...
Diffstat (limited to 'src/systemd')
| -rw-r--r-- | src/systemd/netplug.service | 9 | ||||
| -rw-r--r-- | src/systemd/vyos-netlinkd.service | 25 |
2 files changed, 25 insertions, 9 deletions
diff --git a/src/systemd/netplug.service b/src/systemd/netplug.service deleted file mode 100644 index 928c553e8..000000000 --- a/src/systemd/netplug.service +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=Network cable hotplug management daemon -Documentation=man:netplugd(8) -After=vyos-router.service - -[Service] -Type=forking -PIDFile=/run/netplugd.pid -ExecStart=/sbin/netplugd -c /etc/netplug/netplugd.conf -p /run/netplugd.pid diff --git a/src/systemd/vyos-netlinkd.service b/src/systemd/vyos-netlinkd.service new file mode 100644 index 000000000..6c8a80878 --- /dev/null +++ b/src/systemd/vyos-netlinkd.service @@ -0,0 +1,25 @@ +[Unit] +Description=VyOS netlink daemon + +# Without this option, lots of default dependencies are added, +# among them network.target, which creates a dependency cycle +DefaultDependencies=no + +# Seemingly sensible way to say "as early as the system is ready" +# All vyos-netlinkd needs is read/write mounted root +After=systemd-remount-fs.service vyos-router.service + +[Service] +ExecStart=/usr/bin/python3 -u /usr/libexec/vyos/services/vyos-netlinkd +Type=simple + +SyslogIdentifier=vyos-netlinkd +SyslogFacility=daemon + +Restart=on-failure + +User=root +Group=vyattacfg + +[Install] +WantedBy=vyos.target |
