Update OWRT Source

This commit is contained in:
VIKINGYFY 2025-02-26 17:30:00 +08:00
parent 07089cedb8
commit f7449a50e1
294 changed files with 14107 additions and 3664 deletions

View File

@ -38,3 +38,5 @@ source "target/sdk/Config.in"
source "target/toolchain/Config.in"
source "tmp/.config-package.in"
source "config/Config-ipq.in"

View File

@ -1,93 +1,15 @@
<img src="https://avatars.githubusercontent.com/u/53193414?s=200&v=4" alt="logo" width="200" height="200" align="right">
# 分支说明
main 为高通专用无法编译其他平台带满血NSS驱动。
# Project ImmortalWrt
owrt 为多平台通用可编译高通平台但没有NSS驱动。
ImmortalWrt is a fork of [OpenWrt](https://openwrt.org), with more packages ported, more devices supported, default optimized profiles and localization modifications for mainland China users.<br/>
Compared to upstream, we allow to use (non-upstreamable) modifications/hacks to provide better feature/performance/support.
# 自用 ImmortalWRT
高通部分源码取自以下项目:
Default login address: http://192.168.1.1 or http://immortalwrt.lan, username: __root__, password: _none_.
https://github.com/JiaY-shi/openwrt.git
## Download
Built firmware images are available for many architectures and come with a package selection to be used as WiFi home router. To quickly find a factory image usable to migrate from a vendor stock firmware to ImmortalWrt, try the *Firmware Selector*.
https://github.com/LiBwrt/openwrt-6.x.git
- [ImmortalWrt Firmware Selector](https://firmware-selector.immortalwrt.org/)
https://github.com/qosmio/openwrt-ipq.git
If your device is supported, please follow the **Info** link to see install instructions or consult the support resources listed below.
## Development
To build your own firmware you need a GNU/Linux, BSD or macOS system (case sensitive filesystem required). Cygwin is unsupported because of the lack of a case sensitive file system.<br/>
### Requirements
To build with this project, Debian 11 is preferred. And you need use the CPU based on AMD64 architecture, with at least 4GB RAM and 25 GB available disk space. Make sure the __Internet__ is accessible.
The following tools are needed to compile ImmortalWrt, the package names vary between distributions.
- Here is an example for Debian/Ubuntu users:<br/>
- Method 1:
<details>
<summary>Setup dependencies via APT</summary>
```bash
sudo apt update -y
sudo apt full-upgrade -y
sudo apt install -y ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \
bzip2 ccache clang cmake cpio curl device-tree-compiler ecj fastjar flex gawk gettext gcc-multilib \
g++-multilib git gnutls-dev gperf haveged help2man intltool lib32gcc-s1 libc6-dev-i386 libelf-dev \
libglib2.0-dev libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses-dev libpython3-dev \
libreadline-dev libssl-dev libtool libyaml-dev libz-dev lld llvm lrzsz mkisofs msmtp nano \
ninja-build p7zip p7zip-full patch pkgconf python3 python3-pip python3-ply python3-docutils \
python3-pyelftools qemu-utils re2c rsync scons squashfs-tools subversion swig texinfo uglifyjs \
upx-ucl unzip vim wget xmlto xxd zlib1g-dev zstd
```
</details>
- Method 2:
```bash
sudo bash -c 'bash <(curl -s https://build-scripts.immortalwrt.org/init_build_environment.sh)'
```
Note:
- Do everything as an unprivileged user, not root, without sudo.
- Using CPUs based on other architectures should be fine to compile ImmortalWrt, but more hacks are needed - No warranty at all.
- You must __not__ have spaces or non-ascii characters in PATH or in the work folders on the drive.
- If you're using Windows Subsystem for Linux (or WSL), removing Windows folders from PATH is required, please see [Build system setup WSL](https://openwrt.org/docs/guide-developer/build-system/wsl) documentation.
- Using macOS as the host build OS is __not__ recommended. No warranty at all. You can get tips from [Build system setup macOS](https://openwrt.org/docs/guide-developer/build-system/buildroot.exigence.macosx) documentation.
- For more details, please see [Build system setup](https://openwrt.org/docs/guide-developer/build-system/install-buildsystem) documentation.
### Quickstart
1. Run `git clone -b <branch> --single-branch --filter=blob:none https://github.com/immortalwrt/immortalwrt` to clone the source code.
2. Run `cd immortalwrt` to enter source directory.
3. Run `./scripts/feeds update -a` to obtain all the latest package definitions defined in feeds.conf / feeds.conf.default
4. Run `./scripts/feeds install -a` to install symlinks for all obtained packages into package/feeds/
5. Run `make menuconfig` to select your preferred configuration for the toolchain, target system & firmware packages.
6. Run `make` to build your firmware. This will download all sources, build the cross-compile toolchain and then cross-compile the GNU/Linux kernel & all chosen applications for your target system.
### Related Repositories
The main repository uses multiple sub-repositories to manage packages of different categories. All packages are installed via the OpenWrt package manager called opkg. If you're looking to develop the web interface or port packages to ImmortalWrt, please find the fitting repository below.
- [LuCI Web Interface](https://github.com/immortalwrt/luci): Modern and modular interface to control the device via a web browser.
- [ImmortalWrt Packages](https://github.com/immortalwrt/packages): Community repository of ported packages.
- [OpenWrt Routing](https://github.com/openwrt/routing): Packages specifically focused on (mesh) routing.
- [OpenWrt Video](https://github.com/openwrt/video): Packages specifically focused on display servers and clients (Xorg and Wayland).
## Support Information
For a list of supported devices see the [OpenWrt Hardware Database](https://openwrt.org/supported_devices)
### Documentation
- [Quick Start Guide](https://openwrt.org/docs/guide-quick-start/start)
- [User Guide](https://openwrt.org/docs/guide-user/start)
- [Developer Documentation](https://openwrt.org/docs/guide-developer/start)
- [Technical Reference](https://openwrt.org/docs/techref/start)
### Support Community
- Support Chat: group [@ctcgfw_openwrt_discuss](https://t.me/ctcgfw_openwrt_discuss) on [Telegram](https://telegram.org/).
- Support Chat: group [#immortalwrt](https://matrix.to/#/#immortalwrt:matrix.org) on [Matrix](https://matrix.org/).
## License
ImmortalWrt is licensed under [GPL-2.0-only](https://spdx.org/licenses/GPL-2.0-only.html).
## Acknowledgements
<table>
<tr>
<td><a href="https://dlercloud.com/"><img src="https://user-images.githubusercontent.com/22235437/111103249-f9ec6e00-8588-11eb-9bfc-67cc55574555.png" width="183" height="52" border="0" alt="Dler Cloud"></a></td>
<td><a href="https://www.jetbrains.com/"><img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_square.png" width="120" height="120" border="0" alt="JetBrains Black Box Logo logo"></a></td>
<td><a href="https://sourceforge.net/"><img src="https://sourceforge.net/sflogo.php?type=17&group_id=3663829" alt="SourceForge" width=200></a></td>
</tr>
</table>
https://github.com/King-Of-Knights/openwrt-6.x.git

View File

@ -313,8 +313,8 @@ menu "Target Images"
config TARGET_ROOTFS_PARTSIZE
int "Root filesystem partition size (in MiB)"
depends on USES_ROOTFS_PART || TARGET_ROOTFS_EXT4FS
default 300 if BUILDBOT
default 160
default 512 if BUILDBOT
default 1024
help
Select the root filesystem partition size.

145
config/Config-ipq.in Normal file
View File

@ -0,0 +1,145 @@
# vim: set ft=kconfig
menu "Qualcomm IPQ Options"
comment "Kernel build options"
choice KERNEL_IPQ_MEM_PROFILE
prompt "IPQ memory profile"
default IPQ_MEM_PROFILE_1024
config IPQ_MEM_PROFILE_1024
bool "1024"
config IPQ_MEM_PROFILE_512
bool "512"
config IPQ_MEM_PROFILE_256
bool "256"
endchoice
config KERNEL_IPQ_MEM_PROFILE
int
default 1024 if IPQ_MEM_PROFILE_1024
default 512 if IPQ_MEM_PROFILE_512
default 256 if IPQ_MEM_PROFILE_256
help
This option select memory profile to used, which defines
the reserved memory configuration used in device tree
config KERNEL_SKB_RECYCLER
bool "Generic SKB recycling"
default y if KERNEL_IPQ_MEM_PROFILE > 256
choice KERNEL_SKB_RECYCLE_SIZE
prompt "SKB recycler size"
default SKB_RECYCLE_SIZE_2304
default SKB_RECYCLE_SIZE_1856 if KERNEL_IPQ_MEM_PROFILE < 1024
depends on KERNEL_SKB_RECYCLER
config SKB_RECYCLE_SIZE_1856
bool "1856"
config SKB_RECYCLE_SIZE_2304
bool "2304"
endchoice
config KERNEL_SKB_RECYCLE_SIZE
int
depends on KERNEL_SKB_RECYCLER
default 2304 if SKB_RECYCLE_SIZE_2304
default 1856 if SKB_RECYCLE_SIZE_1856
help
SKB recycler default size
config KERNEL_SKB_RECYCLER_MULTI_CPU
bool "Cross-CPU recycling for CPU-locked workloads"
depends on KERNEL_SKB_RECYCLER
default y
config KERNEL_SKB_RECYCLER_PREALLOC
bool "Enable preallocation of SKBs (For SFE not NSS)"
depends on KERNEL_SKB_RECYCLER
default n
help
NOTE: This is primarily for platforms utilizing SFE (Shortcut Forwarding Engine)
and not NSS (Network Subsystem) offload.
NSS offload platforms mostly utilize the SKB recycling feature when managing memory.
Mostly when to "reclaim" it.
This option enables preallocation of SKBs.
The default is '16384' which means 16384 x 4096 (Size of SKB) = 64MB.
config KERNEL_SKB_RECYCLE_MAX_PREALLOC_SKBS
int "Number of SKBs to be preallocated"
depends on KERNEL_SKB_RECYCLER_PREALLOC
default 16384
config KERNEL_SKB_FIXED_SIZE_2K
bool "SKB size fixed at 2K"
default n
default y if KERNEL_IPQ_MEM_PROFILE < 512
help
SKB size fixed at 2K. Primarily for platforms with less than 512MB memory.
config KERNEL_ALLOC_SKB_PAGE_FRAG_DISABLE
depends on KERNEL_SKB_RECYCLER
bool "Disable alloc skb page frag"
default n
choice KERNEL_PREEMPTION
prompt "Kernel preemption level"
default KERNEL_PREEMPT
config KERNEL_PREEMPT_NONE
bool "No Forced Preemption (Server)"
help
This is the traditional Linux preemption model, geared towards
throughput. It will still provide good latencies most of the time,
but there are no guarantees and occasional longer delays are
possible.
Select this option if you are building a kernel for a server or
scientific/computation system, or if you want to maximize the
raw processing power of the kernel, irrespective of scheduling
latencies.
config KERNEL_PREEMPT_NONE_BUILD
depends on KERNEL_PREEMPT_NONE
bool
default y
config KERNEL_PREEMPT
bool "Preemptible Kernel (Low-Latency)"
help
This option reduces the latency of the kernel by making
all kernel code (that is not executing in a critical section)
preemptible. This allows reaction to interactive events by
permitting a low priority process to be preempted involuntarily
even if it is in kernel mode executing a system call and would
otherwise not be about to reach a natural preemption point.
This allows applications to run more 'smoothly' even when the
system is under load, at the cost of slightly lower throughput
and a slight runtime overhead to kernel code.
Select this if you are building a kernel for a desktop or
embedded system with latency requirements in the milliseconds
range.
if KERNEL_PREEMPT
config KERNEL_PREEMPT_RCU
bool "Preemptible RCU"
default y
select KERNEL_PREEMPT_COUNT
help
This option selects the RCU implementation that is
designed for very large SMP systems with hundreds or
thousands of CPUs, but for which real-time response
is also required. It also scales down nicely to
smaller systems.
Select this option if you are unsure.
endif
endchoice
endmenu

View File

@ -312,8 +312,8 @@ generate_static_system() {
delete system.@system[0]
add system system
set system.@system[-1].hostname='ImmortalWrt'
set system.@system[-1].timezone='GMT0'
set system.@system[-1].zonename='UTC'
set system.@system[-1].timezone="CST-8"
set system.@system[-1].zonename="Asia/Shanghai"
set system.@system[-1].ttylogin='0'
set system.@system[-1].log_size='128'
set system.@system[-1].urandom_seed='0'
@ -322,10 +322,10 @@ generate_static_system() {
set system.ntp='timeserver'
set system.ntp.enabled='1'
set system.ntp.enable_server='0'
add_list system.ntp.server='time1.apple.com'
add_list system.ntp.server='time1.google.com'
add_list system.ntp.server='time.cloudflare.com'
add_list system.ntp.server='pool.ntp.org'
add_list system.ntp.server="ntp.tencent.com"
add_list system.ntp.server="ntp.aliyun.com"
add_list system.ntp.server="ntp.ntsc.ac.cn"
add_list system.ntp.server="cn.ntp.org.cn"
EOF
if json_is_a system object; then

View File

0
package/base-files/files/etc/hotplug.d/leds/00-init Normal file → Executable file
View File

0
package/base-files/files/etc/hotplug.d/net/00-sysctl Normal file → Executable file
View File

0
package/base-files/files/etc/sysctl.d/10-default.conf Normal file → Executable file
View File

View File

View File

View File

View File

View File

View File

@ -0,0 +1,34 @@
#!/bin/sh
# 检查 network.globals.ula_prefix 是否存在且不为空
ula_prefix=$(uci get network.globals.ula_prefix 2>/dev/null)
if [ -n "$ula_prefix" ]; then
uci set dhcp.wan6=dhcp
uci set dhcp.wan6.interface='wan6'
uci set dhcp.wan6.ignore='1'
uci set dhcp.lan.force='1'
uci set dhcp.lan.ra='hybrid'
uci set dhcp.lan.ra_default='1'
uci set dhcp.lan.max_preferred_lifetime='1800'
uci set dhcp.lan.max_valid_lifetime='3600'
uci del dhcp.lan.dhcpv6
uci del dhcp.lan.ra_flags
uci del dhcp.lan.ra_slaac
uci add_list dhcp.lan.ra_flags='none'
uci commit dhcp
uci set network.wan6.reqaddress='try'
uci set network.wan6.reqprefix='auto'
uci set network.lan.ip6assign='64'
uci set network.lan.ip6ifaceid='eui64'
uci set network.globals.packet_steering='0'
uci del network.globals.ula_prefix
uci commit network
fi
exit 0

View File

@ -0,0 +1,7 @@
#!/bin/sh
/etc/init.d/network restart
/etc/init.d/odhcpd restart
/etc/init.d/rpcd restart
exit 0

View File

@ -1,5 +1,4 @@
# Copyright (C) 2021 OpenWrt.org
#
. /lib/functions.sh
@ -29,8 +28,7 @@ emmc_upgrade_tar() {
sync
}
[ "$has_kernel" = 1 -a "$EMMC_KERN_DEV" ] &&
export EMMC_KERNEL_BLOCKS=$(($(tar xf "$tar_file" ${board_dir}/kernel -O | dd of="$EMMC_KERN_DEV" bs=512 2>&1 | grep "records out" | cut -d' ' -f1)))
[ "$has_kernel" = 1 -a "$EMMC_KERN_DEV" ] && export EMMC_KERNEL_BLOCKS=$(($(tar xf "$tar_file" ${board_dir}/kernel -O | dd of="$EMMC_KERN_DEV" bs=512 2>&1 | grep "records out" | cut -d' ' -f1)))
if [ -z "$UPGRADE_BACKUP" ]; then
if [ "$EMMC_DATA_DEV" ]; then

View File

@ -64,7 +64,8 @@ glinet,gl-mt6000|\
glinet,gl-x3000|\
glinet,gl-xe3000|\
huasifei,wh3000-emmc|\
nradio,c8-668gl)
nradio,c8-668gl|\
superbox,s20-plus)
local envdev=$(find_mmc_part "u-boot-env")
ubootenv_add_uci_config "$envdev" "0x0" "0x80000"
;;

View File

@ -7,13 +7,29 @@ touch /etc/config/ubootenv
board=$(board_name)
ubootenv_add_mtd() {
local idx="$(find_mtd_index "${1}")"
[ -n "$idx" ] && ubootenv_add_uci_config "/dev/mtd$idx" "${2}" "${3}" "${4}"
}
ubootenv_add_sys_mtd() {
local idx="$(find_mtd_index "${1}")"
[ -n "$idx" ] && ubootenv_add_uci_sys_config "/dev/mtd$idx" "${2}" "${3}" "${4}"
}
ubootenv_add_mmc() {
local mmcpart="$(find_mmc_part "${1}")"
[ -n "$mmcpart" ] && ubootenv_add_uci_config "$mmcpart" "${2}" "${3}" "${4}" "${5}"
}
case "$board" in
linksys,mx2000|\
linksys,mx5500|\
linksys,spnmx56)
idx="$(find_mtd_index u_env)"
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x40000" "0x20000"
ubootenv_add_mtd "/dev/mtd$idx" "0x0" "0x40000" "0x20000"
;;
jdcloud,re-cs-03)
ubootenv_add_mmc "0:APPSBLENV" "0x0" "0x40000" "0x20000"
;;
esac

View File

@ -9,8 +9,17 @@ board=$(board_name)
ubootenv_add_mtd() {
local idx="$(find_mtd_index "${1}")"
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "${2}" "${3}" "${4}"
[ -n "$idx" ] && ubootenv_add_uci_config "/dev/mtd$idx" "${2}" "${3}" "${4}"
}
ubootenv_add_sys_mtd() {
local idx="$(find_mtd_index "${1}")"
[ -n "$idx" ] && ubootenv_add_uci_sys_config "/dev/mtd$idx" "${2}" "${3}" "${4}"
}
ubootenv_add_mmc() {
local mmcpart="$(find_mmc_part "${1}")"
[ -n "$mmcpart" ] && ubootenv_add_uci_config "$mmcpart" "${2}" "${3}" "${4}" "${5}"
}
case "$board" in
@ -22,6 +31,13 @@ cambiumnetworks,xe3-4)
linksys,mr7350)
ubootenv_add_mtd "u_env" "0x0" "0x40000" "0x20000"
;;
cmiot,ax18|\
glinet,gl-ax1800|\
glinet,gl-axt1800|\
qihoo,360v6|\
redmi,ax5|\
xiaomi,ax1800|\
zn,m2|\
netgear,wax214|\
tplink,eap610-outdoor)
ubootenv_add_mtd "0:appsblenv" "0x0" "0x40000" "0x20000"
@ -29,6 +45,14 @@ tplink,eap610-outdoor)
yuncore,fap650)
ubootenv_add_mtd "0:appsblenv" "0x0" "0x10000" "0x10000"
;;
jdcloud,re-ss-01|\
jdcloud,re-cs-02|\
jdcloud,re-cs-07|\
link,nn6000-v1|\
link,nn6000-v2|\
redmi,ax5-jdcloud)
ubootenv_add_mmc "0:APPSBLENV" "0x0" "0x40000" "0x20000"
;;
esac
config_load ubootenv

View File

@ -9,20 +9,17 @@ board=$(board_name)
ubootenv_add_mtd() {
local idx="$(find_mtd_index "${1}")"
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "${2}" "${3}" "${4}"
[ -n "$idx" ] && ubootenv_add_uci_config "/dev/mtd$idx" "${2}" "${3}" "${4}"
}
ubootenv_add_sys_mtd() {
local idx="$(find_mtd_index "${1}")"
[ -n "$idx" ] && \
ubootenv_add_uci_sys_config "/dev/mtd$idx" "${2}" "${3}" "${4}"
[ -n "$idx" ] && ubootenv_add_uci_sys_config "/dev/mtd$idx" "${2}" "${3}" "${4}"
}
ubootenv_add_mmc() {
local mmcpart="$(find_mmc_part "${1}")"
[ -n "$mmcpart" ] && \
ubootenv_add_uci_config "$mmcpart" "${2}" "${3}" "${4}" "${5}"
[ -n "$mmcpart" ] && ubootenv_add_uci_config "$mmcpart" "${2}" "${3}" "${4}" "${5}"
}
case "$board" in
@ -74,8 +71,9 @@ asus,rt-ax89x|\
qnap,301w)
ubootenv_add_mtd "0:appsblenv" "0x0" "0x20000" "0x20000"
;;
spectrum,sax1v1k)
ubootenv_add_mmc "0:APPSBLENV" "0x0" "0x40000" "0x40000" "1"
spectrum,sax1v1k|\
verizon,cr1000a)
ubootenv_add_mmc "0:APPSBLENV" "0x0" "0x40000" "0x40000"
;;
esac

View File

@ -117,6 +117,13 @@ define U-Boot/rk3399/Default
ATF:=$(RK3399_ATF)
endef
define U-Boot/fine3399-rk3399
$(U-Boot/rk3399/Default)
NAME:=Fine 3399
BUILD_DEVICES:= \
rumu3f_fine-3399
endef
define U-Boot/guangmiao-g4c-rk3399
$(U-Boot/rk3399/Default)
NAME:=GuangMiao G4C
@ -385,6 +392,7 @@ define U-Boot/rock5a-rk3588s
endef
UBOOT_TARGETS := \
fine3399-rk3399 \
guangmiao-g4c-rk3399 \
nanopc-t4-rk3399 \
nanopi-r4s-rk3399 \

View File

@ -1,12 +1,13 @@
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -87,6 +87,23 @@ dtb-$(CONFIG_ROCKCHIP_RK3368) += \
@@ -87,6 +87,24 @@ dtb-$(CONFIG_ROCKCHIP_RK3368) += \
rk3368-geekbox.dtb \
rk3368-px5-evb.dtb \
+dtb-$(CONFIG_ROCKCHIP_RK3399) += \
+ rk3399-guangmiao-g4c.dtb \
+ rk3399-nanopi-r4se.dtb
+ rk3399-nanopi-r4se.dtb \
+ rk3399-fine-3399.dtb
+
+dtb-$(CONFIG_ROCKCHIP_RK3566) += \
+ rk3566-nanopi-r3s.dtb \

View File

@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-2.0
#include "rk3399-u-boot.dtsi"
#include "rk3399-sdram-lpddr4-100.dtsi"
/ {
chosen {
u-boot,spl-boot-order = "same-as-spl", &sdhci, &sdmmc;
};
};
&vdd_log {
regulator-init-microvolt = <950000>;
};

View File

@ -0,0 +1,789 @@
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/dts-v1/;
#include <dt-bindings/input/input.h>
#include <dt-bindings/pwm/pwm.h>
#include "rk3399.dtsi"
#include "rk3399-op1-opp.dtsi"
/ {
model = "RUMU3F Fine3399";
compatible = "rockchip,rk3399";
aliases {
ethernet0 = &gmac;
mmc0 = &sdio0;
mmc1 = &sdmmc;
mmc2 = &sdhci;
};
chosen {
stdout-path = "serial2:1500000n8";
};
clkin_gmac: external-gmac-clock {
compatible = "fixed-clock";
clock-frequency = <125000000>;
clock-output-names = "clkin_gmac";
#clock-cells = <0>;
};
dc_12v: dc-12v {
compatible = "regulator-fixed";
regulator-name = "dc_12v";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <12000000>;
regulator-max-microvolt = <12000000>;
};
sdio_pwrseq: sdio-pwrseq {
compatible = "mmc-pwrseq-simple";
clocks = <&rk808 1>;
clock-names = "ext_clock";
pinctrl-names = "default";
pinctrl-0 = <&wifi_reg_on_h>;
reset-gpios = <&gpio0 RK_PB2 GPIO_ACTIVE_LOW>;
};
/* switched by pmic_sleep */
vcc1v8_s3: vcca1v8_s3: vcc1v8-s3 {
compatible = "regulator-fixed";
regulator-name = "vcc1v8_s3";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
vin-supply = <&vcc_1v8>;
};
vcc3v3_sys: vcc3v3-sys {
compatible = "regulator-fixed";
regulator-name = "vcc3v3_sys";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
vin-supply = <&dc_12v>;
};
vcc_sys: vcc-sys {
compatible = "regulator-fixed";
regulator-name = "vcc_sys";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
vin-supply = <&dc_12v>;
};
vcc_phy: vcc-phy-regulator {
compatible = "regulator-fixed";
enable-active-high;
gpio = <&gpio0 RK_PB4 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&vcc_phy_h>;
regulator-name = "vcc_phy";
regulator-always-on;
regulator-boot-on;
};
vdd_log: vdd-log {
compatible = "pwm-regulator";
pwms = <&pwm2 0 25000 1>;
regulator-name = "vdd_log";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1400000>;
vin-supply = <&vcc_sys>;
};
leds: gpio-leds {
compatible = "gpio-leds";
pinctrl-names = "default";
pinctrl-0 = <&user_led2>;
user_led2 {
label = "blue:work_led";
gpios = <&gpio2 RK_PD3 GPIO_ACTIVE_LOW>;
linux,default-trigger = "heartbeat";
};
};
gpio-keys {
compatible = "gpio-keys";
autorepeat;
pinctrl-names = "default";
pinctrl-0 = <&power_key>;
key-power {
debounce-interval = <100>;
gpios = <&gpio0 RK_PA5 GPIO_ACTIVE_LOW>;
label = "GPIO Key Power";
linux,code = <KEY_POWER>;
wakeup-source;
};
};
fan0: pwm-fan {
compatible = "pwm-fan";
cooling-levels = <0 25 50 75 100 150>;
#cooling-cells = <2>;
fan-supply = <&vcc_sys>;
pwms = <&pwm1 0 40000 0>;
};
backlight: backlight {
compatible = "pwm-backlight";
brightness-levels = <0 36 72 108 144 180 216 255>;
default-brightness-level = <5>;
pwms = <&pwm0 0 1000000 0>;
};
ir-receiver {
compatible = "gpio-ir-receiver";
gpios = <&gpio0 RK_PA6 GPIO_ACTIVE_LOW>;
pinctrl-names = "default";
pinctrl-0 = <&ir_int>;
};
adc-keys {
compatible = "adc-keys";
io-channels = <&saradc 1>;
io-channel-names = "buttons";
keyup-threshold-microvolt = <1750000>;
poll-interval = <100>;
recovery {
label = "Recovery";
linux,code = <KEY_VENDOR>;
press-threshold-microvolt = <0>;
};
};
};
&cpu_l0 {
cpu-supply = <&vdd_cpu_l>;
};
&cpu_l1 {
cpu-supply = <&vdd_cpu_l>;
};
&cpu_l2 {
cpu-supply = <&vdd_cpu_l>;
};
&cpu_l3 {
cpu-supply = <&vdd_cpu_l>;
};
&cpu_b0 {
cpu-supply = <&vdd_cpu_b>;
};
&cpu_b1 {
cpu-supply = <&vdd_cpu_b>;
};
&gpu {
mali-supply = <&vdd_gpu>;
status = "okay";
};
&cpu_thermal {
trips {
cpu_hot: cpu_hot {
hysteresis = <10000>;
temperature = <55000>;
type = "active";
};
};
cooling-maps {
map2 {
cooling-device =
<&fan0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
trip = <&cpu_hot>;
};
};
};
&emmc_phy {
status = "okay";
};
&gmac {
assigned-clocks = <&cru SCLK_RMII_SRC>;
assigned-clock-parents = <&clkin_gmac>;
clock_in_out = "input";
phy-supply = <&vcc_phy>;
phy-mode = "rgmii";
pinctrl-names = "default";
pinctrl-0 = <&rgmii_pins>;
snps,reset-gpio = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
snps,reset-active-low;
snps,reset-delays-us = <0 10000 50000>;
tx_delay = <0x28>;
rx_delay = <0x11>;
status = "okay";
};
&hdmi {
ddc-i2c-bus = <&i2c3>;
pinctrl-names = "default";
pinctrl-0 = <&hdmi_cec>;
status = "okay";
};
&hdmi_sound {
status = "okay";
};
&i2c0 {
clock-frequency = <400000>;
i2c-scl-rising-time-ns = <168>;
i2c-scl-falling-time-ns = <4>;
status = "okay";
rk808: pmic@1b {
compatible = "rockchip,rk808";
reg = <0x1b>;
interrupt-parent = <&gpio1>;
interrupts = <RK_PC5 IRQ_TYPE_LEVEL_LOW>;
#clock-cells = <1>;
clock-output-names = "xin32k", "rk808-clkout2";
pinctrl-names = "default";
pinctrl-0 = <&pmic_int_l &pmic_dvs2>;
rockchip,system-power-controller;
wakeup-source;
vcc1-supply = <&vcc3v3_sys>;
vcc2-supply = <&vcc3v3_sys>;
vcc3-supply = <&vcc3v3_sys>;
vcc4-supply = <&vcc3v3_sys>;
vcc6-supply = <&vcc3v3_sys>;
vcc7-supply = <&vcc3v3_sys>;
vcc8-supply = <&vcc3v3_sys>;
vcc9-supply = <&vcc3v3_sys>;
vcc10-supply = <&vcc3v3_sys>;
vcc11-supply = <&vcc3v3_sys>;
vcc12-supply = <&vcc3v3_sys>;
vddio-supply = <&vcc1v8_pmu>;
regulators {
vdd_center: DCDC_REG1 {
regulator-name = "vdd_center";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <750000>;
regulator-max-microvolt = <1350000>;
regulator-ramp-delay = <6001>;
regulator-state-mem {
regulator-off-in-suspend;
};
};
vdd_cpu_l: DCDC_REG2 {
regulator-name = "vdd_cpu_l";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <750000>;
regulator-max-microvolt = <1350000>;
regulator-ramp-delay = <6001>;
regulator-state-mem {
regulator-off-in-suspend;
};
};
vcc_ddr: DCDC_REG3 {
regulator-name = "vcc_ddr";
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
regulator-on-in-suspend;
};
};
vcc_1v8: DCDC_REG4 {
regulator-name = "vcc_1v8";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-state-mem {
regulator-on-in-suspend;
regulator-suspend-microvolt = <1800000>;
};
};
vcc1v8_dvp: LDO_REG1 {
regulator-name = "vcc1v8_dvp";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-state-mem {
regulator-off-in-suspend;
};
};
vcc3v0_tp: LDO_REG2 {
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <3000000>;
regulator-max-microvolt = <3000000>;
regulator-name = "vcc3v0_tp";
regulator-state-mem {
regulator-off-in-suspend;
};
};
vcc1v8_pmu: LDO_REG3 {
regulator-name = "vcc1v8_pmu";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-state-mem {
regulator-on-in-suspend;
regulator-suspend-microvolt = <1800000>;
};
};
vcc_sd: LDO_REG4 {
regulator-name = "vcc_sd";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-state-mem {
regulator-on-in-suspend;
regulator-suspend-microvolt = <3300000>;
};
};
vcca3v0_codec: LDO_REG5 {
regulator-name = "vcca3v0_codec";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <3000000>;
regulator-max-microvolt = <3000000>;
regulator-state-mem {
regulator-off-in-suspend;
};
};
vcc_1v5: LDO_REG6 {
regulator-name = "vcc_1v5";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <1500000>;
regulator-max-microvolt = <1500000>;
regulator-state-mem {
regulator-on-in-suspend;
regulator-suspend-microvolt = <1500000>;
};
};
vcca1v8_codec: LDO_REG7 {
regulator-name = "vcca1v8_codec";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-state-mem {
regulator-off-in-suspend;
};
};
vcc_3v0: LDO_REG8 {
regulator-name = "vcc_3v0";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <3000000>;
regulator-max-microvolt = <3000000>;
regulator-state-mem {
regulator-on-in-suspend;
regulator-suspend-microvolt = <3000000>;
};
};
vcc3v3_s3: SWITCH_REG1 {
regulator-name = "vcc3v3_s3";
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
regulator-off-in-suspend;
};
};
vcc3v3_s0: SWITCH_REG2 {
regulator-name = "vcc3v3_s0";
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
regulator-off-in-suspend;
};
};
};
};
vdd_cpu_b: regulator@40 {
compatible = "silergy,syr827";
reg = <0x40>;
fcs,suspend-voltage-selector = <1>;
pinctrl-names = "default";
pinctrl-0 = <&cpu_b_sleep>;
regulator-name = "vdd_cpu_b";
regulator-min-microvolt = <712500>;
regulator-max-microvolt = <1500000>;
regulator-ramp-delay = <1000>;
regulator-always-on;
regulator-boot-on;
vin-supply = <&vcc_sys>;
regulator-state-mem {
regulator-off-in-suspend;
};
};
vdd_gpu: regulator@41 {
compatible = "silergy,syr828";
reg = <0x41>;
fcs,suspend-voltage-selector = <1>;
pinctrl-names = "default";
pinctrl-0 = <&gpu_sleep>;
regulator-name = "vdd_gpu";
regulator-min-microvolt = <712500>;
regulator-max-microvolt = <1500000>;
regulator-ramp-delay = <1000>;
regulator-always-on;
regulator-boot-on;
vin-supply = <&vcc_sys>;
regulator-state-mem {
regulator-off-in-suspend;
};
};
};
&i2c3 {
i2c-scl-rising-time-ns = <450>;
i2c-scl-falling-time-ns = <15>;
status = "okay";
};
&i2s2 {
#sound-dai-cells = <0>;
status = "okay";
};
&iep_mmu {
status = "okay";
};
&io_domains {
status = "okay";
bt656-supply = <&vcc_3v0>;
audio-supply = <&vcca1v8_codec>;
sdmmc-supply = <&vcc_sd>;
gpio1830-supply = <&vcc_3v0>;
};
&pmu_io_domains {
status = "okay";
pmu1830-supply = <&vcc_1v8>;
};
&pcie_phy {
status = "okay";
};
&pcie0 {
ep-gpios = <&gpio4 RK_PD3 GPIO_ACTIVE_HIGH>;
max-link-speed = <2>;
num-lanes = <2>;
pinctrl-names = "default";
pinctrl-0 = <&pcie_clkreqn_cpm>;
status = "okay";
};
&pinctrl {
pmic {
cpu_b_sleep: cpu-b-sleep {
rockchip,pins = <1 RK_PC1 RK_FUNC_GPIO &pcfg_pull_down>;
};
gpu_sleep: gpu-sleep {
rockchip,pins = <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_down>;
};
pmic_int_l: pmic-int-l {
rockchip,pins = <1 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>;
};
pmic_dvs2: pmic-dvs2 {
rockchip,pins = <1 RK_PC2 RK_FUNC_GPIO &pcfg_pull_down>;
};
};
sdio-pwrseq {
wifi_reg_on_h: wifi-reg-on-h {
rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_none>;
};
};
wifi {
wifi_host_wake_l: wifi-host-wake-l {
rockchip,pins = <0 RK_PA3 RK_FUNC_GPIO &pcfg_pull_none>;
};
};
bt {
bt_enable_h: bt-enable-h {
rockchip,pins = <0 RK_PB1 RK_FUNC_GPIO &pcfg_pull_none>;
};
bt_host_wake_l: bt-host-wake-l {
rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_pull_down>;
};
bt_wake_l: bt-wake-l {
rockchip,pins = <2 RK_PD2 RK_FUNC_GPIO &pcfg_pull_none>;
};
};
gmac {
vcc_phy_h: vcc-phy-h {
rockchip,pins = <0 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>;
};
};
leds {
user_led2: user_led2 {
rockchip,pins = <2 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>;
};
};
ir {
ir_int: ir-int {
rockchip,pins = <0 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>;
};
};
buttons {
power_key: power_key {
rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>;
};
};
};
&pwm0 {
status = "okay";
};
&pwm1 {
status = "okay";
};
&pwm2 {
status = "okay";
};
&saradc {
vref-supply = <&vcca1v8_s3>;
status = "okay";
};
&sdio0 {
#address-cells = <1>;
#size-cells = <0>;
bus-width = <4>;
cap-sd-highspeed;
cap-sdio-irq;
clock-frequency = <50000000>;
disable-wp;
keep-power-in-suspend;
max-frequency = <50000000>;
mmc-pwrseq = <&sdio_pwrseq>;
non-removable;
pinctrl-names = "default";
pinctrl-0 = <&sdio0_bus4 &sdio0_cmd &sdio0_clk>;
sd-uhs-sdr104;
status = "okay";
brcmf: wifi@1 {
reg = <1>;
compatible = "brcm,bcm4329-fmac";
interrupt-parent = <&gpio0>;
interrupts = <RK_PA3 GPIO_ACTIVE_HIGH>;
interrupt-names = "host-wake";
brcm,drive-strength = <5>;
pinctrl-names = "default";
pinctrl-0 = <&wifi_host_wake_l>;
};
};
&sdmmc {
bus-width = <4>;
cap-sd-highspeed;
cd-gpios = <&gpio0 RK_PA7 GPIO_ACTIVE_LOW>;
clock-frequency = <150000000>;
disable-wp;
sd-uhs-sdr104;
max-frequency = <150000000>;
pinctrl-names = "default";
pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_cd &sdmmc_bus4>;
vqmmc-supply = <&vcc_sd>;
status = "okay";
};
&sdhci {
bus-width = <8>;
mmc-hs400-1_8v;
mmc-hs400-enhanced-strobe;
keep-power-in-suspend;
non-removable;
status = "okay";
};
&spi2 {
status = "okay";
panel@0 {
compatible = "sitronix,st7735s", "sitronix,st7735r", "sitronix,st7789v", "jianda,jd-t18003-t01";
reg = <0>;
rgb;
width = <80>;
height = <160>;
fps = <30>;
buswidth = <8>;
rotate = <270>;
backlight = <&backlight>;
dc-gpios = <&gpio4 RK_PD5 GPIO_ACTIVE_HIGH>;
reset-gpios = <&gpio4 RK_PD1 GPIO_ACTIVE_LOW>;
led-gpios = <&gpio4 RK_PC2 GPIO_ACTIVE_HIGH>;
spi-max-frequency = <32000000>;
debug = <0>;
spi-cpol;
spi-cpha;
};
};
&tcphy0 {
status = "okay";
};
&tcphy1 {
status = "okay";
};
&tsadc {
/* tshut mode 0:CRU 1:GPIO */
rockchip,hw-tshut-mode = <1>;
/* tshut polarity 0:LOW 1:HIGH */
rockchip,hw-tshut-polarity = <1>;
status = "okay";
};
&u2phy0 {
status = "okay";
u2phy0_otg: otg-port {
status = "okay";
};
u2phy0_host: host-port {
status = "okay";
};
};
&u2phy1 {
status = "okay";
u2phy1_otg: otg-port {
status = "okay";
};
u2phy1_host: host-port {
status = "okay";
};
};
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_xfer &uart0_cts &uart0_rts>;
status = "okay";
bluetooth {
compatible = "brcm,bcm43438-bt";
clocks = <&rk808 1>;
clock-names = "lpo";
device-wakeup-gpios = <&gpio2 RK_PD2 GPIO_ACTIVE_HIGH>;
host-wakeup-gpios = <&gpio0 RK_PA4 GPIO_ACTIVE_HIGH>;
shutdown-gpios = <&gpio0 RK_PB1 GPIO_ACTIVE_HIGH>;
max-speed = <4000000>;
pinctrl-names = "default";
pinctrl-0 = <&bt_host_wake_l &bt_wake_l &bt_enable_h>;
vbat-supply = <&vcc3v3_sys>;
vddio-supply = <&vcc_1v8>;
};
};
&uart2 {
status = "okay";
};
&usb_host0_ehci {
status = "okay";
};
&usb_host0_ohci {
status = "okay";
};
&usb_host1_ehci {
status = "okay";
};
&usb_host1_ohci {
status = "okay";
};
&usbdrd3_0 {
status = "okay";
};
&usbdrd_dwc3_0 {
status = "okay";
dr_mode = "host";
};
&usbdrd3_1 {
status = "okay";
};
&usbdrd_dwc3_1 {
status = "okay";
dr_mode = "host";
};
&vopb {
status = "okay";
};
&vopb_mmu {
status = "okay";
};
&vopl {
status = "okay";
};
&vopl_mmu {
status = "okay";
};

View File

@ -0,0 +1,84 @@
CONFIG_ARM=y
CONFIG_SKIP_LOWLEVEL_INIT=y
CONFIG_COUNTER_FREQUENCY=24000000
CONFIG_ARCH_ROCKCHIP=y
CONFIG_SPL_GPIO=y
CONFIG_NR_DRAM_BANKS=1
CONFIG_ENV_OFFSET=0x3F8000
CONFIG_DEFAULT_DEVICE_TREE="rk3399-fine-3399"
CONFIG_DM_RESET=y
CONFIG_ROCKCHIP_RK3399=y
CONFIG_TARGET_EVB_RK3399=y
CONFIG_DEBUG_UART_BASE=0xFF1A0000
CONFIG_DEBUG_UART_CLOCK=24000000
CONFIG_SYS_LOAD_ADDR=0x800800
CONFIG_DEBUG_UART=y
CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-fine-3399.dtb"
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_SPL_MAX_SIZE=0x40000
CONFIG_SPL_PAD_TO=0x7f8000
# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
CONFIG_TPL=y
CONFIG_CMD_BOOTZ=y
CONFIG_CMD_GPT=y
CONFIG_CMD_I2C=y
CONFIG_CMD_MMC=y
CONFIG_CMD_PCI=y
CONFIG_CMD_USB=y
CONFIG_CMD_ROCKUSB=y
CONFIG_CMD_USB_MASS_STORAGE=y
# CONFIG_CMD_SETEXPR is not set
CONFIG_CMD_TIME=y
CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
CONFIG_SPL_OF_CONTROL=y
# CONFIG_OF_UPSTREAM is not set
CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_ENV_IS_IN_MMC=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_ROCKCHIP_GPIO=y
CONFIG_SYS_I2C_ROCKCHIP=y
CONFIG_ROCKCHIP_IODOMAIN=y
CONFIG_MMC_DW=y
CONFIG_MMC_DW_ROCKCHIP=y
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_SDMA=y
CONFIG_MMC_SDHCI_ROCKCHIP=y
CONFIG_ETH_DESIGNWARE=y
CONFIG_GMAC_ROCKCHIP=y
CONFIG_NVME_PCI=y
CONFIG_PHY_ROCKCHIP_INNO_USB2=y
CONFIG_PHY_ROCKCHIP_TYPEC=y
CONFIG_PMIC_RK8XX=y
CONFIG_SPL_DM_REGULATOR_FIXED=y
CONFIG_REGULATOR_PWM=y
CONFIG_REGULATOR_RK8XX=y
CONFIG_PWM_ROCKCHIP=y
CONFIG_RAM_ROCKCHIP_LPDDR4=y
CONFIG_BAUDRATE=1500000
CONFIG_DEBUG_UART_SHIFT=2
CONFIG_SYS_NS16550_MEM32=y
CONFIG_SYSINFO=y
CONFIG_SYSINFO_SMBIOS=y
CONFIG_SYSRESET=y
CONFIG_USB=y
CONFIG_USB_XHCI_HCD=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_EHCI_GENERIC=y
CONFIG_USB_KEYBOARD=y
CONFIG_USB_DWC3=y
CONFIG_USB_DWC3_GENERIC=y
CONFIG_USB_HOST_ETHER=y
CONFIG_USB_ETHER_ASIX=y
CONFIG_USB_ETHER_ASIX88179=y
CONFIG_USB_ETHER_MCS7830=y
CONFIG_USB_ETHER_RTL8152=y
CONFIG_USB_ETHER_SMSC95XX=y
CONFIG_USB_GADGET=y
CONFIG_USB_FUNCTION_ROCKUSB=y
CONFIG_VIDEO=y
CONFIG_DISPLAY=y
CONFIG_VIDEO_ROCKCHIP=y
CONFIG_DISPLAY_ROCKCHIP_HDMI=y
CONFIG_ERRNO_STR=y

View File

@ -30,8 +30,6 @@ define Build/Compile
endef
define Package/autocore/install
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/60-autocore-reload-rpcd $(1)/etc/uci-defaults/
ifneq ($(filter i386 i686 x86_64, $(ARCH)),)
$(INSTALL_DIR) $(1)/etc/init.d

View File

@ -1,5 +0,0 @@
#!/bin/sh
/etc/init.d/rpcd restart
exit 0

View File

View File

@ -7,25 +7,25 @@ THERMAL_PATH="/sys/class/thermal"
case "$DISTRIB_TARGET" in
ipq40xx/*|ipq806x/*)
wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/device/hwmon/hwmon*/temp1_input 2>"/dev/null" | awk '$1=$1')"
wifi_temp="$(cat "$IEEE_PATH"/phy*/device/hwmon/hwmon*/temp1_input 2>"/dev/null" | awk '{printf("%.1f°C ", $0 / 1000)}' | awk '$1=$1')"
;;
mediatek/mt7622)
wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/wl*/hwmon*/temp1_input 2>"/dev/null" | awk '$1=$1')"
wifi_temp="$(cat "$IEEE_PATH"/wl*/hwmon*/temp1_input 2>"/dev/null" | awk '{printf("%.1f°C ", $0 / 1000)}' | awk '$1=$1')"
;;
*)
wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/hwmon*/temp1_input 2>"/dev/null" | awk '$1=$1')"
wifi_temp="$(cat "$IEEE_PATH"/phy*/hwmon*/temp1_input 2>"/dev/null" | awk '{printf("%.1f°C ", $0 / 1000)}' | awk '$1=$1')"
;;
esac
case "$DISTRIB_TARGET" in
ipq40xx/*)
if [ -e "$IEEE_PATH/phy0/hwmon0/temp1_input" ]; then
mt76_temp="$(awk -F ': ' '{print $2}' "$IEEE_PATH/phy0/hwmon0/temp1_input" 2>"/dev/null")°C"
mt76_temp="$(awk -F ': ' '{print $2}' "$IEEE_PATH"/phy0/hwmon0/temp1_input 2>"/dev/null")°C"
fi
[ -z "$mt76_temp" ] || wifi_temp="${wifi_temp:+$wifi_temp }$mt76_temp"
;;
*)
cpu_temp="$(awk '{printf("%.1f°C", $0 / 1000)}' "$THERMAL_PATH/thermal_zone0/temp" 2>"/dev/null")"
cpu_temp="$(cat "$THERMAL_PATH"/thermal_zone0/temp 2>"/dev/null" | awk '{printf("%.1f°C", $0 / 1000)}')"
;;
esac

View File

@ -1,35 +0,0 @@
#
# Copyright (C) 2010-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=autosamba
PKG_VERSION:=1
PKG_RELEASE:=12
include $(INCLUDE_DIR)/package.mk
define Package/autosamba
TITLE:=Samba autoconfig hotplug script.
MAINTAINER:=Lean
DEPENDS:=+luci-app-samba4 +wsdd2
PKGARCH:=all
endef
define Package/autosamba/description
A hotplug script to config Samba share automatically.
endef
define Build/Compile
endef
define Package/autosamba/install
$(INSTALL_DIR) $(1)/etc/hotplug.d/block
$(INSTALL_BIN) ./files/20-smb $(1)/etc/hotplug.d/block/
endef
$(eval $(call BuildPackage,autosamba))

View File

@ -1,106 +0,0 @@
#!/bin/sh
#
# D-Team Technology Co.,Ltd. ShenZhen
# 作者:Vic
#
# 警告:对着屏幕的哥们,我们允许你使用此脚本,但不允许你抹去作者的信息,请保留这段话。
#
. /lib/functions.sh
. /lib/functions/service.sh
global=0
config_file="/etc/config/samba4"
wait_for_init() {
for i in `seq 30`
do
[ -e /tmp/procd.done ] || {
sleep 1; continue;
}
return
done
}
smb_handle() {
config_get path $1 path
if [ "$path" = "$2" ] ;then
global=1
fi
}
chk_en() {
config_get_bool autoshare $1 autoshare 1
[ $autoshare -eq 0 ] && exit
}
config_load samba4
config_foreach chk_en samba4
device=`basename $DEVPATH`
case "$ACTION" in
add)
case "$device" in
sd*);;
md*);;
hd*);;
mmcblk*);;
*) return;;
esac
path="/dev/$device"
wait_for_init
cat /proc/mounts | grep -v '/boot\|/opt' | while read j
do
str=${j%% *}
if [ "$str" == $path ];then
strr=${j#* }
target=${strr%% *}
global=0
config_foreach smb_handle sambashare $target
name=${target#*/mnt/}
if [ $global -eq 0 ] ;then
echo -e "\n\nconfig sambashare" >> $config_file
echo -e "\toption auto '1'" >> $config_file
echo -e "\toption name '$name'" >> $config_file
echo -e "\toption path '$target'" >> $config_file
echo -e "\toption read_only 'no'" >> $config_file
echo -e "\toption guest_ok 'yes'" >> $config_file
echo -e "\toption create_mask '0666'" >> $config_file
echo -e "\toption dir_mask '0777'" >> $config_file
echo -e "\toption device '$device'" >> $config_file
echo -e "\toption inherit_owner 'yes'" >> $config_file
/etc/init.d/samba4 reload
return
fi
fi
done
;;
remove)
i=0
while true
do
dev=`uci get samba4.@sambashare[$i].device`
[ $? -ne 0 ] && break
[ "$dev" = "$device" ] && {
auto=`uci get samba4.@sambashare[$i].auto`
[ $auto = "1" ] && {
mount_dir=`uci get samba4.@sambashare[$i].name`
uci delete samba4.@sambashare[$i]
uci commit
/etc/init.d/samba4 reload
return
}
}
let i+=1
done
;;
esac

View File

@ -9,7 +9,7 @@ if ! uci -q get system.@imm_init[0].system_chn > "/dev/null"; then
delete system.ntp.server
add_list system.ntp.server="ntp.tencent.com"
add_list system.ntp.server="ntp1.aliyun.com"
add_list system.ntp.server="ntp.aliyun.com"
add_list system.ntp.server="ntp.ntsc.ac.cn"
add_list system.ntp.server="cn.ntp.org.cn"

View File

@ -0,0 +1,36 @@
# 忽略编译生成的文件
*.o
*.so
*.a
# LuCI 的生成文件和缓存
build/
bin/
.tmp/
# 忽略 OpenWrt 编译生成的安装包
*.ipk
*.tar.gz
*.deb
# 忽略临时文件和编辑器缓存
*.swp
*.swo
*.bak
*.tmp
*.log
.DS_Store
# 忽略 Git 操作时产生的临时文件
.git/
# IDE 配置文件
.vscode/
.idea/
# 忽略 Makefile 生成的中间文件
/feeds
/staging_dir
/tmp/
config.log
config.status

View File

@ -0,0 +1 @@
f8eeb311

View File

@ -0,0 +1,43 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-athena-led
PKG_DEPENDS:=
PKG_VERSION:=0.0.7
PKG_RELEASE:=20241029
LUCI_TITLE:=LuCI Support for athena-led
LUCI_DEPENDS:=
include $(INCLUDE_DIR)/package.mk
# 包定义;指示我们的包将如何以及在哪里出现在整体配置菜单中 'make menuconfig'
define Package/$(PKG_NAME)
TITLE:=$(PKG_NAME)
endef
# Package description; a more verbose description on what our package does
define Package/$(PKG_NAME)/description
LuCI support for athenaLed
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
cp -pR ./luasrc/* $(1)/usr/lib/lua/luci
$(INSTALL_DIR) $(1)/
cp -pR ./root/* $(1)/
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
chmod +x /usr/sbin/athena-led
chmod +x /etc/init.d/athena_led
exit 0
endef
include $(TOPDIR)/feeds/luci/luci.mk
# This command is always the last, it uses the definitions and variables we give above in order to get the job done
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@ -0,0 +1,21 @@
# luci-app-athena-led
jdCloud ax6600 led screen ctrl
#### 定时关闭开启代码
```
# 早上9点30开启显示
30 9 * * * uci set athena_led.config.enable='1' && uci commit athena_led && /etc/init.d/athena_led reload
# 下午6点30关闭显示
30 18 * * * uci set athena_led.config.enable='0' && uci commit athena_led && /etc/init.d/athena_led reload
```
[推荐固件下载地址](https://github.com/VIKINGYFY/OpenWRT-CI/releases)
![image](https://github.com/user-attachments/assets/a2bcf6af-4e29-49d4-b183-799f68b74efb)
感谢以下朋友的捐赠
1. *姆

View File

@ -0,0 +1,18 @@
module("luci.controller.athena_led", package.seeall)
function index()
if not nixio.fs.access("/etc/config/athena_led") then
return
end
entry({ "admin", "system", "athena_led" }, firstchild(), _("Athena LED Ctrl"), 80).dependent = false
entry({ "admin", "system", "athena_led", "general" }, cbi("athena_led/settings"), _("Base Setting"), 1)
entry({ "admin", "system", "athena_led", "status" }, call("act_status"))
end
function act_status()
local e = {}
e.running = luci.sys.call("pgrep /usr/sbin/athena-led >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -0,0 +1,84 @@
m = Map("athena_led", translate("Athena led Ctrl"), translate("JDCloud AX6600 LED Screen Ctrl"))
m:section(SimpleSection).template = "athena_led/athena_led_status"
s = m:section(TypedSection, "athena_led")
s.addremove = false
s.anonymous = true
enable = s:option(Flag, "enable", translate("Enabled"))
enable.rmempty = false
seconds = s:option(ListValue, "seconds", translate("Display interval time"))
seconds.default = "5"
seconds.rmempty = false
seconds:value("1")
seconds:value("2")
seconds:value("3")
seconds:value("4")
seconds:value("5")
seconds.description = translate("Enable carousel display and set interval time in seconds")
seconds = s:option(ListValue, "lightLevel", translate("Display light level"))
seconds.default = "5"
seconds.rmempty = false
seconds:value("0")
seconds:value("1")
seconds:value("2")
seconds:value("3")
seconds:value("4")
seconds:value("5")
seconds:value("6")
seconds:value("7")
seconds.description = translate("Display light level desc")
status = s:option(MultiValue, "status", translate("side led status"))
status.default = ""
status.rmempty = true
status:value("time", translate("status time"))
status:value("medal", translate("status medal"))
status:value("upload", translate("status upload"))
status:value("download", translate("status download"))
status.description = translate("side led status desc")
type = s:option(MultiValue, "option", translate("Display Type"))
type.default = "date timeBlink"
type.rmempty = false
type:value("date", translate("Display Type Date"))
type:value("time", translate("Display Type Time"))
type:value("timeBlink", translate("Display Type Time Blink"))
type:value("temp", translate("Display Type temp"))
type:value("string", translate("Display Type String"))
type:value("getByUrl", translate("Display Type getByUrl"))
type.description = translate("Specify comma-separated values for option")
customValue = s:option(Value, "value", translate("Custom Value"))
customValue.default = "abcdefghijklmnopqrstuvwxyz0123456789+-*/=.::℃"
customValue.rmempty = false
customValue.placeholder = translate("Enter your message here")
customValue.description = translate("Set the custom message to display on the LED screen, Only effective on 'Display Type String'")
url = s:option(Value, "url", translate("api url for get content"))
url.default = "http://www.baidu.com"
url.rmempty = false
url.placeholder = translate("Enter your api url here")
url.description = translate("api url for get content des")
tempFlag = s:option(MultiValue, "tempFlag", translate("tempFlag"))
tempFlag.default = "4"
tempFlag.rmempty = false
tempFlag:value("0", translate("nss-top"))
tempFlag:value("1", translate("nss"))
tempFlag:value("2", translate("wcss-phya0"))
tempFlag:value("3", translate("wcss-phya1"))
tempFlag:value("4", translate("cpu"))
tempFlag:value("5", translate("lpass"))
tempFlag:value("6", translate("ddrss"))
tempFlag.description = translate("Set the item display on the LED screen, Only effective on 'Display Type temp'")
function m.on_after_commit(self)
local output = luci.util.exec("/etc/init.d/athena_led reload >/dev/null 2>&1")
luci.util.exec("logger '" .. output .. "'")
end
return m

View File

@ -0,0 +1,25 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[system]], [[athena_led]], [[status]])%>', null,
function (x, data) {
var tb = document.getElementById('athena_led_status');
if (data && tb) {
if (data.running) {
var links = '<em><b><font color=green>led <%:RUNNING%></font></b></em>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em><b><font color=red>led <%:NOT RUNNING%></font></b></em>';
}
}
}
);
//]]>
</script>
<style>.mar-10 {
margin-left: 50px;
margin-right: 10px;
}</style>
<fieldset class="cbi-section">
<p id="athena_led_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@ -0,0 +1,124 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "athena_led"
msgstr "athena_led"
msgid "Base Setting"
msgstr "设置"
msgid "Gift"
msgstr "赞赏"
msgid "Athena LED Ctrl"
msgstr "雅典娜 LED 屏幕控制"
msgid "JDCloud AX6600 LED Screen Ctrl"
msgstr "京东云 AX6600 LED 屏幕控制"
msgid "Enabled"
msgstr "启用"
msgid "Display interval time"
msgstr "刷新时间"
msgid "Enable carousel display and set interval time in seconds"
msgstr "刷新时间"
msgid "Display light level"
msgstr "显示亮度调整"
msgid "Display light level desc"
msgstr "显示亮度调整,数字越大越亮"
msgid "side led status"
msgstr "侧边状态灯"
msgid "status time"
msgstr "时间"
msgid "status medal"
msgstr "奖牌"
msgid "status upload"
msgstr "上传"
msgid "status download"
msgstr "下载"
msgid "side led status desc"
msgstr "设置侧边状态灯"
msgid "Display Type"
msgstr "显示模式"
msgid "Display Type Date"
msgstr "日期"
msgid "Display Type Time"
msgstr "时间"
msgid "Display Type Time Blink"
msgstr "时间-闪烁"
msgid "Display Type temp"
msgstr "温度"
msgid "Display Type String"
msgstr "自定义文本"
msgid "Display Type getByUrl"
msgstr "远程文本"
msgid "Specify comma-separated values for option"
msgstr "显示模式"
msgid "Custom Value"
msgstr "自定义文本"
msgid "Enter your message here"
msgstr "输入你的自定义内容"
msgid "Set the custom message to display on the LED screen, Only effective on 'Display Type String'"
msgstr "设置显示在led屏幕上的自定义内容,选中'自定义文本'显示模式生效"
msgid "api url for get content"
msgstr "通过 http/get 请求获取显示内容"
msgid "Enter your api url here"
msgstr "在此处输入你的接口地址"
msgid "api url for get content des"
msgstr "通过 http/get 请求获取显示内容,选中'远程文本'显示模式生效"
msgid "All features are free, and tipping is just to buy me a coffee."
msgstr "所有功能都免费,打赏只是为了请我喝咖啡"
msgid "tempFlag"
msgstr "温度选项"
msgid "nss-top"
msgstr "网络子系统nss-top"
msgid "nss"
msgstr "网络子系统nss"
msgid "wcss-phya0"
msgstr "无线控制子系统-物理0"
msgid "wcss-phya1"
msgstr "无线控制子系统-物理1"
msgid "cpu"
msgstr "中央处理器cpu"
msgid "lpass"
msgstr "lpass"
msgid "ddrss"
msgstr "内存子系统ddr"
msgid "Set the item display on the LED screen, Only effective on 'Display Type temp'"
msgstr "设置显示在led屏幕上的温度,选中'温度'显示模式生效"

View File

@ -0,0 +1,124 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "athena_led"
msgstr "athena_led"
msgid "Base Setting"
msgstr "设置"
msgid "Gift"
msgstr "赞赏"
msgid "Athena LED Ctrl"
msgstr "雅典娜 LED 屏幕控制"
msgid "JDCloud AX6600 LED Screen Ctrl"
msgstr "京东云 AX6600 LED 屏幕控制"
msgid "Enabled"
msgstr "启用"
msgid "Display interval time"
msgstr "刷新时间"
msgid "Enable carousel display and set interval time in seconds"
msgstr "刷新时间"
msgid "Display light level"
msgstr "显示亮度调整"
msgid "Display light level desc"
msgstr "显示亮度调整,数字越大越亮"
msgid "side led status"
msgstr "侧边状态灯"
msgid "status time"
msgstr "时间"
msgid "status medal"
msgstr "奖牌"
msgid "status upload"
msgstr "上传"
msgid "status download"
msgstr "下载"
msgid "side led status desc"
msgstr "设置侧边状态灯"
msgid "Display Type"
msgstr "显示模式"
msgid "Display Type Date"
msgstr "日期"
msgid "Display Type Time"
msgstr "时间"
msgid "Display Type Time Blink"
msgstr "时间-闪烁"
msgid "Display Type temp"
msgstr "温度"
msgid "Display Type String"
msgstr "自定义文本"
msgid "Display Type getByUrl"
msgstr "远程文本"
msgid "Specify comma-separated values for option"
msgstr "显示模式"
msgid "Custom Value"
msgstr "自定义文本"
msgid "Enter your message here"
msgstr "输入你的自定义内容"
msgid "Set the custom message to display on the LED screen, Only effective on 'Display Type String'"
msgstr "设置显示在led屏幕上的自定义内容,选中'自定义文本'显示模式生效"
msgid "api url for get content"
msgstr "通过 http/get 请求获取显示内容"
msgid "Enter your api url here"
msgstr "在此处输入你的接口地址"
msgid "api url for get content des"
msgstr "通过 http/get 请求获取显示内容,选中'远程文本'显示模式生效"
msgid "All features are free, and tipping is just to buy me a coffee."
msgstr "所有功能都免费,打赏只是为了请我喝咖啡"
msgid "tempFlag"
msgstr "温度选项"
msgid "nss-top"
msgstr "网络子系统nss-top"
msgid "nss"
msgstr "网络子系统nss"
msgid "wcss-phya0"
msgstr "无线控制子系统-物理0"
msgid "wcss-phya1"
msgstr "无线控制子系统-物理1"
msgid "cpu"
msgstr "中央处理器cpu"
msgid "lpass"
msgstr "lpass"
msgid "ddrss"
msgstr "内存子系统ddr"
msgid "Set the item display on the LED screen, Only effective on 'Display Type temp'"
msgstr "设置显示在led屏幕上的温度,选中'温度'显示模式生效"

View File

@ -0,0 +1,9 @@
config athena_led 'config'
option enable '1'
option status ' '
option seconds '5'
option lightLevel '5'
option option 'date timeBlink'
option value 'abcdefghijklmnopqrstuvwxyz0123456789+-*/=.::℃'
option url 'https://www.baidu.com'
option tempFlag '4'

View File

@ -0,0 +1,42 @@
#!/bin/sh /etc/rc.common
START=99
STOP=99
USE_PROCD=1
PROG=/usr/sbin/athena-led
start_service() {
config_load 'athena_led'
local cfg='config'
config_get_bool enabled "$cfg" 'enable' '0'
if [ "$enabled" -eq 0 ]; then
logger "athena-led Service is disabled, not starting"
return 1
fi
local status seconds lightLevel option value
config_get status $cfg 'status' ' '
config_get seconds $cfg 'seconds' '5'
config_get lightLevel $cfg 'lightLevel' '5'
config_get option $cfg 'option' 'date timeBlink'
config_get value $cfg 'value' 'abcdefghijklmnopqrstuvwxyz0123456789+-*/=.::℃'
config_get url $cfg 'url' 'https://www.baidu.com'
config_get tempFlag $cfg 'tempFlag' '4'
procd_open_instance
procd_set_param command $PROG -status "${status}" -seconds "${seconds}" -lightLevel "${lightLevel}" -option "${option}" -value "${value}" -url "${url}" -tempFlag "${tempFlag}"
procd_set_param respawn
procd_close_instance
}
service_triggers(){
procd_add_reload_trigger "athena_led"
}
reload_service()
{
stop
start
}

Binary file not shown.

View File

@ -141,3 +141,30 @@ define Package/brcmfmac-nvram-43752-sdio/install
$(1)/lib/firmware/brcm/brcmfmac43752-sdio.firefly,rk3568-roc-pc.txt
endef
$(eval $(call BuildPackage,brcmfmac-nvram-43752-sdio))
Package/brcmfmac-firmware-43430b0-sdio = $(call Package/armbian-firmware-default,Broadcom BCM43430B0 FullMac SDIO firmware)
define Package/brcmfmac-firmware-43430b0-sdio/install
$(INSTALL_DIR) $(1)/lib/firmware/brcm
$(INSTALL_DATA) \
$(PKG_BUILD_DIR)/brcm/BCM43430B0.hcd \
$(1)/lib/firmware/brcm/
$(INSTALL_DATA) \
$(PKG_BUILD_DIR)/brcm/brcmfmac43430b0-sdio.bin \
$(1)/lib/firmware/brcm/
$(INSTALL_DATA) \
$(PKG_BUILD_DIR)/brcm/brcmfmac43430-sdio.clm_blob \
$(1)/lib/firmware/brcm/
endef
$(eval $(call BuildPackage,brcmfmac-firmware-43430b0-sdio))
Package/brcmfmac-nvram-43430b0-sdio = $(call Package/armbian-firmware-default,Broadcom BCM43430B0 SDIO NVRAM firmware)
define Package/brcmfmac-nvram-43430b0-sdio/install
$(INSTALL_DIR) $(1)/lib/firmware/brcm
$(INSTALL_DATA) \
$(PKG_BUILD_DIR)/brcm/brcmfmac43430b0-sdio.txt \
$(1)/lib/firmware/brcm/
$(LN) \
brcmfmac43430b0-sdio.txt \
$(1)/lib/firmware/brcm/brcmfmac43430b0-sdio.rumu3f,fine-3399.txt
endef
$(eval $(call BuildPackage,brcmfmac-nvram-43430b0-sdio))

View File

@ -8,13 +8,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ath11k-firmware
PKG_SOURCE_DATE:=2024-10-14
PKG_SOURCE_VERSION:=15f050122da5ef5bef2cc8c7c19dfb7f98060a49
PKG_MIRROR_HASH:=e7a89d1570f32552ade539376181494724b5eafb31d00451ff2dcf5a2922a0cb
PKG_SOURCE_DATE:=2025-02-20
PKG_SOURCE_VERSION:=0407f7b00b4efd79a16a9481b6bfb6292888a52e
PKG_MIRROR_HASH:=6b03d8bd7ac37765e055f7d6ee41867ee8c4d3e9825f907e5663ffa9b5e3fcaa
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://git.codelinaro.org/clo/ath-firmware/ath11k-firmware.git
PKG_SOURCE_URL:=https://github.com/VIKINGYFY/ath11k-firmware-ddwrt.git
PKG_LICENSE_FILES:=LICENSE.qca_firmware
@ -25,21 +25,6 @@ include $(INCLUDE_DIR)/package.mk
RSTRIP:=:
STRIP:=:
ATH11K_LEGACY_FW_NAME:=ath11k-legacy-firmware
ATH11K_LEGACY_FW_DATE:=2024-03-14
ATH11K_LEGACY_FW_RELEASE:=795809c7
ATH11K_LEGACY_FW_SUBDIR:=$(ATH11K_LEGACY_FW_NAME)-$(ATH11K_LEGACY_FW_DATE)~$(ATH11K_LEGACY_FW_RELEASE)
ATH11K_LEGACY_FW_SOURCE=$(ATH11K_LEGACY_FW_SUBDIR).tar.zst
define Download/$(ATH11K_LEGACY_FW_NAME)
FILE:=$(ATH11K_LEGACY_FW_SOURCE)
PROTO:=git
URL:=https://github.com/quic/upstream-wifi-fw.git
SOURCE_VERSION:=795809c7041582bd51bdfaa1f548b916ae8d4382
MIRROR_HASH:=e042024b6762a5b4fe56f1a5bf8870df2e7abcca90ec22103cd46a609bee7cec
SUBDIR:=$(ATH11K_LEGACY_FW_SUBDIR)
endef
define Package/ath11k-firmware-default
SECTION:=firmware
CATEGORY:=Firmware
@ -73,60 +58,33 @@ $(Package/ath11k-firmware-default)
TITLE:=QCN9074 ath11k firmware
endef
define Build/Clean
$(call Build/Clean/Default,)
rm -rf \
$(BUILD_DIR)/$(ATH11K_LEGACY_FW_SUBDIR)
endef
define Build/Prepare
$(eval $(call Download,ath11k-legacy-firmware))
$(call Build/Prepare/Default,)
$(TAR) -C $(BUILD_DIR) -xf $(DL_DIR)/$(ATH11K_LEGACY_FW_SOURCE)
endef
define Build/Compile
endef
define Package/ath11k-firmware-ipq5018/install
$(INSTALL_DIR) $(1)/lib/firmware/ath11k/IPQ5018/hw1.0
$(INSTALL_DATA) \
$(BUILD_DIR)/$(ATH11K_LEGACY_FW_SUBDIR)/ath11k-firmware/IPQ5018_QCN6122_QCN6122/hw1.0/2.7.0.1/WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1/*.* \
$(1)/lib/firmware/ath11k/IPQ5018/hw1.0/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/IPQ5018/hw1.0/* $(1)/lib/firmware/ath11k/IPQ5018/hw1.0/
endef
define Package/ath11k-firmware-ipq6018/install
$(INSTALL_DIR) $(1)/lib/firmware/IPQ6018
$(INSTALL_DATA) \
$(PKG_BUILD_DIR)/IPQ6018/hw1.0/2.5.0.1/WLAN.HK.2.5.0.1-03982-QCAHKSWPL_SILICONZ-3/* \
$(1)/lib/firmware/IPQ6018/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/IPQ6018/hw1.0/* $(1)/lib/firmware/IPQ6018/
endef
define Package/ath11k-firmware-ipq8074/install
$(INSTALL_DIR) $(1)/lib/firmware/IPQ8074
$(INSTALL_DATA) \
$(PKG_BUILD_DIR)/IPQ8074/hw2.0/2.9.0.1/WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1/* \
$(1)/lib/firmware/IPQ8074/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/IPQ8074/hw2.0/* $(1)/lib/firmware/IPQ8074/
endef
define Package/ath11k-firmware-qcn6122/install
$(INSTALL_DIR) $(1)/lib/firmware/ath11k/QCN6122/hw1.0
$(INSTALL_DATA) \
$(BUILD_DIR)/$(ATH11K_LEGACY_FW_SUBDIR)/ath11k-firmware/IPQ5018_QCN6122_QCN6122/hw1.0/2.7.0.1/WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1/qcn6122/* \
$(1)/lib/firmware/ath11k/QCN6122/hw1.0/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/QCN6122/hw1.0/* $(1)/lib/firmware/ath11k/QCN6122/hw1.0/
endef
define Package/ath11k-firmware-qcn9074/install
$(INSTALL_DIR) $(1)/lib/firmware/ath11k/QCN9074/hw1.0
$(INSTALL_DATA) \
$(PKG_BUILD_DIR)/QCN9074/hw1.0/2.9.0.1/WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1/* \
$(1)/lib/firmware/ath11k/QCN9074/hw1.0/
$(INSTALL_BIN) \
$(PKG_BUILD_DIR)/QCN9074/hw1.0/board-2.bin $(1)/lib/firmware/ath11k/QCN9074/hw1.0/board-2.bin
$(INSTALL_DATA) $(PKG_BUILD_DIR)/QCN9074/hw1.0/* $(1)/lib/firmware/ath11k/QCN9074/hw1.0/
endef
$(eval $(call BuildPackage,ath11k-firmware-ipq5018))

View File

@ -73,7 +73,19 @@ ALLWIFIBOARDS:= \
zte_mf269 \
zte_mf287 \
zte_mf287plus \
zyxel_nbg7815
zyxel_nbg7815 \
cmiot_ax18 \
glinet_gl-ax1800 \
glinet_gl-axt1800 \
jdcloud_re-ss-01 \
jdcloud_re-cs-02 \
jdcloud_re-cs-03 \
link_nn6000 \
redmi_ax5 \
redmi_ax5-jdcloud \
verizon_cr1000a \
xiaomi_ax1800 \
zn_m2
ALLWIFIPACKAGES:=$(foreach BOARD,$(ALLWIFIBOARDS),ipq-wifi-$(BOARD))
@ -214,5 +226,17 @@ $(eval $(call generate-ipq-wifi-package,zte_mf269,ZTE MF269))
$(eval $(call generate-ipq-wifi-package,zte_mf287,ZTE MF287))
$(eval $(call generate-ipq-wifi-package,zte_mf287plus,ZTE MF287Plus))
$(eval $(call generate-ipq-wifi-package,zyxel_nbg7815,Zyxel NBG7815))
$(eval $(call generate-ipq-wifi-package,cmiot_ax18,CMIOT AX18))
$(eval $(call generate-ipq-wifi-package,glinet_gl-ax1800,GL.iNet GL-AX1800))
$(eval $(call generate-ipq-wifi-package,glinet_gl-axt1800,GL.iNet GL-AXT1800))
$(eval $(call generate-ipq-wifi-package,jdcloud_re-ss-01,JDCloud RE-SS-01))
$(eval $(call generate-ipq-wifi-package,jdcloud_re-cs-02,JDCloud RE-CS-02))
$(eval $(call generate-ipq-wifi-package,jdcloud_re-cs-03,JDCloud RE-CS-03))
$(eval $(call generate-ipq-wifi-package,link_nn6000,Link NN6000))
$(eval $(call generate-ipq-wifi-package,redmi_ax5,Redmi AX5))
$(eval $(call generate-ipq-wifi-package,redmi_ax5-jdcloud,Redmi AX5 JDCloud))
$(eval $(call generate-ipq-wifi-package,verizon_cr1000a,Verizon CR1000A))
$(eval $(call generate-ipq-wifi-package,xiaomi_ax1800,Xiaomi AX1800))
$(eval $(call generate-ipq-wifi-package,zn_m2,ZN M2))
$(foreach PACKAGE,$(ALLWIFIPACKAGES),$(eval $(call BuildPackage,$(PACKAGE))))

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,20 @@
--- a/ath10k-6.10/mac.c
+++ b/ath10k-6.10/mac.c
@@ -6365,7 +6365,7 @@ static int ath10k_mac_set_txbf_conf(stru
ar->wmi.vdev_param->txbf, value);
}
-static void ath10k_update_vif_offload(struct ieee80211_hw *hw,
+static int ath10k_update_vif_offload(struct ieee80211_hw *hw,
struct ieee80211_vif *vif)
{
struct ath10k_vif *arvif = (void *)vif->drv_priv;
@@ -6387,6 +6387,8 @@ static void ath10k_update_vif_offload(st
ath10k_warn(ar, "failed to set vdev %i TX encapsulation: %d\n",
arvif->vdev_id, ret);
}
+
+ return ret;
}
/*

View File

@ -0,0 +1,33 @@
--- a/ath10k-6.10/pci.c
+++ b/ath10k-6.10/pci.c
@@ -2285,6 +2285,7 @@ static int ath10k_pci_hif_start(struct a
ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif start\n");
+ dev_set_threaded(ar->napi_dev, true);
ath10k_core_napi_enable(ar);
ath10k_pci_irq_enable(ar);
--- a/ath10k-6.10/sdio.c
+++ b/ath10k-6.10/sdio.c
@@ -1863,6 +1863,7 @@ static int ath10k_sdio_hif_start(struct
struct ath10k_sdio *ar_sdio = ath10k_sdio_priv(ar);
int ret;
+ dev_set_threaded(&ar->napi_dev, true);
ath10k_core_napi_enable(ar);
/* Sleep 20 ms before HIF interrupts are disabled.
--- a/ath10k-6.10/core.c
+++ b/ath10k-6.10/core.c
@@ -4576,6 +4576,10 @@ struct ath10k *ath10k_core_create(size_t
if (!ar->napi_dev)
goto err_free_tx_complete;
+ snprintf(ar->napi_dev->name, sizeof(ar->napi_dev->name), "ath10k_%s",
+ wiphy_name(ar->hw->wiphy));
+ dev_set_threaded(ar->napi_dev, true);
+
ret = ath10k_coredump_create(ar);
if (ret)
goto err_free_netdev;

View File

@ -41,13 +41,22 @@ define KernelPackage/cryptodev/description
via a "/dev/crypto" device.
endef
ifneq ($(CONFIG_PACKAGE_kmod-crypto-qce),)
EXTRA_CFLAGS+=-DQCA
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-crypto),)
EXTRA_CFLAGS+=-DQCANSS
endif
define Build/Configure
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
$(KERNEL_MAKE_FLAGS) \
KERNEL_DIR="$(LINUX_DIR)"
KERNEL_DIR="$(LINUX_DIR)" \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)"
endef
define Build/InstallDev

View File

@ -1193,7 +1193,6 @@ endef
$(eval $(call KernelPackage,crypto-xts))
define KernelPackage/crypto-xxhash
TITLE:=xxHash non-cryptographic hash algorithm
DEPENDS:=+kmod-crypto-hash +kmod-lib-xxhash
@ -1205,3 +1204,20 @@ endef
$(eval $(call KernelPackage,crypto-xxhash))
define KernelPackage/crypto-qce
TITLE:=QTI Crypto Engine (QCE)
KCONFIG:= \
CONFIG_CRYPTO_DEV_QCE \
CONFIG_CRYPTO_DEV_QCE_AEAD=y \
CONFIG_CRYPTO_DEV_QCE_ENABLE_ALL=y \
CONFIG_CRYPTO_DEV_QCE_SHA=y \
CONFIG_CRYPTO_DEV_QCE_SKCIPHER=y \
CONFIG_CRYPTO_DEV_QCE_SW_MAX_LEN=512
FILES:= \
$(LINUX_DIR)/drivers/crypto/qce/qcrypto.ko
AUTOLOAD:=$(call AutoLoad,09,qcrypto)
DEPENDS:=@TARGET_qualcommax +kmod-crypto-manager +kmod-crypto-hash +kmod-crypto-des
$(call AddDepends/crypto)
endef
$(eval $(call KernelPackage,crypto-qce))

View File

@ -328,6 +328,7 @@ $(eval $(call KernelPackage,ipt-offload))
define KernelPackage/ipt-ipopt
TITLE:=Modules for matching/changing IP packet options
KCONFIG:=$(KCONFIG_IPT_IPOPT)
DEPENDS:=+PACKAGE_kmod-nf-conntrack:kmod-nf-conntrack
FILES:=$(foreach mod,$(IPT_IPOPT-m),$(LINUX_DIR)/net/$(mod).ko)
AUTOLOAD:=$(call AutoProbe,$(notdir $(IPT_IPOPT-m)))
$(call AddDepends/ipt)

View File

@ -41,7 +41,7 @@ Signed-off-by: Ziyang Huang <hzyitc@outlook.com>
}
} else {
ab->qmi.target_mem[idx].paddr = 0;
@@ -2292,6 +2296,7 @@ static int ath11k_qmi_load_file_target_m
@@ -2295,6 +2299,7 @@ static int ath11k_qmi_load_file_target_m
struct qmi_wlanfw_bdf_download_resp_msg_v01 resp;
struct qmi_txn txn;
const u8 *temp = data;
@ -49,7 +49,7 @@ Signed-off-by: Ziyang Huang <hzyitc@outlook.com>
void __iomem *bdf_addr = NULL;
int ret = 0;
u32 remaining = len;
@@ -2303,7 +2308,9 @@ static int ath11k_qmi_load_file_target_m
@@ -2306,7 +2311,9 @@ static int ath11k_qmi_load_file_target_m
memset(&resp, 0, sizeof(resp));
if (ab->hw_params.fixed_bdf_addr) {

View File

@ -91,9 +91,9 @@ Signed-off-by: George Moussalem <george.moussalem@outlook.com>
#endif /* _HIF_H_ */
--- a/drivers/net/wireless/ath/ath11k/qmi.c
+++ b/drivers/net/wireless/ath/ath11k/qmi.c
@@ -2184,6 +2184,8 @@ static int ath11k_qmi_request_device_inf
ab->mem = bar_addr_va;
ab->mem_len = resp.bar_size;
@@ -2187,6 +2187,8 @@ static int ath11k_qmi_request_device_inf
if (!ab->hw_params.ce_remap)
ab->mem_ce = ab->mem;
+ ath11k_hif_config_static_window(ab);
+

View File

@ -89,7 +89,7 @@ Signed-off-by: George Moussalem <george.moussalem@outlook.com>
/* SMBIOS type containing Board Data File Name Extension */
#define ATH11K_SMBIOS_BDF_EXT_TYPE 0xF8
@@ -945,6 +948,7 @@ struct ath11k_base {
@@ -951,6 +954,7 @@ struct ath11k_base {
struct list_head peers;
wait_queue_head_t peer_mapping_wq;
u8 mac_addr[ETH_ALEN];

View File

@ -132,7 +132,7 @@ Signed-off-by: Sriram R <srirrama@codeaurora.org>
};
/* HTT definitions */
@@ -1712,5 +1718,6 @@ void ath11k_dp_shadow_init_timer(struct
@@ -1689,5 +1695,6 @@ void ath11k_dp_shadow_init_timer(struct
struct ath11k_hp_update_timer *update_timer,
u32 interval, u32 ring_id);
void ath11k_dp_stop_shadow_timers(struct ath11k_base *ab);

View File

@ -126,7 +126,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
}
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -1318,19 +1318,21 @@ TRACE_EVENT(rdev_libertas_set_mesh_chann
@@ -1322,19 +1322,21 @@ TRACE_EVENT(rdev_libertas_set_mesh_chann
);
TRACE_EVENT(rdev_set_monitor_channel,

View File

@ -12,7 +12,7 @@ Signed-off-by: DENG Qingfang <dqfext@gmail.com>
--- a/mac80211.c
+++ b/mac80211.c
@@ -282,7 +282,7 @@ static void mt76_init_stream_cap(struct
@@ -293,7 +293,7 @@ static void mt76_init_stream_cap(struct
void mt76_set_stream_caps(struct mt76_phy *phy, bool vht)
{
if (phy->cap.has_2ghz)
@ -21,7 +21,7 @@ Signed-off-by: DENG Qingfang <dqfext@gmail.com>
if (phy->cap.has_5ghz)
mt76_init_stream_cap(phy, &phy->sband_5g.sband, vht);
if (phy->cap.has_6ghz)
@@ -349,13 +349,13 @@ mt76_init_sband(struct mt76_phy *phy, st
@@ -360,13 +360,13 @@ mt76_init_sband(struct mt76_phy *phy, st
static int
mt76_init_sband_2g(struct mt76_phy *phy, struct ieee80211_rate *rates,
@ -37,7 +37,7 @@ Signed-off-by: DENG Qingfang <dqfext@gmail.com>
}
static int
@@ -508,7 +508,7 @@ int mt76_register_phy(struct mt76_phy *p
@@ -553,7 +553,7 @@ int mt76_register_phy(struct mt76_phy *p
return ret;
if (phy->cap.has_2ghz) {
@ -46,7 +46,7 @@ Signed-off-by: DENG Qingfang <dqfext@gmail.com>
if (ret)
return ret;
}
@@ -691,7 +691,7 @@ int mt76_register_device(struct mt76_dev
@@ -742,7 +742,7 @@ int mt76_register_device(struct mt76_dev
return ret;
if (phy->cap.has_2ghz) {

View File

@ -3,15 +3,17 @@ include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=nat46
PKG_MIRROR_HASH:=09b93f31d10030d3b4f326066b544b70b1f60236d0482f27c384ed93b298c0a6
PKG_SOURCE_URL:=https://github.com/ayourtch/nat46.git
PKG_SOURCE_DATE:=2022-09-19
PKG_SOURCE_DATE:=2024-08-12
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=4c5beee236841724219598fabb1edc93d4f08ce5
PKG_SOURCE_VERSION:=b42c37d5c6dee4593df0fc60b37bc7ec4ee243a4
PKG_MIRROR_HASH:=2d7bbb6cc22808f7e81d716e6bd7a27d9978fb802496304851946627e21534a5
PKG_MAINTAINER:=Hans Dedecker <dedeckeh@gmail.com>
PKG_LICENSE:=GPL-2.0
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
define KernelPackage/nat46
@ -25,11 +27,17 @@ endef
include $(INCLUDE_DIR)/kernel-defaults.mk
define Build/InstallDev
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/nat46
$(INSTALL_DATA) $(PKG_BUILD_DIR)/nat46/modules/*.h $(STAGING_DIR)/usr/include/nat46/
endef
define Build/Compile
$(KERNEL_MAKE) M="$(PKG_BUILD_DIR)/nat46/modules" \
+$(KERNEL_MAKE) M="$(PKG_BUILD_DIR)/nat46/modules" \
MODFLAGS="-DMODULE -mlong-calls" \
EXTRA_CFLAGS="-DNAT46_VERSION=\\\"$(PKG_SOURCE_VERSION)\\\"" \
modules
$(INSTALL_DATA) $(PKG_BUILD_DIR)/nat46/modules/Module.symvers $(PKG_BUILD_DIR)/Module.symvers
endef
$(eval $(call KernelPackage,nat46))

View File

@ -0,0 +1,30 @@
Author: Pavithra R <pavir@codeaurora.org>
Date: Sun Sep 20 13:33:42 2020 +0530
nat46: Add skb_ext_reset to reset skb extensions
This patch adds support to reset the skb extensions before
resetting the netfilter. Without the change, conntrack
is in invalid state and traffic gets dropped.
Change-Id: I24ee6fe8a9a9dec09d61d8e716fff587f65e4e4f
Signed-off-by: Pavithra R <pavir@codeaurora.org>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -1710,6 +1710,7 @@ int nat46_ipv6_input(struct sk_buff *old
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0)
nf_reset(new_skb);
#else
+ skb_ext_reset(new_skb);
nf_reset_ct(new_skb);
#endif
@@ -1936,6 +1937,7 @@ int nat46_ipv4_input(struct sk_buff *old
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0)
nf_reset(new_skb);
#else
+ skb_ext_reset(new_skb);
nf_reset_ct(new_skb);
#endif

View File

@ -0,0 +1,209 @@
Author: Pavithra R <pavir@codeaurora.org>
Date: Sat Aug 1 13:27:20 2020 +0530
nat46: Export APIs for acceleration engine support in nat46 for kernel 5.4
This patch is propagated from kernel 4.4 commit
861e64a607fd22d5af089cf56539f42a2e31d581
The patch defines and exports APIs in nat46 to be used for accelaration.
Change-Id: I7934b15544953f870d3595b8b359433b4fff7c30
Signed-off-by: Pavithra R <pavir@codeaurora.org>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -1497,7 +1497,6 @@ static uint16_t nat46_fixup_icmp_dest_un
return 0;
}
-
/* Fixup ICMP->ICMP6 before IP header translation, according to http://tools.ietf.org/html/rfc6145 */
static uint16_t nat46_fixup_icmp(nat46_instance_t *nat46, struct iphdr *iph, struct sk_buff *old_skb) {
@@ -1579,6 +1578,10 @@ int pairs_xlate_v6_to_v4_outer(nat46_ins
return ( (xlate_src >= 0) && (xlate_dst >= 0) );
}
+int xlate_6_to_4(struct net_device *dev, struct ipv6hdr *ip6h, uint16_t proto, __u32 *pv4saddr, __u32 *pv4daddr) {
+ return pairs_xlate_v6_to_v4_outer(netdev_nat46_instance(dev), ip6h, proto, pv4saddr, pv4daddr);
+}
+EXPORT_SYMBOL(xlate_6_to_4);
int nat46_ipv6_input(struct sk_buff *old_skb) {
struct ipv6hdr *ip6h = ipv6_hdr(old_skb);
@@ -1733,6 +1736,10 @@ int nat46_ipv6_input(struct sk_buff *old
nat46debug(5, "about to send v4 packet, flags: %02x", IPCB(new_skb)->flags);
nat46_netdev_count_xmit(new_skb, old_skb->dev);
+
+ /* set skb->iif */
+ new_skb->skb_iif = old_skb->skb_iif;
+
netif_rx(new_skb);
/* TBD: should copy be released here? */
@@ -1841,6 +1848,10 @@ int pairs_xlate_v4_to_v6_outer(nat46_ins
return 0;
}
+int xlate_4_to_6(struct net_device *dev, struct iphdr *hdr4, uint16_t sport, uint16_t dport, void *v6saddr, void *v6daddr) {
+ return pairs_xlate_v4_to_v6_outer(netdev_nat46_instance(dev), hdr4, &sport, &dport, v6saddr, v6daddr);
+}
+EXPORT_SYMBOL(xlate_4_to_6);
int nat46_ipv4_input(struct sk_buff *old_skb) {
nat46_instance_t *nat46 = get_nat46_instance(old_skb);
@@ -1981,6 +1992,10 @@ int nat46_ipv4_input(struct sk_buff *old
nat46debug(5, "about to send v6 packet, flags: %02x", IP6CB(new_skb)->flags);
nat46_netdev_count_xmit(new_skb, old_skb->dev);
+
+ /* set skb->iif */
+ new_skb->skb_iif = old_skb->skb_iif;
+
netif_rx(new_skb);
done:
@@ -1988,4 +2003,22 @@ done:
return err;
}
+int nat46_get_npairs(struct net_device *dev) {
+ nat46_instance_t *nat46 = netdev_nat46_instance(dev);
+ return nat46->npairs;
+}
+EXPORT_SYMBOL(nat46_get_npairs);
+bool nat46_get_rule_config(struct net_device *dev, nat46_xlate_rulepair_t **nat46_rule_pair, int *count) {
+ nat46_instance_t *nat46 = netdev_nat46_instance(dev);
+ if (nat46->npairs < 1) {
+ /*
+ * no rules ?
+ */
+ return false;
+ }
+ *count = nat46->npairs;
+ *nat46_rule_pair = nat46->pairs;
+ return true;
+}
+EXPORT_SYMBOL(nat46_get_rule_config);
--- a/nat46/modules/nat46-core.h
+++ b/nat46/modules/nat46-core.h
@@ -42,18 +42,18 @@ typedef enum {
#define NAT46_SIGNATURE 0x544e3634
#define FREED_NAT46_SIGNATURE 0xdead544e
-typedef struct {
+typedef struct nat46_xlate_rule {
nat46_xlate_style_t style;
struct in6_addr v6_pref;
- int v6_pref_len;
- u32 v4_pref;
- int v4_pref_len;
- int ea_len;
- int psid_offset;
- int fmr_flag;
+ int v6_pref_len;
+ u32 v4_pref;
+ int v4_pref_len;
+ int ea_len;
+ int psid_offset;
+ int fmr_flag;
} nat46_xlate_rule_t;
-typedef struct {
+typedef struct nat46_xlate_rulepair {
nat46_xlate_rule_t local;
nat46_xlate_rule_t remote;
} nat46_xlate_rulepair_t;
@@ -82,4 +82,9 @@ nat46_instance_t *get_nat46_instance(str
nat46_instance_t *alloc_nat46_instance(int npairs, nat46_instance_t *old, int from_ipair, int to_ipair, int remove_ipair);
void release_nat46_instance(nat46_instance_t *nat46);
+int xlate_6_to_4(struct net_device *dev, struct ipv6hdr *ip6h, uint16_t proto, __u32 *pv4saddr, __u32 *pv4daddr);
+int xlate_4_to_6(struct net_device *dev, struct iphdr *hdr4, uint16_t sport, uint16_t dport, void *v6saddr, void *v6daddr);
+bool nat46_get_rule_config(struct net_device *dev, nat46_xlate_rulepair_t **nat46_rule_pair, int *count);
+int nat46_get_npairs(struct net_device *dev);
+
#endif
--- a/nat46/modules/nat46-netdev.c
+++ b/nat46/modules/nat46-netdev.c
@@ -24,10 +24,12 @@
#include <net/ip6_route.h>
#include <net/ipv6.h>
#include <linux/version.h>
+#include <linux/radix-tree.h>
#include "nat46-core.h"
#include "nat46-module.h"
#define NETDEV_DEFAULT_NAME "nat46."
+static RADIX_TREE(netdev_tree, GFP_ATOMIC);
typedef struct {
u32 sig;
@@ -83,6 +85,18 @@ void nat46_netdev_count_xmit(struct sk_b
dev->stats.tx_bytes += skb->len;
}
+void nat46_update_stats(struct net_device *dev, uint32_t rx_packets, uint32_t rx_bytes,
+ uint32_t tx_packets, uint32_t tx_bytes, uint32_t rx_dropped, uint32_t tx_dropped)
+{
+ dev->stats.rx_packets += rx_packets;
+ dev->stats.rx_bytes += rx_bytes;
+ dev->stats.tx_packets += tx_packets;
+ dev->stats.tx_bytes += tx_bytes;
+ dev->stats.rx_dropped += rx_dropped;
+ dev->stats.tx_dropped += tx_dropped;
+}
+EXPORT_SYMBOL(nat46_update_stats);
+
void *netdev_nat46_instance(struct net_device *dev) {
nat46_netdev_priv_t *priv = netdev_priv(dev);
return priv->nat46;
@@ -160,6 +174,11 @@ int nat46_netdev_create(struct net *net,
printk("nat46: netdevice nat46 '%s' created successfully.\n", devname);
kfree(devname);
+ /*
+ * add this netdevice to list
+ */
+ radix_tree_insert(&netdev_tree, (*dev)->ifindex, (void *)*dev);
+
return 0;
err_register_dev:
@@ -176,10 +195,24 @@ void nat46_netdev_destroy(struct net_dev
netif_stop_queue(dev);
netdev_nat46_set_instance(dev, NULL);
unregister_netdev(dev);
+ radix_tree_delete(&netdev_tree, dev->ifindex);
free_netdev(dev);
printk("nat46: Destroying nat46 device.\n");
}
+bool is_map_t_dev(struct net_device *dev)
+{
+ if(!dev) {
+ return false;
+ }
+
+ if(radix_tree_lookup(&netdev_tree, dev->ifindex)) {
+ return true;
+ }
+ return false;
+}
+EXPORT_SYMBOL(is_map_t_dev);
+
static int is_nat46(struct net_device *dev) {
nat46_netdev_priv_t *priv = netdev_priv(dev);
return (priv && (NAT46_DEVICE_SIGNATURE == priv->sig));
--- a/nat46/modules/nat46-netdev.h
+++ b/nat46/modules/nat46-netdev.h
@@ -26,3 +26,6 @@ void nat64_show_all_configs(struct net *
void nat46_netdev_count_xmit(struct sk_buff *skb, struct net_device *dev);
void *netdev_nat46_instance(struct net_device *dev);
+void nat46_update_stats(struct net_device *dev, uint32_t rx_packets, uint32_t rx_bytes, uint32_t tx_packets, uint32_t tx_bytes,
+ uint32_t rx_dropped, uint32_t tx_dropped);
+bool is_map_t_dev(struct net_device *dev);

View File

@ -0,0 +1,39 @@
Author: Pavithra R <pavir@codeaurora.org>
Date: Sat Aug 1 13:55:33 2020 +0530
nat46: Set IPv6 traffic class from IPv4 ToS value
Set IPv6 traffic class from IPv4 ToS value during
IPv4 to IPv6 translation and vice-versa.
This patch is propagated from kernel 4.4 commit
1cd3b55b059d4513649bb73bc69da931ed3beb7b
Change-Id: Ia14e53447e829c8648c01656237ac902ad8674ec
Signed-off-by: Pavithra R <pavir@codeaurora.org>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -886,11 +886,12 @@ void *get_next_header_ptr6(void *pv6, in
}
void fill_v4hdr_from_v6hdr(struct iphdr * iph, struct ipv6hdr *ip6h, __u32 v4saddr, __u32 v4daddr, __u16 id, __u16 frag_off, __u16 proto, int l3_payload_len) {
+ uint32_t ver_class_flow = ntohl(*(__be32 *)ip6h);
iph->ttl = ip6h->hop_limit;
iph->saddr = v4saddr;
iph->daddr = v4daddr;
iph->protocol = proto;
- *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (0x00/*tos*/ & 0xff));
+ *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | ((ver_class_flow >> 20) & 0xff));
iph->frag_off = frag_off;
iph->id = id;
iph->tot_len = htons( l3_payload_len + IPV4HDRSIZE );
@@ -1859,7 +1860,7 @@ int nat46_ipv4_input(struct sk_buff *old
uint16_t sport = 0, dport = 0;
int err = 0;
- int tclass = 0;
+ uint8_t tclass = 0;
int flowlabel = 0;
int check_for_l4 = 0;
int having_l4 = 0;

View File

@ -0,0 +1,439 @@
Author: Pavithra R <pavir@codeaurora.org>
Date: Mon Aug 3 17:03:37 2020 +0530
nat46: Fix for icmp translation issues.
This patch is propagated from kernel 4.4 commit
45fce10ba0105515289930b3e3f9df57bf3c22b6.
Fixed icmpv4 to icmpv6 and vice-versa translation issues, in accordance with RFC6145.
The change covers:
1. Translation of ICMP errors from IPv4 to IPv6 and vice-versa.
2. Translation of inner L3 packet header {Eth:IPv4:ICMP:IPv4:ICMP} in ICMP error messages.
3. Address translation for packets not having port numbers, hence CE/BR needs to fetch this
information from inner header (atleast 28 bytes (IP hdr + 8 bytes) of orignal packet received
that is transmitted back will be there in response).
Change-Id: I677474728aeaee656376fdb1edcb9476783d5b40
Signed-off-by: Pavithra R <pavir@codeaurora.org>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -29,6 +29,9 @@
#include "nat46-core.h"
#include "nat46-module.h"
+static uint16_t xlate_pkt_in_err_v4_to_v6(nat46_instance_t *nat46, struct iphdr *iph,
+ struct sk_buff *old_skb, uint16_t *sport, uint16_t *dport);
+
void
nat46debug_dump(nat46_instance_t *nat46, int level, void *addr, int len)
{
@@ -885,6 +888,14 @@ void *get_next_header_ptr6(void *pv6, in
return ret;
}
+void fill_v6hdr_from_v4hdr(struct iphdr *iph, struct ipv6hdr *ip6h) {
+ *((__be16 *)ip6h) = htons((6 << 12) | (iph->tos << 4)); /* Version, Traffic Class */
+ memset(&(ip6h->flow_lbl), 0, sizeof(ip6h->flow_lbl)); /* Flowlabel */
+ ip6h->payload_len = htons(ntohs(iph->tot_len) - IPV4HDRSIZE);
+ ip6h->nexthdr = iph->protocol;
+ ip6h->hop_limit = iph->ttl;
+}
+
void fill_v4hdr_from_v6hdr(struct iphdr * iph, struct ipv6hdr *ip6h, __u32 v4saddr, __u32 v4daddr, __u16 id, __u16 frag_off, __u16 proto, int l3_payload_len) {
uint32_t ver_class_flow = ntohl(*(__be32 *)ip6h);
iph->ttl = ip6h->hop_limit;
@@ -1212,10 +1223,14 @@ static void nat46_fixup_icmp6_paramprob(
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, -1 };
u32 *pptr6 = icmp6_parameter_ptr(icmp6h);
u8 *pptr4 = icmp_parameter_ptr((struct icmphdr *)icmp6h);
- int new_pptr = -1;
+ u8 new_pptr = -1;
int len = ntohs(ip6h->payload_len)-sizeof(*icmp6h);
switch(icmp6h->icmp6_code) {
+ case 1:
+ update_icmp6_type_code(nat46, icmp6h, 3, 2);
+ break;
+
case 0:
if(*pptr6 < sizeof(ptr6_4)/sizeof(ptr6_4[0])) {
new_pptr = ptr6_4[*pptr6];
@@ -1224,27 +1239,21 @@ static void nat46_fixup_icmp6_paramprob(
*pptr4 = 0xff & new_pptr;
update_icmp6_type_code(nat46, icmp6h, 12, 0);
len = xlate_payload6_to4(nat46, (icmp6h + 1), get_next_header_ptr6((icmp6h + 1), len), len, &icmp6h->icmp6_cksum, ptailTruncSize);
- } else {
- ip6h->nexthdr = NEXTHDR_NONE;
+ update_icmp6_type_code(nat46, icmp6h, 12, 0);
+ break;
}
- } else {
- ip6h->nexthdr = NEXTHDR_NONE;
}
- break;
- case 1:
- icmp6h->icmp6_cksum = csum16_upd(icmp6h->icmp6_cksum, ((*pptr6 >> 16) & 0xffff), 0);
- icmp6h->icmp6_cksum = csum16_upd(icmp6h->icmp6_cksum, (*pptr6 & 0xffff), 0);
- *pptr6 = 0;
- update_icmp6_type_code(nat46, icmp6h, 3, 2);
- len = xlate_payload6_to4(nat46, (icmp6h + 1), get_next_header_ptr6((icmp6h + 1), len), len, &icmp6h->icmp6_cksum, ptailTruncSize);
- break;
+#if __has_attribute(__fallthrough__)
+ __attribute__((__fallthrough__));
+#endif
case 2: /* fallthrough to default */
default:
ip6h->nexthdr = NEXTHDR_NONE;
+ return;
}
+ len = xlate_payload6_to4(nat46, (icmp6h + 1), get_next_header_ptr6((icmp6h + 1), len), len, &icmp6h->icmp6_cksum, ptailTruncSize);
}
-
/* Fixup ICMP6->ICMP before IP header translation, according to http://tools.ietf.org/html/rfc6145 */
static void nat46_fixup_icmp6(nat46_instance_t *nat46, struct ipv6hdr *ip6h, struct icmp6hdr *icmp6h, struct sk_buff *old_skb, int *ptailTruncSize) {
@@ -1299,17 +1308,19 @@ int ip6_input_not_interested(nat46_insta
return 0;
}
-static uint16_t nat46_fixup_icmp_time_exceeded(nat46_instance_t *nat46, struct iphdr *iph, struct icmphdr *icmph, struct sk_buff *old_skb) {
+static uint16_t nat46_fixup_icmp_time_exceeded(nat46_instance_t *nat46, struct iphdr *iph,
+ struct icmphdr *icmph, struct sk_buff *old_skb, uint16_t *sport, uint16_t *dport) {
/*
* Set the Type to 3, and adjust the
* ICMP checksum both to take the type change into account and
* to include the ICMPv6 pseudo-header. The Code is unchanged.
*/
icmph->type = 3;
- return 0;
+ return xlate_pkt_in_err_v4_to_v6(nat46, iph, old_skb, sport, dport);
}
-static uint16_t nat46_fixup_icmp_parameterprob(nat46_instance_t *nat46, struct iphdr *iph, struct icmphdr *icmph, struct sk_buff *old_skb) {
+static uint16_t nat46_fixup_icmp_parameterprob(nat46_instance_t *nat46, struct iphdr *iph,
+ struct icmphdr *icmph, struct sk_buff *old_skb, uint16_t *sport, uint16_t *dport) {
/*
* Set the Type to 4, and adjust the
* ICMP checksum both to take the type/code change into account
@@ -1352,27 +1363,33 @@ static uint16_t nat46_fixup_icmp_paramet
*/
static int ptr4_6[] = { 0, 1, 4, 4, -1, -1, -1, -1, 7, 6, -1, -1, 8, 8, 8, 8, 24, 24, 24, 24, -1 };
u8 *icmp_pptr = icmp_parameter_ptr(icmph);
- int new_pptr = -1;
+ u32 *icmp6_pptr = icmp6_parameter_ptr((struct icmp6hdr *)icmph);
+ int8_t new_pptr = -1;
+
+ icmph->type = 4;
+
switch (icmph->code) {
case 0:
case 2:
if (*icmp_pptr < (sizeof(ptr4_6)/sizeof(ptr4_6[0]))) {
icmph->code = 0;
new_pptr = ptr4_6[*icmp_pptr];
- if(new_pptr >= 0) {
- /* FIXME: update the parameter pointer in ICMPv6 with new_pptr value */
+ if (new_pptr >= 0) {
+ *icmp6_pptr = new_pptr;
+ return xlate_pkt_in_err_v4_to_v6(nat46, iph, old_skb, sport, dport);
}
- } else {
- iph->protocol = NEXTHDR_NONE;
}
- break;
+#if __has_attribute(__fallthrough__)
+ __attribute__((__fallthrough__));
+#endif
default:
iph->protocol = NEXTHDR_NONE;
}
return 0;
}
-static uint16_t nat46_fixup_icmp_dest_unreach(nat46_instance_t *nat46, struct iphdr *iph, struct icmphdr *icmph, struct sk_buff *old_skb) {
+static uint16_t nat46_fixup_icmp_dest_unreach(nat46_instance_t *nat46, struct iphdr *iph,
+ struct icmphdr *icmph, struct sk_buff *old_skb, uint16_t *sport, uint16_t *dport) {
/*
* Translate the Code as
* described below, set the Type to 1, and adjust the ICMP
@@ -1435,16 +1452,21 @@ static uint16_t nat46_fixup_icmp_dest_un
u16 *pmtu = ((u16 *)icmph) + 3; /* IPv4-compatible MTU value is 16 bit */
+ icmph->type = 1;
+
switch (icmph->code) {
case 0:
case 1:
icmph->code = 0;
break;
- case 2:
- /* FIXME: set ICMPv6 parameter pointer to 6 */
+ case 2: {
+ u32 *icmp6_pptr = icmp6_parameter_ptr((struct icmp6hdr *)icmph);
+ *icmp6_pptr = 6; /* Offset to Next Proto field in IPv6 header. */
icmph->type = 4;
icmph->code = 1;
+ nat46debug(3, "ICMP Proto Unreachable translated into IPv6 Param Prob.\n");
break;
+ }
case 3:
icmph->code = 4;
break;
@@ -1494,13 +1516,15 @@ static uint16_t nat46_fixup_icmp_dest_un
break;
default:
iph->protocol = NEXTHDR_NONE;
+ return 0;
}
- return 0;
+ return xlate_pkt_in_err_v4_to_v6(nat46, iph, old_skb, sport, dport);
}
/* Fixup ICMP->ICMP6 before IP header translation, according to http://tools.ietf.org/html/rfc6145 */
-
-static uint16_t nat46_fixup_icmp(nat46_instance_t *nat46, struct iphdr *iph, struct sk_buff *old_skb) {
+static uint16_t nat46_fixup_icmp(nat46_instance_t *nat46, struct iphdr *iph,
+ struct sk_buff *old_skb, uint16_t *sport, uint16_t *dport)
+{
struct icmphdr *icmph = (struct icmphdr *)(iph+1);
uint16_t ret = 0;
@@ -1509,22 +1533,22 @@ static uint16_t nat46_fixup_icmp(nat46_i
switch(icmph->type) {
case ICMP_ECHO:
icmph->type = ICMPV6_ECHO_REQUEST;
- ret = icmph->un.echo.id;
+ *sport = *dport = icmph->un.echo.id;
nat46debug(3, "ICMP echo request translated into IPv6, id: %d", ntohs(ret));
break;
case ICMP_ECHOREPLY:
icmph->type = ICMPV6_ECHO_REPLY;
- ret = icmph->un.echo.id;
+ *sport = *dport = icmph->un.echo.id;
nat46debug(3, "ICMP echo reply translated into IPv6, id: %d", ntohs(ret));
break;
case ICMP_TIME_EXCEEDED:
- ret = nat46_fixup_icmp_time_exceeded(nat46, iph, icmph, old_skb);
+ ret = nat46_fixup_icmp_time_exceeded(nat46, iph, icmph, old_skb, sport, dport);
break;
case ICMP_PARAMETERPROB:
- ret = nat46_fixup_icmp_parameterprob(nat46, iph, icmph, old_skb);
+ ret = nat46_fixup_icmp_parameterprob(nat46, iph, icmph, old_skb, sport, dport);
break;
case ICMP_DEST_UNREACH:
- ret = nat46_fixup_icmp_dest_unreach(nat46, iph, icmph, old_skb);
+ ret = nat46_fixup_icmp_dest_unreach(nat46, iph, icmph, old_skb, sport, dport);
break;
default:
/* Silently drop. */
@@ -1544,11 +1568,13 @@ int pairs_xlate_v6_to_v4_outer(nat46_ins
if(-1 == xlate_dst) {
if (xlate_v6_to_v4(nat46, &apair->local, &ip6h->daddr, pv4daddr)) {
+ nat46debug(5, "Dst addr %pI6 to %pI4 \n", &ip6h->daddr, pv4daddr);
xlate_dst = ipair;
}
}
if(-1 == xlate_src) {
if (xlate_v6_to_v4(nat46, &apair->remote, &ip6h->saddr, pv4saddr)) {
+ nat46debug(5, "Src addr %pI6 to %pI4 \n", &ip6h->saddr, pv4saddr);
xlate_src = ipair;
}
}
@@ -1659,6 +1685,7 @@ int nat46_ipv6_input(struct sk_buff *old
}
if(!pairs_xlate_v6_to_v4_outer(nat46, ip6h, proto, &v4saddr, &v4daddr)) {
+ nat46debug(0, "[nat46] Could not translate v6->v4");
goto done;
}
@@ -1821,11 +1848,13 @@ int pairs_xlate_v4_to_v6_outer(nat46_ins
if(-1 == xlate_src) {
if(xlate_v4_to_v6(nat46, &apair->local, &hdr4->saddr, v6saddr, sport)) {
+ nat46debug(5, "Src addr %pI4 to %pI6 \n", &hdr4->saddr, v6saddr);
xlate_src = ipair;
}
}
if(-1 == xlate_dst) {
if(xlate_v4_to_v6(nat46, &apair->remote, &hdr4->daddr, v6daddr, dport)) {
+ nat46debug(5, "Dst addr %pI4 to %pI6 \n", &hdr4->daddr, v6daddr);
xlate_dst = ipair;
}
}
@@ -1854,10 +1883,145 @@ int xlate_4_to_6(struct net_device *dev,
}
EXPORT_SYMBOL(xlate_4_to_6);
+/* FIXME: This is a workaround, till the LPM is not added. The sport & dport in inner header will be dport & sport of the outer
+ * header, respectively. Hence, dest. and source ips of inner header will be found in local & remote rules, respectively.
+ * Will work only for a pair of local & remote rules. Once LPM is brought in, this method can be removed and
+ * pairs_xlate_v4_to_v6_outer be used instead.
+ */
+int pairs_xlate_v4_to_v6_inner(nat46_instance_t *nat46, struct iphdr *iph,
+ uint16_t sport, uint16_t dport, void *v6saddr, void *v6daddr) {
+ int ipair = 0;
+ nat46_xlate_rulepair_t *apair = NULL;
+ int xlate_src = -1;
+ int xlate_dst = -1;
+
+ for (ipair = 0; ipair < nat46->npairs; ipair++) {
+ apair = &nat46->pairs[ipair];
+
+ if (-1 == xlate_dst) {
+ if (xlate_v4_to_v6(nat46, &apair->local, &iph->daddr, v6daddr, &dport)) {
+ nat46debug(3, "Dst addr %pI4 to %pI6 \n", &iph->daddr, v6daddr);
+ xlate_dst = ipair;
+ }
+ }
+ if (-1 == xlate_src) {
+ if(xlate_v4_to_v6(nat46, &apair->remote, &iph->saddr, v6saddr, &sport)) {
+ nat46debug(3, "Src addr %pI4 to %pI6 \n", &iph->saddr, v6saddr);
+ xlate_src = ipair;
+ }
+ }
+ if ((xlate_src >= 0) && (xlate_dst >= 0)) {
+ /* we did manage to translate it */
+ nat46debug(5, "[nat46] Inner header xlate results: src %d dst %d", xlate_src, xlate_dst);
+ return 1;
+ } else {
+ /* We did not match fully and there are more rules */
+ if((ipair+1 < nat46->npairs) && is_last_pair_in_group(apair)) {
+ xlate_src = -1;
+ xlate_dst = -1;
+ }
+ }
+}
+
+ nat46debug(1, "[nat46] Could not find a translation pair v4->v6");
+ return 0;
+}
+
+static uint16_t xlate_pkt_in_err_v4_to_v6(nat46_instance_t *nat46, struct iphdr *iph,
+ struct sk_buff *old_skb, uint16_t *sport, uint16_t *dport) {
+ struct ipv6hdr ip6h;
+ char v6saddr[16], v6daddr[16];
+ uint16_t temp_port = 0;
+ int ret = 0;
+ struct icmphdr *icmph = (struct icmphdr *)(iph + 1);
+ struct iphdr *iiph = (struct iphdr *)(icmph + 1);
+
+ switch (iiph->protocol) {
+ case IPPROTO_TCP: {
+ struct tcphdr *th = (struct tcphdr *)(iiph + 1);
+ *sport = th->source;
+ *dport = th->dest;
+ iiph->protocol = NEXTHDR_TCP;
+ break;
+ }
+ case IPPROTO_UDP: {
+ struct udphdr *udp = (struct udphdr *)(iiph + 1);
+ *sport = udp->source;
+ *dport = udp->dest;
+ iiph->protocol = NEXTHDR_UDP;
+ break;
+ }
+ case IPPROTO_ICMP: {
+ struct icmphdr *icmph = (struct icmphdr *)(iiph + 1);
+ iiph->protocol = NEXTHDR_ICMP;
+ switch (icmph->type) {
+ case ICMP_ECHO:
+ icmph->type = ICMPV6_ECHO_REQUEST;
+ *sport = *dport = icmph->un.echo.id;
+ break;
+ case ICMP_ECHOREPLY:
+ icmph->type = ICMPV6_ECHO_REPLY;
+ *sport = *dport = icmph->un.echo.id;
+ break;
+ default:
+ nat46debug(3, "ICMP Error message can't be inside another ICMP Error messgae.");
+ *sport = *dport = 0;
+ return 0;
+ }
+ break;
+ }
+ default:
+ nat46debug(3, "[ICMPv4] Next header: %u. Only TCP, UDP, and ICMP are supported.", iiph->protocol);
+ *sport = *dport = 0;
+ return 0;
+ }
+
+ nat46debug(3, "Retrieved from pkt in error: dest port %d, and src port %d.", ntohs(*dport), ntohs(*sport));
+
+ if (!pairs_xlate_v4_to_v6_inner(nat46, iiph, *sport, *dport, v6saddr, v6daddr)) {
+ nat46debug(0, "[nat46] Could not translate inner header v4->v6");
+ *sport = *dport = 0;
+ return 0;
+ }
+
+ fill_v6hdr_from_v4hdr (iiph, &ip6h);
+ memcpy(&ip6h.saddr, v6saddr, sizeof(ip6h.saddr));
+ memcpy(&ip6h.daddr, v6daddr, sizeof(ip6h.daddr));
+
+ if (skb_tailroom(old_skb) >= IPV6V4HDRDELTA){
+ skb_put(old_skb, IPV6V4HDRDELTA);
+ memmove(((char *)iiph + IPV6HDRSIZE), (iiph + 1), ntohs(iiph->tot_len) - IPV4HDRSIZE);
+ memcpy(iiph, &ip6h, IPV6HDRSIZE);
+ }
+ else {
+ ret = pskb_expand_head(old_skb, 0, IPV6V4HDRDELTA, GFP_ATOMIC);
+ if (unlikely(ret)) {
+ nat46debug(0, "[nat46] Could not copy v4 skb");
+ *sport = *dport = 0;
+ return 0;
+ }
+
+ skb_put(old_skb, IPV6V4HDRDELTA);
+ iiph = (struct iphdr *)(icmp_hdr(old_skb) + 1);
+ memmove(((char *)iiph + IPV6HDRSIZE), (iiph + 1), ntohs(iiph->tot_len) - IPV4HDRSIZE);
+ memcpy(iiph, &ip6h, IPV6HDRSIZE);
+ nat46 = get_nat46_instance(old_skb);
+ iph = ip_hdr(old_skb);
+ }
+
+ /* Swapping Ports for outer header */
+ /* Another work-around till LPM is not present. */
+ temp_port = *sport;
+ *sport = *dport;
+ *dport = temp_port;
+
+ return 1;
+}
+
int nat46_ipv4_input(struct sk_buff *old_skb) {
nat46_instance_t *nat46 = get_nat46_instance(old_skb);
struct sk_buff *new_skb;
- uint16_t sport = 0, dport = 0;
+ uint16_t sport = 0, dport = 0, ret = 0;
int err = 0;
uint8_t tclass = 0;
@@ -1879,7 +2043,7 @@ int nat46_ipv4_input(struct sk_buff *old
}
nat46debug(1, "nat46_ipv4_input packet");
nat46debug(5, "nat46_ipv4_input protocol: %d, len: %d, flags: %02x", hdr4->protocol, old_skb->len, IPCB(old_skb)->flags);
- if(0 == (ntohs(hdr4->frag_off) & 0x3FFF) ) {
+ if (0 == (ntohs(hdr4->frag_off) & 0x3FFF)) {
check_for_l4 = 1;
} else if (IPPROTO_ICMP == hdr4->protocol) {
/*
@@ -1916,9 +2080,10 @@ int nat46_ipv4_input(struct sk_buff *old
break;
}
case IPPROTO_ICMP:
- sport = dport = nat46_fixup_icmp(nat46, hdr4, old_skb);
- having_l4 = 1;
- break;
+ ret = nat46_fixup_icmp(nat46, hdr4, old_skb, &sport, &dport);
+ nat46debug(3, "ICMP translated to dest port %d, and src port %d.", ntohs(dport), ntohs(sport));
+ having_l4 = 1;
+ break;
default:
break;
}

View File

@ -0,0 +1,640 @@
Author: Pavithra R <pavir@codeaurora.org>
Date: Tue Aug 4 10:33:59 2020 +0530
nat46: Adding support for multiple MAP-T rules.
This patch is propagated from kernel 4.4 commit
05a122b0cb0d3a99f040c94b3f626e7350f1445b
This change covers:
1. Support for adding maximum of 32 MAP-T rules (DMR + FMRs).
2. Support for rule lookup based on Longest Prefix Match method.
3. Support for validation of new rules being inserted.
Change-Id: Id87448a8f544273b40c20aaab6e5c63b0dbd72e
Signed-off-by: Pavithra R <pavir@codeaurora.org>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -128,6 +128,13 @@ int try_parse_ipv6_prefix(struct in6_add
*arg_plen++ = 0;
if (pref_len) {
*pref_len = simple_strtol(arg_plen, NULL, 10);
+
+ /*
+ * ipv6 prefix should be <= 128
+ */
+ if (*pref_len > IPV6_BITS_MAX) {
+ return -1;
+ }
}
}
err = (1 != in6_pton(arg, -1, (u8 *)pref, '\0', NULL));
@@ -141,6 +148,13 @@ int try_parse_ipv4_prefix(u32 *v4addr, i
*arg_plen++ = 0;
if (pref_len) {
*pref_len = simple_strtol(arg_plen, NULL, 10);
+
+ /*
+ * ipv4 prefix len should be <= 32
+ */
+ if (*pref_len > IPV4_BITS_MAX) {
+ return -1;
+ }
}
}
err = (1 != in4_pton(arg, -1, (u8 *)v4addr, '/', NULL));
@@ -183,11 +197,127 @@ int try_parse_rule_arg(nat46_xlate_rule_
return err;
}
-/*
- * Parse the config commands in the buffer,
- * destructive (puts zero between the args)
+static inline void nat46_swap(nat46_xlate_rulepair_t *var1, nat46_xlate_rulepair_t *var2) {
+ nat46_xlate_rulepair_t temp;
+ temp = *var1;
+ *var1 = *var2;
+ *var2 = temp;
+}
+
+/*
+ * Sort rule pairs based on prefix length.
*/
+void nat46_sort_rule_array(nat46_instance_t *nat46) {
+ int i, j;
+ int nelem = nat46->npairs;
+ nat46_xlate_rulepair_t *array = NULL;
+
+ memcpy(nat46->sorted_ipv4_local_pairs, nat46->pairs, nelem * sizeof(nat46_xlate_rulepair_t));
+ memcpy(nat46->sorted_ipv4_remote_pairs, nat46->pairs, nelem * sizeof(nat46_xlate_rulepair_t));
+ memcpy(nat46->sorted_ipv6_local_pairs, nat46->pairs, nelem * sizeof(nat46_xlate_rulepair_t));
+ memcpy(nat46->sorted_ipv6_remote_pairs, nat46->pairs, nelem * sizeof(nat46_xlate_rulepair_t));
+
+ array = &nat46->sorted_ipv4_local_pairs[0];
+ for (i = 0; i < nelem - 1; i++) {
+ for (j = 0; j < nelem - i - 1; j++) {
+ if (array[j].local.v4_pref_len < array[j+1].local.v4_pref_len) {
+ nat46_swap (&array[j], &array[j+1]);
+ }
+ }
+ }
+
+ array = &nat46->sorted_ipv4_remote_pairs[0];
+ for (i = 0; i < nelem - 1; i++) {
+ for (j = 0; j < nelem - i - 1; j++) {
+ if (array[j].remote.v4_pref_len < array[j+1].remote.v4_pref_len) {
+ nat46_swap (&array[j], &array[j+1]);
+ }
+ }
+ }
+ array = &nat46->sorted_ipv6_local_pairs[0];
+ for (i = 0; i < nelem - 1; i++) {
+ for (j = 0; j < nelem - i - 1; j++) {
+ if (array[j].local.v6_pref_len < array[j+1].local.v6_pref_len) {
+ nat46_swap (&array[j], &array[j+1]);
+ }
+ }
+ }
+
+ array = &nat46->sorted_ipv6_remote_pairs[0];
+ for (i = 0; i < nelem - 1; i++) {
+ for (j = 0; j < nelem - i - 1; j++) {
+ if (array[j].remote.v6_pref_len < array[j+1].remote.v6_pref_len) {
+ nat46_swap (&array[j], &array[j+1]);
+ }
+ }
+ }
+}
+
+bool nat46_validate_RFC6052_style(nat46_instance_t *nat46, nat46_xlate_rule_t rule)
+{
+ if (rule.style == NAT46_XLATE_RFC6052) {
+ if (!((rule.v6_pref_len == 32) || (rule.v6_pref_len == 40) ||
+ (rule.v6_pref_len == 48) || (rule.v6_pref_len == 56) ||
+ (rule.v6_pref_len == 64) || (rule.v6_pref_len == 96))) {
+ nat46debug(3, "IPv6 prefix len is invalid");
+ return false;
+ }
+ }
+ return true;
+}
+
+bool nat46_validate_MAP_style(nat46_instance_t *nat46, nat46_xlate_rule_t rule)
+{
+ int psid_len;
+ if (rule.style == NAT46_XLATE_MAP) {
+
+ /*
+ * max ea_len is 48
+ */
+ if (rule.ea_len > EA_LEN_MAX) {
+ nat46debug(3, "EA-length should not exceed 48");
+ return false;
+ }
+
+ if (rule.v4_pref_len + rule.ea_len > IPV4_BITS_MAX) {
+ psid_len = rule.ea_len - (IPV4_BITS_MAX - rule.v4_pref_len);
+ } else {
+ psid_len = 0;
+ }
+
+ if (psid_len + rule.psid_offset > PSID_LEN_MAX) {
+ nat46debug(3, "psid_len + psid_offset should not exceed 16");
+ return false;
+ }
+ }
+ return true;
+}
+
+int nat46_validate_ipair_config(nat46_instance_t *nat46, nat46_xlate_rulepair_t *apair)
+{
+ if (!nat46_validate_RFC6052_style(nat46, apair->local)) {
+ return -1;
+ }
+
+ if (!nat46_validate_RFC6052_style(nat46, apair->remote)) {
+ return -1;
+ }
+
+ if (!nat46_validate_MAP_style(nat46, apair->local)) {
+ return -1;
+ }
+
+ if (!nat46_validate_MAP_style(nat46, apair->remote)) {
+ return -1;
+ }
+ return 0;
+}
+
+/*
+ * Parse the config commands in the buffer,
+ * destructive (puts zero between the args)
+ */
int nat46_set_ipair_config(nat46_instance_t *nat46, int ipair, char *buf, int count) {
char *tail = buf;
char *arg_name;
@@ -217,7 +347,18 @@ int nat46_set_ipair_config(nat46_instanc
err = try_parse_rule_arg(&apair->remote, arg_name, &tail);
}
}
- return err;
+
+ err = nat46_validate_ipair_config(nat46, apair);
+ if (err) {
+ return err;
+ }
+
+ /*
+ * sort nat46->pairs based on prefix length.
+ */
+ nat46_sort_rule_array(nat46);
+
+ return 0;
}
int nat46_set_config(nat46_instance_t *nat46, char *buf, int count) {
@@ -933,37 +1074,120 @@ int is_last_pair_in_group(nat46_xlate_ru
return ( (apair->local.style != NAT46_XLATE_NONE) && (apair->remote.style != NAT46_XLATE_NONE) );
}
+nat46_xlate_rulepair_t *nat46_lpm(nat46_instance_t *nat46, nat46_rule_type_t type, void *paddr) {
+ int ipair = 0;
+ nat46_xlate_rulepair_t *apair = NULL;
+ uint32_t mask = 0;
+ uint8_t *pa1;
+ uint8_t *pa2;
+
+ if(!nat46 || !paddr) {
+ return NULL;
+ }
+
+ switch (type) {
+ case NAT46_IPV4_LOCAL:
+ for (ipair = 0; ipair < nat46->npairs; ipair++) {
+ apair = &nat46->sorted_ipv4_local_pairs[ipair];
+
+ /*
+ * For a 32-bit number, if the shift count is 32, then the
+ * result of the left shift operation is always 0.
+ */
+ if (apair->local.v4_pref_len) {
+ mask = htonl(U32_MASK << (IPV4_BITS_MAX - apair->local.v4_pref_len));
+ }
+
+ if((*(uint32_t *)paddr & mask) == (apair->local.v4_pref & mask)) {
+ return apair;
+ }
+ }
+ break;
+ case NAT46_IPV4_REMOTE:
+ for (ipair = 0; ipair < nat46->npairs; ipair++) {
+ apair = &nat46->sorted_ipv4_remote_pairs[ipair];
+
+ /*
+ * For a 32-bit number, if the shift count is 32, then the
+ * result of the left shift operation is always 0.
+ */
+ if (apair->remote.v4_pref_len) {
+ mask = htonl(U32_MASK << (IPV4_BITS_MAX - apair->remote.v4_pref_len));
+ }
+
+ if((*(uint32_t *)paddr & mask) == (apair->remote.v4_pref & mask)) {
+ return apair;
+ }
+ }
+ break;
+ case NAT46_IPV6_LOCAL:
+ for (ipair = 0; ipair < nat46->npairs; ipair++) {
+ apair = &nat46->sorted_ipv6_local_pairs[ipair];
+ if(memcmp(paddr, &apair->local.v6_pref, apair->local.v6_pref_len / BITS_PER_BYTE)) {
+ continue;
+ }
+ if(apair->local.v6_pref_len % BITS_PER_BYTE) {
+ mask = U8_MASK << (BITS_PER_BYTE - (apair->local.v6_pref_len % BITS_PER_BYTE));
+ pa1 = (uint8_t *)paddr + (apair->local.v6_pref_len / BITS_PER_BYTE);
+ pa2 = (uint8_t *)&apair->local.v6_pref + (apair->local.v6_pref_len / BITS_PER_BYTE);
+
+ if ((*pa1 & mask) == (*pa2 & mask)) {
+ return apair;
+ }
+ }
+ else
+ return apair;
+ }
+ break;
+ case NAT46_IPV6_REMOTE:
+ for (ipair = 0; ipair < nat46->npairs; ipair++) {
+ apair = &nat46->sorted_ipv6_remote_pairs[ipair];
+ if(memcmp(paddr, &apair->remote.v6_pref, apair->remote.v6_pref_len / BITS_PER_BYTE)) {
+ continue;
+ }
+ if(apair->remote.v6_pref_len % BITS_PER_BYTE) {
+ mask = U8_MASK << (BITS_PER_BYTE - (apair->remote.v6_pref_len % BITS_PER_BYTE));
+ pa1 = (uint8_t *)paddr + (apair->remote.v6_pref_len / BITS_PER_BYTE);
+ pa2 = (uint8_t *)&apair->remote.v6_pref + (apair->remote.v6_pref_len / BITS_PER_BYTE);
+
+ if((*pa1 & mask) == (*pa2 & mask)) {
+ return apair;
+ }
+ }
+ else
+ return apair;
+ }
+ break;
+ default:
+ nat46debug(0, "%s : Invalid prefix type.\n", __func__);
+ }
+ return NULL;
+}
+
void pairs_xlate_v6_to_v4_inner(nat46_instance_t *nat46, struct ipv6hdr *ip6h, __u32 *pv4saddr, __u32 *pv4daddr) {
int ipair = 0;
nat46_xlate_rulepair_t *apair = NULL;
int xlate_src = -1;
int xlate_dst = -1;
- for(ipair = 0; ipair < nat46->npairs; ipair++) {
- apair = &nat46->pairs[ipair];
+ apair = nat46_lpm(nat46, NAT46_IPV6_REMOTE, &ip6h->daddr);
+ if (!apair) {
+ return;
+ }
- if(-1 == xlate_dst) {
- if(xlate_v6_to_v4(nat46, &apair->remote, &ip6h->daddr, pv4daddr)) {
- xlate_dst = ipair;
- }
- }
- if(-1 == xlate_src) {
- if(xlate_v6_to_v4(nat46, &apair->local, &ip6h->saddr, pv4saddr)) {
- xlate_src = ipair;
- }
- }
- if((xlate_src >= 0) && (xlate_dst >= 0)) {
- /* we did manage to translate it */
- break;
- } else {
- /* We did not match fully and there are more rules */
- if((ipair+1 < nat46->npairs) && is_last_pair_in_group(apair)) {
- xlate_src = -1;
- xlate_dst = -1;
- }
- }
+ if (xlate_v6_to_v4(nat46, &apair->remote, &ip6h->daddr, pv4daddr)) {
+ xlate_dst = ipair;
+ }
+ if (xlate_v6_to_v4(nat46, &apair->local, &ip6h->saddr, pv4saddr)) {
+ xlate_src = ipair;
+ }
+
+ if ((xlate_src >= 0) && (xlate_dst >= 0)) {
+ /* we did manage to translate it */
+ nat46debug(5, "[nat46payload] xlate results: src %d dst %d", xlate_src, xlate_dst);
+ } else {
+ nat46debug(1, "[nat46] Could not find a translation pair v6->v4 src %pI6c dst %pI6c", &ip6h->saddr, &ip6h->daddr);
}
- nat46debug(5, "[nat46payload] xlate results: src %d dst %d", xlate_src, xlate_dst);
}
/*
@@ -1557,40 +1781,31 @@ static uint16_t nat46_fixup_icmp(nat46_i
return ret;
}
-int pairs_xlate_v6_to_v4_outer(nat46_instance_t *nat46, struct ipv6hdr *ip6h, uint16_t proto, __u32 *pv4saddr, __u32 *pv4daddr) {
+int pairs_xlate_v6_to_v4_outer(nat46_instance_t *nat46, nat46_xlate_rulepair_t *apair,
+ struct ipv6hdr *ip6h, uint16_t proto, __u32 *pv4saddr, __u32 *pv4daddr) {
int ipair = 0;
- nat46_xlate_rulepair_t *apair = NULL;
int xlate_src = -1;
int xlate_dst = -1;
for(ipair = 0; ipair < nat46->npairs; ipair++) {
- apair = &nat46->pairs[ipair];
-
- if(-1 == xlate_dst) {
- if (xlate_v6_to_v4(nat46, &apair->local, &ip6h->daddr, pv4daddr)) {
- nat46debug(5, "Dst addr %pI6 to %pI4 \n", &ip6h->daddr, pv4daddr);
- xlate_dst = ipair;
- }
+ apair = nat46_lpm(nat46, NAT46_IPV6_REMOTE, &ip6h->saddr);
+ if (!apair) {
+ return 0;
}
- if(-1 == xlate_src) {
- if (xlate_v6_to_v4(nat46, &apair->remote, &ip6h->saddr, pv4saddr)) {
- nat46debug(5, "Src addr %pI6 to %pI4 \n", &ip6h->saddr, pv4saddr);
- xlate_src = ipair;
- }
+
+ if (xlate_v6_to_v4(nat46, &apair->local, &ip6h->daddr, pv4daddr)) {
+ nat46debug(5, "Dst addr %pI6 to %pI4 \n", &ip6h->daddr, pv4daddr);
+ xlate_dst = ipair;
}
- if( (xlate_src >= 0) && (xlate_dst >= 0) ) {
- break;
- } else {
- /* We did not match fully and there are more rules */
- if((ipair+1 < nat46->npairs) && is_last_pair_in_group(apair)) {
- xlate_src = -1;
- xlate_dst = -1;
- }
+
+ if (xlate_v6_to_v4(nat46, &apair->remote, &ip6h->saddr, pv4saddr)) {
+ nat46debug(5, "Src addr %pI6 to %pI4 \n", &ip6h->saddr, pv4saddr);
+ xlate_src = ipair;
}
}
if (xlate_dst >= 0) {
if (xlate_src < 0) {
- if(proto == NEXTHDR_ICMP) {
+ if (proto == NEXTHDR_ICMP) {
nat46debug(1, "[nat46] Could not translate remote address v6->v4, ipair %d, for ICMP6 use dest addr", ipair);
*pv4saddr = *pv4daddr;
xlate_src = xlate_dst;
@@ -1606,12 +1821,14 @@ int pairs_xlate_v6_to_v4_outer(nat46_ins
}
int xlate_6_to_4(struct net_device *dev, struct ipv6hdr *ip6h, uint16_t proto, __u32 *pv4saddr, __u32 *pv4daddr) {
- return pairs_xlate_v6_to_v4_outer(netdev_nat46_instance(dev), ip6h, proto, pv4saddr, pv4daddr);
+ nat46_xlate_rulepair_t apair;
+ return pairs_xlate_v6_to_v4_outer(netdev_nat46_instance(dev), &apair, ip6h, proto, pv4saddr, pv4daddr);
}
EXPORT_SYMBOL(xlate_6_to_4);
int nat46_ipv6_input(struct sk_buff *old_skb) {
struct ipv6hdr *ip6h = ipv6_hdr(old_skb);
+ nat46_xlate_rulepair_t apair;
nat46_instance_t *nat46 = get_nat46_instance(old_skb);
uint16_t proto;
uint16_t frag_off;
@@ -1684,7 +1901,7 @@ int nat46_ipv6_input(struct sk_buff *old
check_for_l4 = 1;
}
- if(!pairs_xlate_v6_to_v4_outer(nat46, ip6h, proto, &v4saddr, &v4daddr)) {
+ if (!pairs_xlate_v6_to_v4_outer(nat46, &apair, ip6h, proto, &v4saddr, &v4daddr)) {
nat46debug(0, "[nat46] Could not translate v6->v4");
goto done;
}
@@ -1837,56 +2054,44 @@ int ip4_input_not_interested(nat46_insta
return 0;
}
-int pairs_xlate_v4_to_v6_outer(nat46_instance_t *nat46, struct iphdr *hdr4, uint16_t *sport, uint16_t *dport, void *v6saddr, void *v6daddr) {
+int pairs_xlate_v4_to_v6_outer(nat46_instance_t *nat46, nat46_xlate_rulepair_t *apair,
+ struct iphdr *hdr4, uint16_t *sport, uint16_t *dport, void *v6saddr, void *v6daddr) {
int ipair = 0;
- nat46_xlate_rulepair_t *apair = NULL;
int xlate_src = -1;
int xlate_dst = -1;
+ int ret = 0;
- for(ipair = 0; ipair < nat46->npairs; ipair++) {
- apair = &nat46->pairs[ipair];
+ apair = nat46_lpm(nat46, NAT46_IPV4_REMOTE, &hdr4->daddr);
+ if (!apair) {
+ return 0;
+ }
- if(-1 == xlate_src) {
- if(xlate_v4_to_v6(nat46, &apair->local, &hdr4->saddr, v6saddr, sport)) {
- nat46debug(5, "Src addr %pI4 to %pI6 \n", &hdr4->saddr, v6saddr);
- xlate_src = ipair;
- }
- }
- if(-1 == xlate_dst) {
- if(xlate_v4_to_v6(nat46, &apair->remote, &hdr4->daddr, v6daddr, dport)) {
- nat46debug(5, "Dst addr %pI4 to %pI6 \n", &hdr4->daddr, v6daddr);
- xlate_dst = ipair;
- }
- }
- if( (xlate_src >= 0) && (xlate_dst >= 0) ) {
- break;
- } else {
- /* We did not match fully and there are more rules */
- if((ipair+1 < nat46->npairs) && is_last_pair_in_group(apair)) {
- xlate_src = -1;
- xlate_dst = -1;
- }
- }
+ if (xlate_v4_to_v6(nat46, &apair->local, &hdr4->saddr, v6saddr, sport)) {
+ nat46debug(5, "Src addr %pI4 to %pI6 \n", &hdr4->saddr, v6saddr);
+ xlate_src = ipair;
+ }
+ if (xlate_v4_to_v6(nat46, &apair->remote, &hdr4->daddr, v6daddr, dport)) {
+ nat46debug(5, "Dst addr %pI4 to %pI6 \n", &hdr4->daddr, v6daddr);
+ xlate_dst = ipair;
}
nat46debug(5, "[nat46] pairs_xlate_v4_to_v6_outer result: src %d dst %d", xlate_src, xlate_dst);
if ( (xlate_src >= 0) && (xlate_dst >= 0) ) {
- return 1;
+ ret = 1;
+ } else {
+ nat46debug(1, "[nat46] Could not find a translation pair v4->v6");
}
-
- nat46debug(1, "[nat46] Could not find a translation pair v4->v6");
-
- return 0;
+ return ret;
}
int xlate_4_to_6(struct net_device *dev, struct iphdr *hdr4, uint16_t sport, uint16_t dport, void *v6saddr, void *v6daddr) {
- return pairs_xlate_v4_to_v6_outer(netdev_nat46_instance(dev), hdr4, &sport, &dport, v6saddr, v6daddr);
+ nat46_xlate_rulepair_t apair;
+ return pairs_xlate_v4_to_v6_outer(netdev_nat46_instance(dev), &apair, hdr4, &sport, &dport, v6saddr, v6daddr);
}
EXPORT_SYMBOL(xlate_4_to_6);
-/* FIXME: This is a workaround, till the LPM is not added. The sport & dport in inner header will be dport & sport of the outer
- * header, respectively. Hence, dest. and source ips of inner header will be found in local & remote rules, respectively.
- * Will work only for a pair of local & remote rules. Once LPM is brought in, this method can be removed and
- * pairs_xlate_v4_to_v6_outer be used instead.
+/*
+ * The sport & dport in inner header will be dport & sport of the outer header, respectively.
+ * Hence, dest. and source ips of inner header will be found in local & remote rules, respectively.
*/
int pairs_xlate_v4_to_v6_inner(nat46_instance_t *nat46, struct iphdr *iph,
uint16_t sport, uint16_t dport, void *v6saddr, void *v6daddr) {
@@ -1895,35 +2100,27 @@ int pairs_xlate_v4_to_v6_inner(nat46_ins
int xlate_src = -1;
int xlate_dst = -1;
- for (ipair = 0; ipair < nat46->npairs; ipair++) {
- apair = &nat46->pairs[ipair];
+ apair = nat46_lpm(nat46, NAT46_IPV4_REMOTE, &iph->saddr);
+ if (!apair) {
+ return 0;
+ }
- if (-1 == xlate_dst) {
- if (xlate_v4_to_v6(nat46, &apair->local, &iph->daddr, v6daddr, &dport)) {
- nat46debug(3, "Dst addr %pI4 to %pI6 \n", &iph->daddr, v6daddr);
- xlate_dst = ipair;
- }
- }
- if (-1 == xlate_src) {
- if(xlate_v4_to_v6(nat46, &apair->remote, &iph->saddr, v6saddr, &sport)) {
- nat46debug(3, "Src addr %pI4 to %pI6 \n", &iph->saddr, v6saddr);
- xlate_src = ipair;
- }
- }
- if ((xlate_src >= 0) && (xlate_dst >= 0)) {
- /* we did manage to translate it */
- nat46debug(5, "[nat46] Inner header xlate results: src %d dst %d", xlate_src, xlate_dst);
- return 1;
- } else {
- /* We did not match fully and there are more rules */
- if((ipair+1 < nat46->npairs) && is_last_pair_in_group(apair)) {
- xlate_src = -1;
- xlate_dst = -1;
- }
- }
-}
+ if (xlate_v4_to_v6(nat46, &apair->local, &iph->daddr, v6daddr, &dport)) {
+ nat46debug(3, "Dst addr %pI4 to %pI6 \n", &iph->daddr, v6daddr);
+ xlate_dst = ipair;
+ }
+ if (xlate_v4_to_v6(nat46, &apair->remote, &iph->saddr, v6saddr, &sport)) {
+ nat46debug(3, "Src addr %pI4 to %pI6 \n", &iph->saddr, v6saddr);
+ xlate_src = ipair;
+ }
+ if ((xlate_src >= 0) && (xlate_dst >= 0)) {
+ /* we did manage to translate it */
+ nat46debug(5, "[nat46] Inner header xlate results: src %d dst %d", xlate_src, xlate_dst);
+ return 1;
+ } else {
+ nat46debug(1, "[nat46] Could not find a translation pair v4->v6");
+ }
- nat46debug(1, "[nat46] Could not find a translation pair v4->v6");
return 0;
}
@@ -2020,6 +2217,7 @@ static uint16_t xlate_pkt_in_err_v4_to_v
int nat46_ipv4_input(struct sk_buff *old_skb) {
nat46_instance_t *nat46 = get_nat46_instance(old_skb);
+ nat46_xlate_rulepair_t apair;
struct sk_buff *new_skb;
uint16_t sport = 0, dport = 0, ret = 0;
@@ -2097,7 +2295,7 @@ int nat46_ipv4_input(struct sk_buff *old
having_l4 = 1;
}
- if(!pairs_xlate_v4_to_v6_outer(nat46, hdr4, having_l4 ? &sport : NULL, having_l4 ? &dport : NULL, v6saddr, v6daddr)) {
+ if(!pairs_xlate_v4_to_v6_outer(nat46, &apair, hdr4, having_l4 ? &sport : NULL, having_l4 ? &dport : NULL, v6saddr, v6daddr)) {
nat46debug(0, "[nat46] Could not translate v4->v6");
goto done;
}
--- a/nat46/modules/nat46-core.h
+++ b/nat46/modules/nat46-core.h
@@ -23,6 +23,15 @@
// #define nat46debug(level, format, ...)
#define nat46debug(level, format, ...) do { if(nat46->debug >= level) { printk(format "\n", ##__VA_ARGS__); } } while (0)
+#define U8_MASK (uint8_t)(0xFF)
+#define U32_MASK (uint32_t)(~0U)
+#define BITS_PER_BYTE 8
+#define PSID_LEN_MAX 16
+#define NUM_RULE_PAIRS_MAX 32
+#define IPV4_BITS_MAX 32
+#define EA_LEN_MAX 48
+#define IPV6_BITS_MAX 128
+
#define IPV6HDRSIZE 40
#define IPV4HDRSIZE 20
#define IPV6V4HDRDELTA (IPV6HDRSIZE - IPV4HDRSIZE)
@@ -39,6 +48,17 @@ typedef enum {
NAT46_XLATE_RFC6052
} nat46_xlate_style_t;
+/*
+ * Enumeration for sorting pairs based on
+ * type of prefix length.
+ */
+typedef enum {
+ NAT46_IPV4_LOCAL = 0,
+ NAT46_IPV4_REMOTE,
+ NAT46_IPV6_LOCAL,
+ NAT46_IPV6_REMOTE
+} nat46_rule_type_t;
+
#define NAT46_SIGNATURE 0x544e3634
#define FREED_NAT46_SIGNATURE 0xdead544e
@@ -64,7 +84,11 @@ typedef struct {
int debug;
int npairs;
- nat46_xlate_rulepair_t pairs[0]; /* npairs */
+ nat46_xlate_rulepair_t pairs[NUM_RULE_PAIRS_MAX]; /* npairs */
+ nat46_xlate_rulepair_t sorted_ipv4_local_pairs[NUM_RULE_PAIRS_MAX]; /* npairs */
+ nat46_xlate_rulepair_t sorted_ipv4_remote_pairs[NUM_RULE_PAIRS_MAX]; /* npairs */
+ nat46_xlate_rulepair_t sorted_ipv6_local_pairs[NUM_RULE_PAIRS_MAX]; /* npairs */
+ nat46_xlate_rulepair_t sorted_ipv6_remote_pairs[NUM_RULE_PAIRS_MAX]; /* npairs */
} nat46_instance_t;
int nat46_ipv6_input(struct sk_buff *old_skb);
--- a/nat46/modules/nat46-netdev.c
+++ b/nat46/modules/nat46-netdev.c
@@ -270,7 +270,14 @@ int nat46_insert(struct net *net, char *
int ret = -1;
if(dev) {
nat46_instance_t *nat46 = netdev_nat46_instance(dev);
- nat46_instance_t *nat46_new = alloc_nat46_instance(nat46->npairs+1, nat46, 0, 1, -1);
+ nat46_instance_t *nat46_new;
+
+ if(nat46->npairs == NUM_RULE_PAIRS_MAX) {
+ printk("Could not insert a new rule on device %s\n", devname);
+ return ret;
+ }
+
+ nat46_new = alloc_nat46_instance(nat46->npairs+1, nat46, 0, 1, -1);
if(nat46_new) {
netdev_nat46_set_instance(dev, nat46_new);
ret = nat46_set_ipair_config(nat46_new, 0, buf, strlen(buf));

View File

@ -0,0 +1,104 @@
Author: Pavithra R <pavir@codeaurora.org>
Date: Wed Aug 5 10:09:45 2020 +0530
nat46: Add dummy fragment header for DF=0 IPv4 packet.
This patch is propagated from 4.4 kernel commit
b45f19e86ebcc19ea26d5e014bfdcb837148f99e.
Add dummy fragment header to IPv6 translated packet for
every DF=0 IPv4 packet.
Change-Id: Id72945eefac030e95e4fd18305e48c46e525def3
Signed-off-by: Pavithra R <pavir@codeaurora.org>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -1996,6 +1996,27 @@ done:
+/*
+ * Function to get MAP-T rules and flags.
+ */
+bool nat46_get_info(struct net_device *dev, nat46_xlate_rulepair_t **nat46_rule_pair,
+ int *count, u8 *flag) {
+ if ((!dev) || (!nat46_rule_pair) || (!count) || (!flag)) {
+ return false;
+ }
+
+ if (!nat46_get_rule_config(dev, nat46_rule_pair, count)) {
+ return false;
+ }
+
+ /* Check add dummy header flag */
+ if (add_dummy_header) {
+ *flag = ADD_DUMMY_HEADER;
+ }
+ return true;
+}
+EXPORT_SYMBOL(nat46_get_info);
+
void ip6_update_csum(struct sk_buff * skb, struct ipv6hdr * ip6hdr, int do_atomic_frag)
{
u32 sum1=0;
@@ -2254,6 +2275,11 @@ int nat46_ipv4_input(struct sk_buff *old
}
hdr4 = ip_hdr(old_skb);
check_for_l4 = 1;
+ if (add_dummy_header) {
+ if (0 == (ntohs(hdr4->frag_off) & IP_DF)) {
+ add_frag_header = 1;
+ }
+ }
} else {
add_frag_header = 1;
if (0 == (ntohs(hdr4->frag_off) & 0x1FFF)) {
--- a/nat46/modules/nat46-core.h
+++ b/nat46/modules/nat46-core.h
@@ -32,6 +32,9 @@
#define EA_LEN_MAX 48
#define IPV6_BITS_MAX 128
+/* Flag definations for MAP-T */
+#define ADD_DUMMY_HEADER 0x01
+
#define IPV6HDRSIZE 40
#define IPV4HDRSIZE 20
#define IPV6V4HDRDELTA (IPV6HDRSIZE - IPV4HDRSIZE)
@@ -110,5 +113,6 @@ int xlate_6_to_4(struct net_device *dev,
int xlate_4_to_6(struct net_device *dev, struct iphdr *hdr4, uint16_t sport, uint16_t dport, void *v6saddr, void *v6daddr);
bool nat46_get_rule_config(struct net_device *dev, nat46_xlate_rulepair_t **nat46_rule_pair, int *count);
int nat46_get_npairs(struct net_device *dev);
-
+bool nat46_get_info(struct net_device *dev, nat46_xlate_rulepair_t **nat46_rule_pair,
+ int *count, u8 *flag);
#endif
--- a/nat46/modules/nat46-module.c
+++ b/nat46/modules/nat46-module.c
@@ -59,12 +59,16 @@ MODULE_AUTHOR("Andrew Yourtchenko <ayour
MODULE_DESCRIPTION("NAT46 stateless translation");
int debug = 0;
+bool add_dummy_header = 0;
int zero_csum_pass = 0;
int ip_tos_ignore = 0;
module_param(debug, int, 0);
MODULE_PARM_DESC(debug, "debugging messages level (default=0)");
+module_param(add_dummy_header, bool, 0);
+MODULE_PARM_DESC(add_dummy_header, "Add dummy fragment header");
+
module_param(zero_csum_pass, int, 0);
MODULE_PARM_DESC(zero_csum_pass, "pass all-zero checksum unchanged (default=0)");
--- a/nat46/modules/nat46-module.h
+++ b/nat46/modules/nat46-module.h
@@ -14,5 +14,6 @@
*/
extern int debug;
+extern bool add_dummy_header;
extern int zero_csum_pass;
extern int ip_tos_ignore;

View File

@ -0,0 +1,136 @@
Author: Pavithra R <pavir@codeaurora.org>
Date: Wed Aug 5 10:57:25 2020 +0530
nat46: Add support for 64-bits stats.
This patch is propagated from 4.4 kernel commit
4a2d1dd9bc9331392c7a4947126c361217c82e0c
Add 64-bits stats functionality for MAP-T interface.
Change-Id: I4a6f9c7ed3554ac0ec672aa5fa283be2e95cfdc0
Signed-off-by: Pavithra R <pavir@codeaurora.org>
--- a/nat46/modules/nat46-netdev.c
+++ b/nat46/modules/nat46-netdev.c
@@ -24,6 +24,7 @@
#include <net/ip6_route.h>
#include <net/ipv6.h>
#include <linux/version.h>
+#include <net/ip_tunnels.h>
#include <linux/radix-tree.h>
#include "nat46-core.h"
#include "nat46-module.h"
@@ -40,16 +41,40 @@ static u8 netdev_count = 0;
static int nat46_netdev_up(struct net_device *dev);
static int nat46_netdev_down(struct net_device *dev);
-
+static int nat46_netdev_init(struct net_device *dev);
+static void nat46_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *tot);
static netdev_tx_t nat46_netdev_xmit(struct sk_buff *skb, struct net_device *dev);
static const struct net_device_ops nat46_netdev_ops = {
+ .ndo_init = nat46_netdev_init, /* device specific initialization */
.ndo_open = nat46_netdev_up, /* Called at ifconfig nat46 up */
.ndo_stop = nat46_netdev_down, /* Called at ifconfig nat46 down */
.ndo_start_xmit = nat46_netdev_xmit, /* REQUIRED, must return NETDEV_TX_OK */
+ .ndo_get_stats64 = nat46_get_stats64, /* 64 bit device stats */
};
+static int nat46_netdev_init(struct net_device *dev)
+{
+ int i;
+ dev->tstats = alloc_percpu(struct pcpu_sw_netstats);
+ if (!dev->tstats) {
+ return -ENOMEM;
+ }
+
+ for_each_possible_cpu(i) {
+ struct pcpu_sw_netstats *ipt_stats;
+ ipt_stats = per_cpu_ptr(dev->tstats, i);
+ u64_stats_init(&ipt_stats->syncp);
+ }
+ return 0;
+}
+
+static void nat46_netdev_resource_free(struct net_device *dev)
+{
+ free_percpu(dev->tstats);
+}
+
static int nat46_netdev_up(struct net_device *dev)
{
netif_start_queue(dev);
@@ -65,9 +90,14 @@ static int nat46_netdev_down(struct net_
static netdev_tx_t nat46_netdev_xmit(struct sk_buff *skb, struct net_device *dev)
{
int ret = 0;
+ struct pcpu_sw_netstats *tstats = get_cpu_ptr(dev->tstats);
+
+ u64_stats_update_begin(&tstats->syncp);
+ u64_stats_inc(&tstats->rx_packets);
+ u64_stats_add(&tstats->rx_bytes, skb->len);
+ u64_stats_update_end(&tstats->syncp);
+ put_cpu_ptr(tstats);
- dev->stats.rx_packets++;
- dev->stats.rx_bytes += skb->len;
if(ETH_P_IP == ntohs(skb->protocol)) {
ret = nat46_ipv4_input(skb);
}
@@ -81,22 +111,39 @@ static netdev_tx_t nat46_netdev_xmit(str
}
void nat46_netdev_count_xmit(struct sk_buff *skb, struct net_device *dev) {
- dev->stats.tx_packets++;
- dev->stats.tx_bytes += skb->len;
+ struct pcpu_sw_netstats *tstats = get_cpu_ptr(dev->tstats);
+
+ u64_stats_update_begin(&tstats->syncp);
+ u64_stats_inc(&tstats->tx_packets);
+ u64_stats_add(&tstats->tx_bytes, skb->len);
+ u64_stats_update_end(&tstats->syncp);
+ put_cpu_ptr(tstats);
}
void nat46_update_stats(struct net_device *dev, uint32_t rx_packets, uint32_t rx_bytes,
uint32_t tx_packets, uint32_t tx_bytes, uint32_t rx_dropped, uint32_t tx_dropped)
{
- dev->stats.rx_packets += rx_packets;
- dev->stats.rx_bytes += rx_bytes;
- dev->stats.tx_packets += tx_packets;
- dev->stats.tx_bytes += tx_bytes;
+ struct pcpu_sw_netstats *tstats = get_cpu_ptr(dev->tstats);
+
+ u64_stats_update_begin(&tstats->syncp);
+ u64_stats_add(&tstats->rx_packets, rx_packets);
+ u64_stats_add(&tstats->rx_bytes, rx_bytes);
+ u64_stats_add(&tstats->tx_packets, tx_packets);
+ u64_stats_add(&tstats->tx_bytes, tx_bytes);
dev->stats.rx_dropped += rx_dropped;
dev->stats.tx_dropped += tx_dropped;
+ u64_stats_update_end(&tstats->syncp);
+ put_cpu_ptr(tstats);
}
EXPORT_SYMBOL(nat46_update_stats);
+static void nat46_get_stats64(struct net_device *dev,
+ struct rtnl_link_stats64 *tot)
+{
+ netdev_stats_to_stats64(tot, &dev->stats);
+ dev_fetch_sw_netstats(tot, dev->tstats);
+}
+
void *netdev_nat46_instance(struct net_device *dev) {
nat46_netdev_priv_t *priv = netdev_priv(dev);
return priv->nat46;
@@ -120,6 +167,7 @@ static void nat46_netdev_setup(struct ne
priv->nat46 = nat46;
dev->netdev_ops = &nat46_netdev_ops;
+ dev->priv_destructor = nat46_netdev_resource_free;
dev->type = ARPHRD_NONE;
dev->hard_header_len = 0;
dev->addr_len = 0;

View File

@ -0,0 +1,134 @@
Author: Pavithra R <pavir@codeaurora.org>
Date: Wed Aug 5 18:59:20 2020 +0530
nat46: Copy CE's port number to IPv6 fragment header.
This patch is propagated from kernel 4.4 commit
7886fd3eb081c7767b02685593bc1d19deaecba8
Copy CE's port number to the lower 16-bits of IPv6 identification
number.
Change-Id: I6946e93bf8bed4c1378d19e75db0729097e0d9eb
Signed-off-by: Pavithra R <pavir@codeaurora.org>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -31,6 +31,7 @@
static uint16_t xlate_pkt_in_err_v4_to_v6(nat46_instance_t *nat46, struct iphdr *iph,
struct sk_buff *old_skb, uint16_t *sport, uint16_t *dport);
+static DEFINE_SPINLOCK(port_id_lock);
void
nat46debug_dump(nat46_instance_t *nat46, int level, void *addr, int len)
@@ -2236,6 +2237,73 @@ static uint16_t xlate_pkt_in_err_v4_to_v
return 1;
}
+/* Return the port number from CE's port set */
+static uint16_t nat46_get_ce_port(nat46_xlate_rulepair_t *pair, uint16_t sport)
+{
+ /*
+ * 'psid_bits_len' represents number of bits in PSID.
+ * 'offset' represents offset of PSID in a port number.
+ */
+ uint8_t psid_bits_len, offset, port_set_bitmask;
+
+ /*
+ * 'psid16' represent PSID value.
+ * 'm' represents number of bits in excluded port set.
+ * 'a' represents number of bits in a 16-bit port number after PSID.
+ * It is used to control number of port in one contiguous port set.
+ *
+ * Name of a variable 'a' and 'm' is as per Appendix B of [RFC7597].
+ */
+ uint16_t psid16, value, m, a;
+ nat46_xlate_rule_t *rule;
+
+ /* stores to last port number from CE's port set */
+ static uint16_t port_num;
+
+ rule = &pair->local;
+ offset = rule->psid_offset;
+
+ if (rule->ea_len + rule->v4_pref_len > IPV4_BITS_MAX) {
+ psid_bits_len = rule->ea_len - (IPV4_BITS_MAX - rule->v4_pref_len);
+ } else {
+ return 0;
+ }
+ a = PSID_LEN_MAX - offset - psid_bits_len;
+ psid16 = (ntohs(sport) >> a) & (0xffff >> (PSID_LEN_MAX - psid_bits_len));
+
+ spin_lock(&port_id_lock);
+
+ /* Start case */
+ if (0 == port_num) {
+ m = (offset) ? 1 : 0;
+ port_num = (m << (PSID_LEN_MAX - offset)) | (psid16 << a);
+ value = port_num;
+ spin_unlock(&port_id_lock);
+ return value;
+ }
+
+ /* End of one port set */
+ port_set_bitmask = (1 << a) - 1;
+ value = port_num & port_set_bitmask;
+ if (0 == (value ^ port_set_bitmask)) {
+ m = port_num >> (PSID_LEN_MAX - offset);
+ m++;
+ /* End case */
+ if (m >= (1 << offset)) {
+ m = (offset) ? 1 : 0;
+ }
+ port_num = (m << (PSID_LEN_MAX - offset)) | (psid16 << a);
+ value = port_num;
+ spin_unlock(&port_id_lock);
+ return value;
+ }
+
+ port_num++;
+ value = port_num;
+ spin_unlock(&port_id_lock);
+ return value;
+}
+
int nat46_ipv4_input(struct sk_buff *old_skb) {
nat46_instance_t *nat46 = get_nat46_instance(old_skb);
nat46_xlate_rulepair_t apair;
@@ -2368,9 +2436,34 @@ int nat46_ipv4_input(struct sk_buff *old
if (add_frag_header) {
struct frag_hdr *fh = (struct frag_hdr*)(hdr6 + 1);
+ uint16_t ce_port_num = 0;
+
+ /* Flag to represent whether PSID is assigned to MAP-T node or not */
+ bool is_psid = false;
+
fh->frag_off = htons(((ntohs(hdr4->frag_off) >> 13) & 7) + ((ntohs(hdr4->frag_off) & 0x1FFF) << 3));
fh->nexthdr = hdr4->protocol;
- fh->identification = htonl(ntohs(hdr4->id));
+
+ /*
+ * PSID assigned MAP-T node will have non-zero ea_len and we are currently
+ * only supporting NAT46_XLATE_MAP as the CE's rule style.
+ */
+ is_psid = (apair.local.style == NAT46_XLATE_MAP) && apair.local.ea_len;
+ if (is_psid) {
+ ce_port_num = nat46_get_ce_port(nat46->pairs, sport);
+ nat46debug(10, "\n ce port number is %02x\n", ce_port_num);
+
+ /* Assign CE's port number as the fragment identifier */
+ if (ce_port_num) {
+ fh->identification = htonl(ce_port_num);
+ } else {
+ fh->identification = htonl(ntohs(hdr4->id));
+ }
+ } else {
+ fh->identification = htonl(ntohs(hdr4->id));
+ }
+
+
}
ip6_update_csum(new_skb, hdr6, add_frag_header);

View File

@ -0,0 +1,30 @@
Author: Pavithra R <pavir@codeaurora.org>
Date: Wed Aug 5 19:26:48 2020 +0530
nat46: Fix the issue of packets not fragmented
This patch is propagated from the kernel 4.4 commit
e598f9c249092abd7c7978fe99b6690884f225c9
when packets size is larger than the MTU of dst, if DF flag is not set,
fragment it instead of dropping it with PktTooBig ICMPv6 message.
Change-Id: I380d42f59bb4f46a45e542f251f5710f2cca8b62
Signed-off-by: Pavithra R <pavir@codeaurora.org>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -2343,10 +2343,11 @@ int nat46_ipv4_input(struct sk_buff *old
}
hdr4 = ip_hdr(old_skb);
check_for_l4 = 1;
- if (add_dummy_header) {
- if (0 == (ntohs(hdr4->frag_off) & IP_DF)) {
+ if (0 == (ntohs(hdr4->frag_off) & IP_DF)) {
+ if (add_dummy_header) {
add_frag_header = 1;
}
+ old_skb->ignore_df = 1;
}
} else {
add_frag_header = 1;

View File

@ -0,0 +1,100 @@
Author: Pavithra R <pavir@codeaurora.org>
Date: Wed Aug 5 20:16:27 2020 +0530
nat46: fix ICMPv6 error message dropped locally
This patch is propagated from the kernel 4.4 commit
1b96bd0e9ee9182566b119741854c03bf4b94a99
While routing IPv6 packets from a customer-side translated device (CLAT)
to a provider-side translated device (PLAT), it is possible that the IPv6
destination is unknown. In such a scenario, the IPv6 stack must send back
an ICMP error. However, the source IPv6 address of this error message does
not have a MAP-T translation. According to RFC2473, the translation layer
should use the tunnel's own IPv4 address for the IPv6 ICMP packet's source
address.
Change-Id: I784473cddf9214843c466d10763cb66852139ef6
Signed-off-by: Pavithra R <pavir@codeaurora.org>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -1782,11 +1782,12 @@ static uint16_t nat46_fixup_icmp(nat46_i
return ret;
}
-int pairs_xlate_v6_to_v4_outer(nat46_instance_t *nat46, nat46_xlate_rulepair_t *apair,
+int pairs_xlate_v6_to_v4_outer(nat46_instance_t *nat46, nat46_xlate_rulepair_t **papair,
struct ipv6hdr *ip6h, uint16_t proto, __u32 *pv4saddr, __u32 *pv4daddr) {
int ipair = 0;
int xlate_src = -1;
int xlate_dst = -1;
+ nat46_xlate_rulepair_t *apair;
for(ipair = 0; ipair < nat46->npairs; ipair++) {
apair = nat46_lpm(nat46, NAT46_IPV6_REMOTE, &ip6h->saddr);
@@ -1794,6 +1795,7 @@ int pairs_xlate_v6_to_v4_outer(nat46_ins
return 0;
}
+ *papair = apair;
if (xlate_v6_to_v4(nat46, &apair->local, &ip6h->daddr, pv4daddr)) {
nat46debug(5, "Dst addr %pI6 to %pI4 \n", &ip6h->daddr, pv4daddr);
xlate_dst = ipair;
@@ -1822,14 +1824,14 @@ int pairs_xlate_v6_to_v4_outer(nat46_ins
}
int xlate_6_to_4(struct net_device *dev, struct ipv6hdr *ip6h, uint16_t proto, __u32 *pv4saddr, __u32 *pv4daddr) {
- nat46_xlate_rulepair_t apair;
+ nat46_xlate_rulepair_t *apair;
return pairs_xlate_v6_to_v4_outer(netdev_nat46_instance(dev), &apair, ip6h, proto, pv4saddr, pv4daddr);
}
EXPORT_SYMBOL(xlate_6_to_4);
int nat46_ipv6_input(struct sk_buff *old_skb) {
struct ipv6hdr *ip6h = ipv6_hdr(old_skb);
- nat46_xlate_rulepair_t apair;
+ nat46_xlate_rulepair_t *apair;
nat46_instance_t *nat46 = get_nat46_instance(old_skb);
uint16_t proto;
uint16_t frag_off;
@@ -1903,8 +1905,37 @@ int nat46_ipv6_input(struct sk_buff *old
}
if (!pairs_xlate_v6_to_v4_outer(nat46, &apair, ip6h, proto, &v4saddr, &v4daddr)) {
- nat46debug(0, "[nat46] Could not translate v6->v4");
- goto done;
+ if (proto == NEXTHDR_ICMP) {
+ struct icmp6hdr *icmp6h = add_offset(ip6h, v6packet_l3size);
+ struct ipv6hdr *ip6h_inner = (struct ipv6hdr *) (icmp6h + 1);
+ struct ipv6hdr hdr6;
+ switch(icmp6h->icmp6_type) {
+ case ICMPV6_DEST_UNREACH:
+ case ICMPV6_PKT_TOOBIG:
+ case ICMPV6_TIME_EXCEED:
+ case ICMPV6_PARAMPROB:
+ /*
+ * For icmpv6 error message, using the original message
+ * address to locate the apair one more time according
+ * to the RFC 2473, and use the ipv4 address of the
+ * tunnel as SRC ipv4 address
+ */
+ memcpy(&hdr6.saddr, &ip6h_inner->daddr, 16);
+ memcpy(&hdr6.daddr, &ip6h_inner->saddr, 16);
+ if (!pairs_xlate_v6_to_v4_outer(nat46, &apair, &hdr6, proto, &v4saddr, &v4daddr)) {
+ nat46debug(0, "[nat46] Could not translate v6->v4");
+ goto done;
+ }
+ v4saddr = apair->local.v4_pref;
+ break;
+ default:
+ nat46debug(0, "[nat46] Could not translate v6->v4");
+ goto done;
+ }
+ } else {
+ nat46debug(0, "[nat46] Could not translate v6->v4");
+ goto done;
+ }
}
if (check_for_l4) {

View File

@ -0,0 +1,40 @@
Author: Pavithra R <pavir@codeaurora.org>
Date: Wed Aug 5 20:35:00 2020 +0530
nat46: Fix null pointer dereference issue
This patch is propagated from the kernel 4.4 commit
5bdf9bd5500c45ab5a3fd43e60c40a09d5e5a13d
get_nat46_instance possibly returns null point, before using the returning
point, caller needs to check if it is null.
Change-Id: Id407a71ca8eccd60a713c34429e7e3f16e2cdd12
Signed-off-by: Pavithra R <pavir@codeaurora.org>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -1847,6 +1847,11 @@ int nat46_ipv6_input(struct sk_buff *old
int l3_infrag_payload_len = ntohs(ip6h->payload_len);
int check_for_l4 = 0;
+ if (nat46 == NULL) {
+ printk("nat46:%p skb is dropped for no valid instance found\n", old_skb);
+ return err;
+ }
+
nat46debug(4, "nat46_ipv6_input packet");
if(ip6_input_not_interested(nat46, ip6h, old_skb)) {
@@ -2353,6 +2358,11 @@ int nat46_ipv4_input(struct sk_buff *old
char v6saddr[16], v6daddr[16];
+ if (nat46 == NULL) {
+ printk("nat46:%p skb is dropped for no valid instance found\n", old_skb);
+ return err;
+ }
+
memset(v6saddr, 1, 16);
memset(v6daddr, 2, 16);

View File

@ -0,0 +1,40 @@
Author: Pavithra R <pavir@codeaurora.org>
Date: Wed Aug 5 20:57:33 2020 +0530
Fix crash of free skb
This patch is propagated from the 4.4 kernel commit
b959b0d45c66ae004a5bfc1687980093fa5b8cc3.
This is caused by the translation of the inner ipv6 header, it
move memory by the inner head's tot_len which is not exact that
inner packet will be trimmed for icmp error packets size no more
than 576.
Change-Id: Id5d41fa0721acdf6ea76721c45415fe3be432207
Signed-off-by: Pavithra R <pavir@codeaurora.org>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -2245,7 +2245,9 @@ static uint16_t xlate_pkt_in_err_v4_to_v
if (skb_tailroom(old_skb) >= IPV6V4HDRDELTA){
skb_put(old_skb, IPV6V4HDRDELTA);
- memmove(((char *)iiph + IPV6HDRSIZE), (iiph + 1), ntohs(iiph->tot_len) - IPV4HDRSIZE);
+ /* ErrorICMP size is less than 576, the inner ipv4 packet will be trimmed */
+ memmove(((char *)iiph + IPV6HDRSIZE), (iiph + 1),
+ ntohs(iph->tot_len) - 2 * IPV4HDRSIZE - sizeof(struct icmphdr));
memcpy(iiph, &ip6h, IPV6HDRSIZE);
}
else {
@@ -2258,7 +2260,9 @@ static uint16_t xlate_pkt_in_err_v4_to_v
skb_put(old_skb, IPV6V4HDRDELTA);
iiph = (struct iphdr *)(icmp_hdr(old_skb) + 1);
- memmove(((char *)iiph + IPV6HDRSIZE), (iiph + 1), ntohs(iiph->tot_len) - IPV4HDRSIZE);
+ /* ErrorICMP size is less than 576, the inner ipv4 packet will be trimmed */
+ memmove(((char *)iiph + IPV6HDRSIZE), (iiph + 1),
+ ntohs(iph->tot_len) - 2 * IPV4HDRSIZE - sizeof(struct icmphdr));
memcpy(iiph, &ip6h, IPV6HDRSIZE);
nat46 = get_nat46_instance(old_skb);
iph = ip_hdr(old_skb);

View File

@ -0,0 +1,34 @@
Author: Pavithra R <pavir@codeaurora.org>
Date: Wed Sep 30 14:05:50 2020 +0530
nat46: Add rate limit to a print.
This patch is propagated from the kernel 4.4 commit
d47f62508d2c105f236470e56bedbe279db0e6f1
Change-Id: I2119fbe54d630c3ed39535f1cb1b8a0d9d3199b4
Signed-off-by: Pavithra R <pavir@codeaurora.org>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -1928,7 +1928,9 @@ int nat46_ipv6_input(struct sk_buff *old
memcpy(&hdr6.saddr, &ip6h_inner->daddr, 16);
memcpy(&hdr6.daddr, &ip6h_inner->saddr, 16);
if (!pairs_xlate_v6_to_v4_outer(nat46, &apair, &hdr6, proto, &v4saddr, &v4daddr)) {
- nat46debug(0, "[nat46] Could not translate v6->v4");
+ if (net_ratelimit()) {
+ nat46debug(0, "[nat46] Could not translate v6->v4");
+ }
goto done;
}
v4saddr = apair->local.v4_pref;
@@ -2436,7 +2438,9 @@ int nat46_ipv4_input(struct sk_buff *old
}
if(!pairs_xlate_v4_to_v6_outer(nat46, &apair, hdr4, having_l4 ? &sport : NULL, having_l4 ? &dport : NULL, v6saddr, v6daddr)) {
- nat46debug(0, "[nat46] Could not translate v4->v6");
+ if (net_ratelimit()) {
+ nat46debug(0, "[nat46] Could not translate v4->v6");
+ }
goto done;
}

View File

@ -0,0 +1,34 @@
Author: Pavithra R <pavir@codeaurora.org>
Date: Wed Sep 30 14:27:37 2020 +0530
nat46: Fix for ICMP error packets with no payload.
This patch is propagated from the kernel 4.4 commit
d8b29a8e31f948a5d7338aa69c36e0f654fcb9e4
When no payload is attached to the original packet, any
ICMP error message generated in response to such packets
gets dropped due to malformed packet at CE.
During the translation of packet-in-error in ICMP,
the IPv6 header in ICMPv6 payload gets corrupted.
Hence, the translated packet gets dropped at CE.
This fix updates the outer IPv4 header's total length
before translating to IPv6 header.
Change-Id: Ifd9802afb50771de39b4c6fb734d36b0801613ec
Signed-off-by: Pavithra R <pavir@codeaurora.org>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -2266,9 +2266,8 @@ static uint16_t xlate_pkt_in_err_v4_to_v
memmove(((char *)iiph + IPV6HDRSIZE), (iiph + 1),
ntohs(iph->tot_len) - 2 * IPV4HDRSIZE - sizeof(struct icmphdr));
memcpy(iiph, &ip6h, IPV6HDRSIZE);
- nat46 = get_nat46_instance(old_skb);
- iph = ip_hdr(old_skb);
}
+ iph->tot_len = htons(ntohs(iph->tot_len) + IPV6V4HDRDELTA);
/* Swapping Ports for outer header */
/* Another work-around till LPM is not present. */

View File

@ -0,0 +1,415 @@
Author: Suruchi Agarwal <quic_suruchia@quicinc.com>
Date: Fri Dec 17 13:37:15 2021 -0800
nat46: Performance fix
Avoid allocating new skb and copy for map-t translation
Change-Id: I621b90609b4642d64b6e4cfb98b105b3fcbb0365
Signed-off-by: Suruchi Agarwal <quic_suruchia@quicinc.com>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -118,7 +118,7 @@ char *get_next_arg(char **ptail) {
return pc;
}
-/*
+/*
* Parse an IPv6 address (if pref_len is NULL), or prefix (if it isn't).
* parses destructively (places \0 between address and prefix len)
*/
@@ -163,7 +163,7 @@ int try_parse_ipv4_prefix(u32 *v4addr, i
}
-/*
+/*
* parse a rule argument and put config into a rule.
* advance the tail to prepare for the next arg parsing.
* destructive.
@@ -384,7 +384,7 @@ char *xlate_style_to_string(nat46_xlate_
return "unknown";
}
-/*
+/*
* Get the nat46 configuration into a supplied buffer (if non-null).
*/
int nat46_get_ipair_config(nat46_instance_t *nat46, int ipair, char *buf, int count) {
@@ -985,6 +985,28 @@ __sum16 csum_ipv6_unmagic(nat46_instance
return csum;
}
+/* Update UDP with incremental checksum */
+__sum16 csum_ipv6_udp_remagic(struct ipv6hdr *ip6hdr, u32 csum) {
+ uint32_t sum;
+ sum = csum_partial(ip6hdr->saddr.s6_addr16, 2 * sizeof(ip6hdr->saddr), ~csum);
+ sum = ((sum >> 16) & 0xffff) + (sum & 0xffff);
+ sum += ((sum >> 16) & 0xffff);
+ return (u16)(~sum);
+}
+
+/* Undo the IPv4 pseudoheader inclusion into the checksum */
+__sum16 csum_ipv4_unmagic(__be32 saddr, __be32 daddr,
+ u32 csum) {
+ u32 s;
+ uint32_t addr_csum;
+ csum = ntohs(~csum);
+ addr_csum = (saddr & 0xffff) + (saddr >> 16) + (daddr & 0xffff) + (daddr >> 16);
+ s= csum + ntohs(~addr_csum);
+ s = ((s >> 16) & 0xffff) + (s & 0xffff);
+ s += ((s >> 16) & 0xffff);
+ return htons((u16)(~s));
+}
+
/* Update ICMPv6 type/code with incremental checksum adjustment */
void update_icmp6_type_code(nat46_instance_t *nat46, struct icmp6hdr *icmp6h, u8 type, u8 code) {
u16 old_tc = *((u16 *)icmp6h);
@@ -1038,9 +1060,8 @@ void fill_v6hdr_from_v4hdr(struct iphdr
ip6h->hop_limit = iph->ttl;
}
-void fill_v4hdr_from_v6hdr(struct iphdr * iph, struct ipv6hdr *ip6h, __u32 v4saddr, __u32 v4daddr, __u16 id, __u16 frag_off, __u16 proto, int l3_payload_len) {
- uint32_t ver_class_flow = ntohl(*(__be32 *)ip6h);
- iph->ttl = ip6h->hop_limit;
+void fill_v4hdr_from_v6hdr(struct iphdr * iph, uint32_t ver_class_flow, uint8_t hop_limit, __u32 v4saddr, __u32 v4daddr, __u16 id, __u16 frag_off, __u16 proto, int l3_payload_len) {
+ iph->ttl = hop_limit;
iph->saddr = v4saddr;
iph->daddr = v4daddr;
iph->protocol = proto;
@@ -1198,6 +1219,8 @@ void pairs_xlate_v6_to_v4_inner(nat46_in
*/
int xlate_payload6_to4(nat46_instance_t *nat46, void *pv6, void *ptrans_hdr, int v6_len, u16 *ul_sum, int *ptailTruncSize) {
struct ipv6hdr *ip6h = pv6;
+ uint32_t ver_class_flow;
+ uint8_t hop_limit;
__u32 v4saddr, v4daddr;
struct iphdr new_ipv4;
struct iphdr *iph = &new_ipv4;
@@ -1274,7 +1297,10 @@ int xlate_payload6_to4(nat46_instance_t
}
}
- fill_v4hdr_from_v6hdr(iph, ip6h, v4saddr, v4daddr, ipid, ipflags, proto, infrag_payload_len);
+ ver_class_flow = ntohl(*(__be32 *)ip6h);
+ hop_limit = ip6h->hop_limit;
+
+ fill_v4hdr_from_v6hdr(iph, ver_class_flow, hop_limit, v4saddr, v4daddr, ipid, ipflags, proto, infrag_payload_len);
if(ul_sum) {
*ul_sum = unchecksum16(pv6, (((u8 *)ptrans_hdr)-((u8 *)pv6))/2, *ul_sum);
*ul_sum = rechecksum16(iph, 10, *ul_sum);
@@ -1831,6 +1857,8 @@ EXPORT_SYMBOL(xlate_6_to_4);
int nat46_ipv6_input(struct sk_buff *old_skb) {
struct ipv6hdr *ip6h = ipv6_hdr(old_skb);
+ uint32_t ver_class_flow;
+ uint8_t hop_limit;
nat46_xlate_rulepair_t *apair;
nat46_instance_t *nat46 = get_nat46_instance(old_skb);
uint16_t proto;
@@ -1839,22 +1867,20 @@ int nat46_ipv6_input(struct sk_buff *old
struct iphdr * iph;
__u32 v4saddr, v4daddr;
- struct sk_buff * new_skb = 0;
int err = 0;
- int truncSize = 0;
int tailTruncSize = 0;
int v6packet_l3size = sizeof(*ip6h);
int l3_infrag_payload_len = ntohs(ip6h->payload_len);
int check_for_l4 = 0;
- if (nat46 == NULL) {
+ if (unlikely(nat46 == NULL)) {
printk("nat46:%p skb is dropped for no valid instance found\n", old_skb);
return err;
}
nat46debug(4, "nat46_ipv6_input packet");
- if(ip6_input_not_interested(nat46, ip6h, old_skb)) {
+ if(unlikely(ip6_input_not_interested(nat46, ip6h, old_skb))) {
nat46debug(1, "nat46_ipv6_input not interested");
goto done;
}
@@ -1985,47 +2011,45 @@ int nat46_ipv6_input(struct sk_buff *old
}
}
- new_skb = skb_copy(old_skb, GFP_ATOMIC); // other possible option: GFP_ATOMIC
- if (!new_skb) {
- nat46debug(0, "[nat46] Could not copy v6 skb");
- goto done;
- }
+ ver_class_flow = ntohl(*(__be32 *)ip6h);
+ hop_limit = ip6h->hop_limit;
/* Remove any debris in the socket control block */
- memset(IPCB(new_skb), 0, sizeof(struct inet_skb_parm));
+ memset(IPCB(old_skb), 0, sizeof(struct inet_skb_parm));
+
/* Remove netfilter references to IPv6 packet, new netfilter references will be created based on IPv4 packet */
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0)
- nf_reset(new_skb);
+ nf_reset(old_skb);
#else
- skb_ext_reset(new_skb);
- nf_reset_ct(new_skb);
+ skb_ext_reset(old_skb);
+ nf_reset_ct(old_skb);
#endif
/* modify packet: actual IPv6->IPv4 transformation */
- truncSize = v6packet_l3size - sizeof(struct iphdr); /* chop first 20 bytes */
- skb_pull(new_skb, truncSize);
- skb_put(new_skb, -tailTruncSize);
+ skb_pull(old_skb, sizeof(struct iphdr));
l3_infrag_payload_len -= tailTruncSize;
- skb_reset_network_header(new_skb);
- skb_set_transport_header(new_skb,IPV4HDRSIZE); /* transport (TCP/UDP/ICMP/...) header starts after 20 bytes */
+ skb_reset_mac_header(old_skb);
+ skb_reset_network_header(old_skb);
+ skb_set_transport_header(old_skb,IPV4HDRSIZE); /* transport (TCP/UDP/ICMP/...) header starts after 20 bytes */
/* build IPv4 header */
- iph = ip_hdr(new_skb);
- fill_v4hdr_from_v6hdr(iph, ip6h, v4saddr, v4daddr, frag_id, frag_off, proto, l3_infrag_payload_len);
- new_skb->protocol = htons(ETH_P_IP);
+ iph = ip_hdr(old_skb);
+ fill_v4hdr_from_v6hdr(iph, ver_class_flow, hop_limit, v4saddr, v4daddr, frag_id, frag_off, proto, l3_infrag_payload_len);
+ old_skb->protocol = htons(ETH_P_IP);
if (ntohs(iph->tot_len) >= 2000) {
nat46debug(0, "Too big IP len: %d", ntohs(iph->tot_len));
}
- nat46debug(5, "about to send v4 packet, flags: %02x", IPCB(new_skb)->flags);
- nat46_netdev_count_xmit(new_skb, old_skb->dev);
+ nat46debug(5, "about to send v4 packet, flags: %02x", IPCB(old_skb)->flags);
+ nat46_netdev_count_xmit(old_skb, old_skb->dev);
- /* set skb->iif */
- new_skb->skb_iif = old_skb->skb_iif;
-
- netif_rx(new_skb);
+ netif_rx(old_skb);
+ /*
+ * skb was consumed in the ipv4 format, don't release later.
+ */
+ err = 1;
/* TBD: should copy be released here? */
done:
@@ -2056,7 +2080,7 @@ bool nat46_get_info(struct net_device *d
}
EXPORT_SYMBOL(nat46_get_info);
-void ip6_update_csum(struct sk_buff * skb, struct ipv6hdr * ip6hdr, int do_atomic_frag)
+void ip6_update_csum(struct sk_buff * skb, struct ipv6hdr * ip6hdr, uint32_t v4saddr, uint32_t v4daddr, int do_atomic_frag)
{
u32 sum1=0;
u16 sum2=0;
@@ -2079,12 +2103,13 @@ void ip6_update_csum(struct sk_buff * sk
struct udphdr *udp = udp_hdr(skb);
unsigned udplen = ntohs(ip6hdr->payload_len) - (do_atomic_frag?8:0); /* UDP hdr + payload */
- oldsum = udp->check;
- udp->check = 0;
-
- sum1 = csum_partial((char*)udp, udplen, 0); /* calculate checksum for UDP hdr+payload */
- sum2 = csum_ipv6_magic(&ip6hdr->saddr, &ip6hdr->daddr, udplen, ip6hdr->nexthdr, sum1); /* add pseudoheader */
-
+ if (!udp->check) {
+ sum1 = csum_partial((char*)udp, udplen, 0); /* calculate checksum for UDP hdr+payload */
+ sum2 = csum_ipv6_magic(&ip6hdr->saddr, &ip6hdr->daddr, udplen, ip6hdr->nexthdr, sum1); /* add pseudoheader */
+ } else {
+ sum1 = csum_ipv4_unmagic(v4saddr, v4daddr, udp->check);
+ sum2 = csum_ipv6_udp_remagic(ip6hdr, sum1);
+ }
udp->check = sum2;
break;
@@ -2348,7 +2373,6 @@ static uint16_t nat46_get_ce_port(nat46_
int nat46_ipv4_input(struct sk_buff *old_skb) {
nat46_instance_t *nat46 = get_nat46_instance(old_skb);
nat46_xlate_rulepair_t apair;
- struct sk_buff *new_skb;
uint16_t sport = 0, dport = 0, ret = 0;
int err = 0;
@@ -2360,10 +2384,15 @@ int nat46_ipv4_input(struct sk_buff *old
struct ipv6hdr * hdr6;
struct iphdr * hdr4 = ip_hdr(old_skb);
+ uint32_t v4saddr, v4daddr;
+ uint8_t ttl;
+ uint16_t tot_len;
+ uint8_t protocol;
+ uint16_t frag_off, id;
char v6saddr[16], v6daddr[16];
- if (nat46 == NULL) {
+ if (unlikely(nat46 == NULL)) {
printk("nat46:%p skb is dropped for no valid instance found\n", old_skb);
return err;
}
@@ -2443,31 +2472,39 @@ int nat46_ipv4_input(struct sk_buff *old
goto done;
}
- new_skb = skb_copy(old_skb, GFP_ATOMIC);
- if (!new_skb) {
- nat46debug(0, "[nat46] Could not copy v4 skb");
- goto done;
- }
+ v4saddr = hdr4->saddr;
+ v4daddr = hdr4->daddr;
+ protocol = hdr4->protocol;
+ tot_len = hdr4->tot_len;
+ ttl = hdr4->ttl;
+ frag_off = hdr4->frag_off;
+ id = hdr4->id;
/* Remove any debris in the socket control block */
- memset(IP6CB(new_skb), 0, sizeof(struct inet6_skb_parm));
+ memset(IP6CB(old_skb), 0, sizeof(struct inet6_skb_parm));
/* Remove netfilter references to IPv4 packet, new netfilter references will be created based on IPv6 packet */
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0)
- nf_reset(new_skb);
+ nf_reset(old_skb);
#else
- skb_ext_reset(new_skb);
- nf_reset_ct(new_skb);
+ skb_ext_reset(old_skb);
+ nf_reset_ct(old_skb);
#endif
/* expand header (add 20 extra bytes at the beginning of sk_buff) */
- pskb_expand_head(new_skb, IPV6HDRSIZE - (hdr4->ihl << 2) + (add_frag_header?8:0), 0, GFP_ATOMIC);
+ if (skb_headroom(old_skb) < IPV6V4HDRDELTA) {
+ ret = pskb_expand_head(old_skb, IPV6V4HDRDELTA + (add_frag_header?8:0), 0, GFP_ATOMIC);
+ if (unlikely(ret)) {
+ nat46debug(0, "[nat46] Could not expand skb header");
+ goto done;
+ }
+ }
- skb_push(new_skb, IPV6HDRSIZE - (hdr4->ihl << 2) + (add_frag_header?8:0)); /* push boundary by extra 20 bytes */
+ skb_push(old_skb, IPV6HDRSIZE - (hdr4->ihl << 2) + (add_frag_header?8:0)); /* push boundary by extra 20 bytes */
- skb_reset_network_header(new_skb);
- skb_set_transport_header(new_skb, IPV6HDRSIZE + (add_frag_header?8:0) ); /* transport (TCP/UDP/ICMP/...) header starts after 40 bytes */
+ skb_reset_network_header(old_skb);
+ skb_set_transport_header(old_skb, IPV6HDRSIZE + (add_frag_header?8:0) ); /* transport (TCP/UDP/ICMP/...) header starts after 40 bytes */
- hdr6 = ipv6_hdr(new_skb);
+ hdr6 = ipv6_hdr(old_skb);
memset(hdr6, 0, sizeof(*hdr6) + (add_frag_header?8:0));
/* build IPv6 header */
@@ -2475,13 +2512,14 @@ int nat46_ipv4_input(struct sk_buff *old
*(__be32 *)hdr6 = htonl(0x60000000 | (tclass << 20)) | flowlabel; /* version, priority, flowlabel */
/* IPv6 length is a payload length, IPv4 is hdr+payload */
- hdr6->payload_len = htons(ntohs(hdr4->tot_len) - (hdr4->ihl << 2) + (add_frag_header?8:0));
- hdr6->nexthdr = hdr4->protocol;
- hdr6->hop_limit = hdr4->ttl;
+ hdr6->payload_len = htons(ntohs(tot_len) - sizeof(struct iphdr) + (add_frag_header?8:0));
+ hdr6->nexthdr = protocol;
+ hdr6->hop_limit = ttl;
+
memcpy(&hdr6->saddr, v6saddr, 16);
memcpy(&hdr6->daddr, v6daddr, 16);
- new_skb->protocol = htons(ETH_P_IPV6);
+ old_skb->protocol = htons(ETH_P_IPV6);
if (add_frag_header) {
struct frag_hdr *fh = (struct frag_hdr*)(hdr6 + 1);
@@ -2490,8 +2528,8 @@ int nat46_ipv4_input(struct sk_buff *old
/* Flag to represent whether PSID is assigned to MAP-T node or not */
bool is_psid = false;
- fh->frag_off = htons(((ntohs(hdr4->frag_off) >> 13) & 7) + ((ntohs(hdr4->frag_off) & 0x1FFF) << 3));
- fh->nexthdr = hdr4->protocol;
+ fh->frag_off = htons(((ntohs(frag_off) >> 13) & 7) + ((ntohs(frag_off) & 0x1FFF) << 3));
+ fh->nexthdr = protocol;
/*
* PSID assigned MAP-T node will have non-zero ea_len and we are currently
@@ -2506,29 +2544,30 @@ int nat46_ipv4_input(struct sk_buff *old
if (ce_port_num) {
fh->identification = htonl(ce_port_num);
} else {
- fh->identification = htonl(ntohs(hdr4->id));
+ fh->identification = htonl(ntohs(id));
}
} else {
- fh->identification = htonl(ntohs(hdr4->id));
+ fh->identification = htonl(ntohs(id));
}
}
- ip6_update_csum(new_skb, hdr6, add_frag_header);
+ ip6_update_csum(old_skb, hdr6, v4saddr, v4daddr, add_frag_header);
- hdr6->nexthdr = add_frag_header ? NEXTHDR_FRAGMENT : hdr4->protocol;
+ hdr6->nexthdr = add_frag_header ? NEXTHDR_FRAGMENT : protocol;
// FIXME: check if you can not fit the packet into the cached MTU
- // if (dst_mtu(skb_dst(new_skb))==0) { }
-
- nat46debug(5, "about to send v6 packet, flags: %02x", IP6CB(new_skb)->flags);
- nat46_netdev_count_xmit(new_skb, old_skb->dev);
+ // if (dst_mtu(skb_dst(old_skb))==0) { }
- /* set skb->iif */
- new_skb->skb_iif = old_skb->skb_iif;
+ nat46debug(5, "about to send v6 packet, flags: %02x", IPCB(old_skb)->flags);
+ nat46_netdev_count_xmit(old_skb, old_skb->dev);
+ netif_rx(old_skb);
- netif_rx(new_skb);
+ /*
+ * skb was reused, needn't free it later.
+ */
+ err = 1;
done:
release_nat46_instance(nat46);
--- a/nat46/modules/nat46-core.h
+++ b/nat46/modules/nat46-core.h
@@ -39,7 +39,7 @@
#define IPV4HDRSIZE 20
#define IPV6V4HDRDELTA (IPV6HDRSIZE - IPV4HDRSIZE)
-/*
+/*
* A generic v4<->v6 translation structure.
* The currently supported translation styles:
*/
--- a/nat46/modules/nat46-netdev.c
+++ b/nat46/modules/nat46-netdev.c
@@ -100,8 +100,7 @@ static netdev_tx_t nat46_netdev_xmit(str
if(ETH_P_IP == ntohs(skb->protocol)) {
ret = nat46_ipv4_input(skb);
- }
- if(ETH_P_IPV6 == ntohs(skb->protocol)) {
+ }else if(ETH_P_IPV6 == ntohs(skb->protocol)) {
ret = nat46_ipv6_input(skb);
}
if(0 == ret) {
@@ -174,6 +173,7 @@ static void nat46_netdev_setup(struct ne
dev->mtu = 16384; /* iptables does reassembly. Rather than using ETH_DATA_LEN, let's try to get as much mileage as we can with the Linux stack */
dev->features = NETIF_F_NETNS_LOCAL;
dev->flags = IFF_NOARP | IFF_POINTOPOINT;
+ dev->priv_flags_ext = IFF_EXT_MAPT;
}
int nat46_netdev_create(struct net *net, char *basename, struct net_device **dev)

View File

@ -0,0 +1,57 @@
commit 9457a8be6e700f39e6b545f8db0edd30c0693700
Author: Ken Zhu <quic_guigenz@quicinc.com>
Date: Tue Sep 6 11:11:20 2022 -0700
nat46: fix sleeping warning back trace
use spin_lock instead of mutex_lock since
mutex_lock could sleep in the kernel packet process.
Change-Id: I65c15a9f618ef296159884a0d6d742e66aaf6623
Signed-off-by: Ken Zhu <quic_guigenz@quicinc.com>
--- a/nat46/modules/nat46-glue.c
+++ b/nat46/modules/nat46-glue.c
@@ -18,7 +18,7 @@
#include "nat46-glue.h"
#include "nat46-core.h"
-static DEFINE_MUTEX(ref_lock);
+static DEFINE_SPINLOCK(ref_lock);
int is_valid_nat46(nat46_instance_t *nat46) {
return (nat46 && (nat46->sig == NAT46_SIGNATURE));
}
@@ -47,28 +47,27 @@ nat46_instance_t *alloc_nat46_instance(i
return nat46;
}
-
nat46_instance_t *get_nat46_instance(struct sk_buff *sk) {
nat46_instance_t *nat46 = netdev_nat46_instance(sk->dev);
- mutex_lock(&ref_lock);
+ spin_lock_bh(&ref_lock);
if (is_valid_nat46(nat46)) {
nat46->refcount++;
- mutex_unlock(&ref_lock);
+ spin_unlock_bh(&ref_lock);
return nat46;
} else {
printk("[nat46] get_nat46_instance: Could not find a valid NAT46 instance!");
- mutex_unlock(&ref_lock);
+ spin_unlock_bh(&ref_lock);
return NULL;
}
}
void release_nat46_instance(nat46_instance_t *nat46) {
- mutex_lock(&ref_lock);
+ spin_lock_bh(&ref_lock);
nat46->refcount--;
if(0 == nat46->refcount) {
printk("[nat46] release_nat46_instance: freeing nat46 instance with %d pairs\n", nat46->npairs);
nat46->sig = FREED_NAT46_SIGNATURE;
kfree(nat46);
}
- mutex_unlock(&ref_lock);
+ spin_unlock_bh(&ref_lock);
}

View File

@ -0,0 +1,27 @@
Author: Ramkishan Gurjar <quic_rgurjar@quicinc.com>
Date: Thu Nov 16 15:30:04 2023 +0530
nat46: Fix traffic class is not set in ipv6 Header from ipv4 tos value.
Change-Id: I781d7af8bc9751dd23f6c3f4195644b3f9025fcb
Signed-off-by: Ramkishan Gurjar <quic_rgurjar@quicinc.com>
--- a/nat46/modules/nat46-core.c
+++ b/nat46/modules/nat46-core.c
@@ -2397,6 +2397,8 @@ int nat46_ipv4_input(struct sk_buff *old
return err;
}
+ tclass = ip_tos_ignore ? 0 : hdr4->tos; /* traffic class */
+
memset(v6saddr, 1, 16);
memset(v6daddr, 2, 16);
@@ -2508,7 +2510,6 @@ int nat46_ipv4_input(struct sk_buff *old
memset(hdr6, 0, sizeof(*hdr6) + (add_frag_header?8:0));
/* build IPv6 header */
- tclass = ip_tos_ignore ? 0 : hdr4->tos; /* traffic class */
*(__be32 *)hdr6 = htonl(0x60000000 | (tclass << 20)) | flowlabel; /* version, priority, flowlabel */
/* IPv6 length is a payload length, IPv4 is hdr+payload */

View File

@ -39,7 +39,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
--- a/nss_dp_switchdev.c
+++ b/nss_dp_switchdev.c
@@ -648,4 +648,17 @@ void nss_dp_switchdev_setup(struct net_d
@@ -655,4 +655,17 @@ void nss_dp_switchdev_setup(struct net_d
switch_init_done = true;
}

View File

@ -16,11 +16,9 @@ Signed-off-by: George Moussalem <george.moussalem@outlook.com>
hal/dp_ops/syn_gmac_dp/syn_dp_tx.c | 23 ++++---------
4 files changed, 42 insertions(+), 44 deletions(-)
diff --git a/hal/dp_ops/syn_gmac_dp/syn_dp_cfg_rx.c b/hal/dp_ops/syn_gmac_dp/syn_dp_cfg_rx.c
index 8cbbcaaf..1c9006c7 100644
--- a/hal/dp_ops/syn_gmac_dp/syn_dp_cfg_rx.c
+++ b/hal/dp_ops/syn_gmac_dp/syn_dp_cfg_rx.c
@@ -26,6 +26,7 @@ static int syn_dp_cfg_rx_setup_desc_queue(struct syn_dp_info *dev_info)
@@ -26,6 +26,7 @@ static int syn_dp_cfg_rx_setup_desc_queu
{
struct syn_dp_info_rx *rx_info = &dev_info->dp_info_rx;
struct dma_desc_rx *first_desc = NULL;
@ -28,7 +26,7 @@ index 8cbbcaaf..1c9006c7 100644
struct net_device *netdev = rx_info->netdev;
netdev_dbg(netdev, "Total size of memory required for Rx Descriptors in Ring Mode = %u\n", (uint32_t)((sizeof(struct dma_desc_rx) * SYN_DP_RX_DESC_SIZE)));
@@ -33,13 +34,15 @@ static int syn_dp_cfg_rx_setup_desc_queue(struct syn_dp_info *dev_info)
@@ -33,13 +34,15 @@ static int syn_dp_cfg_rx_setup_desc_queu
/*
* Allocate cacheable descriptors for Rx
*/
@ -46,7 +44,7 @@ index 8cbbcaaf..1c9006c7 100644
rx_info->rx_desc = first_desc;
syn_dp_gmac_rx_desc_init_ring(rx_info->rx_desc, SYN_DP_RX_DESC_SIZE);
@@ -98,6 +101,10 @@ void syn_dp_cfg_rx_cleanup_rings(struct syn_dp_info *dev_info)
@@ -98,6 +101,10 @@ void syn_dp_cfg_rx_cleanup_rings(struct
for (i = 0; i < rx_info->busy_rx_desc_cnt; i++) {
rx_skb_index = (rx_skb_index + i) & SYN_DP_RX_DESC_MAX_INDEX;
rxdesc = rx_info->rx_desc;
@ -57,7 +55,7 @@ index 8cbbcaaf..1c9006c7 100644
skb = rx_info->rx_buf_pool[rx_skb_index].skb;
if (unlikely(skb != NULL)) {
dev_kfree_skb_any(skb);
@@ -105,7 +112,8 @@ void syn_dp_cfg_rx_cleanup_rings(struct syn_dp_info *dev_info)
@@ -105,7 +112,8 @@ void syn_dp_cfg_rx_cleanup_rings(struct
}
}
@ -67,11 +65,9 @@ index 8cbbcaaf..1c9006c7 100644
rx_info->rx_desc = NULL;
dev_info->rx_desc_dma_addr = (dma_addr_t)0;
}
diff --git a/hal/dp_ops/syn_gmac_dp/syn_dp_cfg_tx.c b/hal/dp_ops/syn_gmac_dp/syn_dp_cfg_tx.c
index bf5e19a0..284e8880 100644
--- a/hal/dp_ops/syn_gmac_dp/syn_dp_cfg_tx.c
+++ b/hal/dp_ops/syn_gmac_dp/syn_dp_cfg_tx.c
@@ -91,6 +91,8 @@ void syn_dp_cfg_tx_cleanup_rings(struct syn_dp_info *dev_info)
@@ -91,6 +91,8 @@ void syn_dp_cfg_tx_cleanup_rings(struct
tx_skb_index = syn_dp_tx_inc_index(tx_skb_index, i);
txdesc = tx_info->tx_desc;
@ -80,11 +76,9 @@ index bf5e19a0..284e8880 100644
skb = tx_info->tx_buf_pool[tx_skb_index].skb;
if (unlikely(skb != NULL)) {
dev_kfree_skb_any(skb);
diff --git a/hal/dp_ops/syn_gmac_dp/syn_dp_rx.c b/hal/dp_ops/syn_gmac_dp/syn_dp_rx.c
index 1ddeb7d6..1798d4e7 100644
--- a/hal/dp_ops/syn_gmac_dp/syn_dp_rx.c
+++ b/hal/dp_ops/syn_gmac_dp/syn_dp_rx.c
@@ -73,16 +73,6 @@ static inline void syn_dp_rx_refill_one_desc(struct dma_desc_rx *rx_desc,
@@ -73,16 +73,6 @@ static inline void syn_dp_rx_refill_one_
*/
static inline void syn_dp_rx_inval_and_flush(struct syn_dp_info_rx *rx_info, uint32_t start, uint32_t end)
{
@ -101,7 +95,7 @@ index 1ddeb7d6..1798d4e7 100644
dsb(st);
}
@@ -124,15 +114,19 @@ int syn_dp_rx_refill_page_mode(struct syn_dp_info_rx *rx_info)
@@ -124,15 +114,19 @@ int syn_dp_rx_refill_page_mode(struct sy
break;
}
@ -125,7 +119,7 @@ index 1ddeb7d6..1798d4e7 100644
rx_refill_idx = rx_info->rx_refill_idx;
rx_desc = rx_info->rx_desc + rx_refill_idx;
@@ -181,8 +175,15 @@ int syn_dp_rx_refill(struct syn_dp_info_rx *rx_info)
@@ -181,8 +175,15 @@ int syn_dp_rx_refill(struct syn_dp_info_
skb_reserve(skb, SYN_DP_SKB_HEADROOM + NET_IP_ALIGN);
@ -143,7 +137,7 @@ index 1ddeb7d6..1798d4e7 100644
rx_refill_idx = rx_info->rx_refill_idx;
rx_desc = rx_info->rx_desc + rx_refill_idx;
@@ -407,12 +408,6 @@ int syn_dp_rx(struct syn_dp_info_rx *rx_info, int budget)
@@ -407,12 +408,6 @@ int syn_dp_rx(struct syn_dp_info_rx *rx_
* this code is executing.
*/
end = syn_dp_rx_inc_index(rx_info->rx_idx, busy);
@ -156,7 +150,7 @@ index 1ddeb7d6..1798d4e7 100644
dsb(st);
@@ -439,8 +434,12 @@ int syn_dp_rx(struct syn_dp_info_rx *rx_info, int budget)
@@ -439,8 +434,12 @@ int syn_dp_rx(struct syn_dp_info_rx *rx_
* speculative prefetch by CPU may have occurred.
*/
frame_length = syn_dp_gmac_get_rx_desc_frame_length(status);
@ -171,11 +165,9 @@ index 1ddeb7d6..1798d4e7 100644
prefetch((void *)rx_buf->map_addr_virt);
rx_next_idx = syn_dp_rx_inc_index(rx_idx, 1);
diff --git a/hal/dp_ops/syn_gmac_dp/syn_dp_tx.c b/hal/dp_ops/syn_gmac_dp/syn_dp_tx.c
index c97e252b..6d4adb3f 100644
--- a/hal/dp_ops/syn_gmac_dp/syn_dp_tx.c
+++ b/hal/dp_ops/syn_gmac_dp/syn_dp_tx.c
@@ -104,9 +104,7 @@ static inline struct dma_desc_tx *syn_dp_tx_process_nr_frags(struct syn_dp_info_
@@ -104,9 +104,7 @@ static inline struct dma_desc_tx *syn_dp
BUG_ON(!length);
#endif
@ -186,7 +178,7 @@ index c97e252b..6d4adb3f 100644
*total_length += length;
tx_desc = syn_dp_tx_set_desc_sg(tx_info, dma_addr, length, DESC_OWN_BY_DMA);
@@ -150,8 +148,7 @@ int syn_dp_tx_nr_frags(struct syn_dp_info_tx *tx_info, struct sk_buff *skb)
@@ -150,8 +148,7 @@ int syn_dp_tx_nr_frags(struct syn_dp_inf
/*
* Flush the dma for non-paged skb data
*/
@ -196,7 +188,7 @@ index c97e252b..6d4adb3f 100644
total_len = length;
@@ -256,12 +253,7 @@ int syn_dp_tx_frag_list(struct syn_dp_info_tx *tx_info, struct sk_buff *skb)
@@ -256,12 +253,7 @@ int syn_dp_tx_frag_list(struct syn_dp_in
return NETDEV_TX_BUSY;
}
@ -210,7 +202,7 @@ index c97e252b..6d4adb3f 100644
total_len = length;
@@ -290,9 +282,7 @@ int syn_dp_tx_frag_list(struct syn_dp_info_tx *tx_info, struct sk_buff *skb)
@@ -290,9 +282,7 @@ int syn_dp_tx_frag_list(struct syn_dp_in
BUG_ON(!length);
#endif
@ -221,7 +213,7 @@ index c97e252b..6d4adb3f 100644
total_len += length;
@@ -445,6 +435,7 @@ int syn_dp_tx_complete(struct syn_dp_info_tx *tx_info, int budget)
@@ -445,6 +435,7 @@ int syn_dp_tx_complete(struct syn_dp_inf
break;
}
@ -229,7 +221,7 @@ index c97e252b..6d4adb3f 100644
if (likely(status & DESC_TX_LAST)) {
tx_skb_index = syn_dp_tx_comp_index_get(tx_info);
@@ -571,9 +562,7 @@ int syn_dp_tx(struct syn_dp_info_tx *tx_info, struct sk_buff *skb)
@@ -571,9 +562,7 @@ int syn_dp_tx(struct syn_dp_info_tx *tx_
return NETDEV_TX_BUSY;
}
@ -240,6 +232,3 @@ index c97e252b..6d4adb3f 100644
/*
* Queue packet to the GMAC rings
--
2.40.1

View File

@ -13,8 +13,6 @@ Signed-off-by: George Moussalem <george.moussalem@outlook.com>
hal/soc_ops/ipq50xx/nss_ipq50xx.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/hal/soc_ops/ipq50xx/nss_ipq50xx.c b/hal/soc_ops/ipq50xx/nss_ipq50xx.c
index 3e4491c0..e56de1cc 100644
--- a/hal/soc_ops/ipq50xx/nss_ipq50xx.c
+++ b/hal/soc_ops/ipq50xx/nss_ipq50xx.c
@@ -18,7 +18,7 @@
@ -41,6 +39,3 @@ index 3e4491c0..e56de1cc 100644
if (err) {
pr_err("%s: SCM TCSR write error: %d\n", __func__, err);
}
--
2.40.1

View File

@ -16,11 +16,9 @@ Signed-off-by: George Moussalem <george.moussalem@outlook.com>
nss_dp_main.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/nss_dp_main.c b/nss_dp_main.c
index 9a09edd5..204063bf 100644
--- a/nss_dp_main.c
+++ b/nss_dp_main.c
@@ -619,11 +619,20 @@ static int32_t nss_dp_of_get_pdata(struct device_node *np,
@@ -634,11 +634,20 @@ static int32_t nss_dp_of_get_pdata(struc
}
dp_priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
@ -44,6 +42,3 @@ index 9a09edd5..204063bf 100644
if (of_property_read_u32(np, "qcom,mactype", &hal_pdata->mactype)) {
pr_err("%s: error reading mactype\n", np->name);
return -EFAULT;
--
2.40.1

View File

@ -1,6 +1,6 @@
--- a/src/hsl/phy/hsl_phy.c
+++ b/src/hsl/phy/hsl_phy.c
@@ -785,7 +785,7 @@ hsl_phy_phydev_get(a_uint32_t dev_id, a_
@@ -761,7 +761,7 @@ hsl_phy_phydev_get(a_uint32_t dev_id, a_
*phydev = miibus->phy_map[phy_addr];
if(*phydev == NULL)
{
@ -9,7 +9,7 @@
return SW_NOT_INITIALIZED;
}
pdev_addr = (*phydev)->addr;
@@ -795,7 +795,7 @@ hsl_phy_phydev_get(a_uint32_t dev_id, a_
@@ -771,7 +771,7 @@ hsl_phy_phydev_get(a_uint32_t dev_id, a_
*phydev = mdiobus_get_phy(miibus, phy_addr);
if(*phydev == NULL)
{

View File

@ -18,8 +18,6 @@ Signed-off-by: George Moussalem <george.moussalem@outlook.com>
src/hsl/phy/hsl_phy.c | 4 ++--
5 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/config b/config
index 99d99dff..1f74e4f8 100644
--- a/config
+++ b/config
@@ -299,6 +299,7 @@ else ifeq (DESS, $(CHIP_TYPE))
@ -30,8 +28,6 @@ index 99d99dff..1f74e4f8 100644
IN_SFP_PHY=TRUE
IN_SFP=TRUE
else ifeq (APPE, $(CHIP_TYPE))
diff --git a/make/linux_opt.mk b/make/linux_opt.mk
index 6936b754..66b08ef5 100644
--- a/make/linux_opt.mk
+++ b/make/linux_opt.mk
@@ -183,6 +183,11 @@ endif
@ -46,8 +42,6 @@ index 6936b754..66b08ef5 100644
ifeq (TRUE, $(IN_SFP_PHY))
MODULE_CFLAG += -DIN_SFP_PHY
endif
diff --git a/src/adpt/mp/adpt_mp_portctrl.c b/src/adpt/mp/adpt_mp_portctrl.c
index 2c983fff..db60fc72 100644
--- a/src/adpt/mp/adpt_mp_portctrl.c
+++ b/src/adpt/mp/adpt_mp_portctrl.c
@@ -92,12 +92,15 @@ static sw_error_t
@ -66,7 +60,7 @@ index 2c983fff..db60fc72 100644
/*internal gephy reset*/
SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get(dev_id,
port_id));
@@ -107,6 +110,7 @@ adpt_mp_port_reset_set(a_uint32_t dev_id, a_uint32_t port_id)
@@ -107,6 +110,7 @@ adpt_mp_port_reset_set(a_uint32_t dev_id
SW_RTN_ON_ERROR (rv);
rv = phy_drv->phy_function_reset(dev_id, phy_addr, PHY_FIFO_RESET);
SW_RTN_ON_ERROR (rv);
@ -74,8 +68,6 @@ index 2c983fff..db60fc72 100644
} else if (port_id == SSDK_PHYSICAL_PORT2) {
rv = adpt_mp_uniphy_adapter_port_reset(dev_id, port_id);
} else {
diff --git a/src/hsl/phy/Makefile b/src/hsl/phy/Makefile
index 68d0679f..0eae9377 100755
--- a/src/hsl/phy/Makefile
+++ b/src/hsl/phy/Makefile
@@ -23,7 +23,7 @@ ifeq (ISIS, $(CHIP_TYPE))
@ -100,8 +92,6 @@ index 68d0679f..0eae9377 100755
endif
ifeq (NONHK_CHIP, $(CHIP_TYPE))
diff --git a/src/hsl/phy/hsl_phy.c b/src/hsl/phy/hsl_phy.c
index f2cf90e2..efab2343 100644
--- a/src/hsl/phy/hsl_phy.c
+++ b/src/hsl/phy/hsl_phy.c
@@ -28,7 +28,7 @@
@ -113,7 +103,7 @@ index f2cf90e2..efab2343 100644
#include "mpge_phy.h"
#endif
#ifdef IN_MALIBU_PHY
@@ -94,7 +94,7 @@ phy_driver_instance_t ssdk_phy_driver[] =
@@ -94,7 +94,7 @@ phy_driver_instance_t ssdk_phy_driver[]
#else
{SFP_PHY_CHIP, {0}, NULL, NULL, NULL},
#endif
@ -122,6 +112,3 @@ index f2cf90e2..efab2343 100644
{MPGE_PHY_CHIP, {0}, NULL, mpge_phy_init, NULL},
#else
{MPGE_PHY_CHIP, {0}, NULL, NULL, NULL},
--
2.40.1

View File

@ -18,8 +18,6 @@ Signed-off-by: George Moussalem <george.moussalem@outlook.com>
src/init/ssdk_clk.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/init/ssdk_clk.c b/src/init/ssdk_clk.c
index 71e59452..bc244c6e 100644
--- a/src/init/ssdk_clk.c
+++ b/src/init/ssdk_clk.c
@@ -1282,10 +1282,8 @@ ssdk_mp_reset_init(void)
@ -35,6 +33,3 @@ index 71e59452..bc244c6e 100644
ssdk_gcc_reset(rst, SSDK_RESET_ASSERT);
msleep(200);
ssdk_gcc_reset(rst, SSDK_RESET_DEASSERT);
--
2.40.1

View File

@ -15,11 +15,9 @@ Signed-off-by: George Moussalem <george.moussalem@outlook.com>
src/adpt/mp/adpt_mp_portctrl.c | 3 ++-
2 files changed, 3 insertions(+), 30 deletions(-)
diff --git a/config b/config
index 1f74e4f8..58d67648 100644
--- a/config
+++ b/config
@@ -374,6 +374,7 @@ ifneq (, $(filter MPPE APPE HPPE CPPE ALL_CHIP, $(CHIP_TYPE)))
@@ -374,6 +374,7 @@ ifneq (, $(filter MPPE APPE HPPE CPPE AL
endif
ifneq (, $(filter MP, $(CHIP_TYPE)))
@ -63,11 +61,9 @@ index 1f74e4f8..58d67648 100644
IN_CTRLPKT=TRUE
endif
diff --git a/src/adpt/mp/adpt_mp_portctrl.c b/src/adpt/mp/adpt_mp_portctrl.c
index db60fc72..c230e214 100644
--- a/src/adpt/mp/adpt_mp_portctrl.c
+++ b/src/adpt/mp/adpt_mp_portctrl.c
@@ -45,7 +45,8 @@ _adpt_mp_gcc_mac_clock_set(a_uint32_t dev_id,
@@ -45,7 +45,8 @@ _adpt_mp_gcc_mac_clock_set(a_uint32_t de
static a_bool_t
_adpt_mp_port_phy_connected (a_uint32_t dev_id, fal_port_t port_id)
{
@ -77,6 +73,3 @@ index db60fc72..c230e214 100644
/* force port which connect s17c or other device chip*/
if (hsl_port_feature_get(dev_id, port_id, PHY_F_FORCE | PHY_F_SFP)) {
--
2.40.1

View File

@ -12,11 +12,9 @@ Signed-off-by: George Moussalem <george.moussalem@outlook.com>
src/init/ssdk_clk.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/init/ssdk_clk.c b/src/init/ssdk_clk.c
index bc244c6e..dc45691e 100644
--- a/src/init/ssdk_clk.c
+++ b/src/init/ssdk_clk.c
@@ -1183,7 +1183,7 @@ ssdk_mp_tcsr_get(a_uint32_t tcsr_offset, a_uint32_t *tcsr_val)
@@ -1183,7 +1183,7 @@ ssdk_mp_tcsr_get(a_uint32_t tcsr_offset,
{
void __iomem *tcsr_base = NULL;
@ -25,7 +23,7 @@ index bc244c6e..dc45691e 100644
if (!tcsr_base)
{
SSDK_ERROR("Failed to map tcsr eth address!\n");
@@ -1200,7 +1200,7 @@ ssdk_mp_tcsr_set(a_uint32_t tcsr_offset, a_uint32_t tcsr_val)
@@ -1200,7 +1200,7 @@ ssdk_mp_tcsr_set(a_uint32_t tcsr_offset,
{
void __iomem *tcsr_base = NULL;
@ -43,7 +41,7 @@ index bc244c6e..dc45691e 100644
if (!pll_lock) {
SSDK_ERROR("Failed to map CMN PLL LOCK register!\n");
return A_FALSE;
@@ -1303,7 +1303,7 @@ static void ssdk_cmnblk_pll_src_set(enum cmnblk_pll_src_type pll_source)
@@ -1303,7 +1303,7 @@ static void ssdk_cmnblk_pll_src_set(enum
void __iomem *cmn_pll_src_base = NULL;
a_uint32_t reg_val;
@ -52,6 +50,3 @@ index bc244c6e..dc45691e 100644
if (!cmn_pll_src_base) {
SSDK_ERROR("Failed to map cmn pll source address!\n");
return;
--
2.40.1

View File

@ -40,7 +40,7 @@
kslib_c:
--- a/make/linux_opt.mk
+++ b/make/linux_opt.mk
@@ -782,6 +782,6 @@ LOCAL_CFLAGS += $(CPU_CFLAG) -D"KBUILD_M
@@ -787,6 +787,6 @@ LOCAL_CFLAGS += $(CPU_CFLAG) -D"KBUILD_M
####################################################################
# cflags for LNX Modules-Style Makefile
####################################################################

View File

@ -8,7 +8,7 @@
#include <linux/if_vlan.h>
#include <linux/crc32.h>
#include <linux/interrupt.h>
@@ -26097,6 +26098,22 @@ rtl8168_setup_mqs_reg(struct rtl8168_pri
@@ -26135,6 +26136,22 @@ rtl8168_setup_mqs_reg(struct rtl8168_pri
tp->imr_reg[3] = IntrMask3;
}
@ -31,7 +31,7 @@
static void
rtl8168_init_software_variable(struct net_device *dev)
{
@@ -26792,6 +26809,8 @@ err1:
@@ -26852,6 +26869,8 @@ err1:
if (tp->InitRxDescType == RX_DESC_RING_TYPE_2)
tp->RxDescLength = RX_DESC_LEN_TYPE_2;

Some files were not shown because too many files have changed in this diff Show More