summaryrefslogtreecommitdiff
path: root/python
AgeCommit message (Collapse)Author
2026-11-13Merge pull request #5628 from natali-rs1985/T9568rollingJohn Estabrook
remote: T9568: Do not send HTTP credentials to another host after a redirect
2026-11-12Merge pull request #5558 from jestabro/commit-confirm-timerViacheslav Hletenko
T9446: start commit-confirm timer after commit completes in the case 'reload'
2026-11-10Merge pull request #5636 from jestabro/perms-write-fileJohn Estabrook
T9590: fix order of set perms/ownership and first write in utils write_file
2026-11-09utils: T9590: set perms/ownership before first write in write_fileJohn Estabrook
2026-11-08Merge pull request #5526 from yzguy/wwan-static-bearer-addressingChristian Breunig
wwan: T9388: apply a static bearer's address/gateway/DNS directly instead of DHCP(v6)/SLAAC
2026-11-08wwan: T9388: import wait_for() only where the bearer is polledChristian Breunig
Every interface script loads the WWAN interface class, but only polling the bearer of a modem needs wait_for(). Import it there, as the WWAN helpers already do.
2026-11-08wwan: T9388: import the WWAN route helpers only where they are usedChristian Breunig
The configuration dictionary helpers are imported by nearly every configuration script, but only the collection of WWAN default routes needs the WWAN helpers and the XML default values. Import them there instead of at module level.
2026-11-08wwan: T9388: import tempfile only when recording bearer stateChristian Breunig
The WWAN helpers imported tempfile at module level, which loads shutil, random and the bz2/lzma/zlib modules. As these helpers are imported by the configuration dictionary helpers, every process importing those paid about 2 ms for it, although only writing the bearer state needs it.
2026-11-08Merge pull request #5634 from natali-rs1985/T9588Christian Breunig
http-api: T9588: Keep config strings out of world-readable /tmp
2026-11-08utils: T9322: simplify address assignment lookup and document ValueErrorChristian Breunig
The lookup for an address on all interfaces carried a copy of the zone index and VRF filtering that already exists in the lookup returning the matching interfaces. It now delegates to it, so the two cannot drift. The per-interface address match is written as a single condition, the comments are trimmed, and the docstrings state that anything but a single address raises ValueError instead of being reported as not assigned. The sflow zone index smoketest removes the dummy interface it creates, and the unit tests drop a stale task reference and a duplicate import.
2026-11-08utils: T9322: reject addresses that are not a single address and honour zone ↵Ruben Herold
indexes The helper that tells whether an address is assigned to an interface accepted ranges and addresses with a zone index. A range ended in a traceback. A zone index was ignored, so an address on the loopback interface was reported as assigned to the interface named in the zone. The helper now rejects everything that is not a single address, a zone index included. The functions that look for an address on all interfaces use the zone to pick the one interface to check, so a zone that names an interface which does not hold the address is no longer accepted. The command that lists the addresses is passed as a list, so the interface name and the namespace do not reach a shell. Unit tests and a smoketest cover the cases.
2026-11-07wwan: T9388: tidy up reading the default route optionsChristian Breunig
Import default_value() at module level instead of once per WWAN interface, and share the dhcp-options path of both route options so the lines stay within the line length. No functional change.
2026-11-07wwan: T9388: work out the bearer address families in one placeChristian Breunig
Which address families an interface takes from its bearer was derived from "address dhcp", "address dhcpv6" and "ipv6 address autoconf" in three places: the connect options, the FRR default routes and the re-apply after a re-dial. Share a single helper so they cannot drift apart. No functional change.
2026-11-07wwan: T9388: add and remove a bearer's address via the common helpersChristian Breunig
The address of a static bearer was added and removed with hand-written ip commands, duplicating the assigned check, the IPv4 broadcast and the address cache of the generic interface code. Use add_addr() and del_addr() instead. No functional change.
2026-11-07wwan: T9388: honour no-default-route for the IPv6 route of a bearerChristian Breunig
"dhcp-options no-default-route" only suppressed the IPv4 default route of a static bearer, and only with "address dhcp" configured, as the option is dropped from the interface config otherwise. The IPv6 route was always installed. The option now suppresses both routes, as it does for PPPoE, regardless of which address family is configured.
2026-11-07wwan: T9388: drop a stale DHCP router once a static bearer appliesChristian Breunig
An interface with "address dhcp" contributes a DHCP default route next to the one of its static bearer. The DHCP one is built from the router of the last lease event, which is only cleared by a STOP event. A client which ended up failed never sends one, so a router from an earlier lease added a second default route towards a stale gateway. The record of the last lease event is now removed when a static bearer takes over IPv4.
2026-11-07wwan: T9388: always stop the DHCP(v6) client for a static bearerChristian Breunig
The client was only stopped after asking systemd whether it was running at all. Stopping an inactive unit does nothing, so the query is dropped. This also removes the configuration a client left behind when it ended up failed, which the query skipped.
2026-11-07wwan: T9388: do not retry a family the network does not supplyChristian Breunig
After a re-dial, a configured family the connected bearer had no settings for was reported as incomplete. On a network without IPv6 this was retried on the next ten reconcile passes, restarting the DHCPv6 client or SLAAC each time, and then logged as given up - on every re-dial. A family the connected bearer does not supply is now settled with the configured fallback. Only a missing bearer or a static one without an address is retried.
2026-11-07wwan: T9388: stop waiting for a bearer which cannot completeChristian Breunig
The bearer settings of a family were polled for up to five seconds whenever they were missing. Without a connected bearer, or on a network that only supplies one family, they never arrive, so every such commit waited out the timeout once per configured family. Only wait while the connected bearer has no settings for either family yet.
2026-11-07wwan: T9388: simplify waiting for the bearer methodChristian Breunig
Keep the polled bearer and method in plain variables via nonlocal, as the modem index lookup already does, instead of a result dict. No functional change.
2026-11-07wwan: T9388: apply a bearer's settings only for the static methodChristian Breunig
Every bearer method other than dhcp was handled as static, including unknown. ModemManager reports the address and prefix of such a bearer as "--", which was then installed as "--/--" and aborted the commit. Only a static bearer is applied now, any other method falls back to the DHCP(v6) client or SLAAC, and a placeholder address or prefix counts as missing.
2026-11-07wwan: T9388: apply a static bearer's address/gateway/DNS directlyAdam Smith
QMI raw-ip modems get their address, gateway and DNS from ModemManager as a "static" bearer instead of over a DHCP(v6) or Router Advertisement exchange, so "address dhcp", "address dhcpv6" and "ipv6 address autoconf" never produced a usable config and only worked for IPv4 by accident. Check the interface's connected bearer first. If its method for the family is static, apply it directly; if it is dhcp, or there is no bearer yet, fall through to the existing DHCP(v6) client / kernel SLAAC unchanged. - Address and DNS are applied from the bearer. DNS is registered with vyos-hostsd under the same dhcp-<if>/dhcpv6-<if> tags a real client uses. A DHCP(v6) client which was started while the bearer was still missing, including one which keeps restarting, is stopped before the settings are applied. - The default route is rendered into FRR as a tag 210 static route, the same way a DHCP one is. WWANIf records the gateway of the bearer in /run/vyos-wwan, which the new get_wwan_router() filter reads, and a new block in staticd.frr.j2 fed by get_wwan_interfaces() renders the IPv4 and IPv6 default routes. Distance, no-default-route and VRFs behave as for DHCP, also for an interface without "address dhcp". frrender notices a gateway change, and WWANIf reconciles FRR with vyos-frr-render.py whenever the recorded gateway changes, the way the dhclient lease hook does, so op-mode reconnect is covered as well. The state is written atomically, as the renderer reads it concurrently. - The address installed from the bearer is recorded in /run/vyos-wwan too. It is removed on reconnect, when the family is no longer configured and when the interface goes away, and nothing else on the interface is ever touched. - vyos-netlinkd applies the bearer again after it re-dials a lost session, as the new session can come back with a different address or gateway. A DHCP client used to pick that up on its own. What a previous session left behind is dropped for a family the new one does not supply, the configured DHCP(v6) client or SLAAC is started for it as a commit would, and an incomplete result is retried on the following reconcile passes for a while. - The bearer is picked by its connected status rather than bearers[0], and its config is polled briefly with wait_for() until it is no longer missing or a placeholder, since it can be populated slightly after the bearer reports connected.
2026-11-06http-api: T9588: Keep config strings out of world-readable /tmpNataliia Solomko
The /config-file endpoint wrote config strings to /tmp/config.file, readable by any local user and never removed. A file pre-created at that path by another user made every later request fail. The string now goes to a private temp file that is always removed. The load and merge helpers, and the vyconf session, also remove their own /tmp copy when loading raises, e.g. on a syntax error.
2026-11-06Merge pull request #5631 from c-po/T9559Viacheslav Hletenko
https: T9559: fix bogus port conflict with "vrf default"
2026-11-05qos: T6393: police ingress traffic before redirecting itChristian Breunig
With an ingress limiter and "redirect" on the same interface, the redirect filter was evaluated first and took all traffic, so the limiter never applied. The limiter filters of such an interface now redirect the traffic after policing it: what exceeds the rate is handled by "exceed", conforming traffic is redirected. A "not-exceed ok" is passed on to the redirect instead of ending the actions. The interface's own redirect filter moves to the lowest priority and only catches traffic no limiter class matched; an interface commit only replaces that filter and keeps the limiter in place.
2026-11-05qos: T6393: keep redirect filter when applying an ingress policyChristian Breunig
An interface with both an ingress QoS policy and "redirect" lost its redirect filter on every QoS commit, including boot. QoS re-applied the interface redirect first and then re-created the ingress qdisc for its own policy, dropping the redirect filter again. Mirror and redirect are now re-applied after the QoS policies, and the redirect re-uses an existing ingress qdisc instead of failing to add it.
2026-11-05interfaces: T6393: install mirror and redirect filters for VLAN targetsChristian Breunig
A VLAN sub-interface used as mirror or redirect target (e.g. bond0.10) was only accepted if it already existed in the Kernel. The configuration committed at runtime, but at boot the source interface is committed before the VLAN is created - verify failed and the whole source interface was rolled back, as reported for tunnel targets. A VLAN target is now also accepted if its parent interface has the vif, vif-s or vif-c configured on the CLI. VLAN sub-interfaces learn which interfaces mirror or redirect into them and install their filters once created, as other interfaces already do. Add a config load test mirroring and redirecting into tunnel and bond VLAN targets, which are committed after the ethernet sources.
2026-11-05interfaces: T6393: accept mirror and redirect targets defined on the CLIciaens
Interface types are committed in priority order (ethernet 318, bridge 319, bonding 320, ... tunnel 380). verify_mirror_redirect() required the mirror and redirect target to exist in the Kernel, so "interfaces ethernet eth1 mirror ingress tun0" (or "redirect tun0") could never commit on the first pass at boot, or when both interfaces are created in the same commit: VYOS_TAGNODE_VALUE=eth1 .../interfaces_ethernet.py Requested mirror interface "tun0" does not exist! Sending reply: ERROR_COMMIT with output VYOS_TAGNODE_VALUE=tun0 .../interfaces_tunnel.py Sending reply: SUCCESS with output The whole ethernet node was rolled back, taking its addresses and everything on top of them down with it. The tc filter itself is installed by the target's commit since the previous commit, only verify() blocks. Also accept a target which is defined on the CLI, at its interface name position of the interfaces tree that Config.get_config_dict() attaches to its dictionaries. A target that is neither configured nor existing still fails the commit with the same error message as before. VLAN sub-interface targets are only accepted from the Kernel, as nothing would install their filter later on. VLAN sub-interfaces as sources get the interfaces tree attached to their own dictionaries in get_interface_dict(). A target placed in a network namespace is out of reach for tc(8) and is rejected with its own message, also while its device still sits in the default namespace. A target whose device is created asynchronously by a daemon (OpenVPN) now also passes verify at boot; if its device is not up yet when that interface applies, the filter is installed on the next commit of either side instead of the source interface being rolled back. src/tests/test_configverify.py was removed together with its last test case (T8859) and is re-added with tests for the target verification.
2026-11-05interfaces: T6393: install tc filters for every source of a targetciaens
When an interface is used as the mirror target of other interfaces, its commit installs the tc(8) mirror filters on their behalf, so that mirroring works even if the target did not exist yet when the sources were configured. is_mirror_intf() however only remembered the last source it found, ignored the target's own mirror configuration whenever it had sources, and did not consider VLAN sub-interfaces or "redirect" at all. Return all sources (including vif, vif-s, vif-c and redirecting interfaces), found by walking the interfaces dictionary once instead of calling list_nodes() and exists() per node, and apply the interface's own configuration plus one set of filters per source. A source whose target does not exist yet is skipped with a warning, the target installs the filter once it exists. Only sources missing a filter into the target are touched (each configured direction is checked), so a commit of the target no longer drops and re-adds the qdiscs of every source. A filter left behind by a re-created target is reported by tc as "*" and replaced. A redirecting source may carry a QoS policy: its dictionary gets the "qos" marker of get_interface_dict(), and only the mirred filters are removed instead of the qdiscs. This also drops the stale redirect filter once "redirect" is deleted from a shaped interface.
2026-11-05https: T9559: report a missing VRF instead of a free portChristian Breunig
The port check reported a port as free when the VRF to test it in did not exist, so a missing or misspelled VRF passed unnoticed. The device error is now raised like any other error. Callers that verify the VRF beforehand are not affected; the default VRF is still treated like no VRF at all.
2026-11-05https: T9559: fix bogus port conflict with "vrf default"Christian Breunig
Committing "set service https vrf default" failed with "TCP port 443 in vrf default is already used by another service" although nothing listened on the port. The port check bound its test socket to a VRF device named "default", which does not exist, and reported that failure as a port conflict. The default VRF is now treated like no VRF at all. A VRF device that does not exist no longer counts as a busy port, as nothing can listen in it; any other error is raised instead of being reported as a conflict. The same check is used by the Prometheus VPP exporter.
2026-11-04remote: T9568: Do not use .netrc credentials for redirect targetsNataliia Solomko
A "default" entry in .netrc matches any host, so a download that was redirected to a different host could send those credentials there. Credentials from .netrc are now only used for the original host.
2026-11-04remote: T9568: Do not send HTTP credentials to another host after a redirectNataliia Solomko
Downloads that were redirected to a different host sent the user's credentials to that host. Credentials are now dropped when the redirect leaves the original host.
2026-11-03Merge pull request #5627 from c-po/T9567-serial-console-compat-migrationChristian Breunig
serial: T9567: honor booted serial console during 31 -> 32 migration
2026-11-03serial: T9567: honor booted serial console during 31 -> 32 migrationChristian Breunig
An installation that still carries a legacy 1.3.x image keeps GRUB in compat mode. The GRUB structure update then rewrites the GRUB vars on every boot, before the config migration runs. The migration relied on these vars to detect a serial boot console and silently skipped setting "system console device ttyS0 kernel" after an upgrade from 1.4. The console code then fell back to tty0, so the next boot lost all serial output. On compat GRUB installs, the migration now uses the console the kernel booted with (the last console= argument). Installs using the current GRUB layout keep reading the GRUB vars, so a one-off console choice from the GRUB boot options menu is not persisted into the config.
2026-11-03T9562: pass value instead of callable to set_levelJohn Estabrook
A typo led to passing the function itself, instead of its value.
2026-11-02Merge pull request #5602 from c-po/T9496-secure-boot-add-imageChristian Breunig
op-mode: T9496: verify secure-boot signature when using "add system image"
2026-11-01frrender: T9482: drop a blackhole route FRR would refuseChristian Breunig
The default route of a DHCP or PPPoE interface changes with an interface-only commit or a lease event, without a commit of the static routes. If it gets the same prefix and distance as a blackhole or reject route, FRR refuses the reload and every static route added with it is lost. The rendered FRR configuration is now checked for a blackhole or reject route next to any other route of the same prefix and distance, per VRF and table. Such a blackhole or reject route is not rendered, and an error naming it is logged to the journal. Prefixes are compared in their normalized form, as FRR stores them.
2026-10-31Merge pull request #5479 from c-po/T3871-ifname-storeChristian Breunig
T3871: bind interface names to hardware slots instead of hw-id
2026-10-31Merge pull request #5591 from ruben-herold/T9442-frrender-cacheChristian Breunig
frrender: T9442: cache the FRR configuration only after it was applied
2026-10-31frrender: T9442: reload FRR when the rendered configuration was not appliedChristian Breunig
A failed reload only dropped the in-memory cache. The record of the configuration FRR runs still held the previous one, so the DHCP render helper skipped a return to it while FRR kept a part of the failed configuration. After a rejected reload test, the rendered file also kept the rejected configuration. Change detection now also requires the rendered file to match the applied one, and a failed reload removes that record. The next commit then renders and reloads FRR again, even when it returns to the previous configuration. A smoketest stops FRR during a commit and verifies that committing again brings the configuration into FRR.
2026-10-31interfaces: T3871: keep the address policy the distribution shipsChristian Breunig
Only the first matching link file is applied, and ours sets just the name, so the address policy shipped with the system never ran on any interface. Hardware with a permanent address was unaffected - there was nothing to apply - but a modem, which has none, was left on whatever random address its driver had picked that boot, a different one every time. Spell the policy out again. A permanent address is still kept where there is one, and a device without one is given an address derived from the machine and the device, which is the same on every boot of that machine. An address set through the CLI is applied later and is unaffected.
2026-10-31wwan: T3871: stop reporting a modem as replaced hardware every bootChristian Breunig
A modem that reports no permanent address is given a random one by its driver at every probe. That address was read as if it identified the hardware, so it never matched what was recorded and the modem was taken for a different card in the same socket on each boot, warning the operator to check a port nobody had touched. The map also kept being rewritten with the address of the boot before, so it could never settle. Keep no address for a modem, and compare one only where there is one. An address recorded by an earlier version is dropped on the next pass, so a machine already carrying one needs nothing done to it. A card whose address really did change is still reported.
2026-10-31interfaces: T3871: give a re-created Hyper-V NIC the name of the NIC it replacedAlex Kudentsov
A Hyper-V NIC is known by its MAC alone. One deleted and created again on the same VM - an Azure NIC re-created, or a Hyper-V adapter removed and added - comes back with a new MAC, so nothing on it matched the store: its name stayed reserved, the new NIC got a new name, and its configuration was left on a name with no NIC. cloud-init does not run again on the same instance, so nothing else repairs it. At boot, a vacant name now goes to a new NIC only when the pairing is not in doubt: - exactly one recorded name has no NIC, and exactly one new Hyper-V NIC appeared. With more of either, the order the NICs come up in does not say which replaced which, so nothing is handed over and the names stay reserved, as before; - the name went missing at this pass. The store records which names were missing at the last pass, so a NIC removed for good does not hand its name to a NIC added at a later boot; - the name's own NIC was a Hyper-V one. The store records which names sat on a Hyper-V NIC; a MAC-keyed name can belong to other hardware, and a store written before this was recorded hands nothing over (the boot pass logs that when it holds a name back); - only at boot. On a running system the configuration under a name is not applied to the NIC that takes it, so the hotplug unit passes --hotplug, which names the new NIC like any other and records the vacant name as missing, so the next boot does not hand it over either. An adoption is logged as a warning, reported under 'adopted' in the status file (kept there across hotplug passes while it holds), and repeated by vyos-router, as a slot match is: verify the port before relying on its configuration.
2026-10-31interfaces: T3871: keep an accelerated-networking VF off its NIC's .link fileAlex Kudentsov
On Azure every Hyper-V NIC shares one ID_PATH and has no slot, so it is keyed on its MAC. Its accelerated-networking VF carries the same MAC and matched the NIC's .link file, so udev tried to give the VF the NIC's name. The .link file of a Hyper-V NIC now also matches Driver=hv_netvsc, so the VF cannot match it. This holds for a lone NIC keyed on the VMBus path too. A NIC absent at a pass cannot say what it is, so its file keeps the pin it already carries. NICs that are not Hyper-V ones get no Driver line, and their files do not change. The 34-to-35 migration passes the hardware it found, so the pin is written on the first boot of an upgrade too.
2026-10-31interfaces: T3871: keep the hypervisor's adapter order on ESXiChristian Breunig
ESXi does not lay its adapters out in PCI address order. With four or more it puts the fourth on a root port sorting ahead of the first three, so naming by address made Network adapter 4 eth0 and shifted the rest. On the vmware-vsphere OVA that moved the WAN, because cloud-init takes eth0 from the OVF properties. The firmware port label carries the adapter order, and is what the VMware udev rule this series removed matched on. Order by it, ahead of the address, for hardware the hypervisor presented - recognised by its PCI vendor, or by DMI for a model whose IDs are not known here. A physical server labels its ports too and must not be reordered. The label orders, it never identifies: a relabelled adapter is still the same card.
2026-10-31ethernet: T3871: restore the address the card came with, not the one on itChristian Breunig
Deleting an ethernet configuration puts the hardware address back. It was read from the driver, which reports the current address when it cannot report a permanent one separately - and at that point the current address is still the custom one being removed, so it was reapplied rather than undone and the card kept an address the configuration no longer mentioned. Ask what naming recorded for the interface first, as the reset path already does. That was taken before any custom address was applied, and the driver stays the fallback for an interface no pass has seen.
2026-10-31interfaces: T3871: make the interface map survive a crash, not just a renameChristian Breunig
Replacing the map was atomic but not durable: neither its contents nor the rename were forced to the disk, so a machine losing power shortly after a boot could come back to an empty or truncated file. Names are then derived from the hardware again, which only gives the same answer where they happened to follow slot order - anywhere else an address moves to another cable. Force the contents out before the file is put in place, and the directory entry after, so what comes back is either the names it had before or the ones just written.
2026-10-31interfaces: T3871: only give a name to a device of its own kindChristian Breunig
A recorded slot was enough to claim a name, whatever turned up in it. Pull a modem and put an ordinary USB NIC in the same port and the NIC was handed wwan0 - a name 'interfaces wwan' reads, so a modem's configuration would be applied to a card which can not carry it. The reverse was already handled. Require the device to belong to the namespace the name is read under. If it does not, the name stays reserved for the hardware that earned it and the newcomer is named as what it is.
2026-10-31interfaces: T3871: report a name which changed hands between known cardsChristian Breunig
Cards rearranged among themselves, or a map edited by hand, leave every name matched to a card the store knows - just not the one it had. That was filed as an ordinary match, indistinguishable from a machine where nothing moved, while the addresses configured under those names had quietly changed cable. Report it separately. Which name goes to which card is unchanged, the slot still decides; only the account of what happened is.