--- lfs/linux	2026-11-11 17:42:25.615391051 -0800
+++ /mnt/sda1/ipfire-2.x/lfs/linux	2026-11-29 17:36:08.585836456 -0800
@@ -1,8 +1,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2024  IPFire Team  <info@ipfire.org>                     #
-# Copyright (C) 2025-2026  LoongFire Team  <vincent.mc.li@gmail.com>          #
+# Copyright (C) 2007-2026  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -25,7 +24,7 @@
 
 include Config
 
-VER         = 7.3.4
+VER         = 6.18.64
 
 THISAPP    = linux-$(VER)
 DL_FILE    = linux-$(VER).tar.xz
@@ -36,18 +35,18 @@
 KERNEL_ARCH   = $(BUILD_ARCH)
 KERNEL_TARGET = bzImage
 
-ifeq "$(BUILD_ARCH)" "loongarch64"
-	HEADERS_ARCH = loongarch
-	KERNEL_ARCH  = loongarch
-	KERNEL_TARGET = vmlinuz
-endif
-
 ifeq "$(BUILD_ARCH)" "aarch64"
 	HEADERS_ARCH = arm64
 	KERNEL_ARCH  = arm64
 	KERNEL_TARGET = Image
 endif
 
+ifeq "$(BUILD_ARCH)" "loongarch64"
+	HEADERS_ARCH  = loongarch
+	KERNEL_ARCH   = loongarch
+	KERNEL_TARGET = vmlinuz.efi
+endif
+
 ifeq "$(BUILD_ARCH)" "riscv64"
 	KERNEL_ARCH   = riscv
 	KERNEL_TARGET = Image.gz
@@ -76,7 +75,7 @@
 
 $(DL_FILE) = $(URL_IPFIRE)/$(DL_FILE)
 
-$(DL_FILE)_BLAKE2 = 9b75f615d0a03d6627d7e3db4397882d602161db13cd5efd6226e0e5c5f970d1baea676d9d01edd0f09ed0b7207b6421e6340f1b8e9bd4e8152491ddddcc9021
+$(DL_FILE)_BLAKE2 = 2c9130c8a2f57384556517159efbf843771298943d52abfac7cd3bf5524b10213f0972c9cdc5cfc11028300c06e7afc4ba1a84495119316d286e4c5e0f87e652
 
 install : $(TARGET)
 
@@ -89,6 +88,17 @@
 dist:
 	@$(PAK)
 
+.PHONY: configure
+configure:
+	# Extract the sources
+	$(EXTRACT_SOURCES)
+
+	# Run the configure scripts
+	$(SHELL) $(DIR_SRC)/src/kernel/configure \
+		--kernel-dir=$(DIR_APP) \
+		$(CONFIGURE_ARGS)
+
+
 ###############################################################################
 # Downloading, checking, b2sum
 ###############################################################################
@@ -106,26 +116,21 @@
 # Installation Details
 ###############################################################################
 
-$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
-	@$(PREBUILD)
+define EXTRACT_SOURCES
 	@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
 
-	# Conditionally apply SUBLEVEL removal patch if kernel release is x.y like 7.0
-	DOT_COUNT=$$(echo $(VER) | tr -cd '.' | wc -c); \
-	if [ "$$DOT_COUNT" = "1" ]; then \
-		echo "Applying SUBLEVEL removal for VER=$(VER)"; \
-		sed -i 's/^SUBLEVEL = [0-9]\+/SUBLEVEL =/' $(DIR_APP)/Makefile; \
-	fi
+	# Customise the release
+	cd $(DIR_APP) && echo "$(KVER_SUFFIX)" > localversion.10-$(SNAME)
 
 	# Layer7-patch
-	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-6.6.26-layer7.patch
+	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-6.18-layer7.patch
 
 	# DVB Patches
 	cd $(DIR_APP) && patch -Np2 < $(DIR_SRC)/src/patches/v4l-dvb_fix_tua6034_pll.patch
 
 	# Wlan Patches
 	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.14_ath_user_regd.patch
-	#cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.8-iwlwifi-noibss_only_on_radar_chan.patch
+#	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.8-iwlwifi-noibss_only_on_radar_chan.patch
 
 	# Fix igb and e1000e crash
 	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.14.1-igb-e1000e_fix_lock_at_update_stats.patch
@@ -139,31 +144,17 @@
 	# Patch performance monitoring restrictions to allow further hardening
 	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-5.15.17-security-perf-allow-further-restriction-of-perf_event_open.patch
 
-	# Fix external module compile
-	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-6.0-fix_external_module_build.patch
+	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-3.14.79-amba-fix.patch
 
-	# Patch bpf trampoline fixes from loongarch mailing list https://lore.kernel.org/loongarch/20250923085450.140602-1-hengqi.chen@gmail.com/T/#t
-	# b4 am -o . 20250923085450.140602-1-hengqi.chen@gmail.com download and create the patchset mbx file
-	# cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/v6_20250923_hengqi_chen_loongarch_fix_bpf_trampoline_related_issues.mbx
-
-	# Disable bpf trampoline trace to kernel module functions
-	# cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/LoongArch-BPF-Disable-bpf-trampoline-kernel-module-f.patch
-
-	# Patch 6.18.4 for yt6801
-	# cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/007-stmmac-replace-has_xxxx-with-core_type.patch
-	# cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/20251114_linux_net_stmmac_clean_up_plat_dat_allocation_initialisation.mbx
-	# cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/20251119_linux_net_stmmac_simplify_axi_blen_handling.mbx
-	# cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/v5_20251124_ziyao_unify_platform_suspend_resume_routines_for_pci_dwmac_glue.mbx
-	# cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/v6_20260109_me_add_dwmac_glue_driver_for_motorcomm_yt6801.mbx
-
-ifeq "$(BUILD_ARCH)" "aarch64"
 	# Apply Arm kernel patches.
 	cd $(DIR_APP) && cat patch $(DIR_SRC)/src/patches/linux/aarch64/* | patch -Np1
-endif
-	#cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-3.14.79-amba-fix.patch
+endef
 
-	# Customise the release
-	cd $(DIR_APP) && echo "$(KVER_SUFFIX)" > localversion.10-$(SNAME)
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
+	@$(PREBUILD)
+
+	# Extract the sources
+	$(EXTRACT_SOURCES)
 
 ifeq "$(HEADERS)" "1"
 	# Install the header files
@@ -175,11 +166,20 @@
 else
 
 	# Install ipfire logo
-	cd $(DIR_APP) && cp -vf $(DIR_SRC)/config/kernel/loongfire_logo.ppm \
+	cd $(DIR_APP) && cp -vf $(DIR_SRC)/config/kernel/ipfire_logo.ppm \
 		drivers/video/logo/logo_linux_clut224.ppm
 
+	# Fetch the configuration
+	$(SHELL) $(DIR_SRC)/src/kernel/configure --kernel-dir="$(DIR_APP)" merge \
+		"$(BUILD_ARCH)" "generic" "$(DIR_APP)/.config"
+
+	# Fail if the configuration does not answer all questions
+	cd $(DIR_APP) && if make -s listnewconfig | grep "^CONFIG_"; then \
+		echo "The kernel configuration is incomplete for $(BUILD_ARCH)" >&2; \
+		exit 1; \
+	fi
+
 	# Cleanup kernel source
-	cp $(DIR_SRC)/config/kernel/kernel.config.$(BUILD_ARCH)$(KVER_SUFFIX) $(DIR_APP)/.config
 	cd $(DIR_APP) && make oldconfig
 	cd $(DIR_APP) && make clean
 
@@ -190,27 +190,13 @@
 	rm -rf /lib/modules/$(KVER)
 
 	# Build the kernel
-	# Loongarch64 make requires no argument to build vmlinuz and EFI under arch/loongarch/boot
-ifeq "$(BUILD_ARCH)" "loongarch64"
-	cd $(DIR_APP) && make $(MAKETUNING)
-else
 	cd $(DIR_APP) && make $(MAKETUNING) $(KERNEL_TARGET) modules
-endif
-	# Build objtool
-	cd $(DIR_APP)/tools/objtool && make $(MAKETUNING)
-
-        # Build bpftool
-	cd $(DIR_APP)/tools/bpf/bpftool && sed -i -e 's/^prefix ?= \/usr\/local/prefix ?= \/usr/' Makefile
-	cd $(DIR_APP)/tools/bpf/bpftool && make $(MAKETUNING)
-
-	# Build perf tool
-	cd $(DIR_APP)/tools/perf && NO_JEVENTS=1 NO_LIBTRACEEVENT=1 make LDFLAGS="-Wl,--no-eh-frame-hdr" $(MAKETUNING) WERROR=0
 
 	# Install the kernel
 	cd $(DIR_APP) && cp -v arch/$(KERNEL_ARCH)/boot/$(KERNEL_TARGET) /boot/vmlinuz-$(KVER)
 	cd $(DIR_APP) && cp -v System.map /boot/System.map-$(KVER)
 	cd $(DIR_APP) && cp -v .config /boot/config-$(KVER)
-	cd $(DIR_APP) && INSTALL_MOD_STRIP=1 make $(MAKETUNING) modules_install
+	cd $(DIR_APP) && make $(MAKETUNING) modules_install INSTALL_MOD_STRIP=1
 
 ifneq "$(BUILD_PLATFORM)" "x86"
 	cd $(DIR_APP) && make $(MAKETUNING) dtbs
@@ -226,9 +212,6 @@
 	mkdir -p /lib/modules/$(KVER)/build
 	ln -sf build /lib/modules/$(KVER)/source
 
-	# Create dirs for extra modules
-	mkdir -p /lib/modules/$(KVER)/extra
-
 	cd $(DIR_APP) && cp --parents $$(find -type f -name "Makefile*" -o -name "Kconfig*") \
 		/lib/modules/$(KVER)/build
 	cd $(DIR_APP) && cp Module.symvers System.map /lib/modules/$(KVER)/build
@@ -250,12 +233,6 @@
 	cd $(DIR_APP) && cp -a --parents tools/build/{Build.include,fixdep.c} \
 		tools/scripts/utilities.mak /lib/modules/$(KVER)/build
 
-	# Install bpftool
-	cd $(DIR_APP)/tools/bpf/bpftool && make install
-
-	# Install perf tool
-	cd $(DIR_APP)/tools/perf && install -m 755 perf /usr/sbin/
-
 	# Make sure we can build external modules
 	touch -r /lib/modules/$(KVER)/build/Makefile \
 		/lib/modules/$(KVER)/build/include/generated/uapi/linux/version.h
@@ -273,19 +250,6 @@
 	# Only do this once
 	cd $(DIR_APP) && install -m 755 usr/gen_init_cpio /sbin/
 
-	# disable drm by install drm to /bin/false because i915 ignore blacklisting
-	echo install drm /bin/false > /etc/modprobe.d/framebuffer.conf
-
-	# Blacklist old framebuffer modules
-	for f in $$(find /lib/modules/$(KVER)/kernel/drivers/video/fbdev/ -name *.ko.xz); do \
-		echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer.conf ; \
-	done
-	# Blacklist new drm framebuffer modules
-	for f in $$(find /lib/modules/$(KVER)/kernel/drivers/gpu/drm -name *.ko.xz); do \
-		echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer.conf ; \
-	done
-	sed -i -e "s|.ko.xz||g" /etc/modprobe.d/framebuffer.conf
-
 	# Disable ipv6 at runtime
 	echo "options ipv6 disable_ipv6=1" > /etc/modprobe.d/ipv6.conf
 
