Merge Official Source

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2022-07-05 17:49:45 +08:00
commit 7b9bb83525
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
11 changed files with 349 additions and 10 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=json-c
PKG_VERSION:=0.16
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-nodoc.tar.gz
PKG_SOURCE_URL:=https://s3.amazonaws.com/json-c_releases/releases/
@ -27,8 +27,12 @@ include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/cmake.mk
CMAKE_HOST_OPTIONS += \
-DDISABLE_EXTRA_LIBS=TRUE \
-DBUILD_SHARED_LIBS=FALSE
CMAKE_OPTIONS += \
-DDISABLE_EXTRA_LIBS=TRUE
define Package/libjson-c
SECTION:=libs
CATEGORY:=Libraries

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=openssl
PKG_BASE:=1.1.1
PKG_BUGFIX:=o
PKG_BUGFIX:=p
PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX)
PKG_RELEASE:=$(AUTORELEASE)
PKG_USE_MIPS16:=0
@ -27,7 +27,7 @@ PKG_SOURCE_URL:= \
ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/ \
ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/old/$(PKG_BASE)/
PKG_HASH:=9384a2b0570dd80358841464677115df785edb941c71211f75076d72fe6b438f
PKG_HASH:=bf61b62aaa66c7c7639942a94de4c9ae8280c08f17d4eac2e44644d9fc8ace6f
PKG_LICENSE:=OpenSSL
PKG_LICENSE_FILES:=LICENSE

View File

@ -0,0 +1,131 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=xdp-tools
PKG_RELEASE:=$(AUTORELEASE)
PKG_VERSION:=1.2.5
PKG_HASH:=140c9bdffe4f2b15bc2973b5f975d0fa5cc011f5a699c7bcdcb698b724b97d4d
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/xdp-project/xdp-tools/tar.gz/v$(PKG_VERSION)?
PKG_ABI_VERSION:=$(call abi_version_str,$(PKG_VERSION))
PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
PKG_BUILD_DEPENDS:=bpf-headers
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/bpf.mk
PKG_BUILD_PARALLEL:=1
PKG_INSTALL:=1
define Package/libxdp
SECTION:=libs
CATEGORY:=Libraries
TITLE:=libxdp - Library for use with XDP
LICENSE:=LGPL-2.1 OR BSD-2-Clause
ABI_VERSION:=$(PKG_ABI_VERSION)
URL:=https://github.com/xdp-project/xdp-tools/
DEPENDS:=+libbpf $(BPF_DEPENDS)
endef
define Package/libxdp/description
libxdp - library for attaching XDP programs and using AF_XDP sockets
endef
define Package/xdp-tools/Default
SECTION:=net
CATEGORY:=Network
LICENSE:=GPL-2.0-only
URL:=https://github.com/xdp-project/xdp-tools/
DEPENDS:=+libxdp
endef
define Package/xdp-filter
$(call Package/xdp-tools/Default)
TITLE:=xdp-filter - a simple XDP-powered packet filter
endef
define Package/xdp-filter/description
xdp-filter is a packet filtering utility powered by XDP. It is deliberately
simple and so does not have the same matching capabilities as, e.g.,
netfilter. Instead, thanks to XDP, it can achieve very high drop rates:
tens of millions of packets per second on a single CPU core.
endef
define Package/xdp-loader
$(call Package/xdp-tools/Default)
TITLE:=xdp-loader - an XDP program loader
endef
define Package/xdp-loader/description
xdp-loader is a simple loader for XDP programs with support for attaching
multiple programs to the same interface. To achieve this it exposes the same
load and unload semantics exposed by the libxdp library.
endef
define Package/xdpdump
$(call Package/xdp-tools/Default)
TITLE:=xdpdump - tool for capturing packets at the XDP layer
DEPENDS+=+libpcap
endef
define Package/xdpdump/description
xdpdump - a simple tcpdump like tool for capturing packets at the XDP layer
endef
CONFIGURE_VARS += \
FORCE_SYSTEM_LIBBPF=1 \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
CLANG="$(CLANG)" \
BPF_CFLAGS="$(BPF_CFLAGS)" \
BPF_TARGET="$(BPF_TARGET)" \
LLC="$(LLVM_LLC)"
MAKE_VARS += \
PREFIX=/usr \
RUNDIR=/tmp/run
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include/xdp
$(CP) $(PKG_INSTALL_DIR)/usr/include/xdp/*.h $(1)/usr/include/xdp/
$(INSTALL_DIR) $(1)/usr/lib/bpf
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libxdp.{a,so*} $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/bpf/*.o $(1)/usr/lib/bpf
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libxdp.pc \
$(1)/usr/lib/pkgconfig/
$(SED) 's,/usr/include,$$$${prefix}/include,g' \
$(1)/usr/lib/pkgconfig/libxdp.pc
$(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' \
$(1)/usr/lib/pkgconfig/libxdp.pc
endef
define Package/xdp-filter/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xdp-filter $(1)/usr/sbin
endef
define Package/xdp-loader/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xdp-loader $(1)/usr/sbin
endef
define Package/xdpdump/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xdpdump $(1)/usr/sbin
endef
define Package/libxdp/install
$(INSTALL_DIR) $(1)/usr/lib/bpf
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libxdp.so.* $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/bpf/*.o $(1)/usr/lib/bpf
endef
$(eval $(call BuildPackage,libxdp))
$(eval $(call BuildPackage,xdp-filter))
$(eval $(call BuildPackage,xdp-loader))
$(eval $(call BuildPackage,xdpdump))

View File

@ -99,7 +99,9 @@ endef
CONFIGURE_ARGS += \
--disable-static \
--without-blkid
--without-blkid \
--without-lzo2 \
--without-lz4
ifneq ($(BUILD_VARIANT),selinux)
CONFIGURE_ARGS += --without-selinux

View File

@ -0,0 +1,80 @@
From 821a1d3fcce31c234512a8f4dc4fc97dfbd7ae32 Mon Sep 17 00:00:00 2001
From: Nick Hainke <vincent@systemli.org>
Date: Mon, 4 Jul 2022 09:46:10 +0200
Subject: [PATCH] configure.ac: fix cross compilation
AC_CHECK_LIB seems to not work correctly with OpenWrt. Add possibility
to disable lz4 and lzo2 manually.
Fixes errors in the form of:
Package f2fsck is missing dependencies for the following libraries:
liblz4.so.1
liblzo2.so.2
Signed-off-by: Nick Hainke <vincent@systemli.org>
---
configure.ac | 44 ++++++++++++++++++++++++++++++++++----------
1 file changed, 34 insertions(+), 10 deletions(-)
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,18 @@ AC_ARG_WITH([blkid],
[],
[with_blkid=check])
+AC_ARG_WITH([lzo2],
+ [AS_HELP_STRING([--without-lzo2],
+ [Ignore presence of liblzo2 and disable lzo2 support])],
+ [],
+ [with_lzo2=check])
+
+AC_ARG_WITH([lz4],
+ [AS_HELP_STRING([--without-lz4],
+ [Ignore presence of liblz4 and disable lz4 support])],
+ [],
+ [with_lz4=check])
+
# Checks for programs.
AC_PROG_CC
AM_PROG_AR
@@ -71,17 +83,29 @@ AS_IF([test "x$with_blkid" != xno],
fi
], -lblkid)])
-AC_CHECK_LIB([lzo2], [main],
- [AC_SUBST([liblzo2_LIBS], ["-llzo2"])
- AC_DEFINE([HAVE_LIBLZO2], [1],
- [Define if you have liblzo2])
- ], [], [])
-
-AC_CHECK_LIB([lz4], [main],
- [AC_SUBST([liblz4_LIBS], ["-llz4"])
- AC_DEFINE([HAVE_LIBLZ4], [1],
- [Define if you have liblz4])
- ], [], [])
+AS_IF([test "x$with_lzo2" != xno],
+ [AC_CHECK_LIB([lzo2], [main],
+ [AC_SUBST([liblzo2_LIBS], ["-llzo2"])
+ AC_DEFINE([HAVE_LIBLZO2], [1],
+ [Define if you have liblzo2])
+ ],
+ [if test "x$with_lzo2" != xcheck; then
+ AC_MSG_FAILURE(
+ [--with-lzo2 was given, but test for lzo2 failed])
+ fi
+ ], -llzo2)])
+
+AS_IF([test "x$with_lz4" != xno],
+ [AC_CHECK_LIB([lz4], [main],
+ [AC_SUBST([liblz4_LIBS], ["-llz4"])
+ AC_DEFINE([HAVE_LIBLZ4], [1],
+ [Define if you have liblz4])
+ ],
+ [if test "x$with_lz4" != xcheck; then
+ AC_MSG_FAILURE(
+ [--with-lz4 was given, but test for lz4 failed])
+ fi
+ ], -llz4)])
AS_IF([test "x$with_selinux" != xno],
[AC_CHECK_LIB([selinux], [getcon],

117
scripts/cameo-tag.py Executable file
View File

@ -0,0 +1,117 @@
#!/usr/bin/python3
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright (C) 2022 OpenWrt.org
#
# ./cameo-tag.py <uImageFileName> <OffsetOfRootFS>
#
# CAMEO tag generator used for the D-Link DGS-1210 switches. Their U-Boot
# loader checks for the string CAMEOTAG and a checksum in the kernel and
# rootfs partitions. If not found it complains about the boot image.
# Nevertheless it will boot if the tags are available in the secondary
# boot partitions. If some day we want to overwrite the original vendor
# partition we must have the tags in place. To solve this we insert the
# tag two times into the kernel image.
#
# To understand what we do here it is helpful to explain how the original
# CAMEO tag generation/checking works. The firmware consists of two parts.
# A kernel uImage (<1.5MB) and a rootfs image (<12MB) that are written to
# their respective mtd partitions. The default generator simply checksums
# both parts and appends 16 bytes [<CAMEOTAG><0001><checksum>] to each part.
# The checksum is only an addition of all preceding bytes (b0+b1+b2+...).
# A tag does not interfere with any data in the images itself. During boot
# the loader will scan all primary/secondary partitions (2*kernel, 2*rootfs)
# until it finds the CAMEO tag. If checksums match everything is fine.
# If all 4 fail we are lost. Luckily the loader does not care about where
# the tags are located and ignores any data beyond a tag.
#
# The OpenWrt image consists of a kernel (>1.5MB) and a rootfs. There is
# no chance to add CAMEO tags at the default locations, since the kernel spans
# both the original kernel partition and the start of the rootfs partition.
# This would leave the kernel partition without a tag. So we must find suitable
# space.
#
# Location for original kernel partition is at the end of the uImage header.
# We will reuse the last bytes of the IH_NAME field. This is the tricky part
# because we have the header CRC and the CAMEO checksum that must match the
# whole header. uImage header CRC checksums all data except the CRC itself. The
# for CAMEO checksum in turn, checksums all preceding data except itself.
# Changing one of both results in a change of the other, but data trailing the
# CAMEO checksum only influences the CRC.
#
# Location for original rootfs partition is very simple. It is behind the
# OpenWrt compressed kernel image file that spans into the rootfs. So
# the tag will be written somewhere to the following rootfs partition and
# can be found by U-Boot. The CAMEO checksum calculation must start at the
# offset of the original rootfs partition and includes the "second" half of the
# "split" kernel uImage.
import argparse
import os
import zlib
READ_UNTIL_EOF = -1
UIMAGE_HEADER_SIZE = 64
UIMAGE_CRC_OFF = 4
UIMAGE_CRC_END = 8
UIMAGE_NAME_OFF = 32
UIMAGE_NAME_END = 56
UIMAGE_SUM_OFF = 56
UIMAGE_SUM_END = 60
UIMAGE_INV_OFF = 60
UIMAGE_INV_END = 64
CAMEO_TAG = bytes([0x43, 0x41, 0x4d, 0x45, 0x4f, 0x54, 0x41, 0x47, 0x00, 0x00, 0x00, 0x01])
IMAGE_NAME = bytes([0x4f, 0x70, 0x65, 0x6e, 0x57, 0x72, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00])
CRC_00 = bytes([0x00] * 4)
CRC_FF = bytes([0xff] * 4)
def read_buffer(offset, count):
args.uimage_file.seek(offset)
return bytearray(args.uimage_file.read(count))
def write_buffer(whence, buf):
args.uimage_file.seek(0, whence)
args.uimage_file.write(buf)
def cameosum(buf):
return (sum(buf) & 0xffffffff).to_bytes(4, 'big')
def invertcrc(buf):
return (zlib.crc32(buf) ^ 0xffffffff).to_bytes(4, 'little')
def checksum_header(buf):
# To efficently get a combination, we will make use of the following fact:
# crc32(data + littleendian(crc32(data) ^ 0xffffffff)) = 0xffffffff
#
# After manipulation the uImage header looks like this:
# [...<ffffffff>...<OpenWrt><000000><CAMEOTAG><0001><checksum><InvCRC>]
buf[UIMAGE_NAME_OFF:UIMAGE_NAME_END] = IMAGE_NAME + CAMEO_TAG
buf[UIMAGE_CRC_OFF:UIMAGE_CRC_END] = CRC_FF
buf[UIMAGE_SUM_OFF:UIMAGE_SUM_END] = cameosum(buf[0:UIMAGE_NAME_END])
buf[UIMAGE_CRC_OFF:UIMAGE_CRC_END] = CRC_00
buf[UIMAGE_INV_OFF:UIMAGE_INV_END] = invertcrc(buf[0:UIMAGE_SUM_END])
buf[UIMAGE_CRC_OFF:UIMAGE_CRC_END] = CRC_FF
return buf
parser = argparse.ArgumentParser(description='Insert CAMEO firmware tags.')
parser.add_argument('uimage_file', type=argparse.FileType('r+b'))
parser.add_argument('rootfs_start', type=int)
args = parser.parse_args()
args.uimage_file.seek(0, os.SEEK_END)
if args.uimage_file.tell() <= args.rootfs_start:
raise ValueError(f"uImage must be larger than {args.rootfs_start} bytes")
# tag for the uImage Header of 64 bytes inside the kernel
# partition. Read and mangle it so it contains a valid CAMEO tag
# and checksum that matches perfectly to the uImage header CRC.
buf = checksum_header(read_buffer(0, UIMAGE_HEADER_SIZE))
write_buffer(os.SEEK_SET, buf)
# tag for the second part of the kernel that resides in the
# vendor rootfs partition. For this we will add the CAMEO tag
# and the checksum to the end of the image.
buf = read_buffer(args.rootfs_start, READ_UNTIL_EOF)
write_buffer(os.SEEK_END, CAMEO_TAG + cameosum(buf + CAMEO_TAG))

View File

@ -1278,7 +1278,7 @@ static int ag71xx_tx_packets(struct ag71xx *ag, bool flush)
if (!skb)
continue;
dev_kfree_skb_any(skb);
napi_consume_skb(skb, !flush);
ring->buf[i].skb = NULL;
bytes_compl += ring->buf[i].len;
@ -1352,7 +1352,11 @@ static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
dev->stats.rx_packets++;
dev->stats.rx_bytes += pktlen;
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,12,0)
skb = build_skb(ring->buf[i].rx_buf, ag71xx_buffer_size(ag));
#else
skb = napi_build_skb(ring->buf[i].rx_buf, ag71xx_buffer_size(ag));
#endif
if (!skb) {
skb_free_frag(ring->buf[i].rx_buf);
goto next;

View File

@ -13,13 +13,11 @@
led_white: dome_white {
label = "white:dome";
linux,default-trigger = "default-on";
gpios = <&pio 0x43 GPIO_ACTIVE_HIGH>;
gpios = <&pio 0x43 GPIO_ACTIVE_LOW>;
};
led_blue: dome_blue {
label = "blue:dome";
default-state = "off";
gpios = <&pio 0x44 GPIO_ACTIVE_HIGH>;
};
};

View File

@ -68,7 +68,6 @@ define Device/iei_puzzle-m901
DEVICE_VENDOR := iEi
DEVICE_MODEL := Puzzle-M901
SOC := cn9131
IMAGE/sdcard.img.gz := boot-img-ext4 | sdcard-img-ext4 | gzip | append-metadata
endef
TARGET_DEVICES += iei_puzzle-m901
@ -77,6 +76,5 @@ define Device/iei_puzzle-m902
DEVICE_VENDOR := iEi
DEVICE_MODEL := Puzzle-M902
SOC := cn9132
IMAGE/sdcard.img.gz := boot-img-ext4 | sdcard-img-ext4 | gzip | append-metadata
endef
TARGET_DEVICES += iei_puzzle-m902

View File

@ -17,6 +17,10 @@ define Build/zyxel-vers
done ) >> $@
endef
define Build/dlink-cameo
$(SCRIPT_DIR)/cameo-tag.py $@ $(DLINK_KERNEL_PART_SIZE)
endef
define Build/dlink-headers
dd if=$@ bs=$(DLINK_KERNEL_PART_SIZE) count=1 of=$@.kernel_part; \
dd if=$@ bs=$(DLINK_KERNEL_PART_SIZE) skip=1 of=$@.rootfs_part; \

View File

@ -16,6 +16,7 @@ define Device/d-link_dgs-1210
IMAGE_SIZE := 13824k
DEVICE_VENDOR := D-Link
DLINK_KERNEL_PART_SIZE := 1572864
KERNEL := kernel-bin | append-dtb | gzip | uImage gzip | dlink-cameo
endef
define Device/d-link_dgs-1210-10p