diff --git a/config/Config-images.in b/config/Config-images.in index c331ad24dc..2bfa6bc536 100644 --- a/config/Config-images.in +++ b/config/Config-images.in @@ -297,6 +297,7 @@ menu "Target Images" int "Kernel partition size (in MB)" depends on GRUB_IMAGES || EFI_IMAGES || USES_BOOT_PART default 8 if TARGET_apm821xx_sata + default 64 if TARGET_brcm2708 default 16 config TARGET_ROOTFS_PARTSIZE diff --git a/package/boot/kexec-tools/Makefile b/package/boot/kexec-tools/Makefile index 76ea46f10f..ca41839869 100644 --- a/package/boot/kexec-tools/Makefile +++ b/package/boot/kexec-tools/Makefile @@ -44,7 +44,7 @@ define Package/kexec $(call Package/kexec-tools/Default) TITLE:=Kernel boots kernel DEPENDS:=\ - @armeb||@arm||@i386||@x86_64||@powerpc64||@mipsel||@mips \ + @(armeb||arm||i386||x86_64||powerpc64||mipsel||mips) \ +KEXEC_ZLIB:zlib +KEXEC_LZMA:liblzma @KERNEL_KEXEC endef @@ -55,7 +55,7 @@ endef define Package/kdump $(call Package/kexec-tools/Default) TITLE:=Kernel crash analysis - DEPENDS:=+kexec @i386||@x86_64||@arm @KERNEL_CRASH_DUMP + DEPENDS:=+kexec @(i386||x86_64||arm) @KERNEL_CRASH_DUMP endef define Package/kdump/description diff --git a/package/kernel/brcm2708-gpu-fw/Makefile b/package/kernel/brcm2708-gpu-fw/Makefile index c1195f2171..fd2f7cb504 100644 --- a/package/kernel/brcm2708-gpu-fw/Makefile +++ b/package/kernel/brcm2708-gpu-fw/Makefile @@ -9,8 +9,8 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=brcm2708-gpu-fw -PKG_VERSION:=2019-07-09 -PKG_RELEASE:=025759b8634c2f8df35203be02c19a0633f1cec1 +PKG_VERSION:=2019-12-11 +PKG_RELEASE:=0c01dbefba45a08c47f8538d5a071a0fba6b7e83 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)/rpi-firmware-$(PKG_RELEASE) @@ -25,7 +25,7 @@ define Download/LICENCE_broadcom FILE:=$(RPI_FIRMWARE_FILE)-LICENCE.broadcom URL:=$(RPI_FIRMWARE_URL) URL_FILE:=LICENCE.broadcom - HASH:=ba76edfc10a248166d965b8eaf320771c44f4f432d4fce2fd31fd272e7038add + HASH:=c7283ff51f863d93a275c66e3b4cb08021a5dd4d8c1e7acc47d872fbe52d3d6b endef $(eval $(call Download,LICENCE_broadcom)) @@ -33,7 +33,7 @@ define Download/bootcode_bin FILE:=$(RPI_FIRMWARE_FILE)-bootcode.bin URL:=$(RPI_FIRMWARE_URL) URL_FILE:=bootcode.bin - HASH:=6948c07f60f93489bbbc78747a1dc09ff0b1de42035c915fbd6453cdbd0e6475 + HASH:=6505bbc8798698bd8f1dff30789b22289ebb865ccba7833b87705264525cbe46 endef $(eval $(call Download,bootcode_bin)) @@ -41,7 +41,7 @@ define Download/fixup_dat FILE:=$(RPI_FIRMWARE_FILE)-fixup.dat URL:=$(RPI_FIRMWARE_URL) URL_FILE:=fixup.dat - HASH:=d63bc6d3516dbb860091a34ec3ce584fafb4dc79740c11da9be87572849c2e02 + HASH:=85a54bf460aa3ff0d04ee54bc606bf3af39a2c5194e519ab278cf74ecf75f7a8 endef $(eval $(call Download,fixup_dat)) @@ -49,7 +49,7 @@ define Download/fixup_cd_dat FILE:=$(RPI_FIRMWARE_FILE)-fixup_cd.dat URL:=$(RPI_FIRMWARE_URL) URL_FILE:=fixup_cd.dat - HASH:=eba5b57f49d2e8c1b2261e59297256bdff4751aeb3c7a16e60044799bcfd6b68 + HASH:=4d9ffff3719fff6b14f142cbb4b3f62df175e59be4ad382b0f39830dab18d760 endef $(eval $(call Download,fixup_cd_dat)) @@ -57,7 +57,7 @@ define Download/fixup_x_dat FILE:=$(RPI_FIRMWARE_FILE)-fixup_x.dat URL:=$(RPI_FIRMWARE_URL) URL_FILE:=fixup_x.dat - HASH:=74cc843d28f07940f7f9e618d2f5ff8c0ed245599bb45457bab1960e56cbf672 + HASH:=81aae9581c120fbbf5020fa6b84b355ed342ead7185db0916cbce7a7849307eb endef $(eval $(call Download,fixup_x_dat)) @@ -65,7 +65,7 @@ define Download/fixup4_dat FILE:=$(RPI_FIRMWARE_FILE)-fixup4.dat URL:=$(RPI_FIRMWARE_URL) URL_FILE:=fixup4.dat - HASH:=d8b44fd10c87ae51d4cce14a692f7f322574d63f7255f9776a61005c37183c5a + HASH:=611ea1ec1384931c785687e78a50369aae3a0a29e37bed354862cf5fe6d23ade endef $(eval $(call Download,fixup4_dat)) @@ -73,7 +73,7 @@ define Download/fixup4cd_dat FILE:=$(RPI_FIRMWARE_FILE)-fixup4cd.dat URL:=$(RPI_FIRMWARE_URL) URL_FILE:=fixup4cd.dat - HASH:=efc3fa3cd5f94e08687824bf149ed8c9a11bbd3e8ebac034934246dbf502300c + HASH:=f82da018c2d9fe1ec54fcfe76514dbc3b9f27f53712bb5f5b90f0d38124370eb endef $(eval $(call Download,fixup4cd_dat)) @@ -81,7 +81,7 @@ define Download/fixup4x_dat FILE:=$(RPI_FIRMWARE_FILE)-fixup4x.dat URL:=$(RPI_FIRMWARE_URL) URL_FILE:=fixup4x.dat - HASH:=866c11f0770246fba0756ee671cf118313ee23be88decae09114b123db2f26bd + HASH:=36c1cdb7b5ff8c39c1c0cd962ea1095f79c5c290fc11813869cbb662240386d7 endef $(eval $(call Download,fixup4x_dat)) @@ -89,7 +89,7 @@ define Download/start_elf FILE:=$(RPI_FIRMWARE_FILE)-start.elf URL:=$(RPI_FIRMWARE_URL) URL_FILE:=start.elf - HASH:=c9f831786f4c03d58110baddef4da32f56387d1af191866f839dffb9b0671aab + HASH:=442919907e4b7d8f007b79df1aa1e12f98e09ab393da65b48cd2b2af04301b7d endef $(eval $(call Download,start_elf)) @@ -97,7 +97,7 @@ define Download/start_cd_elf FILE:=$(RPI_FIRMWARE_FILE)-start_cd.elf URL:=$(RPI_FIRMWARE_URL) URL_FILE:=start_cd.elf - HASH:=c7ba345f71b1e5fed2cbc9d16dbb1b658546c1365e92302828f4f75ccb693df5 + HASH:=0942b6ab8eec7e6116a3fc366cb0d4a94b5869c429292da600f92a37e361ec8d endef $(eval $(call Download,start_cd_elf)) @@ -105,7 +105,7 @@ define Download/start_x_elf FILE:=$(RPI_FIRMWARE_FILE)-start_x.elf URL:=$(RPI_FIRMWARE_URL) URL_FILE:=start_x.elf - HASH:=ab51744e7048a67758ac133ed20e3f482e40f81780915b88efb97647f838771e + HASH:=e83dc1fbb5a9cb29e1db5f9ca0f9bd847f5b57a1e421cc79e39640a865456fe6 endef $(eval $(call Download,start_x_elf)) @@ -113,7 +113,7 @@ define Download/start4_elf FILE:=$(RPI_FIRMWARE_FILE)-start4.elf URL:=$(RPI_FIRMWARE_URL) URL_FILE:=start4.elf - HASH:=2691df2baa2d24dc08a7c7c99381555a819722a92c2b80731452724ddcd3e6d0 + HASH:=550b55577075f4056a71b0faa2b1150290b2e8d61e5bc330a54452f28cc1b2d8 endef $(eval $(call Download,start4_elf)) @@ -121,7 +121,7 @@ define Download/start4cd_elf FILE:=$(RPI_FIRMWARE_FILE)-start4cd.elf URL:=$(RPI_FIRMWARE_URL) URL_FILE:=start4cd.elf - HASH:=5e0d5e20b212daab99c2dd57a363ccd64ed27c8bbd0205efee07a731e6ae1a4e + HASH:=1c8206a854fba486b7996aa3735aaca8aaeee7bf20fdbf190acdea4516794f1c endef $(eval $(call Download,start4cd_elf)) @@ -129,7 +129,7 @@ define Download/start4x_elf FILE:=$(RPI_FIRMWARE_FILE)-start4x.elf URL:=$(RPI_FIRMWARE_URL) URL_FILE:=start4x.elf - HASH:=67a748bb67267cfea45597681e8400a1794956dd9b7906032991cb6ce2d8742b + HASH:=3ca2e259861fd31b77a536ccb33637e5305ec44b9e0c62e898e7e1d97e776f22 endef $(eval $(call Download,start4x_elf)) diff --git a/package/kernel/broadcom-wl/Makefile b/package/kernel/broadcom-wl/Makefile index d1d0604519..140107df17 100644 --- a/package/kernel/broadcom-wl/Makefile +++ b/package/kernel/broadcom-wl/Makefile @@ -32,15 +32,15 @@ include $(INCLUDE_DIR)/package.mk define Package/broadcom-wl/Default SECTION:=kernel CATEGORY:=Kernel modules - DEPENDS:=@PACKAGE_kmod-brcm-wl||PACKAGE_kmod-brcm-wl-mini + DEPENDS:=@(PACKAGE_kmod-brcm-wl||PACKAGE_kmod-brcm-wl-mini) SUBMENU:=Proprietary BCM43xx WiFi driver - SUBMENUDEP:=@TARGET_brcm47xx||TARGET_brcm63xx + SUBMENUDEP:=(TARGET_brcm47xx||TARGET_brcm63xx) endef define KernelPackage/brcm-wl/Default $(call Package/broadcom-wl/Default) SECTION:=kernel - DEPENDS:=@TARGET_brcm47xx||TARGET_brcm63xx +wireless-tools + DEPENDS:=@(TARGET_brcm47xx||TARGET_brcm63xx) +wireless-tools TITLE:=Kernel driver for BCM43xx chipsets FILES:=$(PKG_BUILD_DIR)/driver$(1)/wl.ko $(PKG_BUILD_DIR)/glue/wl_glue.ko AUTOLOAD:=$(call AutoProbe,wl) diff --git a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua index 618dcf149c..03c924e917 100755 --- a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua +++ b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua @@ -48,11 +48,19 @@ local function get_urlencode(c) return sformat("%%%02X", sbyte(c)) end -function urlEncode(szText) +local function urlEncode(szText) local str = szText:gsub("([^0-9a-zA-Z ])", get_urlencode) str = str:gsub(" ", "+") return str end + +local function get_urldecode(h) + return schar(tonumber(h, 16)) +end +local function UrlDecode(szText) + return szText:gsub("+", " "):gsub("%%(%x%x)", get_urldecode) +end + -- trim local function trim(text) if not text or text == "" then @@ -68,6 +76,7 @@ local function md5(content) end -- base64 local function base64Decode(text, safe) + local raw = text if not text then return '' end text = text:gsub("%z", "") if safe then @@ -76,7 +85,12 @@ local function base64Decode(text, safe) local mod4 = #text % 4 text = text .. string.sub('====', mod4 + 1) end - return nixio.bin.b64decode(text):gsub("%z", "") + local result = nixio.bin.b64decode(text) + if result then + return result:gsub("%z", "") + else + return raw + end end -- 处理数据 local function processData(szType, content) @@ -134,20 +148,45 @@ local function processData(szType, content) result.h2_host = info.host result.h2_path = info.path if not info.security then - result.security = 'auto' + result.security = "auto" end - if info.tls == 'tls' or info.tls == '1' then - result.tls = '1' + if info.tls == "tls" or info.tls == "1" then + result.tls = "1" else - result.tls = '0' + result.tls = "0" end - elseif szType == 'ssd' then - result.type = 'ss' + elseif szType == "ss" then + local info = content:sub(1, content:find("#") - 1) + local alias = content:sub(content:find("#") + 1, #content) + local hostInfo = split(base64Decode(info, true), "@") + local host = split(hostInfo[2], ":") + local userinfo = base64Decode(hostInfo[1], true) + local method = userinfo:sub(1, userinfo:find(":") - 1) + local password = userinfo:sub(userinfo:find(":") + 1, #userinfo) + result.alias = UrlDecode(alias) + result.type = "ss" + result.server = host[1] + if host[2]:find("/\\?") then + local query = split(host[2], "/\\?") + result.server_port = query[1] + -- local params = {} + -- for k, v in pairs(split(query[2], '&')) do + -- local t = split(v, '=') + -- params[t[1]] = t[2] + -- end + -- 这里似乎没什么用 我看数据结构没有写插件的支持 先抛弃 + else + result.server_port = host[2] + end + result.encrypt_method_ss = method + result.password = password + elseif szType == "ssd" then + result.type = "ss" result.server = content.server result.server_port = content.port result.password = content.password result.encrypt_method_ss = content.encryption - result.alias = '[' .. content.airport .. '] ' .. content.remarks + result.alias = "[" .. content.airport .. "] " .. content.remarks end return result, hash end @@ -173,7 +212,7 @@ local execute = function() cache[groupHash] = {} tinsert(nodeResult, {}) local index = #nodeResult - -- SSD 似乎是这种格式 ssd:// 开头的 不知道 SS 什么格式 没支持 不清楚其他机场是否这样 + -- SSD 似乎是这种格式 ssd:// 开头的 if raw:find('ssd://') then szType = 'ssd' local nEnd = select(2, raw:find('ssd://')) @@ -197,13 +236,18 @@ local execute = function() end for _, v in ipairs(node) do if v then + v = trim(v) local result, hash if szType == 'ssd' then result, hash = processData(szType, v) elseif not szType then local dat = split(v, "://") if dat and dat[1] and dat[2] then - result, hash = processData(dat[1], base64Decode( dat[2], true)) + if dat[1] == 'ss' then + result, hash = processData(dat[1], dat[2]) + else + result, hash = processData(dat[1], base64Decode(dat[2], true)) + end end else log('跳过未知类型: ' .. szType) diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile index 437751aadf..5ff0e726ca 100644 --- a/package/system/procd/Makefile +++ b/package/system/procd/Makefile @@ -58,7 +58,7 @@ endef define Package/procd-seccomp SECTION:=base CATEGORY:=Base system - DEPENDS:=@arm||@armeb||@mips||@mipsel||@i386||@powerpc||@x86_64 @!TARGET_uml @KERNEL_SECCOMP +libubox +libblobmsg-json + DEPENDS:=@(arm||armeb||mips||mipsel||i386||powerpc||x86_64) @!TARGET_uml @KERNEL_SECCOMP +libubox +libblobmsg-json TITLE:=OpenWrt process seccomp helper + utrace endef diff --git a/package/utils/mdadm/Makefile b/package/utils/mdadm/Makefile index ba74997b5e..f20a58b704 100644 --- a/package/utils/mdadm/Makefile +++ b/package/utils/mdadm/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mdadm -PKG_VERSION:=4.0 -PKG_RELEASE:=5 +PKG_VERSION:=4.1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/linux/utils/raid/mdadm -PKG_HASH:=1d6ae7f24ced3a0fa7b5613b32f4a589bb4881e3946a5a2c3724056254ada3a9 +PKG_HASH:=ab7688842908d3583a704d491956f31324c3a5fc9f6a04653cb75d19f1934f4a PKG_MAINTAINER:=Felix Fietkau PKG_CPE_ID:=cpe:/a:mdadm_project:mdadm diff --git a/package/utils/mdadm/patches/100-cross_compile.patch b/package/utils/mdadm/patches/100-cross_compile.patch index 62bf693455..0a5fa017c6 100644 --- a/package/utils/mdadm/patches/100-cross_compile.patch +++ b/package/utils/mdadm/patches/100-cross_compile.patch @@ -1,11 +1,11 @@ --- a/Makefile +++ b/Makefile -@@ -86,7 +86,7 @@ DLM:=$(shell [ -f /usr/include/libdlm.h +@@ -97,7 +97,7 @@ DLM:=$(shell [ -f /usr/include/libdlm.h DIRFLAGS = -DMAP_DIR=\"$(MAP_DIR)\" -DMAP_FILE=\"$(MAP_FILE)\" DIRFLAGS += -DMDMON_DIR=\"$(MDMON_DIR)\" DIRFLAGS += -DFAILED_SLOTS_DIR=\"$(FAILED_SLOTS_DIR)\" -CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(DIRFLAGS) $(COROSYNC) $(DLM) -+# CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(DIRFLAGS) $(COROSYNC) $(DLM) ++#CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(DIRFLAGS) $(COROSYNC) $(DLM) VERSION = $(shell [ -d .git ] && git describe HEAD | sed 's/mdadm-//') - VERS_DATE = $(shell [ -d .git ] && date --date="`git log -n1 --format=format:%cd --date=short`" '+%0dth %B %Y' | sed -e 's/1th/1st/' -e 's/2th/2nd/' -e 's/11st/11th/' -e 's/12nd/12th/') + VERS_DATE = $(shell [ -d .git ] && date --iso-8601 --date="`git log -n1 --format=format:%cd --date=iso --date=short`") diff --git a/package/utils/mdadm/patches/101-mdadm.h-Undefine-dprintf-before-redefining.patch b/package/utils/mdadm/patches/101-mdadm.h-Undefine-dprintf-before-redefining.patch index bcff20d75f..356d0deec8 100644 --- a/package/utils/mdadm/patches/101-mdadm.h-Undefine-dprintf-before-redefining.patch +++ b/package/utils/mdadm/patches/101-mdadm.h-Undefine-dprintf-before-redefining.patch @@ -22,7 +22,7 @@ Upstream-Status: Pending --- a/mdadm.h +++ b/mdadm.h -@@ -1595,11 +1595,13 @@ static inline char *to_subarray(struct m +@@ -1649,11 +1649,13 @@ static inline char *to_subarray(struct m } #ifdef DEBUG diff --git a/package/utils/mdadm/patches/102-Add-missing-include-file-sys-sysmacros.h.patch b/package/utils/mdadm/patches/102-Add-missing-include-file-sys-sysmacros.h.patch new file mode 100644 index 0000000000..891b5c62f0 --- /dev/null +++ b/package/utils/mdadm/patches/102-Add-missing-include-file-sys-sysmacros.h.patch @@ -0,0 +1,29 @@ +From 452dc4d13a012cdcb05088c0dbc699959c4d6c73 Mon Sep 17 00:00:00 2001 +From: Baruch Siach +Date: Tue, 6 Aug 2019 16:05:23 +0300 +Subject: mdadm.h: include sysmacros.h unconditionally + +musl libc now also requires sys/sysmacros.h for the major/minor macros. +All supported libc implementations carry sys/sysmacros.h, including +diet-libc, klibc, and uclibc-ng. + +Cc: Hauke Mehrtens +Signed-off-by: Baruch Siach +Signed-off-by: Jes Sorensen +--- + mdadm.h | 2 -- + 1 file changed, 2 deletions(-) + +--- a/mdadm.h ++++ b/mdadm.h +@@ -45,10 +45,8 @@ extern __off64_t lseek64 __P ((int __fd, + #include + #include + #include +-#ifdef __GLIBC__ + /* Newer glibc requires sys/sysmacros.h directly for makedev() */ + #include +-#endif + #ifdef __dietlibc__ + #include + /* dietlibc has deprecated random and srandom!! */ diff --git a/package/utils/mdadm/patches/200-reduce_size.patch b/package/utils/mdadm/patches/200-reduce_size.patch index ae8204ccd9..6905c2ccfe 100644 --- a/package/utils/mdadm/patches/200-reduce_size.patch +++ b/package/utils/mdadm/patches/200-reduce_size.patch @@ -1,6 +1,6 @@ --- a/Incremental.c +++ b/Incremental.c -@@ -1642,6 +1642,10 @@ static int Incremental_container(struct +@@ -1619,6 +1619,10 @@ static int Incremental_container(struct if (ra_all == ra_blocked) return 0; @@ -13,7 +13,7 @@ memcpy(suuid, uuid_zero, sizeof(int[4])); --- a/util.c +++ b/util.c -@@ -1151,7 +1151,9 @@ void wait_for(char *dev, int fd) +@@ -1220,7 +1220,9 @@ void wait_for(char *dev, int fd) struct superswitch *superlist[] = { &super0, &super1, @@ -21,5 +21,5 @@ &super_ddf, &super_imsm, +#endif &mbr, &gpt, - NULL }; - + NULL + }; diff --git a/target/linux/generic/pending-4.14/681-NET-add-of_get_mac_address_mtd.patch b/target/linux/generic/pending-4.14/681-NET-add-of_get_mac_address_mtd.patch index 301cd87ded..2b89a05238 100644 --- a/target/linux/generic/pending-4.14/681-NET-add-of_get_mac_address_mtd.patch +++ b/target/linux/generic/pending-4.14/681-NET-add-of_get_mac_address_mtd.patch @@ -32,62 +32,17 @@ Signed-off-by: Felix Fietkau { struct property *pp = of_find_property(np, name, NULL); -@@ -47,6 +48,133 @@ static const void *of_get_mac_addr(struc +@@ -47,6 +48,79 @@ static const void *of_get_mac_addr(struc return NULL; } -+typedef int(*mtd_mac_address_read)(struct mtd_info *mtd, loff_t from, u_char *buf); -+ -+static int read_mtd_mac_address(struct mtd_info *mtd, loff_t from, u_char *mac) -+{ -+ int retlen; -+ -+ return mtd_read(mtd, from, 6, &retlen, mac); -+} -+ -+static int read_mtd_mac_address_ascii(struct mtd_info *mtd, loff_t from, u_char *mac) -+{ -+ int retlen; -+ char buf[17]; -+ -+ if (mtd_read(mtd, from, 12, &retlen, buf)) { -+ return -1; -+ } -+ if (sscanf(buf, "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", -+ &mac[0], &mac[1], &mac[2], &mac[3], -+ &mac[4], &mac[5]) == 6) { -+ return 0; -+ } -+ if (mtd_read(mtd, from+12, 5, &retlen, buf+12)) { -+ return -1; -+ } -+ if (sscanf(buf, "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", -+ &mac[0], &mac[1], &mac[2], &mac[3], -+ &mac[4], &mac[5]) == 6) { -+ return 0; -+ } -+ return -1; -+} -+ -+static struct mtd_mac_address_property { -+ char *name; -+ mtd_mac_address_read read; -+} mtd_mac_address_properties[] = { -+ { -+ .name = "mtd-mac-address", -+ .read = read_mtd_mac_address, -+ }, { -+ .name = "mtd-mac-address-ascii", -+ .read = read_mtd_mac_address_ascii, -+ }, -+}; -+ +static const void *of_get_mac_address_mtd(struct device_node *np) +{ +#ifdef CONFIG_MTD + struct device_node *mtd_np = NULL; + struct property *prop; -+ int size, ret = -1; ++ size_t retlen; ++ int size, ret; + struct mtd_info *mtd; + const char *part; + const __be32 *list; @@ -96,37 +51,28 @@ Signed-off-by: Felix Fietkau + u8 mac[ETH_ALEN]; + void *addr; + u32 inc_idx; -+ int i; + -+ for (i = 0; i < ARRAY_SIZE(mtd_mac_address_properties); i++) { -+ list = of_get_property(np, mtd_mac_address_properties[i].name, &size); -+ if (!list || (size != (2 * sizeof(*list)))) -+ continue; -+ -+ phandle = be32_to_cpup(list++); -+ if (phandle) -+ mtd_np = of_find_node_by_phandle(phandle); -+ -+ if (!mtd_np) -+ continue; -+ -+ part = of_get_property(mtd_np, "label", NULL); -+ if (!part) -+ part = mtd_np->name; -+ -+ mtd = get_mtd_device_nm(part); -+ if (IS_ERR(mtd)) -+ continue; -+ -+ ret = mtd_mac_address_properties[i].read(mtd, be32_to_cpup(list), mac); -+ put_mtd_device(mtd); -+ if (!ret) { -+ break; -+ } -+ } -+ if (ret) { ++ list = of_get_property(np, "mtd-mac-address", &size); ++ if (!list || (size != (2 * sizeof(*list)))) + return NULL; -+ } ++ ++ phandle = be32_to_cpup(list++); ++ if (phandle) ++ mtd_np = of_find_node_by_phandle(phandle); ++ ++ if (!mtd_np) ++ return NULL; ++ ++ part = of_get_property(mtd_np, "label", NULL); ++ if (!part) ++ part = mtd_np->name; ++ ++ mtd = get_mtd_device_nm(part); ++ if (IS_ERR(mtd)) ++ return NULL; ++ ++ ret = mtd_read(mtd, be32_to_cpup(list), 6, &retlen, mac); ++ put_mtd_device(mtd); + + if (of_property_read_u32(np, "mtd-mac-address-increment-byte", &inc_idx)) + inc_idx = 5; @@ -166,7 +112,7 @@ Signed-off-by: Felix Fietkau /** * Search the device tree for the best MAC address to use. 'mac-address' is * checked first, because that is supposed to contain to "most recent" MAC -@@ -64,11 +192,18 @@ static const void *of_get_mac_addr(struc +@@ -64,11 +138,18 @@ static const void *of_get_mac_addr(struc * addresses. Some older U-Boots only initialized 'local-mac-address'. In * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists * but is all zeros. diff --git a/target/linux/generic/pending-4.19/681-NET-add-of_get_mac_address_mtd.patch b/target/linux/generic/pending-4.19/681-NET-add-of_get_mac_address_mtd.patch index fa019eab00..13f5640590 100644 --- a/target/linux/generic/pending-4.19/681-NET-add-of_get_mac_address_mtd.patch +++ b/target/linux/generic/pending-4.19/681-NET-add-of_get_mac_address_mtd.patch @@ -32,62 +32,17 @@ Signed-off-by: Felix Fietkau { struct property *pp = of_find_property(np, name, NULL); -@@ -48,6 +49,133 @@ static const void *of_get_mac_addr(struc +@@ -48,6 +49,79 @@ static const void *of_get_mac_addr(struc return NULL; } -+typedef int(*mtd_mac_address_read)(struct mtd_info *mtd, loff_t from, u_char *buf); -+ -+static int read_mtd_mac_address(struct mtd_info *mtd, loff_t from, u_char *mac) -+{ -+ int retlen; -+ -+ return mtd_read(mtd, from, 6, &retlen, mac); -+} -+ -+static int read_mtd_mac_address_ascii(struct mtd_info *mtd, loff_t from, u_char *mac) -+{ -+ int retlen; -+ char buf[17]; -+ -+ if (mtd_read(mtd, from, 12, &retlen, buf)) { -+ return -1; -+ } -+ if (sscanf(buf, "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", -+ &mac[0], &mac[1], &mac[2], &mac[3], -+ &mac[4], &mac[5]) == 6) { -+ return 0; -+ } -+ if (mtd_read(mtd, from+12, 5, &retlen, buf+12)) { -+ return -1; -+ } -+ if (sscanf(buf, "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", -+ &mac[0], &mac[1], &mac[2], &mac[3], -+ &mac[4], &mac[5]) == 6) { -+ return 0; -+ } -+ return -1; -+} -+ -+static struct mtd_mac_address_property { -+ char *name; -+ mtd_mac_address_read read; -+} mtd_mac_address_properties[] = { -+ { -+ .name = "mtd-mac-address", -+ .read = read_mtd_mac_address, -+ }, { -+ .name = "mtd-mac-address-ascii", -+ .read = read_mtd_mac_address_ascii, -+ }, -+}; -+ +static const void *of_get_mac_address_mtd(struct device_node *np) +{ +#ifdef CONFIG_MTD + struct device_node *mtd_np = NULL; + struct property *prop; -+ int size, ret = -1; ++ size_t retlen; ++ int size, ret; + struct mtd_info *mtd; + const char *part; + const __be32 *list; @@ -96,37 +51,28 @@ Signed-off-by: Felix Fietkau + u8 mac[ETH_ALEN]; + void *addr; + u32 inc_idx; -+ int i; + -+ for (i = 0; i < ARRAY_SIZE(mtd_mac_address_properties); i++) { -+ list = of_get_property(np, mtd_mac_address_properties[i].name, &size); -+ if (!list || (size != (2 * sizeof(*list)))) -+ continue; -+ -+ phandle = be32_to_cpup(list++); -+ if (phandle) -+ mtd_np = of_find_node_by_phandle(phandle); -+ -+ if (!mtd_np) -+ continue; -+ -+ part = of_get_property(mtd_np, "label", NULL); -+ if (!part) -+ part = mtd_np->name; -+ -+ mtd = get_mtd_device_nm(part); -+ if (IS_ERR(mtd)) -+ continue; -+ -+ ret = mtd_mac_address_properties[i].read(mtd, be32_to_cpup(list), mac); -+ put_mtd_device(mtd); -+ if (!ret) { -+ break; -+ } -+ } -+ if (ret) { ++ list = of_get_property(np, "mtd-mac-address", &size); ++ if (!list || (size != (2 * sizeof(*list)))) + return NULL; -+ } ++ ++ phandle = be32_to_cpup(list++); ++ if (phandle) ++ mtd_np = of_find_node_by_phandle(phandle); ++ ++ if (!mtd_np) ++ return NULL; ++ ++ part = of_get_property(mtd_np, "label", NULL); ++ if (!part) ++ part = mtd_np->name; ++ ++ mtd = get_mtd_device_nm(part); ++ if (IS_ERR(mtd)) ++ return NULL; ++ ++ ret = mtd_read(mtd, be32_to_cpup(list), 6, &retlen, mac); ++ put_mtd_device(mtd); + + if (of_property_read_u32(np, "mtd-mac-address-increment-byte", &inc_idx)) + inc_idx = 5; @@ -166,7 +112,7 @@ Signed-off-by: Felix Fietkau /** * Search the device tree for the best MAC address to use. 'mac-address' is * checked first, because that is supposed to contain to "most recent" MAC -@@ -65,11 +193,18 @@ static const void *of_get_mac_addr(struc +@@ -65,11 +139,18 @@ static const void *of_get_mac_addr(struc * addresses. Some older U-Boots only initialized 'local-mac-address'. In * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists * but is all zeros. diff --git a/target/linux/generic/pending-4.9/681-NET-add-of_get_mac_address_mtd.patch b/target/linux/generic/pending-4.9/681-NET-add-of_get_mac_address_mtd.patch index 301cd87ded..b29b5f11b0 100644 --- a/target/linux/generic/pending-4.9/681-NET-add-of_get_mac_address_mtd.patch +++ b/target/linux/generic/pending-4.9/681-NET-add-of_get_mac_address_mtd.patch @@ -32,62 +32,17 @@ Signed-off-by: Felix Fietkau { struct property *pp = of_find_property(np, name, NULL); -@@ -47,6 +48,133 @@ static const void *of_get_mac_addr(struc +@@ -47,6 +48,73 @@ static const void *of_get_mac_addr(struc return NULL; } -+typedef int(*mtd_mac_address_read)(struct mtd_info *mtd, loff_t from, u_char *buf); -+ -+static int read_mtd_mac_address(struct mtd_info *mtd, loff_t from, u_char *mac) -+{ -+ int retlen; -+ -+ return mtd_read(mtd, from, 6, &retlen, mac); -+} -+ -+static int read_mtd_mac_address_ascii(struct mtd_info *mtd, loff_t from, u_char *mac) -+{ -+ int retlen; -+ char buf[17]; -+ -+ if (mtd_read(mtd, from, 12, &retlen, buf)) { -+ return -1; -+ } -+ if (sscanf(buf, "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", -+ &mac[0], &mac[1], &mac[2], &mac[3], -+ &mac[4], &mac[5]) == 6) { -+ return 0; -+ } -+ if (mtd_read(mtd, from+12, 5, &retlen, buf+12)) { -+ return -1; -+ } -+ if (sscanf(buf, "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", -+ &mac[0], &mac[1], &mac[2], &mac[3], -+ &mac[4], &mac[5]) == 6) { -+ return 0; -+ } -+ return -1; -+} -+ -+static struct mtd_mac_address_property { -+ char *name; -+ mtd_mac_address_read read; -+} mtd_mac_address_properties[] = { -+ { -+ .name = "mtd-mac-address", -+ .read = read_mtd_mac_address, -+ }, { -+ .name = "mtd-mac-address-ascii", -+ .read = read_mtd_mac_address_ascii, -+ }, -+}; -+ +static const void *of_get_mac_address_mtd(struct device_node *np) +{ +#ifdef CONFIG_MTD + struct device_node *mtd_np = NULL; + struct property *prop; -+ int size, ret = -1; ++ size_t retlen; ++ int size, ret; + struct mtd_info *mtd; + const char *part; + const __be32 *list; @@ -95,46 +50,31 @@ Signed-off-by: Felix Fietkau + u32 mac_inc = 0; + u8 mac[ETH_ALEN]; + void *addr; -+ u32 inc_idx; -+ int i; + -+ for (i = 0; i < ARRAY_SIZE(mtd_mac_address_properties); i++) { -+ list = of_get_property(np, mtd_mac_address_properties[i].name, &size); -+ if (!list || (size != (2 * sizeof(*list)))) -+ continue; -+ -+ phandle = be32_to_cpup(list++); -+ if (phandle) -+ mtd_np = of_find_node_by_phandle(phandle); -+ -+ if (!mtd_np) -+ continue; -+ -+ part = of_get_property(mtd_np, "label", NULL); -+ if (!part) -+ part = mtd_np->name; -+ -+ mtd = get_mtd_device_nm(part); -+ if (IS_ERR(mtd)) -+ continue; -+ -+ ret = mtd_mac_address_properties[i].read(mtd, be32_to_cpup(list), mac); -+ put_mtd_device(mtd); -+ if (!ret) { -+ break; -+ } -+ } -+ if (ret) { ++ list = of_get_property(np, "mtd-mac-address", &size); ++ if (!list || (size != (2 * sizeof(*list)))) + return NULL; -+ } + -+ if (of_property_read_u32(np, "mtd-mac-address-increment-byte", &inc_idx)) -+ inc_idx = 5; -+ if (inc_idx > 5) ++ phandle = be32_to_cpup(list++); ++ if (phandle) ++ mtd_np = of_find_node_by_phandle(phandle); ++ ++ if (!mtd_np) + return NULL; + ++ part = of_get_property(mtd_np, "label", NULL); ++ if (!part) ++ part = mtd_np->name; ++ ++ mtd = get_mtd_device_nm(part); ++ if (IS_ERR(mtd)) ++ return NULL; ++ ++ ret = mtd_read(mtd, be32_to_cpup(list), 6, &retlen, mac); ++ put_mtd_device(mtd); ++ + if (!of_property_read_u32(np, "mtd-mac-address-increment", &mac_inc)) -+ mac[inc_idx] += mac_inc; ++ mac[5] += mac_inc; + + if (!is_valid_ether_addr(mac)) + return NULL; @@ -166,7 +106,7 @@ Signed-off-by: Felix Fietkau /** * Search the device tree for the best MAC address to use. 'mac-address' is * checked first, because that is supposed to contain to "most recent" MAC -@@ -64,11 +192,18 @@ static const void *of_get_mac_addr(struc +@@ -64,11 +132,18 @@ static const void *of_get_mac_addr(struc * addresses. Some older U-Boots only initialized 'local-mac-address'. In * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists * but is all zeros.