summaryrefslogtreecommitdiff
path: root/src/etc/netplug/linkup.d/vyos-python-helper
AgeCommit message (Collapse)Author
2026-03-19vyos-netlinkd: T8047: replace netplugdChristian Breunig
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...
2023-08-16netplug: T5476: rewrite dhclient helper from Perl -> PythonChristian Breunig
There are two hooks called for bridge, ethernet and bond interfaces if the link-state changes up -> down or down -> up. The helpers are: * /etc/netplug/linkdown.d/dhclient * /etc/netplug/linkup.d/dhclient As those helpers use Linux actions to start/restart the dhclient process in Perl it's time to rewrite it. First goal is to get rid of all Perl code and the second is that we now have a Proper Python library. Instead of checking if the process is running the then restarting it without even systemd noticing (yeah we might get two processes beeing alive) we should: * Add a Python helper that can be used for both up and down (see man 8 netplugd FILES section) * Query the VyOS CLI config if the interface in question has DHCP(v6) configured and is not disabled * Add IPv6 DHCPv6 support MAN page: https://linux.die.net/man/8/netplugd