From 6037422f531eba8b1e23780d0e275f86366073b3 Mon Sep 17 00:00:00 2001 From: "Chester A. Unal" Date: Mon, 2 Mar 2026 12:35:25 +0200 Subject: [PATCH] bsbf-openwrt-resources: add Designate bsbf-openwrt-resources as the package to contain the BSBF packages without a remote source to fetch. Move bsbf-bonding and bsbf-usb-netdev-autodhcp into bsbf-openwrt-resources. Change bsbf-usb-netdev-autodhcp to bsbf-autoconf-dhcp along with the logic. Signed-off-by: Chester A. Unal --- .../Makefile | 19 ++++++++- .../etc/hotplug.d/net/99-bsbf-autoconf-dhcp | 39 +++++++++++++++++++ .../files/etc/nftables.d/99-bsbf-bonding.nft | 0 .../files/etc/uci-defaults/99-bsbf-bonding | 0 net/bsbf-usb-netdev-autodhcp/Makefile | 33 ---------------- .../hotplug.d/net/99-bsbf-usb-netdev-autodhcp | 35 ----------------- 6 files changed, 57 insertions(+), 69 deletions(-) rename net/{bsbf-bonding => bsbf-openwrt-resources}/Makefile (62%) create mode 100644 net/bsbf-openwrt-resources/files/etc/hotplug.d/net/99-bsbf-autoconf-dhcp rename net/{bsbf-bonding => bsbf-openwrt-resources}/files/etc/nftables.d/99-bsbf-bonding.nft (100%) rename net/{bsbf-bonding => bsbf-openwrt-resources}/files/etc/uci-defaults/99-bsbf-bonding (100%) delete mode 100644 net/bsbf-usb-netdev-autodhcp/Makefile delete mode 100644 net/bsbf-usb-netdev-autodhcp/files/etc/hotplug.d/net/99-bsbf-usb-netdev-autodhcp diff --git a/net/bsbf-bonding/Makefile b/net/bsbf-openwrt-resources/Makefile similarity index 62% rename from net/bsbf-bonding/Makefile rename to net/bsbf-openwrt-resources/Makefile index 4d78b13949..b36331717a 100644 --- a/net/bsbf-bonding/Makefile +++ b/net/bsbf-openwrt-resources/Makefile @@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk -PKG_NAME:=bsbf-bonding +PKG_NAME:=bsbf-openwrt-resources PKG_VERSION:=1 PKG_LICENSE:=AGPL-3.0-or-later @@ -11,6 +11,17 @@ PKG_MAINTAINER:=Chester A. Unal include $(INCLUDE_DIR)/package.mk +define Package/bsbf-autoconf-dhcp + SECTION:=net + CATEGORY:=Network + TITLE:=bsbf-autoconf-dhcp +endef + +define Package/bsbf-autoconf-dhcp/description + bsbf-autoconf-dhcp creates a network with a DHCP client using a newly created + network interface. It uses metric values from 1 to 8. +endef + define Package/bsbf-bonding SECTION:=net CATEGORY:=Network @@ -26,6 +37,11 @@ endef define Build/Compile endef +define Package/bsbf-autoconf-dhcp/install + $(INSTALL_DIR) $(1)/etc/hotplug.d/net + $(INSTALL_BIN) ./files/etc/hotplug.d/net/99-bsbf-autoconf-dhcp $(1)/etc/hotplug.d/net +endef + define Package/bsbf-bonding/install $(INSTALL_DIR) $(1)/etc/nftables.d $(INSTALL_DATA) ./files/etc/nftables.d/99-bsbf-bonding.nft $(1)/etc/nftables.d @@ -34,4 +50,5 @@ define Package/bsbf-bonding/install $(INSTALL_BIN) ./files/etc/uci-defaults/99-bsbf-bonding $(1)/etc/uci-defaults endef +$(eval $(call BuildPackage,bsbf-autoconf-dhcp)) $(eval $(call BuildPackage,bsbf-bonding)) diff --git a/net/bsbf-openwrt-resources/files/etc/hotplug.d/net/99-bsbf-autoconf-dhcp b/net/bsbf-openwrt-resources/files/etc/hotplug.d/net/99-bsbf-autoconf-dhcp new file mode 100644 index 0000000000..2362fc2c09 --- /dev/null +++ b/net/bsbf-openwrt-resources/files/etc/hotplug.d/net/99-bsbf-autoconf-dhcp @@ -0,0 +1,39 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-or-later +# Copyright (C) 2025-2026 Chester A. Unal + +# Only run if a non-virtual network interface is being added. +[ "$ACTION" = "add" ] && echo "$DEVPATH" | grep -qv virtual || exit + +# Exclude MBIM and QMI network interfaces which a DHCP client wouldn't work on. +grep -E "(mbim|qmi)" /sys"${DEVPATH%/*/*}/uevent" && exit + +# Exit if a network with the network interface already exists. +uci_network=$(uci show network) +echo "$uci_network" | grep -q ".device='$DEVICENAME'" && exit + +# Decide on the metric value. Start from 1 and work up to 8. +metric=1 +while [ $metric -le 8 ]; do + # Break if this metric isn't in use. + echo "$uci_network" | grep -q ".metric='$metric'" || break + + # Add 1 to metric if another network uses this metric. + metric=$((metric + 1)) +done +# If there are no available metrics, exit with code 1. +[ "$metric" -gt 8 ] && exit 1 + +# Decide on the network name. Start from wan1. +index=1 +while echo "$uci_network" | grep -q "wan$index"; do + index=$((index + 1)) +done + +uci set network.wan$index=interface +uci set network.wan$index.device="$DEVICENAME" +uci set network.wan$index.proto='dhcp' +uci set network.wan$index.peerdns='0' +uci set network.wan$index.metric="$metric" +uci commit network +ifup wan$index diff --git a/net/bsbf-bonding/files/etc/nftables.d/99-bsbf-bonding.nft b/net/bsbf-openwrt-resources/files/etc/nftables.d/99-bsbf-bonding.nft similarity index 100% rename from net/bsbf-bonding/files/etc/nftables.d/99-bsbf-bonding.nft rename to net/bsbf-openwrt-resources/files/etc/nftables.d/99-bsbf-bonding.nft diff --git a/net/bsbf-bonding/files/etc/uci-defaults/99-bsbf-bonding b/net/bsbf-openwrt-resources/files/etc/uci-defaults/99-bsbf-bonding similarity index 100% rename from net/bsbf-bonding/files/etc/uci-defaults/99-bsbf-bonding rename to net/bsbf-openwrt-resources/files/etc/uci-defaults/99-bsbf-bonding diff --git a/net/bsbf-usb-netdev-autodhcp/Makefile b/net/bsbf-usb-netdev-autodhcp/Makefile deleted file mode 100644 index 46c7e8c04d..0000000000 --- a/net/bsbf-usb-netdev-autodhcp/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# Copyright (C) 2025-2026 Chester A. Unal - -include $(TOPDIR)/rules.mk - -PKG_NAME:=bsbf-usb-netdev-autodhcp -PKG_VERSION:=1 - -PKG_LICENSE:=AGPL-3.0-or-later -PKG_MAINTAINER:=Chester A. Unal - -include $(INCLUDE_DIR)/package.mk - -define Package/bsbf-usb-netdev-autodhcp - SECTION:=net - CATEGORY:=Network - TITLE:=bsbf-usb-netdev-autodhcp -endef - -define Package/bsbf-usb-netdev-autodhcp/description - bsbf-usb-netdev-autodhcp creates a network with a DHCP client using a newly - created network interface. It uses metric values from 1 to 8. -endef - -define Build/Compile -endef - -define Package/bsbf-usb-netdev-autodhcp/install - $(INSTALL_DIR) $(1)/etc/hotplug.d/net - $(INSTALL_BIN) ./files/etc/hotplug.d/net/99-bsbf-usb-netdev-autodhcp $(1)/etc/hotplug.d/net -endef - -$(eval $(call BuildPackage,bsbf-usb-netdev-autodhcp)) diff --git a/net/bsbf-usb-netdev-autodhcp/files/etc/hotplug.d/net/99-bsbf-usb-netdev-autodhcp b/net/bsbf-usb-netdev-autodhcp/files/etc/hotplug.d/net/99-bsbf-usb-netdev-autodhcp deleted file mode 100644 index 6cf87e3213..0000000000 --- a/net/bsbf-usb-netdev-autodhcp/files/etc/hotplug.d/net/99-bsbf-usb-netdev-autodhcp +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: AGPL-3.0-or-later -# Copyright (C) 2025-2026 Chester A. Unal - -# Only run if a network interface from a USB device is being added. -[ "$ACTION" = "add" ] && echo "$DEVPATH" | grep -q usb || exit - -# Exclude wwan and qmimux network interfaces which a DHCP client wouldn't work -# on. -case "$DEVICENAME" in - wwan*|qmimux*) exit ;; -esac - -# Decide on the metric value. Start from 1 and work up to 8. -metric=1 -while [ $metric -le 8 ]; do - # Break if this metric isn't in use. - uci show network | grep -q ".metric='$metric'" || break - - # Exit if this metric is in use for the same network interface. - [ "$(uci get network.wan_"$DEVICENAME".metric)" = "$metric" ] && exit - - # Add 1 to metric if another network uses this metric. - metric=$((metric + 1)) -done -# If there are no available metrics, exit with code 1. -[ "$metric" -gt 8 ] && exit 1 - -uci set network.wan_"$DEVICENAME"=interface -uci set network.wan_"$DEVICENAME".device="$DEVICENAME" -uci set network.wan_"$DEVICENAME".proto='dhcp' -uci set network.wan_"$DEVICENAME".peerdns='0' -uci set network.wan_"$DEVICENAME".metric="$metric" -uci commit network -ifup wan_"$DEVICENAME"