Merge Official Source

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2023-11-16 13:43:08 +08:00
commit 7fb31f2164
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
9 changed files with 129 additions and 3 deletions

View File

@ -40,8 +40,10 @@ IMG_PREFIX_VERCODE:=$(if $(CONFIG_VERSION_CODE_FILENAMES),$(call sanitize,$(VERS
IMG_PREFIX:=$(VERSION_DIST_SANITIZED)-$(IMG_PREFIX_VERNUM)$(IMG_PREFIX_VERCODE)$(IMG_PREFIX_EXTRA)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
IMG_ROOTFS:=$(IMG_PREFIX)-rootfs
IMG_COMBINED:=$(IMG_PREFIX)-combined
ifeq ($(DUMP),)
IMG_PART_SIGNATURE:=$(shell echo $(SOURCE_DATE_EPOCH)$(LINUX_VERMAGIC) | $(MKHASH) md5 | cut -b1-8)
IMG_PART_DISKGUID:=$(shell echo $(SOURCE_DATE_EPOCH)$(LINUX_VERMAGIC) | $(MKHASH) md5 | sed -E 's/(.{8})(.{4})(.{4})(.{4})(.{10})../\1-\2-\3-\4-\500/')
endif
MKFS_DEVTABLE_OPT := -D $(INCLUDE_DIR)/device_table.txt
@ -167,7 +169,9 @@ define Image/pad-to
mv $(1).new $(1)
endef
ifeq ($(DUMP),)
ROOTFS_PARTSIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_PARTSIZE)*1024*1024)))
endif
define Image/pad-root-squashfs
$(call Image/pad-to,$(KDIR)/root.squashfs,$(if $(1),$(1),$(ROOTFS_PARTSIZE)))

View File

@ -50,7 +50,8 @@ define PackageDir
$$(call progress,Collecting $(SCAN_NAME) info: $(SCAN_DIR)/$(2)) \
echo Source-Makefile: $(SCAN_DIR)/$(2)/Makefile; \
$(if $(3),echo Override: $(3),true); \
$(NO_TRACE_MAKE) --no-print-dir -r DUMP=1 FEED="$(call feedname,$(2))" -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) 2>/dev/null || { \
$(if $(findstring c,$(OPENWRT_VERBOSE)),$(MAKE),$(NO_TRACE_MAKE) --no-print-dir) -r DUMP=1 FEED="$(call feedname,$(2))" -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) \
$(if $(findstring c,$(OPENWRT_VERBOSE)),,2>/dev/null) || { \
mkdir -p "$(TOPDIR)/logs/$(SCAN_DIR)/$(2)"; \
$(NO_TRACE_MAKE) --no-print-dir -r DUMP=1 FEED="$(call feedname,$(2))" -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) > $(TOPDIR)/logs/$(SCAN_DIR)/$(2)/dump.txt 2>&1; \
$$(call progress,ERROR: please fix $(SCAN_DIR)/$(2)/Makefile - see logs/$(SCAN_DIR)/$(2)/dump.txt for details\n) \

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=netifd
PKG_RELEASE:=1
PKG_RELEASE:=1.1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git

View File

@ -0,0 +1,32 @@
From 8587c074f1eb2064c42adb0a6aa5073f695ab89d Mon Sep 17 00:00:00 2001
From: Jo-Philipp Wich <jo@mein.io>
Date: Tue, 14 Nov 2023 14:01:44 +0100
Subject: [PATCH] interface-ip: fix IPv4 route target masking
A previous commit supposed to mask out excess host bits in route targets
failed to correctly calculate the mask value, causing it to produce
improper results for certain mask lengths.
Fixes: #17
Fixes: 76eb342 ("interface-ip: mask out host bits in IPv4 route targets")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
---
interface-ip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/interface-ip.c b/interface-ip.c
index d2fe385..28e7106 100644
--- a/interface-ip.c
+++ b/interface-ip.c
@@ -448,7 +448,7 @@ interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6)
/* Mask out IPv4 host bits to avoid "Invalid prefix for given prefix length" */
if (af == AF_INET && route->mask < 32)
- route->addr.in.s_addr &= ((1u << route->mask) - 1);
+ clear_if_addr(&route->addr, route->mask);
}
if ((cur = tb[ROUTE_GATEWAY]) != NULL) {
--
2.39.1

View File

@ -4,7 +4,7 @@ use strict;
use warnings;
use Cwd;
my (%targets, %architectures, %kernels);
my (%targets, %architectures, %kernels, %devices);
$ENV{'TOPDIR'} = Cwd::getcwd();
@ -56,6 +56,68 @@ sub parse_targetinfo {
}
}
sub parse_devices {
my ($target_dir, $subtarget) = @_;
if (open M, "make -C '$target_dir' --no-print-directory DUMP=1 TARGET_BUILD=1 SUBTARGET='$subtarget' V=s |") {
my ($device_profile, $device_name, @device_alt_names, $device_is_alt);
while (defined(my $line = readline M)) {
chomp $line;
if ($line =~ /^Target-Profile-Name: (.+)$/) {
$device_name = $1;
}
elsif ($line =~ /^Target-Profile: DEVICE_(.+)$/) {
$device_profile = $1;
}
# Logic behind this.
# DUMP duplicate info for each alternative device name and
# the alternative device name are printed first before the
# primary device name
# Alternative device titles always have the full list of
# all the alternative device name.
# The device name pattern for an alternative device name is
# Target-Profile-Name: ALT_NAME (PRIMARY_NAME)
# We compare the detected device name and check if it does
# match the alternative device name pattern with one of
# the alternative device name in Alternative device titles:
# If an alternative device name is detected,
# alternative device is skipped.
elsif ($line =~ /^Alternative device titles:$/) {
while (defined($line = readline M)) {
if ($line =~ /^- (.+)$/) {
if ($device_name =~ /^\Q$1\E \((.+)\)$/) {
$device_is_alt = 1;
last;
}
push @device_alt_names, $1;
}
else {
last;
}
}
}
if ($line =~ /^@\@$/) {
if ($device_name && $device_profile && ! $device_is_alt) {
push @{$devices{$device_profile}}, $device_name;
if (scalar @device_alt_names) {
foreach my $device_alt_name (sort values @device_alt_names) {
push @{$devices{$device_profile}}, $device_alt_name;
}
}
}
undef $device_name;
undef $device_profile;
undef $device_is_alt;
@device_alt_names = ();
}
}
close M;
}
}
sub get_targetinfo {
foreach my $target_makefile (glob "target/linux/*/Makefile") {
my ($target_dir) = $target_makefile =~ m!^(.+)/Makefile$!;
@ -86,6 +148,15 @@ sub get_targetinfo {
}
}
sub get_devices {
my ($target_subtarget) = @_;
my ($target, $subtarget) = split /\//, $target_subtarget;
my ($target_dir) = "target/linux/" . $target;
parse_devices($target_dir, $subtarget)
}
if (@ARGV == 1 && $ARGV[0] eq 'targets') {
get_targetinfo();
foreach my $target_name (sort keys %targets) {
@ -104,8 +175,15 @@ elsif (@ARGV == 1 && $ARGV[0] eq 'kernels') {
printf "%s %s\n", $target_name, join ' ', @{$kernels{$target_name}};
}
}
elsif (@ARGV == 2 && $ARGV[0] eq 'devices') {
get_devices($ARGV[1]);
foreach my $device (sort keys %devices) {
printf "%s \"%s\"\n", $device, join '" "', @{$devices{$device}};
}
}
else {
print "Usage: $0 targets\n";
print "Usage: $0 architectures\n";
print "Usage: $0 kernels\n";
print "Usage: $0 devices <target/subtarget>\n";
}

View File

@ -8,8 +8,11 @@ include $(INCLUDE_DIR)/image.mk
LS_SD_KERNELPART_SIZE = 40
LS_SD_KERNELPART_OFFSET = 16
LS_SD_ROOTFSPART_OFFSET = 64
ifeq ($(DUMP),)
LS_SD_IMAGE_SIZE = $(shell echo $$((($(LS_SD_ROOTFSPART_OFFSET) + \
$(CONFIG_TARGET_ROOTFS_PARTSIZE)))))
endif
# The limitation of flash sysupgrade.bin is 1MB dtb + 16MB kernel + 32MB rootfs
LS_SYSUPGRADE_IMAGE_SIZE = 49m

View File

@ -198,7 +198,9 @@ define Device/bananapi_bpi-r3
pad-to 64M | append-image squashfs-sysupgrade.itb | check-size |\
) \
gzip
ifeq ($(DUMP),)
IMAGE_SIZE := $$(shell expr 64 + $$(CONFIG_TARGET_ROOTFS_PARTSIZE))m
endif
KERNEL := kernel-bin | gzip
KERNEL_INITRAMFS := kernel-bin | lzma | \
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k

View File

@ -94,7 +94,9 @@ define Device/bananapi_bpi-r64
pad-to 46080k | append-image squashfs-sysupgrade.itb | check-size |\
) \
gzip
ifeq ($(DUMP),)
IMAGE_SIZE := $$(shell expr 45 + $$(CONFIG_TARGET_ROOTFS_PARTSIZE))m
endif
KERNEL := kernel-bin | gzip
KERNEL_INITRAMFS := kernel-bin | lzma | fit lzma $$(DTS_DIR)/$$(DEVICE_DTS).dtb with-initrd | pad-to 128k
IMAGE/sysupgrade.itb := append-kernel | fit gzip $$(DTS_DIR)/$$(DEVICE_DTS).dtb external-static-with-rootfs | append-metadata

View File

@ -96,7 +96,9 @@ define Device/bananapi_bpi-r2
KERNEL := kernel-bin | gzip
KERNEL_INITRAMFS_SUFFIX := -recovery.itb
KERNEL_INITRAMFS := kernel-bin | gzip | fit gzip $$(DTS_DIR)/$$(DEVICE_DTS).dtb with-initrd
ifeq ($(DUMP),)
IMAGE_SIZE := $$(shell expr 48 + $$(CONFIG_TARGET_ROOTFS_PARTSIZE))m
endif
IMAGE/sysupgrade.itb := append-kernel | fit gzip $$(DTS_DIR)/$$(DEVICE_DTS).dtb external-static-with-rootfs | append-metadata
ARTIFACT/preloader.bin := mt7623-mbr emmc |\
pad-to 2k | append-preloader $$(UBOOT_TARGET)
@ -130,7 +132,9 @@ define Device/unielec_u7623-02
UBOOT_TARGET := mt7623a_unielec_u7623
UBOOT_IMAGE := u-boot-mtk.bin
UBOOT_PATH := $(STAGING_DIR_IMAGE)/$$(UBOOT_TARGET)-$$(UBOOT_IMAGE)
ifeq ($(DUMP),)
IMAGE_SIZE := $$(shell expr 48 + $$(CONFIG_TARGET_ROOTFS_PARTSIZE))m
endif
IMAGES := sysupgrade.itb
KERNEL := kernel-bin | gzip
KERNEL_INITRAMFS_SUFFIX := -recovery.itb