4b274055ede3 libubus: fix NULL dereference on OOM in ubus_queue_msg
8b5be570f13e libubus-acl: fix dangling pointers on blob_memdup failure in acl_recv_cb
9105ea2a349a ubusd_acl: fix NULL dereference on OOM in ubusd_acl_alloc_obj
07d7f34ac278 ubusd_acl: handle allocation failures in ubusd_acl_init_client
497321a5ea90 ubusd_acl: fix NULL dereference on OOM in ubusd_acl_init
f66d52ba983f ubusd_event: fix OOM handling in ubusd_send_event_msg
11ea1b3bdbea ubusd_main: fix async-signal-unsafe SIGHUP handler
0c095592ccb7 ubusd_proto: fix resource leaks and ID tree corruption in ubusd_proto_new_client
f61695e6e12a ubusd_proto: fix NULL dereference for user/group in ubusd_handle_add_watch
7ecacfadd9bc ubusd_proto: fix NULL dereference on OOM in ubusd_proto_init_retmsg
3ab9d7759545 lua: fix inverted argument check in ubus_lua_add
43051ca73aec lua: fix unchecked calloc and memory leak in ubus_lua_load_object
4ca0b141e9a7 ubusd_id: use getrandom(2) unconditionally on Linux
7e4356da8abe ubusd_monitor: fix NULL dereference on OOM in ubusd_monitor_message
5849870f2251 libubus-req: fix file descriptor leaks in ubus_process_req_msg
f29767f90af1 libubus: fix file descriptor leaks in ubus_process_msg
b099d050b59d libubus: make ubus_shutdown idempotent
a564b8dcb395 ubusd_main: check strdup return value in mkdir_sockdir
239edcbaaac8 ubusd_id: fix continue in do-while skipping random ID retry
09d2df45bf38 ubusd: fix NULL dereference on OOM in ubus_msg_enqueue
bcc45ca981fd libubus: actually set FD_CLOEXEC on the ubus socket
8188f5ce8564 libubus-io: close recv_fd captured before get_next_msg failure
7a068bac5a9b libubus-io: byte-swap peer in HELLO when storing as local_id
747013f6ea05 libubus-io: reset sock.fd to -1 after close on ubus_reconnect error path
020a64b9b169 ubusd_acl: use size_t for strlen result in ubusd_acl_alloc_obj
f92ffd289dcc ubusd: use size_t for string and blob length variables
795b32bb96b6 ubusd: use fixed-width types for sequence counters
Link: https://github.com/openwrt/openwrt/pull/23487
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
The following commit: 27a673916c ("ath79: mr18: use nvmem for MACs")
switched MR18 to use NVMEM subsystem for setting MAC addresses, however
it missed the offset in use. Previously 102 (decimal) was used, but in
device tree 0x102 was used, but the correct value is 0x66.
This was found while reviewing code for Z1 port, which shares the MAC
address source.
Replace the offset with the correct one of 0x66.
Fixes: 27a673916c ("ath79: mr18: use nvmem for MACs")
Signed-off-by: Lech Perczak <lech.perczak@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23486
Signed-off-by: Robert Marko <robimarko@gmail.com>
7df188543e26 libfstools: enable f2fs overlay compression formatting
16718b6e3c0f libfstools: mount f2fs overlay with zstd compression
Signed-off-by: Robert Marko <robimarko@gmail.com>
This adds a patch that makes the pwm1 frequency and LUT temperature
hysteresis of lm63 fan controllers writeable, to be able to replicate
vendor cooling behaviour for fans that need a lower PWM frequency
than the default.
Signed-off-by: Jan-Henrik Bruhn <git@jhbruhn.de>
Link: https://github.com/openwrt/openwrt/pull/23473
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
This adds support for sysupgrade on ONIE-installed systems.
The install is chained through ONIE (using the ONIE installer image),
rather than attempting to manually upgrade the partition.
The idea is to allow future OpenWRT installs flexibility to use
a different partition table. By putting the installer in charge
of setting up the file system partition, the upgrade process needs
to have no knowledge of the internals of the image.
Config preservation is accomplished by appending the sysupgrade .tar.gz
to the ONIE installer image. Of course this also works for a clean
install using a sysupgrade.tar.gz created via `sysupgrade -b`.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Keno Fischer <keno@juliahub.com>
Link: https://github.com/openwrt/openwrt/pull/23062
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
The current documentation for using OpenWRT on Mellanox Spectrum
switches (https://openwrt.org/toh/mellanox/spectrum) suggests
reflashing the entire harddrive from the recovery USB. This is not
the most friendly way to install a new OS on these switches. From
factory, they come with ONIE (Open Network Install Environment),
which is a linux-based preboot environment for fetching an OS
image from the network and installing it on disk. The installer
is a self-executing bash script that executes inside the ONIE
environment. The installer is expected to preserve the ONIE partition
for use as recovery environement. To be a better citizen on
these platforms, it would be preferrable to provide OpenWRT as
an ONIE-compatible installer.
This PR adds an ONIE_INSTALLER_IMAGES build option that produces
an ONIE compatible .bin. The generated .bin follows the ONIE demo
installer pattern [1]: it creates a new GPT partition
labelled OPENWRT-ROOT on the ONIE install device, formats ext4, extracts
the OpenWrt rootfs and kernel into it, installs GRUB into the existing
UEFI ESP under bootloader-id "OpenWrt", and adds a NVRAM boot entry via
efibootmgr. ONIE-BOOT is preserved so ONIE rescue remains available.
Tested with the config at [2] on a Mellanox Spectrum SN3800 to produce
a booting OpenWRT install.
[1] https://github.com/opencomputeproject/onie/demo/installer/grub-arch/install.sh
[2] https://gist.github.com/Keno/abc8c5b72645e73fadd1ff0d9616b23d
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Keno Fischer <keno@juliahub.com>
Link: https://github.com/openwrt/openwrt/pull/23062
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Previously, sds->num_of_links was incremented from rtpcs_create() as
each DSA port bound its phylink_pcs. The count therefore relied on a
temporal contract (DSA must finish enumerating before pcs_config runs)
and on rtpcs_create() being the single chokepoint for all consumers.
Replace this with a probe-time scan of pcs-handle references in the
live OF tree: for every available consumer node carrying a pcs-handle
property pointing at one of our SerDes subnodes, bump that SerDes'
num_of_links. After the scan, the count is final regardless of when
or whether DSA later calls in.
To allow of_parse_phandle_with_args() to walk the property correctly,
add #pcs-cells = <0> to every serdes@N node in the 838x/839x/930x/931x
.dtsi files. A future cell-bearing form remains possible without
touching the scan.
Over-references (DT pointing more consumers at one SerDes than the
hardware can carry) are clamped at RTPCS_MAX_LINKS_PER_SDS and warned
about, but do not fail probe — the correctly-wired ports on that
SerDes still come up, and only the surplus reference is dropped.
The bounds check and the bare ++ in rtpcs_create() become redundant
under the scan-driven count and are removed.
This decouples num_of_links from DSA call ordering and is a prereq
for migrating to fwnode_pcs providers, where rtpcs_create() goes away
as the centralised counter.
Link: https://github.com/openwrt/openwrt/pull/23484
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
The wildcard combined an apk_package_files pattern of $(pkg)-*.apk with a
gen_package_wildcard that ends in [^a-z]*, so the full glob required two
dashes. Files for packages without an ABI version (e.g. ubbf-0~....apk)
only contain one dash and never matched, so ipkg-remove was never called
on them and stale .apk files accumulated in the bin directory.
Drop the explicit dash from apk_package_files. The [^a-z] in
gen_package_wildcard already serves as the dash matcher, and
scripts/ipkg-remove filters precisely by reading apk metadata.
Fixes: 642d568b0f ("build: fix ipkg-remove: add support for removing apk files")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Replace exit(1) on every failure path with return null so callers that
iterate over multiple radios can collect results from the radios that
did succeed instead of aborting on the first one that refuses an
off-channel scan.
Route diagnostics to stderr via warn() so stdout stays clean for
callers parsing JSON output, and include the device name in each
message to disambiguate per-radio failures.
Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
1bf2d490484e libfstools: make get_var_from_file() reusable
0b6022439cad mount_root: add kernel parameter to specify the overlay storage name
e600d842ce81 mount_root: add kernel parameter to specify the overlay fileystem type
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Backport GDM2 loopback fixup for Ethernet driver. This should be the last
patch before introduction of Multi-Serdes support series.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
The chunk length is not correct.
Fixes: d2fabb974c ("mediatek: add support for Wavlink WL-WNT100X3 ubootmod")
Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
The generated firmware patches for RealTek's PHYs are host architecture
agnostic. Express this with PKGARCH:=all.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
When using imagebuilder to create images, ROOTFS_FILESYSTEM may be
defined to create just the desired images, but the '*-rootfs.tar.gz'
and '*-rootfs.cpio.gz' images are being created unconditionally
for many targets.
By making generation of these images conditional on the state of
ROOTFS_FILESYSTEM, we can save significant space (measured 3-7 MB
depending on length of package list) and time.
Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
Now that the upstream RealTek PHY driver is patched to support also
the new 5G and 10G PHYs we can start to phase-out the messy downstream
driver.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
The functionality/support for 5G and 10G PHYs was extracted from the
realtek-phy driver and ported to the upstream Linux realtek PHY driver.
These PHY chips need a sequence of register writes (and similar operations)
for initialization. These sequences are provided as firmware files which
are interpreted/applied by a new register patch engine.
By switching to the upstream driver, it should be possible to get rid of a
large chunk of (from OpenWrt perspective) unmaintained code from Realtek.
The actual Linux phy-core infrastructure from Linux can be mostly used and
only the Realtek specific quirks need to be handled.
The files which need to be provided are depending on the PHY:
* rtl8261n.bin (package "rtl8261n-firmware" or "rtl8261n-lp-firmware")
- RTL8251L 5Gbps PHY
- RTL8261BE 10Gbps PHY
- RTL8261N 10Gbps PHY
* rtl8264b.bin (package "rtl8264b-firmware")
- RTL8254B 5Gbps PHY
- RTL8264 10Gbps PHY
- RTL8264B 10Gbps PHY
Files which are affected by this change (DEVICE_PACKAGES dependencies,
hwmon paths, default kernel configurations, refresh of patches, ...) are
updated at the same times.
Signed-off-by: Balázs Triszka <info@balika011.hu>
Co-authored-by: Semih Baskan <strst.gs@gmail.com>
Co-authored-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Co-authored-by: Gilly1970 <gilroyscott@hotmail.com>
Co-authored-by: Aleksander Jan Bajkowski <olek2@wp.pl>
Co-authored-by: Carlo Szelinsky <github@szelinsky.de>
[sven: rebase, integrate suggestions from PR, add device packages, split]
Signed-off-by: Sven Eckelmann <sven@narfation.org>
[daniel: stripped to Linux 6.18 only, dropped unrelated changes]
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This is required by the realtek PHY driver for:
* rtl8261n.bin (package "rtl8261n-firmware" or "rtl8261n-lp-firmware")
- RTL8251L 5Gbps PHY
- RTL8261BE 10Gbps PHY
- RTL8261N 10Gbps PHY
* rtl8264b.bin (package "rtl8264b-firmware")
- RTL8254B 5Gbps PHY
- RTL8264 10Gbps PHY
- RTL8264B 10Gbps PHY
These PHY chips need a sequence of register writes for initialization.
These are provided as firmware files which are interpreted/applied by a
new register patch engine.
For the moment, the patch instructions in rtl8261-firmware and
rtl8264b-firmware are the same as from the rtl8261n driver. This should
make it possible to first evaluate the patch engine and driver development
for switching over in adjusting the patch instructions.
Signed-off-by: Balázs Triszka <info@balika011.hu>
[sven: rebase, split, fix package version/release, use conf from rtl8261n
driver]
Signed-off-by: Sven Eckelmann <sven@narfation.org>
[daniel: define VERSION matching source date for the resulting packages]
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
qemustart is a handy script to quickly test OpenWrt firmware using
qemu. Bringing up networking currently requires a bridge-helper
setup with privileged IP and bridge assignment. To simplify
testing scenarios like the package manager, which need both shell
access and outbound internet, add a user-mode networking option
backed by SLIRP that requires no privileges.
To stay backward compatible, the defaults don't change. The new
flag --user-network attaches two NICs (LAN + WAN) and forwards
three host ports to the guest LAN interface (192.168.1.1):
2222 -> 22 (ssh), 8080 -> 80 (http) and 8443 -> 443 (https). The
host-side ports can be overridden with --ssh-port, --http-port
and --https-port.
Link: https://github.com/openwrt/openwrt/pull/23424
Signed-off-by: Paul Spooren <mail@aparcar.org>
OpenWrt's 99-default_network assigns eth0 to lan and eth1 to wan
when no target-specific 02_network is present, which is the case
for malta. The qemustart bridge block however placed the wan
-device before the lan -device, so the guest's eth0 (lan) ended
up attached to $BR_WAN and eth1 (wan) to $BR_LAN.
Swap the order to match the guest's actual role assignment.
Link: https://github.com/openwrt/openwrt/pull/23424
Signed-off-by: Paul Spooren <mail@aparcar.org>
In the network context there might be confusion between "struct netdev"
and "struct device". The driver should avoid variables of type device
and name "dev" where possible. Remove all variables that point to the
device and use pdev->dev instead. This is like other network drivers
do it.
While we are here modernize logging during probing. Remove messages
from helpers and log errors during probing with dev_err_probe().
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/23420
Signed-off-by: Robert Marko <robimarko@gmail.com>
The function init_mac() can produce errors for the RTL931x devices.
When this happens it throws a message but continues. That can
leave the hardware in a wrong state.
Cleanup the error handling. Remove all messages from the function
and simply return an error value. In the probe() consumer evaluate
this error and abort probing if needed. As there were no reported
issues in the past it is ok to drop the detailed messages and
aggregate them in a single one.
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/23420
Signed-off-by: Robert Marko <robimarko@gmail.com>
Upstream netdev does not like big guards. Especially
around debugging functions. Convert to scoped_guard()
and only lock the really needed code parts. This way
all debugging can run outside of the lock.
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/23411
Signed-off-by: Robert Marko <robimarko@gmail.com>
Majority of kernel uses a_to_b(a) instead of b_from_a(a).
Convert to that to be consistent with all helpers in the
driver. Additionally drop inline function definitions.
Let the compiler decide what is best.
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/23411
Signed-off-by: Robert Marko <robimarko@gmail.com>
The led_set node was previously duplicated in the per-device DTS for
-10/-12HP and -12F, even though all three share the same Base-T LED
encoding. Move the shared led_set with the Base-T mapping into the
common DTSI as set 0, and have XS1930-12F append its SFP-port mapping
as led_set1 via a property override. Swap the led-set index on the
-12F ports accordingly so SFP ports use set 1 and the two Base-T
ports use set 0.
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23428
Signed-off-by: Robert Marko <robimarko@gmail.com>
The -12HP variant has a dedicated red LED on GPIO 3 that lights up
when the PoE budget is exhausted. Add it as led_poe_max with
function = "poe-usage" so userspace can drive it from the PoE stack.
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23428
Signed-off-by: Robert Marko <robimarko@gmail.com>
The cloud and locator LEDs were declared with no function (cloud) or
with the generic LED_FUNCTION_INDICATOR (locator), which doesn't
match what the hardware actually exposes. Use the descriptive
function strings "cloud" and "locator" instead so the LEDs end up
with sensible names in sysfs.
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23428
Signed-off-by: Robert Marko <robimarko@gmail.com>
The XS1930-12HP model from Zyxel doesn't actually use the same GPIOs for
the SYS LED. This was assumed first but proved wrong now. Instead, the
green part of the SYS LED is on another GPIO and the red part of the SYS
LED is on GPIO 0 instead of the green part. Adjust that accordingly in
the device tree.
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23428
Signed-off-by: Robert Marko <robimarko@gmail.com>
The support addition for those switches defined the restore button as a
button to trigger a restart. However, those switches also have a reset
button which is wired to the SoC's reset line, causing a reset upon
pressing. Thus, using the restore button for basically the same purpose
doesn't make sense. Change the 'linux,code' property to 'BTN_0' to
assign no real function to that button, allowing it to be used for
different purposes.
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23428
Signed-off-by: Robert Marko <robimarko@gmail.com>
The switches from Zyxels XS1930 have one or two fans in the case. They
might be controlled in a limited fashion. There's a single GPIO which -
depending on the state - drives the fan in slow or fast mode. Wire that
up as a device tree node to be able to control that in userspace.
XS1930-10 and XS1930-12HP use the same GPIO while XS1930-12F moves that
to one of its GPIO expanders. Also add 'kmod-hwmon-gpiofan' for all
three devices to be selected by default.
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23428
Signed-off-by: Robert Marko <robimarko@gmail.com>
XS1930-10 and XS1930-12HP share most of their layout: the same
8-port AQR813 Base-T block, the same SFP+ GPIO mux, identical I2C
master config and serdes polarity. Carve those shared pieces out
into a new intermediate rtl9313_zyxel_xs1930-aqr813.dtsi and have both
device DTS files include it, leaving only their device-specific
differences (LED-set masks, extra PoE bits on -12HP, extra AQR113C
PHYs on -12HP) in the per-device files. XS1930-12F continues to
include the common DTSI directly since its layout differs too much
to share usefully.
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23428
Signed-off-by: Robert Marko <robimarko@gmail.com>
The power, cloud and locator LEDs exist on all three XS1930 variants
with the same colors and roles, only the GPIOs differ. Declare them
once in the common DTSI with the -10/-12HP pinout and let -12F
override the gpios properties via phandle references. This removes
three near-identical led-node blocks from the device DTS files.
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23428
Signed-off-by: Robert Marko <robimarko@gmail.com>
The driver uses lazy initialization - during first temperature
get. Checking enabled status over and over again does not make
sense. Provide separate setup functions for this. With this split
the error handling will be improved. If initialization fails, the
sensor will not be registered at all.
While we are here fix some minor typos.
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/23405
Signed-off-by: Robert Marko <robimarko@gmail.com>