From c66b76b62629c66f5bbd24229c556f9b5dca8cf7 Mon Sep 17 00:00:00 2001 From: "github-action[bot]" Date: Thu, 13 Jun 2024 20:31:37 +0200 Subject: [PATCH] Update On Thu Jun 13 20:31:37 CEST 2024 --- .github/update.log | 1 + clash-meta/dns/dialer.go | 12 + .../{dns/dial.go => tunnel/dns_dialer.go} | 33 +- clash-meta/tunnel/tunnel.go | 103 +- .../backend/tauri/src/config/nyanpasu/mod.rs | 12 +- clash-nyanpasu/backend/tauri/src/main.rs | 10 +- .../frontend/interface/service/tauri.ts | 4 + .../frontend/interface/service/types.ts | 2 +- clash-nyanpasu/frontend/nyanpasu/package.json | 6 +- .../nyanpasu/src/assets/styles/index.scss | 1 - .../nyanpasu/src/assets/styles/layout.scss | 124 +- .../nyanpasu/src/assets/styles/page.scss | 52 - .../components/app/app-container.module.scss | 14 + .../app/app-container.module.scss.d.ts | 5 + .../src/components/app/app-container.tsx | 47 + .../src/components/app/app-drawer.tsx | 122 ++ .../src/components/app/locales-provider.tsx | 22 + .../app/modules/route-list-item.tsx | 54 + .../components/base/base-dialog.module.scss | 5 - .../base/base-dialog.module.scss.d.ts | 5 - .../src/components/base/base-dialog.tsx | 141 -- .../src/components/base/base-loading.tsx | 48 - .../src/components/base/base-page.tsx | 38 - .../src/components/base/content-display.tsx | 36 + .../nyanpasu/src/components/base/index.ts | 3 - .../nyanpasu/src/components/common/kbd.tsx | 21 - .../src/components/common/mdy-switch.scss | 15 - .../src/components/common/mdy-switch.tsx | 89 -- .../connection/connection-detail.tsx | 106 -- .../components/connection/connection-item.tsx | 75 -- .../connection/connection-table.tsx | 114 -- .../connections/connections-table.tsx | 40 +- .../layout/animated-logo.module.scss | 7 + .../layout/animated-logo.module.scss.d.ts | 4 + .../src/components/layout/animated-logo.tsx | 81 +- .../src/components/layout/layout-control.tsx | 2 +- .../src/components/layout/layout-item.tsx | 42 - .../src/components/layout/layout-traffic.tsx | 137 -- .../src/components/layout/notice-provider.tsx | 38 + .../src/components/layout/page-transition.tsx | 116 +- .../src/components/layout/scheme-provider.tsx | 44 + .../src/components/layout/traffic-graph.tsx | 197 --- .../src/components/layout/update-button.tsx | 49 - .../components/layout/use-custom-theme.tsx | 3 + .../src/components/layout/use-log-setup.ts | 39 - .../src/components/log/log-item.module.scss | 23 - .../components/log/log-item.module.scss.d.ts | 6 - .../nyanpasu/src/components/log/log-item.tsx | 92 -- .../src/components/profile/editor-viewer.tsx | 94 -- .../src/components/profile/file-input.tsx | 61 - .../src/components/profile/log-viewer.tsx | 69 - .../src/components/profile/profile-box.tsx | 45 - .../src/components/profile/profile-item.tsx | 389 ------ .../src/components/profile/profile-more.tsx | 247 ---- .../src/components/profile/profile-viewer.tsx | 294 ---- .../src/components/proxies/delay-chip.tsx | 69 + .../src/components/proxies/feature-chip.tsx | 24 + .../src/components/proxies/group-list.tsx | 6 +- .../src/components/proxies/node-card.tsx | 45 + .../src/components/proxies/node-list.tsx | 216 +-- .../components/proxies/proxy-group-name.tsx | 31 + .../src/components/proxies/sort-selector.tsx | 55 + .../nyanpasu/src/components/proxies/utils.ts | 35 + .../src/components/proxy/provider-button.tsx | 87 -- .../components/proxy/proxy-group.module.scss | 7 - .../proxy/proxy-group.module.scss.d.ts | 4 - .../src/components/proxy/proxy-groups.tsx | 140 -- .../src/components/proxy/proxy-head.tsx | 162 --- .../src/components/proxy/proxy-item-mini.tsx | 181 --- .../src/components/proxy/proxy-item.tsx | 170 --- .../src/components/proxy/proxy-render.tsx | 236 ---- .../src/components/proxy/use-filter-sort.ts | 125 -- .../src/components/proxy/use-head-state.ts | 81 -- .../src/components/proxy/use-render-list.ts | 171 --- .../src/components/proxy/use-window-width.ts | 16 - .../src/components/rule/rule-item.tsx | 78 -- .../setting/mods/clash-core-viewer.tsx | 407 ------ .../setting/mods/clash-field-viewer.tsx | 129 -- .../setting/mods/clash-port-viewer.tsx | 81 -- .../components/setting/mods/config-viewer.tsx | 74 - .../setting/mods/controller-viewer.tsx | 122 -- .../components/setting/mods/guard-state.tsx | 47 - .../components/setting/mods/hotkey-input.tsx | 107 -- .../components/setting/mods/hotkey-viewer.tsx | 154 --- .../components/setting/mods/layout-viewer.tsx | 123 -- .../components/setting/mods/misc-viewer.tsx | 191 --- .../setting/mods/service-viewer.tsx | 146 -- .../components/setting/mods/setting-comp.tsx | 54 - .../setting/mods/sysproxy-viewer.tsx | 184 --- .../components/setting/mods/tasks-viewer.tsx | 79 -- .../setting/mods/theme-mode-switch.tsx | 31 - .../components/setting/mods/theme-viewer.tsx | 185 --- .../components/setting/mods/update-viewer.tsx | 102 -- .../components/setting/mods/web-ui-item.tsx | 130 -- .../components/setting/mods/web-ui-viewer.tsx | 145 -- .../src/components/setting/setting-clash.tsx | 235 ---- .../src/components/setting/setting-legacy.tsx | 74 - .../setting/setting-nyanpasu-misc.tsx | 5 + .../src/components/setting/setting-system.tsx | 185 --- .../src/components/setting/setting-verge.tsx | 356 ----- .../nyanpasu/src/hooks/use-notification.ts | 2 +- .../frontend/nyanpasu/src/locales/en.json | 3 +- .../frontend/nyanpasu/src/locales/zh.json | 3 +- .../frontend/nyanpasu/src/pages/_app.tsx | 214 +-- .../frontend/nyanpasu/src/pages/_layout.tsx | 3 +- .../frontend/nyanpasu/src/pages/proxies.tsx | 88 +- .../frontend/nyanpasu/src/pages/settings.tsx | 1 - .../frontend/nyanpasu/src/services/api.ts | 231 ---- .../frontend/nyanpasu/src/services/cmds.ts | 270 ---- .../frontend/nyanpasu/src/services/delay.ts | 128 -- .../frontend/nyanpasu/src/services/types.d.ts | 255 ---- .../nyanpasu/src/utils/clash-fields.ts | 53 - .../frontend/nyanpasu/src/utils/noop.ts | 1 - .../nyanpasu/src/utils/routes-utils.ts | 45 + .../nyanpasu/src/utils/truncate-str.ts | 6 - .../materialYou/components/sidePage/index.tsx | 1 + clash-nyanpasu/frontend/ui/package.json | 4 +- clash-nyanpasu/manifest/version.json | 4 +- clash-nyanpasu/package.json | 6 +- clash-nyanpasu/pnpm-lock.yaml | 451 ++----- clash-verge-rev/src-tauri/src/cmds.rs | 9 - clash-verge-rev/src-tauri/src/core/manager.rs | 48 - clash-verge-rev/src-tauri/src/core/mod.rs | 1 - clash-verge-rev/src-tauri/src/main.rs | 1 - .../src/components/profile/file-input.tsx | 4 +- .../src/components/profile/profile-viewer.tsx | 10 +- .../setting/mods/clash-core-viewer.tsx | 37 +- .../setting/mods/service-viewer.tsx | 5 +- .../setting/mods/stack-mode-switch.tsx | 7 +- clash-verge-rev/src/services/cmds.ts | 4 - gost/.github/workflows/release.yml | 2 +- gost/Dockerfile | 3 +- gost/cmd/gost/peer.go | 21 +- gost/cmd/gost/route.go | 1 + gost/go.mod | 53 +- gost/go.sum | 185 +-- gost/gost.go | 6 +- gost/quic.go | 11 +- gost/redirect.go | 1 + gost/redirect_other.go | 4 +- gost/selector.go | 91 ++ gost/selector_test.go | 24 + gost/signal.go | 1 + gost/snap/snapcraft.yaml | 4 +- gost/sockopts_linux.go | 2 +- gost/socks.go | 3 +- gost/ssh.go | 14 +- gost/tuntap_unix.go | 1 + .../package/lean/autocore/files/arm/index.htm | 8 +- lede/package/lean/default-settings/Makefile | 2 +- .../files/zzz-default-settings | 2 +- lede/package/qca/nss-firmware/Makefile | 75 ++ lede/package/qca/qca-mcs/Makefile | 67 + .../patches/0001-kernel-5.10-compat.patch | 40 + lede/package/qca/qca-nss-cfi/Makefile | 87 ++ ...yptoapi-v2.0-fix-SHA1-header-include.patch | 62 + ...ptoapi-v2.0-make-ablkcipher-optional.patch | 116 ++ ...emove-setting-crypto_ahash_type-for-.patch | 137 ++ ...ead-add-downstream-crypto_tfm_alg_fl.patch | 28 + ...-cryptoapi-v2.0-remove-dropped-flags.patch | 97 ++ ...6-cryptoapi-v2.0-convert-to-skcipher.patch | 1199 +++++++++++++++++ lede/package/qca/qca-nss-clients/Makefile | 624 +++++++++ .../qca/qca-nss-clients/files/qca-nss-ipsec | 231 ++++ .../qca-nss-clients/files/qca-nss-mirred.init | 28 + .../files/qca-nss-netlink.init | 31 + .../qca-nss-clients/files/qca-nss-ovpn.init | 69 + .../0001-kernel-5.15-support-qdisc.patch | 162 +++ .../patches/0002-kernel-5.4-support-gre.patch | 31 + .../0003-kernel-5.4-support-ipsec.patch | 29 + .../0004-kernel-5.4-support-dtls.patch | 11 + .../0005-vlanmgr-fix-compile-error.patch | 59 + .../0006-match-fix-compile-error.patch | 25 + .../0007-bridge-fix-compile-error.patch | 29 + .../0008-profiler-fix-compile-error.patch | 61 + .../patches/0009-gre-fix-compile-error.patch | 17 + .../patches/0010-fix-portifmgr.patch | 35 + ...lsmgr-fix-SHA-header-include-in-5.15.patch | 48 + ...0012-dtlsmgr-fix-debug-print-in-5.15.patch | 36 + ...lsmgr-fix-SHA-header-include-in-5.15.patch | 32 + ...pnmgr-fix-SHA-header-include-in-5.15.patch | 32 + ...5-tunipip6-fix-compile-error-in-5.15.patch | 11 + ...6-vxlanmgr-fix-compile-error-in-5.15.patch | 11 + .../0017-tlsmgr-fix-debug-print-in-5.15.patch | 34 + .../patches/0018-kernel-6.1-support.patch | 301 +++++ lede/package/qca/qca-nss-crypto/Makefile | 70 + ...1-nss-crypto-fix-SHA1-header-include.patch | 27 + ...replace-ioremap_nocache-with-ioremap.patch | 94 ++ ...rypto-fix-SHA-header-include-in-5.15.patch | 44 + lede/package/qca/qca-nss-drv/Config.in | 184 +++ lede/package/qca/qca-nss-drv/Makefile | 277 ++++ .../qca/qca-nss-drv/files/qca-nss-drv.conf | 6 + .../qca/qca-nss-drv/files/qca-nss-drv.debug | 26 + .../qca/qca-nss-drv/files/qca-nss-drv.hotplug | 70 + .../qca/qca-nss-drv/files/qca-nss-drv.init | 50 + .../qca/qca-nss-drv/files/qca-nss-drv.sysctl | 3 + ...replace-ioremap_nocache-with-ioremap.patch | 207 +++ ...-nss-drv-add-support-for-kernel-5.15.patch | 62 + ...0003-DMA-Fix-NULL-pointer-exceptions.patch | 28 + ...-rework-NSS_CORE_DMA_CACHE_MAINT-ops.patch | 558 ++++++++ ...ork-getting-the-reserved-memory-size.patch | 114 ++ ...ts-enum-int-compilation-error-GCC-13.patch | 11 + ...s_wifili_if-compilation-error-GCC-13.patch | 11 + .../patches/0008-Add-kernel-6.1-support.patch | 267 ++++ lede/package/qca/qca-nss-ecm/Makefile | 161 +++ .../files/disable_offloads.hotplug | 187 +++ .../qca/qca-nss-ecm/files/disable_offloads.sh | 189 +++ .../package/qca/qca-nss-ecm/files/ecm_dump.sh | 95 ++ .../qca/qca-nss-ecm/files/on-demand-down | 6 + .../qca-nss-ecm/files/qca-nss-ecm.defaults | 28 + .../qca-nss-ecm/files/qca-nss-ecm.firewall | 11 + .../qca/qca-nss-ecm/files/qca-nss-ecm.init | 137 ++ .../qca/qca-nss-ecm/files/qca-nss-ecm.sysctl | 1 + .../qca/qca-nss-ecm/files/qca-nss-ecm.uci | 8 + ...de-componentize-the-module-even-more.patch | 361 +++++ ...eewide-rework-ipv6_dev_find_and_hold.patch | 63 + ...olve-the-cpu-high-load-regarding-ecm.patch | 55 + ...se-of-static-be_liberal-and-no_windo.patch | 88 ++ ...tagram-drop-static-for-EXPORT_SYMBOL.patch | 50 + ...dp_get_timeouts-and-use-standard-ups.patch | 63 + ...-ppp-generic-function-calls-for-5.15.patch | 20 + ...reewide-export-ipv4-and-ipv6-symbols.patch | 99 ++ .../patches/1000-fix-miss-header.patch | 24 + ...-ecm-fix-a-memcpy-overflow-in-ecm_db.patch | 61 + lede/package/qca/qca-ssdk-shell/Makefile | 48 + ...al_port_cdt-compilation-error-GCC-13.patch | 10 + lede/target/linux/qualcommax/Makefile | 5 +- .../arm64/boot/dts/qcom/ipq6000-360v6.dts | 1 + .../arch/arm64/boot/dts/qcom/ipq6000-ax18.dts | 1 + .../arm64/boot/dts/qcom/ipq6000-glinet.dtsi | 1 + .../arm64/boot/dts/qcom/ipq6000-mr7350.dts | 1 + .../arm64/boot/dts/qcom/ipq6000-xiaomi.dtsi | 1 + .../include/dt-bindings/net/qcom-ipq-ess.h | 42 + .../netfilter/nf_conntrack_dscpremark_ext.h | 95 ++ .../include/uapi/linux/tc_act/tc_nss_mirred.h | 36 + .../netfilter/nf_conntrack_dscpremark_ext.c | 61 + lede/target/linux/qualcommax/image/ipq60xx.mk | 5 +- .../ipq60xx/base-files/lib/upgrade/mmc.sh | 83 ++ .../base-files/lib/upgrade/platform.sh | 11 +- .../target/linux/qualcommax/ipq60xx/target.mk | 2 +- .../0600-1-qca-nss-ecm-support-CORE.patch | 785 +++++++++++ ...-2-qca-nss-ecm-support-PPPOE-offload.patch | 590 ++++++++ ...00-3-qca-nss-ecm-support-net-bonding.patch | 81 ++ ...pport-net-bonding-over-LAG-interface.patch | 672 +++++++++ .../0600-5-qca-nss-ecm-support-macvlan.patch | 96 ++ ...nss-ecm-support-netfilter-DSCPREMARK.patch | 69 + ...-qca-nss-ecm-add-missing-net-defines.patch | 35 + ...00-8-qca-nss-ecm-support-MLO-bonding.patch | 536 ++++++++ .../0601-qca-add-nss-bridge-mgr-support.patch | 94 ++ .../0602-qca-nss-drv-add-qdisc-support.patch | 44 + ...-1-qca-nss-clients-add-qdisc-support.patch | 441 ++++++ ...3-2-qca-nss-clients-add-l2tp-support.patch | 46 + ...3-3-qca-nss-clients-add-PPTP-support.patch | 478 +++++++ ...qca-nss-clients-add-iptunnel-support.patch | 77 ++ ...-5-qca-nss-clients-add-vxlan-support.patch | 107 ++ ...-clients-add-l2tp-offloading-support.patch | 368 +++++ ...a-nss-clients-iptunnel-lock-this-cpu.patch | 22 + ...-qca-nss-clients-add-tls-mgr-support.patch | 24 + .../0605-qca-nss-cfi-support.patch | 111 ++ ...l-pointer-dereference-in-ipv6-output.patch | 80 ++ mieru/go.mod | 13 +- mieru/go.sum | 31 +- mihomo/dns/dialer.go | 12 + mihomo/{dns/dial.go => tunnel/dns_dialer.go} | 33 +- mihomo/tunnel/tunnel.go | 103 +- openwrt-packages/ddns-go/Makefile | 4 +- .../luci-app-ikoolproxy/README.md | 2 +- shadowsocks-rust/snap/snapcraft.yaml | 4 +- small/v2ray-geodata/Makefile | 4 +- yass/.github/workflows/releases-deb.yml | 131 +- yass/.github/workflows/releases-rpm.yml | 62 +- yass/.github/workflows/releases-src.yml | 2 +- yass/PACKAGING.md | 16 +- yass/README.md | 12 +- yass/debian/changelog | 8 +- yass/docker/centos9.Dockerfile | 3 +- yass/docker/fedora39.Dockerfile | 10 +- yass/docker/opensuse15.Dockerfile | 3 +- yass/scripts/build-deb.sh | 16 +- yass/scripts/build-rpm.sh | 18 +- yass/yass.spec.in | 49 +- 280 files changed, 14579 insertions(+), 9845 deletions(-) create mode 100644 clash-meta/dns/dialer.go rename clash-meta/{dns/dial.go => tunnel/dns_dialer.go} (77%) delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/assets/styles/page.scss create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/app/app-container.module.scss create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/app/app-container.module.scss.d.ts create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/app/app-container.tsx create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/app/app-drawer.tsx create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/app/locales-provider.tsx create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/app/modules/route-list-item.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/base/base-dialog.module.scss delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/base/base-dialog.module.scss.d.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/base/base-dialog.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/base/base-loading.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/base/base-page.tsx create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/base/content-display.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/common/kbd.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/common/mdy-switch.scss delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/common/mdy-switch.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/connection/connection-detail.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/connection/connection-item.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/connection/connection-table.tsx create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/layout/animated-logo.module.scss create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/layout/animated-logo.module.scss.d.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/layout/layout-item.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/layout/layout-traffic.tsx create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/layout/notice-provider.tsx create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/layout/scheme-provider.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/layout/traffic-graph.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/layout/update-button.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/layout/use-log-setup.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/log/log-item.module.scss delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/log/log-item.module.scss.d.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/log/log-item.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/profile/editor-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/profile/file-input.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/profile/log-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-box.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-item.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-more.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-viewer.tsx create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxies/delay-chip.tsx create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxies/feature-chip.tsx create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxies/node-card.tsx create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxies/proxy-group-name.tsx create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxies/sort-selector.tsx create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxies/utils.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxy/provider-button.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-group.module.scss delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-group.module.scss.d.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-groups.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-head.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-item-mini.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-item.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-render.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-filter-sort.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-head-state.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-render-list.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-window-width.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/rule/rule-item.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/clash-core-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/clash-field-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/clash-port-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/config-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/controller-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/guard-state.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/hotkey-input.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/hotkey-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/layout-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/misc-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/service-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/setting-comp.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/sysproxy-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/tasks-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/theme-mode-switch.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/theme-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/update-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/web-ui-item.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/web-ui-viewer.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-clash.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-legacy.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-system.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-verge.tsx delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/services/api.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/services/cmds.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/services/delay.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/utils/clash-fields.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/utils/noop.ts create mode 100644 clash-nyanpasu/frontend/nyanpasu/src/utils/routes-utils.ts delete mode 100644 clash-nyanpasu/frontend/nyanpasu/src/utils/truncate-str.ts delete mode 100644 clash-verge-rev/src-tauri/src/core/manager.rs create mode 100644 lede/package/qca/nss-firmware/Makefile create mode 100644 lede/package/qca/qca-mcs/Makefile create mode 100644 lede/package/qca/qca-mcs/patches/0001-kernel-5.10-compat.patch create mode 100644 lede/package/qca/qca-nss-cfi/Makefile create mode 100644 lede/package/qca/qca-nss-cfi/patches/0001-cryptoapi-v2.0-fix-SHA1-header-include.patch create mode 100644 lede/package/qca/qca-nss-cfi/patches/0002-cryptoapi-v2.0-make-ablkcipher-optional.patch create mode 100644 lede/package/qca/qca-nss-cfi/patches/0003-cryptoapi-v2.0-remove-setting-crypto_ahash_type-for-.patch create mode 100644 lede/package/qca/qca-nss-cfi/patches/0004-cryptoapi-v2.0-aead-add-downstream-crypto_tfm_alg_fl.patch create mode 100644 lede/package/qca/qca-nss-cfi/patches/0005-cryptoapi-v2.0-remove-dropped-flags.patch create mode 100644 lede/package/qca/qca-nss-cfi/patches/0006-cryptoapi-v2.0-convert-to-skcipher.patch create mode 100644 lede/package/qca/qca-nss-clients/Makefile create mode 100755 lede/package/qca/qca-nss-clients/files/qca-nss-ipsec create mode 100644 lede/package/qca/qca-nss-clients/files/qca-nss-mirred.init create mode 100644 lede/package/qca/qca-nss-clients/files/qca-nss-netlink.init create mode 100644 lede/package/qca/qca-nss-clients/files/qca-nss-ovpn.init create mode 100644 lede/package/qca/qca-nss-clients/patches/0001-kernel-5.15-support-qdisc.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0002-kernel-5.4-support-gre.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0003-kernel-5.4-support-ipsec.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0004-kernel-5.4-support-dtls.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0005-vlanmgr-fix-compile-error.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0006-match-fix-compile-error.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0007-bridge-fix-compile-error.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0008-profiler-fix-compile-error.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0009-gre-fix-compile-error.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0010-fix-portifmgr.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0011-dtlsmgr-fix-SHA-header-include-in-5.15.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0012-dtlsmgr-fix-debug-print-in-5.15.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0013-tlsmgr-fix-SHA-header-include-in-5.15.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0014-ovpnmgr-fix-SHA-header-include-in-5.15.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0015-tunipip6-fix-compile-error-in-5.15.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0016-vxlanmgr-fix-compile-error-in-5.15.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0017-tlsmgr-fix-debug-print-in-5.15.patch create mode 100644 lede/package/qca/qca-nss-clients/patches/0018-kernel-6.1-support.patch create mode 100644 lede/package/qca/qca-nss-crypto/Makefile create mode 100644 lede/package/qca/qca-nss-crypto/patches/0001-nss-crypto-fix-SHA1-header-include.patch create mode 100644 lede/package/qca/qca-nss-crypto/patches/0002-nss-crypto-replace-ioremap_nocache-with-ioremap.patch create mode 100644 lede/package/qca/qca-nss-crypto/patches/0003-nss-crypto-fix-SHA-header-include-in-5.15.patch create mode 100644 lede/package/qca/qca-nss-drv/Config.in create mode 100644 lede/package/qca/qca-nss-drv/Makefile create mode 100644 lede/package/qca/qca-nss-drv/files/qca-nss-drv.conf create mode 100644 lede/package/qca/qca-nss-drv/files/qca-nss-drv.debug create mode 100644 lede/package/qca/qca-nss-drv/files/qca-nss-drv.hotplug create mode 100644 lede/package/qca/qca-nss-drv/files/qca-nss-drv.init create mode 100644 lede/package/qca/qca-nss-drv/files/qca-nss-drv.sysctl create mode 100644 lede/package/qca/qca-nss-drv/patches/0001-nss-drv-replace-ioremap_nocache-with-ioremap.patch create mode 100644 lede/package/qca/qca-nss-drv/patches/0002-nss-drv-add-support-for-kernel-5.15.patch create mode 100644 lede/package/qca/qca-nss-drv/patches/0003-DMA-Fix-NULL-pointer-exceptions.patch create mode 100644 lede/package/qca/qca-nss-drv/patches/0004-nss-drv-rework-NSS_CORE_DMA_CACHE_MAINT-ops.patch create mode 100644 lede/package/qca/qca-nss-drv/patches/0005-nss-drv-rework-getting-the-reserved-memory-size.patch create mode 100644 lede/package/qca/qca-nss-drv/patches/0006-nss-drv-Fix-nss_clmap_stats-enum-int-compilation-error-GCC-13.patch create mode 100644 lede/package/qca/qca-nss-drv/patches/0007-nss-drv-Fix-nss_wifili_if-compilation-error-GCC-13.patch create mode 100644 lede/package/qca/qca-nss-drv/patches/0008-Add-kernel-6.1-support.patch create mode 100644 lede/package/qca/qca-nss-ecm/Makefile create mode 100755 lede/package/qca/qca-nss-ecm/files/disable_offloads.hotplug create mode 100755 lede/package/qca/qca-nss-ecm/files/disable_offloads.sh create mode 100755 lede/package/qca/qca-nss-ecm/files/ecm_dump.sh create mode 100644 lede/package/qca/qca-nss-ecm/files/on-demand-down create mode 100644 lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.defaults create mode 100644 lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.firewall create mode 100644 lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.init create mode 100644 lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.sysctl create mode 100644 lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.uci create mode 100644 lede/package/qca/qca-nss-ecm/patches/0001-treewide-componentize-the-module-even-more.patch create mode 100644 lede/package/qca/qca-nss-ecm/patches/0002-treewide-rework-ipv6_dev_find_and_hold.patch create mode 100644 lede/package/qca/qca-nss-ecm/patches/0003-qca-nss-ecm-resolve-the-cpu-high-load-regarding-ecm.patch create mode 100644 lede/package/qca/qca-nss-ecm/patches/0005-frontends-drop-use-of-static-be_liberal-and-no_windo.patch create mode 100644 lede/package/qca/qca-nss-ecm/patches/0006-ecm_tracker_datagram-drop-static-for-EXPORT_SYMBOL.patch create mode 100644 lede/package/qca/qca-nss-ecm/patches/0007-frontends-drop-udp_get_timeouts-and-use-standard-ups.patch create mode 100644 lede/package/qca/qca-nss-ecm/patches/0008-ecm_interface-fix-ppp-generic-function-calls-for-5.15.patch create mode 100644 lede/package/qca/qca-nss-ecm/patches/0009-treewide-export-ipv4-and-ipv6-symbols.patch create mode 100644 lede/package/qca/qca-nss-ecm/patches/1000-fix-miss-header.patch create mode 100644 lede/package/qca/qca-nss-ecm/patches/900-qca-nss-ecm-fix-a-memcpy-overflow-in-ecm_db.patch create mode 100644 lede/package/qca/qca-ssdk-shell/Makefile create mode 100644 lede/package/qca/qca-ssdk-shell/patches/0001-qca-ssdk-shell-Fix-fal_port_cdt-compilation-error-GCC-13.patch create mode 100644 lede/target/linux/qualcommax/files/include/dt-bindings/net/qcom-ipq-ess.h create mode 100644 lede/target/linux/qualcommax/files/include/net/netfilter/nf_conntrack_dscpremark_ext.h create mode 100644 lede/target/linux/qualcommax/files/include/uapi/linux/tc_act/tc_nss_mirred.h create mode 100644 lede/target/linux/qualcommax/files/net/netfilter/nf_conntrack_dscpremark_ext.c create mode 100644 lede/target/linux/qualcommax/ipq60xx/base-files/lib/upgrade/mmc.sh create mode 100644 lede/target/linux/qualcommax/patches-6.1/0600-1-qca-nss-ecm-support-CORE.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0600-2-qca-nss-ecm-support-PPPOE-offload.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0600-3-qca-nss-ecm-support-net-bonding.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0600-4-qca-nss-ecm-support-net-bonding-over-LAG-interface.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0600-5-qca-nss-ecm-support-macvlan.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0600-6-qca-nss-ecm-support-netfilter-DSCPREMARK.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0600-7-qca-nss-ecm-add-missing-net-defines.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0600-8-qca-nss-ecm-support-MLO-bonding.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0601-qca-add-nss-bridge-mgr-support.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0602-qca-nss-drv-add-qdisc-support.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0603-1-qca-nss-clients-add-qdisc-support.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0603-2-qca-nss-clients-add-l2tp-support.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0603-3-qca-nss-clients-add-PPTP-support.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0603-4-qca-nss-clients-add-iptunnel-support.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0603-5-qca-nss-clients-add-vxlan-support.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0603-6-qca-nss-clients-add-l2tp-offloading-support.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0603-7-qca-nss-clients-iptunnel-lock-this-cpu.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0603-8-qca-nss-clients-add-tls-mgr-support.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0605-qca-nss-cfi-support.patch create mode 100644 lede/target/linux/qualcommax/patches-6.1/0611-ipv6-Fix-null-pointer-dereference-in-ipv6-output.patch create mode 100644 mihomo/dns/dialer.go rename mihomo/{dns/dial.go => tunnel/dns_dialer.go} (77%) diff --git a/.github/update.log b/.github/update.log index 36dc2d5744..44fe9a2c83 100644 --- a/.github/update.log +++ b/.github/update.log @@ -671,3 +671,4 @@ Update On Sun Jun 9 20:29:25 CEST 2024 Update On Mon Jun 10 20:32:26 CEST 2024 Update On Tue Jun 11 20:31:29 CEST 2024 Update On Wed Jun 12 20:32:18 CEST 2024 +Update On Thu Jun 13 20:31:26 CEST 2024 diff --git a/clash-meta/dns/dialer.go b/clash-meta/dns/dialer.go new file mode 100644 index 0000000000..309b6c1886 --- /dev/null +++ b/clash-meta/dns/dialer.go @@ -0,0 +1,12 @@ +package dns + +// export functions from tunnel module + +import "github.com/metacubex/mihomo/tunnel" + +const RespectRules = tunnel.DnsRespectRules + +type dialHandler = tunnel.DnsDialHandler + +var getDialHandler = tunnel.GetDnsDialHandler +var listenPacket = tunnel.DnsListenPacket diff --git a/clash-meta/dns/dial.go b/clash-meta/tunnel/dns_dialer.go similarity index 77% rename from clash-meta/dns/dial.go rename to clash-meta/tunnel/dns_dialer.go index 431707c56f..f4c0be7139 100644 --- a/clash-meta/dns/dial.go +++ b/clash-meta/tunnel/dns_dialer.go @@ -1,4 +1,6 @@ -package dns +package tunnel + +// WARNING: all function in this file should only be using in dns module import ( "context" @@ -11,15 +13,14 @@ import ( "github.com/metacubex/mihomo/component/dialer" "github.com/metacubex/mihomo/component/resolver" C "github.com/metacubex/mihomo/constant" - "github.com/metacubex/mihomo/tunnel" "github.com/metacubex/mihomo/tunnel/statistic" ) -const RespectRules = "RULES" +const DnsRespectRules = "RULES" -type dialHandler func(ctx context.Context, network, addr string) (net.Conn, error) +type DnsDialHandler func(ctx context.Context, network, addr string) (net.Conn, error) -func getDialHandler(r *Resolver, proxyAdapter C.ProxyAdapter, proxyName string, opts ...dialer.Option) dialHandler { +func GetDnsDialHandler(r resolver.Resolver, proxyAdapter C.ProxyAdapter, proxyName string, opts ...dialer.Option) DnsDialHandler { return func(ctx context.Context, network, addr string) (net.Conn, error) { if len(proxyName) == 0 && proxyAdapter == nil { opts = append(opts, dialer.WithResolver(r)) @@ -47,22 +48,22 @@ func getDialHandler(r *Resolver, proxyAdapter C.ProxyAdapter, proxyName string, var rule C.Rule if proxyAdapter == nil { - if proxyName == RespectRules { + if proxyName == DnsRespectRules { if !metadata.Resolved() { - // resolve here before ResolveMetadata to avoid its inner resolver.ResolveIP + // resolve here before resolveMetadata to avoid its inner resolver.ResolveIP dstIP, err := resolver.ResolveIPWithResolver(ctx, metadata.Host, r) if err != nil { return nil, err } metadata.DstIP = dstIP } - proxyAdapter, rule, err = tunnel.ResolveMetadata(metadata) + proxyAdapter, rule, err = resolveMetadata(metadata) if err != nil { return nil, err } } else { var ok bool - proxyAdapter, ok = tunnel.Proxies()[proxyName] + proxyAdapter, ok = Proxies()[proxyName] if !ok { opts = append(opts, dialer.WithInterface(proxyName)) } @@ -88,8 +89,10 @@ func getDialHandler(r *Resolver, proxyAdapter C.ProxyAdapter, proxyName string, conn, err := proxyAdapter.DialContext(ctx, metadata, opts...) if err != nil { + logMetadataErr(metadata, rule, proxyAdapter, err) return nil, err } + logMetadata(metadata, rule, conn) conn = statistic.NewTCPTracker(conn, statistic.DefaultManager, metadata, rule, 0, 0, false) @@ -105,8 +108,10 @@ func getDialHandler(r *Resolver, proxyAdapter C.ProxyAdapter, proxyName string, packetConn, err := proxyAdapter.ListenPacketContext(ctx, metadata, opts...) if err != nil { + logMetadataErr(metadata, rule, proxyAdapter, err) return nil, err } + logMetadata(metadata, rule, packetConn) packetConn = statistic.NewUDPTracker(packetConn, statistic.DefaultManager, metadata, rule, 0, 0, false) @@ -116,7 +121,7 @@ func getDialHandler(r *Resolver, proxyAdapter C.ProxyAdapter, proxyName string, } } -func listenPacket(ctx context.Context, proxyAdapter C.ProxyAdapter, proxyName string, network string, addr string, r *Resolver, opts ...dialer.Option) (net.PacketConn, error) { +func DnsListenPacket(ctx context.Context, proxyAdapter C.ProxyAdapter, proxyName string, network string, addr string, r resolver.Resolver, opts ...dialer.Option) (net.PacketConn, error) { metadata := &C.Metadata{ NetWork: C.UDP, Type: C.INNER, @@ -136,14 +141,14 @@ func listenPacket(ctx context.Context, proxyAdapter C.ProxyAdapter, proxyName st var rule C.Rule if proxyAdapter == nil { - if proxyName == RespectRules { - proxyAdapter, rule, err = tunnel.ResolveMetadata(metadata) + if proxyName == DnsRespectRules { + proxyAdapter, rule, err = resolveMetadata(metadata) if err != nil { return nil, err } } else { var ok bool - proxyAdapter, ok = tunnel.Proxies()[proxyName] + proxyAdapter, ok = Proxies()[proxyName] if !ok { opts = append(opts, dialer.WithInterface(proxyName)) } @@ -160,8 +165,10 @@ func listenPacket(ctx context.Context, proxyAdapter C.ProxyAdapter, proxyName st packetConn, err := proxyAdapter.ListenPacketContext(ctx, metadata, opts...) if err != nil { + logMetadataErr(metadata, rule, proxyAdapter, err) return nil, err } + logMetadata(metadata, rule, packetConn) packetConn = statistic.NewUDPTracker(packetConn, statistic.DefaultManager, metadata, rule, 0, 0, false) diff --git a/clash-meta/tunnel/tunnel.go b/clash-meta/tunnel/tunnel.go index 78628a5687..2c1b894f9d 100644 --- a/clash-meta/tunnel/tunnel.go +++ b/clash-meta/tunnel/tunnel.go @@ -8,6 +8,7 @@ import ( "net/netip" "path/filepath" "runtime" + "strings" "sync" "time" @@ -278,7 +279,7 @@ func preHandleMetadata(metadata *C.Metadata) error { return nil } -func ResolveMetadata(metadata *C.Metadata) (proxy C.Proxy, rule C.Rule, err error) { +func resolveMetadata(metadata *C.Metadata) (proxy C.Proxy, rule C.Rule, err error) { if metadata.SpecialProxy != "" { var exist bool proxy, exist = proxies[metadata.SpecialProxy] @@ -375,7 +376,7 @@ func handleUDPConn(packet C.PacketAdapter) { cond.Broadcast() }() - proxy, rule, err := ResolveMetadata(metadata) + proxy, rule, err := resolveMetadata(metadata) if err != nil { log.Warnln("[UDP] Parse metadata failed: %s", err.Error()) return @@ -386,43 +387,18 @@ func handleUDPConn(packet C.PacketAdapter) { rawPc, err := retry(ctx, func(ctx context.Context) (C.PacketConn, error) { return proxy.ListenPacketContext(ctx, metadata.Pure()) }, func(err error) { - if rule == nil { - log.Warnln( - "[UDP] dial %s %s --> %s error: %s", - proxy.Name(), - metadata.SourceDetail(), - metadata.RemoteAddress(), - err.Error(), - ) - } else { - log.Warnln("[UDP] dial %s (match %s/%s) %s --> %s error: %s", proxy.Name(), rule.RuleType().String(), rule.Payload(), metadata.SourceDetail(), metadata.RemoteAddress(), err.Error()) - } + logMetadataErr(metadata, rule, proxy, err) }) if err != nil { return } + logMetadata(metadata, rule, rawPc) pc := statistic.NewUDPTracker(rawPc, statistic.DefaultManager, metadata, rule, 0, 0, true) - switch true { - case metadata.SpecialProxy != "": - log.Infoln("[UDP] %s --> %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), metadata.SpecialProxy) - case rule != nil: - if rule.Payload() != "" { - log.Infoln("[UDP] %s --> %s match %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), fmt.Sprintf("%s(%s)", rule.RuleType().String(), rule.Payload()), rawPc.Chains().String()) - if rawPc.Chains().Last() == "REJECT-DROP" { - pc.Close() - return - } - } else { - log.Infoln("[UDP] %s --> %s match %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), rule.Payload(), rawPc.Chains().String()) - } - case mode == Global: - log.Infoln("[UDP] %s --> %s using GLOBAL", metadata.SourceDetail(), metadata.RemoteAddress()) - case mode == Direct: - log.Infoln("[UDP] %s --> %s using DIRECT", metadata.SourceDetail(), metadata.RemoteAddress()) - default: - log.Infoln("[UDP] %s --> %s doesn't match any rule using DIRECT", metadata.SourceDetail(), metadata.RemoteAddress()) + if rawPc.Chains().Last() == "REJECT-DROP" { + pc.Close() + return } oAddrPort := metadata.AddrPort() @@ -486,7 +462,7 @@ func handleTCPConn(connCtx C.ConnContext) { }() } - proxy, rule, err := ResolveMetadata(metadata) + proxy, rule, err := resolveMetadata(metadata) if err != nil { log.Warnln("[Metadata] parse failed: %s", err.Error()) return @@ -539,48 +515,18 @@ func handleTCPConn(connCtx C.ConnContext) { } return }, func(err error) { - if rule == nil { - log.Warnln( - "[TCP] dial %s %s --> %s error: %s", - proxy.Name(), - metadata.SourceDetail(), - metadata.RemoteAddress(), - err.Error(), - ) - } else { - log.Warnln("[TCP] dial %s (match %s/%s) %s --> %s error: %s", proxy.Name(), rule.RuleType().String(), rule.Payload(), metadata.SourceDetail(), metadata.RemoteAddress(), err.Error()) - } + logMetadataErr(metadata, rule, proxy, err) }) if err != nil { return } + logMetadata(metadata, rule, remoteConn) remoteConn = statistic.NewTCPTracker(remoteConn, statistic.DefaultManager, metadata, rule, 0, int64(peekLen), true) defer func(remoteConn C.Conn) { _ = remoteConn.Close() }(remoteConn) - switch true { - case metadata.SpecialProxy != "": - log.Infoln("[TCP] %s --> %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), metadata.SpecialProxy) - case rule != nil: - if rule.Payload() != "" { - log.Infoln("[TCP] %s --> %s match %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), fmt.Sprintf("%s(%s)", rule.RuleType().String(), rule.Payload()), remoteConn.Chains().String()) - } else { - log.Infoln("[TCP] %s --> %s match %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), rule.RuleType().String(), remoteConn.Chains().String()) - } - case mode == Global: - log.Infoln("[TCP] %s --> %s using GLOBAL", metadata.SourceDetail(), metadata.RemoteAddress()) - case mode == Direct: - log.Infoln("[TCP] %s --> %s using DIRECT", metadata.SourceDetail(), metadata.RemoteAddress()) - default: - log.Infoln( - "[TCP] %s --> %s doesn't match any rule using DIRECT", - metadata.SourceDetail(), - metadata.RemoteAddress(), - ) - } - _ = conn.SetReadDeadline(time.Now()) // stop unfinished peek peekMutex.Lock() defer peekMutex.Unlock() @@ -588,6 +534,33 @@ func handleTCPConn(connCtx C.ConnContext) { handleSocket(conn, remoteConn) } +func logMetadataErr(metadata *C.Metadata, rule C.Rule, proxy C.ProxyAdapter, err error) { + if rule == nil { + log.Warnln("[%s] dial %s %s --> %s error: %s", strings.ToUpper(metadata.NetWork.String()), proxy.Name(), metadata.SourceDetail(), metadata.RemoteAddress(), err.Error()) + } else { + log.Warnln("[%s] dial %s (match %s/%s) %s --> %s error: %s", strings.ToUpper(metadata.NetWork.String()), proxy.Name(), rule.RuleType().String(), rule.Payload(), metadata.SourceDetail(), metadata.RemoteAddress(), err.Error()) + } +} + +func logMetadata(metadata *C.Metadata, rule C.Rule, remoteConn C.Connection) { + switch { + case metadata.SpecialProxy != "": + log.Infoln("[%s] %s --> %s using %s", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress(), metadata.SpecialProxy) + case rule != nil: + if rule.Payload() != "" { + log.Infoln("[%s] %s --> %s match %s using %s", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress(), fmt.Sprintf("%s(%s)", rule.RuleType().String(), rule.Payload()), remoteConn.Chains().String()) + } else { + log.Infoln("[%s] %s --> %s match %s using %s", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress(), rule.RuleType().String(), remoteConn.Chains().String()) + } + case mode == Global: + log.Infoln("[%s] %s --> %s using GLOBAL", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress()) + case mode == Direct: + log.Infoln("[%s] %s --> %s using DIRECT", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress()) + default: + log.Infoln("[%s] %s --> %s doesn't match any rule using %s", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress(), remoteConn.Chains().Last()) + } +} + func shouldResolveIP(rule C.Rule, metadata *C.Metadata) bool { return rule.ShouldResolveIP() && metadata.Host != "" && !metadata.DstIP.IsValid() } diff --git a/clash-nyanpasu/backend/tauri/src/config/nyanpasu/mod.rs b/clash-nyanpasu/backend/tauri/src/config/nyanpasu/mod.rs index 54c97d52b2..5c3060deff 100644 --- a/clash-nyanpasu/backend/tauri/src/config/nyanpasu/mod.rs +++ b/clash-nyanpasu/backend/tauri/src/config/nyanpasu/mod.rs @@ -78,8 +78,8 @@ pub struct IVerge { /// show memory info (only for Clash Meta) pub enable_memory_usage: Option, - /// page transition animation, default is `slide` - pub page_transition_animation: Option, + /// global ui framer motion effects + pub lighten_animation_effects: Option, /// clash tun mode pub enable_tun_mode: Option, @@ -219,6 +219,10 @@ impl IVerge { config.max_log_files = template.max_log_files; } + if config.lighten_animation_effects.is_none() { + config.lighten_animation_effects = template.lighten_animation_effects; + } + config } @@ -244,7 +248,7 @@ impl IVerge { auto_close_connection: Some(true), enable_builtin_enhanced: Some(true), enable_clash_fields: Some(true), - page_transition_animation: Some("slide".into()), + lighten_animation_effects: Some(false), // auto_log_clean: Some(60 * 24 * 7), // 7 days 自动清理日记 max_log_files: Some(7), // 7 days enable_auto_check_update: Some(true), @@ -275,7 +279,7 @@ impl IVerge { patch!(theme_blur); patch!(traffic_graph); patch!(enable_memory_usage); - patch!(page_transition_animation); + patch!(lighten_animation_effects); patch!(enable_auto_check_update); patch!(enable_tun_mode); diff --git a/clash-nyanpasu/backend/tauri/src/main.rs b/clash-nyanpasu/backend/tauri/src/main.rs index b6e538c7e8..0c6856c361 100644 --- a/clash-nyanpasu/backend/tauri/src/main.rs +++ b/clash-nyanpasu/backend/tauri/src/main.rs @@ -50,11 +50,11 @@ fn main() -> std::io::Result<()> { commands::parse().unwrap(); // Should be in first place in order prevent single instance check block everything - tauri_plugin_deep_link::prepare(if cfg!(feature = "verge-dev") { - "moe.elaina.clash.nyanpasu.dev" - } else { - "moe.elaina.clash.nyanpasu" - }); + #[cfg(feature = "verge-dev")] + tauri_plugin_deep_link::prepare("moe.elaina.clash.nyanpasu.dev"); + + #[cfg(not(feature = "verge-dev"))] + tauri_plugin_deep_link::prepare("moe.elaina.clash.nyanpasu"); // 单例检测 let single_instance_result = utils::init::check_singleton(); diff --git a/clash-nyanpasu/frontend/interface/service/tauri.ts b/clash-nyanpasu/frontend/interface/service/tauri.ts index 14eac819d1..23658264cb 100644 --- a/clash-nyanpasu/frontend/interface/service/tauri.ts +++ b/clash-nyanpasu/frontend/interface/service/tauri.ts @@ -182,3 +182,7 @@ export const selectProxy = async (group: string, name: string) => { export const updateProxyProvider = async (name: string) => { return await invoke("update_proxy_provider", { name }); }; + +export const save_window_size_state = async () => { + return await invoke("save_window_size_state"); +}; diff --git a/clash-nyanpasu/frontend/interface/service/types.ts b/clash-nyanpasu/frontend/interface/service/types.ts index 9a8cbe429b..a3bcf2b7cd 100644 --- a/clash-nyanpasu/frontend/interface/service/types.ts +++ b/clash-nyanpasu/frontend/interface/service/types.ts @@ -8,7 +8,7 @@ export interface VergeConfig { theme_blur?: boolean; traffic_graph?: boolean; enable_memory_usage?: boolean; - page_transition_animation?: string; + lighten_animation_effects?: boolean; enable_auto_check_update?: boolean; enable_tun_mode?: boolean; enable_auto_launch?: boolean; diff --git a/clash-nyanpasu/frontend/nyanpasu/package.json b/clash-nyanpasu/frontend/nyanpasu/package.json index 7722eddc42..d5be09e786 100644 --- a/clash-nyanpasu/frontend/nyanpasu/package.json +++ b/clash-nyanpasu/frontend/nyanpasu/package.json @@ -16,9 +16,9 @@ "@generouted/react-router": "1.19.5", "@juggle/resize-observer": "3.4.0", "@material/material-color-utilities": "0.2.7", - "@mui/icons-material": "5.15.19", + "@mui/icons-material": "5.15.20", "@mui/lab": "5.0.0-alpha.170", - "@mui/material": "5.15.19", + "@mui/material": "5.15.20", "@mui/x-data-grid": "7.6.2", "@nyanpasu/interface": "workspace:^", "@nyanpasu/ui": "workspace:^", @@ -58,7 +58,7 @@ "@vitejs/plugin-react": "4.3.1", "sass": "1.77.5", "shiki": "1.6.4", - "vite": "5.2.13", + "vite": "5.3.0", "vite-plugin-monaco-editor": "1.1.3", "vite-plugin-sass-dts": "1.3.22", "vite-plugin-svgr": "4.2.0", diff --git a/clash-nyanpasu/frontend/nyanpasu/src/assets/styles/index.scss b/clash-nyanpasu/frontend/nyanpasu/src/assets/styles/index.scss index 322ad9133c..7b5f1c1bd6 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/assets/styles/index.scss +++ b/clash-nyanpasu/frontend/nyanpasu/src/assets/styles/index.scss @@ -1,5 +1,4 @@ @import "./layout.scss"; -@import "./page.scss"; @import "./fonts.scss"; body { diff --git a/clash-nyanpasu/frontend/nyanpasu/src/assets/styles/layout.scss b/clash-nyanpasu/frontend/nyanpasu/src/assets/styles/layout.scss index bfc207f791..54e5c9479e 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/assets/styles/layout.scss +++ b/clash-nyanpasu/frontend/nyanpasu/src/assets/styles/layout.scss @@ -1,121 +1,9 @@ -.layout { - display: flex; - width: 100%; - height: 100vh; - overflow: hidden; - - &__left { - position: relative; - box-sizing: border-box; - display: flex; - flex: 1 0 25%; - flex-direction: column; - min-width: 125px; - max-width: 225px; - height: 100%; - padding: 36px 0 28px; - overflow: hidden; - user-select: none; - background-color: var(--background-color-alpha); - - $maxLogo: 100px; - - .the-logo { - position: relative; - box-sizing: border-box; - flex: 0 1 $maxLogo; - width: 100%; - max-width: $maxLogo + 32px; - max-height: $maxLogo; - padding: 0 16px; - margin: 0 auto; - text-align: center; - - img, - svg { - width: 100%; - height: 100%; - pointer-events: none; - fill: var(--primary-main); - - #bg { - fill: var(--background-color); - } - } - - .the-newbtn { - position: absolute; - right: 10px; - bottom: 0; - transform: scale(0.8); - } - } - - .the-menu { - flex: 1 1 80%; - margin-bottom: 8px; - overflow-y: auto; - } - - .the-traffic { - flex: 0 0 60px; - - > div { - margin: 0 auto; - } - } - } - - &__right { - position: relative; - flex: 1 1 75%; - height: 100%; - background-color: var(--background-color-alpha); - - .the-bar { - position: absolute; - top: 8px; - right: 28px; - z-index: 2; - } - - .the-content { - position: absolute; - inset: 0 28px 28px 0; - } - - .drag-mask { - height: 38px; - } - } +.the-content { + position: absolute; + inset: 36px calc(var(--border-radius) * 2) calc(var(--border-radius) * 2) 0; } -.linux, -.windows, -.unknown { - &.layout { - $maxLogo: 115px; - - .layout__left .the-logo { - flex: 0 1 $maxLogo; - max-width: $maxLogo + 32px; - max-height: $maxLogo; - } - - .layout__right .the-content { - top: 30px; - } - } -} - -.macos { - &.layout { - .layout__left { - padding-top: 24px; - } - - .layout__right .the-content { - top: 20px; - } - } +.the-content-small { + position: absolute; + inset: 36px calc(var(--border-radius) * 2) calc(var(--border-radius) * 2); } diff --git a/clash-nyanpasu/frontend/nyanpasu/src/assets/styles/page.scss b/clash-nyanpasu/frontend/nyanpasu/src/assets/styles/page.scss deleted file mode 100644 index e86c5558c0..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/assets/styles/page.scss +++ /dev/null @@ -1,52 +0,0 @@ -.base-page { - display: flex; - flex-direction: column; - width: 100%; - height: 100%; - - > header { - box-sizing: border-box; - display: flex; - flex: 0 0 58px; - align-items: center; - justify-content: space-between; - width: 100%; - padding-right: 4px; - // max-width: 850px; - margin: 0 auto; - } - - .base-container { - height: 100%; - overflow: hidden; - border-radius: var(--border-radius); - - > section { - position: relative; - box-sizing: border-box; - flex: 1 1 100%; - width: 100%; - height: 100%; - padding: 28px 0; - overflow: auto; - background-color: var(--background-color); - scrollbar-gutter: stable; - - .base-content { - width: calc(100% - 28px * 2); - margin: 0 auto; - } - } - - &.no-padding { - > section { - padding: 0; - overflow: visible; - - .base-content { - width: 100%; - } - } - } - } -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/app/app-container.module.scss b/clash-nyanpasu/frontend/nyanpasu/src/components/app/app-container.module.scss new file mode 100644 index 0000000000..6c04a94202 --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/app/app-container.module.scss @@ -0,0 +1,14 @@ +.layout { + display: flex; + width: 100%; + height: 100vh; + overflow: hidden; + background-color: var(--background-color); + + .container { + position: relative; + flex: 1 1 75%; + height: 100%; + background-color: var(--background-color-alpha); + } +} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/app/app-container.module.scss.d.ts b/clash-nyanpasu/frontend/nyanpasu/src/components/app/app-container.module.scss.d.ts new file mode 100644 index 0000000000..1f1eda8994 --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/app/app-container.module.scss.d.ts @@ -0,0 +1,5 @@ +declare const classNames: { + readonly layout: "layout"; + readonly container: "container"; +}; +export default classNames; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/app/app-container.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/app/app-container.tsx new file mode 100644 index 0000000000..4bd0c18d5b --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/app/app-container.tsx @@ -0,0 +1,47 @@ +import getSystem from "@/utils/get-system"; +import { LayoutControl } from "../layout/layout-control"; +import AppDrawer from "./app-drawer"; +import { ReactNode } from "react"; +import styles from "./app-container.module.scss"; +import { appWindow } from "@tauri-apps/api/window"; +import Paper from "@mui/material/Paper"; + +const OS = getSystem(); + +export const AppContainer = ({ + children, + isDrawer, +}: { + children?: ReactNode; + isDrawer?: boolean; +}) => { + return ( + { + if (e.target?.dataset?.windrag) { + appWindow.startDragging(); + } + }} + onContextMenu={(e) => { + e.preventDefault(); + }} + > + + +
+ {OS === "windows" && ( + + )} + +
+ + {children} +
+ + ); +}; + +export default AppContainer; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/app/app-drawer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/app/app-drawer.tsx new file mode 100644 index 0000000000..3fe76b515c --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/app/app-drawer.tsx @@ -0,0 +1,122 @@ +import { classNames } from "@/utils"; +import { getRoutesWithIcon } from "@/utils/routes-utils"; +import { Backdrop, IconButton, alpha, useTheme } from "@mui/material"; +import AnimatedLogo from "../layout/animated-logo"; +import RouteListItem from "./modules/route-list-item"; +import { MenuOpen } from "@mui/icons-material"; +import { useState } from "react"; +import { AnimatePresence, motion } from "framer-motion"; + +export const AppDrawer = ({ isDrawer }: { isDrawer?: boolean }) => { + const { palette } = useTheme(); + + const routes = getRoutesWithIcon(); + + const [open, setOpen] = useState(false); + + const Content = ({ className }: { className?: string }) => { + return ( +
+
+ +
+ +
+ {Object.entries(routes).map(([name, { path, icon }]) => { + return ( + + ); + })} +
+
+ ); + }; + + const DrawerTitle = () => { + return ( +
+ setOpen(true)} + > + + + +
+ +
+ +
+ Clash Nyanpasu +
+
+ ); + }; + + return isDrawer ? ( + <> + + + setOpen(false)} + > + +
+ + + +
+
+
+ + ) : ( + + ); +}; + +export default AppDrawer; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/app/locales-provider.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/app/locales-provider.tsx new file mode 100644 index 0000000000..887270ede4 --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/app/locales-provider.tsx @@ -0,0 +1,22 @@ +import { useNyanpasu } from "@nyanpasu/interface"; +import { locale } from "dayjs"; +import { changeLanguage } from "i18next"; +import { useEffect } from "react"; + +export const LocalesProvider = () => { + const { nyanpasuConfig } = useNyanpasu(); + + useEffect(() => { + if (nyanpasuConfig?.language) { + locale( + nyanpasuConfig?.language === "zh" ? "zh-cn" : nyanpasuConfig?.language, + ); + + changeLanguage(nyanpasuConfig?.language); + } + }, [nyanpasuConfig?.language]); + + return null; +}; + +export default LocalesProvider; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/app/modules/route-list-item.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/app/modules/route-list-item.tsx new file mode 100644 index 0000000000..dad1e3cdac --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/app/modules/route-list-item.tsx @@ -0,0 +1,54 @@ +import { SvgIconComponent } from "@mui/icons-material"; +import { ListItemButton, ListItemIcon, alpha, useTheme } from "@mui/material"; +import { createElement } from "react"; +import { useTranslation } from "react-i18next"; +import { useMatch, useNavigate } from "react-router-dom"; + +export const RouteListItem = ({ + name, + path, + icon, +}: { + name: string; + path: string; + icon: SvgIconComponent; +}) => { + const { t } = useTranslation(); + + const { palette } = useTheme(); + + const match = useMatch({ path: path, end: true }); + + const navigate = useNavigate(); + + return ( + navigate(path)} + > + + {createElement(icon, { + sx: { + fill: match ? palette.primary.main : undefined, + }, + })} + + +
+ {t(`label_${name}`)} +
+
+ ); +}; + +export default RouteListItem; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-dialog.module.scss b/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-dialog.module.scss deleted file mode 100644 index e0ca825020..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-dialog.module.scss +++ /dev/null @@ -1,5 +0,0 @@ -.basePageTransition { - :global(.MuiDialog-paper) { - max-height: calc(100vh - 64px); - } -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-dialog.module.scss.d.ts b/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-dialog.module.scss.d.ts deleted file mode 100644 index 77039e37d3..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-dialog.module.scss.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare const classNames: { - readonly basePageTransition: "basePageTransition"; - readonly "MuiDialog-paper": "MuiDialog-paper"; -}; -export default classNames; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-dialog.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-dialog.tsx deleted file mode 100644 index 55b8623f7b..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-dialog.tsx +++ /dev/null @@ -1,141 +0,0 @@ -import { classNames } from "@/utils"; -import { LoadingButton } from "@mui/lab"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - type SxProps, - type Theme, -} from "@mui/material"; -import { TransitionProps } from "@mui/material/transitions"; -import { AnimatePresence, motion } from "framer-motion"; -import React, { ReactNode } from "react"; -import styles from "./base-dialog.module.scss"; - -interface Props { - title: ReactNode; - open: boolean; - okBtn?: ReactNode; - okBtnDisabled?: boolean; - cancelBtn?: ReactNode; - disableOk?: boolean; - disableCancel?: boolean; - disableFooter?: boolean; - contentSx?: SxProps; - children?: ReactNode; - loading?: boolean; - onOk?: () => void; - onCancel?: () => void; - onClose?: () => void; -} - -export interface DialogRef { - open: () => void; - close: () => void; -} - -export function BaseDialog(props: Props) { - const { - open, - title, - children, - okBtn, - okBtnDisabled, - cancelBtn, - contentSx, - disableCancel, - disableOk, - disableFooter, - loading, - } = props; - - return ( - - {title} - - {children} - - {!disableFooter && ( - - {!disableCancel && ( - - )} - {!disableOk && ( - - {okBtn} - - )} - - )} - - ); -} - -const BaseDialogTransition = React.forwardRef(function BaseDialogTransition( - props: TransitionProps, - ref, -) { - const { in: inProp, children } = props; - - return ( - - {inProp && ( - - {children && - React.cloneElement( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - React.Children.only(children as unknown as any), - { - style: { - opacity: 1, - visibility: "visible", - }, - // TODO: 也许 framer motion 就不会产生这个,手动设定一下。等弄清楚了再说。 - tabIndex: -1, - ref: ref, - }, - )} - - )} - - ); -}); diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-loading.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-loading.tsx deleted file mode 100644 index 0fdbebf1e5..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-loading.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { styled } from "@mui/material"; - -const Loading = styled("div")` - position: relative; - display: flex; - height: 100%; - min-height: 18px; - box-sizing: border-box; - align-items: center; - - & > div { - box-sizing: border-box; - width: 6px; - height: 6px; - margin: 2px; - border-radius: 100%; - animation: loading 0.7s -0.15s infinite linear; - } - - & > div:nth-child(2n-1) { - animation-delay: -0.5s; - } - - @keyframes loading { - 50% { - opacity: 0.2; - transform: scale(0.75); - } - 100% { - opacity: 1; - transform: scale(1); - } - } -`; - -const LoadingItem = styled("div")(({ theme }) => ({ - background: theme.palette.text.secondary, -})); - -export const BaseLoading = () => { - return ( - - - - - - ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-page.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-page.tsx deleted file mode 100644 index 79e1c6de5b..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/base/base-page.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React, { ReactNode } from "react"; -import { Typography } from "@mui/material"; -import { BaseErrorBoundary } from "./base-error-boundary"; - -interface Props { - title?: React.ReactNode; // the page title - header?: React.ReactNode; // something behind title - contentStyle?: React.CSSProperties; - sectionStyle?: React.CSSProperties; - children?: ReactNode; - full?: boolean; -} - -export const BasePage: React.FC = (props) => { - const { title, header, contentStyle, full, children, sectionStyle } = props; - - return ( - -
-
- - {title} - - - {header} -
- -
-
-
- {children} -
-
-
-
-
- ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/base/content-display.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/base/content-display.tsx new file mode 100644 index 0000000000..a999007ab8 --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/base/content-display.tsx @@ -0,0 +1,36 @@ +import { classNames } from "@/utils"; +import { Public } from "@mui/icons-material"; +import { ReactNode } from "react"; + +export interface ContentDisplayProps { + className?: string; + message?: string; + children?: ReactNode; +} + +export const ContentDisplay = ({ + message, + children, + className, +}: ContentDisplayProps) => ( +
+
+ {children ? ( + children + ) : ( + <> + + + {message} + + )} +
+
+); + +export default ContentDisplay; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/base/index.ts b/clash-nyanpasu/frontend/nyanpasu/src/components/base/index.ts index 3e0e32403a..4ab003dee8 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/base/index.ts +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/base/index.ts @@ -1,6 +1,3 @@ -export { BaseDialog, type DialogRef } from "./base-dialog"; -export { BasePage } from "./base-page"; export { BaseEmpty } from "./base-empty"; -export { BaseLoading } from "./base-loading"; export { BaseErrorBoundary } from "./base-error-boundary"; export { Notice } from "./base-notice"; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/common/kbd.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/common/kbd.tsx deleted file mode 100644 index 39ff93db4f..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/common/kbd.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { styled } from "@mui/material/styles"; -const Kbd = styled("kbd")(({ theme }) => ({ - backgroundColor: - theme.palette.mode === "dark" ? "rgb(255 255 255 / 0.06)" : "#edf2f7;", - borderColor: - theme.palette.mode === "dark" ? "rgb(255 255 255 / 0.16)" : "#e2e8f0", - paddingRight: "0.4em", - paddingLeft: "0.4em", - fontFamily: "SFMono-Regular, Menlo, Monaco, Consolas, monospace", - // font-size: 1em, - fontSize: "0.8em", - fontWeight: "bold", - lineHeight: "normal", - whiteSpace: "nowrap", - borderWidth: "1px", - borderBottomWidth: "3px", - borderRadius: "0.375rem", - borderStyle: "solid", -})); - -export default Kbd; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/common/mdy-switch.scss b/clash-nyanpasu/frontend/nyanpasu/src/components/common/mdy-switch.scss deleted file mode 100644 index db1a215f03..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/common/mdy-switch.scss +++ /dev/null @@ -1,15 +0,0 @@ -.MDYSwitch-container { - position: relative; - - .MDYSwitch-CircularProgress { - position: absolute; - top: 8px; - left: 8px; - z-index: 1; - - &.checked { - right: 8px; - left: unset; - } - } -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/common/mdy-switch.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/common/mdy-switch.tsx deleted file mode 100644 index 3077a0156d..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/common/mdy-switch.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import { styled } from "@mui/material/styles"; -import Switch, { SwitchProps } from "@mui/material/Switch"; -import CircularProgress from "@mui/material/CircularProgress"; -import "./mdy-switch.scss"; - -interface MDYSwitchProps extends SwitchProps { - loading?: boolean; -} - -const MDYSwitch = styled((props: MDYSwitchProps) => { - const { loading = false, checked, disabled, ...nativeProps } = props; - - return ( -
- {loading && ( - - )} - -
- ); -})(({ theme, checked, loading, disabled }) => ({ - height: "32px", - padding: 0, - margin: 0, - borderRadius: 24, - opacity: loading || disabled ? 0.5 : 1, - "& .MuiSwitch-track": { - borderRadius: 24, - opacity: checked - ? "1 !important" - : theme.palette.mode === "dark" - ? "0.3 !important" - : "0.7 !important", - backgroundColor: checked - ? theme.palette.primary.main - : theme.palette.mode === "dark" - ? theme.palette.grey.A700 - : theme.palette.grey.A200, - "&::before": { - content: '""', - border: `solid 2px ${theme.palette.grey.A700}`, - width: "100%", - height: "100%", - opacity: checked ? 0 : 1, - position: "absolute", - borderRadius: "inherit", - boxSizing: "border-box", - transitionProperty: "opacity, background-color", - transitionTimingFunction: "linear", - transitionDuration: "67ms", - }, - }, - "& .MuiSwitch-switchBase": { - padding: "6px", - }, - "& .MuiSwitch-thumb": { - boxShadow: "none", - width: loading ? 24 : 15, - height: loading ? 24 : 15, - margin: loading ? -2 : 3, - color: checked - ? theme.palette.getContrastText(theme.palette.primary.main) - : theme.palette.mode === "dark" - ? theme.palette.grey.A200 - : theme.palette.grey.A700, - opacity: checked ? 1 : 0.7, - }, - "& .Mui-checked": { - "&.MuiSwitch-switchBase": { - padding: "6px 9px 6px 12px", - }, - "& .MuiSwitch-thumb": { - width: 24, - height: 24, - margin: -2, - }, - }, -})); - -export default MDYSwitch; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/connection/connection-detail.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/connection/connection-detail.tsx deleted file mode 100644 index f59f88a87b..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/connection/connection-detail.tsx +++ /dev/null @@ -1,106 +0,0 @@ -import { deleteConnection } from "@/services/api"; -import parseTraffic from "@/utils/parse-traffic"; -import { truncateStr } from "@/utils/truncate-str"; -import { Box, Button, Snackbar } from "@mui/material"; -import { useLockFn } from "ahooks"; -import dayjs from "dayjs"; -import { forwardRef, useImperativeHandle, useState } from "react"; - -export interface ConnectionDetailRef { - open: (detail: IConnectionsItem) => void; -} - -export const ConnectionDetail = forwardRef( - (props, ref) => { - const [open, setOpen] = useState(false); - const [detail, setDetail] = useState(null!); - - useImperativeHandle(ref, () => ({ - open: (detail: IConnectionsItem) => { - if (open) return; - setOpen(true); - setDetail(detail); - }, - })); - - const onClose = () => setOpen(false); - - return ( - - ) : null - } - /> - ); - }, -); - -ConnectionDetail.displayName = "ConnectionDetail"; - -interface InnerProps { - data: IConnectionsItem; - onClose?: () => void; -} - -const InnerConnectionDetail = ({ data, onClose }: InnerProps) => { - const { metadata, rulePayload } = data; - const chains = [...data.chains].reverse().join(" / "); - const rule = rulePayload ? `${data.rule}(${rulePayload})` : data.rule; - const host = metadata.host - ? `${metadata.host}:${metadata.destinationPort}` - : `${metadata.destinationIP}:${metadata.destinationPort}`; - - const information = [ - { label: "Host", value: host }, - { label: "Download", value: parseTraffic(data.download).join(" ") }, - { label: "Upload", value: parseTraffic(data.upload).join(" ") }, - { - label: "DL Speed", - value: parseTraffic(data.curDownload ?? -1).join(" ") + "/s", - }, - { - label: "UL Speed", - value: parseTraffic(data.curUpload ?? -1).join(" ") + "/s", - }, - { label: "Chains", value: chains }, - { label: "Rule", value: rule }, - { - label: "Process", - value: truncateStr(metadata.process || metadata.processPath), - }, - { label: "Time", value: dayjs(data.start).fromNow() }, - { label: "Source", value: `${metadata.sourceIP}:${metadata.sourcePort}` }, - { label: "Destination IP", value: metadata.destinationIP }, - { label: "Type", value: `${metadata.type}(${metadata.network})` }, - ]; - - const onDelete = useLockFn(async () => deleteConnection(data.id)); - - return ( - - {information.map((each) => ( -
- {each.label}: {each.value} -
- ))} - - - - -
- ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/connection/connection-item.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/connection/connection-item.tsx deleted file mode 100644 index d04bf210e1..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/connection/connection-item.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import dayjs from "dayjs"; -import { useLockFn } from "ahooks"; -import { - styled, - ListItem, - IconButton, - ListItemText, - Box, - alpha, -} from "@mui/material"; -import { CloseRounded } from "@mui/icons-material"; -import { deleteConnection } from "@/services/api"; -import parseTraffic from "@/utils/parse-traffic"; - -const Tag = styled("span")(({ theme }) => ({ - fontSize: "10px", - padding: "0 4px", - lineHeight: 1.375, - border: "1px solid", - borderRadius: 4, - borderColor: alpha(theme.palette.text.secondary, 0.35), - marginRight: "4px", -})); - -interface Props { - value: IConnectionsItem; - onShowDetail?: () => void; -} - -export const ConnectionItem = (props: Props) => { - const { value, onShowDetail } = props; - - const { id, metadata, chains, start, curUpload, curDownload } = value; - - const onDelete = useLockFn(async () => deleteConnection(id)); - const showTraffic = curUpload! >= 100 || curDownload! >= 100; - - return ( - - - - } - > - - - {metadata.network} - - - {metadata.type} - - {!!metadata.process && {metadata.process}} - - {chains.length > 0 && {chains[value.chains.length - 1]}} - - {dayjs(start).fromNow()} - - {showTraffic && ( - - {parseTraffic(curUpload!)} / {parseTraffic(curDownload!)} - - )} - - } - /> - - ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/connection/connection-table.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/connection/connection-table.tsx deleted file mode 100644 index 8f575c5bcd..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/connection/connection-table.tsx +++ /dev/null @@ -1,114 +0,0 @@ -import parseTraffic from "@/utils/parse-traffic"; -import { truncateStr } from "@/utils/truncate-str"; -import { DataGrid, GridColDef } from "@mui/x-data-grid"; -import dayjs from "dayjs"; -import { useMemo, useState } from "react"; - -interface Props { - connections: IConnectionsItem[]; - onShowDetail: (data: IConnectionsItem) => void; -} - -export const ConnectionTable = (props: Props) => { - const { connections, onShowDetail } = props; - - const [columnVisible, setColumnVisible] = useState< - Partial> - >({}); - - const columns: GridColDef[] = [ - { field: "host", headerName: "Host", flex: 220, minWidth: 220 }, - { - field: "download", - headerName: "Download", - width: 88, - align: "right", - headerAlign: "right", - valueFormatter: (value) => parseTraffic(value).join(" "), - }, - { - field: "upload", - headerName: "Upload", - width: 88, - align: "right", - headerAlign: "right", - valueFormatter: (value) => parseTraffic(value).join(" "), - }, - { - field: "dlSpeed", - headerName: "DL Speed", - width: 88, - align: "right", - headerAlign: "right", - valueFormatter: (value) => parseTraffic(value).join(" ") + "/s", - }, - { - field: "ulSpeed", - headerName: "UL Speed", - width: 88, - align: "right", - headerAlign: "right", - valueFormatter: (value) => parseTraffic(value).join(" ") + "/s", - }, - { field: "chains", headerName: "Chains", flex: 360, minWidth: 360 }, - { field: "rule", headerName: "Rule", flex: 300, minWidth: 250 }, - { field: "process", headerName: "Process", flex: 480, minWidth: 480 }, - { - field: "time", - headerName: "Time", - flex: 120, - minWidth: 100, - align: "right", - headerAlign: "right", - }, - { field: "source", headerName: "Source", flex: 200, minWidth: 130 }, - { - field: "destinationIP", - headerName: "Destination IP", - flex: 200, - minWidth: 130, - }, - { field: "type", headerName: "Type", flex: 160, minWidth: 100 }, - ]; - - const connRows = useMemo(() => { - return connections.map((each) => { - const { metadata, rulePayload } = each; - const chains = [...each.chains].reverse().join(" / "); - const rule = rulePayload ? `${each.rule}(${rulePayload})` : each.rule; - - return { - id: each.id, - host: metadata.host - ? `${metadata.host}:${metadata.destinationPort}` - : `${metadata.destinationIP}:${metadata.destinationPort}`, - download: each.download, - upload: each.upload, - dlSpeed: each.curDownload, - ulSpeed: each.curUpload, - chains, - rule, - process: truncateStr(metadata.process || metadata.processPath), - time: dayjs(each.start).fromNow(), - source: `${metadata.sourceIP}:${metadata.sourcePort}`, - destinationIP: metadata.destinationIP, - type: `${metadata.type}(${metadata.network})`, - - connectionData: each, - }; - }); - }, [connections]); - - return ( - onShowDetail(e.row.connectionData)} - density="compact" - sx={{ border: "none", "div:focus": { outline: "none !important" } }} - columnVisibilityModel={columnVisible} - onColumnVisibilityModelChange={(e) => setColumnVisible(e)} - /> - ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/connections/connections-table.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/connections/connections-table.tsx index 0d1a71b448..de11f9f116 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/connections/connections-table.tsx +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/connections/connections-table.tsx @@ -2,7 +2,7 @@ import parseTraffic from "@/utils/parse-traffic"; import { GridColDef, DataGrid } from "@mui/x-data-grid"; import { useClashWS, Connection } from "@nyanpasu/interface"; import dayjs from "dayjs"; -import { useRef, useMemo, useEffect } from "react"; +import { useRef, useMemo } from "react"; import { useTranslation } from "react-i18next"; import HeaderSearch from "./header-search"; @@ -20,7 +20,7 @@ export const ConnectionsTable = () => { const { t } = useTranslation(); const { - connections: { readyState, latestMessage }, + connections: { latestMessage }, } = useClashWS(); const historyMessage = useRef(undefined); @@ -61,8 +61,18 @@ export const ConnectionsTable = () => { }, [latestMessage?.data]); const columns: GridColDef[] = [ - { field: "host", headerName: t("Host"), flex: 240, minWidth: 240 }, - { field: "process", headerName: t("Process"), flex: 100, minWidth: 100 }, + { + field: "host", + headerName: t("Host"), + flex: 240, + minWidth: 240, + }, + { + field: "process", + headerName: t("Process"), + flex: 100, + minWidth: 100, + }, { field: "download", headerName: t("Download"), @@ -94,7 +104,12 @@ export const ConnectionsTable = () => { minWidth: 360, valueFormatter: (value) => [...value].reverse().join(" / "), }, - { field: "rule", headerName: "Rule", flex: 300, minWidth: 250 }, + { + field: "rule", + headerName: "Rule", + flex: 300, + minWidth: 250, + }, { field: "start", headerName: t("Time"), @@ -102,14 +117,24 @@ export const ConnectionsTable = () => { minWidth: 100, valueFormatter: (value) => dayjs(value).fromNow(), }, - { field: "source", headerName: "Source", flex: 200, minWidth: 130 }, + { + field: "source", + headerName: "Source", + flex: 200, + minWidth: 130, + }, { field: "destinationIP", headerName: t("Destination IP"), flex: 200, minWidth: 130, }, - { field: "type", headerName: t("Type"), flex: 160, minWidth: 100 }, + { + field: "type", + headerName: t("Type"), + flex: 160, + minWidth: 100, + }, ]; return ( @@ -118,6 +143,7 @@ export const ConnectionsTable = () => { rows={connectionsMessage.connections} columns={columns} density="compact" + autosizeOnMount hideFooter disableColumnFilter disableColumnSelector diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/animated-logo.module.scss b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/animated-logo.module.scss new file mode 100644 index 0000000000..d27230527e --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/animated-logo.module.scss @@ -0,0 +1,7 @@ +.LogoSchema { + fill: var(--primary-main); + + :global(#bg) { + fill: var(--background-color); + } +} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/animated-logo.module.scss.d.ts b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/animated-logo.module.scss.d.ts new file mode 100644 index 0000000000..9f8f80e4ac --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/animated-logo.module.scss.d.ts @@ -0,0 +1,4 @@ +declare const classNames: { + readonly LogoSchema: "LogoSchema"; +}; +export default classNames; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/animated-logo.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/animated-logo.tsx index 530d715706..cdde170d64 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/animated-logo.tsx +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/animated-logo.tsx @@ -1,34 +1,67 @@ import LogoSvg from "@/assets/image/logo.svg?react"; -import getSystem from "@/utils/get-system"; -import { motion } from "framer-motion"; -import { useRef } from "react"; -import { UpdateButton } from "./update-button"; - -const OS = getSystem(); +import { AnimatePresence, Variants, motion } from "framer-motion"; +import { classNames } from "@/utils"; +import { CSSProperties } from "react"; +import styles from "./animated-logo.module.scss"; +import { useNyanpasu } from "@nyanpasu/interface"; const Logo = motion(LogoSvg); -export default function AnimatedLogo() { - const constraintsRef = useRef(null); +const transition = { + type: "spring", + stiffness: 260, + damping: 20, +}; + +const motionVariants: { [name: string]: Variants } = { + default: { + initial: { + opacity: 0, + scale: 0.5, + transition, + }, + animate: { + opacity: 1, + scale: 1, + transition, + }, + exit: { + opacity: 0, + scale: 0.5, + transition, + }, + whileHover: { + scale: 1.1, + transition, + }, + }, + none: { + initial: {}, + animate: {}, + exit: {}, + }, +}; + +export default function AnimatedLogo({ + className, + style, + disbaleMotion, +}: { + className?: string; + style?: CSSProperties; + disbaleMotion?: boolean; +}) { + const { nyanpasuConfig } = useNyanpasu(); + + const disbale = disbaleMotion ?? nyanpasuConfig?.lighten_animation_effects; return ( -
+ - - {!(OS === "windows" && WIN_PORTABLE) && ( - - )} -
+ ); } diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/layout-control.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/layout-control.tsx index 8db8bed550..d5d953f488 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/layout-control.tsx +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/layout-control.tsx @@ -1,5 +1,4 @@ import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { save_window_size_state } from "@/services/cmds"; import { classNames } from "@/utils"; import { CloseRounded, @@ -8,6 +7,7 @@ import { HorizontalRuleRounded, } from "@mui/icons-material"; import { alpha, Button, ButtonProps, useTheme } from "@mui/material"; +import { save_window_size_state } from "@nyanpasu/interface"; import { platform, type Platform } from "@tauri-apps/api/os"; import { appWindow } from "@tauri-apps/api/window"; import { debounce } from "lodash-es"; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/layout-item.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/layout-item.tsx deleted file mode 100644 index 784c109a1d..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/layout-item.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { useNavigate, type Params, type Path } from "@/router"; -import type { LinkProps } from "@generouted/react-router/client"; -import { ListItem, ListItemButton, ListItemText, alpha } from "@mui/material"; -import { useMatch, useResolvedPath } from "react-router-dom"; -export const LayoutItem = (props: LinkProps) => { - const { to, children } = props; - - const resolved = useResolvedPath(to); - const match = useMatch({ path: resolved.pathname, end: true }); - const navigate = useNavigate(); - - return ( - - { - const bgcolor = - mode === "light" - ? alpha(primary.main, 0.15) - : alpha(primary.main, 0.35); - const color = mode === "light" ? primary.main : primary.light; - - return { - "&.Mui-selected": { bgcolor }, - "&.Mui-selected:hover": { bgcolor }, - "&.Mui-selected .MuiListItemText-primary": { color }, - }; - }, - ]} - onClick={() => navigate(to)} - > - - - - ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/layout-traffic.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/layout-traffic.tsx deleted file mode 100644 index bc7496675d..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/layout-traffic.tsx +++ /dev/null @@ -1,137 +0,0 @@ -import { useClashInfo } from "@/hooks/use-clash"; -import { useVerge } from "@/hooks/use-verge"; -import { useVisibility } from "@/hooks/use-visibility"; -import { useWebsocket } from "@/hooks/use-websocket"; -import parseTraffic from "@/utils/parse-traffic"; -import { - ArrowDownward, - ArrowUpward, - MemoryOutlined, -} from "@mui/icons-material"; -import { Box, Typography } from "@mui/material"; -import { useEffect, useRef, useState } from "react"; -import { TrafficGraph, type TrafficRef } from "./traffic-graph"; -import { useLogSetup } from "./use-log-setup"; - -// setup the traffic -export const LayoutTraffic = () => { - const { clashInfo } = useClashInfo(); - const { verge } = useVerge(); - - // whether hide traffic graph - const trafficGraph = verge?.traffic_graph ?? true; - - const trafficRef = useRef(null); - const [traffic, setTraffic] = useState({ up: 0, down: 0 }); - const [memory, setMemory] = useState({ inuse: 0 }); - const pageVisible = useVisibility(); - - // setup log ws during layout - useLogSetup(); - - const { connect, disconnect } = useWebsocket((event) => { - const data = JSON.parse(event.data) as ITrafficItem; - trafficRef.current?.appendData(data); - setTraffic(data); - }); - - useEffect(() => { - if (!clashInfo || !pageVisible) return; - - const { server = "", secret = "" } = clashInfo; - connect(`ws://${server}/traffic?token=${encodeURIComponent(secret)}`); - - return () => { - disconnect(); - }; - }, [clashInfo, pageVisible]); - - /* --------- meta memory information --------- */ - const isMetaCore = - verge?.clash_core === "mihomo" || verge?.clash_core === "mihomo-alpha"; - const displayMemory = isMetaCore && (verge?.enable_memory_usage ?? true); - - const memoryWs = useWebsocket( - (event) => { - setMemory(JSON.parse(event.data)); - }, - { onError: () => setMemory({ inuse: 0 }) }, - ); - - useEffect(() => { - if (!clashInfo || !pageVisible || !displayMemory) return; - const { server = "", secret = "" } = clashInfo; - memoryWs.connect( - `ws://${server}/memory?token=${encodeURIComponent(secret)}`, - ); - return () => memoryWs.disconnect(); - }, [clashInfo, pageVisible, displayMemory]); - - const [up, upUnit] = parseTraffic(traffic.up); - const [down, downUnit] = parseTraffic(traffic.down); - const [inuse, inuseUnit] = parseTraffic(memory.inuse); - - const iconStyle: any = { - sx: { mr: "8px", fontSize: 16 }, - }; - const valStyle: any = { - component: "span", - color: "primary", - textAlign: "center", - sx: { flex: "1 1 56px", userSelect: "none" }, - }; - const unitStyle: any = { - component: "span", - color: "grey.500", - fontSize: "12px", - textAlign: "right", - sx: { flex: "0 1 27px", userSelect: "none" }, - }; - - return ( - - {trafficGraph && pageVisible && ( -
- -
- )} - - - - 0 ? "primary" : "disabled"} - /> - {up} - {upUnit}/s - - - - 0 ? "primary" : "disabled"} - /> - {down} - {downUnit}/s - - - {displayMemory && ( - - - {inuse} - {inuseUnit} - - )} - -
- ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/notice-provider.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/notice-provider.tsx new file mode 100644 index 0000000000..9e6043bd2a --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/notice-provider.tsx @@ -0,0 +1,38 @@ +import { NotificationType, useNotification } from "@/hooks/use-notification"; +import { listen } from "@tauri-apps/api/event"; +import { useEffect } from "react"; +import { useTranslation } from "react-i18next"; + +export const NoticeProvider = () => { + const { t } = useTranslation(); + + useEffect(() => { + listen("verge://notice-message", ({ payload }) => { + const [status, msg] = payload as [string, string]; + switch (status) { + case "set_config::ok": + useNotification({ + title: t("Success"), + body: "Refresh Clash Config", + type: NotificationType.Success, + }); + break; + + case "set_config::error": + useNotification({ + title: t("Error"), + body: msg, + type: NotificationType.Error, + }); + break; + + default: + break; + } + }); + }, []); + + return null; +}; + +export default NoticeProvider; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/page-transition.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/page-transition.tsx index 014145e10d..1f6ae04d61 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/page-transition.tsx +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/page-transition.tsx @@ -1,29 +1,21 @@ -import { useVerge } from "@/hooks/use-verge"; import { classNames } from "@/utils"; -import { motion, type HTMLMotionProps } from "framer-motion"; -import { useState } from "react"; -import { useOutlet } from "react-router-dom"; +import { useNyanpasu } from "@nyanpasu/interface"; +import { AnimatePresence, Variant, motion } from "framer-motion"; +import { useLocation, useOutlet } from "react-router-dom"; -type Props = { - children?: React.ReactNode; +type PageVariantKey = "initial" | "visible" | "hidden"; + +type PageVariant = { + [key in PageVariantKey]: Variant; }; -interface PageTransitionVariant { - initial: HTMLMotionProps<"div">["initial"]; - visible: HTMLMotionProps<"div">["animate"]; - hidden: HTMLMotionProps<"div">["exit"]; - transition?: HTMLMotionProps<"div">["transition"]; -} - const commonTransition = { type: "spring", - bounce: 0.3, - duration: 0.5, - delayChildren: 0.2, - staggerChildren: 0.05, + bounce: 0, + duration: 0.35, }; -export const pageTransitionVariants = { +export const pageTransitionVariants: { [name: string]: PageVariant } = { blur: { initial: { opacity: 0, filter: "blur(10px)" }, visible: { opacity: 1, filter: "blur(0px)" }, @@ -31,9 +23,9 @@ export const pageTransitionVariants = { }, slide: { initial: { - translateY: "50%", + translateY: "30%", opacity: 0, - scale: 0.9, + scale: 0.95, }, visible: { translateY: "0%", @@ -42,7 +34,6 @@ export const pageTransitionVariants = { transition: commonTransition, }, hidden: { - translateY: "-50%", opacity: 0, scale: 0.9, transition: commonTransition, @@ -53,66 +44,33 @@ export const pageTransitionVariants = { visible: { opacity: 1 }, hidden: { opacity: 0 }, }, - none: { - initial: {}, - visible: {}, - hidden: {}, - }, -} satisfies Record; - -function overrideVariantsTransition( - variants: Record, - transition?: HTMLMotionProps<"div">["transition"], -) { - if (!transition) return variants; - return Object.keys(variants).reduce( - (acc, cur) => { - acc[cur] = Object.entries(variants[cur]).reduce((acc, [key, value]) => { - if (key === "initial") { - acc[key] = value; - return acc; - } - // @ts-expect-error ts(7053) - 懒得针对工具方法做类型体操了 - acc[key] = { - ...value, - transition, - }; - return acc; - }, {} as PageTransitionVariant); - return acc; - }, - {} as Record, - ); -} - -const AnimatedOutlet: React.FC = () => { - const o = useOutlet(); - const [outlet] = useState(o); - - return <>{outlet}; }; -export default function PageTransition() { - const { verge } = useVerge(); - const { theme_setting } = verge ?? {}; - const variants = overrideVariantsTransition( - pageTransitionVariants, - theme_setting?.page_transition_duration - ? { - duration: theme_setting.page_transition_duration, - } - : undefined, - ) as typeof pageTransitionVariants; +export default function PageTransition({ className }: { className?: string }) { + const { nyanpasuConfig } = useNyanpasu(); + + const outlet = useOutlet(); + + const hashkey = useLocation().pathname; + + const variants = nyanpasuConfig?.lighten_animation_effects + ? pageTransitionVariants.transparent + : pageTransitionVariants.slide; + return ( - - - + + + {outlet} + + ); } diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/scheme-provider.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/scheme-provider.tsx new file mode 100644 index 0000000000..7ee0746cf1 --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/scheme-provider.tsx @@ -0,0 +1,44 @@ +import { listen } from "@tauri-apps/api/event"; +import { useEffect } from "react"; +import { useNavigate } from "react-router-dom"; + +export const SchemeProvider = () => { + const navigate = useNavigate(); + + useEffect(() => { + listen("scheme-request-received", (req) => { + const message: string = req.payload as string; + + const url = new URL(message); + + if (url.pathname.endsWith("/")) { + url.pathname = url.pathname.slice(0, -1); + } + + if (url.pathname.startsWith("//")) { + url.pathname = url.pathname.slice(1); + } + + switch (url.pathname) { + case "/subscribe-remote-profile": + navigate("/profiles", { + state: { + subscribe: { + url: url.searchParams.get("url"), + name: url.searchParams.has("name") + ? decodeURIComponent(url.searchParams.get("name")!) + : undefined, + desc: url.searchParams.has("desc") + ? decodeURIComponent(url.searchParams.get("desc")!) + : undefined, + }, + }, + }); + } + }); + }, []); + + return null; +}; + +export default SchemeProvider; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/traffic-graph.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/traffic-graph.tsx deleted file mode 100644 index 0fb5f95415..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/traffic-graph.tsx +++ /dev/null @@ -1,197 +0,0 @@ -import { useTheme } from "@mui/material"; -import { forwardRef, useEffect, useImperativeHandle, useRef } from "react"; - -const maxPoint = 30; - -const refLineAlpha = 1; -const refLineWidth = 2; - -const upLineAlpha = 0.6; -const upLineWidth = 4; - -const downLineAlpha = 1; -const downLineWidth = 4; - -const defaultList = Array(maxPoint + 2).fill({ up: 0, down: 0 }); - -type TrafficData = { up: number; down: number }; - -export interface TrafficRef { - appendData: (data: TrafficData) => void; - toggleStyle: () => void; -} - -/** - * draw the traffic graph - */ -export const TrafficGraph = forwardRef((props, ref) => { - const countRef = useRef(0); - const styleRef = useRef(true); - const listRef = useRef(defaultList); - const canvasRef = useRef(null!); - - const cacheRef = useRef(null); - - const { palette } = useTheme(); - - useImperativeHandle(ref, () => ({ - appendData: (data: TrafficData) => { - cacheRef.current = data; - }, - toggleStyle: () => { - styleRef.current = !styleRef.current; - }, - })); - - useEffect(() => { - let timer: any; - const zero = { up: 0, down: 0 }; - - const handleData = () => { - const data = cacheRef.current ? cacheRef.current : zero; - cacheRef.current = null; - - const list = listRef.current; - if (list.length > maxPoint + 2) list.shift(); - list.push(data); - countRef.current = 0; - - timer = setTimeout(handleData, 1000); - }; - - handleData(); - - return () => { - if (timer) clearTimeout(timer); - }; - }, []); - - useEffect(() => { - let raf = 0; - const canvas = canvasRef.current!; - - if (!canvas) return; - - const context = canvas.getContext("2d")!; - - if (!context) return; - - const { primary, secondary, divider } = palette; - const refLineColor = divider || "rgba(0, 0, 0, 0.12)"; - const upLineColor = secondary.main || "#9c27b0"; - const downLineColor = primary.main || "#5b5c9d"; - - const width = canvas.width; - const height = canvas.height; - const dx = width / maxPoint; - const dy = height / 7; - const l1 = dy; - const l2 = dy * 4; - - const countY = (v: number) => { - const h = height; - - if (v == 0) return h - 1; - if (v <= 10) return h - (v / 10) * dy; - if (v <= 100) return h - (v / 100 + 1) * dy; - if (v <= 1024) return h - (v / 1024 + 2) * dy; - if (v <= 10240) return h - (v / 10240 + 3) * dy; - if (v <= 102400) return h - (v / 102400 + 4) * dy; - if (v <= 1048576) return h - (v / 1048576 + 5) * dy; - if (v <= 10485760) return h - (v / 10485760 + 6) * dy; - return 1; - }; - - const drawBezier = (list: number[], offset: number) => { - const points = list.map((y, i) => [ - (dx * (i - 1) - offset + 3) | 0, - countY(y), - ]); - - let x = points[0][0]; - let y = points[0][1]; - - context.moveTo(x, y); - - for (let i = 1; i < points.length; i++) { - const p1 = points[i]; - const p2 = points[i + 1] || p1; - - const x1 = (p1[0] + p2[0]) / 2; - const y1 = (p1[1] + p2[1]) / 2; - - context.quadraticCurveTo(p1[0], p1[1], x1, y1); - x = x1; - y = y1; - } - }; - - const drawLine = (list: number[], offset: number) => { - const points = list.map((y, i) => [ - (dx * (i - 1) - offset) | 0, - countY(y), - ]); - - context.moveTo(points[0][0], points[0][1]); - - for (let i = 1; i < points.length; i++) { - const p = points[i]; - context.lineTo(p[0], p[1]); - } - }; - - const drawGraph = (lastTime: number) => { - const listUp = listRef.current.map((v) => v.up); - const listDown = listRef.current.map((v) => v.down); - const lineStyle = styleRef.current; - - const now = Date.now(); - const diff = now - lastTime; - const temp = Math.min((diff / 1000) * dx + countRef.current, dx); - const offset = countRef.current === 0 ? 0 : temp; - countRef.current = temp; - - context.clearRect(0, 0, width, height); - - // Reference lines - context.beginPath(); - context.globalAlpha = refLineAlpha; - context.lineWidth = refLineWidth; - context.strokeStyle = refLineColor; - context.moveTo(0, l1); - context.lineTo(width, l1); - context.moveTo(0, l2); - context.lineTo(width, l2); - context.stroke(); - context.closePath(); - - context.beginPath(); - context.globalAlpha = upLineAlpha; - context.lineWidth = upLineWidth; - context.strokeStyle = upLineColor; - lineStyle ? drawBezier(listUp, offset) : drawLine(listUp, offset); - context.stroke(); - context.closePath(); - - context.beginPath(); - context.globalAlpha = downLineAlpha; - context.lineWidth = downLineWidth; - context.strokeStyle = downLineColor; - lineStyle ? drawBezier(listDown, offset) : drawLine(listDown, offset); - context.stroke(); - context.closePath(); - - raf = requestAnimationFrame(() => drawGraph(now)); - }; - - drawGraph(Date.now()); - - return () => { - cancelAnimationFrame(raf); - }; - }, [palette]); - - return ; -}); - -TrafficGraph.displayName = "TrafficGraph"; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/update-button.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/update-button.tsx deleted file mode 100644 index 8ca7cba25c..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/update-button.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import { useVerge } from "@/hooks/use-verge"; -import { Button } from "@mui/material"; -import { checkUpdate } from "@tauri-apps/api/updater"; -import { useRef } from "react"; -import useSWR from "swr"; -import { DialogRef } from "../base"; -import { UpdateViewer } from "../setting/mods/update-viewer"; - -interface Props { - className?: string; -} - -export const UpdateButton = (props: Props) => { - const { className } = props; - - const viewerRef = useRef(null); - - const { verge } = useVerge(); - - const { disable_auto_check_update } = verge ?? {}; - - const { data: updateInfo } = useSWR( - disable_auto_check_update ? null : "checkUpdate", - disable_auto_check_update ? null : checkUpdate, - { - errorRetryCount: 2, - revalidateIfStale: false, - focusThrottleInterval: 36e5, // 1 hour - }, - ); - - if (!updateInfo?.shouldUpdate) return null; - - return ( - <> - - - - - ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/use-custom-theme.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/use-custom-theme.tsx index 08d01fdb05..e7e44254ab 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/use-custom-theme.tsx +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/use-custom-theme.tsx @@ -6,6 +6,7 @@ import { useNyanpasu } from "@nyanpasu/interface"; import { createMDYTheme } from "@nyanpasu/ui"; import { useAtomValue, useSetAtom } from "jotai"; import { themeMode as themeModeAtom } from "@/store"; +import { useWhyDidYouUpdate } from "ahooks"; const applyRootStyleVar = (mode: "light" | "dark", theme: Theme) => { const root = document.documentElement; @@ -37,6 +38,8 @@ export const useCustomTheme = () => { const { nyanpasuConfig } = useNyanpasu(); const themeMode = useAtomValue(themeModeAtom); + useWhyDidYouUpdate("useCustomTheme", { nyanpasuConfig, themeMode }); + const theme = useMemo(() => { const mergedTheme = createMDYTheme({ ...defaultTheme, diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/use-log-setup.ts b/clash-nyanpasu/frontend/nyanpasu/src/components/layout/use-log-setup.ts deleted file mode 100644 index e0e0cb1cab..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/layout/use-log-setup.ts +++ /dev/null @@ -1,39 +0,0 @@ -import dayjs from "dayjs"; -import { useEffect } from "react"; -import { getClashLogs } from "@/services/cmds"; -import { useClashInfo } from "@/hooks/use-clash"; -import { useWebsocket } from "@/hooks/use-websocket"; -import { useAtomValue, useSetAtom } from "jotai"; -import { atomEnableLog, atomLogData } from "@/store"; - -const MAX_LOG_NUM = 1000; - -// setup the log websocket -export const useLogSetup = () => { - const { clashInfo } = useClashInfo(); - - const enableLog = useAtomValue(atomEnableLog); - const setLogData = useSetAtom(atomLogData); - - const { connect, disconnect } = useWebsocket((event) => { - const data = JSON.parse(event.data) as ILogItem; - const time = dayjs().format("MM-DD HH:mm:ss"); - setLogData((l) => { - if (l.length >= MAX_LOG_NUM) l.shift(); - return [...l, { ...data, time }]; - }); - }); - - useEffect(() => { - if (!enableLog || !clashInfo) return; - - getClashLogs().then(setLogData); - - const { server = "", secret = "" } = clashInfo; - connect(`ws://${server}/logs?token=${encodeURIComponent(secret)}`); - - return () => { - disconnect(); - }; - }, [clashInfo, enableLog]); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/log/log-item.module.scss b/clash-nyanpasu/frontend/nyanpasu/src/components/log/log-item.module.scss deleted file mode 100644 index 5b5b8136ed..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/log/log-item.module.scss +++ /dev/null @@ -1,23 +0,0 @@ -.item { - :global(.shiki) { - margin-top: 0.25em; - margin-bottom: 0; - background-color: transparent !important; - - * { - font-family: var(--item-font); - } - - span { - white-space: normal; - } - } - - &.dark { - :global(.shiki) { - span { - color: var(--shiki-dark) !important; - } - } - } -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/log/log-item.module.scss.d.ts b/clash-nyanpasu/frontend/nyanpasu/src/components/log/log-item.module.scss.d.ts deleted file mode 100644 index 404fa5bf9f..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/log/log-item.module.scss.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare const classNames: { - readonly item: "item"; - readonly shiki: "shiki"; - readonly dark: "dark"; -}; -export default classNames; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/log/log-item.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/log/log-item.tsx deleted file mode 100644 index ad7cfa3c6b..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/log/log-item.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import { classNames } from "@/utils"; -import { formatAnsi } from "@/utils/shiki"; -import { Box, styled, useTheme } from "@mui/material"; -import React, { useEffect, useState } from "react"; -import styles from "./log-item.module.scss"; - -const Item = styled(Box)(({ theme: { palette, typography } }) => ({ - padding: "8px 0", - margin: "0 12px", - lineHeight: 1.35, - borderBottom: `1px solid ${palette.divider}`, - fontSize: "0.875rem", - fontFamily: typography.fontFamily, - userSelect: "text", - "& .time": { - color: palette.text.secondary, - fontWeight: "thin", - }, - "& .type": { - display: "inline-block", - marginLeft: 8, - textAlign: "center", - borderRadius: 2, - textTransform: "uppercase", - fontWeight: "600", - }, - '& .type[data-type="error"], & .type[data-type="err"]': { - color: palette.error.main, - }, - '& .type[data-type="warning"], & .type[data-type="warn"]': { - color: palette.warning.main, - }, - '& .type[data-type="info"], & .type[data-type="inf"]': { - color: palette.info.main, - }, - "& .data": { - color: palette.text.primary, - }, -})); - -interface Props { - value: ILogItem; - index: number; -} - -const LogItem = (props: Props) => { - const theme = useTheme(); - const { value, index } = props; - const [payload, setPayload] = useState(value.payload); - useEffect(() => { - formatAnsi(value.payload).then((res) => { - setPayload(res); - }); - }, [value.payload]); - - return ( - -
- {value.time} - - {value.type} - -
-
- -
-
- ); -}; - -export default LogItem; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/profile/editor-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/profile/editor-viewer.tsx deleted file mode 100644 index 3dc9f35cba..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/profile/editor-viewer.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import { readProfileFile, saveProfileFile } from "@/services/cmds"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, -} from "@mui/material"; -import { useLockFn } from "ahooks"; -import { useEffect, useRef } from "react"; -import { useTranslation } from "react-i18next"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { monaco } from "@/services/monaco"; -import { useAtomValue } from "jotai"; -import { themeMode as atomThemeMode } from "@/store"; - -interface Props { - uid: string; - open: boolean; - mode: "yaml" | "javascript"; - onClose: () => void; - onChange?: () => void; -} - -export const EditorViewer = (props: Props) => { - const { uid, open, mode, onClose, onChange } = props; - - const { t } = useTranslation(); - const editorRef = useRef(); - const instanceRef = useRef(null); - const themeMode = useAtomValue(atomThemeMode); - - useEffect(() => { - if (!open) return; - - readProfileFile(uid).then((data) => { - const dom = editorRef.current; - - if (!dom) return; - if (instanceRef.current) instanceRef.current.dispose(); - - instanceRef.current = monaco.editor.create(editorRef.current, { - value: data, - language: mode, - theme: themeMode === "light" ? "vs" : "vs-dark", - minimap: { enabled: false }, - }); - }); - - return () => { - if (instanceRef.current) { - instanceRef.current.dispose(); - instanceRef.current = null; - } - }; - }, [open]); - - const onSave = useLockFn(async () => { - const value = instanceRef.current?.getValue(); - - if (value == null) return; - - try { - await saveProfileFile(uid, value); - onChange?.(); - onClose(); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } - }); - - return ( - - {t("Edit File")} - - -
- - - - - - -
- ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/profile/file-input.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/profile/file-input.tsx deleted file mode 100644 index 5357224a46..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/profile/file-input.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { useRef, useState } from "react"; -import { useLockFn } from "ahooks"; -import { useTranslation } from "react-i18next"; -import { Box, Button, Typography } from "@mui/material"; - -interface Props { - onChange: (value: string) => void; -} - -export const FileInput = (props: Props) => { - const { onChange } = props; - - const { t } = useTranslation(); - // file input - const inputRef = useRef(); - const [loading, setLoading] = useState(false); - const [fileName, setFileName] = useState(""); - - const onFileInput = useLockFn(async (e: any) => { - const file = e.target.files?.[0] as File; - - if (!file) return; - - setFileName(file.name); - setLoading(true); - - return new Promise((resolve, reject) => { - const reader = new FileReader(); - reader.onload = (event) => { - resolve(null); - onChange(event.target?.result as string); - }; - reader.onerror = reject; - reader.readAsText(file); - }).finally(() => setLoading(false)); - }); - - return ( - - - - - - - {loading ? "Loading..." : fileName} - - - ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/profile/log-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/profile/log-viewer.tsx deleted file mode 100644 index 4792468371..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/profile/log-viewer.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { Fragment } from "react"; -import { useTranslation } from "react-i18next"; -import { - Button, - Chip, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - Divider, - Typography, -} from "@mui/material"; -import { BaseEmpty } from "@/components/base"; - -interface Props { - open: boolean; - logInfo: [string, string][]; - onClose: () => void; -} - -export const LogViewer = (props: Props) => { - const { open, logInfo, onClose } = props; - - const { t } = useTranslation(); - - return ( - - {t("Script Console")} - - - {logInfo.map(([level, log], index) => ( - - - - {log} - - - - ))} - - {logInfo.length === 0 && } - - - - - - - ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-box.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-box.tsx deleted file mode 100644 index ea00b36898..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-box.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { alpha, Box, styled } from "@mui/material"; - -export const ProfileBox = styled(Box)(({ - theme, - "aria-selected": selected, -}) => { - const { mode, primary, text, grey, background } = theme.palette; - const key = `${mode}-${!!selected}`; - - const backgroundColor = { - "light-true": alpha(primary.main, 0.2), - "light-false": alpha(background.paper, 0.75), - "dark-true": alpha(primary.main, 0.45), - "dark-false": alpha(grey[700], 0.45), - }[key]!; - - const color = { - "light-true": text.secondary, - "light-false": text.secondary, - "dark-true": alpha(text.secondary, 0.85), - "dark-false": alpha(text.secondary, 0.65), - }[key]!; - - const h2color = { - "light-true": primary.main, - "light-false": text.primary, - "dark-true": primary.light, - "dark-false": text.primary, - }[key]!; - - return { - position: "relative", - width: "100%", - display: "block", - cursor: "pointer", - textAlign: "left", - borderRadius: 14, - boxShadow: theme.shadows[2], - padding: "10px 14px", - boxSizing: "border-box", - backgroundColor, - color, - "& h2": { color: h2color }, - }; -}); diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-item.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-item.tsx deleted file mode 100644 index 8396de2e8b..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-item.tsx +++ /dev/null @@ -1,389 +0,0 @@ -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { deleteProfile, updateProfile, viewProfile } from "@/services/cmds"; -import parseTraffic from "@/utils/parse-traffic"; -import { useSortable } from "@dnd-kit/sortable"; -import { CSS } from "@dnd-kit/utilities"; -import { DragIndicator, RefreshRounded } from "@mui/icons-material"; -import { - Box, - CircularProgress, - IconButton, - LinearProgress, - Menu, - MenuItem, - Paper, - Typography, - keyframes, -} from "@mui/material"; -import { useLockFn } from "ahooks"; -import dayjs from "dayjs"; -import { useEffect, useState } from "react"; -import { useTranslation } from "react-i18next"; -import { mutate } from "swr"; -import { EditorViewer } from "./editor-viewer"; -import { ProfileBox } from "./profile-box"; -import { useAtom } from "jotai"; -import { atomLoadingCache } from "@/store"; - -const round = keyframes` - from { transform: rotate(0deg); } - to { transform: rotate(360deg); } -`; - -interface Props { - id: string; - selected: boolean; - activating: boolean; - itemData: IProfileItem; - onSelect: (force: boolean) => void; - onEdit: () => void; -} - -export const ProfileItem = (props: Props) => { - const { selected, activating, itemData, onSelect, onEdit } = props; - - const { attributes, listeners, setNodeRef, transform, transition } = - useSortable({ id: props.id }); - - const { t } = useTranslation(); - const [anchorEl, setAnchorEl] = useState(null); - const [position, setPosition] = useState({ left: 0, top: 0 }); - const [loadingCache, setLoadingCache] = useAtom(atomLoadingCache); - - const { uid, name = "Profile", extra, updated = 0 } = itemData; - - // local file mode - // remote file mode - const hasUrl = !!itemData.url; - const hasExtra = !!extra; // only subscription url has extra info - - const { upload = 0, download = 0, total = 0 } = extra ?? {}; - const from = parseUrl(itemData.url); - const expire = parseExpire(extra?.expire); - const progress = Math.round(((download + upload) * 100) / (total + 0.1)); - - const loading = loadingCache[itemData.uid] ?? false; - - // interval update fromNow field - const [, setRefresh] = useState({}); - useEffect(() => { - if (!hasUrl) return; - - let timer: any = null; - - const handler = () => { - const now = Date.now(); - const lastUpdate = updated * 1000; - // 大于一天的不管 - if (now - lastUpdate >= 24 * 36e5) return; - - const wait = now - lastUpdate >= 36e5 ? 30e5 : 5e4; - - timer = setTimeout(() => { - setRefresh({}); - handler(); - }, wait); - }; - - handler(); - - return () => { - if (timer) clearTimeout(timer); - }; - }, [hasUrl, updated]); - - const [fileOpen, setFileOpen] = useState(false); - - const onEditInfo = () => { - setAnchorEl(null); - onEdit(); - }; - - const onEditFile = () => { - setAnchorEl(null); - setFileOpen(true); - }; - - const onForceSelect = () => { - setAnchorEl(null); - onSelect(true); - }; - - const onOpenFile = useLockFn(async () => { - setAnchorEl(null); - try { - await viewProfile(itemData.uid); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } - }); - - /// 0 不使用任何代理 - /// 1 使用配置好的代理 - /// 2 至少使用一个代理,根据配置,如果没配置,默认使用系统代理 - const onUpdate = useLockFn(async (type: 0 | 1 | 2) => { - setAnchorEl(null); - setLoadingCache((cache) => ({ ...cache, [itemData.uid]: true })); - - const option: Partial = {}; - - if (type === 0) { - option.with_proxy = false; - option.self_proxy = false; - } else if (type === 1) { - // nothing - } else if (type === 2) { - if (itemData.option?.self_proxy) { - option.with_proxy = false; - option.self_proxy = true; - } else { - option.with_proxy = true; - option.self_proxy = false; - } - } - - try { - await updateProfile(itemData.uid, option); - mutate("getProfiles"); - } catch (err: any) { - const errmsg = err?.message || err.toString(); - useNotification({ - title: t("Error"), - body: - err.message || - errmsg.replace(/error sending request for url (\S+?): /, ""), - type: NotificationType.Error, - }); - } finally { - setLoadingCache((cache) => ({ ...cache, [itemData.uid]: false })); - } - }); - - const onDelete = useLockFn(async () => { - setAnchorEl(null); - try { - await deleteProfile(itemData.uid); - mutate("getProfiles"); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } - }); - - const urlModeMenu = [ - { label: "Select", handler: onForceSelect }, - { label: "Edit Info", handler: onEditInfo }, - { label: "Edit File", handler: onEditFile }, - { label: "Open File", handler: onOpenFile }, - { label: "Update", handler: () => onUpdate(0) }, - { label: "Update(Proxy)", handler: () => onUpdate(2) }, - { label: "Delete", handler: onDelete }, - ]; - const fileModeMenu = [ - { label: "Select", handler: onForceSelect }, - { label: "Edit Info", handler: onEditInfo }, - { label: "Edit File", handler: onEditFile }, - { label: "Open File", handler: onOpenFile }, - { label: "Delete", handler: onDelete }, - ]; - - const boxStyle = { - height: 26, - display: "flex", - alignItems: "center", - justifyContent: "space-between", - }; - - return ( - - onSelect(false)} - onContextMenu={(event) => { - const { clientX, clientY } = event; - setPosition({ top: clientY, left: clientX }); - setAnchorEl(event.currentTarget); - event.preventDefault(); - }} - sx={{ - borderRadius: 4, - }} - > - {activating && ( - - - - )} - - - - - - - - - {name} - - - - {/* only if has url can it be updated */} - {hasUrl && ( - { - e.stopPropagation(); - onUpdate(1); - }} - > - - - )} - - - {/* the second line show url's info or description */} - - {hasUrl ? ( - <> - - {from} - - - - {updated > 0 ? dayjs(updated * 1000).fromNow() : ""} - - - ) : ( - - {itemData.desc} - - )} - - - {/* the third line show extra info or last updated time */} - {hasExtra ? ( - - - {parseTraffic(upload + download)} / {parseTraffic(total)} - - {expire} - - ) : ( - - {parseExpire(updated)} - - )} - - - - - setAnchorEl(null)} - anchorPosition={position} - anchorReference="anchorPosition" - transitionDuration={225} - MenuListProps={{ sx: { py: 0.5 } }} - onContextMenu={(e) => { - setAnchorEl(null); - e.preventDefault(); - }} - > - {(hasUrl ? urlModeMenu : fileModeMenu).map((item) => ( - - {t(item.label)} - - ))} - - - setFileOpen(false)} - /> - - ); -}; - -function parseUrl(url?: string) { - if (!url) return ""; - const regex = /https?:\/\/(.+?)\//; - const result = url.match(regex); - return result ? result[1] : "local file"; -} - -function parseExpire(expire?: number) { - if (!expire) return "-"; - return dayjs(expire * 1000).format("YYYY-MM-DD"); -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-more.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-more.tsx deleted file mode 100644 index d1cb33c4ff..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-more.tsx +++ /dev/null @@ -1,247 +0,0 @@ -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { viewProfile } from "@/services/cmds"; -import { FeaturedPlayListRounded } from "@mui/icons-material"; -import { - Badge, - Box, - Chip, - IconButton, - Menu, - MenuItem, - Typography, -} from "@mui/material"; -import { useLockFn } from "ahooks"; -import dayjs from "dayjs"; -import { useState } from "react"; -import { useTranslation } from "react-i18next"; -import { EditorViewer } from "./editor-viewer"; -import { LogViewer } from "./log-viewer"; -import { ProfileBox } from "./profile-box"; - -interface Props { - selected: boolean; - itemData: IProfileItem; - enableNum: number; - logInfo?: [string, string][]; - onEnable: () => void; - onDisable: () => void; - onMoveTop: () => void; - onMoveEnd: () => void; - onDelete: () => void; - onEdit: () => void; -} - -// profile enhanced item -export const ProfileMore = (props: Props) => { - const { - selected, - itemData, - enableNum, - logInfo = [], - onEnable, - onDisable, - onMoveTop, - onMoveEnd, - onDelete, - onEdit, - } = props; - - const { uid, type } = itemData; - const { t, i18n } = useTranslation(); - const [anchorEl, setAnchorEl] = useState(null); - const [position, setPosition] = useState({ left: 0, top: 0 }); - const [fileOpen, setFileOpen] = useState(false); - const [logOpen, setLogOpen] = useState(false); - - const onEditInfo = () => { - setAnchorEl(null); - onEdit(); - }; - - const onEditFile = () => { - setAnchorEl(null); - setFileOpen(true); - }; - - const onOpenFile = useLockFn(async () => { - setAnchorEl(null); - try { - await viewProfile(itemData.uid); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } - }); - - const fnWrapper = (fn: () => void) => () => { - setAnchorEl(null); - return fn(); - }; - - const hasError = !!logInfo.find((e) => e[0] === "exception"); - const showMove = enableNum > 1 && !hasError; - - const enableMenu = [ - { label: "Disable", handler: fnWrapper(onDisable) }, - { label: "Edit Info", handler: onEditInfo }, - { label: "Edit File", handler: onEditFile }, - { label: "Open File", handler: onOpenFile }, - { label: "To Top", show: showMove, handler: fnWrapper(onMoveTop) }, - { label: "To End", show: showMove, handler: fnWrapper(onMoveEnd) }, - { label: "Delete", handler: fnWrapper(onDelete) }, - ]; - - const disableMenu = [ - { label: "Enable", handler: fnWrapper(onEnable) }, - { label: "Edit Info", handler: onEditInfo }, - { label: "Edit File", handler: onEditFile }, - { label: "Open File", handler: onOpenFile }, - { label: "Delete", handler: fnWrapper(onDelete) }, - ]; - - const boxStyle = { - height: 26, - display: "flex", - alignItems: "center", - justifyContent: "space-between", - lineHeight: 1, - }; - - return ( - <> - onSelect(false)} - onContextMenu={(event) => { - const { clientX, clientY } = event; - setPosition({ top: clientY, left: clientX }); - setAnchorEl(event.currentTarget); - event.preventDefault(); - }} - > - - - {itemData.name} - - - - - - - {selected && type === "script" ? ( - hasError ? ( - - setLogOpen(true)} - > - - - - ) : ( - setLogOpen(true)} - > - - - ) - ) : ( - - {itemData.desc} - - )} - - - {!!itemData.updated - ? dayjs(itemData.updated! * 1000).fromNow() - : ""} - - - - - setAnchorEl(null)} - anchorPosition={position} - anchorReference="anchorPosition" - transitionDuration={225} - MenuListProps={{ sx: { py: 0.5 } }} - onContextMenu={(e) => { - setAnchorEl(null); - e.preventDefault(); - }} - > - {(selected ? enableMenu : disableMenu) - .filter((item: any) => item.show !== false) - .map((item) => ( - - {t(item.label)} - - ))} - - - setFileOpen(false)} - /> - - {selected && ( - setLogOpen(false)} - /> - )} - - ); -}; - -function parseExpire(expire?: number) { - if (!expire) return "-"; - return dayjs(expire * 1000).format("YYYY-MM-DD"); -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-viewer.tsx deleted file mode 100644 index f47132b0c8..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/profile/profile-viewer.tsx +++ /dev/null @@ -1,294 +0,0 @@ -import { BaseDialog } from "@/components/base"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { createProfile, patchProfile } from "@/services/cmds"; -import { - Box, - FormControl, - InputAdornment, - InputLabel, - MenuItem, - Select, - TextField, - styled, -} from "@mui/material"; -import { useLockFn } from "ahooks"; -import { - forwardRef, - useEffect, - useImperativeHandle, - useRef, - useState, -} from "react"; -import { Controller, useForm } from "react-hook-form"; -import { useTranslation } from "react-i18next"; -import { version } from "~/package.json"; -import MDYSwitch from "../common/mdy-switch"; -import { FileInput } from "./file-input"; - -interface Props { - onChange: () => void; - url?: string; - name?: string; - desc?: string; -} - -export interface ProfileViewerRef { - create: () => void; - edit: (item: IProfileItem) => void; -} - -// create or edit the profile -// remote / local / merge / script -export const ProfileViewer = forwardRef( - (props, ref) => { - const { t } = useTranslation(); - const [open, setOpen] = useState(false); - const [openType, setOpenType] = useState<"new" | "edit">("new"); - const [loading, setLoading] = useState(false); - - // file input - const fileDataRef = useRef(null); - - const { control, watch, register, ...formIns } = useForm({ - defaultValues: { - type: "remote", - name: "Remote File", - desc: "", - url: props.url ?? "", - option: { - // user_agent: "", - with_proxy: false, - self_proxy: false, - }, - }, - }); - - useImperativeHandle(ref, () => ({ - create: () => { - setOpenType("new"); - setOpen(true); - }, - edit: (item) => { - if (item) { - Object.entries(item).forEach(([key, value]) => { - formIns.setValue(key as any, value); - }); - } - setOpenType("edit"); - setOpen(true); - }, - })); - - const selfProxy = watch("option.self_proxy"); - const withProxy = watch("option.with_proxy"); - - useEffect(() => { - if (selfProxy) formIns.setValue("option.with_proxy", false); - }, [selfProxy]); - - useEffect(() => { - if (withProxy) formIns.setValue("option.self_proxy", false); - }, [withProxy]); - - const handleOk = useLockFn( - formIns.handleSubmit(async (form) => { - setLoading(true); - try { - if (!form.type) throw new Error("`Type` should not be null"); - if (form.type === "remote" && !form.url) { - throw new Error("The URL should not be null"); - } - if (form.type !== "remote" && form.type !== "local") { - delete form.option; - } - if (form.option?.update_interval) { - form.option.update_interval = +form.option.update_interval; - } - const name = form.name || `${form.type} file`; - const item = { ...form, name }; - - // 创建 - if (openType === "new") { - await createProfile(item, fileDataRef.current); - } - // 编辑 - else { - if (!form.uid) throw new Error("UID not found"); - await patchProfile(form.uid, item); - } - setOpen(false); - setLoading(false); - setTimeout(() => formIns.reset(), 500); - fileDataRef.current = null; - props.onChange(); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - setLoading(false); - } - }), - ); - - const handleClose = () => { - setOpen(false); - fileDataRef.current = null; - setTimeout(() => formIns.reset(), 500); - }; - - const text = { - fullWidth: true, - size: "small", - margin: "normal", - variant: "outlined", - autoComplete: "off", - autoCorrect: "off", - } as const; - - const formType = watch("type"); - const isRemote = formType === "remote"; - const isLocal = formType === "local"; - - return ( - - ( - - {t("Type")} - - - )} - /> - - ( - - )} - /> - - ( - - )} - /> - - {isRemote && ( - <> - ( - - )} - /> - - ( - - )} - /> - - )} - - {(isRemote || isLocal) && ( - ( - { - e.target.value = e.target.value - ?.replace(/\D/, "") - .slice(0, 10); - field.onChange(e); - }} - label={t("Update Interval")} - InputProps={{ - endAdornment: ( - mins - ), - }} - /> - )} - /> - )} - - {isLocal && openType === "new" && ( - (fileDataRef.current = val)} /> - )} - - {isRemote && ( - <> - ( - - {t("Use System Proxy")} - - - )} - /> - - ( - - {t("Use Clash Proxy")} - - - )} - /> - - )} - - ); - }, -); - -ProfileViewer.displayName = "ProfileViewer"; - -const StyledBox = styled(Box)(() => ({ - margin: "8px 0 8px 8px", - display: "flex", - alignItems: "center", - justifyContent: "space-between", -})); diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/delay-chip.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/delay-chip.tsx new file mode 100644 index 0000000000..087821be8d --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/delay-chip.tsx @@ -0,0 +1,69 @@ +import { memo, useState } from "react"; +import FeatureChip from "./feature-chip"; +import { getColorForDelay } from "./utils"; +import { classNames } from "@/utils"; +import { CircularProgress } from "@mui/material"; + +export const DelayChip = memo(function DelayChip({ + delay, + onClick, +}: { + delay: number; + onClick: () => Promise; +}) { + const [loading, setLoading] = useState(false); + + const handleClick = async () => { + try { + setLoading(true); + + await onClick(); + } finally { + setLoading(false); + } + }; + + return ( + + + {delay ? `${delay} ms` : "timeout"} + + + + + } + variant="filled" + onClick={(e) => { + e.preventDefault(); + e.stopPropagation(); + handleClick(); + }} + /> + ); +}); + +export default DelayChip; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/feature-chip.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/feature-chip.tsx new file mode 100644 index 0000000000..533a119850 --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/feature-chip.tsx @@ -0,0 +1,24 @@ +import { Chip, ChipProps } from "@mui/material"; +import { memo } from "react"; + +export const FeatureChip = memo(function FeatureChip(props: ChipProps) { + return ( + + ); +}); + +export default FeatureChip; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/group-list.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/group-list.tsx index 7fbf8fed7d..e24c095f5f 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/group-list.tsx +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/group-list.tsx @@ -44,7 +44,11 @@ export const GroupList = (listItemButtonProps: ListItemButtonProps) => { > {group.icon && } - + ); diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/node-card.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/node-card.tsx new file mode 100644 index 0000000000..2b815cd834 --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/node-card.tsx @@ -0,0 +1,45 @@ +import { Clash } from "@nyanpasu/interface"; +import { CSSProperties, memo, useMemo } from "react"; +import { filterDelay } from "./utils"; +import { PaperSwitchButton } from "../setting/modules/system-proxy"; +import Box from "@mui/material/Box"; +import FeatureChip from "./feature-chip"; +import DelayChip from "./delay-chip"; + +export const NodeCard = memo(function NodeCard({ + node, + now, + disabled, + onClick, + onClickDelay, + style, +}: { + node: Clash.Proxy; + now?: string; + disabled?: boolean; + onClick: () => void; + onClickDelay: () => Promise; + style?: CSSProperties; +}) { + const delay = useMemo(() => filterDelay(node.history), [node.history]); + + return ( + + + + + {node.udp && } + + + + + ); +}); + +export default NodeCard; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/node-list.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/node-list.tsx index 915fc1faa1..b5469417aa 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/node-list.tsx +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/node-list.tsx @@ -1,180 +1,16 @@ -import { - Box, - Chip, - ChipProps, - CircularProgress, - useTheme, -} from "@mui/material"; -import { PaperSwitchButton } from "../setting/modules/system-proxy"; import { Clash, useClashCore, useNyanpasu } from "@nyanpasu/interface"; import { useBreakpoint } from "@nyanpasu/ui"; import { useAtom, useAtomValue } from "jotai"; import { proxyGroupAtom, proxyGroupSortAtom } from "@/store"; -import { - CSSProperties, - memo, - useEffect, - useMemo, - useState, - useTransition, -} from "react"; +import { useCallback, useEffect, useState, useTransition } from "react"; import { classNames } from "@/utils"; import { VList } from "virtua"; import { AnimatePresence, motion } from "framer-motion"; - -type History = Clash.Proxy["history"]; +import { filterDelay } from "./utils"; +import NodeCard from "./node-card"; type RenderClashProxy = Clash.Proxy & { renderLayoutKey: string }; -const filterDelay = (history?: History): number => { - if (!history || history.length == 0) { - return 0; - } else { - return history[history.length - 1].delay; - } -}; - -const getColorForDelay = (delay: number): string => { - const { palette } = useTheme(); - - const delayColorMapping: { [key: string]: string } = { - "0": palette.error.main, - "1": palette.text.secondary, - "100": palette.success.main, - "500": palette.warning.main, - "10000": palette.error.main, - }; - - let color: string = palette.text.secondary; - - for (const key in delayColorMapping) { - if (delay <= parseInt(key)) { - color = delayColorMapping[key]; - break; - } - } - - return color; -}; - -const FeatureChip = memo(function FeatureChip(props: ChipProps) { - return ( - - ); -}); - -const DelayChip = memo(function DelayChip({ - delay, - onClick, -}: { - delay: number; - onClick: () => Promise; -}) { - const [loading, setLoading] = useState(false); - - const handleClick = async () => { - try { - setLoading(true); - - await onClick(); - } finally { - setLoading(false); - } - }; - - return ( - - - {delay ? `${delay} ms` : "timeout"} - - - - - } - variant="filled" - onClick={(e) => { - e.preventDefault(); - e.stopPropagation(); - handleClick(); - }} - /> - ); -}); - -const NodeCard = memo(function NodeCard({ - node, - now, - disabled, - onClick, - onClickDelay, - style, -}: { - node: Clash.Proxy; - now?: string; - disabled?: boolean; - onClick: () => void; - onClickDelay: () => Promise; - style?: CSSProperties; -}) { - const delay = useMemo(() => filterDelay(node.history), [node.history]); - - return ( - - - - - {node.udp && } - - - - - ); -}); - export const NodeList = () => { const { data, setGroupProxy, setGlobalProxy, updateProxiesDelay } = useClashCore(); @@ -189,7 +25,7 @@ export const NodeList = () => { const [group, setGroup] = useState>>(); - useEffect(() => { + const sortGroup = useCallback(() => { if (!getCurrentMode.global) { if (proxyGroup.selector !== null) { const selectedGroup = data?.groups[proxyGroup.selector]; @@ -225,7 +61,17 @@ export const NodeList = () => { } else { setGroup(data?.global); } - }, [data?.groups, proxyGroup.selector, getCurrentMode, proxyGroupSort]); + }, [ + data?.groups, + proxyGroup.selector, + getCurrentMode, + proxyGroupSort, + setGroup, + ]); + + useEffect(() => { + sortGroup(); + }, [sortGroup]); const { column } = useBreakpoint({ sm: 1, @@ -287,6 +133,10 @@ export const NodeList = () => { } }; + const { nyanpasuConfig } = useNyanpasu(); + + const disableMotion = nyanpasuConfig?.lighten_animation_effects; + return ( { style={{ gridTemplateColumns: `repeat(${column} , 1fr)` }} > {node.map((render) => { - return ( + const Card = () => ( + hendleClick(render.name)} + onClickDelay={async () => { + await updateProxiesDelay(render.name); + }} + /> + ); + + return disableMotion ? ( +
+ +
+ ) : ( { animate={{ scale: 1, opacity: 1 }} exit={{ opacity: 0 }} > - hendleClick(render.name)} - onClickDelay={async () => { - await updateProxiesDelay(render.name); - }} - /> + ); })} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/proxy-group-name.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/proxy-group-name.tsx new file mode 100644 index 0000000000..fd191a552c --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/proxy-group-name.tsx @@ -0,0 +1,31 @@ +import { useNyanpasu } from "@nyanpasu/interface"; +import { AnimatePresence, motion } from "framer-motion"; +import { memo } from "react"; + +export const ProxyGroupName = memo(function ProxyGroupName({ + name, +}: { + name: string; +}) { + const { nyanpasuConfig } = useNyanpasu(); + + const disbaleMotion = nyanpasuConfig?.lighten_animation_effects; + + return disbaleMotion ? ( + <>{name} + ) : ( + + + {name} + + + ); +}); + +export default ProxyGroupName; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/sort-selector.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/sort-selector.tsx new file mode 100644 index 0000000000..75484fbdb4 --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/sort-selector.tsx @@ -0,0 +1,55 @@ +import { proxyGroupSortAtom } from "@/store"; +import { Button, Menu, MenuItem } from "@mui/material"; +import { useAtom } from "jotai"; +import { memo, useState } from "react"; +import { useTranslation } from "react-i18next"; + +export const SortSelector = memo(function SortSelector() { + const { t } = useTranslation(); + + const [proxyGroupSort, setProxyGroupSort] = useAtom(proxyGroupSortAtom); + + type SortType = typeof proxyGroupSort; + + const [anchorEl, setAnchorEl] = useState(null); + + const handleClick = (sort: SortType) => { + setAnchorEl(null); + setProxyGroupSort(sort); + }; + + const tmaps: { [key: string]: string } = { + default: "Sort by default", + delay: "Sort by delay", + name: "Sort by name", + }; + + return ( + <> + + + setAnchorEl(null)} + > + {Object.entries(tmaps).map(([key, value], index) => { + return ( + handleClick(key as SortType)}> + {t(value)} + + ); + })} + + + ); +}); + +export default SortSelector; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/utils.ts b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/utils.ts new file mode 100644 index 0000000000..726979817c --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/proxies/utils.ts @@ -0,0 +1,35 @@ +import { useTheme } from "@mui/material"; +import { Clash } from "@nyanpasu/interface"; + +export type History = Clash.Proxy["history"]; + +export const filterDelay = (history?: History): number => { + if (!history || history.length == 0) { + return 0; + } else { + return history[history.length - 1].delay; + } +}; + +export const getColorForDelay = (delay: number): string => { + const { palette } = useTheme(); + + const delayColorMapping: { [key: string]: string } = { + "0": palette.error.main, + "1": palette.text.secondary, + "100": palette.success.main, + "500": palette.warning.main, + "10000": palette.error.main, + }; + + let color: string = palette.text.secondary; + + for (const key in delayColorMapping) { + if (delay <= parseInt(key)) { + color = delayColorMapping[key]; + break; + } + } + + return color; +}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/provider-button.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/provider-button.tsx deleted file mode 100644 index 4dd0e46c0c..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/provider-button.tsx +++ /dev/null @@ -1,87 +0,0 @@ -import { getProviders } from "@/services/api"; -import { updateProxyProvider } from "@/services/cmds"; -import { RefreshRounded } from "@mui/icons-material"; -import { - Button, - IconButton, - List, - ListItem, - ListItemText, -} from "@mui/material"; -import { useLockFn } from "ahooks"; -import dayjs from "dayjs"; -import { useState } from "react"; -import { useTranslation } from "react-i18next"; -import useSWR, { mutate } from "swr"; -import { BaseDialog } from "../base"; - -export const ProviderButton = () => { - const { t } = useTranslation(); - const { data } = useSWR("getProviders", getProviders); - - const [open, setOpen] = useState(false); - - const hasProvider = Object.keys(data || {}).length > 0; - - const handleUpdate = useLockFn(async (key: string) => { - await updateProxyProvider(key); - await mutate("getProxies"); - await mutate("getProviders"); - }); - - if (!hasProvider) return null; - - return ( - <> - - - setOpen(false)} - onCancel={() => setOpen(false)} - > - - {Object.entries(data || {}).map(([key, item]) => { - const time = dayjs(item.updatedAt); - return ( - - - - Type: {item.vehicleType} - - - Updated: {time.fromNow()} - - - } - /> - handleUpdate(key)} - > - - - - ); - })} - - - - ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-group.module.scss b/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-group.module.scss deleted file mode 100644 index 4ee748f57c..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-group.module.scss +++ /dev/null @@ -1,7 +0,0 @@ -.proxyVirtuoso { - :global(div[data-viewport-type="element"]) { - width: calc(100% - 28px * 2) !important; - height: calc(100% - 28px) !important; - padding: 14px 28px; - } -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-group.module.scss.d.ts b/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-group.module.scss.d.ts deleted file mode 100644 index 1274ce3f47..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-group.module.scss.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare const classNames: { - readonly proxyVirtuoso: "proxyVirtuoso"; -}; -export = classNames; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-groups.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-groups.tsx deleted file mode 100644 index ae6504e864..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-groups.tsx +++ /dev/null @@ -1,140 +0,0 @@ -import { useProfiles } from "@/hooks/use-profiles"; -import { useVerge } from "@/hooks/use-verge"; -import { - // updateProxy, - deleteConnection, - getConnections, - providerHealthCheck, -} from "@/services/api"; -import { selectProxy } from "@/services/cmds"; -import delayManager from "@/services/delay"; -import { classNames } from "@/utils"; -import { useLockFn } from "ahooks"; -import { useRef } from "react"; -import { Virtuoso, type VirtuosoHandle } from "react-virtuoso"; -import { BaseEmpty } from "../base"; -import styles from "./proxy-group.module.scss"; -import { ProxyRender } from "./proxy-render"; -import { useRenderList } from "./use-render-list"; - -interface Props { - mode: string; -} - -export const ProxyGroups = (props: Props) => { - const { mode } = props; - - const { renderList, onProxies, onHeadState } = useRenderList(mode); - - const { verge } = useVerge(); - const { current, patchCurrent } = useProfiles(); - - const virtuosoRef = useRef(null); - - // 切换分组的节点代理 - const handleChangeProxy = useLockFn( - async (group: IProxyGroupItem, proxy: IProxyItem) => { - if (group.type !== "Selector" && group.type !== "Fallback") return; - - const { name, now } = group; - await selectProxy(name, proxy.name); - onProxies(); - - // 断开连接 - if (verge?.auto_close_connection) { - getConnections().then(({ connections }) => { - connections.forEach((conn) => { - if (conn.chains.includes(now!)) { - deleteConnection(conn.id); - } - }); - }); - } - - // 保存到selected中 - if (!current) return; - if (!current.selected) current.selected = []; - - const index = current.selected.findIndex( - (item) => item.name === group.name, - ); - - if (index < 0) { - current.selected.push({ name, now: proxy.name }); - } else { - current.selected[index] = { name, now: proxy.name }; - } - await patchCurrent({ selected: current.selected }); - }, - ); - - // 测全部延迟 - const handleCheckAll = useLockFn(async (groupName: string) => { - const proxies = renderList - .filter( - (e) => e.group?.name === groupName && (e.type === 2 || e.type === 4), - ) - .flatMap((e) => e.proxyCol || e.proxy!) - .filter(Boolean); - - const providers = new Set(proxies.map((p) => p!.provider!).filter(Boolean)); - - if (providers.size) { - Promise.allSettled( - [...providers].map((p) => providerHealthCheck(p)), - ).then(() => onProxies()); - } - - const names = proxies.filter((p) => !p!.provider).map((p) => p!.name); - await delayManager.checkListDelay(names, groupName); - - onProxies(); - }); - - // 滚到对应的节点 - const handleLocation = (group: IProxyGroupItem) => { - if (!group) return; - const { name, now } = group; - - const index = renderList.findIndex( - (e) => - e.group?.name === name && - ((e.type === 2 && e.proxy?.name === now) || - (e.type === 4 && e.proxyCol?.some((p) => p.name === now))), - ); - - if (index >= 0) { - virtuosoRef.current?.scrollToIndex?.({ - index, - align: "center", - behavior: "smooth", - }); - } - }; - - if (mode === "direct") { - return ; - } - - return ( - ( - - )} - /> - ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-head.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-head.tsx deleted file mode 100644 index 8ca486d744..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-head.tsx +++ /dev/null @@ -1,162 +0,0 @@ -import { useVerge } from "@/hooks/use-verge"; -import delayManager from "@/services/delay"; -import { - AccessTimeRounded, - FilterAltOffRounded, - FilterAltRounded, - MyLocationRounded, - NetworkCheckRounded, - SortByAlphaRounded, - SortRounded, - VisibilityOffRounded, - VisibilityRounded, - WifiTetheringOffRounded, - WifiTetheringRounded, -} from "@mui/icons-material"; -import { Box, IconButton, SxProps, TextField } from "@mui/material"; -import { useEffect, useState } from "react"; -import { useTranslation } from "react-i18next"; -import type { ProxySortType } from "./use-filter-sort"; -import type { HeadState } from "./use-head-state"; - -interface Props { - sx?: SxProps; - groupName: string; - headState: HeadState; - onLocation: () => void; - onCheckDelay: () => void; - onHeadState: (val: Partial) => void; -} - -export const ProxyHead = (props: Props) => { - const { sx = {}, groupName, headState, onHeadState } = props; - - const { showType, sortType, filterText, textState, testUrl } = headState; - - const { t } = useTranslation(); - const [autoFocus, setAutoFocus] = useState(false); - - useEffect(() => { - // fix the focus conflict - const timer = setTimeout(() => setAutoFocus(true), 100); - return () => clearTimeout(timer); - }, []); - - const { verge } = useVerge(); - - useEffect(() => { - delayManager.setUrl(groupName, testUrl || verge!.default_latency_test!); - }, [groupName, testUrl, verge?.default_latency_test]); - - return ( - - - - - - { - // Remind the user that it is custom test url - if (testUrl?.trim() && textState !== "filter") { - onHeadState({ textState: "url" }); - } - props.onCheckDelay(); - }} - > - - - - - onHeadState({ sortType: ((sortType + 1) % 3) as ProxySortType }) - } - > - {sortType !== 1 && sortType !== 2 && } - {sortType === 1 && } - {sortType === 2 && } - - - - onHeadState({ textState: textState === "url" ? null : "url" }) - } - > - {textState === "url" ? ( - - ) : ( - - )} - - - onHeadState({ showType: !showType })} - > - {showType ? : } - - - - onHeadState({ textState: textState === "filter" ? null : "filter" }) - } - > - {textState === "filter" ? ( - - ) : ( - - )} - - - {textState === "filter" && ( - onHeadState({ filterText: e.target.value })} - sx={{ ml: 0.5, flex: "1 1 auto", input: { py: 0.65, px: 1 } }} - /> - )} - - {textState === "url" && ( - onHeadState({ testUrl: e.target.value })} - sx={{ ml: 0.5, flex: "1 1 auto", input: { py: 0.65, px: 1 } }} - /> - )} - - ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-item-mini.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-item-mini.tsx deleted file mode 100644 index f02d0deaf7..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-item-mini.tsx +++ /dev/null @@ -1,181 +0,0 @@ -import { BaseLoading } from "@/components/base"; -import delayManager from "@/services/delay"; -import { CheckCircleOutlineRounded } from "@mui/icons-material"; -import { Box, ListItemButton, Typography, alpha, styled } from "@mui/material"; -import { useLockFn } from "ahooks"; -import { useEffect, useState } from "react"; - -interface Props { - groupName: string; - proxy: IProxyItem; - selected: boolean; - showType?: boolean; - onClick?: (name: string) => void; -} - -// 多列布局 -export const ProxyItemMini = (props: Props) => { - const { groupName, proxy, selected, showType = true, onClick } = props; - - // -1/<=0 为 不显示 - // -2 为 loading - const [delay, setDelay] = useState(-1); - - useEffect(() => { - delayManager.setListener(proxy.name, groupName, setDelay); - - return () => { - delayManager.removeListener(proxy.name, groupName); - }; - }, [proxy.name, groupName]); - - useEffect(() => { - if (!proxy) return; - setDelay(delayManager.getDelayFix(proxy, groupName)); - }, [proxy]); - - const onDelay = useLockFn(async () => { - setDelay(-2); - setDelay(await delayManager.checkDelay(proxy.name, groupName)); - }); - - return ( - onClick?.(proxy.name)} - sx={[ - { - height: 56, - borderRadius: 7, - pl: 2, - pr: 1, - justifyContent: "space-between", - alignItems: "center", - }, - ({ palette: { mode, primary } }) => { - const bgcolor = - mode === "light" - ? alpha(primary.main, 0.15) - : alpha(primary.main, 0.35); - const color = mode === "light" ? primary.main : primary.light; - const showDelay = delay > 0; - - const shadowColor = - mode === "light" ? "rgba(0,0,0,0.04)" : "rgba(255,255,255,0.08)"; - - return { - "&:hover .the-check": { display: !showDelay ? "block" : "none" }, - "&:hover .the-delay": { display: showDelay ? "block" : "none" }, - "&:hover .the-icon": { display: "none" }, - "&.Mui-selected": { bgcolor, boxShadow: `0 0 0 1px ${bgcolor}` }, - "&.Mui-selected .MuiListItemText-secondary": { color }, - boxShadow: `0 0 0 1px ${shadowColor}`, - }; - }, - ]} - > - - - {proxy.name} - - - {showType && ( - - {!!proxy.provider && ( - {proxy.provider} - )} - {proxy.type} - {proxy.udp && UDP} - - )} - - - - {delay === -2 && ( - - - - )} - - {!proxy.provider && delay !== -2 && ( - // provider的节点不支持检测 - { - e.preventDefault(); - e.stopPropagation(); - onDelay(); - }} - sx={({ palette }) => ({ - display: "none", // hover才显示 - ":hover": { bgcolor: alpha(palette.primary.main, 0.15) }, - })} - > - Check - - )} - - {delay > 0 && ( - // 显示延迟 - { - if (proxy.provider) return; - e.preventDefault(); - e.stopPropagation(); - onDelay(); - }} - color={delayManager.formatDelayColor(delay)} - sx={({ palette }) => - !proxy.provider - ? { ":hover": { bgcolor: alpha(palette.primary.main, 0.15) } } - : {} - } - > - {delayManager.formatDelay(delay)} - - )} - - {delay !== -2 && delay <= 0 && selected && ( - // 展示已选择的icon - - )} - - - ); -}; - -const Widget = styled(Box)(({ theme: { typography } }) => ({ - padding: "3px 6px", - fontSize: 14, - fontFamily: typography.fontFamily, - borderRadius: "4px", -})); - -const TypeBox = styled(Box)(({ theme: { palette, typography } }) => ({ - display: "inline-block", - border: "1px solid #ccc", - borderColor: alpha(palette.text.secondary, 0.36), - color: alpha(palette.text.secondary, 0.42), - borderRadius: 4, - fontSize: 10, - fontFamily: typography.fontFamily, - marginRight: "4px", - padding: "0 2px", - lineHeight: 1.25, -})); diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-item.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-item.tsx deleted file mode 100644 index 3fbcb5e06d..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-item.tsx +++ /dev/null @@ -1,170 +0,0 @@ -import { BaseLoading } from "@/components/base"; -import delayManager from "@/services/delay"; -import { CheckCircleOutlineRounded } from "@mui/icons-material"; -import { - Box, - ListItem, - ListItemButton, - ListItemIcon, - ListItemText, - SxProps, - Theme, - alpha, - styled, -} from "@mui/material"; -import { useLockFn } from "ahooks"; -import { useEffect, useState } from "react"; - -interface Props { - groupName: string; - proxy: IProxyItem; - selected: boolean; - showType?: boolean; - sx?: SxProps; - onClick?: (name: string) => void; -} - -const Widget = styled(Box)(() => ({ - padding: "3px 6px", - fontSize: 14, - borderRadius: "4px", -})); - -const TypeBox = styled(Box)(({ theme }) => ({ - display: "inline-block", - border: "1px solid #ccc", - borderColor: alpha(theme.palette.text.secondary, 0.36), - color: alpha(theme.palette.text.secondary, 0.42), - borderRadius: 4, - fontSize: 10, - marginRight: "4px", - padding: "0 2px", - lineHeight: 1.25, -})); - -export const ProxyItem = (props: Props) => { - const { groupName, proxy, selected, showType = true, sx, onClick } = props; - - // -1/<=0 为 不显示 - // -2 为 loading - const [delay, setDelay] = useState(-1); - - useEffect(() => { - delayManager.setListener(proxy.name, groupName, setDelay); - - return () => { - delayManager.removeListener(proxy.name, groupName); - }; - }, [proxy.name, groupName]); - - useEffect(() => { - if (!proxy) return; - setDelay(delayManager.getDelayFix(proxy, groupName)); - }, [proxy]); - - const onDelay = useLockFn(async () => { - setDelay(-2); - setDelay(await delayManager.checkDelay(proxy.name, groupName)); - }); - - return ( - - onClick?.(proxy.name)} - sx={[ - { borderRadius: 7 }, - ({ palette: { mode, primary } }) => { - const bgcolor = - mode === "light" - ? alpha(primary.main, 0.15) - : alpha(primary.main, 0.35); - const color = mode === "light" ? primary.main : primary.light; - const showDelay = delay > 0; - - return { - "&:hover .the-check": { display: !showDelay ? "block" : "none" }, - "&:hover .the-delay": { display: showDelay ? "block" : "none" }, - "&:hover .the-icon": { display: "none" }, - "&.Mui-selected": { bgcolor }, - "&.Mui-selected .MuiListItemText-secondary": { color }, - }; - }, - ]} - > - - {proxy.name} - - {showType && !!proxy.provider && ( - {proxy.provider} - )} - {showType && {proxy.type}} - {showType && proxy.udp && UDP} - - } - /> - - - {delay === -2 && ( - - - - )} - - {!proxy.provider && delay !== -2 && ( - // provider的节点不支持检测 - { - e.preventDefault(); - e.stopPropagation(); - onDelay(); - }} - sx={({ palette }) => ({ - display: "none", // hover才显示 - ":hover": { bgcolor: alpha(palette.primary.main, 0.15) }, - })} - > - Check - - )} - - {delay > 0 && ( - // 显示延迟 - { - if (proxy.provider) return; - e.preventDefault(); - e.stopPropagation(); - onDelay(); - }} - color={delayManager.formatDelayColor(delay)} - sx={({ palette }) => - !proxy.provider - ? { ":hover": { bgcolor: alpha(palette.primary.main, 0.15) } } - : {} - } - > - {delayManager.formatDelay(delay)} - - )} - - {delay !== -2 && delay <= 0 && selected && ( - // 展示已选择的icon - - )} - - - - ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-render.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-render.tsx deleted file mode 100644 index dfd4699fe9..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/proxy-render.tsx +++ /dev/null @@ -1,236 +0,0 @@ -import { - alpha, - Box, - ListItemText, - ListItemButton, - Typography, - styled, - Paper, - Divider, -} from "@mui/material"; -import { - ExpandLessRounded, - ExpandMoreRounded, - InboxRounded, -} from "@mui/icons-material"; -import { HeadState } from "./use-head-state"; -import { ProxyHead } from "./proxy-head"; -import { ProxyItem } from "./proxy-item"; -import { ProxyItemMini } from "./proxy-item-mini"; -import type { IRenderItem } from "./use-render-list"; - -interface RenderProps { - item: IRenderItem; - indent: boolean; - onLocation: (group: IProxyGroupItem) => void; - onCheckAll: (groupName: string) => void; - onHeadState: (groupName: string, patch: Partial) => void; - onChangeProxy: (group: IProxyGroupItem, proxy: IProxyItem) => void; -} - -export const ProxyRender = (props: RenderProps) => { - const { indent, item, onLocation, onCheckAll, onHeadState, onChangeProxy } = - props; - const { type, group, headState, proxy, proxyCol } = item; - - if (type === 0) { - return ( - - onHeadState(group!.name, { open: !headState?.open })} - sx={{ - borderRadius: 7, - }} - > - - {group!.type} - {group!.now} - - } - secondaryTypographyProps={{ - sx: { display: "flex", alignItems: "center" }, - }} - /> - {headState?.open ? : } - - - ); - } - - if (type === 1) { - return ( - - onLocation(group!)} - onCheckDelay={() => onCheckAll(group!.name)} - onHeadState={(p) => onHeadState(group!.name, p)} - /> - - - - ); - } - - if (type === 2) { - return ( - - onChangeProxy(group!, proxy!)} - /> - - ); - } - - if (type === 3) { - return ( - - - No Proxies - - ); - } - - if (type === 4) { - return ( - - - {proxyCol?.map((proxy) => ( - onChangeProxy(group!, proxy!)} - /> - ))} - - - ); - } - - if (type === 5) { - return ( - - - - ); - } - - if (type === 6) { - return ( - - ); - } - - return null; -}; - -const StyledSubtitle = styled("span")` - font-size: 0.8rem; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -`; - -const ListItemTextChild = styled("span")` - display: block; -`; - -const StyledTypeBox = styled(ListItemTextChild)(({ theme }) => ({ - display: "inline-block", - border: "1px solid #ccc", - borderColor: alpha(theme.palette.primary.main, 0.5), - color: alpha(theme.palette.primary.main, 0.8), - borderRadius: 4, - fontSize: 10, - padding: "0 2px", - lineHeight: 1.25, - marginRight: "4px", -})); diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-filter-sort.ts b/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-filter-sort.ts deleted file mode 100644 index ca7c6527ce..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-filter-sort.ts +++ /dev/null @@ -1,125 +0,0 @@ -import { useEffect, useMemo, useState } from "react"; -import delayManager from "@/services/delay"; - -// default | delay | alphabet -export type ProxySortType = 0 | 1 | 2; - -export default function useFilterSort( - proxies: IProxyItem[], - groupName: string, - filterText: string, - sortType: ProxySortType, -) { - const [refresh, setRefresh] = useState({}); - - useEffect(() => { - let last = 0; - - delayManager.setGroupListener(groupName, () => { - // 简单节流 - const now = Date.now(); - if (now - last > 666) { - last = now; - setRefresh({}); - } - }); - - return () => { - delayManager.removeGroupListener(groupName); - }; - }, [groupName]); - - return useMemo(() => { - const fp = filterProxies(proxies, groupName, filterText); - const sp = sortProxies(fp, groupName, sortType); - return sp; - }, [proxies, groupName, filterText, sortType, refresh]); -} - -export function filterSort( - proxies: IProxyItem[], - groupName: string, - filterText: string, - sortType: ProxySortType, -) { - const fp = filterProxies(proxies, groupName, filterText); - const sp = sortProxies(fp, groupName, sortType); - return sp; -} - -/** - * 可以通过延迟数/节点类型 过滤 - */ -const regex1 = /delay([=<>])(\d+|timeout|error)/i; -const regex2 = /type=(.*)/i; - -/** - * filter the proxy - * according to the regular conditions - */ -function filterProxies( - proxies: IProxyItem[], - groupName: string, - filterText: string, -) { - if (!filterText) return proxies; - - const res1 = regex1.exec(filterText); - if (res1) { - const symbol = res1[1]; - const symbol2 = res1[2].toLowerCase(); - const value = - symbol2 === "error" ? 1e5 : symbol2 === "timeout" ? 3000 : +symbol2; - - return proxies.filter((p) => { - const delay = delayManager.getDelayFix(p, groupName); - - if (delay < 0) return false; - if (symbol === "=" && symbol2 === "error") return delay >= 1e5; - if (symbol === "=" && symbol2 === "timeout") - return delay < 1e5 && delay >= 3000; - if (symbol === "=") return delay == value; - if (symbol === "<") return delay <= value; - if (symbol === ">") return delay >= value; - return false; - }); - } - - const res2 = regex2.exec(filterText); - if (res2) { - const type = res2[1].toLowerCase(); - return proxies.filter((p) => p.type.toLowerCase().includes(type)); - } - - return proxies.filter((p) => p.name.includes(filterText.trim())); -} - -/** - * sort the proxy - */ -function sortProxies( - proxies: IProxyItem[], - groupName: string, - sortType: ProxySortType, -) { - if (!proxies) return []; - if (sortType === 0) return proxies; - - const list = proxies.slice(); - - if (sortType === 1) { - list.sort((a, b) => { - const ad = delayManager.getDelayFix(a, groupName); - const bd = delayManager.getDelayFix(b, groupName); - - if (ad === -1 || ad === -2) return 1; - if (bd === -1 || bd === -2) return -1; - - return ad - bd; - }); - } else { - list.sort((a, b) => a.name.localeCompare(b.name)); - } - - return list; -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-head-state.ts b/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-head-state.ts deleted file mode 100644 index df46bb0f99..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-head-state.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { useCallback, useEffect, useState } from "react"; -import { ProxySortType } from "./use-filter-sort"; -import { useProfiles } from "@/hooks/use-profiles"; - -export interface HeadState { - open?: boolean; - showType: boolean; - sortType: ProxySortType; - filterText: string; - textState: "url" | "filter" | null; - testUrl: string; -} - -type HeadStateStorage = Record>; - -const HEAD_STATE_KEY = "proxy-head-state"; -export const DEFAULT_STATE: HeadState = { - open: false, - showType: false, - sortType: 0, - filterText: "", - textState: null, - testUrl: "", -}; - -export function useHeadStateNew() { - const { profiles } = useProfiles(); - const current = profiles?.current || ""; - - const [state, setState] = useState>({}); - - useEffect(() => { - if (!current) { - setState({}); - return; - } - - try { - const data = JSON.parse( - localStorage.getItem(HEAD_STATE_KEY)!, - ) as HeadStateStorage; - - const value = data[current] || {}; - - if (value && typeof value === "object") { - setState(value); - } else { - setState({}); - } - } catch {} - }, [current]); - - const setHeadState = useCallback( - (groupName: string, obj: Partial) => { - setState((old) => { - const state = old[groupName] || DEFAULT_STATE; - const ret = { ...old, [groupName]: { ...state, ...obj } }; - - // 保存到存储中 - setTimeout(() => { - try { - const item = localStorage.getItem(HEAD_STATE_KEY); - - let data = (item ? JSON.parse(item) : {}) as HeadStateStorage; - - if (!data || typeof data !== "object") data = {}; - - data[current] = ret; - - localStorage.setItem(HEAD_STATE_KEY, JSON.stringify(data)); - } catch {} - }); - - return ret; - }); - }, - [current], - ); - - return [state, setHeadState] as const; -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-render-list.ts b/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-render-list.ts deleted file mode 100644 index 9884353817..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-render-list.ts +++ /dev/null @@ -1,171 +0,0 @@ -import { useEffect, useMemo } from "react"; -import useSWR from "swr"; -// import { getProxies } from "@/services/api"; -import { useVerge } from "@/hooks/use-verge"; -import { getProxies } from "@/services/cmds"; -import { filterSort } from "./use-filter-sort"; -import { - DEFAULT_STATE, - useHeadStateNew, - type HeadState, -} from "./use-head-state"; -import { useWindowWidth } from "./use-window-width"; - -export interface IRenderItem { - // 组 | head | item | empty | item col | item bottom | empty-padding - type: 0 | 1 | 2 | 3 | 4 | 5 | 6; - key: string; - group?: IProxyGroupItem; - proxy?: IProxyItem; - col?: number; - proxyCol?: IProxyItem[]; - headState?: HeadState; -} - -export const useRenderList = (mode: string) => { - const { data: proxiesData, mutate: mutateProxies } = useSWR( - "getProxies", - async () => { - const res = await getProxies(); - console.log(res); - return res; - }, - { refreshInterval: 45000 }, - ); - - const { verge } = useVerge(); - const { width } = useWindowWidth(); - - let col = Math.floor(verge?.proxy_layout_column || 6); - - // 自适应 - if (col >= 6 || col <= 0) { - if (width > 1450) col = 4; - else if (width > 1024) col = 3; - else if (width > 900) col = 2; - else if (width >= 600) col = 1; - else col = 1; - } - - const [headStates, setHeadState] = useHeadStateNew(); - - // make sure that fetch the proxies successfully - useEffect(() => { - if (!proxiesData) return; - const { groups, proxies } = proxiesData; - - if ( - (mode === "rule" && !groups.length) || - (mode === "global" && proxies.length < 2) - ) { - setTimeout(() => mutateProxies(), 500); - } - }, [proxiesData, mode]); - - const renderList: IRenderItem[] = useMemo(() => { - if (!proxiesData) return []; - - // global 和 direct 使用展开的样式 - const useRule = mode === "rule" || mode === "script"; - const renderGroups = - (useRule && proxiesData.groups.length - ? proxiesData.groups - : [proxiesData.global!]) || []; - - const retList = renderGroups.flatMap((group) => { - const headState = headStates[group.name] || DEFAULT_STATE; - const ret: IRenderItem[] = [ - { type: 0, key: group.name, group, headState }, - ]; - - if (headState?.open || !useRule) { - const proxies = filterSort( - group.all, - group.name, - headState.filterText, - headState.sortType, - ); - - ret.push({ type: 1, key: `head-${group.name}`, group, headState }); - - if (!proxies.length) { - ret.push({ type: 3, key: `empty-${group.name}`, group, headState }); - } - - // 支持多列布局 - if (col > 1) { - const lists = ret.concat( - groupList(proxies, col).map((proxyCol) => ({ - type: 4, - key: `col-${group.name}-${proxyCol[0].name}`, - group, - headState, - col, - proxyCol, - })), - ); - - lists.push({ - type: 5, - key: `footer-${group.name}`, - group, - headState, - }); - - return lists; - } - - const lists = ret.concat( - proxies.map((proxy) => ({ - type: 2, - key: `${group.name}-${proxy!.name}`, - group, - proxy, - headState, - })), - ); - - lists.push({ - type: 5, - key: `footer-${group.name}`, - }); - - return lists; - } - - return ret; - }); - - if (!useRule) return retList.slice(1); - - console.log(retList); - - retList.push({ - type: 6, - key: `empty-padding`, - }); - - return retList; - }, [headStates, proxiesData, mode, col]); - - return { - renderList, - onProxies: mutateProxies, - onHeadState: setHeadState, - }; -}; - -function groupList(list: T[], size: number): T[][] { - return list.reduce((p, n) => { - if (!p.length) return [[n]]; - - const i = p.length - 1; - if (p[i].length < size) { - p[i].push(n); - return p; - } - - p.push([n]); - return p; - }, [] as T[][]); -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-window-width.ts b/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-window-width.ts deleted file mode 100644 index d1de3c354f..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/proxy/use-window-width.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { useEffect, useState } from "react"; - -export const useWindowWidth = () => { - const [width, setWidth] = useState(() => document.body.clientWidth); - - useEffect(() => { - const handleResize = () => setWidth(document.body.clientWidth); - - window.addEventListener("resize", handleResize); - return () => { - window.removeEventListener("resize", handleResize); - }; - }, []); - - return { width }; -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/rule/rule-item.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/rule/rule-item.tsx deleted file mode 100644 index 9c8cd50224..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/rule/rule-item.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import { styled, Box, Typography } from "@mui/material"; - -const Item = styled(Box)(({ theme }) => ({ - display: "flex", - padding: "4px 16px", - color: theme.palette.text.primary, -})); - -const COLOR = [ - "primary", - "secondary", - "info.main", - "warning.main", - "success.main", -]; - -interface Props { - index: number; - value: IRuleItem; -} - -const parseColor = (text: string) => { - if (text === "REJECT" || text === "REJECT-DROP") return "error.main"; - if (text === "DIRECT") return "text.primary"; - - let sum = 0; - for (let i = 0; i < text.length; i++) { - sum += text.charCodeAt(i); - } - return COLOR[sum % COLOR.length]; -}; - -const RuleItem = (props: Props) => { - const { index, value } = props; - - return ( - - - {index + 1} - - - - - {value.payload || "-"} - - - - {value.type} - - - - {value.proxy} - - - - ); -}; - -export default RuleItem; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/clash-core-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/clash-core-viewer.tsx deleted file mode 100644 index 435873185b..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/clash-core-viewer.tsx +++ /dev/null @@ -1,407 +0,0 @@ -import { BaseDialog, DialogRef } from "@/components/base"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { useVerge } from "@/hooks/use-verge"; -import { closeAllConnections } from "@/services/api"; -import { - changeClashCore, - fetchLatestCoreVersions, - getCoreVersion, - grantPermission, - restartSidecar, - updateCore, -} from "@/services/cmds"; -import getSystem from "@/utils/get-system"; -import { FiberManualRecord, Lock, Update } from "@mui/icons-material"; -import { LoadingButton } from "@mui/lab"; -import { - Box, - CircularProgress, - IconButton, - List, - ListItemButton, - ListItemText, - alpha, - useTheme, -} from "@mui/material"; -import { useAsyncEffect, useLockFn } from "ahooks"; -import { forwardRef, useImperativeHandle, useState } from "react"; -import { useTranslation } from "react-i18next"; -import { mutate } from "swr"; - -type ClashCore = Required["clash_core"]; - -interface Core { - name: string; - core: ClashCore; - version?: string; - latest?: string; -} - -const VALID_CORE: Core[] = [ - { name: "Clash Premium", core: "clash" }, - { name: "Mihomo", core: "mihomo" }, - { name: "Mihomo Alpha", core: "mihomo-alpha" }, - { name: "Clash Rust", core: "clash-rs" }, -]; - -const OS = getSystem(); - -export const ClashCoreViewer = forwardRef((props, ref) => { - const { t } = useTranslation(); - - const { verge } = useVerge(); - - const [open, setOpen] = useState(false); - const [lock, setLock] = useState(false); - const [validCores, setValidCores] = useState(VALID_CORE); - useImperativeHandle(ref, () => ({ - open: () => setOpen(true), - close: () => setOpen(false), - })); - - const { clash_core = "clash" } = verge ?? {}; - - const [checkUpdatesLoading, setCheckUpdatesLoading] = useState(false); - const onCheckUpdates = useLockFn(async () => { - try { - setCheckUpdatesLoading(true); - const results = await fetchLatestCoreVersions(); - const buf = validCores.map((each) => ({ - ...each, - latest: - each.core === "clash" - ? `n${results["clash_premium"]}` - : results[each.core.replace(/-/g, "_") as keyof typeof results], - })); - setValidCores(buf); - useNotification({ - title: t("Success"), - body: t("Successfully check updates"), - type: NotificationType.Success, - }); - } catch (e) { - if (e instanceof Error) { - useNotification({ - title: t("Error"), - body: e.message, - type: NotificationType.Error, - }); - } else if (typeof e === "string") { - useNotification({ - title: t("Error"), - body: e, - type: NotificationType.Error, - }); - } else { - console.error(e); - } - } finally { - setCheckUpdatesLoading(false); - } - }); - - const [restartLoading, setRestartLoading] = useState(false); - const onRestart = useLockFn(async () => { - try { - setRestartLoading(true); - await restartSidecar(); - useNotification({ - title: t("Success"), - body: t("Successfully restart core"), - type: NotificationType.Success, - }); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } finally { - setRestartLoading(false); - } - }); - - const getCoreVersions = async () => { - try { - const versions = await Promise.all( - VALID_CORE.reduce( - (acc, each) => acc.concat(getCoreVersion(each.core)), - [] as Promise[], - ), - ); - setValidCores( - VALID_CORE.map((each, idx) => ({ - ...each, - version: !isNaN(Number(versions[idx][0])) - ? `v${versions[idx]}` - : versions[idx], - })), - ); - } catch (e) { - if (e instanceof Error) { - useNotification({ - title: t("Error"), - body: `Failed to get core version: ${e.message}`, - type: NotificationType.Error, - }); - } else if (typeof e === "string") { - useNotification({ - title: t("Error"), - body: `Failed to get core version: ${e}`, - type: NotificationType.Error, - }); - } else { - console.error(e); - } - } - }; - useAsyncEffect(getCoreVersions, []); - - return ( - - {t("Clash Core")} -
- - {t("Check Updates")} - - - - {t("Restart")} - - - } - contentSx={{ - pb: 0, - width: 380, - height: 310, - overflowY: "auto", - userSelect: "text", - marginTop: "-8px", - }} - disableOk - cancelBtn={t("Back")} - onClose={() => setOpen(false)} - onCancel={() => setOpen(false)} - > - - {validCores.map((each) => ( - { - if (state === "start") setLock(true); - else setLock(false); - }} - onCoreUpdated={() => { - getCoreVersions(); - }} - /> - ))} - - - ); -}); - -ClashCoreViewer.displayName = "ClashCoreViewer"; - -function CoreElement({ - selected, - core, - lock, - onCoreChanged, - onCoreUpdated, -}: { - selected: boolean; - core: Core; - lock: boolean; - onCoreChanged: (core: string, state: "start" | "finish") => void; - onCoreUpdated?: (core: string) => void; -}) { - const { t } = useTranslation(); - const { mutateVerge } = useVerge(); - const theme = useTheme(); - const [loading, setLoading] = useState(false); - const needUpdate = core.latest && core.version !== core.latest; - - const onCoreChange = useLockFn(async (core: ClashCore) => { - if (selected || lock) return; - try { - setLoading(true); - onCoreChanged(core, "start"); - closeAllConnections(); - await changeClashCore(core); - mutateVerge(); - setTimeout(() => { - mutate("getClashConfig"); - mutate("getVersion"); - }, 100); - useNotification({ - title: t("Success"), - body: `Successfully switch to ${core}`, - type: NotificationType.Success, - }); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } finally { - setLoading(false); - onCoreChanged(core, "finish"); - } - }); - - const onGrant = useLockFn(async (core: string) => { - try { - await grantPermission(core); - // 自动重启 - if (selected) await restartSidecar(); - useNotification({ - title: t("Success"), - body: `Successfully grant permission to ${core}`, - type: NotificationType.Success, - }); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } - }); - - const [updateCoreLoading, setUpdateCoreLoading] = useState(false); - const onUpdateCore = useLockFn( - async (core: Required["clash_core"]) => { - try { - setUpdateCoreLoading(true); - await updateCore(core); - mutateVerge(); - setTimeout(() => { - mutate("getClashConfig"); - mutate("getVersion"); - }, 100); - useNotification({ - title: t("Success"), - body: `Successfully update core ${core}`, - type: NotificationType.Success, - }); - onCoreUpdated?.(core); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } finally { - setUpdateCoreLoading(false); - } - }, - ); - - return ( - onCoreChange(core.core)} - style={{ - position: "relative", - }} - sx={{ - backgroundColor: loading - ? alpha(theme.palette.action.focus, 0.03) - : undefined, - }} - > - - - - {core.name} - - {needUpdate && ( - - )} -
- } - secondary={ - needUpdate - ? `${core.version} (${core.latest})` - : core.version ?? `/${core.core}` - } - /> - {needUpdate && ( - { - e.preventDefault(); - e.stopPropagation(); - onUpdateCore(core.core); - }} - > - {updateCoreLoading ? ( - - ) : ( - - )} - - )} - {(OS === "macos" || OS === "linux") && ( - { - e.preventDefault(); - e.stopPropagation(); - onGrant(core.core); - }} - > - - - )} - - ); -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/clash-field-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/clash-field-viewer.tsx deleted file mode 100644 index 589ca82ce5..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/clash-field-viewer.tsx +++ /dev/null @@ -1,129 +0,0 @@ -import { BaseDialog, DialogRef } from "@/components/base"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { useProfiles } from "@/hooks/use-profiles"; -import { getRuntimeExists } from "@/services/cmds"; -import { - DEFAULT_FIELDS, - HANDLE_FIELDS, - OTHERS_FIELDS, -} from "@/utils/clash-fields"; -import { InfoRounded } from "@mui/icons-material"; -import { Checkbox, Divider, Stack, Tooltip, Typography } from "@mui/material"; -import { forwardRef, useImperativeHandle, useState } from "react"; -import { useTranslation } from "react-i18next"; -import useSWR from "swr"; - -const otherFields = [...OTHERS_FIELDS]; -const handleFields = [...HANDLE_FIELDS, ...DEFAULT_FIELDS]; - -export const ClashFieldViewer = forwardRef((props, ref) => { - const { t } = useTranslation(); - - const { profiles = {}, patchProfiles } = useProfiles(); - const { data: existsKeys = [], mutate: mutateExists } = useSWR( - "getRuntimeExists", - getRuntimeExists, - ); - - const [open, setOpen] = useState(false); - const [selected, setSelected] = useState([]); - - useImperativeHandle(ref, () => ({ - open: () => { - mutateExists(); - setSelected(profiles.valid || []); - setOpen(true); - }, - close: () => setOpen(false), - })); - - const handleChange = (item: string) => { - if (!item) return; - - setSelected((old) => - old.includes(item) ? old.filter((e) => e !== item) : [...old, item], - ); - }; - - const handleSave = async () => { - setOpen(false); - - const oldSet = new Set(profiles.valid || []); - const curSet = new Set(selected); - const joinSet = new Set(selected.concat([...oldSet])); - - if (curSet.size === oldSet.size && curSet.size === joinSet.size) return; - - try { - await patchProfiles({ valid: [...curSet] }); - // Notice.success("Refresh clash config", 1000); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } - }; - - return ( - setOpen(false)} - onCancel={() => setOpen(false)} - onOk={handleSave} - > - {otherFields.map((item) => { - const inSelect = selected.includes(item); - const inConfig = existsKeys.includes(item); - - return ( - - handleChange(item)} - /> - {item} - - {!inSelect && inConfig && } - - ); - })} - - - - Clash Nyanpasu Control Fields - - - - {handleFields.map((item) => ( - - - {item} - - ))} - - ); -}); - -ClashFieldViewer.displayName = "ClashFieldViewer"; - -function WarnIcon() { - return ( - - - - ); -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/clash-port-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/clash-port-viewer.tsx deleted file mode 100644 index 0176f31c60..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/clash-port-viewer.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import { BaseDialog, DialogRef } from "@/components/base"; -import { useClashInfo } from "@/hooks/use-clash"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { useVerge } from "@/hooks/use-verge"; -import { List, ListItem, ListItemText, TextField } from "@mui/material"; -import { useLockFn } from "ahooks"; -import { forwardRef, useImperativeHandle, useState } from "react"; -import { useTranslation } from "react-i18next"; - -export const ClashPortViewer = forwardRef((props, ref) => { - const { t } = useTranslation(); - - const { clashInfo, patchInfo } = useClashInfo(); - const { verge, patchVerge } = useVerge(); - - const [open, setOpen] = useState(false); - const [port, setPort] = useState( - verge?.verge_mixed_port ?? clashInfo?.port ?? 7890, - ); - - useImperativeHandle(ref, () => ({ - open: () => { - if (verge?.verge_mixed_port) setPort(verge?.verge_mixed_port); - setOpen(true); - }, - close: () => setOpen(false), - })); - - const onSave = useLockFn(async () => { - if (port === verge?.verge_mixed_port) { - setOpen(false); - return; - } - try { - await patchInfo({ "mixed-port": port }); - await patchVerge({ verge_mixed_port: port }); - setOpen(false); - useNotification({ - title: t("Success"), - body: t("Change Clash Port successfully!"), - type: NotificationType.Success, - }); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } - }); - - return ( - setOpen(false)} - onCancel={() => setOpen(false)} - onOk={onSave} - > - - - - - setPort(+e.target.value?.replace(/\D+/, "").slice(0, 5)) - } - /> - - - - ); -}); - -ClashPortViewer.displayName = "ClashPortViewer"; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/config-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/config-viewer.tsx deleted file mode 100644 index 9715ca3e71..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/config-viewer.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import { BaseDialog, DialogRef } from "@/components/base"; -import { getRuntimeYaml } from "@/services/cmds"; -import { Chip } from "@mui/material"; -import { - forwardRef, - useEffect, - useImperativeHandle, - useRef, - useState, -} from "react"; -import { useTranslation } from "react-i18next"; -import { monaco } from "@/services/monaco"; -import { themeMode as atomThemeMode } from "@/store"; -import { useAtomValue } from "jotai"; - -export const ConfigViewer = forwardRef((props, ref) => { - const { t } = useTranslation(); - const [open, setOpen] = useState(false); - - const editorRef = useRef(); - const instanceRef = useRef(null); - const themeMode = useAtomValue(atomThemeMode); - - useEffect(() => { - return () => { - if (instanceRef.current) { - instanceRef.current.dispose(); - instanceRef.current = null; - } - }; - }, []); - - useImperativeHandle(ref, () => ({ - open: () => { - setOpen(true); - - getRuntimeYaml().then((data) => { - const dom = editorRef.current; - - if (!dom) return; - if (instanceRef.current) instanceRef.current.dispose(); - - instanceRef.current = monaco.editor.create(editorRef.current, { - value: data ?? "# Error\n", - language: "yaml", - theme: themeMode === "light" ? "vs" : "vs-dark", - minimap: { enabled: false }, - readOnly: true, - }); - }); - }, - close: () => setOpen(false), - })); - - return ( - - {t("Runtime Config")} - - } - contentSx={{ width: 520, pb: 1, userSelect: "text" }} - cancelBtn={t("Back")} - disableOk - onClose={() => setOpen(false)} - onCancel={() => setOpen(false)} - > -
- - ); -}); - -ConfigViewer.displayName = "ConfigViewer"; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/controller-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/controller-viewer.tsx deleted file mode 100644 index 50db0f32fb..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/controller-viewer.tsx +++ /dev/null @@ -1,122 +0,0 @@ -import { BaseDialog, DialogRef } from "@/components/base"; -import { useClashInfo } from "@/hooks/use-clash"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { useVerge } from "@/hooks/use-verge"; -import { - List, - ListItem, - ListItemText, - MenuItem, - Select, - TextField, -} from "@mui/material"; -import { useLockFn } from "ahooks"; -import { forwardRef, useImperativeHandle, useState } from "react"; -import { useTranslation } from "react-i18next"; - -export const ControllerViewer = forwardRef((props, ref) => { - const { t } = useTranslation(); - const [open, setOpen] = useState(false); - const [loading, setLoading] = useState(false); - - const { clashInfo, patchInfo } = useClashInfo(); - const { verge, patchVerge } = useVerge(); - const [controller, setController] = useState(clashInfo?.server || ""); - const [secret, setSecret] = useState(clashInfo?.secret || ""); - const [portStrategy, setPortStrategy] = useState( - verge?.clash_strategy?.external_controller_port_strategy || - "allow_fallback", - ); - - useImperativeHandle(ref, () => ({ - open: () => { - setOpen(true); - setController(clashInfo?.server || ""); - setSecret(clashInfo?.secret || ""); - }, - close: () => setOpen(false), - })); - - const onSave = useLockFn(async () => { - try { - setLoading(true); - await patchVerge({ - clash_strategy: { external_controller_port_strategy: portStrategy }, - }); - await patchInfo({ "external-controller": controller, secret }); - useNotification({ - title: t("Success"), - body: t("Change Clash Config successfully!"), - type: NotificationType.Success, - }); - setOpen(false); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } finally { - setLoading(false); - } - }); - - return ( - setOpen(false)} - onCancel={() => setOpen(false)} - loading={loading} - onOk={onSave} - > - - - - setController(e.target.value)} - /> - - - - - - - - - - setSecret(e.target.value)} - /> - - - - ); -}); - -ControllerViewer.displayName = "ControllerViewer"; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/guard-state.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/guard-state.tsx deleted file mode 100644 index 73d190a98d..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/guard-state.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { cloneElement, isValidElement, ReactNode, useRef } from "react"; -import noop from "@/utils/noop"; - -interface Props { - value?: Value; - valueProps?: string; - loading?: boolean; - onChangeProps?: string; - waitTime?: number; - onFormat?: (...args: any[]) => Value; - onGuard?: (value: Value) => Promise; - onCatch?: (error: Error) => void; - children: ReactNode; -} - -export function GuardState(props: Props) { - const { - value, - children, - valueProps = "value", - loading, - onChangeProps = "onChange", - onGuard = noop, - onCatch = noop, - onFormat = (v: T) => v, - } = props; - - if (!isValidElement(children)) { - return children as any; - } - - const childProps = { ...children.props, loading }; - - childProps[valueProps] = value; - - childProps[onChangeProps] = async (...args: any[]) => { - try { - const newValue = (onFormat as any)(...args); - - await onGuard(newValue); - } catch (err: any) { - onCatch(err); - } - }; - - return cloneElement(children, childProps); -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/hotkey-input.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/hotkey-input.tsx deleted file mode 100644 index 8d0ba1b242..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/hotkey-input.tsx +++ /dev/null @@ -1,107 +0,0 @@ -import Kbd from "@/components/common/kbd"; -import { parseHotkey } from "@/utils/parse-hotkey"; -import { DeleteRounded } from "@mui/icons-material"; -import { Box, IconButton, alpha, styled } from "@mui/material"; -import { FocusEvent, useRef, useState } from "react"; - -const KeyWrapper = styled("div")<{ - isDuplicate?: boolean; -}>(({ theme, isDuplicate }) => ({ - position: "relative", - width: 165, - minHeight: 36, - - "> input": { - position: "absolute", - top: 0, - left: 0, - width: "100%", - height: "100%", - zIndex: 1, - opacity: 0, - }, - "> input:focus + .list": { - borderColor: alpha(theme.palette.primary.main, 0.75), - }, - ".list": { - display: "flex", - alignItems: "center", - flexWrap: "wrap", - width: "100%", - height: "100%", - minHeight: 36, - boxSizing: "border-box", - padding: "2px 5px", - border: "1px solid", - borderRadius: 4, - gap: 4, - borderColor: isDuplicate - ? theme.palette.error.main - : alpha(theme.palette.text.secondary, 0.15), - "&:last-child": { - marginRight: 0, - }, - }, -})); - -interface Props { - func: string; - isDuplicate: boolean; - value: string[]; - onChange: (value: string[]) => void; - onBlur?: (e: FocusEvent, func: string) => void; -} - -export const HotkeyInput = (props: Props) => { - const { value, onChange, func, isDuplicate } = props; - - const changeRef = useRef([]); - const [keys, setKeys] = useState(value); - - return ( - - - { - const ret = changeRef.current.slice(); - if (ret.length) { - onChange(ret); - changeRef.current = []; - } - }} - onKeyDown={(e) => { - const evt = e.nativeEvent; - e.preventDefault(); - e.stopPropagation(); - - const key = parseHotkey(evt.key); - if (key === "UNIDENTIFIED") return; - - changeRef.current = [...new Set([...changeRef.current, key])]; - setKeys(changeRef.current); - }} - onBlur={(e) => props.onBlur && props.onBlur(e, func)} - /> - -
- {keys.map((key) => ( - {key} - ))} -
-
- - { - onChange([]); - setKeys([]); - props.onBlur && props.onBlur({} as never, func); - }} - > - - -
- ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/hotkey-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/hotkey-viewer.tsx deleted file mode 100644 index 4a1d5b8a16..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/hotkey-viewer.tsx +++ /dev/null @@ -1,154 +0,0 @@ -import { BaseDialog, DialogRef } from "@/components/base"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { useVerge } from "@/hooks/use-verge"; -import { Typography, styled } from "@mui/material"; -import { useLatest, useLockFn } from "ahooks"; -import { - FocusEvent, - forwardRef, - useEffect, - useImperativeHandle, - useState, -} from "react"; -import { useTranslation } from "react-i18next"; -import { HotkeyInput } from "./hotkey-input"; - -const ItemWrapper = styled("div")` - display: flex; - align-items: center; - justify-content: space-between; - margin-bottom: 8px; -`; - -const HOTKEY_FUNC = [ - "open_or_close_dashboard", - "clash_mode_rule", - "clash_mode_global", - "clash_mode_direct", - "clash_mode_script", - "toggle_system_proxy", - "enable_system_proxy", - "disable_system_proxy", - "toggle_tun_mode", - "enable_tun_mode", - "disable_tun_mode", -]; - -export const HotkeyViewer = forwardRef((props, ref) => { - const { t } = useTranslation(); - const [open, setOpen] = useState(false); - - const { verge, patchVerge } = useVerge(); - - const [hotkeyMap, setHotkeyMap] = useState>({}); - const hotkeyMapRef = useLatest(hotkeyMap); - - useImperativeHandle(ref, () => ({ - open: () => { - setOpen(true); - - const map = {} as typeof hotkeyMap; - - verge?.hotkeys?.forEach((text) => { - const [func, key] = text.split(",").map((e) => e.trim()); - - if (!func || !key) return; - - map[func] = key - .split("+") - .map((e) => e.trim()) - .map((k) => (k === "PLUS" ? "+" : k)); - }); - - setHotkeyMap(map); - setDuplicateItems([]); - }, - close: () => setOpen(false), - })); - - // 检查是否有快捷键重复 - const [duplicateItems, setDuplicateItems] = useState([]); - const isDuplicate = !!duplicateItems.length; - const onBlur = (e: FocusEvent, func: string) => { - console.log(func); - const keys = Object.values(hotkeyMapRef.current).flat().filter(Boolean); - const set = new Set(keys); - if (keys.length !== set.size) { - setDuplicateItems([...duplicateItems, func]); - } else { - setDuplicateItems(duplicateItems.filter((e) => e !== func)); - } - }; - - const saveState = useLockFn(async () => { - const hotkeys = Object.entries(hotkeyMap) - .map(([func, keys]) => { - if (!func || !keys?.length) return ""; - - const key = keys - .map((k) => k.trim()) - .filter(Boolean) - .map((k) => (k === "+" ? "PLUS" : k)) - .join("+"); - - if (!key) return ""; - return `${func},${key}`; - }) - .filter(Boolean); - - try { - await patchVerge({ hotkeys }); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } - }); - - useEffect(() => { - if (!duplicateItems.length && open) { - saveState(); - } - }, [hotkeyMap, duplicateItems, open]); - - const onSave = () => { - saveState().then(() => { - setOpen(false); - }); - }; - - return ( - setOpen(false)} - onCancel={() => setOpen(false)} - onOk={onSave} - > - {HOTKEY_FUNC.map((func) => ( - - {t(func)} - { - const map = { ...hotkeyMapRef.current, [func]: v }; - hotkeyMapRef.current = map; - setHotkeyMap(map); - }} - /> - - ))} - - ); -}); - -HotkeyViewer.displayName = "HotkeyViewer"; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/layout-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/layout-viewer.tsx deleted file mode 100644 index 7d522afc42..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/layout-viewer.tsx +++ /dev/null @@ -1,123 +0,0 @@ -import { BaseDialog, DialogRef } from "@/components/base"; -import { pageTransitionVariants } from "@/components/layout/page-transition"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { useVerge } from "@/hooks/use-verge"; -import { List, MenuItem, Select } from "@mui/material"; -import { forwardRef, useImperativeHandle, useState } from "react"; -import { useTranslation } from "react-i18next"; -import { GuardState } from "./guard-state"; -import { SettingItem } from "./setting-comp"; -import MDYSwitch from "@/components/common/mdy-switch"; - -export const LayoutViewer = forwardRef((props, ref) => { - const { t } = useTranslation(); - const { verge, patchVerge, mutateVerge } = useVerge(); - - const [open, setOpen] = useState(false); - - const [loading, setLoading] = useState({ - theme_blur: false, - traffic_graph: false, - }); - - useImperativeHandle(ref, () => ({ - open: () => setOpen(true), - close: () => setOpen(false), - })); - - const onSwitchFormat = (_e: any, value: boolean) => value; - const onError = (err: any) => { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - }; - const onChangeData = (patch: Partial) => { - mutateVerge({ ...verge, ...patch }, false); - }; - - return ( - setOpen(false)} - onCancel={() => setOpen(false)} - > - - - patchVerge({ theme_blur: e })} - loading={loading["theme_blur"]} - > - - - - - - patchVerge({ traffic_graph: e })} - loading={loading["traffic_graph"]} - > - - - - - - patchVerge({ enable_memory_usage: e })} - > - - - - {/* TODO: 将 select 单独开一个 Modal 以符合 Material Design 的设计 */} - - - - - - ); -}); - -LayoutViewer.displayName = "LayoutViewer"; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/misc-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/misc-viewer.tsx deleted file mode 100644 index 2cdd81eabe..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/misc-viewer.tsx +++ /dev/null @@ -1,191 +0,0 @@ -import { BaseDialog, DialogRef } from "@/components/base"; -import MDYSwitch from "@/components/common/mdy-switch"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { useVerge } from "@/hooks/use-verge"; -import { - List, - ListItem, - ListItemText, - MenuItem, - Select, - TextField, -} from "@mui/material"; -import { useLockFn } from "ahooks"; -import { forwardRef, useImperativeHandle, useState } from "react"; -import { useTranslation } from "react-i18next"; - -export const MiscViewer = forwardRef((props, ref) => { - const { t } = useTranslation(); - const { verge, patchVerge } = useVerge(); - - const [open, setOpen] = useState(false); - const [values, setValues] = useState({ - appLogLevel: "info", - autoCloseConnection: false, - enableClashFields: true, - enableBuiltinEnhanced: true, - clashTraySelector: true, - proxyLayoutColumn: 6, - defaultLatencyTest: "", - }); - - useImperativeHandle(ref, () => ({ - open: () => { - setOpen(true); - setValues({ - appLogLevel: verge?.app_log_level ?? "info", - autoCloseConnection: verge?.auto_close_connection ?? false, - enableClashFields: verge?.enable_clash_fields ?? true, - enableBuiltinEnhanced: verge?.enable_builtin_enhanced ?? true, - clashTraySelector: verge?.clash_tray_selector ?? true, - proxyLayoutColumn: verge?.proxy_layout_column || 6, - defaultLatencyTest: verge?.default_latency_test || "", - }); - }, - close: () => setOpen(false), - })); - - const onSave = useLockFn(async () => { - try { - await patchVerge({ - app_log_level: values.appLogLevel, - auto_close_connection: values.autoCloseConnection, - enable_clash_fields: values.enableClashFields, - enable_builtin_enhanced: values.enableBuiltinEnhanced, - proxy_layout_column: values.proxyLayoutColumn, - default_latency_test: values.defaultLatencyTest, - clash_tray_selector: values.clashTraySelector, - }); - setOpen(false); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } - }); - - return ( - setOpen(false)} - onCancel={() => setOpen(false)} - onOk={onSave} - > - - - - - - - - - - setValues((v) => ({ ...v, autoCloseConnection: c })) - } - /> - - - - - - setValues((v) => ({ ...v, enableClashFields: c })) - } - /> - - - - - - setValues((v) => ({ ...v, enableBuiltinEnhanced: c })) - } - /> - - - - - - setValues((v) => ({ ...v, clashTraySelector: c })) - } - /> - - - - - - - - - - - setValues((v) => ({ ...v, defaultLatencyTest: e.target.value })) - } - /> - - - - ); -}); - -MiscViewer.displayName = "MiscViewer"; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/service-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/service-viewer.tsx deleted file mode 100644 index d1bd0f51fb..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/service-viewer.tsx +++ /dev/null @@ -1,146 +0,0 @@ -import { BaseDialog, DialogRef } from "@/components/base"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { - checkService, - installService, - patchVergeConfig, - uninstallService, -} from "@/services/cmds"; -import { Button, Stack, Typography } from "@mui/material"; -import { useLockFn } from "ahooks"; -import { forwardRef, useImperativeHandle, useState } from "react"; -import { useTranslation } from "react-i18next"; -import useSWR from "swr"; - -interface Props { - enable: boolean; -} - -export const ServiceViewer = forwardRef((props, ref) => { - const { enable } = props; - - const { t } = useTranslation(); - const [open, setOpen] = useState(false); - - const { data: status, mutate: mutateCheck } = useSWR( - "checkService", - checkService, - { - revalidateIfStale: false, - shouldRetryOnError: false, - focusThrottleInterval: 36e5, // 1 hour - }, - ); - - useImperativeHandle(ref, () => ({ - open: () => setOpen(true), - close: () => setOpen(false), - })); - - const state = status != null ? status : "pending"; - - const onInstall = useLockFn(async () => { - try { - await installService(); - mutateCheck(); - setOpen(false); - useNotification({ - title: t("Success"), - body: "Service installed successfully", - type: NotificationType.Success, - }); - } catch (err: any) { - mutateCheck(); - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } - }); - - const onUninstall = useLockFn(async () => { - try { - if (enable) { - await patchVergeConfig({ enable_service_mode: false }); - } - - await uninstallService(); - mutateCheck(); - setOpen(false); - useNotification({ - title: t("Success"), - body: "Service uninstalled successfully", - type: NotificationType.Success, - }); - } catch (err: any) { - mutateCheck(); - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } - }); - - // fix unhandled error of the service mode - const onDisable = useLockFn(async () => { - try { - await patchVergeConfig({ enable_service_mode: false }); - mutateCheck(); - setOpen(false); - } catch (err: any) { - mutateCheck(); - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } - }); - - return ( - setOpen(false)} - > - Current State: {state} - - {(state === "unknown" || state === "uninstall") && ( - - Information: Please make sure that the Clash Nyanpasu Service is - installed and enabled - - )} - - - {state === "uninstall" && enable && ( - - )} - - {state === "uninstall" && ( - - )} - - {(state === "active" || state === "installed") && ( - - )} - - - ); -}); - -ServiceViewer.displayName = "ServiceViewer"; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/setting-comp.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/setting-comp.tsx deleted file mode 100644 index 8ad84951e4..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/setting-comp.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import { - Box, - List, - ListItem, - ListItemText, - ListSubheader, -} from "@mui/material"; -import React, { ReactNode } from "react"; - -interface ItemProps { - label: ReactNode; - extra?: ReactNode; - children?: ReactNode; - secondary?: ReactNode; -} - -export const SettingItem: React.FC = (props) => { - const { label, extra, children, secondary } = props; - - const primary = !extra ? ( - label - ) : ( - - {label} - - {extra} - - - ); - - return ( - - - {children} - - ); -}; - -export const SettingList: React.FC<{ - title: string; - children: ReactNode; -}> = (props) => ( - - - {props.title} - - - {props.children} - -); diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/sysproxy-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/sysproxy-viewer.tsx deleted file mode 100644 index fa5a092b7d..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/sysproxy-viewer.tsx +++ /dev/null @@ -1,184 +0,0 @@ -import { BaseDialog, DialogRef } from "@/components/base"; -import MDYSwitch from "@/components/common/mdy-switch"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { useVerge } from "@/hooks/use-verge"; -import { getSystemProxy } from "@/services/cmds"; -import { - Box, - InputAdornment, - List, - ListItem, - ListItemText, - TextField, - Typography, - styled, -} from "@mui/material"; -import { useLockFn } from "ahooks"; -import { forwardRef, useImperativeHandle, useState } from "react"; -import { useTranslation } from "react-i18next"; - -export const SysproxyViewer = forwardRef((props, ref) => { - const { t } = useTranslation(); - - const [open, setOpen] = useState(false); - - const { verge, patchVerge } = useVerge(); - - type SysProxy = Awaited>; - const [sysproxy, setSysproxy] = useState(); - - const { - enable_system_proxy: enabled, - enable_proxy_guard, - system_proxy_bypass, - proxy_guard_duration, - } = verge ?? {}; - - const [value, setValue] = useState({ - guard: enable_proxy_guard, - bypass: system_proxy_bypass, - duration: proxy_guard_duration ?? 10, - }); - - useImperativeHandle(ref, () => ({ - open: () => { - setOpen(true); - setValue({ - guard: enable_proxy_guard, - bypass: system_proxy_bypass, - duration: proxy_guard_duration ?? 10, - }); - getSystemProxy().then((p) => setSysproxy(p)); - }, - close: () => setOpen(false), - })); - - const onSave = useLockFn(async () => { - if (value.duration < 1) { - useNotification({ - title: t("Error"), - body: "Proxy guard duration at least 1 seconds", - type: NotificationType.Error, - }); - return; - } - - const patch: Partial = {}; - - if (value.guard !== enable_proxy_guard) { - patch.enable_proxy_guard = value.guard; - } - if (value.duration !== proxy_guard_duration) { - patch.proxy_guard_duration = value.duration; - } - if (value.bypass !== system_proxy_bypass) { - patch.system_proxy_bypass = value.bypass; - } - - try { - await patchVerge(patch); - setOpen(false); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } - }); - - return ( - setOpen(false)} - onCancel={() => setOpen(false)} - onOk={onSave} - > - - - - setValue((v) => ({ ...v, guard: e }))} - /> - - - - - s, - }} - onChange={(e) => { - setValue((v) => ({ - ...v, - duration: +e.target.value.replace(/\D/, ""), - })); - }} - /> - - - - - - setValue((v) => ({ ...v, bypass: e.target.value })) - } - /> - - - - - - {t("Current System Proxy")} - - - - Enable: - - {(!!sysproxy?.enable).toString()} - - - - - Server: - {sysproxy?.server || "-"} - - - - Bypass: - {sysproxy?.bypass || "-"} - - - - ); -}); - -SysproxyViewer.displayName = "SysproxyViewer"; - -const FlexBox = styled("div")` - display: flex; - margin-top: 4px; - - .label { - flex: none; - width: 80px; - } -`; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/tasks-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/tasks-viewer.tsx deleted file mode 100644 index ff8941aa5b..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/tasks-viewer.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import { BaseDialog, DialogRef } from "@/components/base"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { useVerge } from "@/hooks/use-verge"; -import { List, ListItem, ListItemText, TextField } from "@mui/material"; -import { useLockFn } from "ahooks"; -import { forwardRef, useImperativeHandle, useState } from "react"; -import { useTranslation } from "react-i18next"; -export const TasksViewer = forwardRef( - function TasksViewer(props, ref) { - const { t } = useTranslation(); - const { verge, patchVerge } = useVerge(); - - const [open, setOpen] = useState(false); - const [loading, setLoading] = useState(false); - const [values, setValues] = useState({ - max_log_files: 0, - }); - - useImperativeHandle(ref, () => ({ - open: () => { - setOpen(true); - setValues({ - max_log_files: verge?.max_log_files ?? 7, - }); - }, - close: () => setOpen(false), - })); - const onSave = useLockFn(async () => { - setLoading(true); - try { - await patchVerge({ - max_log_files: values.max_log_files, - }); - setOpen(false); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } finally { - setLoading(false); - } - }); - - return ( - setOpen(false)} - onCancel={() => setOpen(false)} - onOk={onSave} - > - - - - { - setValues({ - ...values, - max_log_files: Number.parseInt(e.target.value, 10), - }); - }} - /> - - - - ); - }, -); diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/theme-mode-switch.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/theme-mode-switch.tsx deleted file mode 100644 index 29ae9ef0c6..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/theme-mode-switch.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { useTranslation } from "react-i18next"; -import { Button, ButtonGroup } from "@mui/material"; - -type ThemeValue = IVergeConfig["theme_mode"]; - -interface Props { - value?: ThemeValue; - onChange?: (value: ThemeValue) => void; -} - -export const ThemeModeSwitch = (props: Props) => { - const { value, onChange } = props; - const { t } = useTranslation(); - - const modes = ["light", "dark", "system"] as const; - - return ( - - {modes.map((mode) => ( - - ))} - - ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/theme-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/theme-viewer.tsx deleted file mode 100644 index 7f86c5b09e..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/theme-viewer.tsx +++ /dev/null @@ -1,185 +0,0 @@ -import { BaseDialog, DialogRef } from "@/components/base"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { useVerge } from "@/hooks/use-verge"; -import { defaultDarkTheme, defaultTheme } from "@/pages/_theme"; -import { - List, - ListItem, - ListItemText, - TextField, - styled, - useTheme, -} from "@mui/material"; -import { useLockFn } from "ahooks"; -import { forwardRef, useImperativeHandle, useState } from "react"; -import { useTranslation } from "react-i18next"; -import { MuiColorInput } from "mui-color-input"; -import React from "react"; - -export const ThemeViewer = forwardRef((props, ref) => { - const { t } = useTranslation(); - - const [open, setOpen] = useState(false); - const { verge, patchVerge } = useVerge(); - const { theme_setting } = verge ?? {}; - const [theme, setTheme] = useState(theme_setting || {}); - - useImperativeHandle(ref, () => ({ - open: () => { - setOpen(true); - setTheme({ ...theme_setting } || {}); - }, - close: () => setOpen(false), - })); - - const textProps = { - size: "small", - autoComplete: "off", - sx: { width: 135 }, - } as const; - - const handleChange = (field: keyof typeof theme) => (e: any) => { - setTheme((t) => ({ ...t, [field]: e.target.value })); - }; - - const onSave = useLockFn(async () => { - try { - const msgs = (Object.keys(theme) as Array).reduce( - (acc, cur) => { - if (theme[cur] === "") { - return acc; - } - // theme.page_transition_duration should be string here - if (cur === "page_transition_duration") { - acc[cur] = parseFloat( - theme.page_transition_duration as unknown as string, - ); - } else { - acc[cur] = theme[cur]; - } - return acc; - }, - {} as Exclude, - ); - await patchVerge({ theme_setting: msgs }); - setOpen(false); - } catch (err: any) { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - } - }); - - // default theme - const { palette } = useTheme(); - - const dt = palette.mode === "light" ? defaultTheme : defaultDarkTheme; - - type ThemeKey = keyof typeof theme & keyof typeof defaultTheme; - - const renderItem = (label: string, key: ThemeKey) => { - const [color, setColor] = React.useState(theme[key] || dt[key]); - - const onChange = (color: string) => { - if (!color) { - color = dt[key]; - } - - setColor(color); - setTheme((t) => ({ ...t, [key]: color })); - }; - - return ( - - - - - - ); - }; - - return ( - setOpen(false)} - onCancel={() => setOpen(false)} - onOk={onSave} - > - - {renderItem("Primary Color", "primary_color")} - - {renderItem("Secondary Color", "secondary_color")} - - {renderItem("Primary Text", "primary_text")} - - {renderItem("Secondary Text", "secondary_text")} - - {renderItem("Info Color", "info_color")} - - {renderItem("Error Color", "error_color")} - - {renderItem("Warning Color", "warning_color")} - - {renderItem("Success Color", "success_color")} - - - - e.key === "Enter" && onSave()} - /> - - - - - e.key === "Enter" && onSave()} - /> - - - {/* 单位为秒,内容为浮点数 */} - - e.key === "Enter" && onSave()} - /> - - - - ); -}); - -ThemeViewer.displayName = "ThemeViewer"; - -const Item = styled(ListItem)(() => ({ - padding: "5px 2px", -})); - -const Round = styled("div")(() => ({ - width: "24px", - height: "24px", - borderRadius: "18px", - display: "inline-block", - marginRight: "8px", -})); diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/update-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/update-viewer.tsx deleted file mode 100644 index c5fff310d6..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/update-viewer.tsx +++ /dev/null @@ -1,102 +0,0 @@ -import { BaseDialog, DialogRef } from "@/components/base"; -import { useMessage } from "@/hooks/use-notification"; -import { isPortable } from "@/services/cmds"; -import { relaunch } from "@tauri-apps/api/process"; -import { checkUpdate, installUpdate } from "@tauri-apps/api/updater"; -import { open as openWebUrl } from "@tauri-apps/api/shell"; -import { useLockFn } from "ahooks"; -import { forwardRef, useImperativeHandle, useState } from "react"; -import { useTranslation } from "react-i18next"; -import Markdown, { Components } from "react-markdown"; -import useSWR from "swr"; -import { Chip, Tooltip } from "@mui/material"; -import { useAtom } from "jotai"; -import { atomUpdateState } from "@/store"; - -export const UpdateViewer = forwardRef((props, ref) => { - const { t } = useTranslation(); - - const [open, setOpen] = useState(false); - const [updateState, setUpdateState] = useAtom(atomUpdateState); - - const { data: updateInfo } = useSWR("checkUpdate", checkUpdate, { - errorRetryCount: 2, - revalidateIfStale: false, - focusThrottleInterval: 36e5, // 1 hour - }); - - useImperativeHandle(ref, () => ({ - open: () => setOpen(true), - close: () => setOpen(false), - })); - - const components: Components = { - a: ({ children, href }) => { - const click = () => openWebUrl(href || ""); - - return ( - - - - ); - }, - }; - - const updatePreprocess = () => { - const context = updateInfo?.manifest?.body; - - if (!context) { - return "New Version is available"; - } - - return context.replace(/@(\w+)/g, "[@$1](https://github.com/$1)"); - }; - - const onUpdate = useLockFn(async () => { - const portable = await isPortable(); - if (portable) { - useMessage(t("Portable Update Error"), { - type: "error", - title: t("Error"), - }); - return; - } - if (updateState) return; - setUpdateState(true); - - try { - await installUpdate(); - await relaunch(); - } catch (err: any) { - useMessage(err.message || err.toString(), { - type: "error", - title: t("Error"), - }); - } finally { - setUpdateState(false); - } - }); - - return ( - setOpen(false)} - onCancel={() => setOpen(false)} - onOk={onUpdate} - > - {/* */} - {updatePreprocess()} - - ); -}); - -UpdateViewer.displayName = "UpdateViewer"; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/web-ui-item.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/web-ui-item.tsx deleted file mode 100644 index 5d3d84d591..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/web-ui-item.tsx +++ /dev/null @@ -1,130 +0,0 @@ -import { useState } from "react"; -import { - Divider, - IconButton, - Stack, - TextField, - Typography, -} from "@mui/material"; -import { - CheckRounded, - CloseRounded, - DeleteRounded, - EditRounded, - OpenInNewRounded, -} from "@mui/icons-material"; - -interface Props { - value?: string; - onlyEdit?: boolean; - onChange: (value?: string) => void; - onOpenUrl?: (value?: string) => void; - onDelete?: () => void; - onCancel?: () => void; -} - -export const WebUIItem = (props: Props) => { - const { - value, - onlyEdit = false, - onChange, - onDelete, - onOpenUrl, - onCancel, - } = props; - - const [editing, setEditing] = useState(false); - const [editValue, setEditValue] = useState(value); - - if (editing || onlyEdit) { - return ( - <> - - setEditValue(e.target.value)} - placeholder={`Support %host %port %secret`} - autoComplete="off" - /> - { - onChange(editValue); - setEditing(false); - }} - > - - - { - onCancel?.(); - setEditing(false); - }} - > - - - - - - ); - } - - const html = value - ?.replace("%host", "%host") - .replace("%port", "%port") - .replace("%secret", "%secret"); - - return ( - <> - - ({ - "> span": { - color: palette.primary.main, - }, - })} - dangerouslySetInnerHTML={{ __html: html || "NULL" }} - /> - onOpenUrl?.(value)} - > - - - { - setEditing(true); - setEditValue(value); - }} - > - - - - - - - - - ); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/web-ui-viewer.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/web-ui-viewer.tsx deleted file mode 100644 index adb56caceb..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/mods/web-ui-viewer.tsx +++ /dev/null @@ -1,145 +0,0 @@ -import { BaseDialog, BaseEmpty, DialogRef } from "@/components/base"; -import { useClashInfo } from "@/hooks/use-clash"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { useVerge } from "@/hooks/use-verge"; -import { openWebUrl } from "@/services/cmds"; -import { Box, Button, Typography } from "@mui/material"; -import { useLockFn } from "ahooks"; -import { forwardRef, useImperativeHandle, useState } from "react"; -import { useTranslation } from "react-i18next"; -import { WebUIItem } from "./web-ui-item"; - -export const WebUIViewer = forwardRef((props, ref) => { - const { t } = useTranslation(); - - const { clashInfo } = useClashInfo(); - const { verge, patchVerge, mutateVerge } = useVerge(); - - const [open, setOpen] = useState(false); - const [editing, setEditing] = useState(false); - - useImperativeHandle(ref, () => ({ - open: () => setOpen(true), - close: () => setOpen(false), - })); - - const webUIList = verge?.web_ui_list || []; - - const handleAdd = useLockFn(async (value: string) => { - const newList = [value, ...webUIList]; - mutateVerge((old) => (old ? { ...old, web_ui_list: newList } : old), false); - await patchVerge({ web_ui_list: newList }); - }); - - const handleChange = useLockFn(async (index: number, value?: string) => { - const newList = [...webUIList]; - newList[index] = value ?? ""; - mutateVerge((old) => (old ? { ...old, web_ui_list: newList } : old), false); - await patchVerge({ web_ui_list: newList }); - }); - - const handleDelete = useLockFn(async (index: number) => { - const newList = [...webUIList]; - newList.splice(index, 1); - mutateVerge((old) => (old ? { ...old, web_ui_list: newList } : old), false); - await patchVerge({ web_ui_list: newList }); - }); - - const handleOpenUrl = useLockFn(async (value?: string) => { - if (!value) return; - try { - let url = value.trim().replaceAll("%host", "127.0.0.1"); - - if (url.includes("%port") || url.includes("%secret")) { - if (!clashInfo) throw new Error("failed to get clash info"); - if (!clashInfo.server?.includes(":")) { - throw new Error(`failed to parse the server "${clashInfo.server}"`); - } - - const port = clashInfo.server - .slice(clashInfo.server.indexOf(":") + 1) - .trim(); - - url = url.replaceAll("%port", port || "9090"); - url = url.replaceAll( - "%secret", - encodeURIComponent(clashInfo.secret || ""), - ); - } - - await openWebUrl(url); - } catch (e: any) { - useNotification({ - title: t("Error"), - body: e.message || e.toString(), - type: NotificationType.Error, - }); - } - }); - - return ( - - {t("Web UI")} - - - } - contentSx={{ - width: 450, - height: 300, - pb: 1, - overflowY: "auto", - userSelect: "text", - }} - cancelBtn={t("Back")} - disableOk - onClose={() => setOpen(false)} - onCancel={() => setOpen(false)} - > - {editing && ( - { - setEditing(false); - handleAdd(v || ""); - }} - onCancel={() => setEditing(false)} - /> - )} - - {!editing && webUIList.length === 0 && ( - - Replace host, port, secret with "%host" - "%port" "%secret" - - } - /> - )} - - {webUIList.map((item, index) => ( - handleChange(index, v)} - onDelete={() => handleDelete(index)} - onOpenUrl={handleOpenUrl} - /> - ))} - - ); -}); - -WebUIViewer.displayName = "WebUIViewer"; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-clash.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-clash.tsx deleted file mode 100644 index 6551c9b53d..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-clash.tsx +++ /dev/null @@ -1,235 +0,0 @@ -import { DialogRef } from "@/components/base"; -import { useClash } from "@/hooks/use-clash"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { useVerge } from "@/hooks/use-verge"; -import { invoke_uwp_tool } from "@/services/cmds"; -import getSystem from "@/utils/get-system"; -import { ArrowForward, Settings, Shuffle } from "@mui/icons-material"; -import { - IconButton, - MenuItem, - Select, - TextField, - Tooltip, - Typography, -} from "@mui/material"; -import { useRef, useState } from "react"; -import { useTranslation } from "react-i18next"; -import { ClashCoreViewer } from "./mods/clash-core-viewer"; -import { ClashFieldViewer } from "./mods/clash-field-viewer"; -import { ClashPortViewer } from "./mods/clash-port-viewer"; -import { ControllerViewer } from "./mods/controller-viewer"; -import { GuardState } from "./mods/guard-state"; -import { SettingItem, SettingList } from "./mods/setting-comp"; -import { WebUIViewer } from "./mods/web-ui-viewer"; -import MDYSwitch from "../common/mdy-switch"; - -const isWIN = getSystem() === "windows"; - -interface Props { - onError: (err: Error) => void; -} - -const SettingClash = ({ onError }: Props) => { - const { t } = useTranslation(); - - const { clash, version, mutateClash, patchClash } = useClash(); - const { verge, mutateVerge, patchVerge } = useVerge(); - - const { ipv6, "allow-lan": allowLan, "log-level": logLevel } = clash ?? {}; - - const { enable_random_port = false, verge_mixed_port } = verge ?? {}; - - const [loading, setLoading] = useState({ - ipv6: false, - "allow-lan": false, - "log-level": false, - }); - - const patchClashWithLoading = async (value: Partial) => { - try { - setLoading((prevLoading) => ({ - ...prevLoading, - ...Object.fromEntries(Object.keys(value).map((key) => [key, true])), - })); - - await patchClash(value); - } finally { - setLoading((prevLoading) => ({ - ...prevLoading, - ...Object.fromEntries(Object.keys(value).map((key) => [key, false])), - })); - } - }; - - const webRef = useRef(null); - const fieldRef = useRef(null); - const portRef = useRef(null); - const ctrlRef = useRef(null); - const coreRef = useRef(null); - - const onSwitchFormat = (_e: any, value: boolean) => value; - - const onChangeVerge = (patch: Partial) => { - mutateVerge({ ...verge, ...patch }, false); - }; - - return ( - - - - - - - - - patchClashWithLoading({ "allow-lan": e })} - loading={loading["allow-lan"]} - > - - - - - - patchClashWithLoading({ ipv6: e })} - loading={loading["ipv6"]} - > - - - - - - e.target.value} - onGuard={(e) => patchClashWithLoading({ "log-level": e })} - loading={loading["log-level"]} - > - - - - - - { - useNotification({ - title: `${t("Random Port")}: ${ - enable_random_port ? t("Disable") : t("Enable") - }`, - body: t("After restart to take effect"), - }); - onChangeVerge({ enable_random_port: !enable_random_port }); - patchVerge({ enable_random_port: !enable_random_port }); - }} - > - - - - } - > - { - portRef.current?.open(); - (e.target as any).blur(); - }} - /> - - - - ctrlRef.current?.open()} - > - - - - - - webRef.current?.open()} - > - - - - - - fieldRef.current?.open()} - > - - - - - coreRef.current?.open()} - > - - - } - > - {version} - - {isWIN && ( - - - - - - )} - - ); -}; - -export default SettingClash; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-legacy.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-legacy.tsx deleted file mode 100644 index ee966c2b7a..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-legacy.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import { - NotificationType, - useMessage, - useNotification, -} from "@/hooks/use-notification"; -import Paper from "@mui/material/Paper"; -import { BaseCard } from "@nyanpasu/ui"; -import { lazy, Suspense, useState } from "react"; -import { useTranslation } from "react-i18next"; -import { LabelSwitch } from "./modules/clash-field"; -import Box from "@mui/material/Box"; - -export const SettingLegacy = () => { - const { t } = useTranslation(); - - const [show, setShow] = useState(false); - - const legacyComponents = [ - () => import("./setting-clash"), - () => import("./setting-system"), - () => import("./setting-verge"), - ]; - - const onError = (err: any) => { - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }); - }; - - const handleChange = async () => { - if (!show) { - const content = - "Legacy Settings will be completely removed in a future update. They are retained here solely for debugging purposes. No fixes will be made for any issues encountered when using them."; - - await useMessage(content, { - type: "warning", - title: "Warning", - }); - } - - setShow(!show); - }; - - return ( - <> - - - handleChange()} - /> - - - - {show && - legacyComponents.map((item, index) => { - const AsyncComponent = lazy(item); - - return ( - - - - - - ); - })} - - ); -}; - -export default SettingLegacy; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-nyanpasu-misc.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-nyanpasu-misc.tsx index c62938fa1e..9424332e22 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-nyanpasu-misc.tsx +++ b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-nyanpasu-misc.tsx @@ -47,6 +47,11 @@ export const SettingNyanpasuMisc = () => { {...createBooleanProps("clash_tray_selector")} /> + + void; -} - -const isWIN = getSystem() === "windows"; - -const SettingSystem = ({ onError }: Props) => { - const { t } = useTranslation(); - - const { verge, patchVerge } = useVerge(); - - // service mode - const { data: serviceStatus } = useSWR( - isWIN ? "checkService" : null, - checkService, - { - revalidateIfStale: false, - shouldRetryOnError: false, - focusThrottleInterval: 36e5, // 1 hour - }, - ); - - const serviceRef = useRef(null); - const sysproxyRef = useRef(null); - - const { - enable_tun_mode, - enable_auto_launch, - enable_service_mode, - enable_silent_start, - enable_system_proxy, - } = verge ?? {}; - - const [loading, setLoading] = useState({ - enable_tun_mode: false, - enable_auto_launch: false, - enable_service_mode: false, - enable_silent_start: false, - enable_system_proxy: false, - }); - - const patchVergeWithLoading = async (value: Partial) => { - try { - setLoading((prevLoading) => ({ - ...prevLoading, - ...Object.fromEntries(Object.keys(value).map((key) => [key, true])), - })); - - await patchVerge(value); - } finally { - setLoading((prevLoading) => ({ - ...prevLoading, - ...Object.fromEntries(Object.keys(value).map((key) => [key, false])), - })); - } - }; - - const onSwitchFormat = (_e: any, value: boolean) => value; - - return ( - - - {isWIN && ( - - )} - - - patchVergeWithLoading({ enable_tun_mode: e })} - loading={loading["enable_tun_mode"]} - > - - - - - {isWIN && ( - serviceRef.current?.open()} - > - - - } - > - patchVergeWithLoading({ enable_service_mode: e })} - loading={loading["enable_service_mode"]} - > - - - - )} - - sysproxyRef.current?.open()} - > - - - } - > - patchVergeWithLoading({ enable_system_proxy: e })} - loading={loading["enable_system_proxy"]} - > - - - - - - patchVergeWithLoading({ enable_auto_launch: e })} - loading={loading["enable_auto_launch"]} - > - - - - - - patchVergeWithLoading({ enable_silent_start: e })} - loading={loading["enable_auto_launch"]} - > - - - - - ); -}; - -export default SettingSystem; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-verge.tsx b/clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-verge.tsx deleted file mode 100644 index d7c0cc3a80..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/components/setting/setting-verge.tsx +++ /dev/null @@ -1,356 +0,0 @@ -import { DialogRef } from "@/components/base"; -import { useMessage, useNotification } from "@/hooks/use-notification"; -import { useVerge } from "@/hooks/use-verge"; -import { - collectLogs, - isPortable, - openAppDir, - openCoreDir, - openLogsDir, - restartApplication, - setCustomAppDir, -} from "@/services/cmds"; -import { sleep } from "@/utils"; -import getSystem from "@/utils/get-system"; -import { ArrowForward, IosShare, Settings } from "@mui/icons-material"; -import { - Chip, - CircularProgress, - IconButton, - MenuItem, - Select, - Tooltip, - Typography, -} from "@mui/material"; -import { open } from "@tauri-apps/api/dialog"; -import { checkUpdate } from "@tauri-apps/api/updater"; -import { useAsyncEffect, useLockFn } from "ahooks"; -import { useRef, useState } from "react"; -import { useTranslation } from "react-i18next"; -import { version } from "~/package.json"; -import MDYSwitch from "../common/mdy-switch"; -import { ConfigViewer } from "./mods/config-viewer"; -import { GuardState } from "./mods/guard-state"; -import { HotkeyViewer } from "./mods/hotkey-viewer"; -import { LayoutViewer } from "./mods/layout-viewer"; -import { MiscViewer } from "./mods/misc-viewer"; -import { SettingItem, SettingList } from "./mods/setting-comp"; -import { TasksViewer } from "./mods/tasks-viewer"; -import { ThemeModeSwitch } from "./mods/theme-mode-switch"; -import { ThemeViewer } from "./mods/theme-viewer"; -import { UpdateViewer } from "./mods/update-viewer"; - -interface Props { - onError?: (err: Error) => void; -} - -const OS = getSystem(); - -const SettingVerge = ({ onError }: Props) => { - const { t } = useTranslation(); - - const { verge, patchVerge } = useVerge(); - const { theme_mode, language, disable_auto_check_update } = verge ?? {}; - const [portable, setPortable] = useState(false); - - useAsyncEffect(async () => { - setPortable(await isPortable()); - }); - - const [loading, setLoading] = useState({ - theme_mode: false, - language: false, - onCheckUpdate: false, - }); - - const tipChips = useRef({ - onCheckUpdate: "", - }); - - const configRef = useRef(null); - const hotkeyRef = useRef(null); - const miscRef = useRef(null); - const themeRef = useRef(null); - const layoutRef = useRef(null); - const updateRef = useRef(null); - const tasksRef = useRef(null); - - const onCheckUpdate = useLockFn(async () => { - try { - setLoading((prevLoading) => ({ - ...prevLoading, - onCheckUpdate: true, - })); - - const info = await checkUpdate(); - - if (!info?.shouldUpdate) { - tipChips.current.onCheckUpdate = t("No update available"); - } else { - updateRef.current?.open(); - } - } catch (err: any) { - useMessage(err.message || err.toString(), { - title: t("Error"), - type: "error", - }); - } finally { - setLoading((prevLoading) => ({ - ...prevLoading, - onCheckUpdate: false, - })); - } - }); - - const onSwitchFormat = (_e: any, value: boolean) => value; - - const [changingAppDir, setChangingAppDir] = useState(false); - const changeAppDir = useLockFn(async () => { - setChangingAppDir(true); - try { - const selected = await open({ directory: true, multiple: false }); // TODO: use current app dir as defaultPath - if (!selected) return; // user cancelled the selection - if (Array.isArray(selected)) { - useMessage(t("Multiple directories are not supported"), { - title: t("Error"), - type: "error", - }); - return; - } - await setCustomAppDir(selected); - useNotification({ - title: t("Success"), - body: t("App directory changed successfully"), - }); - await sleep(1000); - await restartApplication(); - } catch (err: any) { - useMessage(err.message || err.toString(), { - title: t("Error"), - type: "error", - }); - } finally { - setChangingAppDir(false); - } - }); - - return ( - - - - - - - - - - - e.target.value} - onGuard={(e) => patchVerge({ language: e })} - loading={loading["language"]} - > - - - - - - patchVerge({ theme_mode: e })} - loading={loading["theme_mode"]} - > - - - - - - themeRef.current?.open()} - > - - - - - - layoutRef.current?.open()} - > - - - - - - tasksRef.current?.open()} - > - - - - - - miscRef.current?.open()} - > - - - - - - hotkeyRef.current?.open()} - > - - - - - - configRef.current?.open()} - > - - - - - - {changingAppDir ? ( - - ) : ( - - )} - - } - > - - - - - - - - - - - - - { - collectLogs(); - }} - > - - - - } - > - - - - - - {!(OS === "windows" && WIN_PORTABLE) && ( - <> - - ) - } - > - - {loading["onCheckUpdate"] ? ( - - ) : ( - - )} - - - - - patchVerge({ disable_auto_check_update: !e })} - > - - - - - )} - - - v{version} - - - ); -}; - -export default SettingVerge; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/hooks/use-notification.ts b/clash-nyanpasu/frontend/nyanpasu/src/hooks/use-notification.ts index ad8b3d0355..6694e8abf6 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/hooks/use-notification.ts +++ b/clash-nyanpasu/frontend/nyanpasu/src/hooks/use-notification.ts @@ -1,5 +1,4 @@ import { Notice } from "@/components/base"; -import { isPortable } from "@/services/cmds"; import { Options, isPermissionGranted, @@ -7,6 +6,7 @@ import { sendNotification, } from "@tauri-apps/api/notification"; import { MessageDialogOptions, message } from "@tauri-apps/api/dialog"; +import { isPortable } from "@nyanpasu/interface"; let permissionGranted: boolean | null = null; let portable: boolean | null = null; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/locales/en.json b/clash-nyanpasu/frontend/nyanpasu/src/locales/en.json index 101b3d060c..db4338f997 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/locales/en.json +++ b/clash-nyanpasu/frontend/nyanpasu/src/locales/en.json @@ -152,5 +152,6 @@ "Portable Update Error": "Portable Update is not supported, please download the latest version from the official website.", "Enable Tray Proxies Selector": "Enable Tray Proxies Selector", "Proxy Set proxies": "{{rule}} proxies", - "Update Proxies Providers All": "Update Rules Proxies All" + "Update Proxies Providers All": "Update Rules Proxies All", + "Lighten up Animation Effects": "Lighten up Animation Effects" } diff --git a/clash-nyanpasu/frontend/nyanpasu/src/locales/zh.json b/clash-nyanpasu/frontend/nyanpasu/src/locales/zh.json index 3abba34e99..13539fce76 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/locales/zh.json +++ b/clash-nyanpasu/frontend/nyanpasu/src/locales/zh.json @@ -165,5 +165,6 @@ "Enable Tray Proxies Selector": "开启托盘代理选择", "Proxy Set proxies": "{{rule}} 个节点", - "Update Proxies Providers All": "全部更新" + "Update Proxies Providers All": "全部更新", + "Lighten up Animation Effects": "减轻动画效果" } diff --git a/clash-nyanpasu/frontend/nyanpasu/src/pages/_app.tsx b/clash-nyanpasu/frontend/nyanpasu/src/pages/_app.tsx index 0b67d542dd..a9f43a36c2 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/pages/_app.tsx +++ b/clash-nyanpasu/frontend/nyanpasu/src/pages/_app.tsx @@ -1,209 +1,52 @@ -import { LayoutControl } from "@/components/layout/layout-control"; -import { LayoutTraffic } from "@/components/layout/layout-traffic"; +import { useTheme } from "@mui/material"; +import { Experimental_CssVarsProvider as CssVarsProvider } from "@mui/material/styles"; +import { AnimatePresence } from "framer-motion"; +import { classNames } from "@/utils"; import { ThemeModeProvider, useCustomTheme, } from "@/components/layout/use-custom-theme"; -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { useVerge } from "@/hooks/use-verge"; -import { getAxios } from "@/services/api"; -import getSystem from "@/utils/get-system"; -import { List, Paper, ThemeProvider, alpha, useTheme } from "@mui/material"; -import { emit, listen } from "@tauri-apps/api/event"; -import { appWindow } from "@tauri-apps/api/window"; -import dayjs from "dayjs"; +import PageTransition from "@/components/layout/page-transition"; +import LogProvider from "@/components/logs/log-provider"; +import LocalesProvider from "@/components/app/locales-provider"; +import AppContainer from "@/components/app/app-container"; +import NoticeProvider from "@/components/layout/notice-provider"; +import SchemeProvider from "@/components/layout/scheme-provider"; +import { useBreakpoint } from "@nyanpasu/ui"; +import { FallbackProps } from "react-error-boundary"; +import { SWRConfig } from "swr"; +import styles from "./_app.module.scss"; + import "dayjs/locale/ru"; import "dayjs/locale/zh-cn"; -import relativeTime from "dayjs/plugin/relativeTime"; -import { AnimatePresence } from "framer-motion"; -import i18next from "i18next"; -import { useEffect } from "react"; -import { useTranslation } from "react-i18next"; -import { SWRConfig, mutate } from "swr"; -// import { routers } from "./_routers"; -import { LayoutItem } from "@/components/layout/layout-item"; -import PageTransition from "@/components/layout/page-transition"; -import { useNavigate, type Path } from "@/router"; -import { classNames } from "@/utils"; -import AnimatedLogo from "@/components/layout/animated-logo"; -import { FallbackProps } from "react-error-boundary"; -import styles from "./_app.module.scss"; -import { Experimental_CssVarsProvider as CssVarsProvider } from "@mui/material/styles"; -import LogProvider from "@/components/logs/log-provider"; +import dayjs from "dayjs"; +import relativeTime from "dayjs/plugin/relativeTime"; +import { useMemo } from "react"; dayjs.extend(relativeTime); -const OS = getSystem(); - -export const routes = { - proxies: "/proxies", - profiles: "/profiles", - connections: "/connections", - rules: "/rules", - logs: "/logs", - settings: "/settings", - providers: "/providers", -}; - export default function App() { - const { t } = useTranslation(); - const { theme } = useCustomTheme(); - const { verge } = useVerge(); - const { theme_blur, language } = verge || {}; + const { column } = useBreakpoint(); - const navigate = useNavigate(); - // const location = useLocation(); - // const routes = useRoutes(routers); - // if (!routes) return null; - - useEffect(() => { - window.addEventListener("keydown", (e) => { - // macOS有cmd+w - if (e.key === "Escape" && OS !== "macos") { - appWindow.close(); - } - }); - - listen("verge://refresh-clash-config", async () => { - // the clash info may be updated - await getAxios(true); - mutate("getProxies"); - mutate("getVersion"); - mutate("getClashConfig"); - mutate("getProviders"); - }); - - // update the verge config - listen("verge://refresh-verge-config", () => mutate("getVergeConfig")); - - // 设置提示监听 - listen("verge://notice-message", ({ payload }) => { - const [status, msg] = payload as [string, string]; - switch (status) { - case "set_config::ok": - useNotification({ - title: t("Success"), - body: "Refresh Clash Config", - type: NotificationType.Success, - }); - break; - case "set_config::error": - useNotification({ - title: t("Error"), - body: msg, - type: NotificationType.Error, - }); - break; - default: - break; - } - }); - - listen("verge://mutate-proxies", () => { - mutate("getProxies"); - mutate("getProviders"); - }); - - listen("scheme-request-received", (req) => { - const message: string = req.payload as string; - const url = new URL(message); - if (url.pathname.endsWith("/")) url.pathname = url.pathname.slice(0, -1); - if (url.pathname.startsWith("//")) url.pathname = url.pathname.slice(1); - switch (url.pathname) { - case "/subscribe-remote-profile": - navigate("/profiles", { - state: { - subscribe: { - url: url.searchParams.get("url"), - name: url.searchParams.has("name") - ? decodeURIComponent(url.searchParams.get("name")!) - : undefined, - desc: url.searchParams.has("desc") - ? decodeURIComponent(url.searchParams.get("desc")!) - : undefined, - }, - }, - }); - } - }); - - setTimeout(() => { - appWindow.show(); - appWindow.unminimize(); - appWindow.setFocus(); - emit("init-complete"); - }, 50); - }, []); - - useEffect(() => { - if (language) { - dayjs.locale(language === "zh" ? "zh-cn" : language); - i18next.changeLanguage(language); - } - }, [language]); + const isDrawer = useMemo(() => Boolean(column === 1), [column]); return ( + + + - { - if (e.target?.dataset?.windrag) appWindow.startDragging(); - }} - onContextMenu={(e) => { - // only prevent it on Windows - const validList = ["input", "textarea"]; - const target = e.currentTarget; - if ( - OS === "windows" && - !( - validList.includes(target.tagName.toLowerCase()) || - target.isContentEditable - ) - ) { - e.preventDefault(); - } - }} - sx={[ - ({ palette }) => ({ - bgcolor: alpha(palette.background.paper, theme_blur ? 0.8 : 1), - }), - ]} - > -
- - - {Object.entries(routes).map(([name, to]) => ( - - {t(`label_${name}`)} - - ))} - - -
- -
-
- -
- {OS === "windows" && } - -
- - - {/* {React.cloneElement(routes, { key: location.pathname })} */} - - -
- + + + ); @@ -211,6 +54,7 @@ export default function App() { export const Catch = ({ error }: FallbackProps) => { const theme = useTheme(); + return (
{ - // const theme = useTheme(); return ( -
+

Oops!

Something went wrong... Caught at _layout error boundary.

{error.message}
diff --git a/clash-nyanpasu/frontend/nyanpasu/src/pages/proxies.tsx b/clash-nyanpasu/frontend/nyanpasu/src/pages/proxies.tsx index 236c296a42..dec5cda344 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/pages/proxies.tsx +++ b/clash-nyanpasu/frontend/nyanpasu/src/pages/proxies.tsx @@ -2,98 +2,20 @@ import { Box, Button, ButtonGroup, - Menu, - MenuItem, TextField, alpha, useTheme, } from "@mui/material"; -import { memo, useEffect, useState } from "react"; +import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { useNyanpasu, useClashCore, Clash } from "@nyanpasu/interface"; import { SidePage } from "@nyanpasu/ui"; import { DelayButton, GroupList, NodeList } from "@/components/proxies"; -import { Public } from "@mui/icons-material"; import { useAtom } from "jotai"; -import { proxyGroupAtom, proxyGroupSortAtom } from "@/store"; -import { AnimatePresence, motion } from "framer-motion"; - -const ContentDisplay = ({ message }: { message: string }) => ( -
-
- - {message} -
-
-); - -const ProxyGroupName = memo(function ProxyGroupName({ - name, -}: { - name: string; -}) { - return ( - - - {name} - - - ); -}); - -const SortSelector = memo(function SortSelector() { - const { t } = useTranslation(); - - const [proxyGroupSort, setProxyGroupSort] = useAtom(proxyGroupSortAtom); - - type SortType = typeof proxyGroupSort; - - const [anchorEl, setAnchorEl] = useState(null); - - const handleClick = (sort: SortType) => { - setAnchorEl(null); - setProxyGroupSort(sort); - }; - - const tmaps: { [key: string]: string } = { - default: "Sort by default", - delay: "Sort by delay", - name: "Sort by name", - }; - - return ( - <> - - - setAnchorEl(null)} - > - {Object.entries(tmaps).map(([key, value], index) => { - return ( - handleClick(key as SortType)}> - {t(value)} - - ); - })} - - - ); -}); +import { proxyGroupAtom } from "@/store"; +import ContentDisplay from "@/components/base/content-display"; +import SortSelector from "@/components/proxies/sort-selector"; +import ProxyGroupName from "@/components/proxies/proxy-group-name"; export default function ProxyPage() { const { t } = useTranslation(); diff --git a/clash-nyanpasu/frontend/nyanpasu/src/pages/settings.tsx b/clash-nyanpasu/frontend/nyanpasu/src/pages/settings.tsx index fb108d9573..e9b3af41c8 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/pages/settings.tsx +++ b/clash-nyanpasu/frontend/nyanpasu/src/pages/settings.tsx @@ -23,7 +23,6 @@ const asyncComponents = [ () => import("@/components/setting/setting-nyanpasu-misc"), () => import("@/components/setting/setting-nyanpasu-path"), () => import("@/components/setting/setting-nyanpasu-version"), - () => import("@/components/setting/setting-legacy"), ]; const GithubIcon = () => { diff --git a/clash-nyanpasu/frontend/nyanpasu/src/services/api.ts b/clash-nyanpasu/frontend/nyanpasu/src/services/api.ts deleted file mode 100644 index d5d7572756..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/services/api.ts +++ /dev/null @@ -1,231 +0,0 @@ -import axios, { AxiosInstance } from "axios"; -import { getClashInfo } from "./cmds"; - -let axiosIns: AxiosInstance = null!; - -/// initialize some information -/// enable force update axiosIns -export const getAxios = async (force: boolean = false) => { - if (axiosIns && !force) return axiosIns; - - let server = ""; - let secret = ""; - - try { - const info = await getClashInfo(); - - if (info?.server) { - server = info.server; - - // compatible width `external-controller` - if (server.startsWith(":")) server = `127.0.0.1${server}`; - else if (/^\d+$/.test(server)) server = `127.0.0.1:${server}`; - } - if (info?.secret) secret = info?.secret; - } catch {} - - axiosIns = axios.create({ - baseURL: `http://${server}`, - headers: secret ? { Authorization: `Bearer ${secret}` } : {}, - timeout: 15000, - }); - axiosIns.interceptors.response.use((r) => r.data); - return axiosIns; -}; - -/// Get Version -export const getVersion = async () => { - const instance = await getAxios(); - return instance.get("/version") as Promise<{ - premium: boolean; - meta?: boolean; - version: string; - }>; -}; - -/// Get current base configs -export const getClashConfig = async () => { - const instance = await getAxios(); - return instance.get("/configs") as Promise; -}; - -/// Update current configs -export const updateConfigs = async (config: Partial) => { - const instance = await getAxios(); - return instance.patch("/configs", config); -}; - -/// Get current rules -export const getRules = async () => { - const instance = await getAxios(); - const response = await instance.get("/rules"); - return response?.rules as IRuleItem[]; -}; - -/// Get Proxy delay -export const getProxyDelay = async (name: string, url?: string) => { - const params = { - timeout: 10000, - url: url || "http://www.gstatic.com/generate_204", - }; - const instance = await getAxios(); - const result = await instance.get( - `/proxies/${encodeURIComponent(name)}/delay`, - { params }, - ); - return result as any as { delay: number }; -}; - -/// Update the Proxy Choose -export const updateProxy = async (group: string, proxy: string) => { - const instance = await getAxios(); - return instance.put(`/proxies/${encodeURIComponent(group)}`, { name: proxy }); -}; - -// get proxy -export const getProxiesInner = async () => { - const instance = await getAxios(); - const response = await instance.get("/proxies"); - return (response?.proxies || {}) as Record; -}; - -/// Get the Proxy information -export const getProxies = async () => { - const [proxyRecord, providerRecord] = await Promise.all([ - getProxiesInner(), - getProviders(), - ]); - - // provider name map - const providerMap = Object.fromEntries( - Object.entries(providerRecord).flatMap(([provider, item]) => - item.proxies.map((p) => [p.name, { ...p, provider }]), - ), - ); - - // compatible with proxy-providers - const generateItem = (name: string) => { - if (proxyRecord[name]) return proxyRecord[name]; - if (providerMap[name]) return providerMap[name]; - return { name, type: "unknown", udp: false, history: [] }; - }; - - const { GLOBAL: global, DIRECT: direct, REJECT: reject } = proxyRecord; - - let groups: IProxyGroupItem[] = []; - - if (global?.all) { - groups = global.all - .filter((name) => proxyRecord[name]?.all) - .map((name) => proxyRecord[name]) - .map((each) => ({ - ...each, - all: each.all!.map((item) => generateItem(item)), - })); - } else { - groups = Object.values(proxyRecord) - .filter((each) => each.name !== "GLOBAL" && each.all) - .map((each) => ({ - ...each, - all: each.all!.map((item) => generateItem(item)), - })) - .sort((a, b) => b.name.localeCompare(a.name)); - } - - const proxies = [direct, reject].concat( - Object.values(proxyRecord).filter( - (p) => !p.all?.length && p.name !== "DIRECT" && p.name !== "REJECT", - ), - ); - - const _global: IProxyGroupItem = { - ...global, - all: global?.all?.map((item) => generateItem(item)) || [], - }; - - return { global: _global, direct, groups, records: proxyRecord, proxies }; -}; - -// get proxy providers -export const getProviders = async () => { - const instance = await getAxios(); - const response = await instance.get("/providers/proxies"); - - const providers = (response.providers || {}) as Record; - - return Object.fromEntries( - Object.entries(providers).filter(([key, item]) => { - const type = item.vehicleType.toLowerCase(); - return type === "http" || type === "file"; - }), - ); -}; - -export type IProxies = Awaited>; - -// proxy providers health check -export const providerHealthCheck = async (name: string) => { - const instance = await getAxios(); - return instance.get( - `/providers/proxies/${encodeURIComponent(name)}/healthcheck`, - ); -}; - -export const providerUpdate = async (name: string) => { - const instance = await getAxios(); - return instance.put(`/providers/proxies/${encodeURIComponent(name)}`); -}; - -export const getConnections = async () => { - const instance = await getAxios(); - const result = await instance.get("/connections"); - return result as any as IConnections; -}; - -// Close specific connection -export const deleteConnection = async (id: string) => { - const instance = await getAxios(); - await instance.delete(`/connections/${encodeURIComponent(id)}`); -}; - -// Close all connections -export const closeAllConnections = async () => { - const instance = await getAxios(); - await instance.delete(`/connections`); -}; - -export interface ProviderRules { - behavior: string; - format: string; - name: string; - ruleCount: number; - type: string; - updatedAt: string; - vehicleType: string; -} - -export interface ProvidersRules { - providers: { - [name: string]: { - behavior: string; - format: string; - name: string; - ruleCount: number; - type: string; - updatedAt: string; - vehicleType: string; - }; - }; -} - -// Get rule providers -export const getRulesProviders = async () => { - const instance = await getAxios(); - const response = await instance.get("/providers/rules"); - return Object.values(response.providers) as ProviderRules[]; -}; - -export const updateRulesProviders = async (name: string) => { - const instance = await getAxios(); - return instance.put(`/providers/rules/${name}`); -}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/services/cmds.ts b/clash-nyanpasu/frontend/nyanpasu/src/services/cmds.ts deleted file mode 100644 index 4834f9d06a..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/services/cmds.ts +++ /dev/null @@ -1,270 +0,0 @@ -import { NotificationType, useNotification } from "@/hooks/use-notification"; -import { invoke } from "@tauri-apps/api/tauri"; -import dayjs from "dayjs"; -import { t } from "i18next"; -import type { ManifestVersion } from "~/scripts/generate-latest-version"; -import type { IProxies } from "./api"; -export async function getClashLogs() { - const regex = /time="(.+?)"\s+level=(.+?)\s+msg="(.+?)"/; - const newRegex = /(.+?)\s+(.+?)\s+(.+)/; - const logs = await invoke("get_clash_logs"); - - return logs - .map((log) => { - const result = log.match(regex); - if (result) { - const [_, _time, type, payload] = result; - const time = dayjs(_time).format("MM-DD HH:mm:ss"); - return { time, type, payload }; - } - - const result2 = log.match(newRegex); - if (result2) { - const [_, time, type, payload] = result2; - return { time, type, payload }; - } - return null; - }) - .filter(Boolean) as ILogItem[]; -} - -export async function getProfiles() { - return invoke("get_profiles"); -} - -export async function enhanceProfiles() { - return invoke("enhance_profiles"); -} - -export async function patchProfilesConfig(profiles: IProfilesConfig) { - return invoke("patch_profiles_config", { profiles }); -} - -export async function createProfile( - item: Partial, - fileData?: string | null, -) { - return invoke("create_profile", { item, fileData }); -} - -export async function viewProfile(index: string) { - return invoke("view_profile", { index }); -} - -export async function readProfileFile(index: string) { - return invoke("read_profile_file", { index }); -} - -export async function saveProfileFile(index: string, fileData: string) { - return invoke("save_profile_file", { index, fileData }); -} - -export async function importProfile(url: string) { - return invoke("import_profile", { - url, - option: { with_proxy: true }, - }); -} - -export async function reorderProfile(activeId: string, overId: string) { - return invoke("reorder_profile", { - activeId, - overId, - }); -} - -export async function updateProfile(index: string, option?: IProfileOption) { - return invoke("update_profile", { index, option }); -} - -export async function deleteProfile(index: string) { - return invoke("delete_profile", { index }); -} - -export async function patchProfile( - index: string, - profile: Partial, -) { - return invoke("patch_profile", { index, profile }); -} - -export async function getClashInfo() { - return invoke("get_clash_info"); -} - -export async function getRuntimeConfig() { - return invoke("get_runtime_config"); -} - -export async function getRuntimeYaml() { - return invoke("get_runtime_yaml"); -} - -export async function getRuntimeExists() { - return invoke("get_runtime_exists"); -} - -export async function getRuntimeLogs() { - return invoke>("get_runtime_logs"); -} - -export async function patchClashConfig(payload: Partial) { - return invoke("patch_clash_config", { payload }); -} - -export async function getVergeConfig() { - return invoke("get_verge_config"); -} - -export async function patchVergeConfig(payload: IVergeConfig) { - return invoke("patch_verge_config", { payload }); -} - -export async function getSystemProxy() { - return invoke<{ - enable: boolean; - server: string; - bypass: string; - }>("get_sys_proxy"); -} - -export async function changeClashCore(clashCore: string) { - return invoke("change_clash_core", { clashCore }); -} - -export async function restartSidecar() { - return invoke("restart_sidecar"); -} - -export async function grantPermission(core: string) { - return invoke("grant_permission", { core }); -} - -export async function openAppDir() { - return invoke("open_app_dir").catch((err) => - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }), - ); -} - -export async function openCoreDir() { - return invoke("open_core_dir").catch((err) => - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }), - ); -} - -export async function openLogsDir() { - return invoke("open_logs_dir").catch((err) => - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }), - ); -} - -export async function openWebUrl(url: string) { - return invoke("open_web_url", { url }); -} - -/// service mode - -export async function checkService() { - try { - const result = await invoke("check_service"); - if (result?.code === 0) return "active"; - if (result?.code === 400) return "installed"; - return "unknown"; - } catch (err: any) { - return "uninstall"; - } -} - -export async function installService() { - return invoke("install_service"); -} - -export async function uninstallService() { - return invoke("uninstall_service"); -} - -export async function invoke_uwp_tool() { - return invoke("invoke_uwp_tool").catch((err) => - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }), - ); -} - -export async function save_window_size_state() { - return invoke("save_window_size_state").catch((err) => - useNotification({ - title: t("Error"), - body: err.message || err.toString(), - type: NotificationType.Error, - }), - ); -} - -export async function getCoreVersion( - coreType: Required["clash_core"], -) { - return invoke("get_core_version", { coreType }); -} - -export async function fetchLatestCoreVersions() { - return invoke("fetch_latest_core_versions"); -} - -export async function updateCore( - coreType: Required["clash_core"], -) { - return invoke("update_core", { coreType }); -} - -export async function collectLogs() { - return invoke("collect_logs"); -} - -export async function cmdGetProxyDelay(name: string, url?: string) { - name = encodeURIComponent(name); - return invoke<{ delay: number }>("clash_api_get_proxy_delay", { name, url }); -} - -export async function isPortable() { - if (OS_PLATFORM !== "win32") return false; - return invoke("is_portable"); -} - -export async function getProxies() { - return invoke("get_proxies"); -} - -export async function selectProxy(group: string, name: string) { - return invoke("select_proxy", { group, name }); -} - -export async function updateProxyProvider(name: string) { - return invoke("update_proxy_provider", { name }); -} - -export async function getCustomAppDir() { - return invoke("get_custom_app_dir"); -} - -export async function setCustomAppDir(path: string) { - return invoke("set_custom_app_dir", { path }); -} - -export async function restartApplication() { - return invoke("restart_application"); -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/services/delay.ts b/clash-nyanpasu/frontend/nyanpasu/src/services/delay.ts deleted file mode 100644 index b613f7e55c..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/services/delay.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { getProxyDelay } from "./api"; -import { cmdGetProxyDelay } from "./cmds"; - -const hashKey = (name: string, group: string) => `${group ?? ""}::${name}`; - -class DelayManager { - private cache = new Map(); - private urlMap = new Map(); - - // 每个item的监听 - private listenerMap = new Map void>(); - - // 每个分组的监听 - private groupListenerMap = new Map void>(); - - setUrl(group: string, url: string) { - this.urlMap.set(group, url); - } - - getUrl(group: string) { - return this.urlMap.get(group); - } - - setListener(name: string, group: string, listener: (time: number) => void) { - const key = hashKey(name, group); - this.listenerMap.set(key, listener); - } - - removeListener(name: string, group: string) { - const key = hashKey(name, group); - this.listenerMap.delete(key); - } - - setGroupListener(group: string, listener: () => void) { - this.groupListenerMap.set(group, listener); - } - - removeGroupListener(group: string) { - this.groupListenerMap.delete(group); - } - - setDelay(name: string, group: string, delay: number) { - const key = hashKey(name, group); - this.cache.set(key, [Date.now(), delay]); - this.listenerMap.get(key)?.(delay); - this.groupListenerMap.get(group)?.(); - } - - getDelay(name: string, group: string) { - if (!name) return -1; - - const result = this.cache.get(hashKey(name, group)); - if (result && Date.now() - result[0] <= 18e5) { - return result[1]; - } - return -1; - } - - /// 暂时修复provider的节点延迟排序的问题 - getDelayFix(proxy: IProxyItem, group: string) { - if (!proxy.provider) { - const delay = this.getDelay(proxy.name, group); - if (delay >= 0 || delay === -2) return delay; - } - - if (proxy.history.length > 0) { - // 0ms以error显示 - return proxy.history[proxy.history.length - 1].delay || 1e6; - } - return -1; - } - - async checkDelay(name: string, group: string) { - let delay = -1; - - try { - const url = this.getUrl(group); - const result = await cmdGetProxyDelay(name, url); - delay = result.delay; - } catch { - delay = 1e6; // error - } - - this.setDelay(name, group, delay); - return delay; - } - - async checkListDelay(nameList: string[], group: string, concurrency = 36) { - const names = nameList.filter(Boolean); - // 设置正在延迟测试中 - names.forEach((name) => this.setDelay(name, group, -2)); - - let total = names.length; - let current = 0; - - return new Promise((resolve) => { - const help = async (): Promise => { - if (current >= concurrency) return; - const task = names.shift(); - if (!task) return; - current += 1; - await this.checkDelay(task, group); - current -= 1; - total -= 1; - if (total <= 0) resolve(null); - else return help(); - }; - for (let i = 0; i < concurrency; ++i) help(); - }); - } - - formatDelay(delay: number) { - if (delay < 0) return "-"; - if (delay > 1e5) return "Error"; - if (delay >= 10000) return "Timeout"; // 10s - return `${delay}`; - } - - formatDelayColor(delay: number) { - if (delay <= 0) return "text.secondary"; - if (delay >= 10000) return "error.main"; - if (delay > 500) return "warning.main"; - if (delay > 100) return "text.secondary"; - return "success.main"; - } -} - -export default new DelayManager(); diff --git a/clash-nyanpasu/frontend/nyanpasu/src/services/types.d.ts b/clash-nyanpasu/frontend/nyanpasu/src/services/types.d.ts index 422490ac39..5a0ec28432 100644 --- a/clash-nyanpasu/frontend/nyanpasu/src/services/types.d.ts +++ b/clash-nyanpasu/frontend/nyanpasu/src/services/types.d.ts @@ -16,258 +16,3 @@ type Platform = */ declare const WIN_PORTABLE: boolean; declare const OS_PLATFORM: Platform; - -/** - * Some interface for clash api - */ -interface IConfigData { - port: number; - mode: string; - ipv6: boolean; - "socket-port": number; - "allow-lan": boolean; - "log-level": string; - "mixed-port": number; - "redir-port": number; - "socks-port": number; - "tproxy-port": number; - "external-controller": string; - secret: string; -} - -interface IRuleItem { - type: string; - payload: string; - proxy: string; -} - -interface IProxyItem { - name: string; - type: string; - udp: boolean; - history: { - time: string; - delay: number; - }[]; - all?: string[]; - now?: string; - provider?: string; // 记录是否来自provider -} - -type IProxyGroupItem = Omit & { - all: IProxyItem[]; -}; - -interface IProviderItem { - name: string; - type: string; - proxies: IProxyItem[]; - updatedAt: string; - vehicleType: string; -} - -interface ITrafficItem { - up: number; - down: number; -} - -interface ILogItem { - type: string; - time?: string; - payload: string; -} - -interface IConnectionsItem { - id: string; - metadata: { - network: string; - type: string; - host: string; - sourceIP: string; - sourcePort: string; - destinationPort: string; - destinationIP?: string; - process?: string; - processPath?: string; - }; - upload: number; - download: number; - start: string; - chains: string[]; - rule: string; - rulePayload: string; - curUpload?: number; // upload speed, calculate at runtime - curDownload?: number; // download speed, calculate at runtime -} - -interface IConnections { - downloadTotal: number; - uploadTotal: number; - connections: IConnectionsItem[]; -} - -/** - * Some interface for command - */ - -interface IClashInfo { - // status: string; - port?: number; // clash mixed port - server?: string; // external-controller - secret?: string; -} - -interface IProfileItem { - uid: string; - type?: "local" | "remote" | "merge" | "script"; - name?: string; - desc?: string; - file?: string; - url?: string; - updated?: number; - selected?: { - name?: string; - now?: string; - }[]; - extra?: { - upload: number; - download: number; - total: number; - expire: number; - }; - option?: IProfileOption; -} - -interface IProfileOption { - user_agent?: string; - with_proxy?: boolean; - self_proxy?: boolean; - update_interval?: number; -} - -interface IProfilesConfig { - current?: string; - chain?: string[]; - valid?: string[]; - items?: IProfileItem[]; -} - -interface IVergeConfig { - app_log_level?: "trace" | "debug" | "info" | "warn" | "error" | string; - language?: string; - clash_core?: "mihomo" | "mihomo-alpha" | "clash-rs" | "clash"; - theme_mode?: "light" | "dark" | "system"; - theme_blur?: boolean; - traffic_graph?: boolean; - enable_memory_usage?: boolean; - page_transition_animation?: keyof typeof import("@/components/layout/page-transition").pageTransitionVariants; - disable_auto_check_update?: boolean; - enable_tun_mode?: boolean; - enable_auto_launch?: boolean; - enable_service_mode?: boolean; - enable_silent_start?: boolean; - enable_system_proxy?: boolean; - enable_random_port?: boolean; - verge_mixed_port?: number; - enable_proxy_guard?: boolean; - proxy_guard_duration?: number; - system_proxy_bypass?: string; - web_ui_list?: string[]; - hotkeys?: string[]; - theme_setting?: { - primary_color?: string; - secondary_color?: string; - primary_text?: string; - secondary_text?: string; - info_color?: string; - error_color?: string; - warning_color?: string; - success_color?: string; - font_family?: string; - css_injection?: string; - page_transition_duration?: number; - }; - max_log_files?: number; - auto_close_connection?: boolean; - default_latency_test?: string; - enable_clash_fields?: boolean; - enable_builtin_enhanced?: boolean; - proxy_layout_column?: number; - clash_tray_selector?: boolean; - - clash_strategy?: { - external_controller_port_strategy: "fixed" | "random" | "allow_fallback"; - }; -} - -type IClashConfigValue = any; - -interface IProfileMerge { - // clash config fields (default supports) - rules?: IClashConfigValue; - proxies?: IClashConfigValue; - "proxy-groups"?: IClashConfigValue; - "proxy-providers"?: IClashConfigValue; - "rule-providers"?: IClashConfigValue; - // clash config fields (use flag) - tun?: IClashConfigValue; - dns?: IClashConfigValue; - hosts?: IClashConfigValue; - script?: IClashConfigValue; - profile?: IClashConfigValue; - payload?: IClashConfigValue; - "interface-name"?: IClashConfigValue; - "routing-mark"?: IClashConfigValue; - // functional fields - use?: string[]; - "prepend-rules"?: any[]; - "append-rules"?: any[]; - "prepend-proxies"?: any[]; - "append-proxies"?: any[]; - "prepend-proxy-groups"?: any[]; - "append-proxy-groups"?: any[]; - // fix - ebpf?: any; - experimental?: any; - iptables?: any; - sniffer?: any; - authentication?: any; - "bind-address"?: any; - "external-ui"?: any; - "auto-redir"?: any; - "socks-port"?: any; - "redir-port"?: any; - "tproxy-port"?: any; - "geodata-mode"?: any; - "tcp-concurrent"?: any; -} - -// partial of the clash config -type IProfileData = Partial<{ - rules: any[]; - proxies: any[]; - "proxy-groups": any[]; - "proxy-providers": any[]; - "rule-providers": any[]; - - [k: string]: any; -}>; - -interface IChainItem { - item: IProfileItem; - merge?: IProfileMerge; - script?: string; -} - -interface IEnhancedPayload { - chain: IChainItem[]; - valid: string[]; - current: IProfileData; - callback: string; -} - -interface IEnhancedResult { - data: IProfileData; - status: string; - error?: string; -} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/utils/clash-fields.ts b/clash-nyanpasu/frontend/nyanpasu/src/utils/clash-fields.ts deleted file mode 100644 index 7a9b369b69..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/utils/clash-fields.ts +++ /dev/null @@ -1,53 +0,0 @@ -export const HANDLE_FIELDS = [ - "mode", - "port", - "socks-port", - "mixed-port", - "allow-lan", - "log-level", - "ipv6", - "secret", - "external-controller", -]; - -export const DEFAULT_FIELDS = [ - "proxies", - "proxy-groups", - "proxy-providers", - "rules", - "rule-providers", -] as const; - -export const OTHERS_FIELDS = [ - "dns", - "tun", - "ebpf", - "hosts", - "script", - "profile", - "payload", - "tunnels", - "auto-redir", - "experimental", - "interface-name", - "routing-mark", - "redir-port", - "tproxy-port", - "iptables", - "external-ui", - "bind-address", - "authentication", - "tls", // meta - "sniffer", // meta - "geox-url", // meta - "listeners", // meta - "sub-rules", // meta - "geodata-mode", // meta - "unified-delay", // meta - "tcp-concurrent", // meta - "enable-process", // meta - "find-process-mode", // meta - "skip-auth-prefixes", // meta - "external-controller-tls", // meta - "global-client-fingerprint", // meta -] as const; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/utils/noop.ts b/clash-nyanpasu/frontend/nyanpasu/src/utils/noop.ts deleted file mode 100644 index ca6a744710..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/utils/noop.ts +++ /dev/null @@ -1 +0,0 @@ -export default function noop() {} diff --git a/clash-nyanpasu/frontend/nyanpasu/src/utils/routes-utils.ts b/clash-nyanpasu/frontend/nyanpasu/src/utils/routes-utils.ts new file mode 100644 index 0000000000..bef788c1e8 --- /dev/null +++ b/clash-nyanpasu/frontend/nyanpasu/src/utils/routes-utils.ts @@ -0,0 +1,45 @@ +import { + Apps, + DesignServices, + GridView, + Public, + Settings, + SettingsEthernet, + SvgIconComponent, + Terminal, +} from "@mui/icons-material"; + +const routes: { [key: string]: SvgIconComponent } = { + proxies: Public, + profiles: GridView, + connections: SettingsEthernet, + rules: DesignServices, + logs: Terminal, + settings: Settings, + providers: Apps, +}; + +export const getRoutes = () => { + return Object.keys(routes).reduce( + (acc, key) => { + acc[key] = `/${key}`; + return acc; + }, + {} as { [key: string]: string }, + ); +}; + +export const getRoutesWithIcon = () => { + return Object.keys(routes).reduce( + (acc, key) => { + acc[key] = { + path: `/${key}`, + icon: routes[key], + }; + return acc; + }, + {} as { + [key: string]: { path: string; icon: SvgIconComponent }; + }, + ); +}; diff --git a/clash-nyanpasu/frontend/nyanpasu/src/utils/truncate-str.ts b/clash-nyanpasu/frontend/nyanpasu/src/utils/truncate-str.ts deleted file mode 100644 index 491fa07aef..0000000000 --- a/clash-nyanpasu/frontend/nyanpasu/src/utils/truncate-str.ts +++ /dev/null @@ -1,6 +0,0 @@ -export const truncateStr = (str?: string, prefixLen = 16, maxLen = 56) => { - if (!str || str.length <= maxLen) return str; - return ( - str.slice(0, prefixLen) + " ... " + str.slice(-(maxLen - prefixLen - 5)) - ); -}; diff --git a/clash-nyanpasu/frontend/ui/materialYou/components/sidePage/index.tsx b/clash-nyanpasu/frontend/ui/materialYou/components/sidePage/index.tsx index c27528184e..56215f8184 100644 --- a/clash-nyanpasu/frontend/ui/materialYou/components/sidePage/index.tsx +++ b/clash-nyanpasu/frontend/ui/materialYou/components/sidePage/index.tsx @@ -70,6 +70,7 @@ export const SidePage: FC = ({ open: { opacity: 1, maxWidth: "348px", + minWidth: "192px", display: "flex", }, closed: { diff --git a/clash-nyanpasu/frontend/ui/package.json b/clash-nyanpasu/frontend/ui/package.json index 182d684918..a5d9122ea2 100644 --- a/clash-nyanpasu/frontend/ui/package.json +++ b/clash-nyanpasu/frontend/ui/package.json @@ -5,9 +5,9 @@ "module": "index.ts", "dependencies": { "@material/material-color-utilities": "0.2.7", - "@mui/icons-material": "5.15.19", + "@mui/icons-material": "5.15.20", "@mui/lab": "5.0.0-alpha.170", - "@mui/material": "5.15.19", + "@mui/material": "5.15.20", "@types/react": "18.3.3", "ahooks": "3.8.0", "framer-motion": "11.2.10", diff --git a/clash-nyanpasu/manifest/version.json b/clash-nyanpasu/manifest/version.json index 8ef90c578c..df50a8152e 100644 --- a/clash-nyanpasu/manifest/version.json +++ b/clash-nyanpasu/manifest/version.json @@ -2,7 +2,7 @@ "manifest_version": 1, "latest": { "mihomo": "v1.18.5", - "mihomo_alpha": "alpha-10f8ba4", + "mihomo_alpha": "alpha-d96d765", "clash_rs": "v0.1.18", "clash_premium": "2023-09-05-gdcc8d87" }, @@ -36,5 +36,5 @@ "darwin-x64": "clash-darwin-amd64-n{}.gz" } }, - "updated_at": "2024-06-11T22:19:49.011Z" + "updated_at": "2024-06-13T05:37:49.210Z" } diff --git a/clash-nyanpasu/package.json b/clash-nyanpasu/package.json index c0a1642bec..cb6f012e75 100644 --- a/clash-nyanpasu/package.json +++ b/clash-nyanpasu/package.json @@ -89,7 +89,7 @@ "eslint-plugin-prettier": "5.1.3", "eslint-plugin-promise": "6.2.0", "eslint-plugin-react": "7.34.2", - "lint-staged": "15.2.6", + "lint-staged": "15.2.7", "npm-run-all2": "6.2.0", "postcss": "8.4.38", "postcss-html": "1.7.0", @@ -106,12 +106,12 @@ "stylelint-order": "6.0.4", "stylelint-scss": "6.3.1", "tailwindcss": "3.4.4", - "tsx": "4.15.2", + "tsx": "4.15.4", "typescript": "5.4.5" }, "packageManager": "pnpm@9.3.0", "engines": { - "node": "22.2.0" + "node": "22.3.0" }, "pnpm": { "overrides": { diff --git a/clash-nyanpasu/pnpm-lock.yaml b/clash-nyanpasu/pnpm-lock.yaml index d677399c82..0204e08960 100644 --- a/clash-nyanpasu/pnpm-lock.yaml +++ b/clash-nyanpasu/pnpm-lock.yaml @@ -83,8 +83,8 @@ importers: specifier: 7.34.2 version: 7.34.2(eslint@8.57.0) lint-staged: - specifier: 15.2.6 - version: 15.2.6 + specifier: 15.2.7 + version: 15.2.7 npm-run-all2: specifier: 6.2.0 version: 6.2.0 @@ -134,8 +134,8 @@ importers: specifier: 3.4.4 version: 3.4.4 tsx: - specifier: 4.15.2 - version: 4.15.2 + specifier: 4.15.4 + version: 4.15.4 typescript: specifier: 5.4.5 version: 5.4.5 @@ -178,7 +178,7 @@ importers: version: 11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@generouted/react-router': specifier: 1.19.5 - version: 1.19.5(react-router-dom@6.23.1(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(vite@5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)) + version: 1.19.5(react-router-dom@6.23.1(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(vite@5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)) '@juggle/resize-observer': specifier: 3.4.0 version: 3.4.0 @@ -186,17 +186,17 @@ importers: specifier: 0.2.7 version: 0.2.7 '@mui/icons-material': - specifier: 5.15.19 - version: 5.15.19(@mui/material@5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + specifier: 5.15.20 + version: 5.15.20(@mui/material@5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@mui/lab': specifier: 5.0.0-alpha.170 - version: 5.0.0-alpha.170(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@mui/material@5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + version: 5.0.0-alpha.170(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@mui/material@5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@mui/material': - specifier: 5.15.19 - version: 5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + specifier: 5.15.20 + version: 5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@mui/x-data-grid': specifier: 7.6.2 - version: 7.6.2(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@mui/material@5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + version: 7.6.2(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@mui/material@5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@nyanpasu/interface': specifier: workspace:^ version: link:../interface @@ -232,7 +232,7 @@ importers: version: 0.49.0 mui-color-input: specifier: 2.0.3 - version: 2.0.3(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@mui/material@5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + version: 2.0.3(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@mui/material@5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) react: specifier: npm:react@rc version: 19.0.0-rc-9d4fba0788-20240530 @@ -250,7 +250,7 @@ importers: version: 7.51.5(react@19.0.0-rc-9d4fba0788-20240530) react-hook-form-mui: specifier: 7.0.0 - version: 7.0.0(szplwmyfv5kdrzoa2ayly36z7i) + version: 7.0.0(vzgnxglunplyfvn2vosyka7udq) react-i18next: specifier: 14.1.2 version: 14.1.2(i18next@23.11.5)(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530) @@ -299,7 +299,7 @@ importers: version: 7.13.0(eslint@8.57.0)(typescript@5.4.5) '@vitejs/plugin-react': specifier: 4.3.1 - version: 4.3.1(vite@5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)) + version: 4.3.1(vite@5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)) sass: specifier: 1.77.5 version: 1.77.5 @@ -307,20 +307,20 @@ importers: specifier: 1.6.4 version: 1.6.4 vite: - specifier: 5.2.13 - version: 5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0) + specifier: 5.3.0 + version: 5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0) vite-plugin-monaco-editor: specifier: npm:vite-plugin-monaco-editor-new@1.1.3 version: vite-plugin-monaco-editor-new@1.1.3(monaco-editor@0.49.0) vite-plugin-sass-dts: specifier: 1.3.22 - version: 1.3.22(postcss@8.4.38)(prettier@3.3.2)(sass@1.77.5)(vite@5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)) + version: 1.3.22(postcss@8.4.38)(prettier@3.3.2)(sass@1.77.5)(vite@5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)) vite-plugin-svgr: specifier: 4.2.0 - version: 4.2.0(rollup@4.17.2)(typescript@5.4.5)(vite@5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)) + version: 4.2.0(rollup@4.17.2)(typescript@5.4.5)(vite@5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)) vite-tsconfig-paths: specifier: 4.3.2 - version: 4.3.2(typescript@5.4.5)(vite@5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)) + version: 4.3.2(typescript@5.4.5)(vite@5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)) frontend/ui: dependencies: @@ -328,14 +328,14 @@ importers: specifier: 0.2.7 version: 0.2.7 '@mui/icons-material': - specifier: 5.15.19 - version: 5.15.19(@mui/material@5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + specifier: 5.15.20 + version: 5.15.20(@mui/material@5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@mui/lab': specifier: 5.0.0-alpha.170 - version: 5.0.0-alpha.170(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@mui/material@5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + version: 5.0.0-alpha.170(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@mui/material@5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@mui/material': - specifier: 5.15.19 - version: 5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + specifier: 5.15.20 + version: 5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@types/react': specifier: npm:types-react@rc version: types-react@19.0.0-rc.0 @@ -720,12 +720,6 @@ packages: cpu: [ppc64] os: [aix] - '@esbuild/aix-ppc64@0.20.2': - resolution: {integrity: sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [aix] - '@esbuild/aix-ppc64@0.21.4': resolution: {integrity: sha512-Zrm+B33R4LWPLjDEVnEqt2+SLTATlru1q/xYKVn8oVTbiRBGmK2VIMoIYGJDGyftnGaC788IuzGFAlb7IQ0Y8A==} engines: {node: '>=12'} @@ -738,12 +732,6 @@ packages: cpu: [arm64] os: [android] - '@esbuild/android-arm64@0.20.2': - resolution: {integrity: sha512-mRzjLacRtl/tWU0SvD8lUEwb61yP9cqQo6noDZP/O8VkwafSYwZ4yWy24kan8jE/IMERpYncRt2dw438LP3Xmg==} - engines: {node: '>=12'} - cpu: [arm64] - os: [android] - '@esbuild/android-arm64@0.21.4': resolution: {integrity: sha512-fYFnz+ObClJ3dNiITySBUx+oNalYUT18/AryMxfovLkYWbutXsct3Wz2ZWAcGGppp+RVVX5FiXeLYGi97umisA==} engines: {node: '>=12'} @@ -756,12 +744,6 @@ packages: cpu: [arm] os: [android] - '@esbuild/android-arm@0.20.2': - resolution: {integrity: sha512-t98Ra6pw2VaDhqNWO2Oph2LXbz/EJcnLmKLGBJwEwXX/JAN83Fym1rU8l0JUWK6HkIbWONCSSatf4sf2NBRx/w==} - engines: {node: '>=12'} - cpu: [arm] - os: [android] - '@esbuild/android-arm@0.21.4': resolution: {integrity: sha512-E7H/yTd8kGQfY4z9t3nRPk/hrhaCajfA3YSQSBrst8B+3uTcgsi8N+ZWYCaeIDsiVs6m65JPCaQN/DxBRclF3A==} engines: {node: '>=12'} @@ -774,12 +756,6 @@ packages: cpu: [x64] os: [android] - '@esbuild/android-x64@0.20.2': - resolution: {integrity: sha512-btzExgV+/lMGDDa194CcUQm53ncxzeBrWJcncOBxuC6ndBkKxnHdFJn86mCIgTELsooUmwUm9FkhSp5HYu00Rg==} - engines: {node: '>=12'} - cpu: [x64] - os: [android] - '@esbuild/android-x64@0.21.4': resolution: {integrity: sha512-mDqmlge3hFbEPbCWxp4fM6hqq7aZfLEHZAKGP9viq9wMUBVQx202aDIfc3l+d2cKhUJM741VrCXEzRFhPDKH3Q==} engines: {node: '>=12'} @@ -792,12 +768,6 @@ packages: cpu: [arm64] os: [darwin] - '@esbuild/darwin-arm64@0.20.2': - resolution: {integrity: sha512-4J6IRT+10J3aJH3l1yzEg9y3wkTDgDk7TSDFX+wKFiWjqWp/iCfLIYzGyasx9l0SAFPT1HwSCR+0w/h1ES/MjA==} - engines: {node: '>=12'} - cpu: [arm64] - os: [darwin] - '@esbuild/darwin-arm64@0.21.4': resolution: {integrity: sha512-72eaIrDZDSiWqpmCzVaBD58c8ea8cw/U0fq/PPOTqE3c53D0xVMRt2ooIABZ6/wj99Y+h4ksT/+I+srCDLU9TA==} engines: {node: '>=12'} @@ -810,12 +780,6 @@ packages: cpu: [x64] os: [darwin] - '@esbuild/darwin-x64@0.20.2': - resolution: {integrity: sha512-tBcXp9KNphnNH0dfhv8KYkZhjc+H3XBkF5DKtswJblV7KlT9EI2+jeA8DgBjp908WEuYll6pF+UStUCfEpdysA==} - engines: {node: '>=12'} - cpu: [x64] - os: [darwin] - '@esbuild/darwin-x64@0.21.4': resolution: {integrity: sha512-uBsuwRMehGmw1JC7Vecu/upOjTsMhgahmDkWhGLWxIgUn2x/Y4tIwUZngsmVb6XyPSTXJYS4YiASKPcm9Zitag==} engines: {node: '>=12'} @@ -828,12 +792,6 @@ packages: cpu: [arm64] os: [freebsd] - '@esbuild/freebsd-arm64@0.20.2': - resolution: {integrity: sha512-d3qI41G4SuLiCGCFGUrKsSeTXyWG6yem1KcGZVS+3FYlYhtNoNgYrWcvkOoaqMhwXSMrZRl69ArHsGJ9mYdbbw==} - engines: {node: '>=12'} - cpu: [arm64] - os: [freebsd] - '@esbuild/freebsd-arm64@0.21.4': resolution: {integrity: sha512-8JfuSC6YMSAEIZIWNL3GtdUT5NhUA/CMUCpZdDRolUXNAXEE/Vbpe6qlGLpfThtY5NwXq8Hi4nJy4YfPh+TwAg==} engines: {node: '>=12'} @@ -846,12 +804,6 @@ packages: cpu: [x64] os: [freebsd] - '@esbuild/freebsd-x64@0.20.2': - resolution: {integrity: sha512-d+DipyvHRuqEeM5zDivKV1KuXn9WeRX6vqSqIDgwIfPQtwMP4jaDsQsDncjTDDsExT4lR/91OLjRo8bmC1e+Cw==} - engines: {node: '>=12'} - cpu: [x64] - os: [freebsd] - '@esbuild/freebsd-x64@0.21.4': resolution: {integrity: sha512-8d9y9eQhxv4ef7JmXny7591P/PYsDFc4+STaxC1GBv0tMyCdyWfXu2jBuqRsyhY8uL2HU8uPyscgE2KxCY9imQ==} engines: {node: '>=12'} @@ -864,12 +816,6 @@ packages: cpu: [arm64] os: [linux] - '@esbuild/linux-arm64@0.20.2': - resolution: {integrity: sha512-9pb6rBjGvTFNira2FLIWqDk/uaf42sSyLE8j1rnUpuzsODBq7FvpwHYZxQ/It/8b+QOS1RYfqgGFNLRI+qlq2A==} - engines: {node: '>=12'} - cpu: [arm64] - os: [linux] - '@esbuild/linux-arm64@0.21.4': resolution: {integrity: sha512-/GLD2orjNU50v9PcxNpYZi+y8dJ7e7/LhQukN3S4jNDXCKkyyiyAz9zDw3siZ7Eh1tRcnCHAo/WcqKMzmi4eMQ==} engines: {node: '>=12'} @@ -882,12 +828,6 @@ packages: cpu: [arm] os: [linux] - '@esbuild/linux-arm@0.20.2': - resolution: {integrity: sha512-VhLPeR8HTMPccbuWWcEUD1Az68TqaTYyj6nfE4QByZIQEQVWBB8vup8PpR7y1QHL3CpcF6xd5WVBU/+SBEvGTg==} - engines: {node: '>=12'} - cpu: [arm] - os: [linux] - '@esbuild/linux-arm@0.21.4': resolution: {integrity: sha512-2rqFFefpYmpMs+FWjkzSgXg5vViocqpq5a1PSRgT0AvSgxoXmGF17qfGAzKedg6wAwyM7UltrKVo9kxaJLMF/g==} engines: {node: '>=12'} @@ -900,12 +840,6 @@ packages: cpu: [ia32] os: [linux] - '@esbuild/linux-ia32@0.20.2': - resolution: {integrity: sha512-o10utieEkNPFDZFQm9CoP7Tvb33UutoJqg3qKf1PWVeeJhJw0Q347PxMvBgVVFgouYLGIhFYG0UGdBumROyiig==} - engines: {node: '>=12'} - cpu: [ia32] - os: [linux] - '@esbuild/linux-ia32@0.21.4': resolution: {integrity: sha512-pNftBl7m/tFG3t2m/tSjuYeWIffzwAZT9m08+9DPLizxVOsUl8DdFzn9HvJrTQwe3wvJnwTdl92AonY36w/25g==} engines: {node: '>=12'} @@ -918,12 +852,6 @@ packages: cpu: [loong64] os: [linux] - '@esbuild/linux-loong64@0.20.2': - resolution: {integrity: sha512-PR7sp6R/UC4CFVomVINKJ80pMFlfDfMQMYynX7t1tNTeivQ6XdX5r2XovMmha/VjR1YN/HgHWsVcTRIMkymrgQ==} - engines: {node: '>=12'} - cpu: [loong64] - os: [linux] - '@esbuild/linux-loong64@0.21.4': resolution: {integrity: sha512-cSD2gzCK5LuVX+hszzXQzlWya6c7hilO71L9h4KHwqI4qeqZ57bAtkgcC2YioXjsbfAv4lPn3qe3b00Zt+jIfQ==} engines: {node: '>=12'} @@ -936,12 +864,6 @@ packages: cpu: [mips64el] os: [linux] - '@esbuild/linux-mips64el@0.20.2': - resolution: {integrity: sha512-4BlTqeutE/KnOiTG5Y6Sb/Hw6hsBOZapOVF6njAESHInhlQAghVVZL1ZpIctBOoTFbQyGW+LsVYZ8lSSB3wkjA==} - engines: {node: '>=12'} - cpu: [mips64el] - os: [linux] - '@esbuild/linux-mips64el@0.21.4': resolution: {integrity: sha512-qtzAd3BJh7UdbiXCrg6npWLYU0YpufsV9XlufKhMhYMJGJCdfX/G6+PNd0+v877X1JG5VmjBLUiFB0o8EUSicA==} engines: {node: '>=12'} @@ -954,12 +876,6 @@ packages: cpu: [ppc64] os: [linux] - '@esbuild/linux-ppc64@0.20.2': - resolution: {integrity: sha512-rD3KsaDprDcfajSKdn25ooz5J5/fWBylaaXkuotBDGnMnDP1Uv5DLAN/45qfnf3JDYyJv/ytGHQaziHUdyzaAg==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [linux] - '@esbuild/linux-ppc64@0.21.4': resolution: {integrity: sha512-yB8AYzOTaL0D5+2a4xEy7OVvbcypvDR05MsB/VVPVA7nL4hc5w5Dyd/ddnayStDgJE59fAgNEOdLhBxjfx5+dg==} engines: {node: '>=12'} @@ -972,12 +888,6 @@ packages: cpu: [riscv64] os: [linux] - '@esbuild/linux-riscv64@0.20.2': - resolution: {integrity: sha512-snwmBKacKmwTMmhLlz/3aH1Q9T8v45bKYGE3j26TsaOVtjIag4wLfWSiZykXzXuE1kbCE+zJRmwp+ZbIHinnVg==} - engines: {node: '>=12'} - cpu: [riscv64] - os: [linux] - '@esbuild/linux-riscv64@0.21.4': resolution: {integrity: sha512-Y5AgOuVzPjQdgU59ramLoqSSiXddu7F3F+LI5hYy/d1UHN7K5oLzYBDZe23QmQJ9PIVUXwOdKJ/jZahPdxzm9w==} engines: {node: '>=12'} @@ -990,12 +900,6 @@ packages: cpu: [s390x] os: [linux] - '@esbuild/linux-s390x@0.20.2': - resolution: {integrity: sha512-wcWISOobRWNm3cezm5HOZcYz1sKoHLd8VL1dl309DiixxVFoFe/o8HnwuIwn6sXre88Nwj+VwZUvJf4AFxkyrQ==} - engines: {node: '>=12'} - cpu: [s390x] - os: [linux] - '@esbuild/linux-s390x@0.21.4': resolution: {integrity: sha512-Iqc/l/FFwtt8FoTK9riYv9zQNms7B8u+vAI/rxKuN10HgQIXaPzKZc479lZ0x6+vKVQbu55GdpYpeNWzjOhgbA==} engines: {node: '>=12'} @@ -1008,12 +912,6 @@ packages: cpu: [x64] os: [linux] - '@esbuild/linux-x64@0.20.2': - resolution: {integrity: sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==} - engines: {node: '>=12'} - cpu: [x64] - os: [linux] - '@esbuild/linux-x64@0.21.4': resolution: {integrity: sha512-Td9jv782UMAFsuLZINfUpoF5mZIbAj+jv1YVtE58rFtfvoKRiKSkRGQfHTgKamLVT/fO7203bHa3wU122V/Bdg==} engines: {node: '>=12'} @@ -1026,12 +924,6 @@ packages: cpu: [x64] os: [netbsd] - '@esbuild/netbsd-x64@0.20.2': - resolution: {integrity: sha512-K8/DhBxcVQkzYc43yJXDSyjlFeHQJBiowJ0uVL6Tor3jGQfSGHNNJcWxNbOI8v5k82prYqzPuwkzHt3J1T1iZQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [netbsd] - '@esbuild/netbsd-x64@0.21.4': resolution: {integrity: sha512-Awn38oSXxsPMQxaV0Ipb7W/gxZtk5Tx3+W+rAPdZkyEhQ6968r9NvtkjhnhbEgWXYbgV+JEONJ6PcdBS+nlcpA==} engines: {node: '>=12'} @@ -1044,12 +936,6 @@ packages: cpu: [x64] os: [openbsd] - '@esbuild/openbsd-x64@0.20.2': - resolution: {integrity: sha512-eMpKlV0SThJmmJgiVyN9jTPJ2VBPquf6Kt/nAoo6DgHAoN57K15ZghiHaMvqjCye/uU4X5u3YSMgVBI1h3vKrQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [openbsd] - '@esbuild/openbsd-x64@0.21.4': resolution: {integrity: sha512-IsUmQeCY0aU374R82fxIPu6vkOybWIMc3hVGZ3ChRwL9hA1TwY+tS0lgFWV5+F1+1ssuvvXt3HFqe8roCip8Hg==} engines: {node: '>=12'} @@ -1062,12 +948,6 @@ packages: cpu: [x64] os: [sunos] - '@esbuild/sunos-x64@0.20.2': - resolution: {integrity: sha512-2UyFtRC6cXLyejf/YEld4Hajo7UHILetzE1vsRcGL3earZEW77JxrFjH4Ez2qaTiEfMgAXxfAZCm1fvM/G/o8w==} - engines: {node: '>=12'} - cpu: [x64] - os: [sunos] - '@esbuild/sunos-x64@0.21.4': resolution: {integrity: sha512-hsKhgZ4teLUaDA6FG/QIu2q0rI6I36tZVfM4DBZv3BG0mkMIdEnMbhc4xwLvLJSS22uWmaVkFkqWgIS0gPIm+A==} engines: {node: '>=12'} @@ -1080,12 +960,6 @@ packages: cpu: [arm64] os: [win32] - '@esbuild/win32-arm64@0.20.2': - resolution: {integrity: sha512-GRibxoawM9ZCnDxnP3usoUDO9vUkpAxIIZ6GQI+IlVmr5kP3zUq+l17xELTHMWTWzjxa2guPNyrpq1GWmPvcGQ==} - engines: {node: '>=12'} - cpu: [arm64] - os: [win32] - '@esbuild/win32-arm64@0.21.4': resolution: {integrity: sha512-UUfMgMoXPoA/bvGUNfUBFLCh0gt9dxZYIx9W4rfJr7+hKe5jxxHmfOK8YSH4qsHLLN4Ck8JZ+v7Q5fIm1huErg==} engines: {node: '>=12'} @@ -1098,12 +972,6 @@ packages: cpu: [ia32] os: [win32] - '@esbuild/win32-ia32@0.20.2': - resolution: {integrity: sha512-HfLOfn9YWmkSKRQqovpnITazdtquEW8/SoHW7pWpuEeguaZI4QnCRW6b+oZTztdBnZOS2hqJ6im/D5cPzBTTlQ==} - engines: {node: '>=12'} - cpu: [ia32] - os: [win32] - '@esbuild/win32-ia32@0.21.4': resolution: {integrity: sha512-yIxbspZb5kGCAHWm8dexALQ9en1IYDfErzjSEq1KzXFniHv019VT3mNtTK7t8qdy4TwT6QYHI9sEZabONHg+aw==} engines: {node: '>=12'} @@ -1116,12 +984,6 @@ packages: cpu: [x64] os: [win32] - '@esbuild/win32-x64@0.20.2': - resolution: {integrity: sha512-N49X4lJX27+l9jbLKSqZ6bKNjzQvHaT8IIFUy+YIqmXQdjYCToGWwOItDrfby14c78aDd5NHQl29xingXfCdLQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [win32] - '@esbuild/win32-x64@0.21.4': resolution: {integrity: sha512-sywLRD3UK/qRJt0oBwdpYLBibk7KiRfbswmWRDabuncQYSlf8aLEEUor/oP6KRz8KEG+HoiVLBhPRD5JWjS8Sg==} engines: {node: '>=12'} @@ -1224,11 +1086,11 @@ packages: '@types/react': optional: true - '@mui/core-downloads-tracker@5.15.19': - resolution: {integrity: sha512-tCHSi/Tomez9ERynFhZRvFO6n9ATyrPs+2N80DMDzp6xDVirbBjEwhPcE+x7Lj+nwYw0SqFkOxyvMP0irnm55w==} + '@mui/core-downloads-tracker@5.15.20': + resolution: {integrity: sha512-DoL2ppgldL16utL8nNyj/P12f8mCNdx/Hb/AJnX9rLY4b52hCMIx1kH83pbXQ6uMy6n54M3StmEbvSGoj2OFuA==} - '@mui/icons-material@5.15.19': - resolution: {integrity: sha512-RsEiRxA5azN9b8gI7JRqekkgvxQUlitoBOtZglflb8cUDyP12/cP4gRwhb44Ea1/zwwGGjAj66ZJpGHhKfibNA==} + '@mui/icons-material@5.15.20': + resolution: {integrity: sha512-oGcKmCuHaYbAAoLN67WKSXtHmEgyWcJToT1uRtmPyxMj9N5uqwc/mRtEnst4Wj/eGr+zYH2FiZQ79v9k7kSk1Q==} engines: {node: '>=12.0.0'} peerDependencies: '@mui/material': ^5.0.0 @@ -1256,8 +1118,8 @@ packages: '@types/react': optional: true - '@mui/material@5.15.19': - resolution: {integrity: sha512-lp5xQBbcRuxNtjpWU0BWZgIrv2XLUz4RJ0RqFXBdESIsKoGCQZ6P3wwU5ZPuj5TjssNiKv9AlM+vHopRxZhvVQ==} + '@mui/material@5.15.20': + resolution: {integrity: sha512-tVq3l4qoXx/NxUgIx/x3lZiPn/5xDbdTE8VrLczNpfblLYZzlrbxA7kb9mI8NoBF6+w9WE9IrxWnKK5KlPI2bg==} engines: {node: '>=12.0.0'} peerDependencies: '@emotion/react': ^11.5.0 @@ -1283,6 +1145,16 @@ packages: '@types/react': optional: true + '@mui/private-theming@5.15.20': + resolution: {integrity: sha512-BK8F94AIqSrnaPYXf2KAOjGZJgWfvqAVQ2gVR3EryvQFtuBnG6RwodxrCvd3B48VuMy6Wsk897+lQMUxJyk+6g==} + engines: {node: '>=12.0.0'} + peerDependencies: + '@types/react': npm:types-react@rc + react: npm:react@rc + peerDependenciesMeta: + '@types/react': + optional: true + '@mui/styled-engine@5.15.14': resolution: {integrity: sha512-RILkuVD8gY6PvjZjqnWhz8fu68dVkqhM5+jYWfB5yhlSQKg+2rHkmEwm75XIeAqI3qwOndK6zELK5H6Zxn4NHw==} engines: {node: '>=12.0.0'} @@ -1312,6 +1184,22 @@ packages: '@types/react': optional: true + '@mui/system@5.15.20': + resolution: {integrity: sha512-LoMq4IlAAhxzL2VNUDBTQxAb4chnBe8JvRINVNDiMtHE2PiPOoHlhOPutSxEbaL5mkECPVWSv6p8JEV+uykwIA==} + engines: {node: '>=12.0.0'} + peerDependencies: + '@emotion/react': ^11.5.0 + '@emotion/styled': ^11.3.0 + '@types/react': npm:types-react@rc + react: npm:react@rc + peerDependenciesMeta: + '@emotion/react': + optional: true + '@emotion/styled': + optional: true + '@types/react': + optional: true + '@mui/types@7.2.14': resolution: {integrity: sha512-MZsBZ4q4HfzBsywtXgM1Ksj6HDThtiwmOKUXH1pKYISI9gAVXCNHNpo7TlGoGrBaYWZTdNoirIN7JsQcQUjmQQ==} peerDependencies: @@ -1330,6 +1218,16 @@ packages: '@types/react': optional: true + '@mui/utils@5.15.20': + resolution: {integrity: sha512-mAbYx0sovrnpAu1zHc3MDIhPqL8RPVC5W5xcO1b7PiSCJPtckIZmBkp8hefamAvUiAV8gpfMOM6Zb+eSisbI2A==} + engines: {node: '>=12.0.0'} + peerDependencies: + '@types/react': npm:types-react@rc + react: npm:react@rc + peerDependenciesMeta: + '@types/react': + optional: true + '@mui/x-data-grid@7.6.2': resolution: {integrity: sha512-f3t6TU8+f0VgmL4aJ9N/Wm5IeWfICfVb45S469wzzldUhbb/beIO/T3uMyGP13WFhx5f8N5wRRHSYZRHpfzhZw==} engines: {node: '>=14.0.0'} @@ -2540,11 +2438,6 @@ packages: engines: {node: '>=12'} hasBin: true - esbuild@0.20.2: - resolution: {integrity: sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==} - engines: {node: '>=12'} - hasBin: true - esbuild@0.21.4: resolution: {integrity: sha512-sFMcNNrj+Q0ZDolrp5pDhH0nRPN9hLIM3fRPwgbLYJeSHHgnXSnbV3xYgSVuOeLWH9c73VwmEverVzupIv5xuA==} engines: {node: '>=12'} @@ -3471,8 +3364,8 @@ packages: lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - lint-staged@15.2.6: - resolution: {integrity: sha512-M/3PdijFXT/A5lnbSK3EQNLbIIrkE00JZaD39r7t4kfFOqT1Ly9LgSZSMMtvQ3p2/C8Nyj/ou0vkNHmEwqoB8g==} + lint-staged@15.2.7: + resolution: {integrity: sha512-+FdVbbCZ+yoh7E/RosSdqKJyUM2OEjTciH0TFNkawKgvFp1zbGlEC39RADg+xKBG1R4mhoH2j85myBQZ5wR+lw==} engines: {node: '>=18.12.0'} hasBin: true @@ -4813,8 +4706,8 @@ packages: tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} - tsx@4.15.2: - resolution: {integrity: sha512-kIZTOCmR37nEw0qxQks2dR+eZWSXydhTGmz7yx94vEiJtJGBTkUl0D/jt/5fey+CNdm6i3Cp+29WKRay9ScQUw==} + tsx@4.15.4: + resolution: {integrity: sha512-d++FLCwJLrXaBFtRcqdPBzu6FiVOJ2j+UsvUZPtoTrnYtCGU5CEW7iHXtNZfA2fcRTvJFWPqA6SWBuB0GSva9w==} engines: {node: '>=18.0.0'} hasBin: true @@ -5017,8 +4910,8 @@ packages: vite: optional: true - vite@5.2.13: - resolution: {integrity: sha512-SSq1noJfY9pR3I1TUENL3rQYDQCFqgD+lM6fTRAM8Nv6Lsg5hDLaXkjETVeBt+7vZBCMoibD+6IWnT2mJ+Zb/A==} + vite@5.3.0: + resolution: {integrity: sha512-hA6vAVK977NyW1Qw+fLvqSo7xDPej7von7C3DwwqPRmnnnK36XEBC/J3j1V5lP8fbt7y0TgTKJbpNGSwM+Bdeg==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -5595,207 +5488,138 @@ snapshots: '@esbuild/aix-ppc64@0.19.12': optional: true - '@esbuild/aix-ppc64@0.20.2': - optional: true - '@esbuild/aix-ppc64@0.21.4': optional: true '@esbuild/android-arm64@0.19.12': optional: true - '@esbuild/android-arm64@0.20.2': - optional: true - '@esbuild/android-arm64@0.21.4': optional: true '@esbuild/android-arm@0.19.12': optional: true - '@esbuild/android-arm@0.20.2': - optional: true - '@esbuild/android-arm@0.21.4': optional: true '@esbuild/android-x64@0.19.12': optional: true - '@esbuild/android-x64@0.20.2': - optional: true - '@esbuild/android-x64@0.21.4': optional: true '@esbuild/darwin-arm64@0.19.12': optional: true - '@esbuild/darwin-arm64@0.20.2': - optional: true - '@esbuild/darwin-arm64@0.21.4': optional: true '@esbuild/darwin-x64@0.19.12': optional: true - '@esbuild/darwin-x64@0.20.2': - optional: true - '@esbuild/darwin-x64@0.21.4': optional: true '@esbuild/freebsd-arm64@0.19.12': optional: true - '@esbuild/freebsd-arm64@0.20.2': - optional: true - '@esbuild/freebsd-arm64@0.21.4': optional: true '@esbuild/freebsd-x64@0.19.12': optional: true - '@esbuild/freebsd-x64@0.20.2': - optional: true - '@esbuild/freebsd-x64@0.21.4': optional: true '@esbuild/linux-arm64@0.19.12': optional: true - '@esbuild/linux-arm64@0.20.2': - optional: true - '@esbuild/linux-arm64@0.21.4': optional: true '@esbuild/linux-arm@0.19.12': optional: true - '@esbuild/linux-arm@0.20.2': - optional: true - '@esbuild/linux-arm@0.21.4': optional: true '@esbuild/linux-ia32@0.19.12': optional: true - '@esbuild/linux-ia32@0.20.2': - optional: true - '@esbuild/linux-ia32@0.21.4': optional: true '@esbuild/linux-loong64@0.19.12': optional: true - '@esbuild/linux-loong64@0.20.2': - optional: true - '@esbuild/linux-loong64@0.21.4': optional: true '@esbuild/linux-mips64el@0.19.12': optional: true - '@esbuild/linux-mips64el@0.20.2': - optional: true - '@esbuild/linux-mips64el@0.21.4': optional: true '@esbuild/linux-ppc64@0.19.12': optional: true - '@esbuild/linux-ppc64@0.20.2': - optional: true - '@esbuild/linux-ppc64@0.21.4': optional: true '@esbuild/linux-riscv64@0.19.12': optional: true - '@esbuild/linux-riscv64@0.20.2': - optional: true - '@esbuild/linux-riscv64@0.21.4': optional: true '@esbuild/linux-s390x@0.19.12': optional: true - '@esbuild/linux-s390x@0.20.2': - optional: true - '@esbuild/linux-s390x@0.21.4': optional: true '@esbuild/linux-x64@0.19.12': optional: true - '@esbuild/linux-x64@0.20.2': - optional: true - '@esbuild/linux-x64@0.21.4': optional: true '@esbuild/netbsd-x64@0.19.12': optional: true - '@esbuild/netbsd-x64@0.20.2': - optional: true - '@esbuild/netbsd-x64@0.21.4': optional: true '@esbuild/openbsd-x64@0.19.12': optional: true - '@esbuild/openbsd-x64@0.20.2': - optional: true - '@esbuild/openbsd-x64@0.21.4': optional: true '@esbuild/sunos-x64@0.19.12': optional: true - '@esbuild/sunos-x64@0.20.2': - optional: true - '@esbuild/sunos-x64@0.21.4': optional: true '@esbuild/win32-arm64@0.19.12': optional: true - '@esbuild/win32-arm64@0.20.2': - optional: true - '@esbuild/win32-arm64@0.21.4': optional: true '@esbuild/win32-ia32@0.19.12': optional: true - '@esbuild/win32-ia32@0.20.2': - optional: true - '@esbuild/win32-ia32@0.21.4': optional: true '@esbuild/win32-x64@0.19.12': optional: true - '@esbuild/win32-x64@0.20.2': - optional: true - '@esbuild/win32-x64@0.21.4': optional: true @@ -5841,13 +5665,13 @@ snapshots: '@floating-ui/utils@0.2.2': {} - '@generouted/react-router@1.19.5(react-router-dom@6.23.1(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(vite@5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0))': + '@generouted/react-router@1.19.5(react-router-dom@6.23.1(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(vite@5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0))': dependencies: fast-glob: 3.3.2 - generouted: 1.19.5(vite@5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)) + generouted: 1.19.5(vite@5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)) react: 19.0.0-rc-9d4fba0788-20240530 react-router-dom: 6.23.1(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530) - vite: 5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0) + vite: 5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0) '@humanwhocodes/config-array@0.11.14': dependencies: @@ -5905,21 +5729,21 @@ snapshots: optionalDependencies: '@types/react': types-react@19.0.0-rc.0 - '@mui/core-downloads-tracker@5.15.19': {} + '@mui/core-downloads-tracker@5.15.20': {} - '@mui/icons-material@5.15.19(@mui/material@5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0)': + '@mui/icons-material@5.15.20(@mui/material@5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0)': dependencies: - '@babel/runtime': 7.24.5 - '@mui/material': 5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + '@babel/runtime': 7.24.6 + '@mui/material': 5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) react: 19.0.0-rc-9d4fba0788-20240530 optionalDependencies: '@types/react': types-react@19.0.0-rc.0 - '@mui/lab@5.0.0-alpha.170(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@mui/material@5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0)': + '@mui/lab@5.0.0-alpha.170(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@mui/material@5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0)': dependencies: '@babel/runtime': 7.24.5 '@mui/base': 5.0.0-beta.40(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) - '@mui/material': 5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + '@mui/material': 5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@mui/system': 5.15.15(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@mui/types': 7.2.14(types-react@19.0.0-rc.0) '@mui/utils': 5.15.14(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) @@ -5932,14 +5756,14 @@ snapshots: '@emotion/styled': 11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@types/react': types-react@19.0.0-rc.0 - '@mui/material@5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0)': + '@mui/material@5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0)': dependencies: - '@babel/runtime': 7.24.5 + '@babel/runtime': 7.24.6 '@mui/base': 5.0.0-beta.40(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) - '@mui/core-downloads-tracker': 5.15.19 - '@mui/system': 5.15.15(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + '@mui/core-downloads-tracker': 5.15.20 + '@mui/system': 5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@mui/types': 7.2.14(types-react@19.0.0-rc.0) - '@mui/utils': 5.15.14(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + '@mui/utils': 5.15.20(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@types/react-transition-group': 4.4.10 clsx: 2.1.1 csstype: 3.1.3 @@ -5962,6 +5786,15 @@ snapshots: optionalDependencies: '@types/react': types-react@19.0.0-rc.0 + '@mui/private-theming@5.15.20(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0)': + dependencies: + '@babel/runtime': 7.24.6 + '@mui/utils': 5.15.20(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + prop-types: 15.8.1 + react: 19.0.0-rc-9d4fba0788-20240530 + optionalDependencies: + '@types/react': types-react@19.0.0-rc.0 + '@mui/styled-engine@5.15.14(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)': dependencies: '@babel/runtime': 7.24.6 @@ -5989,6 +5822,22 @@ snapshots: '@emotion/styled': 11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@types/react': types-react@19.0.0-rc.0 + '@mui/system@5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0)': + dependencies: + '@babel/runtime': 7.24.6 + '@mui/private-theming': 5.15.20(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + '@mui/styled-engine': 5.15.14(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530) + '@mui/types': 7.2.14(types-react@19.0.0-rc.0) + '@mui/utils': 5.15.20(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + clsx: 2.1.1 + csstype: 3.1.3 + prop-types: 15.8.1 + react: 19.0.0-rc-9d4fba0788-20240530 + optionalDependencies: + '@emotion/react': 11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + '@emotion/styled': 11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + '@types/react': types-react@19.0.0-rc.0 + '@mui/types@7.2.14(types-react@19.0.0-rc.0)': optionalDependencies: '@types/react': types-react@19.0.0-rc.0 @@ -6003,10 +5852,20 @@ snapshots: optionalDependencies: '@types/react': types-react@19.0.0-rc.0 - '@mui/x-data-grid@7.6.2(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@mui/material@5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0)': + '@mui/utils@5.15.20(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0)': dependencies: '@babel/runtime': 7.24.6 - '@mui/material': 5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + '@types/prop-types': 15.7.12 + prop-types: 15.8.1 + react: 19.0.0-rc-9d4fba0788-20240530 + react-is: 18.3.1 + optionalDependencies: + '@types/react': types-react@19.0.0-rc.0 + + '@mui/x-data-grid@7.6.2(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@mui/material@5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0)': + dependencies: + '@babel/runtime': 7.24.6 + '@mui/material': 5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@mui/system': 5.15.15(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@mui/utils': 5.15.14(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) clsx: 2.1.1 @@ -6488,14 +6347,14 @@ snapshots: '@ungap/structured-clone@1.2.0': {} - '@vitejs/plugin-react@4.3.1(vite@5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0))': + '@vitejs/plugin-react@4.3.1(vite@5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0))': dependencies: '@babel/core': 7.24.5 '@babel/plugin-transform-react-jsx-self': 7.24.5(@babel/core@7.24.5) '@babel/plugin-transform-react-jsx-source': 7.24.1(@babel/core@7.24.5) '@types/babel__core': 7.20.5 react-refresh: 0.14.2 - vite: 5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0) + vite: 5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0) transitivePeerDependencies: - supports-color @@ -7334,32 +7193,6 @@ snapshots: '@esbuild/win32-ia32': 0.19.12 '@esbuild/win32-x64': 0.19.12 - esbuild@0.20.2: - optionalDependencies: - '@esbuild/aix-ppc64': 0.20.2 - '@esbuild/android-arm': 0.20.2 - '@esbuild/android-arm64': 0.20.2 - '@esbuild/android-x64': 0.20.2 - '@esbuild/darwin-arm64': 0.20.2 - '@esbuild/darwin-x64': 0.20.2 - '@esbuild/freebsd-arm64': 0.20.2 - '@esbuild/freebsd-x64': 0.20.2 - '@esbuild/linux-arm': 0.20.2 - '@esbuild/linux-arm64': 0.20.2 - '@esbuild/linux-ia32': 0.20.2 - '@esbuild/linux-loong64': 0.20.2 - '@esbuild/linux-mips64el': 0.20.2 - '@esbuild/linux-ppc64': 0.20.2 - '@esbuild/linux-riscv64': 0.20.2 - '@esbuild/linux-s390x': 0.20.2 - '@esbuild/linux-x64': 0.20.2 - '@esbuild/netbsd-x64': 0.20.2 - '@esbuild/openbsd-x64': 0.20.2 - '@esbuild/sunos-x64': 0.20.2 - '@esbuild/win32-arm64': 0.20.2 - '@esbuild/win32-ia32': 0.20.2 - '@esbuild/win32-x64': 0.20.2 - esbuild@0.21.4: optionalDependencies: '@esbuild/aix-ppc64': 0.21.4 @@ -7769,9 +7602,9 @@ snapshots: functions-have-names@1.2.3: {} - generouted@1.19.5(vite@5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)): + generouted@1.19.5(vite@5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)): dependencies: - vite: 5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0) + vite: 5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0) gensync@1.0.0-beta.2: {} @@ -8366,7 +8199,7 @@ snapshots: lines-and-columns@1.2.4: {} - lint-staged@15.2.6: + lint-staged@15.2.7: dependencies: chalk: 5.3.0 commander: 12.1.0 @@ -8761,12 +8594,12 @@ snapshots: ms@2.1.3: {} - mui-color-input@2.0.3(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@mui/material@5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0): + mui-color-input@2.0.3(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@mui/material@5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0): dependencies: '@ctrl/tinycolor': 4.1.0 '@emotion/react': 11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) '@emotion/styled': 11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) - '@mui/material': 5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + '@mui/material': 5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) react: 19.0.0-rc-9d4fba0788-20240530 react-dom: 19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530) optionalDependencies: @@ -9196,13 +9029,13 @@ snapshots: react: 19.0.0-rc-9d4fba0788-20240530 react-dom: 19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530) - react-hook-form-mui@7.0.0(szplwmyfv5kdrzoa2ayly36z7i): + react-hook-form-mui@7.0.0(vzgnxglunplyfvn2vosyka7udq): dependencies: - '@mui/material': 5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + '@mui/material': 5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react-dom@19.0.0-rc-9d4fba0788-20240530(react@19.0.0-rc-9d4fba0788-20240530))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) react: 19.0.0-rc-9d4fba0788-20240530 react-hook-form: 7.51.5(react@19.0.0-rc-9d4fba0788-20240530) optionalDependencies: - '@mui/icons-material': 5.15.19(@mui/material@5.15.19(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) + '@mui/icons-material': 5.15.20(@mui/material@5.15.20(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(@emotion/styled@11.11.5(@emotion/react@11.11.4(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0))(react@19.0.0-rc-9d4fba0788-20240530)(types-react@19.0.0-rc.0) react-hook-form@7.51.5(react@19.0.0-rc-9d4fba0788-20240530): dependencies: @@ -9898,7 +9731,7 @@ snapshots: tslib@2.6.2: {} - tsx@4.15.2: + tsx@4.15.4: dependencies: esbuild: 0.21.4 get-tsconfig: 4.7.5 @@ -10118,39 +9951,39 @@ snapshots: esbuild: 0.19.12 monaco-editor: 0.49.0 - vite-plugin-sass-dts@1.3.22(postcss@8.4.38)(prettier@3.3.2)(sass@1.77.5)(vite@5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)): + vite-plugin-sass-dts@1.3.22(postcss@8.4.38)(prettier@3.3.2)(sass@1.77.5)(vite@5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)): dependencies: postcss: 8.4.38 postcss-js: 4.0.1(postcss@8.4.38) prettier: 3.3.2 sass: 1.77.5 - vite: 5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0) + vite: 5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0) - vite-plugin-svgr@4.2.0(rollup@4.17.2)(typescript@5.4.5)(vite@5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)): + vite-plugin-svgr@4.2.0(rollup@4.17.2)(typescript@5.4.5)(vite@5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)): dependencies: '@rollup/pluginutils': 5.1.0(rollup@4.17.2) '@svgr/core': 8.1.0(typescript@5.4.5) '@svgr/plugin-jsx': 8.1.0(@svgr/core@8.1.0(typescript@5.4.5)) - vite: 5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0) + vite: 5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0) transitivePeerDependencies: - rollup - supports-color - typescript - vite-tsconfig-paths@4.3.2(typescript@5.4.5)(vite@5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)): + vite-tsconfig-paths@4.3.2(typescript@5.4.5)(vite@5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0)): dependencies: debug: 4.3.4 globrex: 0.1.2 tsconfck: 3.0.3(typescript@5.4.5) optionalDependencies: - vite: 5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0) + vite: 5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0) transitivePeerDependencies: - supports-color - typescript - vite@5.2.13(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0): + vite@5.3.0(@types/node@20.14.2)(less@4.2.0)(sass@1.77.5)(stylus@0.62.0): dependencies: - esbuild: 0.20.2 + esbuild: 0.21.4 postcss: 8.4.38 rollup: 4.17.2 optionalDependencies: diff --git a/clash-verge-rev/src-tauri/src/cmds.rs b/clash-verge-rev/src-tauri/src/cmds.rs index 68b2ac8024..dd474e88a0 100644 --- a/clash-verge-rev/src-tauri/src/cmds.rs +++ b/clash-verge-rev/src-tauri/src/cmds.rs @@ -181,15 +181,6 @@ pub async fn restart_sidecar() -> CmdResult { wrap_err!(CoreManager::global().run_core().await) } -#[tauri::command] -pub fn grant_permission(_core: String) -> CmdResult { - #[cfg(any(target_os = "macos", target_os = "linux"))] - return wrap_err!(manager::grant_permission(_core)); - - #[cfg(not(any(target_os = "macos", target_os = "linux")))] - return Err("Unsupported target".into()); -} - /// get the system proxy #[tauri::command] pub fn get_sys_proxy() -> CmdResult { diff --git a/clash-verge-rev/src-tauri/src/core/manager.rs b/clash-verge-rev/src-tauri/src/core/manager.rs deleted file mode 100644 index de877382c3..0000000000 --- a/clash-verge-rev/src-tauri/src/core/manager.rs +++ /dev/null @@ -1,48 +0,0 @@ -/// 给clash内核的tun模式授权 -#[cfg(any(target_os = "macos", target_os = "linux"))] -pub fn grant_permission(core: String) -> anyhow::Result<()> { - use std::process::Command; - use tauri::utils::platform::current_exe; - - let path = current_exe()?.with_file_name(core).canonicalize()?; - let path = path.display().to_string(); - - log::debug!("grant_permission path: {path}"); - - #[cfg(target_os = "macos")] - let output = { - let path = path.replace(' ', "\\\\ "); - let shell = format!("chown root:admin {path}\nchmod +sx {path}"); - let command = format!(r#"do shell script "{shell}" with administrator privileges"#); - Command::new("osascript") - .args(vec!["-e", &command]) - .output()? - }; - - #[cfg(target_os = "linux")] - let output = { - let path = path.replace(' ', "\\ "); // 避免路径中有空格 - let shell = - format!("setcap cap_net_bind_service,cap_net_admin,cap_dac_override=+ep {path}"); - - let sudo = match Command::new("which").arg("pkexec").output() { - Ok(output) => { - if output.stdout.is_empty() { - "sudo" - } else { - "pkexec" - } - } - Err(_) => "sudo", - }; - - Command::new(sudo).arg("sh").arg("-c").arg(shell).output()? - }; - - if output.status.success() { - Ok(()) - } else { - let stderr = std::str::from_utf8(&output.stderr).unwrap_or(""); - anyhow::bail!("{stderr}"); - } -} diff --git a/clash-verge-rev/src-tauri/src/core/mod.rs b/clash-verge-rev/src-tauri/src/core/mod.rs index 436ac51872..52e8f27782 100644 --- a/clash-verge-rev/src-tauri/src/core/mod.rs +++ b/clash-verge-rev/src-tauri/src/core/mod.rs @@ -4,7 +4,6 @@ mod core; pub mod handle; pub mod hotkey; pub mod logger; -pub mod manager; pub mod service; pub mod sysopt; pub mod timer; diff --git a/clash-verge-rev/src-tauri/src/main.rs b/clash-verge-rev/src-tauri/src/main.rs index 738135c60d..032f1764bb 100644 --- a/clash-verge-rev/src-tauri/src/main.rs +++ b/clash-verge-rev/src-tauri/src/main.rs @@ -44,7 +44,6 @@ fn main() -> std::io::Result<()> { cmds::get_portable_flag, // cmds::kill_sidecar, cmds::restart_sidecar, - cmds::grant_permission, // clash cmds::get_clash_info, cmds::get_clash_logs, diff --git a/clash-verge-rev/src/components/profile/file-input.tsx b/clash-verge-rev/src/components/profile/file-input.tsx index 5357224a46..2943d829e3 100644 --- a/clash-verge-rev/src/components/profile/file-input.tsx +++ b/clash-verge-rev/src/components/profile/file-input.tsx @@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next"; import { Box, Button, Typography } from "@mui/material"; interface Props { - onChange: (value: string) => void; + onChange: (file: File, value: string) => void; } export const FileInput = (props: Props) => { @@ -28,7 +28,7 @@ export const FileInput = (props: Props) => { const reader = new FileReader(); reader.onload = (event) => { resolve(null); - onChange(event.target?.result as string); + onChange(file, event.target?.result as string); }; reader.onerror = reject; reader.readAsText(file); diff --git a/clash-verge-rev/src/components/profile/profile-viewer.tsx b/clash-verge-rev/src/components/profile/profile-viewer.tsx index ba70096aa0..14839dd85e 100644 --- a/clash-verge-rev/src/components/profile/profile-viewer.tsx +++ b/clash-verge-rev/src/components/profile/profile-viewer.tsx @@ -246,7 +246,15 @@ export const ProfileViewer = forwardRef( )} {isLocal && openType === "new" && ( - (fileDataRef.current = val)} /> + { + if (!formIns.getValues("name")) { + const name = file.name.substring(0, file.name.lastIndexOf(".")); + formIns.setValue("name", name); + } + fileDataRef.current = val; + }} + /> )} {isRemote && ( diff --git a/clash-verge-rev/src/components/setting/mods/clash-core-viewer.tsx b/clash-verge-rev/src/components/setting/mods/clash-core-viewer.tsx index b5f4986b59..88e89ab1ad 100644 --- a/clash-verge-rev/src/components/setting/mods/clash-core-viewer.tsx +++ b/clash-verge-rev/src/components/setting/mods/clash-core-viewer.tsx @@ -6,17 +6,9 @@ import { useVerge } from "@/hooks/use-verge"; import { useLockFn } from "ahooks"; import { LoadingButton } from "@mui/lab"; import { SwitchAccessShortcut, RestartAlt } from "@mui/icons-material"; -import { - Box, - Button, - Tooltip, - List, - ListItemButton, - ListItemText, -} from "@mui/material"; +import { Box, Button, List, ListItemButton, ListItemText } from "@mui/material"; import { changeClashCore, restartSidecar } from "@/services/cmds"; import { closeAllConnections, upgradeCore } from "@/services/api"; -import { grantPermission } from "@/services/cmds"; import getSystem from "@/utils/get-system"; const VALID_CORE = [ @@ -58,17 +50,6 @@ export const ClashCoreViewer = forwardRef((props, ref) => { } }); - const onGrant = useLockFn(async (core: string) => { - try { - await grantPermission(core); - // 自动重启 - if (core === clash_core) await restartSidecar(); - Notice.success(t("Permissions Granted Successfully for _clash Core", { core: `${core}` }), 1000); - } catch (err: any) { - Notice.error(err?.message || err.toString()); - } - }); - const onRestart = useLockFn(async () => { try { await restartSidecar(); @@ -140,22 +121,6 @@ export const ClashCoreViewer = forwardRef((props, ref) => { onClick={() => onCoreChange(each.core)} > - - {(OS === "macos" || OS === "linux") && ( - - - - )} ))} diff --git a/clash-verge-rev/src/components/setting/mods/service-viewer.tsx b/clash-verge-rev/src/components/setting/mods/service-viewer.tsx index 137c55e829..5c4e97fa0e 100644 --- a/clash-verge-rev/src/components/setting/mods/service-viewer.tsx +++ b/clash-verge-rev/src/components/setting/mods/service-viewer.tsx @@ -41,8 +41,11 @@ export const ServiceViewer = forwardRef((props, ref) => { const onInstall = useLockFn(async () => { try { await installService(); - mutateCheck(); + await mutateCheck(); setOpen(false); + setTimeout(() => { + mutateCheck(); + }, 2000); Notice.success(t("Service Installed Successfully")); } catch (err: any) { mutateCheck(); diff --git a/clash-verge-rev/src/components/setting/mods/stack-mode-switch.tsx b/clash-verge-rev/src/components/setting/mods/stack-mode-switch.tsx index d671d339ae..4bb7604fec 100644 --- a/clash-verge-rev/src/components/setting/mods/stack-mode-switch.tsx +++ b/clash-verge-rev/src/components/setting/mods/stack-mode-switch.tsx @@ -4,6 +4,7 @@ import { checkService } from "@/services/cmds"; import { useVerge } from "@/hooks/use-verge"; import getSystem from "@/utils/get-system"; import useSWR from "swr"; +import { useEffect } from "react"; const isWIN = getSystem() === "windows"; @@ -17,7 +18,7 @@ export const StackModeSwitch = (props: Props) => { const { verge } = useVerge(); const { enable_service_mode } = verge ?? {}; // service mode - const { data: serviceStatus } = useSWR( + const { data: serviceStatus, mutate: mutateCheck } = useSWR( isWIN ? "checkService" : null, checkService, { @@ -28,6 +29,10 @@ export const StackModeSwitch = (props: Props) => { const { t } = useTranslation(); + useEffect(() => { + mutateCheck(); + }, []); + return ( ("restart_sidecar"); } -export async function grantPermission(core: string) { - return invoke("grant_permission", { core }); -} - export async function getAppDir() { return invoke("get_app_dir"); } diff --git a/gost/.github/workflows/release.yml b/gost/.github/workflows/release.yml index e5e3f1093e..6a5edb8adb 100644 --- a/gost/.github/workflows/release.yml +++ b/gost/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: - run: git fetch --force --tags - uses: actions/setup-go@v3 with: - go-version: '1.19' + go-version: '1.21.7' cache: true # More assembly might be required: Docker logins, GPG, etc. It all depends # on your needs. diff --git a/gost/Dockerfile b/gost/Dockerfile index 6186a99e48..797006c77e 100644 --- a/gost/Dockerfile +++ b/gost/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=$BUILDPLATFORM golang:1.20-alpine as builder +FROM --platform=$BUILDPLATFORM golang:1.22-alpine as builder # Convert TARGETPLATFORM to GOARCH format # https://github.com/tonistiigi/xx @@ -13,6 +13,7 @@ ADD . /src WORKDIR /src ENV GO111MODULE=on +ENV CGO_ENABLED=0 RUN cd cmd/gost && go env && go build -v diff --git a/gost/cmd/gost/peer.go b/gost/cmd/gost/peer.go index 6f5b32ce59..af062c7198 100644 --- a/gost/cmd/gost/peer.go +++ b/gost/cmd/gost/peer.go @@ -13,14 +13,16 @@ import ( ) type peerConfig struct { - Strategy string `json:"strategy"` - MaxFails int `json:"max_fails"` - FailTimeout time.Duration - period time.Duration // the period for live reloading - Nodes []string `json:"nodes"` - group *gost.NodeGroup - baseNodes []gost.Node - stopped chan struct{} + Strategy string `json:"strategy"` + MaxFails int `json:"max_fails"` + FastestCount int `json:"fastest_count"` // topN fastest node count + FailTimeout time.Duration + period time.Duration // the period for live reloading + + Nodes []string `json:"nodes"` + group *gost.NodeGroup + baseNodes []gost.Node + stopped chan struct{} } func newPeerConfig() *peerConfig { @@ -51,6 +53,7 @@ func (cfg *peerConfig) Reload(r io.Reader) error { FailTimeout: cfg.FailTimeout, }, &gost.InvalidFilter{}, + gost.NewFastestFilter(0, cfg.FastestCount), ), gost.WithStrategy(gost.NewStrategy(cfg.Strategy)), ) @@ -125,6 +128,8 @@ func (cfg *peerConfig) parse(r io.Reader) error { cfg.Strategy = ss[1] case "max_fails": cfg.MaxFails, _ = strconv.Atoi(ss[1]) + case "fastest_count": + cfg.FastestCount, _ = strconv.Atoi(ss[1]) case "fail_timeout": cfg.FailTimeout, _ = time.ParseDuration(ss[1]) case "reload": diff --git a/gost/cmd/gost/route.go b/gost/cmd/gost/route.go index e6f0c633a6..360bc2d1f5 100644 --- a/gost/cmd/gost/route.go +++ b/gost/cmd/gost/route.go @@ -66,6 +66,7 @@ func (r *route) parseChain() (*gost.Chain, error) { FailTimeout: nodes[0].GetDuration("fail_timeout"), }, &gost.InvalidFilter{}, + gost.NewFastestFilter(0, nodes[0].GetInt("fastest_count")), ), gost.WithStrategy(gost.NewStrategy(nodes[0].Get("strategy"))), ) diff --git a/gost/go.mod b/gost/go.mod index cfd2b9e0a0..d6336663df 100644 --- a/gost/go.mod +++ b/gost/go.mod @@ -1,34 +1,34 @@ module github.com/ginuerzh/gost -go 1.20 +go 1.22 replace github.com/templexxx/cpu v0.0.7 => github.com/templexxx/cpu v0.0.10-0.20211111114238-98168dcec14a require ( - git.torproject.org/pluggable-transports/goptlib.git v1.2.0 + git.torproject.org/pluggable-transports/goptlib.git v1.3.0 github.com/LiamHaworth/go-tproxy v0.0.0-20190726054950-ef7efd7f24ed - github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d + github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 github.com/go-gost/gosocks4 v0.0.1 github.com/go-gost/gosocks5 v0.3.0 github.com/go-gost/relay v0.1.1-0.20211123134818-8ef7fd81ffd7 github.com/go-gost/tls-dissector v0.0.2-0.20220408131628-aac992c27451 github.com/go-log/log v0.2.0 github.com/gobwas/glob v0.2.3 - github.com/gorilla/websocket v1.4.2 - github.com/klauspost/compress v1.13.6 + github.com/gorilla/websocket v1.5.1 + github.com/klauspost/compress v1.17.6 github.com/mdlayher/vsock v1.2.1 - github.com/miekg/dns v1.1.47 - github.com/quic-go/quic-go v0.32.0 + github.com/miekg/dns v1.1.58 + github.com/quic-go/quic-go v0.45.0 github.com/ryanuber/go-glob v1.0.0 github.com/shadowsocks/go-shadowsocks2 v0.1.5 github.com/shadowsocks/shadowsocks-go v0.0.0-20200409064450-3e585ff90601 github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 - github.com/xtaci/kcp-go/v5 v5.6.1 - github.com/xtaci/smux v1.5.16 + github.com/xtaci/kcp-go/v5 v5.6.7 + github.com/xtaci/smux v1.5.24 github.com/xtaci/tcpraw v1.2.25 gitlab.com/yawning/obfs4.git v0.0.0-20220204003609-77af0cba934d - golang.org/x/crypto v0.17.0 - golang.org/x/net v0.10.0 + golang.org/x/crypto v0.24.0 + golang.org/x/net v0.26.0 ) require ( @@ -36,28 +36,25 @@ require ( github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect github.com/coreos/go-iptables v0.6.0 // indirect github.com/dchest/siphash v1.2.2 // indirect - github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect - github.com/golang/mock v1.6.0 // indirect + github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/google/gopacket v1.1.19 // indirect - github.com/google/pprof v0.0.0-20230131232505-5a9e8f65f08f // indirect - github.com/klauspost/cpuid/v2 v2.0.9 // indirect - github.com/klauspost/reedsolomon v1.9.15 // indirect + github.com/google/pprof v0.0.0-20240528025155-186aa0362fba // indirect + github.com/klauspost/cpuid/v2 v2.2.6 // indirect + github.com/klauspost/reedsolomon v1.12.0 // indirect github.com/mdlayher/socket v0.4.1 // indirect - github.com/onsi/ginkgo/v2 v2.8.0 // indirect + github.com/onsi/ginkgo/v2 v2.19.0 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/quic-go/qtls-go1-18 v0.2.0 // indirect - github.com/quic-go/qtls-go1-19 v0.2.0 // indirect - github.com/quic-go/qtls-go1-20 v0.1.0 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect - github.com/templexxx/cpu v0.0.7 // indirect - github.com/templexxx/xorsimd v0.4.1 // indirect + github.com/templexxx/cpu v0.1.0 // indirect + github.com/templexxx/xorsimd v0.4.2 // indirect github.com/tjfoc/gmsm v1.4.1 // indirect github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37 // indirect gitlab.com/yawning/edwards25519-extra.git v0.0.0-20211229043746-2f91fcc9fbdb // indirect - golang.org/x/exp v0.0.0-20230203172020-98cc5a0785f9 // indirect - golang.org/x/mod v0.8.0 // indirect - golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.15.0 // indirect - golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.6.0 // indirect + go.uber.org/mock v0.4.0 // indirect + golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect + golang.org/x/mod v0.18.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect + golang.org/x/tools v0.22.0 // indirect ) diff --git a/gost/go.sum b/gost/go.sum index e22a2d0e19..1b988e449d 100644 --- a/gost/go.sum +++ b/gost/go.sum @@ -2,21 +2,20 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT filippo.io/edwards25519 v1.0.0-rc.1.0.20210721174708-390f27c3be20 h1:iJoUgXvhagsNMrJrvavw7vu1eG8+hm6jLOxlLFcoODw= filippo.io/edwards25519 v1.0.0-rc.1.0.20210721174708-390f27c3be20/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= git.torproject.org/pluggable-transports/goptlib.git v1.0.0/go.mod h1:YT4XMSkuEXbtqlydr9+OxqFAyspUv0Gr9qhM3B++o/Q= -git.torproject.org/pluggable-transports/goptlib.git v1.2.0 h1:0qRF7Dw5qXd0FtZkjWUiAh5GTutRtDGL4GXUDJ4qMHs= -git.torproject.org/pluggable-transports/goptlib.git v1.2.0/go.mod h1:4PBMl1dg7/3vMWSoWb46eGWlrxkUyn/CAJmxhDLAlDs= +git.torproject.org/pluggable-transports/goptlib.git v1.3.0 h1:G+iuRUblCCC2xnO+0ag1/4+aaM98D5mjWP1M0v9s8a0= +git.torproject.org/pluggable-transports/goptlib.git v1.3.0/go.mod h1:4PBMl1dg7/3vMWSoWb46eGWlrxkUyn/CAJmxhDLAlDs= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/LiamHaworth/go-tproxy v0.0.0-20190726054950-ef7efd7f24ed h1:eqa6queieK8SvoszxCu0WwH7lSVeL4/N/f1JwOMw1G4= github.com/LiamHaworth/go-tproxy v0.0.0-20190726054950-ef7efd7f24ed/go.mod h1:rA52xkgZwql9LRZXWb2arHEFP6qSR48KY2xOfWzEciQ= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= -github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= -github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= +github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= +github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/coreos/go-iptables v0.6.0 h1:is9qnZMPYjLd8LYqmm/qlE+wwEgJIkTYdhV3rfZo4jk= github.com/coreos/go-iptables v0.6.0/go.mod h1:Qe8Bv2Xik5FyTXwgIbLAnv2sWSBmvWdFETJConOQ//Q= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= @@ -35,15 +34,14 @@ github.com/go-gost/tls-dissector v0.0.2-0.20220408131628-aac992c27451 h1:xj8gUZG github.com/go-gost/tls-dissector v0.0.2-0.20220408131628-aac992c27451/go.mod h1:/9QfdewqmHdaE362Hv5nDaSWLx3pCmtD870d6GaquXs= github.com/go-log/log v0.2.0 h1:z8i91GBudxD5L3RmF0KVpetCbcGWAV7q1Tw1eRwQM9Q= github.com/go-log/log v0.2.0/go.mod h1:xzCnwajcues/6w7lne3yK2QU7DBPW7kqbgPGG5AF65U= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= @@ -53,51 +51,41 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= -github.com/google/pprof v0.0.0-20230131232505-5a9e8f65f08f h1:gl1DCiSk+mrXXBGPm6CEeS2MkJuMVzAOrXg34oVj1QI= -github.com/google/pprof v0.0.0-20230131232505-5a9e8f65f08f/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/cpuid v1.2.4/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/klauspost/cpuid v1.3.1/go.mod h1:bYW4mA6ZgKPob1/Dlai2LviZJO7KGI3uoWLd42rAQw4= -github.com/klauspost/cpuid/v2 v2.0.6/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/reedsolomon v1.9.9/go.mod h1:O7yFFHiQwDR6b2t63KPUpccPtNdp5ADgh1gg4fd12wo= -github.com/klauspost/reedsolomon v1.9.15 h1:g2erWKD2M6rgnPf89fCji6jNlhMKMdXcuNHMW1SYCIo= -github.com/klauspost/reedsolomon v1.9.15/go.mod h1:eqPAcE7xar5CIzcdfwydOEdcmchAKAP/qs14y4GCBOk= +github.com/google/pprof v0.0.0-20240528025155-186aa0362fba h1:ql1qNgCyOB7iAEk8JTNM+zJrgIbnyCKX/wdlyPufP5g= +github.com/google/pprof v0.0.0-20240528025155-186aa0362fba/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI= +github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= +github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= +github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/reedsolomon v1.12.0 h1:I5FEp3xSwVCcEh3F5A7dofEfhXdF/bWhQWPH+XwBFno= +github.com/klauspost/reedsolomon v1.12.0/go.mod h1:EPLZJeh4l27pUGC3aXOjheaoh1I9yut7xTURiW3LQ9Y= github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U= github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA= github.com/mdlayher/vsock v1.2.1 h1:pC1mTJTvjo1r9n9fbm7S1j04rCgCzhCOS5DY0zqHlnQ= github.com/mdlayher/vsock v1.2.1/go.mod h1:NRfCibel++DgeMD8z/hP+PPTjlNJsdPOmxcnENvE+SE= -github.com/miekg/dns v1.1.47 h1:J9bWiXbqMbnZPcY8Qi2E3EWIBsIm6MZzzJB9VRg5gL8= -github.com/miekg/dns v1.1.47/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME= -github.com/mmcloughlin/avo v0.0.0-20200803215136-443f81d77104/go.mod h1:wqKykBG2QzQDJEzvRkcS8x6MiSJkF52hXZsXcjaB3ls= -github.com/onsi/ginkgo/v2 v2.8.0 h1:pAM+oBNPrpXRs+E/8spkeGx9QgekbRVyr74EUvRVOUI= -github.com/onsi/ginkgo/v2 v2.8.0/go.mod h1:6JsQiECmxCa3V5st74AL/AmsV482EDdVrGaVW6z3oYU= -github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y= +github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4= +github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY= +github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= +github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= +github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= +github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/quic-go/qtls-go1-18 v0.2.0 h1:5ViXqBZ90wpUcZS0ge79rf029yx0dYB0McyPJwqqj7U= -github.com/quic-go/qtls-go1-18 v0.2.0/go.mod h1:moGulGHK7o6O8lSPSZNoOwcLvJKJ85vVNc7oJFD65bc= -github.com/quic-go/qtls-go1-19 v0.2.0 h1:Cvn2WdhyViFUHoOqK52i51k4nDX8EwIh5VJiVM4nttk= -github.com/quic-go/qtls-go1-19 v0.2.0/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= -github.com/quic-go/qtls-go1-20 v0.1.0 h1:d1PK3ErFy9t7zxKsG3NXBJXZjp/kMLoIb3y/kV54oAI= -github.com/quic-go/qtls-go1-20 v0.1.0/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= -github.com/quic-go/quic-go v0.32.0 h1:lY02md31s1JgPiiyfqJijpu/UX/Iun304FI3yUqX7tA= -github.com/quic-go/quic-go v0.32.0/go.mod h1:/fCsKANhQIeD5l76c2JFU+07gVE3KaA0FP+0zMWwfwo= +github.com/quic-go/quic-go v0.45.0 h1:OHmkQGM37luZITyTSu6ff03HP/2IrwDX1ZFiNEhSFUE= +github.com/quic-go/quic-go v0.45.0/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk= @@ -108,137 +96,92 @@ github.com/shadowsocks/shadowsocks-go v0.0.0-20200409064450-3e585ff90601 h1:XU9h github.com/shadowsocks/shadowsocks-go v0.0.0-20200409064450-3e585ff90601/go.mod h1:mttDPaeLm87u74HMrP+n2tugXvIKWcwff/cqSX0lehY= github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 h1:TG/diQgUe0pntT/2D9tmUCz4VNwm9MfrtPr0SU2qSX8= github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8/go.mod h1:P5HUIBuIWKbyjl083/loAegFkfbFNx5i2qEP4CNbm7E= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/templexxx/cpu v0.0.1/go.mod h1:w7Tb+7qgcAlIyX4NhLuDKt78AHA5SzPmq0Wj6HiEnnk= -github.com/templexxx/cpu v0.0.10-0.20211111114238-98168dcec14a h1:f0GQM8LuKYnXdNLcAg+di6PULSlR5iQtZT3bDwDRiA0= -github.com/templexxx/cpu v0.0.10-0.20211111114238-98168dcec14a/go.mod h1:w7Tb+7qgcAlIyX4NhLuDKt78AHA5SzPmq0Wj6HiEnnk= -github.com/templexxx/xorsimd v0.4.1 h1:iUZcywbOYDRAZUasAs2eSCUW8eobuZDy0I9FJiORkVg= -github.com/templexxx/xorsimd v0.4.1/go.mod h1:W+ffZz8jJMH2SXwuKu9WhygqBMbFnp14G2fqEr8qaNo= -github.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/templexxx/cpu v0.1.0 h1:wVM+WIJP2nYaxVxqgHPD4wGA2aJ9rvrQRV8CvFzNb40= +github.com/templexxx/cpu v0.1.0/go.mod h1:w7Tb+7qgcAlIyX4NhLuDKt78AHA5SzPmq0Wj6HiEnnk= +github.com/templexxx/xorsimd v0.4.2 h1:ocZZ+Nvu65LGHmCLZ7OoCtg8Fx8jnHKK37SjvngUoVI= +github.com/templexxx/xorsimd v0.4.2/go.mod h1:HgwaPoDREdi6OnULpSfxhzaiiSUY4Fi3JPn1wpt28NI= github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho= github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE= -github.com/xtaci/kcp-go/v5 v5.6.1 h1:Pwn0aoeNSPF9dTS7IgiPXn0HEtaIlVb6y5UKWPsx8bI= -github.com/xtaci/kcp-go/v5 v5.6.1/go.mod h1:W3kVPyNYwZ06p79dNwFWQOVFrdcBpDBsdyvK8moQrYo= -github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae/go.mod h1:gXtu8J62kEgmN++bm9BVICuT/e8yiLI2KFobd/TRFsE= +github.com/xtaci/kcp-go/v5 v5.6.7 h1:7+rnxNFIsjEwTXQk4cSZpXM4pO0hqtpwE1UFFoJBffA= +github.com/xtaci/kcp-go/v5 v5.6.7/go.mod h1:oE9j2NVqAkuKO5o8ByKGch3vgVX3BNf8zqP8JiGq0bM= github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37 h1:EWU6Pktpas0n8lLQwDsRyZfmkPeRbdgPtW609es+/9E= github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37/go.mod h1:HpMP7DB2CyokmAh4lp0EQnnWhmycP/TvwBGzvuie+H0= -github.com/xtaci/smux v1.5.16 h1:FBPYOkW8ZTjLKUM4LI4xnnuuDC8CQ/dB04HD519WoEk= -github.com/xtaci/smux v1.5.16/go.mod h1:OMlQbT5vcgl2gb49mFkYo6SMf+zP3rcjcwQz7ZU7IGY= +github.com/xtaci/smux v1.5.24 h1:77emW9dtnOxxOQ5ltR+8BbsX1kzcOxQ5gB+aaV9hXOY= +github.com/xtaci/smux v1.5.24/go.mod h1:OMlQbT5vcgl2gb49mFkYo6SMf+zP3rcjcwQz7ZU7IGY= github.com/xtaci/tcpraw v1.2.25 h1:VDlqo0op17JeXBM6e2G9ocCNLOJcw9mZbobMbJjo0vk= github.com/xtaci/tcpraw v1.2.25/go.mod h1:dKyZ2V75s0cZ7cbgJYdxPvms7af0joIeOyx1GgJQbLk= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= gitlab.com/yawning/edwards25519-extra.git v0.0.0-20211229043746-2f91fcc9fbdb h1:qRSZHsODmAP5qDvb3YsO7Qnf3TRiVbGxNG/WYnlM4/o= gitlab.com/yawning/edwards25519-extra.git v0.0.0-20211229043746-2f91fcc9fbdb/go.mod h1:gvdJuZuO/tPZyhEV8K3Hmoxv/DWud5L4qEQxfYjEUTo= gitlab.com/yawning/obfs4.git v0.0.0-20220204003609-77af0cba934d h1:tJ8F7ABaQ3p3wjxwXiWSktVDgjZEXkvaRawd2rIq5ws= gitlab.com/yawning/obfs4.git v0.0.0-20220204003609-77af0cba934d/go.mod h1:9GcM8QNU9/wXtEEH2q8bVOnPI7FtIF6VVLzZ1l6Hgf8= -golang.org/x/arch v0.0.0-20190909030613-46d78d1859ac/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4= +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= -golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20230203172020-98cc5a0785f9 h1:frX3nT9RkKybPnjyI+yvZh6ZucTZatCCEm9D47sZ2zo= -golang.org/x/exp v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 h1:LoYXNGAShUG3m/ehNk4iFctuhGX/+R1ZpfJ4/ia80JM= +golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= +golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200808120158-1030fc2bf1d9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= +golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= +golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200425043458-8463f397d07c/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200808161706-5bf02b21f123/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4= -golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= -golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= +golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= @@ -253,11 +196,9 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/gost/gost.go b/gost/gost.go index 70633d5d3f..cb4ca47ac0 100644 --- a/gost/gost.go +++ b/gost/gost.go @@ -20,7 +20,7 @@ import ( ) // Version is the gost version. -const Version = "2.11.5" +const Version = "2.12.0" // Debug is a flag that enables the debug log. var Debug bool @@ -149,9 +149,7 @@ func (rw *readWriter) Write(p []byte) (n int, err error) { return rw.w.Write(p) } -var ( - nopClientConn = &nopConn{} -) +var nopClientConn = &nopConn{} // a nop connection implements net.Conn, // it does nothing. diff --git a/gost/quic.go b/gost/quic.go index 67b83d35df..5d60caa7bb 100644 --- a/gost/quic.go +++ b/gost/quic.go @@ -115,10 +115,10 @@ func (tr *quicTransporter) initSession(addr net.Addr, conn net.PacketConn) (*qui KeepAlivePeriod: config.KeepAlivePeriod, Versions: []quic.VersionNumber{ quic.Version1, - quic.VersionDraft29, + quic.Version2, }, } - session, err := quic.DialEarly(conn, addr, addr.String(), tlsConfigQUICALPN(config.TLSConfig), quicConfig) + session, err := quic.DialEarly(context.Background(), conn, addr, tlsConfigQUICALPN(config.TLSConfig), quicConfig) if err != nil { log.Logf("quic dial %s: %v", addr, err) return nil, err @@ -157,7 +157,7 @@ func QUICListener(addr string, config *QUICConfig) (Listener, error) { MaxIdleTimeout: config.IdleTimeout, Versions: []quic.VersionNumber{ quic.Version1, - quic.VersionDraft29, + quic.Version2, }, } @@ -186,7 +186,7 @@ func QUICListener(addr string, config *QUICConfig) (Listener, error) { } l := &quicListener{ - ln: ln, + ln: *ln, connChan: make(chan net.Conn, 1024), errChan: make(chan error, 1), } @@ -341,8 +341,7 @@ func tlsConfigQUICALPN(tlsConfig *tls.Config) *tls.Config { if tlsConfig == nil { panic("quic: tlsconfig is nil") } - tlsConfigQUIC := &tls.Config{} - *tlsConfigQUIC = *tlsConfig + tlsConfigQUIC := tlsConfig.Clone() tlsConfigQUIC.NextProtos = []string{"http/3", "quic/v1"} return tlsConfigQUIC } diff --git a/gost/redirect.go b/gost/redirect.go index 0ab59d1047..199d5c2fe1 100644 --- a/gost/redirect.go +++ b/gost/redirect.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package gost diff --git a/gost/redirect_other.go b/gost/redirect_other.go index d2a576a6ab..a22fec2c8c 100644 --- a/gost/redirect_other.go +++ b/gost/redirect_other.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package gost @@ -35,8 +36,7 @@ func (h *tcpRedirectHandler) Handle(c net.Conn) { c.Close() } -type udpRedirectHandler struct { -} +type udpRedirectHandler struct{} // UDPRedirectHandler creates a server Handler for UDP transparent server. func UDPRedirectHandler(opts ...HandlerOption) Handler { diff --git a/gost/selector.go b/gost/selector.go index bff6d11f49..ccac77ea1b 100644 --- a/gost/selector.go +++ b/gost/selector.go @@ -4,10 +4,13 @@ import ( "errors" "math/rand" "net" + "sort" "strconv" "sync" "sync/atomic" "time" + + "github.com/go-log/log" ) var ( @@ -205,6 +208,94 @@ func (f *FailFilter) String() string { return "fail" } +// FastestFilter filter the fastest node +type FastestFilter struct { + mu sync.Mutex + + pinger *net.Dialer + pingResult map[int]int + pingResultTTL map[int]int64 + + topCount int +} + +func NewFastestFilter(pingTimeOut int, topCount int) *FastestFilter { + if pingTimeOut == 0 { + pingTimeOut = 3000 // 3s + } + return &FastestFilter{ + mu: sync.Mutex{}, + pinger: &net.Dialer{Timeout: time.Millisecond * time.Duration(pingTimeOut)}, + pingResult: make(map[int]int, 0), + pingResultTTL: make(map[int]int64, 0), + topCount: topCount, + } +} + +func (f *FastestFilter) Filter(nodes []Node) []Node { + // disabled + if f.topCount == 0 { + return nodes + } + + // get latency with ttl cache + now := time.Now().Unix() + + var getNodeLatency = func(node Node) int { + f.mu.Lock() + defer f.mu.Unlock() + + if f.pingResultTTL[node.ID] < now { + f.pingResultTTL[node.ID] = now + 5 // tmp + + // get latency + go func(node Node) { + latency := f.doTcpPing(node.Addr) + r := rand.New(rand.NewSource(time.Now().UnixNano())) + ttl := 300 - int64(120*r.Float64()) + + f.mu.Lock() + defer f.mu.Unlock() + + f.pingResult[node.ID] = latency + f.pingResultTTL[node.ID] = now + ttl + }(node) + } + return f.pingResult[node.ID] + } + + // sort + sort.Slice(nodes, func(i, j int) bool { + return getNodeLatency(nodes[i]) < getNodeLatency(nodes[j]) + }) + + // split + if len(nodes) <= f.topCount { + return nodes + } + + return nodes[0:f.topCount] +} + +func (f *FastestFilter) String() string { + return "fastest" +} + +// doTcpPing +func (f *FastestFilter) doTcpPing(address string) int { + start := time.Now() + conn, err := f.pinger.Dial("tcp", address) + elapsed := time.Since(start) + + if err == nil { + _ = conn.Close() + } + + latency := int(elapsed.Milliseconds()) + log.Logf("pingDoTCP: %s, latency: %d", address, latency) + return latency +} + // InvalidFilter filters the invalid node. // A node is invalid if its port is invalid (negative or zero value). type InvalidFilter struct{} diff --git a/gost/selector_test.go b/gost/selector_test.go index 5da667cfe5..7cbbfd05de 100644 --- a/gost/selector_test.go +++ b/gost/selector_test.go @@ -127,6 +127,30 @@ func TestFailFilter(t *testing.T) { } } +func TestFastestFilter(t *testing.T) { + nodes := []Node{ + Node{ID: 1, marker: &failMarker{}, Addr: "1.0.0.1:80"}, + Node{ID: 2, marker: &failMarker{}, Addr: "1.0.0.2:80"}, + Node{ID: 3, marker: &failMarker{}, Addr: "1.0.0.3:80"}, + } + filter := NewFastestFilter(0, 2) + + var print = func(nodes []Node) []string { + var rows []string + for _, node := range nodes { + rows = append(rows, node.Addr) + } + return rows + } + + result1 := filter.Filter(nodes) + t.Logf("result 1: %+v", print(result1)) + + time.Sleep(time.Second) + result2 := filter.Filter(nodes) + t.Logf("result 2: %+v", print(result2)) +} + func TestSelector(t *testing.T) { nodes := []Node{ Node{ID: 1, marker: &failMarker{}}, diff --git a/gost/signal.go b/gost/signal.go index f12e9023af..cf7e4840c3 100644 --- a/gost/signal.go +++ b/gost/signal.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package gost diff --git a/gost/snap/snapcraft.yaml b/gost/snap/snapcraft.yaml index b438421457..142de11f54 100644 --- a/gost/snap/snapcraft.yaml +++ b/gost/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: gost base: core20 -version: '2.11.5' +version: '2.12.0' summary: A simple security tunnel written in golang description: | Project: https://github.com/ginuerzh/gost @@ -20,7 +20,7 @@ parts: source: https://github.com/ginuerzh/gost source-subdir: cmd/gost source-type: git - source-tag: v2.11.5 + source-tag: v2.12.0 build-packages: - gcc diff --git a/gost/sockopts_linux.go b/gost/sockopts_linux.go index 380f272b4e..7df3f49a33 100644 --- a/gost/sockopts_linux.go +++ b/gost/sockopts_linux.go @@ -8,4 +8,4 @@ func setSocketMark(fd int, value int) (e error) { func setSocketInterface(fd int, value string) (e error) { return syscall.SetsockoptString(fd, syscall.SOL_SOCKET, syscall.SO_BINDTODEVICE, value) -} \ No newline at end of file +} diff --git a/gost/socks.go b/gost/socks.go index dfd8012ac4..d59dd89e29 100644 --- a/gost/socks.go +++ b/gost/socks.go @@ -1125,7 +1125,7 @@ func (h *socks5Handler) handleUDPRelay(conn net.Conn, req *gosocks5.Request) { return } - relay, err := net.ListenUDP("udp", nil) + relay, err := net.ListenUDP("udp", &net.UDPAddr{IP: conn.LocalAddr().(*net.TCPAddr).IP, Port: 0}) // use out-going interface's IP if err != nil { log.Logf("[socks5-udp] %s -> %s : %s", conn.RemoteAddr(), conn.LocalAddr(), err) reply := gosocks5.NewReply(gosocks5.Failure, nil) @@ -1138,7 +1138,6 @@ func (h *socks5Handler) handleUDPRelay(conn net.Conn, req *gosocks5.Request) { defer relay.Close() socksAddr := toSocksAddr(relay.LocalAddr()) - socksAddr.Host, _, _ = net.SplitHostPort(conn.LocalAddr().String()) // replace the IP to the out-going interface's reply := gosocks5.NewReply(gosocks5.Succeeded, socksAddr) if err := reply.Write(conn); err != nil { log.Logf("[socks5-udp] %s <- %s : %s", conn.RemoteAddr(), conn.LocalAddr(), err) diff --git a/gost/ssh.go b/gost/ssh.go index 17ad653f9f..a78e4c3560 100644 --- a/gost/ssh.go +++ b/gost/ssh.go @@ -6,8 +6,8 @@ import ( "encoding/binary" "errors" "fmt" - "os" "net" + "os" "strconv" "strings" "sync" @@ -27,9 +27,7 @@ const ( GostSSHTunnelRequest = "gost-tunnel" // extended request type for ssh tunnel ) -var ( - errSessionDead = errors.New("session is dead") -) +var errSessionDead = errors.New("session is dead") // ParseSSHKeyFile parses ssh key file. func ParseSSHKeyFile(fp string) (ssh.Signer, error) { @@ -59,8 +57,7 @@ func ParseSSHAuthorizedKeysFile(fp string) (map[string]bool, error) { return authorizedKeysMap, nil } -type sshDirectForwardConnector struct { -} +type sshDirectForwardConnector struct{} // SSHDirectForwardConnector creates a Connector for SSH TCP direct port forwarding. func SSHDirectForwardConnector() Connector { @@ -103,8 +100,7 @@ func (c *sshDirectForwardConnector) ConnectContext(ctx context.Context, conn net return conn, nil } -type sshRemoteForwardConnector struct { -} +type sshRemoteForwardConnector struct{} // SSHRemoteForwardConnector creates a Connector for SSH TCP remote port forwarding. func SSHRemoteForwardConnector() Connector { @@ -650,7 +646,7 @@ func (h *sshForwardHandler) tcpipForwardRequest(sshConn ssh.Conn, req *ssh.Reque return } - ln, err := net.Listen("tcp", addr) //tie to the client connection + ln, err := net.Listen("tcp", addr) // tie to the client connection if err != nil { log.Log("[ssh-rtcp]", err) req.Reply(false, nil) diff --git a/gost/tuntap_unix.go b/gost/tuntap_unix.go index 9a6d17ee4d..04d6db01c2 100644 --- a/gost/tuntap_unix.go +++ b/gost/tuntap_unix.go @@ -1,3 +1,4 @@ +//go:build !linux && !windows && !darwin // +build !linux,!windows,!darwin package gost diff --git a/lede/package/lean/autocore/files/arm/index.htm b/lede/package/lean/autocore/files/arm/index.htm index 0537b09035..f62369b6eb 100644 --- a/lede/package/lean/autocore/files/arm/index.htm +++ b/lede/package/lean/autocore/files/arm/index.htm @@ -55,8 +55,14 @@ ):match("%d+")) or 4096 local user_info = luci.sys.exec("cat /proc/net/arp | grep 'br-lan' | grep '0x2' | wc -l") + + if fs.access("/sys/kernel/debug/qca-nss-drv/stats/cpu_load_ubi") then + nss_usage = " NSS: "..luci.sys.exec("grep '%' /sys/kernel/debug/qca-nss-drv/stats/cpu_load_ubi | awk -F ' ' '{print $2}'") or "" + else + nss_usage = "" + end - local cpu_usage = luci.sys.exec("top -n1 | awk '/^CPU/ { printf(\"%d%%\", 100 - $8) }'") or "6%" + local cpu_usage = "CPU: "..luci.sys.exec("top -n1 | awk '/^CPU/ { printf(\"%d%%\", 100 - $8) }'")..nss_usage local cpu_info = luci.sys.exec("/sbin/cpuinfo") or "ARM Processor x 0 (233MHz, 2.3°C)" local eth_info = luci.sys.exec("ethinfo") diff --git a/lede/package/lean/default-settings/Makefile b/lede/package/lean/default-settings/Makefile index 5a411dc8b3..9f4d13a023 100644 --- a/lede/package/lean/default-settings/Makefile +++ b/lede/package/lean/default-settings/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=default-settings PKG_VERSION:=3 -PKG_RELEASE:=12 +PKG_RELEASE:=13 PKG_LICENSE:=GPLv3 PKG_LICENSE_FILES:=LICENSE diff --git a/lede/package/lean/default-settings/files/zzz-default-settings b/lede/package/lean/default-settings/files/zzz-default-settings index cb44bf041c..61b4c5e2c9 100755 --- a/lede/package/lean/default-settings/files/zzz-default-settings +++ b/lede/package/lean/default-settings/files/zzz-default-settings @@ -51,7 +51,7 @@ sed -i '/option disabled/d' /etc/config/wireless sed -i '/set wireless.radio${devidx}.disabled/d' /lib/wifi/mac80211.sh sed -i '/DISTRIB_REVISION/d' /etc/openwrt_release -echo "DISTRIB_REVISION='R24.5.1'" >> /etc/openwrt_release +echo "DISTRIB_REVISION='R24.6.6'" >> /etc/openwrt_release sed -i '/DISTRIB_DESCRIPTION/d' /etc/openwrt_release echo "DISTRIB_DESCRIPTION='OpenWrt '" >> /etc/openwrt_release diff --git a/lede/package/qca/nss-firmware/Makefile b/lede/package/qca/nss-firmware/Makefile new file mode 100644 index 0000000000..47b62283aa --- /dev/null +++ b/lede/package/qca/nss-firmware/Makefile @@ -0,0 +1,75 @@ +# +# Copyright (C) 2021 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:=nss-firmware +PKG_SOURCE_DATE:=2022-07-14 +PKG_SOURCE_VERSION:=ade6bff594377c9d9c79b45e39bf104303d919bc +PKG_MIRROR_HASH:=99ca44dd0733cff569308550c6c74febb0e7a03093b14df092d0f53362189647 +PKG_RELEASE:=$(AUTORELEASE) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/quic/qca-sdk-nss-fw.git + +PKG_LICENSE_FILES:=LICENSE.md + +PKG_MAINTAINER:=Robert Marko + +include $(INCLUDE_DIR)/package.mk + +RSTRIP:=: +STRIP:=: + +VERSION_PATH=$(PKG_BUILD_DIR)/QCA_Networking_2022.SPF_12.0.0/ED1 + +define Package/nss-firmware-default + SECTION:=firmware + CATEGORY:=Firmware + URL:=$(PKG_SOURCE_URL) + DEPENDS:=@(TARGET_ipq807x||TARGET_ipq60xx||TARGET_qualcommax) +endef + +define Package/nss-firmware-ipq6018 +$(Package/nss-firmware-default) + TITLE:=NSS firmware for IPQ6018 devices + NSS_ARCHIVE:=$(VERSION_PATH)/IPQ6018.ATH.12.0.0/BIN-NSS.FW.12.1-022-CP.R.tar.bz2 +endef + +define Package/nss-firmware-ipq8074 +$(Package/nss-firmware-default) + TITLE:=NSS firmware for IPQ8074 devices + NSS_ARCHIVE:=$(VERSION_PATH)/IPQ8074.ATH.12.0.0/BIN-NSS.FW.12.0.r1-002-HK.R.tar.bz2 +endef + +define Build/Compile + +endef + +define Package/nss-firmware-ipq6018/install + mkdir -p $(PKG_BUILD_DIR)/IPQ6018 + $(TAR) -C $(PKG_BUILD_DIR)/IPQ6018 -xf $(NSS_ARCHIVE) --strip-components=1 + $(INSTALL_DIR) $(1)/lib/firmware/ + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/IPQ6018/retail_router0.bin \ + $(1)/lib/firmware/qca-nss0-retail.bin +endef + +define Package/nss-firmware-ipq8074/install + mkdir -p $(PKG_BUILD_DIR)/IPQ8074 + $(TAR) -C $(PKG_BUILD_DIR)/IPQ8074 -xf $(NSS_ARCHIVE) --strip-components=1 + $(INSTALL_DIR) $(1)/lib/firmware/ + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/IPQ8074/retail_router0.bin \ + $(1)/lib/firmware/qca-nss0-retail.bin + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/IPQ8074/retail_router1.bin \ + $(1)/lib/firmware/qca-nss1-retail.bin +endef + +$(eval $(call BuildPackage,nss-firmware-ipq6018)) +$(eval $(call BuildPackage,nss-firmware-ipq8074)) diff --git a/lede/package/qca/qca-mcs/Makefile b/lede/package/qca/qca-mcs/Makefile new file mode 100644 index 0000000000..a0a3eef04d --- /dev/null +++ b/lede/package/qca/qca-mcs/Makefile @@ -0,0 +1,67 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=qca-mcs +PKG_RELEASE:=1 + +PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/qca-mcs.git +PKG_SOURCE_DATE:=2023-04-21 +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=8797823e392ac3d9098c090964afd46805a0eb2b +PKG_MIRROR_HASH:=f0fa76af4545842ebf8b4f0743e1079e190dfa5f3f0d464c063063521d3d30df + +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/qca-mcs + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Support + URL:=http://www.qca.qualcomm.com + MAINTAINER:=Qualcomm Atheros, Inc. + TITLE:=QCA Multicast Snooping Support + DEPENDS:=+@KERNEL_IPV6_MROUTE +@KERNEL_IP_MROUTE + KCONFIG:=CONFIG_NETFILTER=y \ + CONFIG_BRIDGE_NETFILTER=y + FILES:=$(PKG_BUILD_DIR)/qca-mcs.ko + AUTOLOAD:=$(call AutoLoad,41,qca-mcs) +endef + +define KernelPackage/qca-mcs/Description + This package installs the IGMP/MLD Snooping Module +endef + +QCA_MC_SNOOPING_HEADERS= \ + $(PKG_BUILD_DIR)/mc_api.h \ + $(PKG_BUILD_DIR)/mc_ecm.h \ + +define Build/InstallDev + mkdir -p $(1)/usr/include/qca-mcs + $(foreach header_file,$(QCA_MC_SNOOPING_HEADERS), $(CP) $(header_file) $(1)/usr/include/qca-mcs;) + $(foreach header_file,$(QCA_MC_SNOOPING_HEADERS), $(CP) $(header_file) $(1)/usr/include/;) +endef + +EXTRA_CFLAGS+=-Wno-implicit-fallthrough + +QCA_MC_SNOOPING_MAKE_OPTS:= \ + $(KERNEL_MAKE_FLAGS) \ + CONFIG_SUPPORT_MLD=y \ + MDIR=$(PKG_BUILD_DIR) \ + KBUILDPATH=$(LINUX_DIR) \ + KERNELPATH=$(LINUX_SRC_DIR) \ + KERNELRELEASE=$(LINUX_RELEASE) + +define Build/Compile + +$(MAKE) -C $(LINUX_DIR) \ + $(KERNEL_MAKE_FLAGS) \ + $(PKG_JOBS) \ + KBUILDPATH=$(LINUX_DIR) \ + $(PKG_MAKE_FLAGS) \ + M=$(PKG_BUILD_DIR) \ + EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ + $(strip $(QCA_MC_SNOOPING_MAKE_OPTS)) \ + modules +endef + +$(eval $(call KernelPackage,qca-mcs)) diff --git a/lede/package/qca/qca-mcs/patches/0001-kernel-5.10-compat.patch b/lede/package/qca/qca-mcs/patches/0001-kernel-5.10-compat.patch new file mode 100644 index 0000000000..958a7a3377 --- /dev/null +++ b/lede/package/qca/qca-mcs/patches/0001-kernel-5.10-compat.patch @@ -0,0 +1,40 @@ +--- a/mc_osdep.h ++++ b/mc_osdep.h +@@ -189,7 +189,7 @@ static inline struct net_bridge_port *mc + + dst = os_br_fdb_get((struct net_bridge *)br, eth_hdr(*skb)->h_dest); + +- if (dst && !dst->is_local) ++ if (dst && !test_bit(BR_FDB_LOCAL, &dst->flags)) + return dst->dst; + + return NULL; +--- a/mc_snooping.c ++++ b/mc_snooping.c +@@ -3453,6 +3453,18 @@ static int mc_proc_snooper_open(struct i + return single_open(file, mc_proc_snooper_show, NULL); + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) ++#define HAVE_PROC_OPS ++#endif ++ ++#ifdef HAVE_PROC_OPS ++static const struct proc_ops mc_proc_snooper_fops = { ++ .proc_open = mc_proc_snooper_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, ++}; ++#else + static const struct file_operations mc_proc_snooper_fops = { + .owner = THIS_MODULE, + .open = mc_proc_snooper_open, +@@ -3460,6 +3472,7 @@ static const struct file_operations mc_p + .llseek = seq_lseek, + .release = single_release, + }; ++#endif + + /* mc_proc_create_snooper_entry + * create proc entry for information show diff --git a/lede/package/qca/qca-nss-cfi/Makefile b/lede/package/qca/qca-nss-cfi/Makefile new file mode 100644 index 0000000000..27e4f38080 --- /dev/null +++ b/lede/package/qca/qca-nss-cfi/Makefile @@ -0,0 +1,87 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=qca-nss-cfi +PKG_RELEASE:=1 + +PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/nss-cfi.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_DATE:=2022-12-15 +PKG_SOURCE_VERSION:=5cd07ce299ee3ce62dbe4f6783ad36361e57583b +PKG_MIRROR_HASH:=e449eee24fccc09b1cf0f1367bb54cedadcc46a30423934744e78272443197e7 + +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/package.mk + +ifneq (, $(findstring $(CONFIG_TARGET_SUBTARGET), "ipq807x" "ipq60xx")) +#4.4/5.4 + ipq807x/ipq60xx/ipq50xx + CFI_OCF_DIR:=ocf/v2.0 + CFI_CRYPTOAPI_DIR:=cryptoapi/v2.0 +else +#4.4 Kernel + ipq806x + CFI_CRYPTOAPI_DIR:=cryptoapi/v1.1 + CFI_OCF_DIR:=ocf/v1.0 + CFI_IPSEC_DIR:=ipsec/v1.0 +endif + +define KernelPackage/qca-nss-cfi-cryptoapi + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Cryptographic API modules + DEPENDS:=@TARGET_qualcommax +kmod-qca-nss-crypto +kmod-crypto-authenc + TITLE:=Kernel driver for NSS cfi + FILES:=$(PKG_BUILD_DIR)/$(CFI_CRYPTOAPI_DIR)/qca-nss-cfi-cryptoapi.ko + AUTOLOAD:=$(call AutoLoad,59,qca-nss-cfi-cryptoapi) +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/qca-nss-cfi + $(CP) $(PKG_BUILD_DIR)/$(CFI_CRYPTOAPI_DIR)/../exports/* $(1)/usr/include/qca-nss-cfi + $(CP) $(PKG_BUILD_DIR)/include/* $(1)/usr/include/qca-nss-cfi +endef + +define KernelPackage/qca-nss-cfi/Description +This package contains a NSS cfi driver for QCA chipset +endef + +EXTRA_CFLAGS+= \ + -DCONFIG_NSS_DEBUG_LEVEL=4 \ + -I$(LINUX_DIR)/crypto/ocf \ + -I$(STAGING_DIR)/usr/include/qca-nss-crypto \ + -I$(STAGING_DIR)/usr/include/crypto \ + -I$(STAGING_DIR)/usr/include/qca-nss-drv + +ifneq (, $(findstring $(CONFIG_TARGET_SUBTARGET), "ipq807x")) +EXTRA_CFLAGS+= -I$(STAGING_DIR)/usr/include/qca-nss-clients +endif + +# Build individual packages if selected +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-cfi-cryptoapi),) +MAKE_OPTS+= \ + cryptoapi=y \ + NSS_CRYPTOAPI_ABLK=n \ + NSS_CRYPTOAPI_SKCIPHER=y +endif + +ifeq ($(CONFIG_TARGET_BOARD), "qualcommax") + SOC:=$(CONFIG_TARGET_SUBTARGET) +endif + +define Build/Compile + +$(MAKE) -C "$(LINUX_DIR)" $(strip $(MAKE_OPTS)) \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + ARCH="$(LINUX_KARCH)" \ + M="$(PKG_BUILD_DIR)" \ + EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ + CC="$(TARGET_CC)" \ + CFI_CRYPTOAPI_DIR=$(CFI_CRYPTOAPI_DIR) \ + CFI_OCF_DIR=$(CFI_OCF_DIR) \ + CFI_IPSEC_DIR=$(CFI_IPSEC_DIR) \ + SoC=$(SOC) \ + $(KERNEL_MAKE_FLAGS) \ + $(PKG_JOBS) \ + modules +endef + +$(eval $(call KernelPackage,qca-nss-cfi-cryptoapi)) diff --git a/lede/package/qca/qca-nss-cfi/patches/0001-cryptoapi-v2.0-fix-SHA1-header-include.patch b/lede/package/qca/qca-nss-cfi/patches/0001-cryptoapi-v2.0-fix-SHA1-header-include.patch new file mode 100644 index 0000000000..12df90fdcf --- /dev/null +++ b/lede/package/qca/qca-nss-cfi/patches/0001-cryptoapi-v2.0-fix-SHA1-header-include.patch @@ -0,0 +1,62 @@ +From 1569ac3b6bbcae9c3f4898e0d34aec8f88297ee6 Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Sun, 22 Jan 2023 21:45:23 +0100 +Subject: [PATCH 1/5] cryptoapi: v2.0: fix SHA1 header include + +SHA1 header has been merged to the generic SHA one, +and with that the cryptohash.h was dropped. + +So, fix include in kernels 5.8 and newer. + +Signed-off-by: Robert Marko +--- + cryptoapi/v2.0/nss_cryptoapi.c | 5 +++++ + cryptoapi/v2.0/nss_cryptoapi_aead.c | 5 +++++ + cryptoapi/v2.0/nss_cryptoapi_ahash.c | 5 +++++ + 3 files changed, 15 insertions(+) + +--- a/cryptoapi/v2.0/nss_cryptoapi.c ++++ b/cryptoapi/v2.0/nss_cryptoapi.c +@@ -39,7 +39,12 @@ + + #include + #include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) + #include ++#else ++#include ++#include ++#endif + #include + #include + #include +--- a/cryptoapi/v2.0/nss_cryptoapi_aead.c ++++ b/cryptoapi/v2.0/nss_cryptoapi_aead.c +@@ -39,7 +39,12 @@ + + #include + #include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) + #include ++#else ++#include ++#include ++#endif + #include + #include + #include +--- a/cryptoapi/v2.0/nss_cryptoapi_ahash.c ++++ b/cryptoapi/v2.0/nss_cryptoapi_ahash.c +@@ -38,7 +38,12 @@ + + #include + #include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) + #include ++#else ++#include ++#include ++#endif + #include + #include + #include diff --git a/lede/package/qca/qca-nss-cfi/patches/0002-cryptoapi-v2.0-make-ablkcipher-optional.patch b/lede/package/qca/qca-nss-cfi/patches/0002-cryptoapi-v2.0-make-ablkcipher-optional.patch new file mode 100644 index 0000000000..e9702eb33a --- /dev/null +++ b/lede/package/qca/qca-nss-cfi/patches/0002-cryptoapi-v2.0-make-ablkcipher-optional.patch @@ -0,0 +1,116 @@ +From 26cca5006bddb0da57398452616e07ee7b11edb1 Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Sun, 22 Jan 2023 22:01:34 +0100 +Subject: [PATCH 2/5] cryptoapi: v2.0: make ablkcipher optional + +albkcipher has been removed from the kernel in v5.5, so until it has been +converted to skcipher, lets make it optional to at least have hashes +working. + +Signed-off-by: Robert Marko +--- + cryptoapi/v2.0/Makefile | 3 +++ + cryptoapi/v2.0/nss_cryptoapi.c | 10 ++++++++++ + cryptoapi/v2.0/nss_cryptoapi_private.h | 2 ++ + 3 files changed, 15 insertions(+) + +--- a/cryptoapi/v2.0/Makefile ++++ b/cryptoapi/v2.0/Makefile +@@ -5,7 +5,10 @@ NSS_CRYPTOAPI_MOD_NAME=qca-nss-cfi-crypt + obj-m += $(NSS_CRYPTOAPI_MOD_NAME).o + $(NSS_CRYPTOAPI_MOD_NAME)-objs = nss_cryptoapi.o + $(NSS_CRYPTOAPI_MOD_NAME)-objs += nss_cryptoapi_aead.o ++ifneq "$(NSS_CRYPTOAPI_ABLK)" "n" + $(NSS_CRYPTOAPI_MOD_NAME)-objs += nss_cryptoapi_ablk.o ++ccflags-y += -DNSS_CRYPTOAPI_ABLK ++endif + $(NSS_CRYPTOAPI_MOD_NAME)-objs += nss_cryptoapi_ahash.o + + obj ?= . +--- a/cryptoapi/v2.0/nss_cryptoapi.c ++++ b/cryptoapi/v2.0/nss_cryptoapi.c +@@ -1367,6 +1367,7 @@ struct aead_alg cryptoapi_aead_algs[] = + /* + * ABLK cipher algorithms + */ ++#if defined(NSS_CRYPTOAPI_ABLK) + static struct crypto_alg cryptoapi_ablkcipher_algs[] = { + { + .cra_name = "cbc(aes)", +@@ -1466,6 +1467,7 @@ static struct crypto_alg cryptoapi_ablkc + }, + } + }; ++#endif + + /* + * AHASH algorithms +@@ -2189,7 +2191,9 @@ void nss_cryptoapi_add_ctx2debugfs(struc + */ + void nss_cryptoapi_attach_user(void *app_data, struct nss_crypto_user *user) + { ++#if defined(NSS_CRYPTOAPI_ABLK) + struct crypto_alg *ablk = cryptoapi_ablkcipher_algs; ++#endif + struct aead_alg *aead = cryptoapi_aead_algs; + struct ahash_alg *ahash = cryptoapi_ahash_algs; + struct nss_cryptoapi *sc = app_data; +@@ -2212,6 +2216,7 @@ void nss_cryptoapi_attach_user(void *app + g_cryptoapi.user = user; + } + ++#if defined(NSS_CRYPTOAPI_ABLK) + for (i = 0; enable_ablk && (i < ARRAY_SIZE(cryptoapi_ablkcipher_algs)); i++, ablk++) { + info = nss_cryptoapi_cra_name_lookup(ablk->cra_name); + if(!info || !nss_crypto_algo_is_supp(info->algo)) +@@ -2222,6 +2227,7 @@ void nss_cryptoapi_attach_user(void *app + ablk->cra_flags = 0; + } + } ++#endif + + for (i = 0; enable_aead && (i < ARRAY_SIZE(cryptoapi_aead_algs)); i++, aead++) { + info = nss_cryptoapi_cra_name_lookup(aead->base.cra_name); +@@ -2257,7 +2263,9 @@ void nss_cryptoapi_attach_user(void *app + */ + void nss_cryptoapi_detach_user(void *app_data, struct nss_crypto_user *user) + { ++#if defined(NSS_CRYPTOAPI_ABLK) + struct crypto_alg *ablk = cryptoapi_ablkcipher_algs; ++#endif + struct aead_alg *aead = cryptoapi_aead_algs; + struct ahash_alg *ahash = cryptoapi_ahash_algs; + struct nss_cryptoapi *sc = app_data; +@@ -2270,6 +2278,7 @@ void nss_cryptoapi_detach_user(void *app + */ + atomic_set(&g_cryptoapi.registered, 0); + ++#if defined(NSS_CRYPTOAPI_ABLK) + for (i = 0; enable_ablk && (i < ARRAY_SIZE(cryptoapi_ablkcipher_algs)); i++, ablk++) { + if (!ablk->cra_flags) + continue; +@@ -2277,6 +2286,7 @@ void nss_cryptoapi_detach_user(void *app + crypto_unregister_alg(ablk); + nss_cfi_info("%px: ABLK unregister succeeded, algo: %s\n", sc, ablk->cra_name); + } ++#endif + + for (i = 0; enable_aead && (i < ARRAY_SIZE(cryptoapi_aead_algs)); i++, aead++) { + if (!aead->base.cra_flags) +--- a/cryptoapi/v2.0/nss_cryptoapi_private.h ++++ b/cryptoapi/v2.0/nss_cryptoapi_private.h +@@ -250,12 +250,14 @@ extern void nss_cryptoapi_aead_tx_proc(s + /* + * ABLKCIPHER + */ ++#if defined(NSS_CRYPTOAPI_ABLK) + extern int nss_cryptoapi_ablkcipher_init(struct crypto_tfm *tfm); + extern void nss_cryptoapi_ablkcipher_exit(struct crypto_tfm *tfm); + extern int nss_cryptoapi_ablk_setkey(struct crypto_ablkcipher *cipher, const u8 *key, unsigned int len); + extern int nss_cryptoapi_ablk_encrypt(struct ablkcipher_request *req); + extern int nss_cryptoapi_ablk_decrypt(struct ablkcipher_request *req); + extern void nss_cryptoapi_copy_iv(struct nss_cryptoapi_ctx *ctx, struct scatterlist *sg, uint8_t *iv, uint8_t iv_len); ++#endif + + /* + * AHASH diff --git a/lede/package/qca/qca-nss-cfi/patches/0003-cryptoapi-v2.0-remove-setting-crypto_ahash_type-for-.patch b/lede/package/qca/qca-nss-cfi/patches/0003-cryptoapi-v2.0-remove-setting-crypto_ahash_type-for-.patch new file mode 100644 index 0000000000..ad11b8b357 --- /dev/null +++ b/lede/package/qca/qca-nss-cfi/patches/0003-cryptoapi-v2.0-remove-setting-crypto_ahash_type-for-.patch @@ -0,0 +1,137 @@ +From 797b5166783cda0886038ffb22f5386b9363a961 Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Sun, 22 Jan 2023 22:08:27 +0100 +Subject: [PATCH 3/5] cryptoapi: v2.0: remove setting crypto_ahash_type for + newer kernels + +Upstream has stopped exporting crypto_ahash_type and removed setting it +on ahash algos since v4.19 as its easily identifiable by the struct type +and its being set in the core directly, so lets do the same. + +Signed-off-by: Robert Marko +--- + cryptoapi/v2.0/nss_cryptoapi.c | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +--- a/cryptoapi/v2.0/nss_cryptoapi.c ++++ b/cryptoapi/v2.0/nss_cryptoapi.c +@@ -1495,7 +1495,9 @@ static struct ahash_alg cryptoapi_ahash_ + .cra_blocksize = MD5_HMAC_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), + .cra_alignmask = 0, ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) + .cra_type = &crypto_ahash_type, ++#endif + .cra_module = THIS_MODULE, + .cra_init = nss_cryptoapi_ahash_cra_init, + .cra_exit = nss_cryptoapi_ahash_cra_exit, +@@ -1521,7 +1523,9 @@ static struct ahash_alg cryptoapi_ahash_ + .cra_blocksize = SHA1_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), + .cra_alignmask = 0, ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) + .cra_type = &crypto_ahash_type, ++#endif + .cra_module = THIS_MODULE, + .cra_init = nss_cryptoapi_ahash_cra_init, + .cra_exit = nss_cryptoapi_ahash_cra_exit, +@@ -1547,7 +1551,9 @@ static struct ahash_alg cryptoapi_ahash_ + .cra_blocksize = SHA224_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), + .cra_alignmask = 0, ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) + .cra_type = &crypto_ahash_type, ++#endif + .cra_module = THIS_MODULE, + .cra_init = nss_cryptoapi_ahash_cra_init, + .cra_exit = nss_cryptoapi_ahash_cra_exit, +@@ -1573,7 +1579,9 @@ static struct ahash_alg cryptoapi_ahash_ + .cra_blocksize = SHA256_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), + .cra_alignmask = 0, ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) + .cra_type = &crypto_ahash_type, ++#endif + .cra_module = THIS_MODULE, + .cra_init = nss_cryptoapi_ahash_cra_init, + .cra_exit = nss_cryptoapi_ahash_cra_exit, +@@ -1599,7 +1607,9 @@ static struct ahash_alg cryptoapi_ahash_ + .cra_blocksize = SHA384_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), + .cra_alignmask = 0, ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) + .cra_type = &crypto_ahash_type, ++#endif + .cra_module = THIS_MODULE, + .cra_init = nss_cryptoapi_ahash_cra_init, + .cra_exit = nss_cryptoapi_ahash_cra_exit, +@@ -1625,7 +1635,9 @@ static struct ahash_alg cryptoapi_ahash_ + .cra_blocksize = SHA512_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), + .cra_alignmask = 0, ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) + .cra_type = &crypto_ahash_type, ++#endif + .cra_module = THIS_MODULE, + .cra_init = nss_cryptoapi_ahash_cra_init, + .cra_exit = nss_cryptoapi_ahash_cra_exit, +@@ -1655,7 +1667,9 @@ static struct ahash_alg cryptoapi_ahash_ + .cra_blocksize = MD5_HMAC_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), + .cra_alignmask = 0, ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) + .cra_type = &crypto_ahash_type, ++#endif + .cra_module = THIS_MODULE, + .cra_init = nss_cryptoapi_ahash_cra_init, + .cra_exit = nss_cryptoapi_ahash_cra_exit, +@@ -1681,7 +1695,9 @@ static struct ahash_alg cryptoapi_ahash_ + .cra_blocksize = SHA1_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), + .cra_alignmask = 0, ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) + .cra_type = &crypto_ahash_type, ++#endif + .cra_module = THIS_MODULE, + .cra_init = nss_cryptoapi_ahash_cra_init, + .cra_exit = nss_cryptoapi_ahash_cra_exit, +@@ -1707,7 +1723,9 @@ static struct ahash_alg cryptoapi_ahash_ + .cra_blocksize = SHA224_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), + .cra_alignmask = 0, ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) + .cra_type = &crypto_ahash_type, ++#endif + .cra_module = THIS_MODULE, + .cra_init = nss_cryptoapi_ahash_cra_init, + .cra_exit = nss_cryptoapi_ahash_cra_exit, +@@ -1733,7 +1751,9 @@ static struct ahash_alg cryptoapi_ahash_ + .cra_blocksize = SHA256_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), + .cra_alignmask = 0, ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) + .cra_type = &crypto_ahash_type, ++#endif + .cra_module = THIS_MODULE, + .cra_init = nss_cryptoapi_ahash_cra_init, + .cra_exit = nss_cryptoapi_ahash_cra_exit, +@@ -1759,7 +1779,9 @@ static struct ahash_alg cryptoapi_ahash_ + .cra_blocksize = SHA384_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), + .cra_alignmask = 0, ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) + .cra_type = &crypto_ahash_type, ++#endif + .cra_module = THIS_MODULE, + .cra_init = nss_cryptoapi_ahash_cra_init, + .cra_exit = nss_cryptoapi_ahash_cra_exit, +@@ -1785,7 +1807,9 @@ static struct ahash_alg cryptoapi_ahash_ + .cra_blocksize = SHA512_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), + .cra_alignmask = 0, ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) + .cra_type = &crypto_ahash_type, ++#endif + .cra_module = THIS_MODULE, + .cra_init = nss_cryptoapi_ahash_cra_init, + .cra_exit = nss_cryptoapi_ahash_cra_exit, diff --git a/lede/package/qca/qca-nss-cfi/patches/0004-cryptoapi-v2.0-aead-add-downstream-crypto_tfm_alg_fl.patch b/lede/package/qca/qca-nss-cfi/patches/0004-cryptoapi-v2.0-aead-add-downstream-crypto_tfm_alg_fl.patch new file mode 100644 index 0000000000..a872321fb3 --- /dev/null +++ b/lede/package/qca/qca-nss-cfi/patches/0004-cryptoapi-v2.0-aead-add-downstream-crypto_tfm_alg_fl.patch @@ -0,0 +1,28 @@ +From 8db77add1a794bdee8eef0a351e40bf1cdf6dfa9 Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Sun, 22 Jan 2023 22:09:51 +0100 +Subject: [PATCH 4/5] cryptoapi: v2.0: aead: add downstream + crypto_tfm_alg_flags + +crypto_tfm_alg_flags newer made it upstream, but as a temporary stopgap +until a better solution is figured out lets add it. + +Signed-off-by: Robert Marko +--- + cryptoapi/v2.0/nss_cryptoapi_aead.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/cryptoapi/v2.0/nss_cryptoapi_aead.c ++++ b/cryptoapi/v2.0/nss_cryptoapi_aead.c +@@ -61,6 +61,11 @@ + #include + #include "nss_cryptoapi_private.h" + ++static inline u32 crypto_tfm_alg_flags(struct crypto_tfm *tfm) ++{ ++ return tfm->__crt_alg->cra_flags & ~CRYPTO_ALG_TYPE_MASK; ++} ++ + /* + * nss_cryptoapi_aead_ctx2session() + * Cryptoapi function to get the session ID for an AEAD diff --git a/lede/package/qca/qca-nss-cfi/patches/0005-cryptoapi-v2.0-remove-dropped-flags.patch b/lede/package/qca/qca-nss-cfi/patches/0005-cryptoapi-v2.0-remove-dropped-flags.patch new file mode 100644 index 0000000000..645633abc5 --- /dev/null +++ b/lede/package/qca/qca-nss-cfi/patches/0005-cryptoapi-v2.0-remove-dropped-flags.patch @@ -0,0 +1,97 @@ +From 62bbb188e1a72d28916e1eca31f4cb9fbbf51cd1 Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Sun, 22 Jan 2023 22:11:06 +0100 +Subject: [PATCH 5/5] cryptoapi: v2.0: remove dropped flags + +Upstream has dropped these flags as there was no use for them, so lets do +the same. + +Signed-off-by: Robert Marko +--- + cryptoapi/v2.0/nss_cryptoapi_aead.c | 6 ------ + cryptoapi/v2.0/nss_cryptoapi_ahash.c | 4 ---- + 2 files changed, 10 deletions(-) + +--- a/cryptoapi/v2.0/nss_cryptoapi_aead.c ++++ b/cryptoapi/v2.0/nss_cryptoapi_aead.c +@@ -207,7 +207,6 @@ int nss_cryptoapi_aead_setkey_noauth(str + ctx->info = nss_cryptoapi_cra_name2info(crypto_tfm_alg_name(tfm), keylen, 0); + if (!ctx->info) { + nss_cfi_err("%px: Unable to find algorithm with keylen\n", ctx); +- crypto_aead_set_flags(aead, CRYPTO_TFM_RES_BAD_KEY_LEN); + return -ENOENT; + } + +@@ -239,7 +238,6 @@ int nss_cryptoapi_aead_setkey_noauth(str + status = nss_crypto_session_alloc(ctx->user, &data, &ctx->sid); + if (status < 0) { + nss_cfi_err("%px: Unable to allocate crypto session(%d)\n", ctx, status); +- crypto_aead_set_flags(aead, CRYPTO_TFM_RES_BAD_FLAGS); + return status; + } + +@@ -271,14 +269,12 @@ int nss_cryptoapi_aead_setkey(struct cry + */ + if (crypto_authenc_extractkeys(&keys, key, keylen) != 0) { + nss_cfi_err("%px: Unable to extract keys\n", ctx); +- crypto_aead_set_flags(aead, CRYPTO_TFM_RES_BAD_KEY_LEN); + return -EIO; + } + + ctx->info = nss_cryptoapi_cra_name2info(crypto_tfm_alg_name(tfm), keys.enckeylen, crypto_aead_maxauthsize(aead)); + if (!ctx->info) { + nss_cfi_err("%px: Unable to find algorithm with keylen\n", ctx); +- crypto_aead_set_flags(aead, CRYPTO_TFM_RES_BAD_KEY_LEN); + return -ENOENT; + } + +@@ -299,7 +295,6 @@ int nss_cryptoapi_aead_setkey(struct cry + */ + if (keys.authkeylen > ctx->info->auth_blocksize) { + nss_cfi_err("%px: Auth keylen(%d) exceeds supported\n", ctx, keys.authkeylen); +- crypto_aead_set_flags(aead, CRYPTO_TFM_RES_BAD_KEY_LEN); + return -EINVAL; + } + +@@ -342,7 +337,6 @@ int nss_cryptoapi_aead_setkey(struct cry + status = nss_crypto_session_alloc(ctx->user, &data, &ctx->sid); + if (status < 0) { + nss_cfi_err("%px: Unable to allocate crypto session(%d)\n", ctx, status); +- crypto_aead_set_flags(aead, CRYPTO_TFM_RES_BAD_FLAGS); + return status; + } + +--- a/cryptoapi/v2.0/nss_cryptoapi_ahash.c ++++ b/cryptoapi/v2.0/nss_cryptoapi_ahash.c +@@ -192,7 +192,6 @@ int nss_cryptoapi_ahash_setkey(struct cr + + ctx->info = nss_cryptoapi_cra_name2info(crypto_tfm_alg_name(tfm), 0, crypto_ahash_digestsize(ahash)); + if (!ctx->info) { +- crypto_ahash_set_flags(ahash, CRYPTO_TFM_RES_BAD_KEY_LEN); + return -EINVAL; + } + +@@ -215,7 +214,6 @@ int nss_cryptoapi_ahash_setkey(struct cr + status = nss_crypto_session_alloc(ctx->user, &data, &ctx->sid); + if (status < 0) { + nss_cfi_warn("%px: Unable to allocate crypto session(%d)\n", ctx, status); +- crypto_ahash_set_flags(ahash, CRYPTO_TFM_RES_BAD_FLAGS); + return status; + } + +@@ -299,7 +297,6 @@ int nss_cryptoapi_ahash_init(struct ahas + */ + ctx->info = nss_cryptoapi_cra_name2info(crypto_tfm_alg_name(tfm), 0, 0); + if (!ctx->info) { +- crypto_ahash_set_flags(ahash, CRYPTO_TFM_RES_BAD_KEY_LEN); + return -EINVAL; + } + +@@ -314,7 +311,6 @@ int nss_cryptoapi_ahash_init(struct ahas + status = nss_crypto_session_alloc(ctx->user, &data, &ctx->sid); + if (status < 0) { + nss_cfi_err("%px: Unable to allocate crypto session(%d)\n", ctx, status); +- crypto_ahash_set_flags(ahash, CRYPTO_TFM_RES_BAD_FLAGS); + return status; + } + diff --git a/lede/package/qca/qca-nss-cfi/patches/0006-cryptoapi-v2.0-convert-to-skcipher.patch b/lede/package/qca/qca-nss-cfi/patches/0006-cryptoapi-v2.0-convert-to-skcipher.patch new file mode 100644 index 0000000000..f85e3d892c --- /dev/null +++ b/lede/package/qca/qca-nss-cfi/patches/0006-cryptoapi-v2.0-convert-to-skcipher.patch @@ -0,0 +1,1199 @@ +From 1b30927548c2498c76b815b87f604f9a1de40a48 Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Sun, 22 Jan 2023 23:31:09 +0100 +Subject: [PATCH] cryptoapi: v2.0: convert to skcipher + +Finally convert the driver from ablkcipher that was dropped in v5.5 to +skcipher. + +Signed-off-by: Robert Marko +--- + cryptoapi/v2.0/Makefile | 6 +- + cryptoapi/v2.0/nss_cryptoapi.c | 200 ++++++++---------- + cryptoapi/v2.0/nss_cryptoapi_private.h | 14 +- + ...ptoapi_ablk.c => nss_cryptoapi_skcipher.c} | 116 +++++----- + 4 files changed, 145 insertions(+), 191 deletions(-) + rename cryptoapi/v2.0/{nss_cryptoapi_ablk.c => nss_cryptoapi_skcipher.c} (74%) + +--- a/cryptoapi/v2.0/Makefile ++++ b/cryptoapi/v2.0/Makefile +@@ -5,9 +5,9 @@ NSS_CRYPTOAPI_MOD_NAME=qca-nss-cfi-crypt + obj-m += $(NSS_CRYPTOAPI_MOD_NAME).o + $(NSS_CRYPTOAPI_MOD_NAME)-objs = nss_cryptoapi.o + $(NSS_CRYPTOAPI_MOD_NAME)-objs += nss_cryptoapi_aead.o +-ifneq "$(NSS_CRYPTOAPI_ABLK)" "n" +-$(NSS_CRYPTOAPI_MOD_NAME)-objs += nss_cryptoapi_ablk.o +-ccflags-y += -DNSS_CRYPTOAPI_ABLK ++ifneq "$(NSS_CRYPTOAPI_SKCIPHER)" "n" ++$(NSS_CRYPTOAPI_MOD_NAME)-objs += nss_cryptoapi_skcipher.o ++ccflags-y += -DNSS_CRYPTOAPI_SKCIPHER + endif + $(NSS_CRYPTOAPI_MOD_NAME)-objs += nss_cryptoapi_ahash.o + +--- a/cryptoapi/v2.0/nss_cryptoapi.c ++++ b/cryptoapi/v2.0/nss_cryptoapi.c +@@ -1367,104 +1367,78 @@ struct aead_alg cryptoapi_aead_algs[] = + /* + * ABLK cipher algorithms + */ +-#if defined(NSS_CRYPTOAPI_ABLK) +-static struct crypto_alg cryptoapi_ablkcipher_algs[] = { ++#if defined(NSS_CRYPTOAPI_SKCIPHER) ++static struct skcipher_alg cryptoapi_skcipher_algs[] = { + { +- .cra_name = "cbc(aes)", +- .cra_driver_name = "nss-cbc-aes", +- .cra_priority = 10000, +- .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, +- .cra_blocksize = AES_BLOCK_SIZE, +- .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), +- .cra_alignmask = 0, +- .cra_type = &crypto_ablkcipher_type, +- .cra_module = THIS_MODULE, +- .cra_init = nss_cryptoapi_ablkcipher_init, +- .cra_exit = nss_cryptoapi_ablkcipher_exit, +- .cra_u = { +- .ablkcipher = { +- .ivsize = AES_BLOCK_SIZE, +- .min_keysize = AES_MIN_KEY_SIZE, +- .max_keysize = AES_MAX_KEY_SIZE, +- .setkey = nss_cryptoapi_ablk_setkey, +- .encrypt = nss_cryptoapi_ablk_encrypt, +- .decrypt = nss_cryptoapi_ablk_decrypt, +- }, +- }, +- }, +- { +- .cra_name = "rfc3686(ctr(aes))", +- .cra_driver_name = "nss-rfc3686-ctr-aes", +- .cra_priority = 30000, +- .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, +- .cra_blocksize = AES_BLOCK_SIZE, +- .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), +- .cra_alignmask = 0, +- .cra_type = &crypto_ablkcipher_type, +- .cra_module = THIS_MODULE, +- .cra_init = nss_cryptoapi_ablkcipher_init, +- .cra_exit = nss_cryptoapi_ablkcipher_exit, +- .cra_u = { +- .ablkcipher = { +- .ivsize = CTR_RFC3686_IV_SIZE, +-/* +- * geniv deprecated from kernel version 5.0 and above +- */ +-#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) +- .geniv = "seqiv", +-#endif +- .min_keysize = AES_MIN_KEY_SIZE + CTR_RFC3686_NONCE_SIZE, +- .max_keysize = AES_MAX_KEY_SIZE + CTR_RFC3686_NONCE_SIZE, +- .setkey = nss_cryptoapi_ablk_setkey, +- .encrypt = nss_cryptoapi_ablk_encrypt, +- .decrypt = nss_cryptoapi_ablk_decrypt, +- }, +- }, +- }, +- { +- .cra_name = "ecb(aes)", +- .cra_driver_name = "nss-ecb-aes", +- .cra_priority = 10000, +- .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, +- .cra_blocksize = AES_BLOCK_SIZE, +- .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), +- .cra_alignmask = 0, +- .cra_type = &crypto_ablkcipher_type, +- .cra_module = THIS_MODULE, +- .cra_init = nss_cryptoapi_ablkcipher_init, +- .cra_exit = nss_cryptoapi_ablkcipher_exit, +- .cra_u = { +- .ablkcipher = { +- .min_keysize = AES_MIN_KEY_SIZE, +- .max_keysize = AES_MAX_KEY_SIZE, +- .setkey = nss_cryptoapi_ablk_setkey, +- .encrypt = nss_cryptoapi_ablk_encrypt, +- .decrypt = nss_cryptoapi_ablk_decrypt, +- }, +- }, +- }, +- { +- .cra_name = "cbc(des3_ede)", +- .cra_driver_name = "nss-cbc-des-ede", +- .cra_priority = 10000, +- .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, +- .cra_blocksize = DES3_EDE_BLOCK_SIZE, +- .cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), +- .cra_alignmask = 0, +- .cra_type = &crypto_ablkcipher_type, +- .cra_module = THIS_MODULE, +- .cra_init = nss_cryptoapi_ablkcipher_init, +- .cra_exit = nss_cryptoapi_ablkcipher_exit, +- .cra_u = { +- .ablkcipher = { +- .ivsize = DES3_EDE_BLOCK_SIZE, +- .min_keysize = DES3_EDE_KEY_SIZE, +- .max_keysize = DES3_EDE_KEY_SIZE, +- .setkey = nss_cryptoapi_ablk_setkey, +- .encrypt = nss_cryptoapi_ablk_encrypt, +- .decrypt = nss_cryptoapi_ablk_decrypt, +- }, +- }, ++ .base.cra_name = "cbc(aes)", ++ .base.cra_driver_name = "nss-cbc-aes", ++ .base.cra_priority = 10000, ++ .base.cra_flags = CRYPTO_ALG_ASYNC, ++ .base.cra_blocksize = AES_BLOCK_SIZE, ++ .base.cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), ++ .base.cra_alignmask = 0, ++ .base.cra_module = THIS_MODULE, ++ .init = nss_cryptoapi_skcipher_init, ++ .exit = nss_cryptoapi_skcipher_exit, ++ .ivsize = AES_BLOCK_SIZE, ++ .min_keysize = AES_MIN_KEY_SIZE, ++ .max_keysize = AES_MAX_KEY_SIZE, ++ .setkey = nss_cryptoapi_skcipher_setkey, ++ .encrypt = nss_cryptoapi_skcipher_encrypt, ++ .decrypt = nss_cryptoapi_skcipher_decrypt, ++ }, ++ { ++ .base.cra_name = "rfc3686(ctr(aes))", ++ .base.cra_driver_name = "nss-rfc3686-ctr-aes", ++ .base.cra_priority = 30000, ++ .base.cra_flags = CRYPTO_ALG_ASYNC, ++ .base.cra_blocksize = AES_BLOCK_SIZE, ++ .base.cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), ++ .base.cra_alignmask = 0, ++ .base.cra_module = THIS_MODULE, ++ .init = nss_cryptoapi_skcipher_init, ++ .exit = nss_cryptoapi_skcipher_exit, ++ .ivsize = CTR_RFC3686_IV_SIZE, ++ .min_keysize = AES_MIN_KEY_SIZE + CTR_RFC3686_NONCE_SIZE, ++ .max_keysize = AES_MAX_KEY_SIZE + CTR_RFC3686_NONCE_SIZE, ++ .setkey = nss_cryptoapi_skcipher_setkey, ++ .encrypt = nss_cryptoapi_skcipher_encrypt, ++ .decrypt = nss_cryptoapi_skcipher_decrypt, ++ }, ++ { ++ .base.cra_name = "ecb(aes)", ++ .base.cra_driver_name = "nss-ecb-aes", ++ .base.cra_priority = 10000, ++ .base.cra_flags = CRYPTO_ALG_ASYNC, ++ .base.cra_blocksize = AES_BLOCK_SIZE, ++ .base.cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), ++ .base.cra_alignmask = 0, ++ .base.cra_module = THIS_MODULE, ++ .init = nss_cryptoapi_skcipher_init, ++ .exit = nss_cryptoapi_skcipher_exit, ++ .min_keysize = AES_MIN_KEY_SIZE, ++ .max_keysize = AES_MAX_KEY_SIZE, ++ .setkey = nss_cryptoapi_skcipher_setkey, ++ .encrypt = nss_cryptoapi_skcipher_encrypt, ++ .decrypt = nss_cryptoapi_skcipher_decrypt, ++ }, ++ { ++ .base.cra_name = "cbc(des3_ede)", ++ .base.cra_driver_name = "nss-cbc-des-ede", ++ .base.cra_priority = 10000, ++ .base.cra_flags = CRYPTO_ALG_ASYNC, ++ .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, ++ .base.cra_ctxsize = sizeof(struct nss_cryptoapi_ctx), ++ .base.cra_alignmask = 0, ++ .base.cra_module = THIS_MODULE, ++ .init = nss_cryptoapi_skcipher_init, ++ .exit = nss_cryptoapi_skcipher_exit, ++ .ivsize = DES3_EDE_BLOCK_SIZE, ++ .min_keysize = DES3_EDE_KEY_SIZE, ++ .max_keysize = DES3_EDE_KEY_SIZE, ++ .setkey = nss_cryptoapi_skcipher_setkey, ++ .encrypt = nss_cryptoapi_skcipher_encrypt, ++ .decrypt = nss_cryptoapi_skcipher_decrypt, + } + }; + #endif +@@ -2215,8 +2189,8 @@ void nss_cryptoapi_add_ctx2debugfs(struc + */ + void nss_cryptoapi_attach_user(void *app_data, struct nss_crypto_user *user) + { +-#if defined(NSS_CRYPTOAPI_ABLK) +- struct crypto_alg *ablk = cryptoapi_ablkcipher_algs; ++#if defined(NSS_CRYPTOAPI_SKCIPHER) ++ struct skcipher_alg *ablk = cryptoapi_skcipher_algs; + #endif + struct aead_alg *aead = cryptoapi_aead_algs; + struct ahash_alg *ahash = cryptoapi_ahash_algs; +@@ -2240,15 +2214,15 @@ void nss_cryptoapi_attach_user(void *app + g_cryptoapi.user = user; + } + +-#if defined(NSS_CRYPTOAPI_ABLK) +- for (i = 0; enable_ablk && (i < ARRAY_SIZE(cryptoapi_ablkcipher_algs)); i++, ablk++) { +- info = nss_cryptoapi_cra_name_lookup(ablk->cra_name); ++#if defined(NSS_CRYPTOAPI_SKCIPHER) ++ for (i = 0; enable_ablk && (i < ARRAY_SIZE(cryptoapi_skcipher_algs)); i++, ablk++) { ++ info = nss_cryptoapi_cra_name_lookup(ablk->base.cra_name); + if(!info || !nss_crypto_algo_is_supp(info->algo)) + continue; + +- if (crypto_register_alg(ablk)) { +- nss_cfi_err("%px: ABLK registration failed(%s)\n", sc, ablk->cra_name); +- ablk->cra_flags = 0; ++ if (crypto_register_skcipher(ablk)) { ++ nss_cfi_err("%px: skcipher registration failed(%s)\n", sc, ablk->base.cra_name); ++ ablk->base.cra_flags = 0; + } + } + #endif +@@ -2287,8 +2261,8 @@ void nss_cryptoapi_attach_user(void *app + */ + void nss_cryptoapi_detach_user(void *app_data, struct nss_crypto_user *user) + { +-#if defined(NSS_CRYPTOAPI_ABLK) +- struct crypto_alg *ablk = cryptoapi_ablkcipher_algs; ++#if defined(NSS_CRYPTOAPI_SKCIPHER) ++ struct skcipher_alg *ablk = cryptoapi_skcipher_algs; + #endif + struct aead_alg *aead = cryptoapi_aead_algs; + struct ahash_alg *ahash = cryptoapi_ahash_algs; +@@ -2302,13 +2276,13 @@ void nss_cryptoapi_detach_user(void *app + */ + atomic_set(&g_cryptoapi.registered, 0); + +-#if defined(NSS_CRYPTOAPI_ABLK) +- for (i = 0; enable_ablk && (i < ARRAY_SIZE(cryptoapi_ablkcipher_algs)); i++, ablk++) { +- if (!ablk->cra_flags) ++#if defined(NSS_CRYPTOAPI_SKCIPHER) ++ for (i = 0; enable_ablk && (i < ARRAY_SIZE(cryptoapi_skcipher_algs)); i++, ablk++) { ++ if (!ablk->base.cra_flags) + continue; + +- crypto_unregister_alg(ablk); +- nss_cfi_info("%px: ABLK unregister succeeded, algo: %s\n", sc, ablk->cra_name); ++ crypto_unregister_skcipher(ablk); ++ nss_cfi_info("%px: skcipher unregister succeeded, algo: %s\n", sc, ablk->base.cra_name); + } + #endif + +--- a/cryptoapi/v2.0/nss_cryptoapi_private.h ++++ b/cryptoapi/v2.0/nss_cryptoapi_private.h +@@ -248,14 +248,14 @@ extern void nss_cryptoapi_aead_tx_proc(s + struct nss_cryptoapi_info *info, bool encrypt); + + /* +- * ABLKCIPHER ++ * SKCIPHER + */ +-#if defined(NSS_CRYPTOAPI_ABLK) +-extern int nss_cryptoapi_ablkcipher_init(struct crypto_tfm *tfm); +-extern void nss_cryptoapi_ablkcipher_exit(struct crypto_tfm *tfm); +-extern int nss_cryptoapi_ablk_setkey(struct crypto_ablkcipher *cipher, const u8 *key, unsigned int len); +-extern int nss_cryptoapi_ablk_encrypt(struct ablkcipher_request *req); +-extern int nss_cryptoapi_ablk_decrypt(struct ablkcipher_request *req); ++#if defined(NSS_CRYPTOAPI_SKCIPHER) ++extern int nss_cryptoapi_skcipher_init(struct crypto_skcipher *tfm); ++extern void nss_cryptoapi_skcipher_exit(struct crypto_skcipher *tfm); ++extern int nss_cryptoapi_skcipher_setkey(struct crypto_skcipher *cipher, const u8 *key, unsigned int len); ++extern int nss_cryptoapi_skcipher_encrypt(struct skcipher_request *req); ++extern int nss_cryptoapi_skcipher_decrypt(struct skcipher_request *req); + extern void nss_cryptoapi_copy_iv(struct nss_cryptoapi_ctx *ctx, struct scatterlist *sg, uint8_t *iv, uint8_t iv_len); + #endif + +--- a/cryptoapi/v2.0/nss_cryptoapi_ablk.c ++++ /dev/null +@@ -1,458 +0,0 @@ +-/* Copyright (c) 2015-2020 The Linux Foundation. All rights reserved. +- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. +- * +- * Permission to use, copy, modify, and/or distribute this software for any +- * purpose with or without fee is hereby granted, provided that the above +- * copyright notice and this permission notice appear in all copies. +- * +- * +- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT +- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +- * PERFORMANCE OF THIS SOFTWARE. +- * +- * +- */ +- +-/** +- * nss_cryptoapi_ablk.c +- * Interface to communicate Native Linux crypto framework specific data +- * to Crypto core specific data +- */ +- +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include "nss_cryptoapi_private.h" +- +-extern struct nss_cryptoapi g_cryptoapi; +- +-/* +- * nss_cryptoapi_skcipher_ctx2session() +- * Cryptoapi function to get the session ID for an skcipher +- */ +-int nss_cryptoapi_skcipher_ctx2session(struct crypto_skcipher *sk, uint32_t *sid) +-{ +- struct crypto_tfm *tfm = crypto_skcipher_tfm(sk); +- struct crypto_ablkcipher **actx, *ablk; +- struct ablkcipher_tfm *ablk_tfm; +- struct nss_cryptoapi_ctx *ctx; +- +- if (strncmp("nss-", crypto_tfm_alg_driver_name(tfm), 4)) +- return -EINVAL; +- +- /* Get the ablkcipher from the skcipher */ +- actx = crypto_skcipher_ctx(sk); +- if (!actx || !(*actx)) +- return -EINVAL; +- +- /* +- * The ablkcipher now obtained is a wrapper around the actual +- * ablkcipher that is created when the skcipher is created. +- * Hence we derive the required ablkcipher through ablkcipher_tfm. +- */ +- ablk_tfm = crypto_ablkcipher_crt(*actx); +- if (!ablk_tfm) +- return -EINVAL; +- +- ablk = ablk_tfm->base; +- if (!ablk) +- return -EINVAL; +- +- /* Get the nss_cryptoapi context stored in the ablkcipher */ +- ctx = crypto_ablkcipher_ctx(ablk); +- +- BUG_ON(!ctx); +- NSS_CRYPTOAPI_VERIFY_MAGIC(ctx); +- +- *sid = ctx->sid; +- return 0; +-} +-EXPORT_SYMBOL(nss_cryptoapi_skcipher_ctx2session); +- +-/* +- * nss_cryptoapi_ablkcipher_init() +- * Cryptoapi ablkcipher init function. +- */ +-int nss_cryptoapi_ablkcipher_init(struct crypto_tfm *tfm) +-{ +- struct nss_cryptoapi_ctx *ctx = crypto_tfm_ctx(tfm); +- +- BUG_ON(!ctx); +- NSS_CRYPTOAPI_SET_MAGIC(ctx); +- +- memset(ctx, 0, sizeof(struct nss_cryptoapi_ctx)); +- +- ctx->user = g_cryptoapi.user; +- ctx->stats.init++; +- ctx->sid = NSS_CRYPTO_SESSION_MAX; +- init_completion(&ctx->complete); +- +- return 0; +-} +- +-/* +- * nss_cryptoapi_ablkcipher_exit() +- * Cryptoapi ablkcipher exit function. +- */ +-void nss_cryptoapi_ablkcipher_exit(struct crypto_tfm *tfm) +-{ +- struct nss_cryptoapi_ctx *ctx = crypto_tfm_ctx(tfm); +- int ret; +- +- BUG_ON(!ctx); +- NSS_CRYPTOAPI_VERIFY_MAGIC(ctx); +- +- ctx->stats.exit++; +- +- /* +- * When fallback_req is set, it means that fallback tfm was used +- * we didn't create any sessions. +- */ +- if (ctx->fallback_req) { +- ctx->stats.failed_fallback++; +- return; +- } +- +- if (!atomic_read(&ctx->active)) { +- ctx->stats.failed_exit++; +- return; +- } +- +- /* +- * Mark cryptoapi context as inactive +- */ +- atomic_set(&ctx->active, 0); +- +- if (!atomic_sub_and_test(1, &ctx->refcnt)) { +- /* +- * We need to wait for any outstanding packet using this ctx. +- * Once the last packet get processed, reference count will become +- * 0 this ctx. We will wait for the reference to go down to 0. +- */ +- ret = wait_for_completion_timeout(&ctx->complete, NSS_CRYPTOAPI_REQ_TIMEOUT_TICKS); +- WARN_ON(!ret); +- } +- +- if (ctx->sid != NSS_CRYPTO_SESSION_MAX) { +- nss_crypto_session_free(ctx->user, ctx->sid); +- debugfs_remove_recursive(ctx->dentry); +- ctx->sid = NSS_CRYPTO_SESSION_MAX; +- } +- +- NSS_CRYPTOAPI_CLEAR_MAGIC(ctx); +-} +- +-/* +- * nss_cryptoapi_ablk_setkey() +- * Cryptoapi setkey routine for aes. +- */ +-int nss_cryptoapi_ablk_setkey(struct crypto_ablkcipher *cipher, const u8 *key, unsigned int keylen) +-{ +- struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); +- struct nss_cryptoapi_ctx *ctx = crypto_tfm_ctx(tfm); +- struct nss_crypto_session_data data = {0}; +- int status; +- +- /* +- * Validate magic number - init should be called before setkey +- */ +- NSS_CRYPTOAPI_VERIFY_MAGIC(ctx); +- +- ctx->info = nss_cryptoapi_cra_name2info(crypto_tfm_alg_name(tfm), keylen, 0); +- if (!ctx->info) { +- crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); +- return -EINVAL; +- } +- +- ctx->iv_size = crypto_ablkcipher_ivsize(cipher); +- +- if (ctx->info->cipher_mode == NSS_CRYPTOAPI_CIPHER_MODE_CTR_RFC3686) { +- keylen = keylen - CTR_RFC3686_NONCE_SIZE; +- memcpy(ctx->ctx_iv, key + keylen, CTR_RFC3686_NONCE_SIZE); +- ctx->ctx_iv[3] = ntohl(0x1); +- ctx->iv_size += CTR_RFC3686_NONCE_SIZE + sizeof(uint32_t); +- } +- +- /* +- * Fill NSS crypto session data +- */ +- data.algo = ctx->info->algo; +- data.cipher_key = key; +- +- if (data.algo >= NSS_CRYPTO_CMN_ALGO_MAX) +- return -ERANGE; +- +- if (ctx->sid != NSS_CRYPTO_SESSION_MAX) { +- nss_crypto_session_free(ctx->user, ctx->sid); +- debugfs_remove_recursive(ctx->dentry); +- ctx->sid = NSS_CRYPTO_SESSION_MAX; +- } +- +- status = nss_crypto_session_alloc(ctx->user, &data, &ctx->sid); +- if (status < 0) { +- nss_cfi_err("%px: Unable to allocate crypto session(%d)\n", ctx, status); +- crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_FLAGS); +- return status; +- } +- +- nss_cryptoapi_add_ctx2debugfs(ctx); +- atomic_set(&ctx->active, 1); +- atomic_set(&ctx->refcnt, 1); +- return 0; +-} +- +-/* +- * nss_cryptoapi_ablkcipher_done() +- * Cipher operation completion callback function +- */ +-void nss_cryptoapi_ablkcipher_done(void *app_data, struct nss_crypto_hdr *ch, uint8_t status) +-{ +- struct ablkcipher_request *req = app_data; +- struct nss_cryptoapi_ctx *ctx = crypto_tfm_ctx(req->base.tfm); +- int error; +- +- BUG_ON(!ch); +- +- /* +- * Check cryptoapi context magic number. +- */ +- NSS_CRYPTOAPI_VERIFY_MAGIC(ctx); +- +- /* +- * For skcipher decryption case, the last block of encrypted data is used as +- * an IV for the next data +- */ +- if (ch->op == NSS_CRYPTO_OP_DIR_ENC) { +- nss_cryptoapi_copy_iv(ctx, req->dst, req->info, ch->iv_len); +- } +- +- /* +- * Free crypto hdr +- */ +- nss_crypto_hdr_free(ctx->user, ch); +- +- nss_cfi_dbg("data dump after transformation\n"); +- nss_cfi_dbg_data(sg_virt(req->dst), req->nbytes, ' '); +- +- /* +- * Check if there is any error reported by hardware +- */ +- error = nss_cryptoapi_status2error(ctx, status); +- ctx->stats.completed++; +- +- /* +- * Decrement cryptoapi reference +- */ +- nss_cryptoapi_ref_dec(ctx); +- req->base.complete(&req->base, error); +-} +- +-/* +- * nss_cryptoapi_ablk_encrypt() +- * Crytoapi encrypt for AES and 3DES algorithms. +- */ +-int nss_cryptoapi_ablk_encrypt(struct ablkcipher_request *req) +-{ +- struct nss_cryptoapi_info info = {.op_dir = NSS_CRYPTO_OP_DIR_ENC}; +- struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(req); +- struct nss_cryptoapi_ctx *ctx = crypto_ablkcipher_ctx(cipher); +- struct crypto_tfm *tfm = req->base.tfm; +- struct scatterlist *cur; +- int tot_len = 0; +- int i; +- +- /* +- * Check cryptoapi context magic number. +- */ +- NSS_CRYPTOAPI_VERIFY_MAGIC(ctx); +- +- /* +- * Check if cryptoapi context is active or not +- */ +- if (!atomic_read(&ctx->active)) +- return -EINVAL; +- +- if (sg_nents(req->src) != sg_nents(req->dst)) { +- ctx->stats.failed_req++; +- return -EINVAL; +- } +- +- /* +- * Block size not aligned. +- * AES-CTR requires only a one-byte block size alignment. +- */ +- if (!IS_ALIGNED(req->nbytes, crypto_tfm_alg_blocksize(tfm)) && ctx->info->blk_align) { +- ctx->stats.failed_align++; +- crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_BLOCK_LEN); +- return -EFAULT; +- } +- +- /* +- * Fill the request information structure +- */ +- info.iv = req->info; +- info.src.nsegs = sg_nents(req->src); +- info.dst.nsegs = sg_nents(req->dst); +- info.op_dir = NSS_CRYPTO_OP_DIR_ENC; +- info.cb = nss_cryptoapi_ablkcipher_done; +- info.iv_size = ctx->iv_size; +- info.src.first_sg = req->src; +- info.dst.first_sg = req->dst; +- info.dst.last_sg = sg_last(req->dst, info.dst.nsegs); +- +- /* out and in length will be same as ablk does only encrypt/decryt operation */ +- info.total_in_len = info.total_out_len = req->nbytes; +- info.in_place = (req->src == req->dst) ? true : false; +- +- /* +- * The exact length of data that needs to be ciphered for an ABLK +- * request is stored in req->nbytes. Hence we may have to reduce +- * the DMA length to what is specified in req->nbytes and later +- * restore the length of scatterlist back to its original value. +- */ +- for_each_sg(req->src, cur, info.src.nsegs, i) { +- if (!cur) +- break; +- +- tot_len += cur->length; +- if (!sg_next(cur)) +- break; +- } +- +- /* +- * We only support (2^16 - 1) length. +- */ +- if (tot_len > U16_MAX) { +- ctx->stats.failed_len++; +- return -EFBIG; +- } +- +- info.src.last_sg = cur; +- info.ahash_skip = tot_len - req->nbytes; +- +- if (!atomic_inc_not_zero(&ctx->refcnt)) +- return -ENOENT; +- +- return nss_cryptoapi_transform(ctx, &info, (void *)req, false); +-} +- +-/* +- * nss_cryptoapi_ablk_decrypt() +- * Crytoapi decrypt for AES and 3DES CBC algorithms. +- */ +-int nss_cryptoapi_ablk_decrypt(struct ablkcipher_request *req) +-{ +- struct nss_cryptoapi_info info = {.op_dir = NSS_CRYPTO_OP_DIR_DEC}; +- struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(req); +- struct nss_cryptoapi_ctx *ctx = crypto_ablkcipher_ctx(cipher); +- struct crypto_tfm *tfm = req->base.tfm; +- struct scatterlist *cur; +- int tot_len = 0; +- int i; +- +- /* +- * Check cryptoapi context magic number. +- */ +- NSS_CRYPTOAPI_VERIFY_MAGIC(ctx); +- +- /* +- * Check if cryptoapi context is active or not +- */ +- if (!atomic_read(&ctx->active)) +- return -EINVAL; +- +- if (sg_nents(req->src) != sg_nents(req->dst)) { +- ctx->stats.failed_req++; +- return -EINVAL; +- } +- +- /* +- * Block size not aligned +- */ +- if (!IS_ALIGNED(req->nbytes, crypto_tfm_alg_blocksize(tfm)) && ctx->info->blk_align) { +- ctx->stats.failed_align++; +- crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_BLOCK_LEN); +- return -EFAULT; +- } +- +- /* +- * Fill the request information structure +- * Note: For CTR mode, IV size will be set to AES_BLOCK_SIZE. +- * This is because linux gives iv size as 8 while we need to alloc 16 bytes +- * in crypto hdr to accomodate +- * - 4 bytes of nonce +- * - 8 bytes of IV +- * - 4 bytes of initial counter +- */ +- info.iv = req->info; +- info.src.nsegs = sg_nents(req->src); +- info.dst.nsegs = sg_nents(req->dst); +- info.iv_size = ctx->iv_size; +- info.op_dir = NSS_CRYPTO_OP_DIR_DEC; +- info.cb = nss_cryptoapi_ablkcipher_done; +- info.src.first_sg = req->src; +- info.dst.first_sg = req->dst; +- info.dst.last_sg = sg_last(req->dst, info.dst.nsegs); +- +- /* out and in length will be same as ablk does only encrypt/decryt operation */ +- info.total_in_len = info.total_out_len = req->nbytes; +- info.in_place = (req->src == req->dst) ? true : false; +- +- /* +- * The exact length of data that needs to be ciphered for an ABLK +- * request is stored in req->nbytes. Hence we may have to reduce +- * the DMA length to what is specified in req->nbytes and later +- * restore the length of scatterlist back to its original value. +- */ +- for_each_sg(req->src, cur, info.src.nsegs, i) { +- tot_len += cur->length; +- if (!sg_next(cur)) +- break; +- } +- +- /* +- * We only support (2^16 - 1) length. +- */ +- if (tot_len > U16_MAX) { +- ctx->stats.failed_len++; +- return -EFBIG; +- } +- +- info.ahash_skip = tot_len - req->nbytes; +- info.src.last_sg = cur; +- +- if (!atomic_inc_not_zero(&ctx->refcnt)) +- return -ENOENT; +- +- return nss_cryptoapi_transform(ctx, &info, (void *)req, false); +-} +--- /dev/null ++++ b/cryptoapi/v2.0/nss_cryptoapi_skcipher.c +@@ -0,0 +1,438 @@ ++/* Copyright (c) 2015-2020 The Linux Foundation. All rights reserved. ++ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY ++ * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT ++ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM ++ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE ++ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR ++ * PERFORMANCE OF THIS SOFTWARE. ++ * ++ * ++ */ ++ ++/** ++ * nss_cryptoapi_ablk.c ++ * Interface to communicate Native Linux crypto framework specific data ++ * to Crypto core specific data ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) ++#include ++#else ++#include ++#include ++#endif ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "nss_cryptoapi_private.h" ++ ++extern struct nss_cryptoapi g_cryptoapi; ++ ++/* ++ * nss_cryptoapi_skcipher_ctx2session() ++ * Cryptoapi function to get the session ID for an skcipher ++ */ ++int nss_cryptoapi_skcipher_ctx2session(struct crypto_skcipher *sk, uint32_t *sid) ++{ ++ struct crypto_tfm *tfm = crypto_skcipher_tfm(sk); ++ struct nss_cryptoapi_ctx *ctx; ++ ++ if (strncmp("nss-", crypto_tfm_alg_driver_name(tfm), 4)) ++ return -EINVAL; ++ ++ /* Get the nss_cryptoapi context stored in skcipher */ ++ ctx = crypto_skcipher_ctx(sk); ++ BUG_ON(!ctx); ++ NSS_CRYPTOAPI_VERIFY_MAGIC(ctx); ++ ++ *sid = ctx->sid; ++ return 0; ++} ++EXPORT_SYMBOL(nss_cryptoapi_skcipher_ctx2session); ++ ++/* ++ * nss_cryptoapi_skcipher_init() ++ * Cryptoapi skcipher init function. ++ */ ++int nss_cryptoapi_skcipher_init(struct crypto_skcipher *tfm) ++{ ++ struct nss_cryptoapi_ctx *ctx = crypto_skcipher_ctx(tfm); ++ ++ BUG_ON(!ctx); ++ NSS_CRYPTOAPI_SET_MAGIC(ctx); ++ ++ memset(ctx, 0, sizeof(struct nss_cryptoapi_ctx)); ++ ++ ctx->user = g_cryptoapi.user; ++ ctx->stats.init++; ++ ctx->sid = NSS_CRYPTO_SESSION_MAX; ++ init_completion(&ctx->complete); ++ ++ return 0; ++} ++ ++/* ++ * nss_cryptoapi_skcipher_exit() ++ * Cryptoapi skcipher exit function. ++ */ ++void nss_cryptoapi_skcipher_exit(struct crypto_skcipher *tfm) ++{ ++ struct nss_cryptoapi_ctx *ctx = crypto_skcipher_ctx(tfm); ++ int ret; ++ ++ BUG_ON(!ctx); ++ NSS_CRYPTOAPI_VERIFY_MAGIC(ctx); ++ ++ ctx->stats.exit++; ++ ++ /* ++ * When fallback_req is set, it means that fallback tfm was used ++ * we didn't create any sessions. ++ */ ++ if (ctx->fallback_req) { ++ ctx->stats.failed_fallback++; ++ return; ++ } ++ ++ if (!atomic_read(&ctx->active)) { ++ ctx->stats.failed_exit++; ++ return; ++ } ++ ++ /* ++ * Mark cryptoapi context as inactive ++ */ ++ atomic_set(&ctx->active, 0); ++ ++ if (!atomic_sub_and_test(1, &ctx->refcnt)) { ++ /* ++ * We need to wait for any outstanding packet using this ctx. ++ * Once the last packet get processed, reference count will become ++ * 0 this ctx. We will wait for the reference to go down to 0. ++ */ ++ ret = wait_for_completion_timeout(&ctx->complete, NSS_CRYPTOAPI_REQ_TIMEOUT_TICKS); ++ WARN_ON(!ret); ++ } ++ ++ if (ctx->sid != NSS_CRYPTO_SESSION_MAX) { ++ nss_crypto_session_free(ctx->user, ctx->sid); ++ debugfs_remove_recursive(ctx->dentry); ++ ctx->sid = NSS_CRYPTO_SESSION_MAX; ++ } ++ ++ NSS_CRYPTOAPI_CLEAR_MAGIC(ctx); ++} ++ ++/* ++ * nss_cryptoapi_skcipher_setkey() ++ * Cryptoapi setkey routine for aes. ++ */ ++int nss_cryptoapi_skcipher_setkey(struct crypto_skcipher *cipher, const u8 *key, unsigned int keylen) ++{ ++ struct crypto_tfm *tfm = crypto_skcipher_tfm(cipher); ++ struct nss_cryptoapi_ctx *ctx = crypto_skcipher_ctx(cipher); ++ struct nss_crypto_session_data data = {0}; ++ int status; ++ ++ /* ++ * Validate magic number - init should be called before setkey ++ */ ++ NSS_CRYPTOAPI_VERIFY_MAGIC(ctx); ++ ++ ctx->info = nss_cryptoapi_cra_name2info(crypto_tfm_alg_name(tfm), keylen, 0); ++ if (!ctx->info) { ++ return -EINVAL; ++ } ++ ++ ctx->iv_size = crypto_skcipher_ivsize(cipher); ++ ++ if (ctx->info->cipher_mode == NSS_CRYPTOAPI_CIPHER_MODE_CTR_RFC3686) { ++ keylen = keylen - CTR_RFC3686_NONCE_SIZE; ++ memcpy(ctx->ctx_iv, key + keylen, CTR_RFC3686_NONCE_SIZE); ++ ctx->ctx_iv[3] = ntohl(0x1); ++ ctx->iv_size += CTR_RFC3686_NONCE_SIZE + sizeof(uint32_t); ++ } ++ ++ /* ++ * Fill NSS crypto session data ++ */ ++ data.algo = ctx->info->algo; ++ data.cipher_key = key; ++ ++ if (data.algo >= NSS_CRYPTO_CMN_ALGO_MAX) ++ return -ERANGE; ++ ++ if (ctx->sid != NSS_CRYPTO_SESSION_MAX) { ++ nss_crypto_session_free(ctx->user, ctx->sid); ++ debugfs_remove_recursive(ctx->dentry); ++ ctx->sid = NSS_CRYPTO_SESSION_MAX; ++ } ++ ++ status = nss_crypto_session_alloc(ctx->user, &data, &ctx->sid); ++ if (status < 0) { ++ nss_cfi_err("%px: Unable to allocate crypto session(%d)\n", ctx, status); ++ return status; ++ } ++ ++ nss_cryptoapi_add_ctx2debugfs(ctx); ++ atomic_set(&ctx->active, 1); ++ atomic_set(&ctx->refcnt, 1); ++ return 0; ++} ++ ++/* ++ * nss_cryptoapi_skcipher_done() ++ * Cipher operation completion callback function ++ */ ++void nss_cryptoapi_skcipher_done(void *app_data, struct nss_crypto_hdr *ch, uint8_t status) ++{ ++ struct skcipher_request *req = app_data; ++ struct nss_cryptoapi_ctx *ctx = skcipher_request_ctx(req); ++ int error; ++ ++ BUG_ON(!ch); ++ ++ /* ++ * Check cryptoapi context magic number. ++ */ ++ NSS_CRYPTOAPI_VERIFY_MAGIC(ctx); ++ ++ /* ++ * For skcipher decryption case, the last block of encrypted data is used as ++ * an IV for the next data ++ */ ++ if (ch->op == NSS_CRYPTO_OP_DIR_ENC) { ++ nss_cryptoapi_copy_iv(ctx, req->dst, req->iv, ch->iv_len); ++ } ++ ++ /* ++ * Free crypto hdr ++ */ ++ nss_crypto_hdr_free(ctx->user, ch); ++ ++ nss_cfi_dbg("data dump after transformation\n"); ++ nss_cfi_dbg_data(sg_virt(req->dst), req->cryptlen, ' '); ++ ++ /* ++ * Check if there is any error reported by hardware ++ */ ++ error = nss_cryptoapi_status2error(ctx, status); ++ ctx->stats.completed++; ++ ++ /* ++ * Decrement cryptoapi reference ++ */ ++ nss_cryptoapi_ref_dec(ctx); ++ req->base.complete(&req->base, error); ++} ++ ++/* ++ * nss_cryptoapi_skcipher_encrypt() ++ * Crytoapi encrypt for AES and 3DES algorithms. ++ */ ++int nss_cryptoapi_skcipher_encrypt(struct skcipher_request *req) ++{ ++ struct nss_cryptoapi_info info = {.op_dir = NSS_CRYPTO_OP_DIR_ENC}; ++ struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req); ++ struct nss_cryptoapi_ctx *ctx = crypto_skcipher_ctx(cipher); ++ struct crypto_tfm *tfm = req->base.tfm; ++ struct scatterlist *cur; ++ int tot_len = 0; ++ int i; ++ ++ /* ++ * Check cryptoapi context magic number. ++ */ ++ NSS_CRYPTOAPI_VERIFY_MAGIC(ctx); ++ ++ /* ++ * Check if cryptoapi context is active or not ++ */ ++ if (!atomic_read(&ctx->active)) ++ return -EINVAL; ++ ++ if (sg_nents(req->src) != sg_nents(req->dst)) { ++ ctx->stats.failed_req++; ++ return -EINVAL; ++ } ++ ++ /* ++ * Block size not aligned. ++ * AES-CTR requires only a one-byte block size alignment. ++ */ ++ if (!IS_ALIGNED(req->cryptlen, crypto_tfm_alg_blocksize(tfm)) && ctx->info->blk_align) { ++ ctx->stats.failed_align++; ++ return -EFAULT; ++ } ++ ++ /* ++ * Fill the request information structure ++ */ ++ info.iv = req->iv; ++ info.src.nsegs = sg_nents(req->src); ++ info.dst.nsegs = sg_nents(req->dst); ++ info.op_dir = NSS_CRYPTO_OP_DIR_ENC; ++ info.cb = nss_cryptoapi_skcipher_done; ++ info.iv_size = ctx->iv_size; ++ info.src.first_sg = req->src; ++ info.dst.first_sg = req->dst; ++ info.dst.last_sg = sg_last(req->dst, info.dst.nsegs); ++ ++ /* out and in length will be same as ablk does only encrypt/decryt operation */ ++ info.total_in_len = info.total_out_len = req->cryptlen; ++ info.in_place = (req->src == req->dst) ? true : false; ++ ++ /* ++ * The exact length of data that needs to be ciphered for an ABLK ++ * request is stored in req->cryptlen. Hence we may have to reduce ++ * the DMA length to what is specified in req->cryptlen and later ++ * restore the length of scatterlist back to its original value. ++ */ ++ for_each_sg(req->src, cur, info.src.nsegs, i) { ++ if (!cur) ++ break; ++ ++ tot_len += cur->length; ++ if (!sg_next(cur)) ++ break; ++ } ++ ++ /* ++ * We only support (2^16 - 1) length. ++ */ ++ if (tot_len > U16_MAX) { ++ ctx->stats.failed_len++; ++ return -EFBIG; ++ } ++ ++ info.src.last_sg = cur; ++ info.ahash_skip = tot_len - req->cryptlen; ++ ++ if (!atomic_inc_not_zero(&ctx->refcnt)) ++ return -ENOENT; ++ ++ return nss_cryptoapi_transform(ctx, &info, (void *)req, false); ++} ++ ++/* ++ * nss_cryptoapi_skcipher_decrypt() ++ * Crytoapi decrypt for AES and 3DES CBC algorithms. ++ */ ++int nss_cryptoapi_skcipher_decrypt(struct skcipher_request *req) ++{ ++ struct nss_cryptoapi_info info = {.op_dir = NSS_CRYPTO_OP_DIR_DEC}; ++ struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req); ++ struct nss_cryptoapi_ctx *ctx = crypto_skcipher_ctx(cipher); ++ struct crypto_tfm *tfm = req->base.tfm; ++ struct scatterlist *cur; ++ int tot_len = 0; ++ int i; ++ ++ /* ++ * Check cryptoapi context magic number. ++ */ ++ NSS_CRYPTOAPI_VERIFY_MAGIC(ctx); ++ ++ /* ++ * Check if cryptoapi context is active or not ++ */ ++ if (!atomic_read(&ctx->active)) ++ return -EINVAL; ++ ++ if (sg_nents(req->src) != sg_nents(req->dst)) { ++ ctx->stats.failed_req++; ++ return -EINVAL; ++ } ++ ++ /* ++ * Block size not aligned ++ */ ++ if (!IS_ALIGNED(req->cryptlen, crypto_tfm_alg_blocksize(tfm)) && ctx->info->blk_align) { ++ ctx->stats.failed_align++; ++ return -EFAULT; ++ } ++ ++ /* ++ * Fill the request information structure ++ * Note: For CTR mode, IV size will be set to AES_BLOCK_SIZE. ++ * This is because linux gives iv size as 8 while we need to alloc 16 bytes ++ * in crypto hdr to accomodate ++ * - 4 bytes of nonce ++ * - 8 bytes of IV ++ * - 4 bytes of initial counter ++ */ ++ info.iv = req->iv; ++ info.src.nsegs = sg_nents(req->src); ++ info.dst.nsegs = sg_nents(req->dst); ++ info.iv_size = ctx->iv_size; ++ info.op_dir = NSS_CRYPTO_OP_DIR_DEC; ++ info.cb = nss_cryptoapi_skcipher_done; ++ info.src.first_sg = req->src; ++ info.dst.first_sg = req->dst; ++ info.dst.last_sg = sg_last(req->dst, info.dst.nsegs); ++ ++ /* out and in length will be same as ablk does only encrypt/decryt operation */ ++ info.total_in_len = info.total_out_len = req->cryptlen; ++ info.in_place = (req->src == req->dst) ? true : false; ++ ++ /* ++ * The exact length of data that needs to be ciphered for an ABLK ++ * request is stored in req->cryptlen. Hence we may have to reduce ++ * the DMA length to what is specified in req->cryptlen and later ++ * restore the length of scatterlist back to its original value. ++ */ ++ for_each_sg(req->src, cur, info.src.nsegs, i) { ++ tot_len += cur->length; ++ if (!sg_next(cur)) ++ break; ++ } ++ ++ /* ++ * We only support (2^16 - 1) length. ++ */ ++ if (tot_len > U16_MAX) { ++ ctx->stats.failed_len++; ++ return -EFBIG; ++ } ++ ++ info.ahash_skip = tot_len - req->cryptlen; ++ info.src.last_sg = cur; ++ ++ if (!atomic_inc_not_zero(&ctx->refcnt)) ++ return -ENOENT; ++ ++ return nss_cryptoapi_transform(ctx, &info, (void *)req, false); ++} diff --git a/lede/package/qca/qca-nss-clients/Makefile b/lede/package/qca/qca-nss-clients/Makefile new file mode 100644 index 0000000000..b69ea8f225 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/Makefile @@ -0,0 +1,624 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=qca-nss-clients +PKG_RELEASE:=$(AUTORELEASE) + +PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/nss-clients.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_DATE:=2023-10-04 +PKG_SOURCE_VERSION:=f058ae199b42f30be9925b2ed1ce53afb128200c +PKG_MIRROR_HASH:=90401b577a7750d3b7eadb423700aab7e1da1af392637598e08f6007f23a92e1 + +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/package.mk + +ifeq ($(CONFIG_TARGET_SUBTARGET), "ipq807x") + SOC="ipq807x_64" + subtarget:=$(CONFIG_TARGET_SUBTARGET) +else ifeq ($(CONFIG_TARGET_SUBTARGET), "ipq60xx") + SOC="ipq60xx_64" + subtarget:=$(CONFIG_TARGET_SUBTARGET) +endif + +ifneq (, $(findstring $(subtarget), "ipq807x" "ipq807x_64" "ipq60xx" "ipq60xx_64")) +# DTLS Manager v2.0 for Hawkeye/Cypress + DTLSMGR_DIR:=v2.0 +# IPsec Manager v2.0 for Hawkeye/Cypress + IPSECMGR_DIR:=v2.0 +# KLIPS plugin + IPSECMGR_KLIPS:= $(PKG_BUILD_DIR)/ipsecmgr/$(IPSECMGR_DIR)/plugins/klips/qca-nss-ipsec-klips.ko +endif + +define KernelPackage/qca-nss-drv-gre + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for NSS (connection manager) - GRE + DEPENDS:=@(TARGET_ipq_ipq806x||TARGET_ipq806x||TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_64||TARGET_ipq807x||TARGET_ipq807x_64||TARGET_qualcommax||TARGET_ipq_ipq60xx||TARGET_ipq_ipq60xx_64||TARGET_ipq_ipq50xx||TARGET_ipq_ipq50xx_64||TARGET_ipq50xx) \ + +@NSS_DRV_GRE_ENABLE +kmod-gre6 \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv + FILES:=$(PKG_BUILD_DIR)/gre/qca-nss-gre.ko $(PKG_BUILD_DIR)/gre/test/qca-nss-gre-test.ko + AUTOLOAD:=$(call AutoLoad,51,qca-nss-gre) +endef + +define KernelPackage/qca-nss-drv-gre/description +Kernel modules for NSS connection manager - Support for GRE +endef + +define KernelPackage/qca-nss-drv-l2tpv2 + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for NSS (connection manager) - l2tp + DEPENDS:=@NSS_DRV_L2TP_ENABLE +kmod-ppp +kmod-l2tp \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv + FILES:=$(PKG_BUILD_DIR)/l2tp/l2tpv2/qca-nss-l2tpv2.ko + KCONFIG:=CONFIG_L2TP=y + AUTOLOAD:=$(call AutoLoad,51,qca-nss-l2tpv2) +endef + +define KernelPackage/qca-nss-drv-l2tp/description +Kernel modules for NSS connection manager - Support for l2tp tunnel +endef + +define KernelPackage/qca-nss-drv-pptp + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for NSS (connection manager) - PPTP + DEPENDS:=+@NSS_DRV_PPTP_ENABLE +kmod-pptp \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv + FILES:=$(PKG_BUILD_DIR)/pptp/qca-nss-pptp.ko + AUTOLOAD:=$(call AutoLoad,51,qca-nss-pptp) +endef + +define KernelPackage/qca-nss-drv-pptp/description +Kernel modules for NSS connection manager - Support for PPTP tunnel +endef + +define KernelPackage/qca-nss-drv-pppoe + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for NSS (connection manager) - PPPoE + DEPENDS:=+@NSS_DRV_PPPOE_ENABLE +kmod-ppp +kmod-pppoe \ + +PACKAGE_kmod-bonding:kmod-bonding \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv + FILES:=$(PKG_BUILD_DIR)/pppoe/qca-nss-pppoe.ko + AUTOLOAD:=$(call AutoLoad,51,qca-nss-pppoe) +endef + +define KernelPackage/qca-nss-drv-pppoe/Description +Kernel modules for NSS connection manager - Support for PPPoE +endef + +define KernelPackage/qca-nss-drv-map-t + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for NSS (connection manager) - MAP-T + DEPENDS:=+@NSS_DRV_MAPT_ENABLE \ + +PACKAGE_kmod-nat46:kmod-nat46 \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv + FILES:=$(PKG_BUILD_DIR)/map/map-t/qca-nss-map-t.ko + AUTOLOAD:=$(call AutoLoad,51,qca-nss-map-t) +endef + +define KernelPackage/qca-nss-drv-map-t/description +Kernel modules for NSS connection manager - Support for MAP-T +endef + +define KernelPackage/qca-nss-drv-tun6rd + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for NSS (connection manager) - tun6rd + DEPENDS:=+@NSS_DRV_TUN6RD_ENABLE +kmod-sit +6rd \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv + FILES:=$(PKG_BUILD_DIR)/qca-nss-tun6rd.ko + AUTOLOAD:=$(call AutoLoad,60,qca-nss-tun6rd) +endef + +define KernelPackage/qca-nss-drv-tun6rd/description +Kernel modules for NSS connection manager - Support for 6rd tunnel +endef + +define KernelPackage/qca-nss-drv-tunipip6 + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for NSS (connection manager) - DS-lite and ipip6 Tunnel + DEPENDS:=+@NSS_DRV_TUNIPIP6_ENABLE +kmod-iptunnel6 +kmod-ip6-tunnel \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv + FILES:=$(PKG_BUILD_DIR)/tunipip6/qca-nss-tunipip6.ko + AUTOLOAD:=$(call AutoLoad,60,qca-nss-tunipip6) +endef + +define KernelPackage/qca-nss-drv-tunipip6/description +Kernel modules for NSS connection manager +Add support for DS-lite and ipip6 tunnel +endef + +define KernelPackage/qca-nss-drv-bridge-mgr + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for NSS bridge manager + DEPENDS:=@(TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_64||TARGET_ipq807x||TARGET_qualcommax||TARGET_ipq_ipq60xx||TARGET_ipq_ipq60xx_64||TARGET_ipq60xx) \ + +TARGET_ipq_ipq807x:kmod-qca-nss-drv-vlan-mgr \ + +TARGET_ipq_ipq807x_64:kmod-qca-nss-drv-vlan-mgr \ + +TARGET_ipq807x:kmod-qca-nss-drv-vlan-mgr \ + +TARGET_qualcommax:kmod-qca-nss-drv-vlan-mgr \ + +TARGET_ipq60xx:kmod-qca-nss-drv-vlan-mgr \ + +TARGET_ipq_ipq60xx:kmod-qca-nss-drv-vlan-mgr \ + +TARGET_ipq_ipq60xx_64:kmod-qca-nss-drv-vlan-mgr \ + +@NSS_DRV_BRIDGE_ENABLE \ + +PACKAGE_kmod-bonding:kmod-bonding \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv +ifneq ($(CONFIG_PACKAGE_kmod-qca-ovsmgr),) + DEPENDS+=kmod-qca-ovsmgr +endif + FILES:=$(PKG_BUILD_DIR)/bridge/qca-nss-bridge-mgr.ko + AUTOLOAD:=$(call AutoLoad,51,qca-nss-bridge-mgr) +endef + +define KernelPackage/qca-nss-drv-bridge-mgr/Description +Kernel modules for NSS bridge manager +endef + +define KernelPackage/qca-nss-drv-clmapmgr + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + DEPENDS:=+@NSS_DRV_CLMAP_ENABLE \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv \ + +kmod-qca-nss-drv-eogremgr + TITLE:=NSS clmap Manager for QCA NSS driver + FILES:=$(PKG_BUILD_DIR)/clmapmgr/qca-nss-clmapmgr.ko +endef + +define KernelPackage/qca-nss-drv-clmapmgr/description +Kernel module for managing NSS clmap +endef + +define KernelPackage/qca-nss-drv-dtlsmgr + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for NSS (connection manager) - dtlsmgr + DEPENDS:=+@NSS_DRV_DTLS_ENABLE \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv \ + +PACKAGE_kmod-qca-nss-cfi-cryptoapi:kmod-qca-nss-cfi-cryptoapi + FILES:=$(PKG_BUILD_DIR)/dtls/$(DTLSMGR_DIR)/qca-nss-dtlsmgr.ko +endef + +define KernelPackage/qca-nss-drv-dtls/description +Kernel modules for NSS connection manager - Support for DTLS sessions +endef + +define KernelPackage/qca-nss-drv-tlsmgr + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for NSS (connection manager) - tlsmgr + DEPENDS:=@(TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_64||TARGET_ipq807x||TARGET_ipq807x_64||TARGET_qualcommax||TARGET_ipq_ipq60xx||TARGET_ipq_ipq60xx_64||TARGET_ipq60xx) \ + +@NSS_DRV_TLS_ENABLE \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv \ + +PACKAGE_kmod-qca-nss-cfi-cryptoapi:kmod-qca-nss-cfi-cryptoapi + FILES:=$(PKG_BUILD_DIR)/tls/qca-nss-tlsmgr.ko +endef + +define KernelPackage/qca-nss-drv-tls/description +Kernel modules for NSS connection manager - Support for TLS sessions +endef + +define KernelPackage/qca-nss-drv-ipsecmgr + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for NSS (ipsec manager) - ipsecmgr + DEPENDS:=@(TARGET_ipq806x||TARGET_ipq807x||TARGET_qualcommax) \ + +@NSS_DRV_TSTAMP_ENABLE \ + +@NSS_DRV_IPSEC_ENABLE \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv \ + +PACKAGE_kmod-qca-nss-cfi-cryptoapi:kmod-qca-nss-cfi-cryptoapi +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-l2tpv2),) + DEPENDS+=+kmod-qca-nss-drv-l2tpv2 +endif + FILES:=$(PKG_BUILD_DIR)/ipsecmgr/$(IPSECMGR_DIR)/qca-nss-ipsecmgr.ko $(IPSECMGR_KLIPS) + AUTOLOAD:=$(call AutoLoad,60,qca-nss-ipsecmgr) +endef + +define KernelPackage/qca-nss-drv-ipsecmgr/description +Kernel module for NSS IPsec offload manager +endef + +define KernelPackage/qca-nss-drv-ovpn-mgr + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for NSS OpenVPN manager + DEPENDS:=@(TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_64||TARGET_ipq807x||TARGET_qualcommax||TARGET_ipq_ipq60xx||TARGET_ipq_ipq60xx_64||TARGET_ipq60xx) \ + +@NSS_DRV_OVPN_ENABLE +kmod-qca-nss-drv +kmod-tun +kmod-ipt-conntrack \ + +PACKAGE_kmod-qca-nss-cfi-cryptoapi:kmod-qca-nss-cfi-cryptoapi + FILES:=$(PKG_BUILD_DIR)/openvpn/src/qca-nss-ovpn-mgr.ko +endef + +define KernelPackage/qca-nss-drv-ovpn-mgr/description +Kernel module for NSS OpenVPN manager +endef + +define KernelPackage/qca-nss-drv-ovpn-link + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for interfacing NSS OpenVPN manager with ECM + DEPENDS:=@(TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_64||TARGET_ipq807x||TARGET_qualcommax||TARGET_ipq_ipq60xx||TARGET_ipq_ipq60xx_64||TARGET_ipq60xx) \ + +kmod-qca-nss-drv-ovpn-mgr \ + +@PACKAGE_kmod-qca-nss-ecm + FILES:=$(PKG_BUILD_DIR)/openvpn/plugins/qca-nss-ovpn-link.ko +endef + +define KernelPackage/qca-nss-drv-ovpn-link/description +This module registers with ECM and communicates with NSS OpenVPN manager for supporting OpenVPN offload. +endef + +define KernelPackage/qca-nss-drv-pvxlanmgr + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + DEPENDS:=+@NSS_DRV_PVXLAN_ENABLE \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv + TITLE:=NSS PVXLAN Manager for QCA NSS driver + FILES:=$(PKG_BUILD_DIR)/pvxlanmgr/qca-nss-pvxlanmgr.ko +endef + +define KernelPackage/qca-nss-drv-pvxlanmgr/description +Kernel module for managing NSS PVxLAN +endef + +define KernelPackage/qca-nss-drv-eogremgr + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + DEPENDS:=+@NSS_DRV_GRE_ENABLE \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv \ + +kmod-qca-nss-drv-gre + TITLE:=NSS EOGRE Manager for QCA NSS driver + FILES:=$(PKG_BUILD_DIR)/eogremgr/qca-nss-eogremgr.ko +endef + +define KernelPackage/qca-nss-drv-eogremgr/description +Kernel module for managing NSS EoGRE +endef + +define KernelPackage/qca-nss-drv-clmapmgr + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + DEPENDS:=+@NSS_DRV_CLMAP_ENABLE \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv \ + +kmod-qca-nss-drv-eogremgr + TITLE:=NSS clmap Manager for QCA NSS driver + FILES:=$(PKG_BUILD_DIR)/clmapmgr/qca-nss-clmapmgr.ko +endef + +define KernelPackage/qca-nss-drv-clmapmgr/description +Kernel module for managing NSS clmap +endef + +define KernelPackage/qca-nss-drv-lag-mgr + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for NSS LAG manager + DEPENDS:=+@NSS_DRV_LAG_ENABLE \ + +TARGET_ipq_ipq807x:kmod-qca-nss-drv-vlan-mgr \ + +TARGET_ipq_ipq807x_64:kmod-qca-nss-drv-vlan-mgr \ + +TARGET_ipq807x:kmod-qca-nss-drv-vlan-mgr \ + +TARGET_qualcommax:kmod-qca-nss-drv-vlan-mgr \ + +TARGET_ipq_ipq60xx:kmod-qca-nss-drv-vlan-mgr \ + +TARGET_ipq_ipq60xx_64:kmod-qca-nss-drv-vlan-mgr \ + +TARGET_ipq60xx:kmod-qca-nss-drv-vlan-mgr \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv \ + +PACKAGE_kmod-bonding:kmod-bonding + FILES:=$(PKG_BUILD_DIR)/lag/qca-nss-lag-mgr.ko + AUTOLOAD:=$(call AutoLoad,51,qca-nss-lag-mgr) +endef + +define KernelPackage/qca-nss-drv-lag-mgr/description +Kernel modules for NSS LAG manager +endef + +define KernelPackage/qca-nss-drv-vxlanmgr + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + DEPENDS:=+@NSS_DRV_VXLAN_ENABLE +@NSS_DRV_PVXLAN_ENABLE +kmod-vxlan \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv + TITLE:=NSS VxLAN Manager for QCA NSS driver + FILES:=$(PKG_BUILD_DIR)/vxlanmgr/qca-nss-vxlanmgr.ko + AUTOLOAD:=$(call AutoLoad,51,qca-nss-vxlanmgr) +endef + +define KernelPackage/qca-nss-drv-vxlanmgr/description +Kernel module for managing NSS VxLAN +endef + +define KernelPackage/qca-nss-drv-vlan-mgr + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Kernel driver for NSS vlan manager + DEPENDS:=@(TARGET_ipq_ipq807x||TARGET_ipq_ipq806x||TARGET_ipq807x||TARGET_qualcommax||TARGET_ipq_ipq60xx||TARGET_ipq_ipq60xx_64||TARGET_ipq60xx) \ + +@NSS_DRV_VLAN_ENABLE \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv \ + +PACKAGE_kmod-bonding:kmod-bonding + FILES:=$(PKG_BUILD_DIR)/vlan/qca-nss-vlan.ko + AUTOLOAD:=$(call AutoLoad,51,qca-nss-vlan) +endef + +define KernelPackage/qca-nss-drv-vlan-mgr/Description +Kernel modules for NSS vlan manager +endef + +define KernelPackage/qca-nss-drv-igs + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Support + TITLE:=Action for offloading traffic to an IFB interface to perform ingress shaping. + DEPENDS:=@(TARGET_ipq806x||TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_64||TARGET_ipq807x||TARGET_qualcommax||TARGET_ipq_ipq60xx||TARGET_ipq_ipq60xx_64||TARGET_ipq60xx||TARGET_ipq_ipq50xx||TARGET_ipq_ipq50xx_64||TARGET_ipq50xx) \ + +@NSS_DRV_IGS_ENABLE +kmod-sched-core +kmod-nf-conntrack +kmod-ifb +kmod-qca-nss-drv-qdisc \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv + FILES:=$(PKG_BUILD_DIR)/nss_qdisc/igs/act_nssmirred.ko +endef + +define KernelPackage/qca-nss-drv-igs/description +Linux action that helps in offloading traffic to an IFB interface to perform ingress shaping. +endef + +define KernelPackage/qca-nss-drv-match + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + DEPENDS:=+@NSS_DRV_MATCH_ENABLE \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv + TITLE:=NSS Match for QCA NSS driver + FILES:=$(PKG_BUILD_DIR)/match/qca-nss-match.ko +endef + +define KernelPackage/qca-nss-drv-match/description +Kernel module for managing NSS Match +endef + +define KernelPackage/qca-nss-drv-mirror + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Support + TITLE:=Module for mirroring packets from NSS to host. + DEPENDS:=+@NSS_DRV_MIRROR_ENABLE \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv + FILES:=$(PKG_BUILD_DIR)/mirror/qca-nss-mirror.ko +endef + +define KernelPackage/qca-nss-drv-mirror/Description +Kernel module for managing NSS Mirror +endef + +define KernelPackage/qca-nss-drv-netlink + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=NSS NETLINK Manager for QCA NSS driver + DEPENDS:=@(TARGET_ipq806x||TARGET_ipq807x||TARGET_ipq_ipq807x_64||TARGET_qualcommax||TARGET_ipq_ipq60xx||TARGET_ipq_ipq60xx_64||TARGET_ipq60xx||TARGET_ipq_ipq50xx||TARGET_ipq_ipq50xx_64||TARGET_ipq50xx) \ + +@NSS_DRV_C2C_ENABLE +@NSS_DRV_GRE_REDIR_ENABLE +@NSS_DRV_IPV4_REASM_ENABLE +@NSS_DRV_IPV6_ENABLE +@NSS_DRV_IPV6_REASM_ENABLE +@NSS_DRV_RMNET_ENABLE +@NSS_DRV_OAM_ENABLE +@NSS_DRV_QRFS_ENABLE \ + +kmod-pppoe +kmod-qca-nss-drv-dtlsmgr \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv + FILES:=$(PKG_BUILD_DIR)/netlink/qca-nss-netlink.ko +endef + +define KernelPackage/qca-nss-drv-netlink/Description +Kernel module for NSS netlink manager +endef + +define KernelPackage/qca-nss-drv-qdisc + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Support + TITLE:=Qdisc for configuring shapers in NSS + DEPENDS:=+@NSS_DRV_SHAPER_ENABLE +@NSS_DRV_IGS_ENABLE \ + +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv + FILES:=$(PKG_BUILD_DIR)/nss_qdisc/qca-nss-qdisc.ko + KCONFIG:=CONFIG_NET_CLS_ACT=y + AUTOLOAD:=$(call AutoLoad,58,qca-nss-qdisc) +endef + +define KernelPackage/qca-nss-drv-qdisc/Description +Linux qdisc that aids in configuring shapers in the NSS +endef + +define Build/InstallDev + mkdir -p $(1)/usr/include/qca-nss-clients + $(CP) $(PKG_BUILD_DIR)/netlink/include/* $(1)/usr/include/qca-nss-clients/ + $(CP) $(PKG_BUILD_DIR)/exports/* $(1)/usr/include/qca-nss-clients/ +endef + +define KernelPackage/qca-nss-drv-ovpn-mgr/install + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/qca-nss-ovpn.init $(1)/etc/init.d/qca-nss-ovpn +endef + +define KernelPackage/qca-nss-drv-ipsecmgr/install + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/qca-nss-ipsec $(1)/etc/init.d/qca-nss-ipsec +endef + +define KernelPackage/qca-nss-drv-igs/install + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/qca-nss-mirred.init $(1)/etc/init.d/qca-nss-mirred +endef + +define KernelPackage/qca-nss-drv-netlink/install + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/qca-nss-netlink.init $(1)/etc/init.d/qca-nss-netlink +endef + +EXTRA_CFLAGS+= \ + -I$(STAGING_DIR)/usr/include/qca-nss-drv \ + -I$(STAGING_DIR)/usr/include/qca-nss-crypto \ + -I$(STAGING_DIR)/usr/include/qca-nss-cfi \ + -I$(STAGING_DIR)/usr/include/qca-nss-ecm \ + -I$(STAGING_DIR)/usr/include/qca-ssdk \ + -I$(STAGING_DIR)/usr/include/qca-ssdk/fal \ + -I$(STAGING_DIR)/usr/include/nat46 + +# Build individual packages if selected +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-tun6rd),) +NSS_CLIENTS_MAKE_OPTS+=tun6rd=m +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-dtlsmgr),) +NSS_CLIENTS_MAKE_OPTS+=dtlsmgr=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-tlsmgr),) +EXTRA_CFLAGS+= -I$(PKG_BUILD_DIR)/exports +NSS_CLIENTS_MAKE_OPTS+=tlsmgr=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-l2tpv2),) +NSS_CLIENTS_MAKE_OPTS+=l2tpv2=y +EXTRA_CFLAGS += -DNSS_L2TPV2_ENABLED +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-gre),) +EXTRA_CFLAGS+= -I$(PKG_BUILD_DIR)/exports +NSS_CLIENTS_MAKE_OPTS+=gre=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-pppoe),) +NSS_CLIENTS_MAKE_OPTS+=pppoe=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-bridge-mgr),) +NSS_CLIENTS_MAKE_OPTS+=bridge-mgr=y +#enable OVS bridge if ovsmgr is enabled +ifneq ($(CONFIG_PACKAGE_kmod-qca-ovsmgr),) +NSS_CLIENTS_MAKE_OPTS+= NSS_BRIDGE_MGR_OVS_ENABLE=y +EXTRA_CFLAGS+= -I$(STAGING_DIR)/usr/include/qca-ovsmgr +endif +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-ipsecmgr),) +EXTRA_CFLAGS+= -I$(PKG_BUILD_DIR)/exports \ + -I$(STAGING_DIR)/usr/include/qca-nss-ecm +NSS_CLIENTS_MAKE_OPTS+=ipsecmgr=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-vlan-mgr),) +NSS_CLIENTS_MAKE_OPTS+=vlan-mgr=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-lag-mgr),) +NSS_CLIENTS_MAKE_OPTS+=lag-mgr=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-pvxlanmgr),) +# The memset() call in nss_pvxlanmgr_get_tunnel_stats +# triggers a compilation error with GCC 13, most likely +# it is a false positive, disable the warning for now. +EXTRA_CFLAGS+= -Wno-stringop-overread +NSS_CLIENTS_MAKE_OPTS+=pvxlanmgr=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-clmapmgr),) +NSS_CLIENTS_MAKE_OPTS+=clmapmgr=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-eogremgr),) +NSS_CLIENTS_MAKE_OPTS+=eogremgr=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-vlan-mgr),) +NSS_CLIENTS_MAKE_OPTS+=vlan-mgr=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-vxlanmgr),) +NSS_CLIENTS_MAKE_OPTS+=vxlanmgr=y +EXTRA_CFLAGS += -DNSS_VXLAN_ENABLED +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-pptp),) +NSS_CLIENTS_MAKE_OPTS+=pptp=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-map-t),) +NSS_CLIENTS_MAKE_OPTS+=map-t=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-ovpn-mgr),) +NSS_CLIENTS_MAKE_OPTS+=ovpn-mgr=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-ovpn-link),) +NSS_CLIENTS_MAKE_OPTS+=ovpn-link=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-tunipip6),) +NSS_CLIENTS_MAKE_OPTS+=tunipip6=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-igs),) +NSS_CLIENTS_MAKE_OPTS+=igs=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-netlink),) +NSS_CLIENTS_MAKE_OPTS+=netlink=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-qdisc),) +NSS_CLIENTS_MAKE_OPTS+=qdisc=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-match),) +NSS_CLIENTS_MAKE_OPTS+=match=y +endif + +define Build/Compile + +$(MAKE) -C "$(LINUX_DIR)" $(strip $(NSS_CLIENTS_MAKE_OPTS)) \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + ARCH="$(LINUX_KARCH)" \ + M="$(PKG_BUILD_DIR)" \ + EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ + DTLSMGR_DIR="$(DTLSMGR_DIR)" \ + IPSECMGR_DIR="$(IPSECMGR_DIR)" \ + SoC=$(SOC) \ + $(KERNEL_MAKE_FLAGS) \ + modules +endef + +$(eval $(call KernelPackage,qca-nss-drv-gre)) +$(eval $(call KernelPackage,qca-nss-drv-l2tpv2)) +$(eval $(call KernelPackage,qca-nss-drv-pptp)) +$(eval $(call KernelPackage,qca-nss-drv-pppoe)) +$(eval $(call KernelPackage,qca-nss-drv-ipsecmgr)) +$(eval $(call KernelPackage,qca-nss-drv-bridge-mgr)) +$(eval $(call KernelPackage,qca-nss-drv-clmapmgr)) +$(eval $(call KernelPackage,qca-nss-drv-eogremgr)) +$(eval $(call KernelPackage,qca-nss-drv-lag-mgr)) +$(eval $(call KernelPackage,qca-nss-drv-vlan-mgr)) +$(eval $(call KernelPackage,qca-nss-drv-vxlanmgr)) +$(eval $(call KernelPackage,qca-nss-drv-pvxlanmgr)) +$(eval $(call KernelPackage,qca-nss-drv-ovpn-mgr)) +$(eval $(call KernelPackage,qca-nss-drv-ovpn-link)) +$(eval $(call KernelPackage,qca-nss-drv-dtlsmgr)) +$(eval $(call KernelPackage,qca-nss-drv-tlsmgr)) +$(eval $(call KernelPackage,qca-nss-drv-match)) +$(eval $(call KernelPackage,qca-nss-drv-map-t)) +$(eval $(call KernelPackage,qca-nss-drv-tunipip6)) +$(eval $(call KernelPackage,qca-nss-drv-tun6rd)) +$(eval $(call KernelPackage,qca-nss-drv-qdisc)) +$(eval $(call KernelPackage,qca-nss-drv-igs)) +$(eval $(call KernelPackage,qca-nss-drv-netlink)) diff --git a/lede/package/qca/qca-nss-clients/files/qca-nss-ipsec b/lede/package/qca/qca-nss-clients/files/qca-nss-ipsec new file mode 100755 index 0000000000..21eea7c4c1 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/files/qca-nss-ipsec @@ -0,0 +1,231 @@ +#!/bin/sh /etc/rc.common +# +# Copyright (c) 2018-2019, 2021 The Linux Foundation. All rights reserved. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +NSS_IPSEC_LOG_FILE=/tmp/.nss_ipsec_log +NSS_IPSEC_LOG_STR_ECM="ECM_Loaded" +NSS_IPSEC_OL_FILE=/tmp/qca_nss_ipsec_ol + +ecm_load () { + if [ ! -d /sys/module/ecm ]; then + /etc/init.d/qca-nss-ecm start + if [ -d /sys/module/ecm ]; then + echo ${NSS_IPSEC_LOG_STR_ECM} >> ${NSS_IPSEC_LOG_FILE} + fi + fi +} + +ecm_unload () { + if [ -f /tmp/.nss_ipsec_log ]; then + str=`grep ${NSS_IPSEC_LOG_STR_ECM} ${NSS_IPSEC_LOG_FILE}` + if [[ $str == ${NSS_IPSEC_LOG_STR_ECM} ]]; then + /etc/init.d/qca-nss-ecm stop + `sed 's/${NSS_IPSEC_LOG_STR_ECM}/ /g' $NSS_IPSEC_LOG_FILE > $NSS_IPSEC_LOG_FILE` + fi + fi +} + +ecm_disable() { + if [ ! -d /sys/module/ecm ]; then + return; + fi + + echo 1 > /sys/kernel/debug/ecm/front_end_ipv4_stop + echo 1 > /sys/kernel/debug/ecm/front_end_ipv6_stop + echo 1 > /sys/kernel/debug/ecm/ecm_db/defunct_all + sleep 2 +} + +ecm_enable() { + if [ ! -d /sys/module/ecm ]; then + return; + fi + + echo 0 > /sys/kernel/debug/ecm/ecm_db/defunct_all + echo 0 > /sys/kernel/debug/ecm/front_end_ipv4_stop + echo 0 > /sys/kernel/debug/ecm/front_end_ipv6_stop +} + +kernel_version_check_5_4() { + major_ver=$(uname -r | awk -F '.' '{print $1}') + minor_ver=$(uname -r | awk -F '.' '{print $2}') + if [ $major_ver -lt 5 ] || ([ $major_ver -eq 5 ] && [ $minor_ver -lt 4 ] ); then + return 1 + else + return 0 + fi +} + +kernel_version_check_5_15() { + major_ver=$(uname -r | awk -F '.' '{print $1}') + minor_ver=$(uname -r | awk -F '.' '{print $2}') + if [ $major_ver -lt 5 ] || ([ $major_ver -eq 5 ] && [ $minor_ver -lt 15 ] ); then + return 1 + else + return 0 + fi +} + +start_klips() { + if kernel_version_check_5_4; then + echo "Kernel 5.4 doesn't support klips stack." + return $? + fi + + if kernel_version_check_5_15; then + echo "Kernel 5.15 doesn't support klips stack." + return $? + fi + + touch $NSS_IPSEC_OL_FILE + ecm_load + + local kernel_version=$(uname -r) + + insmod /lib/modules/${kernel_version}/qca-nss-ipsec-klips.ko + if [ "$?" -gt 0 ]; then + echo "Failed to load plugin. Please start ecm if not done already" + ecm_enable + rm $NSS_IPSEC_OL_FILE + return + fi + + /etc/init.d/ipsec start + sleep 2 + ipsec eroute + + ecm_enable +} + +stop_klips() { + if kernel_version_check_5_4; then + echo "Kernel 5.4 doesn't support klips stack." + return $? + fi + + if kernel_version_check_5_15; then + echo "Kernel 5.15 doesn't support klips stack." + return $? + fi + + ecm_disable + + /etc/init.d/ipsec stop + rmmod qca-nss-ipsec-klips + rm $NSS_IPSEC_OL_FILE + + ecm_unload +} + +start_xfrm() { + touch $NSS_IPSEC_OL_FILE + ecm_load + + local kernel_version=$(uname -r) + + # load all NETKEY modules first. + for mod in xfrm_ipcomp ipcomp xfrm6_tunnel ipcomp6 xfrm6_mode_tunnel xfrm6_mode_beet xfrm6_mode_ro \ + xfrm6_mode_transport xfrm4_mode_transport xfrm4_mode_tunnel \ + xfrm4_tunnel xfrm4_mode_beet esp4 esp6 ah4 ah6 af_key + do + insmod $mod 2> /dev/null + done + + # Now load the xfrm plugin + insmod /lib/modules/${kernel_version}/qca-nss-ipsec-xfrm.ko + if [ "$?" -gt 0 ]; then + echo "Failed to load plugin. Please start ecm if not done already" + ecm_enable + rm $NSS_IPSEC_OL_FILE + return + fi + + /etc/init.d/ipsec start + sleep 2 + + ecm_enable +} + +stop_xfrm() { + ecm_disable + + #Shutdown Pluto first. Then only plugin can be removed. + plutopid=/var/run/pluto/pluto.pid + if [ -f $plutopid ]; then + pid=`cat $plutopid` + if [ ! -z "$pid" ]; then + ipsec whack --shutdown | grep -v "002"; + if [ -s $plutopid ]; then + echo "Attempt to shut Pluto down failed! Trying kill:" + kill $pid; + sleep 5; + fi + fi + rm -rf $plutopid + fi + ip xfrm state flush; + ip xfrm policy flush; + sleep 2 + + #Now we can remove the plugin + retries=5 + while [ -d /sys/module/qca_nss_ipsec_xfrm ] + do + rmmod qca-nss-ipsec-xfrm + if [ "$?" -eq 0 ]; then + rm $NSS_IPSEC_OL_FILE + break + fi + + if [ ${retries} -eq 0 ]; then + echo "Failed to unload qca-nss-ipsec-xfrm plugin!" + exit + fi + + echo "XFRM plugin unload failed; retrying ${retries} times" + sleep 1 + retries=`expr ${retries} - 1` + done + + /etc/init.d/ipsec stop + ecm_unload +} + +start() { + local protostack=`uci -q get ipsec.setup.protostack` + if [ "$protostack" = "klips" ]; then + start_klips + return $? + fi + + start_xfrm + return $? +} + +stop() { + local protostack=`uci -q get ipsec.setup.protostack` + if [ "$protostack" = "klips" ]; then + stop_klips + return $? + fi + + stop_xfrm + return $? +} + +restart() { + stop + start +} diff --git a/lede/package/qca/qca-nss-clients/files/qca-nss-mirred.init b/lede/package/qca/qca-nss-clients/files/qca-nss-mirred.init new file mode 100644 index 0000000000..259aaa0908 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/files/qca-nss-mirred.init @@ -0,0 +1,28 @@ +#!/bin/sh /etc/rc.common + +########################################################################### +# Copyright (c) 2019, The Linux Foundation. All rights reserved. +# Permission to use, copy, modify, and/or distribute this software for +# any purpose with or without fee is hereby granted, provided that the +# above copyright notice and this permission notice appear in all copies. +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +########################################################################### + +start() { + insmod act_nssmirred.ko +} + +stop() { + rmmod act_nssmirred.ko +} + +restart() { + stop + start +} diff --git a/lede/package/qca/qca-nss-clients/files/qca-nss-netlink.init b/lede/package/qca/qca-nss-clients/files/qca-nss-netlink.init new file mode 100644 index 0000000000..8d38ad33f7 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/files/qca-nss-netlink.init @@ -0,0 +1,31 @@ +#!/bin/sh /etc/rc.common +# +# Copyright (c) 2023, The Linux Foundation. All rights reserved. +# +# Permission to use, copy, modify, and/or distribute this software for +# any purpose with or without fee is hereby granted, provided that the +# above copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +start() { + modprobe qca-nss-netlink + + echo 2048 > /proc/sys/dev/nss/n2hcfg/n2h_queue_limit_core0 + echo 2048 > /proc/sys/dev/nss/n2hcfg/n2h_queue_limit_core1 +} + +stop() { + rmmod qca-nss-netlink.ko +} + +restart() { + stop + start +} diff --git a/lede/package/qca/qca-nss-clients/files/qca-nss-ovpn.init b/lede/package/qca/qca-nss-clients/files/qca-nss-ovpn.init new file mode 100644 index 0000000000..622e295eee --- /dev/null +++ b/lede/package/qca/qca-nss-clients/files/qca-nss-ovpn.init @@ -0,0 +1,69 @@ +#!/bin/sh /etc/rc.common + +########################################################################### +# Copyright (c) 2019, The Linux Foundation. All rights reserved. +# Permission to use, copy, modify, and/or distribute this software for +# any purpose with or without fee is hereby granted, provided that the +# above copyright notice and this permission notice appear in all copies. +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +########################################################################### + +ecm_disable() { + if [ ! -d /sys/module/ecm ]; then + return + fi + + echo 1 > /sys/kernel/debug/ecm/front_end_ipv4_stop + echo 1 > /sys/kernel/debug/ecm/front_end_ipv6_stop + echo 1 > /sys/kernel/debug/ecm/ecm_db/defunct_all + sleep 2 +} + +ecm_enable() { + if [ ! -d /sys/module/ecm ]; then + return + fi + + echo 0 > /sys/kernel/debug/ecm/ecm_db/defunct_all + echo 0 > /sys/kernel/debug/ecm/front_end_ipv4_stop + echo 0 > /sys/kernel/debug/ecm/front_end_ipv6_stop +} + +restart() { + ecm_disable + + /etc/init.d/openvpn stop + rmmod qca-nss-ovpn-link + rmmod qca-nss-ovpn-mgr + + insmod qca-nss-ovpn-mgr + insmod qca-nss-ovpn-link + + if [ "$?" -gt 0 ]; then + echo "Failed to load plugin. Please start ecm if not done already" + ecm_enable + return + fi + + ecm_enable +} + +start() { + restart +} + +stop() { + ecm_disable + + /etc/init.d/openvpn stop + rmmod qca-nss-ovpn-link + rmmod qca-nss-ovpn-mgr + + ecm_enable +} diff --git a/lede/package/qca/qca-nss-clients/patches/0001-kernel-5.15-support-qdisc.patch b/lede/package/qca/qca-nss-clients/patches/0001-kernel-5.15-support-qdisc.patch new file mode 100644 index 0000000000..97479d9b93 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0001-kernel-5.15-support-qdisc.patch @@ -0,0 +1,162 @@ +--- a/nss_qdisc/igs/nss_mirred.c ++++ b/nss_qdisc/igs/nss_mirred.c +@@ -82,20 +82,24 @@ static const struct nla_policy nss_mirre + * nss_mirred_init() + * Initialize the nss mirred action. + */ +-#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + static int nss_mirred_init(struct net *net, struct nlattr *nla, +- struct nlattr *est, struct tc_action *tc_act, int ovr, +- int bind) ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) ++ struct nlattr *est, struct tc_action *tc_act, int ovr, ++ int bind) ++{ ++#elif (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) ++ struct nlattr *est, struct tc_action **tc_act, int ovr, ++ int bind, bool rtnl_held, struct tcf_proto *tp, ++ u32 flags, struct netlink_ext_ack *extack) + { + #else +-static int nss_mirred_init(struct net *net, struct nlattr *nla, +- struct nlattr *est, struct tc_action **tc_act, int ovr, +- int bind, bool rtnl_held, struct tcf_proto *tp, +- struct netlink_ext_ack *extack) ++ struct nlattr *est, struct tc_action **tc_act, ++ struct tcf_proto *tp, u32 flags, struct netlink_ext_ack *extack) + { ++ bool bind = flags & TCA_ACT_FLAGS_BIND; ++#endif + struct tc_action_net *tn = net_generic(net, nss_mirred_net_id); + u32 index; +-#endif + struct nlattr *arr[TC_NSS_MIRRED_MAX + 1]; + struct tc_nss_mirred *parm; + struct nss_mirred_tcf *act; +@@ -239,8 +243,13 @@ static int nss_mirred_init(struct net *n + } + + if (!ret) { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0)) + ret = tcf_idr_create(tn, index, est, tc_act, &nss_mirred_act_ops, + bind, true); ++#else ++ ret = tcf_idr_create(tn, index, est, tc_act, &nss_mirred_act_ops, ++ bind, true, 0); ++#endif + if (ret) { + tcf_idr_cleanup(tn, index); + return ret; +--- a/nss_qdisc/nss_bf.c ++++ b/nss_qdisc/nss_bf.c +@@ -74,7 +74,7 @@ static inline struct nss_bf_class_data * + */ + #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_bf_change_class(struct Qdisc *sch, u32 classid, u32 parentid, +- struct nlattr **tca, unsigned long *arg) ++ struct nlattr **tca, unsigned long *arg, struct netlink_ext_ack *extack) + { + struct netlink_ext_ack *extack = NULL; + #else +@@ -290,7 +290,11 @@ static void nss_bf_destroy_class(struct + * nss_bf_delete_class() + * Detaches a class from operation, but does not destroy it. + */ ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)) ++static int nss_bf_delete_class(struct Qdisc *sch, unsigned long arg, struct netlink_ext_ack *extack) ++#else + static int nss_bf_delete_class(struct Qdisc *sch, unsigned long arg) ++#endif + { + struct nss_bf_sched_data *q = qdisc_priv(sch); + struct nss_bf_class_data *cl = (struct nss_bf_class_data *)arg; +--- a/nss_qdisc/nss_htb.c ++++ b/nss_qdisc/nss_htb.c +@@ -282,7 +282,7 @@ static int nss_htb_ppe_change_class(stru + */ + #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_htb_change_class(struct Qdisc *sch, u32 classid, u32 parentid, +- struct nlattr **tca, unsigned long *arg) ++ struct nlattr **tca, unsigned long *arg, struct netlink_ext_ack *extack) + { + struct netlink_ext_ack *extack = NULL; + #else +@@ -516,7 +516,11 @@ static void nss_htb_destroy_class(struct + * nss_htb_delete_class() + * Detaches a class from operation, but does not destroy it. + */ ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)) ++static int nss_htb_delete_class(struct Qdisc *sch, unsigned long arg, struct netlink_ext_ack *extack) ++#else + static int nss_htb_delete_class(struct Qdisc *sch, unsigned long arg) ++#endif + { + struct nss_htb_sched_data *q = qdisc_priv(sch); + struct nss_htb_class_data *cl = (struct nss_htb_class_data *)arg; +--- a/nss_qdisc/nss_qdisc.c ++++ b/nss_qdisc/nss_qdisc.c +@@ -1140,15 +1140,16 @@ unsigned int nss_qdisc_drop(struct Qdisc + { + struct nss_qdisc *nq = qdisc_priv(sch); + unsigned int ret; ++ struct sk_buff *to_free = qdisc_peek_head(sch); + + if (!nq->is_virtual) { +- ret = __qdisc_queue_drop_head(sch, &sch->q); ++ ret = __qdisc_queue_drop_head(sch, &sch->q, &to_free); + } else { + spin_lock_bh(&nq->bounce_protection_lock); + /* + * This function is safe to call within locks + */ +- ret = __qdisc_queue_drop_head(sch, &sch->q); ++ ret = __qdisc_queue_drop_head(sch, &sch->q, &to_free); + spin_unlock_bh(&nq->bounce_protection_lock); + } + +@@ -1209,10 +1210,10 @@ static bool nss_qdisc_iterate_fl(struct + return 0; + } + +-#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) +- status = tc_classify(skb, tcf, &res, false); +-#else ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) + status = tcf_classify(skb, tcf, &res, false); ++#else ++ status = tcf_classify(skb, NULL, tcf, &res, false); + #endif + if ((status == TC_ACT_STOLEN) || (status == TC_ACT_QUEUED)) { + return 1; +@@ -2188,6 +2189,8 @@ int __nss_qdisc_init(struct Qdisc *sch, + * This is to prevent mixing NSS and PPE qdisc with linux qdisc. + */ + if ((parent != TC_H_ROOT) && (root->ops->owner != THIS_MODULE)) { ++ nss_qdisc_warning("parent (%d) and TC_H_ROOT (%d))", parent, TC_H_ROOT); ++ nss_qdisc_warning("root->ops->owner (%px) and THIS_MODULE (%px))", root->ops->owner , THIS_MODULE); + nss_qdisc_warning("NSS qdisc %px (type %d) used along with non-nss qdiscs," + " or the interface is currently down", nq->qdisc, nq->type); + } +--- a/nss_qdisc/nss_wrr.c ++++ b/nss_qdisc/nss_wrr.c +@@ -229,7 +229,7 @@ static int nss_wrr_ppe_change_class(stru + + #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_wrr_change_class(struct Qdisc *sch, u32 classid, u32 parentid, +- struct nlattr **tca, unsigned long *arg) ++ struct nlattr **tca, unsigned long *arg, struct netlink_ext_ack *extack) + { + struct netlink_ext_ack *extack = NULL; + #else +@@ -400,7 +400,11 @@ failure: + return -EINVAL; + } + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)) ++static int nss_wrr_delete_class(struct Qdisc *sch, unsigned long arg, struct netlink_ext_ack *extack) ++#else + static int nss_wrr_delete_class(struct Qdisc *sch, unsigned long arg) ++#endif + { + struct nss_wrr_sched_data *q = qdisc_priv(sch); + struct nss_wrr_class_data *cl = (struct nss_wrr_class_data *)arg; diff --git a/lede/package/qca/qca-nss-clients/patches/0002-kernel-5.4-support-gre.patch b/lede/package/qca/qca-nss-clients/patches/0002-kernel-5.4-support-gre.patch new file mode 100644 index 0000000000..7ed66bd45e --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0002-kernel-5.4-support-gre.patch @@ -0,0 +1,31 @@ +--- a/gre/nss_connmgr_gre_v6.c ++++ b/gre/nss_connmgr_gre_v6.c +@@ -95,7 +95,8 @@ static int nss_connmgr_gre_v6_get_mac_ad + /* + * Find src MAC address + */ +- local_dev = (struct net_device *)ipv6_dev_find(&init_net, &src_addr, 1); ++ local_dev = NULL; ++ local_dev = (struct net_device *)ipv6_dev_find(&init_net, &src_addr, local_dev); + if (!local_dev) { + nss_connmgr_gre_warning("Unable to find local dev for %pI6", src_ip); + return GRE_ERR_NO_LOCAL_NETDEV; +--- a/gre/test/nss_connmgr_gre_test.c ++++ b/gre/test/nss_connmgr_gre_test.c +@@ -229,10 +229,12 @@ static int nss_connmgr_gre_test_open_pro + /* + * Proc ops + */ +-static const struct file_operations nss_connmgr_gre_test_proc_ops = { +- .open = nss_connmgr_gre_test_open_proc, +- .write = nss_connmgr_gre_test_write_proc, +- .read = seq_read, ++static const struct proc_ops nss_connmgr_gre_test_proc_ops = { ++ .proc_open = nss_connmgr_gre_test_open_proc, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, ++ .proc_write = nss_connmgr_gre_test_write_proc, + }; + + /* diff --git a/lede/package/qca/qca-nss-clients/patches/0003-kernel-5.4-support-ipsec.patch b/lede/package/qca/qca-nss-clients/patches/0003-kernel-5.4-support-ipsec.patch new file mode 100644 index 0000000000..de43b4d01d --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0003-kernel-5.4-support-ipsec.patch @@ -0,0 +1,29 @@ +--- a/ipsecmgr/v1.0/nss_ipsecmgr.c ++++ b/ipsecmgr/v1.0/nss_ipsecmgr.c +@@ -377,7 +377,7 @@ free: + * nss_ipsecmgr_tunnel_stats() + * get tunnel statistics + */ +-static struct rtnl_link_stats64 *nss_ipsecmgr_tunnel_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) ++void nss_ipsecmgr_tunnel_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) + { + struct nss_ipsecmgr_priv *priv = netdev_priv(dev); + +@@ -389,8 +389,6 @@ static struct rtnl_link_stats64 *nss_ips + read_lock_bh(&ipsecmgr_ctx->lock); + memcpy(stats, &priv->stats, sizeof(struct rtnl_link_stats64)); + read_unlock_bh(&ipsecmgr_ctx->lock); +- +- return stats; + } + + /* +@@ -442,7 +440,7 @@ static void nss_ipsecmgr_tunnel_setup(st + dev->header_ops = NULL; + dev->netdev_ops = &nss_ipsecmgr_tunnel_ops; + +- dev->destructor = nss_ipsecmgr_tunnel_free; ++ dev->priv_destructor = nss_ipsecmgr_tunnel_free; + + /* + * get the MAC address from the ethernet device diff --git a/lede/package/qca/qca-nss-clients/patches/0004-kernel-5.4-support-dtls.patch b/lede/package/qca/qca-nss-clients/patches/0004-kernel-5.4-support-dtls.patch new file mode 100644 index 0000000000..ae9c914701 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0004-kernel-5.4-support-dtls.patch @@ -0,0 +1,11 @@ +--- a/dtls/v1.0/nss_connmgr_dtls_netdev.c ++++ b/dtls/v1.0/nss_connmgr_dtls_netdev.c +@@ -160,7 +160,7 @@ static void nss_dtlsmgr_dev_setup(struct + dev->ethtool_ops = NULL; + dev->header_ops = NULL; + dev->netdev_ops = &nss_dtlsmgr_session_ops; +- dev->destructor = NULL; ++ dev->priv_destructor = NULL; + + memcpy(dev->dev_addr, "\xaa\xbb\xcc\xdd\xee\xff", dev->addr_len); + memset(dev->broadcast, 0xff, dev->addr_len); diff --git a/lede/package/qca/qca-nss-clients/patches/0005-vlanmgr-fix-compile-error.patch b/lede/package/qca/qca-nss-clients/patches/0005-vlanmgr-fix-compile-error.patch new file mode 100644 index 0000000000..13fb7673b6 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0005-vlanmgr-fix-compile-error.patch @@ -0,0 +1,59 @@ +--- a/vlan/nss_vlan_mgr.c ++++ b/vlan/nss_vlan_mgr.c +@@ -800,8 +800,10 @@ static struct nss_vlan_pvt *nss_vlan_mgr + */ + static void nss_vlan_mgr_instance_free(struct nss_vlan_pvt *v) + { ++#ifdef NSS_VLAN_MGR_PPE_SUPPORT + int32_t i; + int ret = 0; ++#endif + + spin_lock(&vlan_mgr_ctx.lock); + BUG_ON(--v->refs); +@@ -961,8 +963,11 @@ static int nss_vlan_mgr_register_event(s + int ret; + #endif + uint32_t vlan_tag; ++#ifdef NSS_VLAN_MGR_PPE_SUPPORT + struct net_device *slave; +- int32_t port, port_if; ++ int32_t port; ++#endif ++ int32_t port_if; + struct vlan_dev_priv *vlan; + struct net_device *real_dev; + bool is_bond_master = false; +@@ -1355,8 +1360,10 @@ return_with_error: + int nss_vlan_mgr_join_bridge(struct net_device *dev, uint32_t bridge_vsi) + { + struct nss_vlan_pvt *v = nss_vlan_mgr_instance_find_and_ref(dev); ++#ifdef NSS_VLAN_MGR_PPE_SUPPORT + struct net_device *real_dev; + int ret; ++#endif + + if (!v) + return 0; +@@ -1416,8 +1423,10 @@ EXPORT_SYMBOL(nss_vlan_mgr_join_bridge); + int nss_vlan_mgr_leave_bridge(struct net_device *dev, uint32_t bridge_vsi) + { + struct nss_vlan_pvt *v = nss_vlan_mgr_instance_find_and_ref(dev); ++#ifdef NSS_VLAN_MGR_PPE_SUPPORT + struct net_device *real_dev; + int ret; ++#endif + + if (!v) + return 0; +--- a/vlan/Makefile ++++ b/vlan/Makefile +@@ -8,7 +8,7 @@ ifeq ($(SoC),$(filter $(SoC),ipq807x ipq + ccflags-y += -DNSS_VLAN_MGR_PPE_SUPPORT + endif + +-ccflags-y += -DNSS_VLAN_MGR_DEBUG_LEVEL=0 ++ccflags-y += -DNSS_VLAN_MGR_DEBUG_LEVEL=4 + ccflags-y += -Wall -Werror + + ifneq (,$(filter $(CONFIG_BONDING),y m)) diff --git a/lede/package/qca/qca-nss-clients/patches/0006-match-fix-compile-error.patch b/lede/package/qca/qca-nss-clients/patches/0006-match-fix-compile-error.patch new file mode 100644 index 0000000000..ad3ad0b91e --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0006-match-fix-compile-error.patch @@ -0,0 +1,25 @@ +--- a/match/nss_match_priv.h ++++ b/match/nss_match_priv.h +@@ -29,19 +29,19 @@ + /* + * Statically compile messages at different levels + */ +-#if (NSS_match_DEBUG_LEVEL < 2) ++#if (NSS_MATCH_DEBUG_LEVEL < 2) + #define nss_match_warn(s, ...) + #else + #define nss_match_warn(s, ...) pr_warn("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) + #endif + +-#if (NSS_match_DEBUG_LEVEL < 3) ++#if (NSS_MATCH_DEBUG_LEVEL < 3) + #define nss_match_info(s, ...) + #else + #define nss_match_info(s, ...) pr_notice("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) + #endif + +-#if (NSS_match_DEBUG_LEVEL < 4) ++#if (NSS_MATCH_DEBUG_LEVEL < 4) + #define nss_match_trace(s, ...) + #else + #define nss_match_trace(s, ...) pr_info("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) diff --git a/lede/package/qca/qca-nss-clients/patches/0007-bridge-fix-compile-error.patch b/lede/package/qca/qca-nss-clients/patches/0007-bridge-fix-compile-error.patch new file mode 100644 index 0000000000..539ff68744 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0007-bridge-fix-compile-error.patch @@ -0,0 +1,29 @@ +--- a/bridge/nss_bridge_mgr.c ++++ b/bridge/nss_bridge_mgr.c +@@ -1098,8 +1098,10 @@ int nss_bridge_mgr_register_br(struct ne + */ + b_pvt->ifnum = ifnum; + b_pvt->mtu = dev->mtu; ++#if defined(NSS_BRIDGE_MGR_PPE_SUPPORT) + b_pvt->wan_if_num = -1; + b_pvt->wan_if_enabled = false; ++#endif + ether_addr_copy(b_pvt->dev_addr, dev->dev_addr); + spin_lock(&br_mgr_ctx.lock); + list_add(&b_pvt->list, &br_mgr_ctx.list); +@@ -1165,6 +1167,7 @@ static int nss_bridge_mgr_bond_slave_cha + return NOTIFY_DONE; + } + ++#if defined(NSS_BRIDGE_MGR_PPE_SUPPORT) + /* + * Add or remove the slave based based on linking event + */ +@@ -1179,6 +1182,7 @@ static int nss_bridge_mgr_bond_slave_cha + cu_info->upper_dev->name, master->name); + } + } ++#endif + + return NOTIFY_DONE; + } diff --git a/lede/package/qca/qca-nss-clients/patches/0008-profiler-fix-compile-error.patch b/lede/package/qca/qca-nss-clients/patches/0008-profiler-fix-compile-error.patch new file mode 100644 index 0000000000..8b6d92c055 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0008-profiler-fix-compile-error.patch @@ -0,0 +1,61 @@ +--- a/profiler/profile.c ++++ b/profiler/profile.c +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -937,12 +938,26 @@ static ssize_t debug_if(struct file *fil + return count; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) ++#define HAVE_PROC_OPS ++#endif ++ ++#ifdef HAVE_PROC_OPS ++static const struct proc_ops profile_fops = { ++ .proc_open = profile_open, ++ .proc_read = profile_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = profile_release, ++ .proc_write = debug_if, ++}; ++#else + static const struct file_operations profile_fops = { + .open = profile_open, + .read = profile_read, + .release = profile_release, + .write = debug_if, + }; ++#endif + + /* + * showing sample status on Linux console +@@ -971,6 +986,15 @@ static ssize_t profile_rate_write(struct + return 0; + } + ++#ifdef HAVE_PROC_OPS ++static const struct proc_ops profile_rate_fops = { ++ .proc_open = profile_rate_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, ++ .proc_write = profile_rate_write, ++}; ++#else + static const struct file_operations profile_rate_fops = { + .open = profile_rate_open, + .read = seq_read, +@@ -978,6 +1002,7 @@ static const struct file_operations prof + .release = single_release, + .write = profile_rate_write, + }; ++#endif + + /* + * hexdump diff --git a/lede/package/qca/qca-nss-clients/patches/0009-gre-fix-compile-error.patch b/lede/package/qca/qca-nss-clients/patches/0009-gre-fix-compile-error.patch new file mode 100644 index 0000000000..e833327edd --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0009-gre-fix-compile-error.patch @@ -0,0 +1,17 @@ +--- a/gre/nss_connmgr_gre_v4.c ++++ b/gre/nss_connmgr_gre_v4.c +@@ -172,14 +172,6 @@ int nss_connmgr_gre_v4_set_config(struct + } + } + +- /* +- * IP address validate +- */ +- if ((cfg->src_ip == 0) || (cfg->dest_ip == 0)) { +- nss_connmgr_gre_warning("Source ip/Destination IP is invalid"); +- return GRE_ERR_INVALID_IP; +- } +- + memset(t, 0, sizeof(struct ip_tunnel)); + + priv->pad_len = (cfg->add_padding) ? GRE_HDR_PAD_LEN : 0; diff --git a/lede/package/qca/qca-nss-clients/patches/0010-fix-portifmgr.patch b/lede/package/qca/qca-nss-clients/patches/0010-fix-portifmgr.patch new file mode 100644 index 0000000000..343f17b842 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0010-fix-portifmgr.patch @@ -0,0 +1,35 @@ +--- a/portifmgr/nss_portifmgr.c ++++ b/portifmgr/nss_portifmgr.c +@@ -187,16 +187,20 @@ drop: + } + + /* +- * nss_portifmgr_get_stats() ++ * nss_portifmgr_get_stats64() + * Netdev get stats function to get port stats + */ +-static struct rtnl_link_stats64 *nss_portifmgr_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) ++/* ++ * nss_nlgre_redir_cmn_dev_stats64 ++ * Report packet statistics to linux ++ */ ++static void nss_portifmgr_get_stats64(struct net_device *dev, ++ struct rtnl_link_stats64 *stats) + { + struct nss_portifmgr_priv *priv = (struct nss_portifmgr_priv *)netdev_priv(dev); + BUG_ON(priv == NULL); + + nss_portid_get_stats(priv->if_num, stats); +- return stats; + } + + /* +@@ -225,7 +229,7 @@ static const struct net_device_ops nss_p + .ndo_start_xmit = nss_portifmgr_start_xmit, + .ndo_set_mac_address = eth_mac_addr, + .ndo_change_mtu = nss_portifmgr_change_mtu, +- .ndo_get_stats64 = nss_portifmgr_get_stats, ++ .ndo_get_stats64 = nss_portifmgr_get_stats64, + }; + + /* diff --git a/lede/package/qca/qca-nss-clients/patches/0011-dtlsmgr-fix-SHA-header-include-in-5.15.patch b/lede/package/qca/qca-nss-clients/patches/0011-dtlsmgr-fix-SHA-header-include-in-5.15.patch new file mode 100644 index 0000000000..a095a53706 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0011-dtlsmgr-fix-SHA-header-include-in-5.15.patch @@ -0,0 +1,48 @@ +--- a/dtls/v2.0/nss_dtlsmgr.c ++++ b/dtls/v2.0/nss_dtlsmgr.c +@@ -38,7 +38,13 @@ + #include + #include + #include ++#include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) + #include ++#else ++#include ++#include ++#endif + #include + #include + +--- a/dtls/v2.0/nss_dtlsmgr_ctx.c ++++ b/dtls/v2.0/nss_dtlsmgr_ctx.c +@@ -40,7 +40,13 @@ + #include + #include + #include ++#include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) + #include ++#else ++#include ++#include ++#endif + #include + #include + +--- a/dtls/v2.0/nss_dtlsmgr_ctx_dev.c ++++ b/dtls/v2.0/nss_dtlsmgr_ctx_dev.c +@@ -36,7 +36,13 @@ + #include + #include + #include ++#include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) + #include ++#else ++#include ++#include ++#endif + + #include + #include diff --git a/lede/package/qca/qca-nss-clients/patches/0012-dtlsmgr-fix-debug-print-in-5.15.patch b/lede/package/qca/qca-nss-clients/patches/0012-dtlsmgr-fix-debug-print-in-5.15.patch new file mode 100644 index 0000000000..89936dbdca --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0012-dtlsmgr-fix-debug-print-in-5.15.patch @@ -0,0 +1,36 @@ +--- a/dtls/v2.0/nss_dtlsmgr_private.h ++++ b/dtls/v2.0/nss_dtlsmgr_private.h +@@ -36,9 +36,9 @@ + /* + * Compile messages for dynamic enable/disable + */ +-#define nss_dtlsmgr_warn(s, ...) pr_debug("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__) +-#define nss_dtlsmgr_info(s, ...) pr_debug("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__) +-#define nss_dtlsmgr_trace(s, ...) pr_debug("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__) ++#define nss_dtlsmgr_warn(s, ...) pr_debug("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__); ++#define nss_dtlsmgr_info(s, ...) pr_debug("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__); ++#define nss_dtlsmgr_trace(s, ...) pr_debug("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__); + #else + + /* +@@ -46,17 +46,17 @@ + */ + #define nss_dtlsmgr_warn(s, ...) { \ + if (NSS_DTLSMGR_DEBUG_LEVEL > NSS_DTLSMGR_DEBUG_LEVEL_ERROR) \ +- pr_warn("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__) \ ++ pr_warn("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__); \ + } + + #define nss_dtlsmgr_info(s, ...) { \ + if (NSS_DTLSMGR_DEBUG_LEVEL > NSS_DTLSMGR_DEBUG_LEVEL_WARN) \ +- pr_notice("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__) \ ++ pr_notice("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__); \ + } + + #define nss_dtlsmgr_trace(s, ...) { \ + if (NSS_DTLSMGR_DEBUG_LEVEL > NSS_DTLSMGR_DEBUG_LEVEL_INFO) \ +- pr_info("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__) \ ++ pr_info("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__); \ + } + + #endif /* CONFIG_DYNAMIC_DEBUG */ diff --git a/lede/package/qca/qca-nss-clients/patches/0013-tlsmgr-fix-SHA-header-include-in-5.15.patch b/lede/package/qca/qca-nss-clients/patches/0013-tlsmgr-fix-SHA-header-include-in-5.15.patch new file mode 100644 index 0000000000..f3cee731d4 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0013-tlsmgr-fix-SHA-header-include-in-5.15.patch @@ -0,0 +1,32 @@ +--- a/tls/nss_tlsmgr_crypto.c ++++ b/tls/nss_tlsmgr_crypto.c +@@ -41,7 +41,13 @@ + #include + #include + #include ++#include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) + #include ++#else ++#include ++#include ++#endif + #include + #include + #include +--- a/tls/nss_tlsmgr_tun.c ++++ b/tls/nss_tlsmgr_tun.c +@@ -35,7 +35,13 @@ + #include + #include + #include ++#include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) + #include ++#else ++#include ++#include ++#endif + + #include + #include diff --git a/lede/package/qca/qca-nss-clients/patches/0014-ovpnmgr-fix-SHA-header-include-in-5.15.patch b/lede/package/qca/qca-nss-clients/patches/0014-ovpnmgr-fix-SHA-header-include-in-5.15.patch new file mode 100644 index 0000000000..0b8cd17eb2 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0014-ovpnmgr-fix-SHA-header-include-in-5.15.patch @@ -0,0 +1,32 @@ +--- a/openvpn/src/nss_ovpnmgr_crypto.c ++++ b/openvpn/src/nss_ovpnmgr_crypto.c +@@ -28,7 +28,13 @@ + #include + #include + #include ++#include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) + #include ++#else ++#include ++#include ++#endif + #include + + #include +--- a/openvpn/src/nss_ovpnmgr_route.c ++++ b/openvpn/src/nss_ovpnmgr_route.c +@@ -34,7 +34,13 @@ + #include + #include + #include ++#include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) + #include ++#else ++#include ++#include ++#endif + #include + + #include diff --git a/lede/package/qca/qca-nss-clients/patches/0015-tunipip6-fix-compile-error-in-5.15.patch b/lede/package/qca/qca-nss-clients/patches/0015-tunipip6-fix-compile-error-in-5.15.patch new file mode 100644 index 0000000000..b9d6c2e229 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0015-tunipip6-fix-compile-error-in-5.15.patch @@ -0,0 +1,11 @@ +--- a/tunipip6/nss_connmgr_tunipip6.c ++++ b/tunipip6/nss_connmgr_tunipip6.c +@@ -258,7 +258,7 @@ static void nss_tunipip6_decap_exception + struct iphdr *iph; + struct rtable *rt; + int cpu; +- int8_t ver = skb->data[0] >> 4; ++ __attribute__((unused)) int8_t ver = skb->data[0] >> 4; + + nss_tunipip6_trace("%px: received - %d bytes name %s ver %x\n", + dev, skb->len, dev->name, ver); diff --git a/lede/package/qca/qca-nss-clients/patches/0016-vxlanmgr-fix-compile-error-in-5.15.patch b/lede/package/qca/qca-nss-clients/patches/0016-vxlanmgr-fix-compile-error-in-5.15.patch new file mode 100644 index 0000000000..80173f88a1 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0016-vxlanmgr-fix-compile-error-in-5.15.patch @@ -0,0 +1,11 @@ +--- a/vxlanmgr/nss_vxlanmgr.c ++++ b/vxlanmgr/nss_vxlanmgr.c +@@ -84,7 +84,7 @@ int32_t nss_vxlanmgr_bind_ipsec_by_ip(un + { + int32_t ipsec_if_num; + nss_vxlanmgr_get_ipsec_if_num_by_ip_callback_t ipsec_cb; +- struct nss_ctx_instance *nss_ctx = nss_vxlan_get_ctx(); ++ __attribute__((unused)) struct nss_ctx_instance *nss_ctx = nss_vxlan_get_ctx(); + + /* + * Check if the VxLAN interface is applied over an IPsec interface by querying the IPsec. diff --git a/lede/package/qca/qca-nss-clients/patches/0017-tlsmgr-fix-debug-print-in-5.15.patch b/lede/package/qca/qca-nss-clients/patches/0017-tlsmgr-fix-debug-print-in-5.15.patch new file mode 100644 index 0000000000..4fbdecb495 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0017-tlsmgr-fix-debug-print-in-5.15.patch @@ -0,0 +1,34 @@ +--- a/tls/nss_tlsmgr_priv.h ++++ b/tls/nss_tlsmgr_priv.h +@@ -28,7 +28,7 @@ + #define NSS_TLSMGR_DEBUG_LEVEL_INFO 3 + #define NSS_TLSMGR_DEBUG_LEVEL_TRACE 4 + +-#define nss_tlsmgr_info_always(s, ...) pr_info("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__) ++#define nss_tlsmgr_info_always(s, ...) pr_info("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__); + + #define nss_tlsmgr_error(s, ...) do { \ + if (net_ratelimit()) { \ +@@ -43,18 +43,18 @@ + } while (0) + + #if defined(CONFIG_DYNAMIC_DEBUG) +-#define nss_tlsmgr_info(s, ...) pr_debug("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__) +-#define nss_tlsmgr_trace(s, ...) pr_debug("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__) ++#define nss_tlsmgr_info(s, ...) pr_debug("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__); ++#define nss_tlsmgr_trace(s, ...) pr_debug("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__); + #else + + #define nss_tlsmgr_info(s, ...) { \ + if (NSS_TLSMGR_DEBUG_LEVEL > NSS_TLSMGR_DEBUG_LEVEL_WARN) \ +- pr_notice("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__) \ ++ pr_notice("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__); \ + } + + #define nss_tlsmgr_trace(s, ...) { \ + if (NSS_TLSMGR_DEBUG_LEVEL > NSS_TLSMGR_DEBUG_LEVEL_INFO) \ +- pr_info("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__) \ ++ pr_info("%s[%d]:" s "\n", __func__, __LINE__, ##__VA_ARGS__); \ + } + + #endif /* CONFIG_DYNAMIC_DEBUG */ diff --git a/lede/package/qca/qca-nss-clients/patches/0018-kernel-6.1-support.patch b/lede/package/qca/qca-nss-clients/patches/0018-kernel-6.1-support.patch new file mode 100644 index 0000000000..7606a15351 --- /dev/null +++ b/lede/package/qca/qca-nss-clients/patches/0018-kernel-6.1-support.patch @@ -0,0 +1,301 @@ +--- a/bridge/nss_bridge_mgr.c ++++ b/bridge/nss_bridge_mgr.c +@@ -1081,7 +1081,7 @@ int nss_bridge_mgr_register_br(struct ne + } + #endif + +- err = nss_bridge_tx_set_mac_addr_msg(ifnum, dev->dev_addr); ++ err = nss_bridge_tx_set_mac_addr_msg(ifnum, (uint8_t *) dev->dev_addr); + if (err != NSS_TX_SUCCESS) { + nss_bridge_mgr_warn("%px: failed to set mac_addr msg, error = %d\n", b_pvt, err); + goto fail_4; +@@ -1242,7 +1242,7 @@ static int nss_bridge_mgr_changeaddr_eve + + nss_bridge_mgr_trace("%px: MAC changed to %pM, update NSS\n", b_pvt, dev->dev_addr); + +- if (nss_bridge_tx_set_mac_addr_msg(b_pvt->ifnum, dev->dev_addr) != NSS_TX_SUCCESS) { ++ if (nss_bridge_tx_set_mac_addr_msg(b_pvt->ifnum, (uint8_t *) dev->dev_addr) != NSS_TX_SUCCESS) { + nss_bridge_mgr_warn("%px: Failed to send change MAC address message to NSS\n", b_pvt); + return NOTIFY_DONE; + } +--- a/dtls/v2.0/nss_dtlsmgr_ctx_dev.c ++++ b/dtls/v2.0/nss_dtlsmgr_ctx_dev.c +@@ -532,7 +532,7 @@ void nss_dtlsmgr_ctx_dev_setup(struct ne + #else + dev->priv_destructor = nss_dtlsmgr_ctx_dev_free; + #endif +- memcpy(dev->dev_addr, "\xaa\xbb\xcc\xdd\xee\xff", dev->addr_len); ++ memcpy((void *) dev->dev_addr, "\xaa\xbb\xcc\xdd\xee\xff", dev->addr_len); + memset(dev->broadcast, 0xff, dev->addr_len); + memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); + } +--- a/gre/test/nss_connmgr_gre_test.c ++++ b/gre/test/nss_connmgr_gre_test.c +@@ -223,7 +223,7 @@ static int nss_connmgr_gre_test_show_pro + */ + static int nss_connmgr_gre_test_open_proc(struct inode *inode, struct file *filp) + { +- return single_open(filp, nss_connmgr_gre_test_show_proc, PDE_DATA(inode)); ++ return single_open(filp, nss_connmgr_gre_test_show_proc, pde_data(inode)); + } + + /* +--- a/gre/nss_connmgr_gre.c ++++ b/gre/nss_connmgr_gre.c +@@ -279,10 +279,10 @@ static struct rtnl_link_stats64 *nss_con + #else + start = u64_stats_fetch_begin_irq(&tstats->syncp); + #endif +- rx_packets = tstats->rx_packets; +- tx_packets = tstats->tx_packets; +- rx_bytes = tstats->rx_bytes; +- tx_bytes = tstats->tx_bytes; ++ rx_packets = u64_stats_read(&tstats->rx_packets); ++ tx_packets = u64_stats_read(&tstats->tx_packets); ++ rx_bytes = u64_stats_read(&tstats->rx_bytes); ++ tx_bytes = u64_stats_read(&tstats->tx_bytes); + #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)) + } while (u64_stats_fetch_retry_bh(&tstats->syncp, start)); + #else +@@ -697,11 +697,11 @@ static void nss_connmgr_gre_event_receiv + tstats = this_cpu_ptr(dev->tstats); + u64_stats_update_begin(&tstats->syncp); + if (interface_type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_INNER) { +- tstats->tx_packets += stats->tx_packets; +- tstats->tx_bytes += stats->tx_bytes; ++ u64_stats_add(&tstats->tx_packets, stats->tx_packets); ++ u64_stats_add(&tstats->tx_bytes, stats->tx_bytes); + } else if (interface_type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_OUTER) { +- tstats->rx_packets += stats->rx_packets; +- tstats->rx_bytes += stats->rx_bytes; ++ u64_stats_add(&tstats->rx_packets, stats->rx_packets); ++ u64_stats_add(&tstats->rx_bytes, stats->rx_bytes); + } + u64_stats_update_end(&tstats->syncp); + dev->stats.rx_dropped += nss_cmn_rx_dropped_sum(stats); +--- a/tunipip6/nss_connmgr_tunipip6.c ++++ b/tunipip6/nss_connmgr_tunipip6.c +@@ -354,11 +354,11 @@ static void nss_tunipip6_update_dev_stat + + memset(&stats, 0, sizeof(stats)); + if (interface_type == NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_INNER) { +- stats.tx_packets = sync_stats->node_stats.tx_packets; +- stats.tx_bytes = sync_stats->node_stats.tx_bytes; ++ u64_stats_set(&stats.tx_packets, sync_stats->node_stats.tx_packets); ++ u64_stats_set(&stats.tx_bytes, sync_stats->node_stats.tx_bytes); + } else if (interface_type == NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_OUTER) { +- stats.rx_packets = sync_stats->node_stats.rx_packets; +- stats.rx_bytes = sync_stats->node_stats.rx_bytes; ++ u64_stats_set(&stats.rx_packets, sync_stats->node_stats.rx_packets); ++ u64_stats_set(&stats.rx_bytes, sync_stats->node_stats.rx_bytes); + } else { + nss_tunipip6_warning("%px: Invalid interface type received from NSS\n", dev); + return; +--- a/nss_qdisc/igs/nss_mirred.c ++++ b/nss_qdisc/igs/nss_mirred.c +@@ -317,7 +317,7 @@ static int nss_mirred_act(struct sk_buff + * Update the last use of action. + */ + tcf_lastuse_update(&act->tcf_tm); +- bstats_cpu_update(this_cpu_ptr(act->common.cpu_bstats), skb); ++ bstats_update(this_cpu_ptr(act->common.cpu_bstats), skb); + + rcu_read_lock(); + retval = READ_ONCE(act->tcf_action); +--- a/nss_qdisc/nss_qdisc.h ++++ b/nss_qdisc/nss_qdisc.h +@@ -217,7 +217,7 @@ struct nss_qdisc { + /* Shaper configure callback for reading shaper specific + * responses (e.g. memory size). + */ +- struct gnet_stats_basic_packed bstats; /* Basic class statistics */ ++ struct gnet_stats_basic_sync bstats; /* Basic class statistics */ + struct gnet_stats_queue qstats; /* Qstats for use by classes */ + #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)) + atomic_t refcnt; /* Reference count for class use */ +@@ -464,7 +464,7 @@ extern int nss_qdisc_init(struct Qdisc * + * Wrapper around gnet_stats_copy_basic() + */ + extern int nss_qdisc_gnet_stats_copy_basic(struct Qdisc *sch, +- struct gnet_dump *d, struct gnet_stats_basic_packed *b); ++ struct gnet_dump *d, struct gnet_stats_basic_sync *b); + + /* + * nss_qdisc_gnet_stats_copy_queue() +--- a/nss_qdisc/igs/nss_ifb.c ++++ b/nss_qdisc/igs/nss_ifb.c +@@ -544,8 +544,10 @@ static void nss_ifb_update_dev_stats(str + * post shaping. Therefore IFB interface's stats should be updated + * with NSS firmware's IFB TX stats only. + */ +- stats.rx_packets = stats.tx_packets = node_stats->tx_packets; +- stats.rx_bytes = stats.tx_bytes = node_stats->tx_bytes; ++ u64_stats_set(&stats.rx_packets, node_stats->tx_packets); ++ u64_stats_set(&stats.tx_packets, node_stats->tx_packets); ++ u64_stats_set(&stats.rx_bytes, node_stats->tx_bytes); ++ u64_stats_set(&stats.tx_bytes, node_stats->tx_bytes); + dev->stats.rx_dropped = dev->stats.tx_dropped += sync_stats->igs_stats.tx_dropped; + u64_stats_update_end(&stats.syncp); + +--- a/nss_qdisc/nss_qdisc.c ++++ b/nss_qdisc/nss_qdisc.c +@@ -2608,12 +2608,14 @@ int nss_qdisc_init(struct Qdisc *sch, st + * Wrapper around gnet_stats_copy_basic() + */ + int nss_qdisc_gnet_stats_copy_basic(struct Qdisc *sch, struct gnet_dump *d, +- struct gnet_stats_basic_packed *b) ++ struct gnet_stats_basic_sync *b) + { + #if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 18, 0)) + return gnet_stats_copy_basic(d, b); + #elif (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + return gnet_stats_copy_basic(d, NULL, b); ++#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)) ++ return gnet_stats_copy_basic(d, NULL, b, true); + #else + return gnet_stats_copy_basic(qdisc_root_sleeping_running(sch), d, NULL, b); + #endif +--- a/nss_qdisc/nss_qdisc_stats.c ++++ b/nss_qdisc/nss_qdisc_stats.c +@@ -160,7 +160,7 @@ static void nss_qdisc_stats_process_node + { + struct Qdisc *qdisc; + struct nss_qdisc *nq; +- struct gnet_stats_basic_packed *bstats; ++ struct gnet_stats_basic_sync *bstats; + struct gnet_stats_queue *qstats; + uint32_t qos_tag = response->qos_tag; + #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)) +@@ -214,8 +214,8 @@ static void nss_qdisc_stats_process_node + * Update qdisc->bstats + */ + spin_lock_bh(&nq->lock); +- bstats->bytes += (__u64)response->sn_stats.delta.dequeued_bytes; +- bstats->packets += response->sn_stats.delta.dequeued_packets; ++ u64_stats_add(&bstats->bytes, (__u64)response->sn_stats.delta.dequeued_bytes); ++ u64_stats_add(&bstats->packets, response->sn_stats.delta.dequeued_packets); + + /* + * Update qdisc->qstats +--- a/vlan/nss_vlan_mgr.c ++++ b/vlan/nss_vlan_mgr.c +@@ -787,7 +787,7 @@ static struct nss_vlan_pvt *nss_vlan_mgr + } + + v->mtu = dev->mtu; +- ether_addr_copy(v->dev_addr, dev->dev_addr); ++ ether_addr_copy(v->dev_addr, (uint8_t *) dev->dev_addr); + v->ifindex = dev->ifindex; + v->refs = 1; + +@@ -936,14 +936,14 @@ static int nss_vlan_mgr_changeaddr_event + } + spin_unlock(&vlan_mgr_ctx.lock); + +- if (nss_vlan_tx_set_mac_addr_msg(v_pvt->nss_if, dev->dev_addr) != NSS_TX_SUCCESS) { ++ if (nss_vlan_tx_set_mac_addr_msg(v_pvt->nss_if, (uint8_t *) dev->dev_addr) != NSS_TX_SUCCESS) { + nss_vlan_mgr_warn("%s: Failed to send change MAC address message to NSS\n", dev->name); + nss_vlan_mgr_instance_deref(v_pvt); + return NOTIFY_BAD; + } + + spin_lock(&vlan_mgr_ctx.lock); +- ether_addr_copy(v_pvt->dev_addr, dev->dev_addr); ++ ether_addr_copy(v_pvt->dev_addr, (uint8_t *) dev->dev_addr); + spin_unlock(&vlan_mgr_ctx.lock); + nss_vlan_mgr_trace("%s: MAC changed to %pM, updated NSS\n", dev->name, dev->dev_addr); + nss_vlan_mgr_instance_deref(v_pvt); +--- a/vxlanmgr/nss_vxlanmgr_tunnel.c ++++ b/vxlanmgr/nss_vxlanmgr_tunnel.c +@@ -489,8 +489,8 @@ static void nss_vxlanmgr_tunnel_inner_st + + tstats = this_cpu_ptr(dev->tstats); + u64_stats_update_begin(&tstats->syncp); +- tstats->tx_packets += stats->node_stats.tx_packets; +- tstats->tx_bytes += stats->node_stats.tx_bytes; ++ u64_stats_add(&tstats->tx_packets, stats->node_stats.tx_packets); ++ u64_stats_add(&tstats->tx_bytes, stats->node_stats.tx_bytes); + u64_stats_update_end(&tstats->syncp); + netdev_stats->tx_dropped += dropped; + } +@@ -526,8 +526,8 @@ static void nss_vxlanmgr_tunnel_outer_st + + tstats = this_cpu_ptr(dev->tstats); + u64_stats_update_begin(&tstats->syncp); +- tstats->rx_packets += stats->node_stats.tx_packets; +- tstats->rx_bytes += stats->node_stats.tx_bytes; ++ u64_stats_add(&tstats->rx_packets, stats->node_stats.tx_packets); ++ u64_stats_add(&tstats->rx_bytes, stats->node_stats.tx_bytes); + u64_stats_update_end(&tstats->syncp); + netdev_stats->rx_dropped += dropped; + dev_put(dev); +--- a/pvxlanmgr/nss_pvxlanmgr.c ++++ b/pvxlanmgr/nss_pvxlanmgr.c +@@ -177,7 +177,7 @@ static struct rtnl_link_stats64 *nss_pvx + * Netdev seems to be incrementing rx_dropped because we don't give IP header. + * So reset it as it's of no use for us. + */ +- atomic_long_set(&dev->rx_dropped, 0); ++ atomic_long_set(&(dev)->stats.__rx_dropped, 0); + priv = netdev_priv(dev); + memset(stats, 0, sizeof(struct rtnl_link_stats64)); + memcpy(stats, &priv->stats, sizeof(struct rtnl_link_stats64)); +@@ -305,7 +305,7 @@ static void nss_pvxlanmgr_dummy_netdev_s + dev->priv_destructor = NULL; + #endif + +- memcpy(dev->dev_addr, "\x00\x00\x00\x00\x00\x00", dev->addr_len); ++ memcpy((void *) dev->dev_addr, "\x00\x00\x00\x00\x00\x00", dev->addr_len); + memset(dev->broadcast, 0xff, dev->addr_len); + memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); + } +--- a/clmapmgr/nss_clmapmgr.c ++++ b/clmapmgr/nss_clmapmgr.c +@@ -103,7 +103,7 @@ static struct rtnl_link_stats64 *nss_clm + * Netdev seems to be incrementing rx_dropped because we don't give IP header. + * So reset it as it's of no use for us. + */ +- atomic_long_set(&dev->rx_dropped, 0); ++ atomic_long_set(&(dev)->stats.__rx_dropped, 0); + priv = netdev_priv(dev); + memset(stats, 0, sizeof(struct rtnl_link_stats64)); + memcpy(stats, &priv->stats, sizeof(struct rtnl_link_stats64)); +--- a/tls/nss_tlsmgr_tun.c ++++ b/tls/nss_tlsmgr_tun.c +@@ -185,7 +185,7 @@ static void nss_tlsmgr_tun_setup(struct + /* + * Get the MAC address from the ethernet device + */ +- random_ether_addr(dev->dev_addr); ++ eth_random_addr((u8 *) dev->dev_addr); + + memset(dev->broadcast, 0xff, dev->addr_len); + memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); +--- a/netlink/nss_nlgre_redir_cmn.c ++++ b/netlink/nss_nlgre_redir_cmn.c +@@ -384,7 +384,7 @@ static int nss_nlgre_redir_cmn_set_mac_a + return -EINVAL; + } + +- memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); ++ memcpy((void *) dev->dev_addr, addr->sa_data, ETH_ALEN); + return 0; + } + +--- a/nss_connmgr_tun6rd.c ++++ b/nss_connmgr_tun6rd.c +@@ -101,10 +101,10 @@ static void nss_tun6rd_update_dev_stats( + + u64_stats_init(&stats.syncp); + u64_stats_update_begin(&stats.syncp); +- stats.rx_packets = sync_stats->node_stats.rx_packets; +- stats.rx_bytes = sync_stats->node_stats.rx_bytes; +- stats.tx_packets = sync_stats->node_stats.tx_packets; +- stats.tx_bytes = sync_stats->node_stats.tx_bytes; ++ u64_stats_set(&stats.rx_packets, sync_stats->node_stats.rx_packets); ++ u64_stats_set(&stats.rx_bytes, sync_stats->node_stats.rx_bytes); ++ u64_stats_set(&stats.tx_packets, sync_stats->node_stats.tx_packets); ++ u64_stats_set(&stats.tx_bytes, sync_stats->node_stats.tx_bytes); + u64_stats_update_end(&stats.syncp); + #else + struct nss_tun6rd_stats stats; diff --git a/lede/package/qca/qca-nss-crypto/Makefile b/lede/package/qca/qca-nss-crypto/Makefile new file mode 100644 index 0000000000..1e22918543 --- /dev/null +++ b/lede/package/qca/qca-nss-crypto/Makefile @@ -0,0 +1,70 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=qca-nss-crypto +PKG_RELEASE:=1 + +PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/nss-crypto.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_DATE:=2022-12-15 +PKG_SOURCE_VERSION:=3c5a574ce99d7f0b9f892002020f1bf9bfc57a81 +PKG_MIRROR_HASH:=ff487c5574481f548eef7b61129fa7be1d83ae285dcc3356a06be237440d8782 + +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/package.mk + +# v1.0 is for Akronite +# v2.0 is for Hawkeye/Cypress/Maple +ifneq (, $(findstring $(CONFIG_TARGET_SUBTARGET), "ipq807x" "ipq60xx")) +NSS_CRYPTO_DIR:=v2.0 +else +NSS_CRYPTO_DIR:=v1.0 +endif + +define KernelPackage/qca-nss-crypto + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Cryptographic API modules + DEPENDS:=@TARGET_qualcommax +kmod-qca-nss-drv + TITLE:=Kernel driver for NSS crypto driver + FILES:=$(PKG_BUILD_DIR)/$(NSS_CRYPTO_DIR)/src/qca-nss-crypto.ko \ + $(PKG_BUILD_DIR)/$(NSS_CRYPTO_DIR)/tool/qca-nss-crypto-tool.ko + AUTOLOAD:=$(call AutoProbe,qca-nss-crypto) +endef + +define KernelPackage/qca-nss-crypto/Description +This package contains a NSS crypto driver for QCA chipset +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/qca-nss-crypto + $(CP) $(PKG_BUILD_DIR)/$(NSS_CRYPTO_DIR)/include/* $(1)/usr/include/qca-nss-crypto +endef + +EXTRA_CFLAGS+= \ + -DCONFIG_NSS_DEBUG_LEVEL=4 \ + -I$(STAGING_DIR)/usr/include/qca-nss-crypto \ + -I$(STAGING_DIR)/usr/include/qca-nss-drv \ + -I$(PKG_BUILD_DIR)/$(NSS_CRYPTO_DIR)/include \ + -I$(PKG_BUILD_DIR)/$(NSS_CRYPTO_DIR)/src + +ifeq ($(CONFIG_TARGET_BOARD), "qualcommax") + SOC:=$(CONFIG_TARGET_SUBTARGET) +endif + +define Build/Compile + +$(MAKE) -C "$(LINUX_DIR)" \ + CC="$(TARGET_CC)" \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + ARCH="$(LINUX_KARCH)" \ + M="$(PKG_BUILD_DIR)" \ + EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ + NSS_CRYPTO_DIR=$(NSS_CRYPTO_DIR) \ + SoC=$(SOC) \ + $(KERNEL_MAKE_FLAGS) \ + $(PKG_JOBS) \ + modules +endef + +$(eval $(call KernelPackage,qca-nss-crypto)) diff --git a/lede/package/qca/qca-nss-crypto/patches/0001-nss-crypto-fix-SHA1-header-include.patch b/lede/package/qca/qca-nss-crypto/patches/0001-nss-crypto-fix-SHA1-header-include.patch new file mode 100644 index 0000000000..c9849a2e8d --- /dev/null +++ b/lede/package/qca/qca-nss-crypto/patches/0001-nss-crypto-fix-SHA1-header-include.patch @@ -0,0 +1,27 @@ +From 0c6c593783f2d64a429ad38523661a915aa462fc Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Sun, 13 Mar 2022 13:44:47 +0100 +Subject: [PATCH 1/3] nss-crypto: fix SHA1 header include + +SHA1 header has been merged to the generic SHA one, +and with that the cryptohash.h was dropped. + +So, fix include in kernels 5.8 and newer. + +Signed-off-by: Robert Marko +--- + v2.0/src/nss_crypto_hlos.h | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/v2.0/src/nss_crypto_hlos.h ++++ b/v2.0/src/nss_crypto_hlos.h +@@ -55,7 +55,9 @@ + #include + #include + #include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0) + #include ++#endif + #include + #include + #include diff --git a/lede/package/qca/qca-nss-crypto/patches/0002-nss-crypto-replace-ioremap_nocache-with-ioremap.patch b/lede/package/qca/qca-nss-crypto/patches/0002-nss-crypto-replace-ioremap_nocache-with-ioremap.patch new file mode 100644 index 0000000000..19454c457b --- /dev/null +++ b/lede/package/qca/qca-nss-crypto/patches/0002-nss-crypto-replace-ioremap_nocache-with-ioremap.patch @@ -0,0 +1,94 @@ +From 8baa8e747247403c6f814ea5dc3e463c70e0415f Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Tue, 8 Jun 2021 22:14:34 +0200 +Subject: [PATCH 2/3] nss-crypto: replace ioremap_nocache() with ioremap + +ioremap_nocache() was dropped in kernel 5.5 as regular +ioremap() was exactly the same. + +So, simply replace all of the ioremap_nocache() calls +with ioremap(). + +Signed-off-by: Robert Marko +--- + v1.0/src/nss_crypto_dtsi.c | 4 ++-- + v1.0/src/nss_crypto_platform.c | 4 ++-- + v2.0/src/hal/ipq50xx/nss_crypto_ce5.c | 4 ++-- + v2.0/src/hal/ipq60xx/nss_crypto_eip197.c | 2 +- + v2.0/src/hal/ipq807x/nss_crypto_eip197.c | 2 +- + 5 files changed, 8 insertions(+), 8 deletions(-) + +--- a/v1.0/src/nss_crypto_dtsi.c ++++ b/v1.0/src/nss_crypto_dtsi.c +@@ -311,11 +311,11 @@ static int nss_crypto_probe(struct platf + e_ctrl->dev = &pdev->dev; + + e_ctrl->cmd_base = crypto_res.start; +- e_ctrl->crypto_base = ioremap_nocache(e_ctrl->cmd_base, resource_size(&crypto_res)); ++ e_ctrl->crypto_base = ioremap(e_ctrl->cmd_base, resource_size(&crypto_res)); + nss_crypto_assert(e_ctrl->crypto_base); + + e_ctrl->bam_pbase = bam_res.start; +- e_ctrl->bam_base = ioremap_nocache(e_ctrl->bam_pbase, resource_size(&bam_res)); ++ e_ctrl->bam_base = ioremap(e_ctrl->bam_pbase, resource_size(&bam_res)); + nss_crypto_assert(e_ctrl->bam_base); + + e_ctrl->bam_ee = bam_ee; +--- a/v1.0/src/nss_crypto_platform.c ++++ b/v1.0/src/nss_crypto_platform.c +@@ -134,11 +134,11 @@ static int nss_crypto_probe(struct platf + e_ctrl->bam_ee = res->bam_ee; + + e_ctrl->cmd_base = res->crypto_pbase; +- e_ctrl->crypto_base = ioremap_nocache(res->crypto_pbase, res->crypto_pbase_sz); ++ e_ctrl->crypto_base = ioremap(res->crypto_pbase, res->crypto_pbase_sz); + nss_crypto_assert(e_ctrl->crypto_base); + + e_ctrl->bam_pbase = res->bam_pbase; +- e_ctrl->bam_base = ioremap_nocache(res->bam_pbase, res->bam_pbase_sz); ++ e_ctrl->bam_base = ioremap(res->bam_pbase, res->bam_pbase_sz); + nss_crypto_assert(e_ctrl->bam_base); + + /* +--- a/v2.0/src/hal/ipq50xx/nss_crypto_ce5.c ++++ b/v2.0/src/hal/ipq50xx/nss_crypto_ce5.c +@@ -288,7 +288,7 @@ int nss_crypto_ce5_engine_init(struct pl + * remap the I/O addresses for crypto + */ + eng->crypto_paddr = crypto_res->start; +- eng->crypto_vaddr = ioremap_nocache(crypto_res->start, resource_size(crypto_res)); ++ eng->crypto_vaddr = ioremap(crypto_res->start, resource_size(crypto_res)); + if (!eng->crypto_vaddr) { + nss_crypto_warn("%px: unable to remap crypto_addr(0x%px)\n", node, (void *)eng->crypto_paddr); + nss_crypto_engine_free(eng); +@@ -299,7 +299,7 @@ int nss_crypto_ce5_engine_init(struct pl + * remap the I/O addresses for bam + */ + eng->dma_paddr = bam_res->start; +- eng->dma_vaddr = ioremap_nocache(bam_res->start, resource_size(bam_res)); ++ eng->dma_vaddr = ioremap(bam_res->start, resource_size(bam_res)); + if (!eng->dma_vaddr) { + iounmap(eng->crypto_vaddr); + nss_crypto_warn("%px: unable to remap dma_addr(0x%px)\n", node, (void *)eng->dma_paddr); +--- a/v2.0/src/hal/ipq60xx/nss_crypto_eip197.c ++++ b/v2.0/src/hal/ipq60xx/nss_crypto_eip197.c +@@ -490,7 +490,7 @@ int nss_crypto_eip197_engine_init(struct + * remap the I/O addresses + */ + paddr = res->start + offset; +- vaddr = ioremap_nocache(paddr, resource_size(res)); ++ vaddr = ioremap(paddr, resource_size(res)); + if (!vaddr) { + nss_crypto_warn("%px: unable to remap crypto_addr(0x%px)\n", node, (void *)paddr); + return -EIO; +--- a/v2.0/src/hal/ipq807x/nss_crypto_eip197.c ++++ b/v2.0/src/hal/ipq807x/nss_crypto_eip197.c +@@ -490,7 +490,7 @@ int nss_crypto_eip197_engine_init(struct + * remap the I/O addresses + */ + paddr = res->start + offset; +- vaddr = ioremap_nocache(paddr, resource_size(res)); ++ vaddr = ioremap(paddr, resource_size(res)); + if (!vaddr) { + nss_crypto_warn("%px: unable to remap crypto_addr(0x%px)\n", node, (void *)paddr); + return -EIO; diff --git a/lede/package/qca/qca-nss-crypto/patches/0003-nss-crypto-fix-SHA-header-include-in-5.15.patch b/lede/package/qca/qca-nss-crypto/patches/0003-nss-crypto-fix-SHA-header-include-in-5.15.patch new file mode 100644 index 0000000000..61df791fdd --- /dev/null +++ b/lede/package/qca/qca-nss-crypto/patches/0003-nss-crypto-fix-SHA-header-include-in-5.15.patch @@ -0,0 +1,44 @@ +From 96da3ca01ac172e5d858209b3d3d9aefad04423c Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Sun, 13 Mar 2022 13:47:24 +0100 +Subject: [PATCH 3/3] nss-crypto: fix SHA header include in 5.15 + +SHA header was split into SHA-1 and SHA-2 headers in kernel 5.11, so +fix the include for newer kernels. + +Signed-off-by: Robert Marko +--- + v2.0/src/nss_crypto_ctrl.c | 6 ++++++ + v2.0/src/nss_crypto_hlos.h | 4 ++++ + 2 files changed, 10 insertions(+) + +--- a/v2.0/src/nss_crypto_ctrl.c ++++ b/v2.0/src/nss_crypto_ctrl.c +@@ -38,7 +38,13 @@ + #include + #include + #include ++#include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) + #include ++#else ++#include ++#include ++#endif + #include + #include + #include +--- a/v2.0/src/nss_crypto_hlos.h ++++ b/v2.0/src/nss_crypto_hlos.h +@@ -58,7 +58,11 @@ + #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0) + #include + #endif ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) + #include ++#else ++#include ++#endif + #include + #include + #include diff --git a/lede/package/qca/qca-nss-drv/Config.in b/lede/package/qca/qca-nss-drv/Config.in new file mode 100644 index 0000000000..c1bd4760a0 --- /dev/null +++ b/lede/package/qca/qca-nss-drv/Config.in @@ -0,0 +1,184 @@ +menu "Configuration" + depends on PACKAGE_kmod-qca-nss-drv + +comment "Build Options" + +config NSS_DRV_BRIDGE_ENABLE + bool + default n + prompt "Enable BRIDGE" +config NSS_DRV_C2C_ENABLE + bool + default n + prompt "Enable C2C" +config NSS_DRV_CLMAP_ENABLE + bool + default n + prompt "Enable CLMAP" +config NSS_DRV_CRYPTO_ENABLE + bool + default y + prompt "Enable CRYPTO" +config NSS_DRV_DTLS_ENABLE + bool + default n + prompt "Enable DTLS" +config NSS_DRV_EDMA_ENABLE + bool + default n + prompt "Enable EDMA" +config NSS_DRV_GRE_ENABLE + bool + default n + prompt "Enable GRE" +config NSS_DRV_GRE_REDIR_ENABLE + bool + default n + depends on NSS_DRV_GRE_ENABLE + prompt "Enable GRE_REDIR" +config NSS_DRV_GRE_TUNNEL_ENABLE + bool + default n + depends on NSS_DRV_GRE_ENABLE + prompt "Enable GRE_TUNNEL" +config NSS_DRV_IGS_ENABLE + bool + default n + prompt "Enable IGS" +config NSS_DRV_IPSEC_ENABLE + bool + default n + prompt "Enable IPSEC" +config NSS_DRV_IPV4_REASM_ENABLE + bool + default n + prompt "Enable IPV4_REASM" +config NSS_DRV_IPV6_ENABLE + bool + default n + prompt "Enable IPV6" +config NSS_DRV_IPV6_REASM_ENABLE + bool + default n + depends on NSS_DRV_IPV6_ENABLE + prompt "Enable IPV6_REASM" +config NSS_DRV_L2TP_ENABLE + bool + default n + prompt "Enable L2TP" +config NSS_DRV_LAG_ENABLE + bool + default n + prompt "Enable LAG" +config NSS_DRV_MAPT_ENABLE + bool + default n + prompt "Enable MAPT" +config NSS_DRV_MATCH_ENABLE + bool + default n + prompt "Enable MATCH" +config NSS_DRV_MIRROR_ENABLE + bool + default n + prompt "Enable MIRROR" +config NSS_DRV_OAM_ENABLE + bool + default n + prompt "Enable OAM" +config NSS_DRV_PORTID_ENABLE + bool + default n + prompt "Enable PORTID" +config NSS_DRV_PPE_ENABLE + bool + default n + prompt "Enable PPE" +config NSS_DRV_PPPOE_ENABLE + bool + default n + prompt "Enable PPPOE" +config NSS_DRV_PPTP_ENABLE + bool + default y + prompt "Enable PPTP" +config NSS_DRV_PVXLAN_ENABLE + bool + default n + prompt "Enable PVXLAN" +config NSS_DRV_QRFS_ENABLE + bool + default n + prompt "Enable QRFS" +config NSS_DRV_QVPN_ENABLE + bool + default n + prompt "Enable QVPN" +config NSS_DRV_OVPN_ENABLE + bool + default n + prompt "Enable OVPN" +config NSS_DRV_RMNET_ENABLE + bool + default n + prompt "Enable RMNET" +config NSS_DRV_SHAPER_ENABLE + bool + default n + prompt "Enable SHAPER" +config NSS_DRV_SJACK_ENABLE + bool + default n + prompt "Enable SJACK" +config NSS_DRV_TLS_ENABLE + bool + default n + prompt "Enable TLS" +config NSS_DRV_TRUSTSEC_ENABLE + bool + default n + prompt "Enable TRUSTSEC" +config NSS_DRV_TRUSTSEC_RX_ENABLE + bool + default n + prompt "Enable TRUSTSEC_RX" + depends on NSS_DRV_TRUSTSEC_ENABLE +config NSS_DRV_TSTAMP_ENABLE + bool + default n + prompt "Enable TSTAMP" +config NSS_DRV_TUN6RD_ENABLE + bool + default n + prompt "Enable TUN6RD" +config NSS_DRV_TUNIPIP6_ENABLE + bool + default n + prompt "Enable TUNIPIP6" +config NSS_DRV_VIRT_IF_ENABLE + bool + default y + prompt "Enable VIRT_IF" +config NSS_DRV_VLAN_ENABLE + bool + default n + prompt "Enable VLAN" +config NSS_DRV_VXLAN_ENABLE + bool + default n + prompt "Enable VXLAN" +config NSS_DRV_WIFI_ENABLE + bool + default n + prompt "Enable WIFI" +config NSS_DRV_WIFI_EXT_VDEV_ENABLE + bool + default n + depends on NSS_DRV_WIFI_ENABLE + prompt "Enable WIFI EXT VDEV" +config NSS_DRV_WIFI_MESH_ENABLE + bool + default n + depends on NSS_DRV_WIFI_ENABLE + prompt "Enable WIFI MESH" +endmenu diff --git a/lede/package/qca/qca-nss-drv/Makefile b/lede/package/qca/qca-nss-drv/Makefile new file mode 100644 index 0000000000..625c8a2c86 --- /dev/null +++ b/lede/package/qca/qca-nss-drv/Makefile @@ -0,0 +1,277 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=qca-nss-drv +PKG_RELEASE:=$(AUTORELEASE) + +PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/nss-drv.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_DATE:=2023-08-06 +PKG_SOURCE_VERSION:=1ab184034529539f61093184a67d4454cb3eb352 +PKG_MIRROR_HASH:=6aa081c0853d3e3b6d78eee588a0967e540b2317d15aef3c3f6f7129925653f7 + +PKG_BUILD_PARALLEL:=1 +PKG_FLAGS:=nonshared + +PKG_CONFIG_DEPENDS:= \ + CONFIG_NSS_DRV_BRIDGE_ENABLE \ + CONFIG_NSS_DRV_C2C_ENABLE \ + CONFIG_NSS_DRV_CLMAP_ENABLE \ + CONFIG_NSS_DRV_CRYPTO_ENABLE \ + CONFIG_NSS_DRV_DMA_ENABLE \ + CONFIG_NSS_DRV_DTLS_ENABLE \ + CONFIG_NSS_DRV_EDMA_ENABLE \ + CONFIG_NSS_DRV_GRE_ENABLE \ + CONFIG_NSS_DRV_GRE_REDIR_ENABLE \ + CONFIG_NSS_DRV_GRE_TUNNEL_ENABLE \ + CONFIG_NSS_DRV_IGS_ENABLE \ + CONFIG_NSS_DRV_IPSEC_ENABLE \ + CONFIG_NSS_DRV_IPV4_REASM_ENABLE \ + CONFIG_NSS_DRV_IPV6_ENABLE \ + CONFIG_NSS_DRV_IPV6_REASM_ENABLE \ + CONFIG_NSS_DRV_L2TP_ENABLE \ + CONFIG_NSS_DRV_LAG_ENABLE \ + CONFIG_NSS_DRV_MAPT_ENABLE \ + CONFIG_NSS_DRV_MATCH_ENABLE \ + CONFIG_NSS_DRV_MIRROR_ENABLE \ + CONFIG_NSS_DRV_OAM_ENABLE \ + CONFIG_NSS_DRV_PORTID_ENABLE \ + CONFIG_NSS_DRV_PPE_ENABLE \ + CONFIG_NSS_DRV_PPPOE_ENABLE \ + CONFIG_NSS_DRV_PPTP_ENABLE \ + CONFIG_NSS_DRV_PVXLAN_ENABLE \ + CONFIG_NSS_DRV_QRFS_ENABLE \ + CONFIG_NSS_DRV_QVPN_ENABLE \ + CONFIG_NSS_DRV_OVPN_ENABLE \ + CONFIG_NSS_DRV_RMNET_ENABLE \ + CONFIG_NSS_DRV_SHAPER_ENABLE \ + CONFIG_NSS_DRV_SJACK_ENABLE \ + CONFIG_NSS_DRV_TLS_ENABLE \ + CONFIG_NSS_DRV_TRUSTSEC_ENABLE \ + CONFIG_NSS_DRV_TRUSTSEC_RX_ENABLE \ + CONFIG_NSS_DRV_TSTAMP_ENABLE \ + CONFIG_NSS_DRV_TUN6RD_ENABLE \ + CONFIG_NSS_DRV_TUNIPIP6_ENABLE \ + CONFIG_NSS_DRV_VIRT_IF_ENABLE \ + CONFIG_NSS_DRV_VLAN_ENABLE \ + CONFIG_NSS_DRV_VXLAN_ENABLE \ + CONFIG_NSS_DRV_WIFI_ENABLE \ + CONFIG_NSS_DRV_WIFI_EXT_VDEV_ENABLE \ + CONFIG_NSS_DRV_WIFI_MESH_ENABLE + +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/package.mk + +NSS_CLIENTS_DIR:=$(TOPDIR)/qca/src/qca-nss-clients + +define KernelPackage/qca-nss-drv + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + DEPENDS:=@(TARGET_qualcommax||TARGET_ipq60xx) +kmod-qca-nss-dp + TITLE:=Qualcomm NSS core driver + FILES:=$(PKG_BUILD_DIR)/qca-nss-drv.ko + AUTOLOAD:=$(call AutoLoad,32,qca-nss-drv) +endef + +define KernelPackage/qca-nss-drv/config + source "$(SOURCE)/Config.in" +endef + +define KernelPackage/qca-nss-drv/install + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_DIR) $(1)/etc/sysctl.d + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DIR) $(1)/etc/hotplug.d/firmware + $(INSTALL_DIR) $(1)/lib/debug + + $(INSTALL_BIN) ./files/qca-nss-drv.init $(1)/etc/init.d/qca-nss-drv + $(INSTALL_BIN) ./files/qca-nss-drv.sysctl $(1)/etc/sysctl.d/qca-nss-drv.conf + $(INSTALL_BIN) ./files/qca-nss-drv.conf $(1)/etc/config/nss + $(INSTALL_BIN) ./files/qca-nss-drv.hotplug $(1)/etc/hotplug.d/firmware/10-qca-nss-fw + $(INSTALL_BIN) ./files/qca-nss-drv.debug $(1)/lib/debug/qca-nss-drv + +endef + +define KernelPackage/qca-nss-drv/Description +This package contains a NSS driver for QCA chipset +endef + +ifeq ($(CONFIG_TARGET_SUBTARGET), "ipq807x") + SOC="ipq807x_64" + subtarget:=$(CONFIG_TARGET_SUBTARGET) +else ifeq ($(CONFIG_TARGET_SUBTARGET), "ipq60xx") + SOC="ipq60xx_64" + subtarget:=$(CONFIG_TARGET_SUBTARGET) +endif + +define Build/InstallDev + mkdir -p $(1)/usr/include/qca-nss-drv + $(CP) $(PKG_BUILD_DIR)/exports/* $(1)/usr/include/qca-nss-drv/ +ifneq (, $(findstring $(subtarget), "ipq807x" "ipq807x_64" "ipq60xx" "ipq60xx_64" "ipq50xx" "ipq50xx_64")) + $(RM) $(1)/usr/include/qca-nss-drv/nss_ipsecmgr.h + # $(INSTALL_DIR) $(1)/usr/include/qca-nss-clients + # $(CP) $(NSS_CLIENTS_DIR)/exports/nss_ipsecmgr.h $(1)/usr/include/qca-nss-clients/. +endif +endef + +EXTRA_CFLAGS+= -I$(STAGING_DIR)/usr/include/qca-nss-gmac \ + -I$(STAGING_DIR)/usr/include/qca-nss-dp \ + -I$(STAGING_DIR)/usr/include/qca-ssdk \ + -Wno-unused-variable \ + -Wno-error=unused-function + +ifneq (, $(findstring $(CONFIG_TARGET_BOARD), "qualcommax" "ipq60xx")) +EXTRA_CFLAGS+= -DNSS_MEM_PROFILE_MEDIUM +endif + +DRV_MAKE_OPTS:= +ifndef CONFIG_NSS_DRV_BRIDGE_ENABLE + DRV_MAKE_OPTS += NSS_DRV_BRIDGE_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_C2C_ENABLE + DRV_MAKE_OPTS += NSS_DRV_C2C_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_CLMAP_ENABLE + DRV_MAKE_OPTS += NSS_DRV_CLMAP_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_CRYPTO_ENABLE + DRV_MAKE_OPTS += NSS_DRV_CRYPTO_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_DMA_ENABLE + DRV_MAKE_OPTS += NSS_DRV_DMA_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_DTLS_ENABLE + DRV_MAKE_OPTS += NSS_DRV_DTLS_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_EDMA_ENABLE + DRV_MAKE_OPTS += NSS_DRV_EDMA_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_GRE_ENABLE + DRV_MAKE_OPTS += NSS_DRV_GRE_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_GRE_REDIR_ENABLE + DRV_MAKE_OPTS += NSS_DRV_GRE_REDIR_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_GRE_TUNNEL_ENABLE + DRV_MAKE_OPTS += NSS_DRV_GRE_TUNNEL_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_IGS_ENABLE + DRV_MAKE_OPTS += NSS_DRV_IGS_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_IPSEC_ENABLE + DRV_MAKE_OPTS += NSS_DRV_IPSEC_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_IPV4_REASM_ENABLE + DRV_MAKE_OPTS += NSS_DRV_IPV4_REASM_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_IPV6_ENABLE + DRV_MAKE_OPTS += NSS_DRV_IPV6_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_IPV6_REASM_ENABLE + DRV_MAKE_OPTS += NSS_DRV_IPV6_REASM_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_L2TP_ENABLE + DRV_MAKE_OPTS += NSS_DRV_L2TP_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_LAG_ENABLE + DRV_MAKE_OPTS += NSS_DRV_LAG_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_MAPT_ENABLE + DRV_MAKE_OPTS += NSS_DRV_MAPT_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_MATCH_ENABLE + DRV_MAKE_OPTS += NSS_DRV_MATCH_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_MIRROR_ENABLE + DRV_MAKE_OPTS += NSS_DRV_MIRROR_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_OAM_ENABLE + DRV_MAKE_OPTS += NSS_DRV_OAM_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_PORTID_ENABLE + DRV_MAKE_OPTS += NSS_DRV_PORTID_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_PPE_ENABLE + DRV_MAKE_OPTS += NSS_DRV_PPE_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_PPPOE_ENABLE + DRV_MAKE_OPTS += NSS_DRV_PPPOE_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_PPTP_ENABLE + DRV_MAKE_OPTS += NSS_DRV_PPTP_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_PVXLAN_ENABLE + DRV_MAKE_OPTS += NSS_DRV_PVXLAN_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_QRFS_ENABLE + DRV_MAKE_OPTS += NSS_DRV_QRFS_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_QVPN_ENABLE + DRV_MAKE_OPTS += NSS_DRV_QVPN_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_OVPN_ENABLE + DRV_MAKE_OPTS += NSS_DRV_OVPN_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_RMNET_ENABLE + DRV_MAKE_OPTS += NSS_DRV_RMNET_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_SHAPER_ENABLE + DRV_MAKE_OPTS += NSS_DRV_SHAPER_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_SJACK_ENABLE + DRV_MAKE_OPTS += NSS_DRV_SJACK_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_TLS_ENABLE + DRV_MAKE_OPTS += NSS_DRV_TLS_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_TRUSTSEC_ENABLE + DRV_MAKE_OPTS += NSS_DRV_TRUSTSEC_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_TRUSTSEC_RX_ENABLE + DRV_MAKE_OPTS += NSS_DRV_TRUSTSEC_RX_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_TSTAMP_ENABLE + DRV_MAKE_OPTS += NSS_DRV_TSTAMP_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_TUN6RD_ENABLE + DRV_MAKE_OPTS += NSS_DRV_TUN6RD_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_TUNIPIP6_ENABLE + DRV_MAKE_OPTS += NSS_DRV_TUNIPIP6_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_VIRT_IF_ENABLE + DRV_MAKE_OPTS += NSS_DRV_VIRT_IF_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_VLAN_ENABLE + DRV_MAKE_OPTS += NSS_DRV_VLAN_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_VXLAN_ENABLE + DRV_MAKE_OPTS += NSS_DRV_VXLAN_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_WIFI_ENABLE + DRV_MAKE_OPTS += NSS_DRV_WIFI_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_WIFI_EXT_VDEV_ENABLE + DRV_MAKE_OPTS += NSS_DRV_WIFI_EXT_VDEV_ENABLE=n +endif +ifndef CONFIG_NSS_DRV_WIFI_MESH_ENABLE + DRV_MAKE_OPTS += NSS_DRV_WIFI_MESH_ENABLE=n +endif + +define Build/Configure + $(LN) arch/nss_$(SOC).h $(PKG_BUILD_DIR)/exports/nss_arch.h +endef + +define Build/Compile + +$(MAKE) -C "$(LINUX_DIR)" $(strip $(DRV_MAKE_OPTS)) \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + ARCH="$(LINUX_KARCH)" \ + M="$(PKG_BUILD_DIR)" \ + EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ + SoC=$(SOC) \ + $(KERNEL_MAKE_FLAGS) \ + $(PKG_JOBS) \ + modules +endef + +$(eval $(call KernelPackage,qca-nss-drv)) diff --git a/lede/package/qca/qca-nss-drv/files/qca-nss-drv.conf b/lede/package/qca/qca-nss-drv/files/qca-nss-drv.conf new file mode 100644 index 0000000000..a8a1fbf406 --- /dev/null +++ b/lede/package/qca/qca-nss-drv/files/qca-nss-drv.conf @@ -0,0 +1,6 @@ +config nss_firmware 'qca_nss_0' + +config nss_firmware 'qca_nss_1' + +config general + option enable_rps '1' diff --git a/lede/package/qca/qca-nss-drv/files/qca-nss-drv.debug b/lede/package/qca/qca-nss-drv/files/qca-nss-drv.debug new file mode 100644 index 0000000000..5d435c3a76 --- /dev/null +++ b/lede/package/qca/qca-nss-drv/files/qca-nss-drv.debug @@ -0,0 +1,26 @@ +#!/bin/sh /sbin/sysdebug +# +# Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +log cat /sys/kernel/debug/qca-nss-drv/stats/pppoe +log cat /sys/kernel/debug/qca-nss-drv/stats/n2h +log cat /sys/kernel/debug/qca-nss-drv/stats/ipv6 +log cat /sys/kernel/debug/qca-nss-drv/stats/ipv4 +log cat /sys/kernel/debug/qca-nss-drv/stats/gmac +log cat /sys/kernel/debug/qca-nss-drv/stats/drv +log cat /sys/kernel/debug/qca-nss-drv/stats/wifi +log cat /sys/kernel/debug/qca-nss-drv/stats/wifi_if +log cat /sys/kernel/debug/qca-nss-drv/stats/eth_rx diff --git a/lede/package/qca/qca-nss-drv/files/qca-nss-drv.hotplug b/lede/package/qca/qca-nss-drv/files/qca-nss-drv.hotplug new file mode 100644 index 0000000000..1e4813838c --- /dev/null +++ b/lede/package/qca/qca-nss-drv/files/qca-nss-drv.hotplug @@ -0,0 +1,70 @@ +#!/bin/sh +# +# Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +KERNEL=`uname -r` +case "${KERNEL}" in + 3.4*) + select_or_load=load_nss_fw + ;; + *) + select_or_load=select_nss_fw + ;; +esac + +load_nss_fw () { + ls -l $1 | awk ' { print $9,$5 } '> /dev/console + echo 1 > /sys/class/firmware/$DEVICENAME/loading + cat $1 > /sys/class/firmware/$DEVICENAME/data + echo 0 > /sys/class/firmware/$DEVICENAME/loading +} + +select_nss_fw () { + rm -f /lib/firmware/$DEVICENAME + ln -s $1 /lib/firmware/$DEVICENAME + ls -l /lib/firmware/$DEVICENAME | awk ' { print $9,$5 } '> /dev/console +} + +[ "$ACTION" != "add" ] && exit + +# dev name for UCI, since it doesn't let you use . or - +SDEVNAME=$(echo ${DEVICENAME} | sed s/[.-]/_/g) + +SELECTED_FW=$(uci get nss.${SDEVNAME}.firmware 2>/dev/null) +[ -e "${SELECTED_FW}" ] && { + $select_or_load ${SELECTED_FW} + exit +} + +case $DEVICENAME in + qca-nss0* | qca-nss.0*) + if [ -e /lib/firmware/qca-nss0-enterprise.bin ] ; then + $select_or_load /lib/firmware/qca-nss0-enterprise.bin + else + $select_or_load /lib/firmware/qca-nss0-retail.bin + fi + exit + ;; + qca-nss1* | qca-nss.1*) + if [ -e /lib/firmware/qca-nss1-enterprise.bin ] ; then + $select_or_load /lib/firmware/qca-nss1-enterprise.bin + else + $select_or_load /lib/firmware/qca-nss1-retail.bin + fi + exit + ;; +esac + diff --git a/lede/package/qca/qca-nss-drv/files/qca-nss-drv.init b/lede/package/qca/qca-nss-drv/files/qca-nss-drv.init new file mode 100644 index 0000000000..de12cb6d12 --- /dev/null +++ b/lede/package/qca/qca-nss-drv/files/qca-nss-drv.init @@ -0,0 +1,50 @@ +#!/bin/sh /etc/rc.common +# +# Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +START=70 + +enable_rps() { + irq_nss_rps=`grep nss_queue1 /proc/interrupts | cut -d ':' -f 1 | tr -d ' '` + for entry in $irq_nss_rps + do + echo 2 > /proc/irq/$entry/smp_affinity + done + + irq_nss_rps=`grep nss_queue2 /proc/interrupts | cut -d ':' -f 1 | tr -d ' '` + for entry in $irq_nss_rps + do + echo 4 > /proc/irq/$entry/smp_affinity + done + + irq_nss_rps=`grep nss_queue3 /proc/interrupts | cut -d ':' -f 1 | tr -d ' '` + for entry in $irq_nss_rps + do + echo 8 > /proc/irq/$entry/smp_affinity + done + + # Enable NSS RPS + sysctl -w dev.nss.rps.enable=1 >/dev/null 2>/dev/null + +} + + +start() { + local rps_enabled="$(uci_get nss @general[0] enable_rps)" + if [ "$rps_enabled" -eq 1 ]; then + enable_rps + fi +} diff --git a/lede/package/qca/qca-nss-drv/files/qca-nss-drv.sysctl b/lede/package/qca/qca-nss-drv/files/qca-nss-drv.sysctl new file mode 100644 index 0000000000..0276bba120 --- /dev/null +++ b/lede/package/qca/qca-nss-drv/files/qca-nss-drv.sysctl @@ -0,0 +1,3 @@ +# Default Number of connection configuration +dev.nss.ipv4cfg.ipv4_conn=4096 +dev.nss.ipv6cfg.ipv6_conn=4096 diff --git a/lede/package/qca/qca-nss-drv/patches/0001-nss-drv-replace-ioremap_nocache-with-ioremap.patch b/lede/package/qca/qca-nss-drv/patches/0001-nss-drv-replace-ioremap_nocache-with-ioremap.patch new file mode 100644 index 0000000000..edbd104344 --- /dev/null +++ b/lede/package/qca/qca-nss-drv/patches/0001-nss-drv-replace-ioremap_nocache-with-ioremap.patch @@ -0,0 +1,207 @@ +From dddfe22459a988a5b86d195bc3cc3bd3c2ac7037 Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Sat, 14 Jan 2023 21:52:38 +0100 +Subject: [PATCH 1/4] nss-drv: replace ioremap_nocache() with ioremap() + +Since 5.5 ioremap_nocache is equal to ioremap on all archs and was removed +from the kernel, so just use ioremap instead. + +Signed-off-by: Robert Marko +--- + nss_hal/fsm9010/nss_hal_pvt.c | 2 +- + nss_hal/ipq50xx/nss_hal_pvt.c | 6 +++--- + nss_hal/ipq60xx/nss_hal_pvt.c | 8 ++++---- + nss_hal/ipq806x/nss_hal_pvt.c | 4 ++-- + nss_hal/ipq807x/nss_hal_pvt.c | 6 +++--- + nss_hal/ipq95xx/nss_hal_pvt.c | 6 +++--- + nss_hal/nss_hal.c | 4 ++-- + nss_meminfo.c | 2 +- + nss_ppe.c | 2 +- + 9 files changed, 20 insertions(+), 20 deletions(-) + +--- a/nss_hal/fsm9010/nss_hal_pvt.c ++++ b/nss_hal/fsm9010/nss_hal_pvt.c +@@ -145,7 +145,7 @@ static struct nss_platform_data *__nss_h + npd->nphys = res_nphys.start; + npd->vphys = res_vphys.start; + +- npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys)); ++ npd->nmap = ioremap(npd->nphys, resource_size(&res_nphys)); + if (!npd->nmap) { + nss_info_always("%px: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); + goto out; +--- a/nss_hal/ipq50xx/nss_hal_pvt.c ++++ b/nss_hal/ipq50xx/nss_hal_pvt.c +@@ -185,13 +185,13 @@ static struct nss_platform_data *__nss_h + npd->nphys = res_nphys.start; + npd->qgic_phys = res_qgic_phys.start; + +- npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys)); ++ npd->nmap = ioremap(npd->nphys, resource_size(&res_nphys)); + if (!npd->nmap) { + nss_info_always("%px: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); + goto out; + } + +- npd->qgic_map = ioremap_nocache(npd->qgic_phys, resource_size(&res_qgic_phys)); ++ npd->qgic_map = ioremap(npd->qgic_phys, resource_size(&res_qgic_phys)); + if (!npd->qgic_map) { + nss_info_always("%px: nss%d: ioremap() fail for qgic map\n", nss_ctx, nss_ctx->id); + goto out; +@@ -349,7 +349,7 @@ static int __nss_hal_common_reset(struct + + of_node_put(cmn); + +- nss_misc_reset = ioremap_nocache(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); ++ nss_misc_reset = ioremap(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); + if (!nss_misc_reset) { + pr_err("%px: ioremap fail for nss_misc_reset\n", nss_dev); + return -EFAULT; +--- a/nss_hal/ipq60xx/nss_hal_pvt.c ++++ b/nss_hal/ipq60xx/nss_hal_pvt.c +@@ -208,13 +208,13 @@ static struct nss_platform_data *__nss_h + npd->nphys = res_nphys.start; + npd->qgic_phys = res_qgic_phys.start; + +- npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys)); ++ npd->nmap = ioremap(npd->nphys, resource_size(&res_nphys)); + if (!npd->nmap) { + nss_info_always("%px: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); + goto out; + } + +- npd->qgic_map = ioremap_nocache(npd->qgic_phys, resource_size(&res_qgic_phys)); ++ npd->qgic_map = ioremap(npd->qgic_phys, resource_size(&res_qgic_phys)); + if (!npd->qgic_map) { + nss_info_always("%px: nss%d: ioremap() fail for qgic map\n", nss_ctx, nss_ctx->id); + goto out; +@@ -434,13 +434,13 @@ static int __nss_hal_common_reset(struct + + of_node_put(cmn); + +- nss_misc_reset = ioremap_nocache(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); ++ nss_misc_reset = ioremap(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); + if (!nss_misc_reset) { + pr_err("%px: ioremap fail for nss_misc_reset\n", nss_dev); + return -EFAULT; + } + +- nss_misc_reset_flag = ioremap_nocache(res_nss_misc_reset_flag.start, resource_size(&res_nss_misc_reset_flag)); ++ nss_misc_reset_flag = ioremap(res_nss_misc_reset_flag.start, resource_size(&res_nss_misc_reset_flag)); + if (!nss_misc_reset_flag) { + pr_err("%px: ioremap fail for nss_misc_reset_flag\n", nss_dev); + return -EFAULT; +--- a/nss_hal/ipq806x/nss_hal_pvt.c ++++ b/nss_hal/ipq806x/nss_hal_pvt.c +@@ -461,7 +461,7 @@ static struct nss_platform_data *__nss_h + npd->nphys = res_nphys.start; + npd->vphys = res_vphys.start; + +- npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys)); ++ npd->nmap = ioremap(npd->nphys, resource_size(&res_nphys)); + if (!npd->nmap) { + nss_info_always("%px: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); + goto out; +@@ -714,7 +714,7 @@ static int __nss_hal_common_reset(struct + } + of_node_put(cmn); + +- fpb_base = ioremap_nocache(res_nss_fpb_base.start, resource_size(&res_nss_fpb_base)); ++ fpb_base = ioremap(res_nss_fpb_base.start, resource_size(&res_nss_fpb_base)); + if (!fpb_base) { + pr_err("%px: ioremap fail for nss_fpb_base\n", nss_dev); + return -EFAULT; +--- a/nss_hal/ipq807x/nss_hal_pvt.c ++++ b/nss_hal/ipq807x/nss_hal_pvt.c +@@ -237,7 +237,7 @@ static struct nss_platform_data *__nss_h + npd->vphys = res_vphys.start; + npd->qgic_phys = res_qgic_phys.start; + +- npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys)); ++ npd->nmap = ioremap(npd->nphys, resource_size(&res_nphys)); + if (!npd->nmap) { + nss_info_always("%px: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); + goto out; +@@ -250,7 +250,7 @@ static struct nss_platform_data *__nss_h + goto out; + } + +- npd->qgic_map = ioremap_nocache(npd->qgic_phys, resource_size(&res_qgic_phys)); ++ npd->qgic_map = ioremap(npd->qgic_phys, resource_size(&res_qgic_phys)); + if (!npd->qgic_map) { + nss_info_always("%px: nss%d: ioremap() fail for qgic map\n", nss_ctx, nss_ctx->id); + goto out; +@@ -470,7 +470,7 @@ static int __nss_hal_common_reset(struct + } + of_node_put(cmn); + +- nss_misc_reset = ioremap_nocache(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); ++ nss_misc_reset = ioremap(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); + if (!nss_misc_reset) { + pr_err("%px: ioremap fail for nss_misc_reset\n", nss_dev); + return -EFAULT; +--- a/nss_hal/ipq95xx/nss_hal_pvt.c ++++ b/nss_hal/ipq95xx/nss_hal_pvt.c +@@ -291,7 +291,7 @@ static struct nss_platform_data *__nss_h + npd->vphys = res_vphys.start; + npd->qgic_phys = res_qgic_phys.start; + +- npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys)); ++ npd->nmap = ioremap(npd->nphys, resource_size(&res_nphys)); + if (!npd->nmap) { + nss_info_always("%px: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); + goto out; +@@ -303,7 +303,7 @@ static struct nss_platform_data *__nss_h + goto out; + } + +- npd->qgic_map = ioremap_nocache(npd->qgic_phys, resource_size(&res_qgic_phys)); ++ npd->qgic_map = ioremap(npd->qgic_phys, resource_size(&res_qgic_phys)); + if (!npd->qgic_map) { + nss_info_always("%px: nss%d: ioremap() fail for qgic map\n", nss_ctx, nss_ctx->id); + goto out; +@@ -608,7 +608,7 @@ static int __nss_hal_common_reset(struct + + of_node_put(cmn); + +- nss_misc_reset = ioremap_nocache(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); ++ nss_misc_reset = ioremap(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); + if (!nss_misc_reset) { + pr_err("%px: ioremap fail for nss_misc_reset\n", nss_dev); + return -EFAULT; +--- a/nss_hal/nss_hal.c ++++ b/nss_hal/nss_hal.c +@@ -81,9 +81,9 @@ int nss_hal_firmware_load(struct nss_ctx + } + + +- load_mem = ioremap_nocache(npd->load_addr, nss_fw->size); ++ load_mem = ioremap(npd->load_addr, nss_fw->size); + if (!load_mem) { +- nss_info_always("%px: ioremap_nocache failed: %x", nss_ctx, npd->load_addr); ++ nss_info_always("%px: ioremap failed: %x", nss_ctx, npd->load_addr); + release_firmware(nss_fw); + return rc; + } +--- a/nss_meminfo.c ++++ b/nss_meminfo.c +@@ -736,7 +736,7 @@ bool nss_meminfo_init(struct nss_ctx_ins + /* + * meminfo_start is the label where the start address of meminfo map is stored. + */ +- meminfo_start = (uint32_t *)ioremap_nocache(nss_ctx->load + NSS_MEMINFO_MAP_START_OFFSET, ++ meminfo_start = (uint32_t *)ioremap(nss_ctx->load + NSS_MEMINFO_MAP_START_OFFSET, + NSS_MEMINFO_RESERVE_AREA_SIZE); + if (!meminfo_start) { + nss_info_always("%px: cannot remap meminfo start\n", nss_ctx); +--- a/nss_ppe.c ++++ b/nss_ppe.c +@@ -357,7 +357,7 @@ void nss_ppe_init(void) + /* + * Get the PPE base address + */ +- ppe_pvt.ppe_base = ioremap_nocache(PPE_BASE_ADDR, PPE_REG_SIZE); ++ ppe_pvt.ppe_base = ioremap(PPE_BASE_ADDR, PPE_REG_SIZE); + if (!ppe_pvt.ppe_base) { + nss_warning("DRV can't get PPE base address\n"); + return; diff --git a/lede/package/qca/qca-nss-drv/patches/0002-nss-drv-add-support-for-kernel-5.15.patch b/lede/package/qca/qca-nss-drv/patches/0002-nss-drv-add-support-for-kernel-5.15.patch new file mode 100644 index 0000000000..279c18e573 --- /dev/null +++ b/lede/package/qca/qca-nss-drv/patches/0002-nss-drv-add-support-for-kernel-5.15.patch @@ -0,0 +1,62 @@ +From 2a3b9f4659542e529f4e1a535c33dfde7e272707 Mon Sep 17 00:00:00 2001 +From: Ansuel Smith +Date: Tue, 5 Apr 2022 18:10:57 +0200 +Subject: [PATCH 2/4] nss-drv: add support for kernel 5.15 + +- Fix coredump panic notifier include change. +- Fix skb ZEROCOPY flag. +- Add skb reuse support for 5.15 kernel version. + +Signed-off-by: Ansuel Smith +--- + nss_core.c | 5 +++-- + nss_coredump.c | 4 ++++ + nss_hal/nss_hal.c | 1 + + 3 files changed, 9 insertions(+), 2 deletions(-) + +--- a/nss_core.c ++++ b/nss_core.c +@@ -61,7 +61,9 @@ + (((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)))) || \ + (((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)))) || \ + (((LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)))) || \ +-(((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0)))))) ++(((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0)))) || \ ++(((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)))) || \ ++(((LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0)))))) + #error "Check skb recycle code in this file to match Linux version" + #endif + +@@ -2658,7 +2660,7 @@ static inline bool nss_core_skb_can_reus + if (unlikely(irqs_disabled())) + return false; + +- if (unlikely(skb_shinfo(nbuf)->tx_flags & SKBTX_DEV_ZEROCOPY)) ++ if (unlikely(skb_shinfo(nbuf)->flags & SKBFL_ZEROCOPY_ENABLE)) + return false; + + if (unlikely(skb_is_nonlinear(nbuf))) +--- a/nss_coredump.c ++++ b/nss_coredump.c +@@ -25,7 +25,11 @@ + #include "nss_hal.h" + #include "nss_log.h" + #include ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)) + #include /* for panic_notifier_list */ ++#else ++#include ++#endif + #include /* for time */ + #include "nss_tx_rx_common.h" + +--- a/nss_hal/nss_hal.c ++++ b/nss_hal/nss_hal.c +@@ -27,6 +27,7 @@ + #include + #include + #include ++#include + + #include "nss_hal.h" + #include "nss_arch.h" diff --git a/lede/package/qca/qca-nss-drv/patches/0003-DMA-Fix-NULL-pointer-exceptions.patch b/lede/package/qca/qca-nss-drv/patches/0003-DMA-Fix-NULL-pointer-exceptions.patch new file mode 100644 index 0000000000..4577b8a4b0 --- /dev/null +++ b/lede/package/qca/qca-nss-drv/patches/0003-DMA-Fix-NULL-pointer-exceptions.patch @@ -0,0 +1,28 @@ +From a6e3e81daab4eb9acbdef0ad1fed056e1bfbe320 Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Tue, 8 Jun 2021 23:24:43 +0200 +Subject: [PATCH 3/4] DMA: Fix NULL pointer exceptions + +There are multiple instances that pass NULL instead +of device to DMA functions. +That is incorrect and will cause kernel NULL pointer +exceptions. + +So, simply pass the device structure pointers. + +Signed-off-by: Robert Marko +--- + nss_core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/nss_core.c ++++ b/nss_core.c +@@ -1660,7 +1660,7 @@ static int32_t nss_core_handle_cause_que + * + */ + if (unlikely((buffer_type == N2H_BUFFER_CRYPTO_RESP))) { +- dma_unmap_single(NULL, (desc->buffer + desc->payload_offs), desc->payload_len, DMA_FROM_DEVICE); ++ dma_unmap_single(nss_ctx->dev, (desc->buffer + desc->payload_offs), desc->payload_len, DMA_FROM_DEVICE); + goto consume; + } + diff --git a/lede/package/qca/qca-nss-drv/patches/0004-nss-drv-rework-NSS_CORE_DMA_CACHE_MAINT-ops.patch b/lede/package/qca/qca-nss-drv/patches/0004-nss-drv-rework-NSS_CORE_DMA_CACHE_MAINT-ops.patch new file mode 100644 index 0000000000..793da70f01 --- /dev/null +++ b/lede/package/qca/qca-nss-drv/patches/0004-nss-drv-rework-NSS_CORE_DMA_CACHE_MAINT-ops.patch @@ -0,0 +1,558 @@ +From e6814c47d22ee5133a71016375239f87ea265794 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Tue, 5 Apr 2022 15:38:18 +0200 +Subject: [PATCH 4/4] nss-drv: rework NSS_CORE_DMA_CACHE_MAINT ops + +Rework NSS_CORE_DMA_CACHE_MAINT ops to use standard dma sync ops instead +of using the direct arch function. This permit to skip any hack/patch +needed for nss-drv to correctly compile on upstream kernel. + +We drop any NSS_CORE_DMA_CACHE_MAINT use in nss_core and we correctly +use the dma_sync_single_for_device we correctly dma addr using the new +DMA helper. +We drop sync for IOREMAP addr and we just leave a memory block. +We hope the nss_profiler is correctly ported. +We finally drop the NSS_CORE_DMA_CACHE_MAINT jus in case someone wants +to use it. + +Signed-off-by: Christian Marangi +--- + nss_core.c | 136 +++++++++++++++++++++++++--------- + nss_core.h | 41 +++++----- + nss_hal/ipq806x/nss_hal_pvt.c | 5 +- + nss_hal/ipq807x/nss_hal_pvt.c | 5 +- + nss_meminfo.c | 5 +- + nss_profiler.c | 3 +- + 6 files changed, 127 insertions(+), 68 deletions(-) + +--- a/nss_core.c ++++ b/nss_core.c +@@ -1472,6 +1472,8 @@ static inline void nss_core_handle_empty + uint32_t count, uint32_t hlos_index, + uint16_t mask) + { ++ struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; ++ + while (count) { + /* + * Since we only return the primary skb, we have no way to unmap +@@ -1525,7 +1527,9 @@ next: + n2h_desc_ring->hlos_index = hlos_index; + if_map->n2h_hlos_index[NSS_IF_N2H_EMPTY_BUFFER_RETURN_QUEUE] = hlos_index; + +- NSS_CORE_DMA_CACHE_MAINT((void *)&if_map->n2h_hlos_index[NSS_IF_N2H_EMPTY_BUFFER_RETURN_QUEUE], sizeof(uint32_t), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, ++ n2h_hlos_index_to_dma(mem_ctx->if_map_dma, NSS_IF_N2H_EMPTY_BUFFER_RETURN_QUEUE), ++ sizeof(uint32_t), DMA_TO_DEVICE); + NSS_CORE_DSB(); + } + +@@ -1547,6 +1551,7 @@ static int32_t nss_core_handle_cause_que + struct nss_ctx_instance *nss_ctx = int_ctx->nss_ctx; + struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; + struct nss_if_mem_map *if_map = mem_ctx->if_map; ++ int dma_size; + + qid = nss_core_cause_to_queue(cause); + +@@ -1558,7 +1563,8 @@ static int32_t nss_core_handle_cause_que + n2h_desc_ring = &nss_ctx->n2h_desc_ring[qid]; + desc_if = &n2h_desc_ring->desc_ring; + desc_ring = desc_if->desc; +- NSS_CORE_DMA_CACHE_MAINT((void *)&if_map->n2h_nss_index[qid], sizeof(uint32_t), DMA_FROM_DEVICE); ++ dma_sync_single_for_cpu(nss_ctx->dev, n2h_nss_index_to_dma(mem_ctx->if_map_dma, qid), ++ sizeof(uint32_t), DMA_FROM_DEVICE); + NSS_CORE_DSB(); + nss_index = if_map->n2h_nss_index[qid]; + +@@ -1587,13 +1593,23 @@ static int32_t nss_core_handle_cause_que + start = hlos_index; + end = (hlos_index + count) & mask; + if (end > start) { +- dmac_inv_range((void *)&desc_ring[start], (void *)&desc_ring[end] + sizeof(struct n2h_descriptor)); ++ dma_size = sizeof(struct n2h_descriptor) * (end - start + 1); ++ ++ dma_sync_single_for_cpu(nss_ctx->dev, n2h_desc_index_to_dma(if_map, qid, start), ++ dma_size, DMA_FROM_DEVICE); + } else { + /* + * We have wrapped around + */ +- dmac_inv_range((void *)&desc_ring[start], (void *)&desc_ring[mask] + sizeof(struct n2h_descriptor)); +- dmac_inv_range((void *)&desc_ring[0], (void *)&desc_ring[end] + sizeof(struct n2h_descriptor)); ++ dma_size = sizeof(struct n2h_descriptor) * (mask - start + 1); ++ ++ dma_sync_single_for_cpu(nss_ctx->dev, n2h_desc_index_to_dma(if_map, qid, start), ++ dma_size, DMA_FROM_DEVICE); ++ ++ dma_size = sizeof(struct n2h_descriptor) * (end + 1); ++ ++ dma_sync_single_for_cpu(nss_ctx->dev, n2h_desc_index_to_dma(if_map, qid, 0), dma_size, ++ DMA_FROM_DEVICE); + } + + /* +@@ -1722,7 +1738,8 @@ next: + n2h_desc_ring->hlos_index = hlos_index; + if_map->n2h_hlos_index[qid] = hlos_index; + +- NSS_CORE_DMA_CACHE_MAINT((void *)&if_map->n2h_hlos_index[qid], sizeof(uint32_t), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, n2h_hlos_index_to_dma(mem_ctx->if_map_dma, qid), ++ sizeof(uint32_t), DMA_TO_DEVICE); + NSS_CORE_DSB(); + + return count; +@@ -1734,11 +1751,12 @@ next: + */ + static void nss_core_init_nss(struct nss_ctx_instance *nss_ctx, struct nss_if_mem_map *if_map) + { ++ struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; + struct nss_top_instance *nss_top; + int ret; + int i; + +- NSS_CORE_DMA_CACHE_MAINT((void *)if_map, sizeof(*if_map), DMA_FROM_DEVICE); ++ dma_sync_single_for_cpu(nss_ctx->dev, mem_ctx->if_map_dma, sizeof(*if_map), DMA_FROM_DEVICE); + NSS_CORE_DSB(); + + /* +@@ -1835,6 +1853,7 @@ static void nss_core_alloc_paged_buffers + uint16_t count, int16_t mask, int32_t hlos_index, uint32_t alloc_fail_count, + uint32_t buffer_type, uint32_t buffer_queue, uint32_t stats_index) + { ++ struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; + struct sk_buff *nbuf; + struct page *npage; + struct hlos_h2n_desc_rings *h2n_desc_ring = &nss_ctx->h2n_desc_rings[buffer_queue]; +@@ -1904,7 +1923,9 @@ static void nss_core_alloc_paged_buffers + /* + * Flush the descriptor + */ +- NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, ++ h2n_desc_index_to_dma(if_map, buffer_queue, hlos_index), ++ sizeof(*desc), DMA_TO_DEVICE); + + hlos_index = (hlos_index + 1) & (mask); + count--; +@@ -1918,7 +1939,8 @@ static void nss_core_alloc_paged_buffers + h2n_desc_ring->hlos_index = hlos_index; + if_map->h2n_hlos_index[buffer_queue] = hlos_index; + +- NSS_CORE_DMA_CACHE_MAINT(&if_map->h2n_hlos_index[buffer_queue], sizeof(uint32_t), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, h2n_hlos_index_to_dma(mem_ctx->if_map_dma, buffer_queue), ++ sizeof(uint32_t), DMA_TO_DEVICE); + NSS_CORE_DSB(); + + NSS_PKT_STATS_INC(&nss_top->stats_drv[stats_index]); +@@ -1931,7 +1953,7 @@ static void nss_core_alloc_paged_buffers + static void nss_core_alloc_jumbo_mru_buffers(struct nss_ctx_instance *nss_ctx, struct nss_if_mem_map *if_map, + int jumbo_mru, uint16_t count, int16_t mask, int32_t hlos_index) + { +- ++ struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; + struct sk_buff *nbuf; + struct hlos_h2n_desc_rings *h2n_desc_ring = &nss_ctx->h2n_desc_rings[NSS_IF_H2N_EMPTY_BUFFER_QUEUE]; + struct h2n_desc_if_instance *desc_if = &h2n_desc_ring->desc_ring; +@@ -1978,7 +2000,9 @@ static void nss_core_alloc_jumbo_mru_buf + /* + * Flush the descriptor + */ +- NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, ++ h2n_desc_index_to_dma(if_map, NSS_IF_H2N_EMPTY_BUFFER_QUEUE, hlos_index), ++ sizeof(*desc), DMA_TO_DEVICE); + + hlos_index = (hlos_index + 1) & (mask); + count--; +@@ -1992,7 +2016,8 @@ static void nss_core_alloc_jumbo_mru_buf + h2n_desc_ring->hlos_index = hlos_index; + if_map->h2n_hlos_index[NSS_IF_H2N_EMPTY_BUFFER_QUEUE] = hlos_index; + +- NSS_CORE_DMA_CACHE_MAINT(&if_map->h2n_hlos_index[NSS_IF_H2N_EMPTY_BUFFER_QUEUE], sizeof(uint32_t), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, h2n_hlos_index_to_dma(mem_ctx->if_map_dma, NSS_IF_H2N_EMPTY_BUFFER_QUEUE), ++ sizeof(uint32_t), DMA_TO_DEVICE); + NSS_CORE_DSB(); + + NSS_PKT_STATS_INC(&nss_top->stats_drv[NSS_DRV_STATS_TX_EMPTY]); +@@ -2005,6 +2030,7 @@ static void nss_core_alloc_jumbo_mru_buf + static void nss_core_alloc_max_avail_size_buffers(struct nss_ctx_instance *nss_ctx, struct nss_if_mem_map *if_map, + uint16_t max_buf_size, uint16_t count, int16_t mask, int32_t hlos_index) + { ++ struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; + struct hlos_h2n_desc_rings *h2n_desc_ring = &nss_ctx->h2n_desc_rings[NSS_IF_H2N_EMPTY_BUFFER_QUEUE]; + struct h2n_desc_if_instance *desc_if = &h2n_desc_ring->desc_ring; + struct h2n_descriptor *desc_ring = desc_if->desc; +@@ -2012,6 +2038,7 @@ static void nss_core_alloc_max_avail_siz + uint16_t payload_len = max_buf_size + NET_SKB_PAD; + uint16_t start = hlos_index; + uint16_t prev_hlos_index; ++ int dma_size; + + while (count) { + dma_addr_t buffer; +@@ -2064,13 +2091,26 @@ static void nss_core_alloc_max_avail_siz + * Flush the descriptors, including the descriptor at prev_hlos_index. + */ + if (prev_hlos_index > start) { +- dmac_clean_range((void *)&desc_ring[start], (void *)&desc_ring[prev_hlos_index] + sizeof(struct h2n_descriptor)); ++ dma_size = sizeof(struct h2n_descriptor) * (prev_hlos_index - start + 1); ++ ++ dma_sync_single_for_device(nss_ctx->dev, ++ h2n_desc_index_to_dma(if_map, NSS_IF_H2N_EMPTY_BUFFER_QUEUE, start), ++ dma_size, DMA_TO_DEVICE); + } else { + /* + * We have wrapped around + */ +- dmac_clean_range((void *)&desc_ring[start], (void *)&desc_ring[mask] + sizeof(struct h2n_descriptor)); +- dmac_clean_range((void *)&desc_ring[0], (void *)&desc_ring[prev_hlos_index] + sizeof(struct h2n_descriptor)); ++ dma_size = sizeof(struct h2n_descriptor) * (mask - start + 1); ++ ++ dma_sync_single_for_device(nss_ctx->dev, ++ h2n_desc_index_to_dma(if_map, NSS_IF_H2N_EMPTY_BUFFER_QUEUE, start), ++ dma_size, DMA_TO_DEVICE); ++ ++ dma_size = sizeof(struct h2n_descriptor) * (prev_hlos_index + 1); ++ ++ dma_sync_single_for_device(nss_ctx->dev, ++ h2n_desc_index_to_dma(if_map, NSS_IF_H2N_EMPTY_BUFFER_QUEUE, 0), ++ dma_size, DMA_TO_DEVICE); + } + + /* +@@ -2081,7 +2121,8 @@ static void nss_core_alloc_max_avail_siz + h2n_desc_ring->hlos_index = hlos_index; + if_map->h2n_hlos_index[NSS_IF_H2N_EMPTY_BUFFER_QUEUE] = hlos_index; + +- NSS_CORE_DMA_CACHE_MAINT(&if_map->h2n_hlos_index[NSS_IF_H2N_EMPTY_BUFFER_QUEUE], sizeof(uint32_t), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, h2n_hlos_index_to_dma(mem_ctx->if_map_dma, NSS_IF_H2N_EMPTY_BUFFER_QUEUE), ++ sizeof(uint32_t), DMA_TO_DEVICE); + NSS_CORE_DSB(); + + NSS_PKT_STATS_INC(&nss_top->stats_drv[NSS_DRV_STATS_TX_EMPTY]); +@@ -2094,6 +2135,7 @@ static void nss_core_alloc_max_avail_siz + static inline void nss_core_handle_empty_buffer_sos(struct nss_ctx_instance *nss_ctx, + struct nss_if_mem_map *if_map, uint16_t max_buf_size) + { ++ struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; + uint16_t count, size, mask; + int32_t nss_index, hlos_index; + struct hlos_h2n_desc_rings *h2n_desc_ring = &nss_ctx->h2n_desc_rings[NSS_IF_H2N_EMPTY_BUFFER_QUEUE]; +@@ -2104,7 +2146,8 @@ static inline void nss_core_handle_empty + /* + * Check how many empty buffers could be filled in queue + */ +- NSS_CORE_DMA_CACHE_MAINT(&if_map->h2n_nss_index[NSS_IF_H2N_EMPTY_BUFFER_QUEUE], sizeof(uint32_t), DMA_FROM_DEVICE); ++ dma_sync_single_for_cpu(nss_ctx->dev, h2n_nss_index_to_dma(mem_ctx->if_map_dma, NSS_IF_H2N_EMPTY_BUFFER_QUEUE), ++ sizeof(uint32_t), DMA_FROM_DEVICE); + NSS_CORE_DSB(); + nss_index = if_map->h2n_nss_index[NSS_IF_H2N_EMPTY_BUFFER_QUEUE]; + +@@ -2149,6 +2192,7 @@ static inline void nss_core_handle_empty + static inline void nss_core_handle_paged_empty_buffer_sos(struct nss_ctx_instance *nss_ctx, + struct nss_if_mem_map *if_map, uint16_t max_buf_size) + { ++ struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; + uint16_t count, size, mask; + int32_t nss_index, hlos_index; + struct hlos_h2n_desc_rings *h2n_desc_ring = &nss_ctx->h2n_desc_rings[NSS_IF_H2N_EMPTY_PAGED_BUFFER_QUEUE]; +@@ -2156,7 +2200,8 @@ static inline void nss_core_handle_paged + /* + * Check how many empty buffers could be filled in queue + */ +- NSS_CORE_DMA_CACHE_MAINT((void *)&if_map->h2n_nss_index[NSS_IF_H2N_EMPTY_PAGED_BUFFER_QUEUE], sizeof(uint32_t), DMA_FROM_DEVICE); ++ dma_sync_single_for_cpu(nss_ctx->dev, h2n_nss_index_to_dma(mem_ctx->if_map_dma, NSS_IF_H2N_EMPTY_PAGED_BUFFER_QUEUE), ++ sizeof(uint32_t), DMA_FROM_DEVICE); + NSS_CORE_DSB(); + nss_index = if_map->h2n_nss_index[NSS_IF_H2N_EMPTY_PAGED_BUFFER_QUEUE]; + +@@ -2733,9 +2778,11 @@ void nss_skb_reuse(struct sk_buff *nbuf) + * Sends one skb to NSS FW + */ + static inline int32_t nss_core_send_buffer_simple_skb(struct nss_ctx_instance *nss_ctx, +- struct h2n_desc_if_instance *desc_if, uint32_t if_num, +- struct sk_buff *nbuf, uint16_t hlos_index, uint16_t flags, uint8_t buffer_type, uint16_t mss) ++ struct h2n_desc_if_instance *desc_if, uint32_t if_num, struct sk_buff *nbuf, ++ uint16_t qid, uint16_t hlos_index, uint16_t flags, uint8_t buffer_type, uint16_t mss) + { ++ struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; ++ struct nss_if_mem_map *if_map = mem_ctx->if_map; + struct h2n_descriptor *desc_ring = desc_if->desc; + struct h2n_descriptor *desc; + uint16_t bit_flags; +@@ -2789,7 +2836,8 @@ static inline int32_t nss_core_send_buff + (nss_ptr_t)nbuf, (uint16_t)(nbuf->data - nbuf->head), nbuf->len, + sz, (uint32_t)nbuf->priority, mss, bit_flags); + +- NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, h2n_desc_index_to_dma(if_map, qid, hlos_index), ++ sizeof(*desc), DMA_TO_DEVICE); + + /* + * We are done using the skb fields and can reuse it now +@@ -2813,7 +2861,8 @@ no_reuse: + (nss_ptr_t)nbuf, (uint16_t)(nbuf->data - nbuf->head), nbuf->len, + (uint16_t)skb_end_offset(nbuf), (uint32_t)nbuf->priority, mss, bit_flags); + +- NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, h2n_desc_index_to_dma(if_map, qid, hlos_index), ++ sizeof(*desc), DMA_TO_DEVICE); + + NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_SIMPLE]); + return 1; +@@ -2827,9 +2876,11 @@ no_reuse: + * Used to differentiate from FRAGLIST + */ + static inline int32_t nss_core_send_buffer_nr_frags(struct nss_ctx_instance *nss_ctx, +- struct h2n_desc_if_instance *desc_if, uint32_t if_num, +- struct sk_buff *nbuf, uint16_t hlos_index, uint16_t flags, uint8_t buffer_type, uint16_t mss) ++ struct h2n_desc_if_instance *desc_if, uint32_t if_num, struct sk_buff *nbuf, ++ uint16_t qid, uint16_t hlos_index, uint16_t flags, uint8_t buffer_type, uint16_t mss) + { ++ struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; ++ struct nss_if_mem_map *if_map = mem_ctx->if_map; + struct h2n_descriptor *desc_ring = desc_if->desc; + struct h2n_descriptor *desc; + const skb_frag_t *frag; +@@ -2869,7 +2920,8 @@ static inline int32_t nss_core_send_buff + (nss_ptr_t)NULL, nbuf->data - nbuf->head, nbuf->len - nbuf->data_len, + skb_end_offset(nbuf), (uint32_t)nbuf->priority, mss, bit_flags | H2N_BIT_FLAG_FIRST_SEGMENT); + +- NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, h2n_desc_index_to_dma(if_map, qid, hlos_index), ++ sizeof(*desc), DMA_TO_DEVICE); + + /* + * Now handle rest of the fragments. +@@ -2893,7 +2945,8 @@ static inline int32_t nss_core_send_buff + (nss_ptr_t)NULL, 0, skb_frag_size(frag), skb_frag_size(frag), + nbuf->priority, mss, bit_flags); + +- NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, h2n_desc_index_to_dma(if_map, qid, hlos_index), ++ sizeof(*desc), DMA_TO_DEVICE); + } + + /* +@@ -2909,7 +2962,8 @@ static inline int32_t nss_core_send_buff + desc->bit_flags &= ~(H2N_BIT_FLAG_DISCARD); + desc->opaque = (nss_ptr_t)nbuf; + +- NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, h2n_desc_index_to_dma(if_map, qid, hlos_index), ++ sizeof(*desc), DMA_TO_DEVICE); + + NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_NR_FRAGS]); + return i+1; +@@ -2923,9 +2977,11 @@ static inline int32_t nss_core_send_buff + * Used to differentiate from FRAGS + */ + static inline int32_t nss_core_send_buffer_fraglist(struct nss_ctx_instance *nss_ctx, +- struct h2n_desc_if_instance *desc_if, uint32_t if_num, +- struct sk_buff *nbuf, uint16_t hlos_index, uint16_t flags, uint8_t buffer_type, uint16_t mss) ++ struct h2n_desc_if_instance *desc_if, uint32_t if_num, struct sk_buff *nbuf, ++ uint16_t qid, uint16_t hlos_index, uint16_t flags, uint8_t buffer_type, uint16_t mss) + { ++ struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; ++ struct nss_if_mem_map *if_map = mem_ctx->if_map; + struct h2n_descriptor *desc_ring = desc_if->desc; + struct h2n_descriptor *desc; + dma_addr_t buffer; +@@ -2964,7 +3020,8 @@ static inline int32_t nss_core_send_buff + (nss_ptr_t)nbuf, nbuf->data - nbuf->head, nbuf->len - nbuf->data_len, + skb_end_offset(nbuf), (uint32_t)nbuf->priority, mss, bit_flags | H2N_BIT_FLAG_FIRST_SEGMENT); + +- NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, h2n_desc_index_to_dma(if_map, qid, hlos_index), ++ sizeof(*desc), DMA_TO_DEVICE); + + /* + * Walk the frag_list in nbuf +@@ -3017,7 +3074,8 @@ static inline int32_t nss_core_send_buff + (nss_ptr_t)iter, iter->data - iter->head, iter->len - iter->data_len, + skb_end_offset(iter), iter->priority, mss, bit_flags); + +- NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, h2n_desc_index_to_dma(if_map, qid, hlos_index), ++ sizeof(*desc), DMA_TO_DEVICE); + + i++; + } +@@ -3036,7 +3094,8 @@ static inline int32_t nss_core_send_buff + * Update bit flag for last descriptor. + */ + desc->bit_flags |= H2N_BIT_FLAG_LAST_SEGMENT; +- NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, h2n_desc_index_to_dma(if_map, qid, hlos_index), ++ sizeof(*desc), DMA_TO_DEVICE); + + NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_FRAGLIST]); + return i+1; +@@ -3115,8 +3174,10 @@ int32_t nss_core_send_buffer(struct nss_ + * We need to work out if there's sufficent space in our transmit descriptor + * ring to place all the segments of a nbuf. + */ +- NSS_CORE_DMA_CACHE_MAINT((void *)&if_map->h2n_nss_index[qid], sizeof(uint32_t), DMA_FROM_DEVICE); ++ dma_sync_single_for_cpu(nss_ctx->dev, h2n_nss_index_to_dma(mem_ctx->if_map_dma, qid), ++ sizeof(uint32_t), DMA_FROM_DEVICE); + NSS_CORE_DSB(); ++ + nss_index = if_map->h2n_nss_index[qid]; + h2n_desc_ring->nss_index_local = nss_index; + count = ((nss_index - hlos_index - 1) + size) & (mask); +@@ -3181,13 +3242,13 @@ int32_t nss_core_send_buffer(struct nss_ + count = 0; + if (likely((segments == 0) || is_bounce)) { + count = nss_core_send_buffer_simple_skb(nss_ctx, desc_if, if_num, +- nbuf, hlos_index, flags, buffer_type, mss); ++ nbuf, qid, hlos_index, flags, buffer_type, mss); + } else if (skb_has_frag_list(nbuf)) { + count = nss_core_send_buffer_fraglist(nss_ctx, desc_if, if_num, +- nbuf, hlos_index, flags, buffer_type, mss); ++ nbuf, qid, hlos_index, flags, buffer_type, mss); + } else { + count = nss_core_send_buffer_nr_frags(nss_ctx, desc_if, if_num, +- nbuf, hlos_index, flags, buffer_type, mss); ++ nbuf, qid, hlos_index, flags, buffer_type, mss); + } + + if (unlikely(count <= 0)) { +@@ -3211,7 +3272,8 @@ int32_t nss_core_send_buffer(struct nss_ + h2n_desc_ring->hlos_index = hlos_index; + if_map->h2n_hlos_index[qid] = hlos_index; + +- NSS_CORE_DMA_CACHE_MAINT(&if_map->h2n_hlos_index[qid], sizeof(uint32_t), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, h2n_hlos_index_to_dma(mem_ctx->if_map_dma, qid), ++ sizeof(uint32_t), DMA_TO_DEVICE); + NSS_CORE_DSB(); + + #ifdef CONFIG_DEBUG_KMEMLEAK +--- a/nss_core.h ++++ b/nss_core.h +@@ -105,31 +105,30 @@ + #endif + + /* +- * Cache operation ++ * DMA Offset helper + */ +-#define NSS_CORE_DSB() dsb(sy) +-#define NSS_CORE_DMA_CACHE_MAINT(start, size, dir) nss_core_dma_cache_maint(start, size, dir) ++#define n2h_desc_index_offset(_index) sizeof(struct n2h_descriptor) * (_index) ++#define h2n_desc_index_offset(_index) sizeof(struct h2n_descriptor) * (_index) ++ ++#define n2h_desc_index_to_dma(_if_map_addr, _qid, _index) (_if_map_addr)->n2h_desc_if[(_qid)].desc_addr + n2h_desc_index_offset(_index) ++#define h2n_desc_index_to_dma(_if_map_addr, _qid, _index) (_if_map_addr)->h2n_desc_if[(_qid)].desc_addr + h2n_desc_index_offset(_index) ++ ++#define h2n_nss_index_offset offsetof(struct nss_if_mem_map, h2n_nss_index) ++#define n2h_nss_index_offset offsetof(struct nss_if_mem_map, n2h_nss_index) ++#define h2n_hlos_index_offset offsetof(struct nss_if_mem_map, h2n_hlos_index) ++#define n2h_hlos_index_offset offsetof(struct nss_if_mem_map, n2h_hlos_index) ++ ++#define h2n_nss_index_to_dma(_if_map_addr, _index) (_if_map_addr) + h2n_nss_index_offset + (sizeof(uint32_t) * (_index)) ++#define n2h_nss_index_to_dma(_if_map_addr, _index) (_if_map_addr) + n2h_nss_index_offset + (sizeof(uint32_t) * (_index)) ++#define h2n_hlos_index_to_dma(_if_map_addr, _index) (_if_map_addr) + h2n_hlos_index_offset + (sizeof(uint32_t) * (_index)) ++#define n2h_hlos_index_to_dma(_if_map_addr, _index) (_if_map_addr) + n2h_hlos_index_offset + (sizeof(uint32_t) * (_index)) + + /* +- * nss_core_dma_cache_maint() +- * Perform the appropriate cache op based on direction ++ * Cache operation + */ +-static inline void nss_core_dma_cache_maint(void *start, uint32_t size, int direction) +-{ +- switch (direction) { +- case DMA_FROM_DEVICE:/* invalidate only */ +- dmac_inv_range(start, start + size); +- break; +- case DMA_TO_DEVICE:/* writeback only */ +- dmac_clean_range(start, start + size); +- break; +- case DMA_BIDIRECTIONAL:/* writeback and invalidate */ +- dmac_flush_range(start, start + size); +- break; +- default: +- BUG(); +- } +-} ++#define NSS_CORE_DSB() dsb(sy) ++#define NSS_CORE_DMA_CACHE_MAINT(dev, start, size, dir) BUILD_BUG_ON_MSG(1, \ ++ "NSS_CORE_DMA_CACHE_MAINT is deprecated. Fix the code to use correct dma_sync_* API") + + #define NSS_DEVICE_IF_START NSS_PHYSICAL_IF_START + +--- a/nss_hal/ipq806x/nss_hal_pvt.c ++++ b/nss_hal/ipq806x/nss_hal_pvt.c +@@ -477,10 +477,9 @@ static struct nss_platform_data *__nss_h + /* + * Clear TCM memory used by this core + */ +- for (i = 0; i < resource_size(&res_vphys) ; i += 4) { ++ for (i = 0; i < resource_size(&res_vphys) ; i += 4) + nss_write_32(npd->vmap, i, 0); +- NSS_CORE_DMA_CACHE_MAINT((npd->vmap + i), 4, DMA_TO_DEVICE); +- } ++ + NSS_CORE_DSB(); + + /* +--- a/nss_hal/ipq807x/nss_hal_pvt.c ++++ b/nss_hal/ipq807x/nss_hal_pvt.c +@@ -259,10 +259,9 @@ static struct nss_platform_data *__nss_h + /* + * Clear TCM memory used by this core + */ +- for (i = 0; i < resource_size(&res_vphys) ; i += 4) { ++ for (i = 0; i < resource_size(&res_vphys) ; i += 4) + nss_write_32(npd->vmap, i, 0); +- NSS_CORE_DMA_CACHE_MAINT((npd->vmap + i), 4, DMA_TO_DEVICE); +- } ++ + NSS_CORE_DSB(); + + /* +--- a/nss_meminfo.c ++++ b/nss_meminfo.c +@@ -415,7 +415,6 @@ static bool nss_meminfo_init_block_lists + /* + * Flush the updated meminfo request. + */ +- NSS_CORE_DMA_CACHE_MAINT(r, sizeof(struct nss_meminfo_request), DMA_TO_DEVICE); + NSS_CORE_DSB(); + + /* +@@ -546,7 +545,7 @@ static bool nss_meminfo_configure_n2h_h2 + * Bring a fresh copy of if_map from memory in order to read it correctly. + */ + if_map = mem_ctx->if_map; +- NSS_CORE_DMA_CACHE_MAINT((void *)if_map, sizeof(struct nss_if_mem_map), DMA_FROM_DEVICE); ++ dma_sync_single_for_cpu(nss_ctx->dev, mem_ctx->if_map_dma, sizeof(struct nss_if_mem_map), DMA_FROM_DEVICE); + NSS_CORE_DSB(); + + if_map->n2h_rings = NSS_N2H_RING_COUNT; +@@ -584,7 +583,7 @@ static bool nss_meminfo_configure_n2h_h2 + /* + * Flush the updated nss_if_mem_map. + */ +- NSS_CORE_DMA_CACHE_MAINT((void *)if_map, sizeof(struct nss_if_mem_map), DMA_TO_DEVICE); ++ dma_sync_single_for_device(nss_ctx->dev, mem_ctx->if_map_dma, sizeof(struct nss_if_mem_map), DMA_TO_DEVICE); + NSS_CORE_DSB(); + + return true; +--- a/nss_profiler.c ++++ b/nss_profiler.c +@@ -209,11 +209,12 @@ EXPORT_SYMBOL(nss_profile_dma_deregister + struct nss_profile_sdma_ctrl *nss_profile_dma_get_ctrl(struct nss_ctx_instance *nss_ctx) + { + struct nss_profile_sdma_ctrl *ctrl = nss_ctx->meminfo_ctx.sdma_ctrl; ++ int size = offsetof(struct nss_profile_sdma_ctrl, cidx); + if (!ctrl) { + return ctrl; + } + +- dmac_inv_range(ctrl, &ctrl->cidx); ++ dma_sync_single_for_cpu(nss_ctx->dev, (dma_addr_t) ctrl, size, DMA_FROM_DEVICE); + dsb(sy); + return ctrl; + } diff --git a/lede/package/qca/qca-nss-drv/patches/0005-nss-drv-rework-getting-the-reserved-memory-size.patch b/lede/package/qca/qca-nss-drv/patches/0005-nss-drv-rework-getting-the-reserved-memory-size.patch new file mode 100644 index 0000000000..7bb8549e5e --- /dev/null +++ b/lede/package/qca/qca-nss-drv/patches/0005-nss-drv-rework-getting-the-reserved-memory-size.patch @@ -0,0 +1,114 @@ +From 1c2b564d7b29644765925a784d468f40555ded8a Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Fri, 10 Feb 2023 12:50:51 +0100 +Subject: [PATCH] nss-drv: rework getting the reserved-memory size + +Currently, the way NSS DRV gets the reserved memory node strictly depends +on the nss@40000000 node being present so it can find it after globaly +looking for the reserved-memory node and then going through its children. + +After that its evaluation the address and size cells manually in order to +properly calculate the size of reserved-memory. + +We can make this way more reliable and generic, so lets pass the memory +region wia the NSS common DTS node, match it via its compatible and then +get the memory region phandle and simply convert it to a resource. + +Signed-off-by: Robert Marko +--- + nss_core.c | 70 +++++++++++++++++++++++------------------------------- + 1 file changed, 30 insertions(+), 40 deletions(-) + +--- a/nss_core.c ++++ b/nss_core.c +@@ -26,6 +26,8 @@ + #include + #include + #include ++#include ++#include + #include + #include + #ifdef CONFIG_BRIDGE_NETFILTER +@@ -492,50 +494,38 @@ static void nss_core_handle_crypto_pkt(s + */ + static uint32_t nss_soc_mem_info(void) + { +- struct device_node *node; +- struct device_node *snode; +- int addr_cells; +- int size_cells; +- int n_items; +- uint32_t nss_msize = 8 << 20; /* default: 8MB */ +- const __be32 *ppp; +- +- node = of_find_node_by_name(NULL, "reserved-memory"); +- if (!node) { +- nss_info_always("reserved-memory not found\n"); +- return nss_msize; +- } +- +- ppp = (__be32 *)of_get_property(node, "#address-cells", NULL); +- addr_cells = ppp ? be32_to_cpup(ppp) : 2; +- nss_info("%px addr cells %d\n", ppp, addr_cells); +- ppp = (__be32 *)of_get_property(node, "#size-cells", NULL); +- size_cells = ppp ? be32_to_cpup(ppp) : 2; +- nss_info("%px size cells %d\n", ppp, size_cells); +- +- for_each_child_of_node(node, snode) { +- /* +- * compare (snode->full_name, "/reserved-memory/nss@40000000") may be safer +- */ +- nss_info("%px snode %s fn %s\n", snode, snode->name, snode->full_name); +- if (strcmp(snode->name, "nss") == 0) +- break; +- } +- of_node_put(node); +- if (!snode) { +- nss_info_always("nss@node not found: needed to determine NSS reserved DDR\n"); +- return nss_msize; +- } +- +- ppp = (__be32 *)of_get_property(snode, "reg", &n_items); +- if (ppp) { +- n_items /= sizeof(ppp[0]); +- nss_msize = be32_to_cpup(ppp + addr_cells + size_cells - 1); +- nss_info("addr/size storage words %d %d # words %d in DTS, ddr size %x\n", +- addr_cells, size_cells, n_items, nss_msize); ++ struct device_node *common_node, *memory_node; ++ struct resource r; ++ int ret; ++ ++ common_node = of_find_compatible_node(NULL, NULL, "qcom,nss-common"); ++ if (!common_node) { ++ nss_info_always("NSS common node not found!\n"); ++ goto err_use_default_memsize; ++ } ++ ++ memory_node = of_parse_phandle(common_node, "memory-region", 0); ++ if (!memory_node) { ++ nss_info_always("NSS reserved-memory node not found!\n"); ++ goto err_use_default_memsize; ++ } ++ ++ ret = of_address_to_resource(memory_node, 0, &r); ++ of_node_put(common_node); ++ of_node_put(memory_node); ++ if (ret) { ++ nss_info_always("NSS reserved-memory resource not found!\n"); ++ goto err_use_default_memsize; + } +- of_node_put(snode); +- return nss_msize; ++ ++ nss_info_always("NSS DDR size is 0x%x\n", (uint32_t) resource_size(&r)); ++ ++ return resource_size(&r); ++ ++err_use_default_memsize: ++ nss_info_always("Using default NSS reserved-memory size of 0x%x !\n", SZ_8M); ++ ++ return SZ_8M; + } + + /* diff --git a/lede/package/qca/qca-nss-drv/patches/0006-nss-drv-Fix-nss_clmap_stats-enum-int-compilation-error-GCC-13.patch b/lede/package/qca/qca-nss-drv/patches/0006-nss-drv-Fix-nss_clmap_stats-enum-int-compilation-error-GCC-13.patch new file mode 100644 index 0000000000..7cdb0127f8 --- /dev/null +++ b/lede/package/qca/qca-nss-drv/patches/0006-nss-drv-Fix-nss_clmap_stats-enum-int-compilation-error-GCC-13.patch @@ -0,0 +1,11 @@ +--- a/nss_clmap_stats.c ++++ b/nss_clmap_stats.c +@@ -63,7 +63,7 @@ void nss_clmap_stats_session_unregister( + * nss_clmap_stats_session_register + * Register debug statistic for clmap session. + */ +-bool nss_clmap_stats_session_register(uint32_t if_num, uint32_t if_type, struct net_device *netdev) ++bool nss_clmap_stats_session_register(uint32_t if_num, enum nss_clmap_interface_type if_type, struct net_device *netdev) + { + uint32_t i; + bool stats_status = false; diff --git a/lede/package/qca/qca-nss-drv/patches/0007-nss-drv-Fix-nss_wifili_if-compilation-error-GCC-13.patch b/lede/package/qca/qca-nss-drv/patches/0007-nss-drv-Fix-nss_wifili_if-compilation-error-GCC-13.patch new file mode 100644 index 0000000000..0abeab1ad2 --- /dev/null +++ b/lede/package/qca/qca-nss-drv/patches/0007-nss-drv-Fix-nss_wifili_if-compilation-error-GCC-13.patch @@ -0,0 +1,11 @@ +--- a/exports/nss_wifili_if.h ++++ b/exports/nss_wifili_if.h +@@ -2207,7 +2207,7 @@ void nss_wifili_release_external_if(nss_ + */ + uint8_t nss_wifili_thread_scheme_alloc(struct nss_ctx_instance *nss_ctx, + int32_t radio_ifnum, +- uint32_t radio_priority); ++ enum nss_wifili_thread_scheme_priority radio_priority); + + /** + * nss_wifili_thread_scheme_dealloc diff --git a/lede/package/qca/qca-nss-drv/patches/0008-Add-kernel-6.1-support.patch b/lede/package/qca/qca-nss-drv/patches/0008-Add-kernel-6.1-support.patch new file mode 100644 index 0000000000..acec8a7bfc --- /dev/null +++ b/lede/package/qca/qca-nss-drv/patches/0008-Add-kernel-6.1-support.patch @@ -0,0 +1,267 @@ +From aa48e29c88c467ba0b2cf9d1f32a7f3484d88e0e Mon Sep 17 00:00:00 2001 +From: JiaY-shi +Date: Fri, 9 Jun 2023 20:51:03 +0800 +Subject: [PATCH] nss-drv: adapt to netif_napi_add() changes + +netif_napi_add() removed the weight argument and just uses the default +NAPI_POLL_WEIGHT in background, so for those requiring custom weight use +netif_napi_add_weight() instead. +--- + nss_hal/fsm9010/nss_hal_pvt.c | 6 +++- + nss_hal/ipq50xx/nss_hal_pvt.c | 6 +++- + nss_hal/ipq60xx/nss_hal_pvt.c | 60 +++++++++++++++++++++++++++++------ + nss_hal/ipq806x/nss_hal_pvt.c | 6 +++- + nss_hal/ipq807x/nss_hal_pvt.c | 60 +++++++++++++++++++++++++++++------ + nss_hal/ipq95xx/nss_hal_pvt.c | 6 +++- + 6 files changed, 120 insertions(+), 24 deletions(-) + +--- a/nss_hal/fsm9010/nss_hal_pvt.c ++++ b/nss_hal/fsm9010/nss_hal_pvt.c +@@ -291,7 +291,11 @@ static int __nss_hal_request_irq(struct + } + + int_ctx->irq = npd->irq[irq_num]; +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi, 64); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) ++ netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi, 64); ++#else ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi, 64); ++#endif + return 0; + } + +--- a/nss_hal/ipq50xx/nss_hal_pvt.c ++++ b/nss_hal/ipq50xx/nss_hal_pvt.c +@@ -599,7 +599,11 @@ static int __nss_hal_request_irq(struct + return err; + } + +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, napi_poll_cb, napi_wgt); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) ++ netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, napi_poll_cb, napi_wgt); ++#else ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, napi_poll_cb, napi_wgt); ++#endif + int_ctx->cause = cause; + err = request_irq(irq, nss_hal_handle_irq, 0, irq_name, int_ctx); + if (err) { +--- a/nss_hal/ipq60xx/nss_hal_pvt.c ++++ b/nss_hal/ipq60xx/nss_hal_pvt.c +@@ -615,62 +615,102 @@ static int __nss_hal_request_irq(struct + irq_set_status_flags(irq, IRQ_DISABLE_UNLAZY); + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_SOS) { +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) ++ netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT); ++#else ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT); ++#endif + int_ctx->cause = NSS_N2H_INTR_EMPTY_BUFFERS_SOS; + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_empty_buf_sos", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_QUEUE) { +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_EMPTY_BUFFER_RETURN_PROCESSING_WEIGHT); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) ++ netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_EMPTY_BUFFER_RETURN_PROCESSING_WEIGHT); ++#else ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_EMPTY_BUFFER_RETURN_PROCESSING_WEIGHT); ++#endif + int_ctx->cause = NSS_N2H_INTR_EMPTY_BUFFER_QUEUE; + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_empty_buf_queue", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_TX_UNBLOCKED) { +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_TX_UNBLOCKED_PROCESSING_WEIGHT); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) ++ netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_TX_UNBLOCKED_PROCESSING_WEIGHT); ++#else ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_TX_UNBLOCKED_PROCESSING_WEIGHT); ++#endif + int_ctx->cause = NSS_N2H_INTR_TX_UNBLOCKED; + err = request_irq(irq, nss_hal_handle_irq, 0, "nss-tx-unblock", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_0) { +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) ++ netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#else ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#endif + int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_0; + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue0", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_1) { + int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_1; +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) ++ netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#else ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#endif + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue1", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_2) { + int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_2; +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) ++ netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#else ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#endif + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue2", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_3) { + int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_3; +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) ++ netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#else ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#endif + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue3", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_COREDUMP_COMPLETE) { + int_ctx->cause = NSS_N2H_INTR_COREDUMP_COMPLETE; +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_emergency, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) ++ netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_emergency, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#else ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_emergency, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#endif + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_coredump_complete", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_PAGED_EMPTY_BUFFER_SOS) { +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) ++ netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT); ++#else ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT); ++#endif + int_ctx->cause = NSS_N2H_INTR_PAGED_EMPTY_BUFFERS_SOS; + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_paged_empty_buf_sos", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_PROFILE_DMA) { + int_ctx->cause = NSS_N2H_INTR_PROFILE_DMA; +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_sdma, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) ++ netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_sdma, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#else ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_sdma, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++#endif + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_profile_dma", int_ctx); + } + +--- a/nss_hal/ipq806x/nss_hal_pvt.c ++++ b/nss_hal/ipq806x/nss_hal_pvt.c +@@ -1185,7 +1185,11 @@ static int __nss_hal_request_irq(struct + } + + int_ctx->irq = npd->irq[irq_num]; +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi, 64); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) ++ netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi, 64); ++#else ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi, 64); ++#endif + + return 0; + } +--- a/nss_hal/ipq807x/nss_hal_pvt.c ++++ b/nss_hal/ipq807x/nss_hal_pvt.c +@@ -659,62 +659,62 @@ static int __nss_hal_request_irq(struct + irq_set_status_flags(irq, IRQ_DISABLE_UNLAZY); + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_SOS) { +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT); ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT); + int_ctx->cause = NSS_N2H_INTR_EMPTY_BUFFERS_SOS; + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_empty_buf_sos", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_QUEUE) { +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_EMPTY_BUFFER_RETURN_PROCESSING_WEIGHT); ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_EMPTY_BUFFER_RETURN_PROCESSING_WEIGHT); + int_ctx->cause = NSS_N2H_INTR_EMPTY_BUFFER_QUEUE; + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_empty_buf_queue", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_TX_UNBLOCKED) { +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_TX_UNBLOCKED_PROCESSING_WEIGHT); ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_TX_UNBLOCKED_PROCESSING_WEIGHT); + int_ctx->cause = NSS_N2H_INTR_TX_UNBLOCKED; + err = request_irq(irq, nss_hal_handle_irq, 0, "nss-tx-unblock", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_0) { +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); + int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_0; + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue0", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_1) { + int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_1; +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue1", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_2) { + int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_2; +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue2", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_3) { + int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_3; +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue3", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_COREDUMP_COMPLETE) { + int_ctx->cause = NSS_N2H_INTR_COREDUMP_COMPLETE; +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_emergency, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_emergency, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_coredump_complete", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_PAGED_EMPTY_BUFFER_SOS) { +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT); ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT); + int_ctx->cause = NSS_N2H_INTR_PAGED_EMPTY_BUFFERS_SOS; + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_paged_empty_buf_sos", int_ctx); + } + + if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_PROFILE_DMA) { + int_ctx->cause = NSS_N2H_INTR_PROFILE_DMA; +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_sdma, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_sdma, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); + err = request_irq(irq, nss_hal_handle_irq, 0, "nss_profile_dma", int_ctx); + } + +--- a/nss_hal/ipq95xx/nss_hal_pvt.c ++++ b/nss_hal/ipq95xx/nss_hal_pvt.c +@@ -889,7 +889,11 @@ static int __nss_hal_request_irq(struct + return err; + } + +- netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, napi_poll_cb, napi_wgt); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) ++ netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, napi_poll_cb, napi_wgt); ++#else ++ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, napi_poll_cb, napi_wgt); ++#endif + int_ctx->cause = cause; + err = request_irq(irq, nss_hal_handle_irq, 0, irq_name, int_ctx); + if (err) { diff --git a/lede/package/qca/qca-nss-ecm/Makefile b/lede/package/qca/qca-nss-ecm/Makefile new file mode 100644 index 0000000000..d74940a096 --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/Makefile @@ -0,0 +1,161 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=qca-nss-ecm +PKG_RELEASE=1 + +PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/qca-nss-ecm.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_DATE:=2023-10-20 +PKG_SOURCE_VERSION:=82b27915fffdbe2cdb2d4eb70e5736ccf92e2560 +PKG_MIRROR_HASH:=643895cb187cacfcde337c19dc5a34512acc225c0db1813a15cc1b66523835c4 + +PKG_BUILD_PARALLEL:=1 +PKG_FLAGS:=nonshared + +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/qca-nss-ecm + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Support + DEPENDS:=@(TARGET_qualcommax||TARGET_ipq60xx) \ + +@NSS_DRV_IPV6_ENABLE \ + +@NSS_DRV_PPE_ENABLE \ + +@NSS_DRV_TUN6RD_ENABLE \ + +@NSS_DRV_PPPOE_ENABLE \ + +@NSS_DRV_PPTP_ENABLE \ + +@NSS_DRV_VIRT_IF_ENABLE \ + +@NSS_DRV_WIFI_ENABLE \ + +kmod-qca-nss-drv \ + +kmod-nf-conntrack \ + +kmod-ppp +kmod-pppoe +kmod-pptp +kmod-bonding \ + +PACKAGE_kmod-pppol2tp:kmod-pppol2tp \ + +PACKAGE_kmod-qca-mcs:kmod-qca-mcs \ + +PACKAGE_kmod-nat46:kmod-nat46 \ + +PACKAGE_kmod-vxlan:kmod-vxlan + TITLE:=QCA NSS Enhanced Connection Manager (ECM) + FILES:=$(PKG_BUILD_DIR)/ecm.ko + KCONFIG:=CONFIG_BRIDGE_NETFILTER=y \ + CONFIG_NF_CONNTRACK_EVENTS=y \ + CONFIG_NF_CONNTRACK_DSCPREMARK_EXT=y +endef + +define KernelPackage/qca-nss-ecm/Description +This package contains the QCA NSS Enhanced Connection Manager +endef + +define KernelPackage/qca-nss-ecm/install + $(INSTALL_DIR) $(1)/etc/firewall.d $(1)/etc/init.d $(1)/usr/bin $(1)/lib/netifd/offload $(1)/etc/config $(1)/etc/uci-defaults $(1)/etc/sysctl.d $(1)/etc/hotplug.d/net + $(INSTALL_DATA) ./files/qca-nss-ecm.firewall $(1)/etc/firewall.d/qca-nss-ecm + $(INSTALL_BIN) ./files/qca-nss-ecm.init $(1)/etc/init.d/qca-nss-ecm + $(INSTALL_BIN) ./files/ecm_dump.sh $(1)/usr/bin/ + $(INSTALL_BIN) ./files/disable_offloads.sh $(1)/usr/bin/ + $(INSTALL_BIN) ./files/on-demand-down $(1)/lib/netifd/offload/on-demand-down + $(INSTALL_DATA) ./files/qca-nss-ecm.uci $(1)/etc/config/ecm + $(INSTALL_DATA) ./files/qca-nss-ecm.defaults $(1)/etc/uci-defaults/99-qca-nss-ecm + $(INSTALL_BIN) ./files/qca-nss-ecm.sysctl $(1)/etc/sysctl.d/qca-nss-ecm.conf + $(INSTALL_BIN) ./files/disable_offloads.hotplug $(1)/etc/hotplug.d/net/99-disable_offloads +endef + +EXTRA_CFLAGS+= \ + -I$(STAGING_DIR)/usr/include/qca-nss-drv \ + -I$(STAGING_DIR)/usr/include/qca-mcs \ + -I$(STAGING_DIR)/usr/include/nat46 + +ifneq (, $(findstring $(CONFIG_TARGET_BOARD), "qualcommax" "ipq60xx")) +ECM_MAKE_OPTS+=ECM_FRONT_END_NSS_ENABLE=y \ + ECM_FRONT_END_SFE_ENABLE=n \ + ECM_NON_PORTED_SUPPORT_ENABLE=y \ + ECM_INTERFACE_BOND_ENABLE=y \ + ECM_INTERFACE_VLAN_ENABLE=y \ + ECM_CLASSIFIER_MARK_ENABLE=y \ + ECM_CLASSIFIER_DSCP_ENABLE=y \ + ECM_CLASSIFIER_PCC_ENABLE=n \ + ECM_BAND_STEERING_ENABLE=n +endif + +# Disable ECM IPv6 support when global IPv6 support is disabled. +ifneq ($(CONFIG_IPV6),) +ECM_MAKE_OPTS+=ECM_IPV6_ENABLE=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-ovpn-link),) +ECM_MAKE_OPTS+=ECM_INTERFACE_OVPN_ENABLE=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-vxlanmgr),) +ECM_MAKE_OPTS+=ECM_INTERFACE_VXLAN_ENABLE=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-ovsmgr),) +ECM_MAKE_OPTS+=ECM_INTERFACE_OVS_BRIDGE_ENABLE=y \ + ECM_CLASSIFIER_OVS_ENABLE=y +EXTRA_CFLAGS+= -I$(STAGING_DIR)/usr/include/qca-ovsmgr +endif + +ifneq ($(CONFIG_PACKAGE_kmod-macvlan),) +ECM_MAKE_OPTS+=ECM_INTERFACE_MACVLAN_ENABLE=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-mcs),) +ECM_MAKE_OPTS+=ECM_MULTICAST_ENABLE=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-nat46),) +ECM_MAKE_OPTS+=ECM_INTERFACE_MAP_T_ENABLE=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-ipsec),) +ECM_MAKE_OPTS+=ECM_INTERFACE_IPSEC_ENABLE=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-pppoe),) +ECM_MAKE_OPTS+=ECM_INTERFACE_PPPOE_ENABLE=y \ + ECM_INTERFACE_PPTP_ENABLE=y \ + ECM_INTERFACE_PPP_ENABLE=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-pppol2tp),) +ECM_MAKE_OPTS+=ECM_INTERFACE_L2TPV2_ENABLE=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-gre)$(CONFIG_PACKAGE_kmod-gre6),) +ECM_MAKE_OPTS+=ECM_INTERFACE_GRE_TAP_ENABLE=y \ + ECM_INTERFACE_GRE_TUN_ENABLE=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-sit),) +ECM_MAKE_OPTS+=ECM_INTERFACE_SIT_ENABLE=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-ip6-tunnel),) +ECM_MAKE_OPTS+=ECM_INTERFACE_TUNIPIP6_ENABLE=y +endif + +ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-mscs),) +ECM_MAKE_OPTS+=ECM_CLASSIFIER_MSCS_ENABLE=y +endif + +define Build/InstallDev + mkdir -p $(1)/usr/include/qca-nss-ecm + $(CP) $(PKG_BUILD_DIR)/exports/* $(1)/usr/include/qca-nss-ecm +endef + +ifeq ($(CONFIG_TARGET_BOARD), "qualcommax") + SOC:=$(CONFIG_TARGET_SUBTARGET) +endif + +define Build/Compile + +$(MAKE) -C "$(LINUX_DIR)" $(strip $(ECM_MAKE_OPTS)) \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + ARCH="$(LINUX_KARCH)" \ + M="$(PKG_BUILD_DIR)" \ + EXTRA_CFLAGS="$(EXTRA_CFLAGS) -Wno-error=unused-function " \ + SoC=$(SOC) \ + $(KERNEL_MAKE_FLAGS) \ + $(PKG_JOBS) \ + modules +endef + +$(eval $(call KernelPackage,qca-nss-ecm)) diff --git a/lede/package/qca/qca-nss-ecm/files/disable_offloads.hotplug b/lede/package/qca/qca-nss-ecm/files/disable_offloads.hotplug new file mode 100755 index 0000000000..01c5647401 --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/files/disable_offloads.hotplug @@ -0,0 +1,187 @@ +#!/bin/sh + +[ "$ACTION" != "add" ] && exit + +function log() +{ + local status="$1" + local feature="$2" + local interface="$3" + + if [ $status -eq 0 ]; then + logger "[ethtool] $feature: disabled on $interface" + fi + + if [ $status -eq 1 ]; then + logger -s "[ethtool] $feature: failed to disable on $interface" + fi + + if [ $status -gt 1 ]; then + logger "[ethtool] $feature: no changes performed on $interface" + fi +} + +function interface_is_virtual() +{ + local interface="$1" + [ -d /sys/devices/virtual/net/"$interface"/ ] || return 1 + return 0 +} + +function get_base_interface() +{ + local interface="$1" + echo "$interface" | grep -Eo '^[a-z]*[0-9]*' 2>/dev/null || return 1 + return 0 +} + +function disable_offloads() +{ + local interface="$1" + local features + local cmd + + # Check if we can change features + if ethtool -k $interface 1>/dev/null 2>/dev/null; then + # Filter whitespaces + # Get only enabled/not fixed features + # Filter features that are only changeable by global keyword + # Filter empty lines + # Cut to First column + features=$(ethtool -k "$interface" | awk '{$1=$1;print}' \ + | grep -E '^.+: on$' \ + | grep -v -E '^tx-checksum-.+$' \ + | grep -v -E '^tx-scatter-gather.+$' \ + | grep -v -E '^tx-tcp.+segmentation.+$' \ + | grep -v -E '^tx-udp-fragmentation$' \ + | grep -v -E '^tx-generic-segmentation$' \ + | grep -v -E '^rx-gro$' \ + | grep -v -E '^rx-gro$' \ + | grep -v -E '^$' \ + | cut -d: -f1) + + # Replace feature name by global keyword + features=$(echo "$features" | sed -e s/rx-checksumming/rx/ \ + -e s/tx-checksumming/tx/ \ + -e s/scatter-gather/sg/ \ + -e s/tcp-segmentation-offload/tso/ \ + -e s/udp-fragmentation-offload/ufo/ \ + -e s/generic-segmentation-offload/gso/ \ + -e s/generic-receive-offload/gro/ \ + -e s/large-receive-offload/lro/ \ + -e s/rx-vlan-offload/rxvlan/ \ + -e s/tx-vlan-offload/txvlan/ \ + -e s/ntuple-filters/ntuple/ \ + -e s/receive-hashing/rxhash/) + + # Check if we can disable anything + if [ -z "$features" ]; then + logger "[ethtool] offloads: no changes performed on $interface" + return 0 + fi + + # Construct ethtool command line + cmd="-K $interface" + + for feature in $features; do + cmd="$cmd $feature off" + done + + # Try to disable offloads + ethtool $cmd 1>/dev/null 2>/dev/null + log $? "Offloads" "$interface" + + else + log $? "Offloads" "$interface" + fi +} + +function disable_flow_control() +{ + local interface="$1" + local features + local cmd + + # Check if we can change settings + if ethtool -a $interface 1>/dev/null 2>/dev/null; then + # Construct ethtool command line + cmd="-A $interface autoneg off tx off rx off" + + # Try to disable flow control + ethtool $cmd 1>/dev/null 2>/dev/null + log $? "Flow Control" "$interface" + + else + log $? "Flow Control" "$interface" + fi +} + +function disable_interrupt_moderation() +{ + local interface="$1" + local features + local cmd + + # Check if we can change settings + if ethtool -c $interface 1>/dev/null 2>/dev/null; then + # Construct ethtool command line + cmd="-C $interface adaptive-tx off adaptive-rx off" + + # Try to disable adaptive interrupt moderation + ethtool $cmd 1>/dev/null 2>/dev/null + log $? "Adaptive Interrupt Moderation" "$interface" + + features=$(ethtool -c $interface | awk '{$1=$1;print}' \ + | grep -v -E '^.+: 0$|Adaptive|Coalesce' \ + | grep -v -E '^$' \ + | cut -d: -f1) + + # Check if we can disable anything + if [ -z "$features" ]; then + logger "[ethtool] Interrupt Moderation: no changes performed on $interface" + return 0 + fi + + # Construct ethtool command line + cmd="-C $interface" + + for feature in $features; do + cmd="$cmd $feature 0" + done + + # Try to disable interrupt Moderation + ethtool $cmd 1>/dev/null 2>/dev/null + log $? "Interrupt Moderation" "$interface" + + else + log $? "Interrupt Moderation" "$interface" + fi +} + +function disable_interface_offloads() { + #local interface=$(get_base_interface "$1") + #{ [ -z "$interface" ] || interface_is_virtual "$interface"; } && exit 0 + + local interface="$1" + + local disable_offloads="$(uci get ecm.@general[0].disable_offloads)" + if [ "$disable_offloads" -eq 1 ]; then + disable_offloads "$interface" + fi + + local disable_flow_control="$(uci get ecm.@general[0].disable_flow_control)" + if [ "$disable_flow_control" -eq 1 ]; then + disable_flow_control "$interface" + fi + + local disable_interrupt_moderation="$(uci get ecm.@general[0].disable_interrupt_moderation)" + if [ "$disable_interrupt_moderation" -eq 1 ]; then + disable_interrupt_moderation "$interface" + fi +} + +if [ "$ACTION" = add ]; then + disable_interface_offloads "$INTERFACE" +fi + +exit 0 diff --git a/lede/package/qca/qca-nss-ecm/files/disable_offloads.sh b/lede/package/qca/qca-nss-ecm/files/disable_offloads.sh new file mode 100755 index 0000000000..9f8394fe7a --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/files/disable_offloads.sh @@ -0,0 +1,189 @@ +#!/bin/sh +# +# Helper script which uses ethtool to disable (most) +# interface offloads, if possible. +# +# Reference: +# https://forum.openwrt.org/t/how-to-make-ethtool-setting-persistent-on-br-lan/6433/14 +# + +function log() +{ + local status="$1" + local feature="$2" + local interface="$3" + + if [ $status -eq 0 ]; then + logger "[ethtool] $feature: disabled on $interface" + fi + + if [ $status -eq 1 ]; then + logger -s "[ethtool] $feature: failed to disable on $interface" + fi + + if [ $status -gt 1 ]; then + logger "[ethtool] $feature: no changes performed on $interface" + fi +} + +function interface_is_virtual() +{ + local interface="$1" + [ -d /sys/devices/virtual/net/"$interface"/ ] || return 1 + return 0 +} + +function get_base_interface() +{ + local interface="$1" + echo "$interface" | grep -Eo '^[a-z]*[0-9]*' 2>/dev/null || return 1 + return 0 +} + +function disable_offloads() +{ + local interface="$1" + local features + local cmd + + # Check if we can change features + if ethtool -k $interface 1>/dev/null 2>/dev/null; then + + # Filter whitespaces + # Get only enabled/not fixed features + # Filter features that are only changeable by global keyword + # Filter empty lines + # Cut to First column + features=$(ethtool -k "$interface" | awk '{$1=$1;print}' \ + | grep -E '^.+: on$' \ + | grep -v -E '^tx-checksum-.+$' \ + | grep -v -E '^tx-scatter-gather.+$' \ + | grep -v -E '^tx-tcp.+segmentation.+$' \ + | grep -v -E '^tx-udp-fragmentation$' \ + | grep -v -E '^tx-generic-segmentation$' \ + | grep -v -E '^rx-gro$' \ + | grep -v -E '^rx-gro$' \ + | grep -v -E '^$' \ + | cut -d: -f1) + + # Replace feature name by global keyword + features=$(echo "$features" | sed -e s/rx-checksumming/rx/ \ + -e s/tx-checksumming/tx/ \ + -e s/scatter-gather/sg/ \ + -e s/tcp-segmentation-offload/tso/ \ + -e s/udp-fragmentation-offload/ufo/ \ + -e s/generic-segmentation-offload/gso/ \ + -e s/generic-receive-offload/gro/ \ + -e s/large-receive-offload/lro/ \ + -e s/rx-vlan-offload/rxvlan/ \ + -e s/tx-vlan-offload/txvlan/ \ + -e s/ntuple-filters/ntuple/ \ + -e s/receive-hashing/rxhash/) + + # Check if we can disable anything + if [ -z "$features" ]; then + logger "[ethtool] offloads: no changes performed on $interface" + return 0 + fi + + # Construct ethtool command line + cmd="-K $interface" + + for feature in $features; do + cmd="$cmd $feature off" + done + + # Try to disable offloads + ethtool $cmd 1>/dev/null 2>/dev/null + log $? "Offloads" "$interface" + + else + log $? "Offloads" "$interface" + fi +} + +function disable_flow_control() +{ + local interface="$1" + local features + local cmd + + # Check if we can change settings + if ethtool -a $interface 1>/dev/null 2>/dev/null; then + + # Construct ethtool command line + cmd="-A $interface autoneg off tx off rx off" + + # Try to disable flow control + ethtool $cmd 1>/dev/null 2>/dev/null + log $? "Flow Control" "$interface" + + else + log $? "Flow Control" "$interface" + fi +} + +function disable_interrupt_moderation() +{ + local interface="$1" + local features + local cmd + + # Check if we can change settings + if ethtool -c $interface 1>/dev/null 2>/dev/null; then + # Construct ethtool command line + cmd="-C $interface adaptive-tx off adaptive-rx off" + + # Try to disable adaptive interrupt moderation + ethtool $cmd 1>/dev/null 2>/dev/null + log $? "Adaptive Interrupt Moderation" "$interface" + + features=$(ethtool -c $interface | awk '{$1=$1;print}' \ + | grep -v -E '^.+: 0$|Adaptive|Coalesce' \ + | grep -v -E '^$' \ + | cut -d: -f1) + + # Check if we can disable anything + if [ -z "$features" ]; then + logger "[ethtool] Interrupt Moderation: no changes performed on $interface" + return 0 + fi + + # Construct ethtool command line + cmd="-C $interface" + + for feature in $features; do + cmd="$cmd $feature 0" + done + + # Try to disable interrupt Moderation + ethtool $cmd 1>/dev/null 2>/dev/null + log $? "Interrupt Moderation" "$interface" + + else + log $? "Interrupt Moderation" "$interface" + fi +} + +function main() +{ + for interface in /sys/class/net/*; do + interface=$(basename $interface) + + #interface=$(get_base_interface "$interface") + #{ [ -z "$interface" ] || interface_is_virtual "$interface"; } && exit 0 + + # Skip Loopback + if [ $interface == lo ]; then + continue + fi + + disable_offloads "$interface" + disable_flow_control "$interface" + disable_interrupt_moderation "$interface" + done +} + +main + +exit 0 diff --git a/lede/package/qca/qca-nss-ecm/files/ecm_dump.sh b/lede/package/qca/qca-nss-ecm/files/ecm_dump.sh new file mode 100755 index 0000000000..dbf7de753f --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/files/ecm_dump.sh @@ -0,0 +1,95 @@ +#!/bin/sh +# +# Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +ECM_MODULE=${1:-ecm_state} +MOUNT_ROOT=/dev/ecm + +# +# usage: ecm_dump.sh [module=ecm_db] +# +# with no parameters, ecm_dump.sh will attempt to mount the +# ecm_db state file and cat its contents. +# +# example with a parameter: ecm_dump.sh ecm_classifier_default +# +# this will cause ecm_dump to attempt to find and mount the state +# file for the ecm_classifier_default module, and if successful +# cat the contents. +# + +# this is one of the state files, which happens to be the +# last module started in ecm +ECM_STATE=/sys/kernel/debug/ecm/ecm_state/state_dev_major + +# tests to see if ECM is up and ready to receive commands. +# returns 0 if ECM is fully up and ready, else 1 +ecm_is_ready() { + if [ ! -e "${ECM_STATE}" ] + then + return 1 + fi + return 0 +} + +# +# module_state_mount(module_name) +# Mounts the state file of the module, if supported +# +module_state_mount() { + local module_name=$1 + local mount_dir=$2 + local state_file="/sys/kernel/debug/ecm/${module_name}/state_dev_major" + + if [ -e "${mount_dir}/${module_name}" ] + then + # already mounted + return 0 + fi + + #echo "Mount state file for $module_name ..." + if [ ! -e "$state_file" ] + then + #echo "... $module_name does not support state" + return 1 + fi + + local major="`cat $state_file`" + #echo "... Mounting state $state_file with major: $major" + mknod "${mount_dir}/${module_name}" c $major 0 +} + +# +# main +# +ecm_is_ready || { + #echo "ECM is not running" + exit 1 +} + +# all state files are mounted under MOUNT_ROOT, so make sure it exists +mkdir -p ${MOUNT_ROOT} + +# +# attempt to mount state files for the requested module and cat it +# if the mount succeeded +# +module_state_mount ${ECM_MODULE} ${MOUNT_ROOT} && { + cat ${MOUNT_ROOT}/${ECM_MODULE} + exit 0 +} + +exit 2 diff --git a/lede/package/qca/qca-nss-ecm/files/on-demand-down b/lede/package/qca/qca-nss-ecm/files/on-demand-down new file mode 100644 index 0000000000..02d708e03b --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/files/on-demand-down @@ -0,0 +1,6 @@ +#!/bin/sh +# Copyright (c) 2016 The Linux Foundation. All rights reserved. + +[ -e "/sys/kernel/debug/ecm/ecm_db/defunct_all" ] && { + echo 1 > /sys/kernel/debug/ecm/ecm_db/defunct_all +} diff --git a/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.defaults b/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.defaults new file mode 100644 index 0000000000..308e265c98 --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.defaults @@ -0,0 +1,28 @@ +#!/bin/sh +# +# Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +uci -q batch << EOF + delete firewall.qcanssecm + set firewall.qcanssecm=include + set firewall.qcanssecm.type=script + set firewall.qcanssecm.path=/etc/firewall.d/qca-nss-ecm + set firewall.qcanssecm.family=any + set firewall.qcanssecm.reload=1 + commit firewall +EOF + +exit 0 diff --git a/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.firewall b/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.firewall new file mode 100644 index 0000000000..2ec5b7e514 --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.firewall @@ -0,0 +1,11 @@ +#!/bin/sh +if [ ! -r /sbin/fw4 ]; then +iptables-save|grep physdev-is-bridged|while read a; do + iptables -D FORWARD -m physdev --physdev-is-bridged -j ACCEPT +done +iptables -I FORWARD 1 -m physdev --physdev-is-bridged -j ACCEPT +ip6tables-save|grep physdev-is-bridged|while read a; do + ip6tables -D FORWARD -m physdev --physdev-is-bridged -j ACCEPT +done +ip6tables -I FORWARD 1 -m physdev --physdev-is-bridged -j ACCEPT +fi diff --git a/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.init b/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.init new file mode 100644 index 0000000000..83314e6963 --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.init @@ -0,0 +1,137 @@ +#!/bin/sh /etc/rc.common +# +# Copyright (c) 2014, 2019-2020 The Linux Foundation. All rights reserved. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +# The shebang above has an extra space intentially to avoid having +# openwrt build scripts automatically enable this package starting +# at boot. + +START=19 + +get_front_end_mode() { + config_load "ecm" + config_get front_end global acceleration_engine "auto" + + case $front_end in + auto) + echo '0' + ;; + nss) + echo '1' + ;; + *) + echo 'uci_option_acceleration_engine is invalid' + esac +} + +support_bridge() { + # NSS support bridge acceleration + [ -d /sys/kernel/debug/ecm/ecm_nss_ipv4 ] && [ -d /sys/kernel/debug/ecm/ecm_nss_ipv6 ] && return 0 +} + +enable_bridge_filtering() { + sysctl -w net.bridge.bridge-nf-call-arptables=1 + sysctl -w net.bridge.bridge-nf-call-iptables=1 + sysctl -w net.bridge.bridge-nf-call-ip6tables=1 + + if ([ -z "$(grep "net.bridge.bridge-nf-call-arptables=1" /etc/sysctl.d/qca-nss-ecm.conf)" ] && \ + [ -z "$(grep "net.bridge.bridge-nf-call-iptables=1" /etc/sysctl.d/qca-nss-ecm.conf)" ] && \ + [ -z "$(grep "net.bridge.bridge-nf-call-ip6tables=1" /etc/sysctl.d/qca-nss-ecm.conf)" ] \ + ); then + echo 'net.bridge.bridge-nf-call-arptables=1' >> /etc/sysctl.d/qca-nss-ecm.conf + echo 'net.bridge.bridge-nf-call-iptables=1' >> /etc/sysctl.d/qca-nss-ecm.conf + echo 'net.bridge.bridge-nf-call-ip6tables=1' >> /etc/sysctl.d/qca-nss-ecm.conf + fi +} + +disable_bridge_filtering() { + sysctl -w net.bridge.bridge-nf-call-arptables=0 + sysctl -w net.bridge.bridge-nf-call-iptables=0 + sysctl -w net.bridge.bridge-nf-call-ip6tables=0 + + sed '/net.bridge.bridge-nf-call-arptables=1/d' -i /etc/sysctl.d/qca-nss-ecm.conf + sed '/net.bridge.bridge-nf-call-iptables=1/d' -i /etc/sysctl.d/qca-nss-ecm.conf + sed '/net.bridge.bridge-nf-call-ip6tables=1/d' -i /etc/sysctl.d/qca-nss-ecm.conf +} + +load_ecm() { + [ -d /sys/module/ecm ] || { + insmod ecm front_end_selection=$(get_front_end_mode) + echo 1 > /sys/kernel/debug/ecm/ecm_classifier_default/accel_delay_pkts + } + + support_bridge && enable_bridge_filtering +} + +unload_ecm() { + disable_bridge_filtering + + if [ -d /sys/module/ecm ]; then + # + # Stop ECM frontends + # + echo 1 > /sys/kernel/debug/ecm/front_end_ipv4_stop + echo 1 > /sys/kernel/debug/ecm/front_end_ipv6_stop + + # + # Defunct the connections + # + echo 1 > /sys/kernel/debug/ecm/ecm_db/defunct_all + sleep 5 + + rmmod ecm + sleep 1 + fi +} + +start() { + load_ecm + + # If the acceleration engine is NSS, enable wifi redirect + [ -d /sys/kernel/debug/ecm/ecm_nss_ipv4 ] && sysctl -w dev.nss.general.redirect=1 + + # If bridge filtering is enabled, apply and persist the sysctl flags + local bridge_filtering_enabled="$(uci_get ecm @general[0] enable_bridge_filtering)" + if [ "$bridge_filtering_enabled" -eq 1 ]; then + echo "Bridge filtering is enabled in the ECM config, this will cause issues with NAT loopback!" + enable_bridge_filtering + fi + + if [ -d /sys/module/qca_ovsmgr ]; then + insmod ecm_ovs + fi +} + +stop() { + # If ECM is already not loaded, just return + if [ ! -d /sys/module/ecm ]; then + return + fi + + # If the acceleration engine is NSS, disable wifi redirect + [ -d /sys/kernel/debug/ecm/ecm_nss_ipv4 ] && sysctl -w dev.nss.general.redirect=0 + + # If bridge filtering is enabled, reset the sysctl flags + local bridge_filtering_enabled="$(uci_get ecm @general[0] enable_bridge_filtering)" + if [ "$bridge_filtering_enabled" -eq 1 ]; then + disable_bridge_filtering + fi + + if [ -d /sys/module/ecm_ovs ]; then + rmmod ecm_ovs + fi + + unload_ecm +} diff --git a/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.sysctl b/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.sysctl new file mode 100644 index 0000000000..27a819003d --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.sysctl @@ -0,0 +1 @@ +net.netfilter.nf_conntrack_max=32768 diff --git a/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.uci b/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.uci new file mode 100644 index 0000000000..20c02bbf2e --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/files/qca-nss-ecm.uci @@ -0,0 +1,8 @@ +config ecm 'global' + option acceleration_engine 'auto' + +config general + option enable_bridge_filtering '1' + option disable_offloads '0' + option disable_flow_control '0' + option disable_interrupt_moderation '0' diff --git a/lede/package/qca/qca-nss-ecm/patches/0001-treewide-componentize-the-module-even-more.patch b/lede/package/qca/qca-nss-ecm/patches/0001-treewide-componentize-the-module-even-more.patch new file mode 100644 index 0000000000..584f0a3fc4 --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/patches/0001-treewide-componentize-the-module-even-more.patch @@ -0,0 +1,361 @@ +From 09980e54011e2d95a9db2d6134f635bc90e5a7f2 Mon Sep 17 00:00:00 2001 +From: Ansuel Smith +Date: Wed, 19 May 2021 02:38:53 +0200 +Subject: [PATCH 01/12] treewide: componentize the module even more + +Signed-off-by: Ansuel Smith +--- + Makefile | 57 +++++++++++++++++++++++++------- + Makefile_61.mk | 1 - + ecm_db/ecm_db_connection.c | 8 +++++ + ecm_db/ecm_db_node.c | 4 +++ + ecm_interface.c | 8 +++++ + frontends/ecm_front_end_common.c | 7 ++++ + 6 files changed, 72 insertions(+), 13 deletions(-) + +--- a/Makefile ++++ b/Makefile +@@ -17,7 +17,7 @@ + # ################################################### + # Makefile for the QCA NSS ECM + # ################################################### +-ifneq ($(findstring 6.1., $(KERNELVERSION)),) ++ifneq ($(findstring 6.2., $(KERNELVERSION)),) + include $(obj)/Makefile_61.mk + else + ifeq ($(ECM_FRONT_END_SFE_ENABLE), y) +@@ -134,9 +134,17 @@ ccflags-$(ECM_INTERFACE_BOND_ENABLE) += -DECM_INTERFACE_BOND_ENABLE + # Define ECM_INTERFACE_PPPOE_ENABLE=y in order + # to enable support for PPPoE acceleration. + # ############################################################################# +-ECM_INTERFACE_PPPOE_ENABLE=y ++ifndef $(ECM_INTERFACE_PPPOE_ENABLE) ++ ECM_INTERFACE_PPPOE_ENABLE=y ++endif + ccflags-$(ECM_INTERFACE_PPPOE_ENABLE) += -DECM_INTERFACE_PPPOE_ENABLE + ++# ############################################################################# ++# Define ECM_INTERFACE_L2TPV2_PPTP_ENABLE=y in order ++# to enable support for l2tpv2 or PPTP detection. ++# ############################################################################# ++ccflags-$(ECM_INTERFACE_L2TPV2_PPTP_ENABLE) += -DECM_INTERFACE_L2TPV2_PPTP_ENABLE ++ + # ############################################################################# + # Define ECM_INTERFACE_L2TPV2_ENABLE=y in order + # to enable support for l2tpv2 acceleration. +@@ -163,6 +171,12 @@ endif + endif + ccflags-$(ECM_INTERFACE_PPP_ENABLE) += -DECM_INTERFACE_PPP_ENABLE + ++# ############################################################################# ++# Define ECM_INTERFACE_GRE_ENABLE=y in order ++# to enable support for GRE detection. ++# ############################################################################# ++ccflags-$(ECM_INTERFACE_GRE_ENABLE) += -DECM_INTERFACE_GRE_ENABLE ++ + # ############################################################################# + # Define ECM_INTERFACE_GRE_TAP_ENABLE=y in order + # to enable support for GRE TAP interface. +@@ -246,7 +260,9 @@ ccflags-$(ECM_INTERFACE_OVS_BRIDGE_ENABLE) += -DECM_INTERFACE_OVS_BRIDGE_ENABLE + # ############################################################################# + # Define ECM_INTERFACE_VLAN_ENABLE=y in order to enable support for VLAN + # ############################################################################# +-ECM_INTERFACE_VLAN_ENABLE=y ++ifndef $(ECM_INTERFACE_VLAN_ENABLE) ++ ECM_INTERFACE_VLAN_ENABLE=y ++endif + ccflags-$(ECM_INTERFACE_VLAN_ENABLE) += -DECM_INTERFACE_VLAN_ENABLE + + # ############################################################################# +@@ -288,7 +304,9 @@ ccflags-$(ECM_CLASSIFIER_OVS_ENABLE) += -DECM_CLASSIFIER_OVS_ENABLE + # ############################################################################# + # Define ECM_CLASSIFIER_MARK_ENABLE=y in order to enable mark classifier. + # ############################################################################# +-ECM_CLASSIFIER_MARK_ENABLE=y ++ifndef $(ECM_CLASSIFIER_MARK_ENABLE) ++ ECM_CLASSIFIER_MARK_ENABLE=y ++endif + ecm-$(ECM_CLASSIFIER_MARK_ENABLE) += ecm_classifier_mark.o + ccflags-$(ECM_CLASSIFIER_MARK_ENABLE) += -DECM_CLASSIFIER_MARK_ENABLE + +@@ -312,7 +330,9 @@ ccflags-$(ECM_CLASSIFIER_NL_ENABLE) += -DECM_CLASSIFIER_NL_ENABLE + # ############################################################################# + # Define ECM_CLASSIFIER_DSCP_ENABLE=y in order to enable DSCP classifier. + # ############################################################################# +-ECM_CLASSIFIER_DSCP_ENABLE=y ++ifndef $(ECM_CLASSIFIER_DSCP_ENABLE) ++ ECM_CLASSIFIER_DSCP_ENABLE=y ++endif + ecm-$(ECM_CLASSIFIER_DSCP_ENABLE) += ecm_classifier_dscp.o + ccflags-$(ECM_CLASSIFIER_DSCP_ENABLE) += -DECM_CLASSIFIER_DSCP_ENABLE + ccflags-$(ECM_CLASSIFIER_DSCP_IGS) += -DECM_CLASSIFIER_DSCP_IGS +@@ -331,7 +351,9 @@ ccflags-$(ECM_CLASSIFIER_HYFI_ENABLE) += -DECM_CLASSIFIER_HYFI_ENABLE + # the Parental Controls subsystem classifier in ECM. Currently disabled until + # customers require it / if they need to integrate their Parental Controls with it. + # ############################################################################# +-ECM_CLASSIFIER_PCC_ENABLE=y ++ifndef $(ECM_CLASSIFIER_PCC_ENABLE) ++ ECM_CLASSIFIER_PCC_ENABLE=y ++endif + ecm-$(ECM_CLASSIFIER_PCC_ENABLE) += ecm_classifier_pcc.o + ccflags-$(ECM_CLASSIFIER_PCC_ENABLE) += -DECM_CLASSIFIER_PCC_ENABLE + +@@ -372,27 +394,36 @@ ccflags-$(ECM_NON_PORTED_SUPPORT_ENABLE) += -DECM_NON_PORTED_SUPPORT_ENABLE + # ############################################################################# + # Define ECM_STATE_OUTPUT_ENABLE=y to support XML state output + # ############################################################################# +-ECM_STATE_OUTPUT_ENABLE=y ++ifndef $(ECM_STATE_OUTPUT_ENABLE) ++ ECM_STATE_OUTPUT_ENABLE=y ++endif + ecm-$(ECM_STATE_OUTPUT_ENABLE) += ecm_state.o + ccflags-$(ECM_STATE_OUTPUT_ENABLE) += -DECM_STATE_OUTPUT_ENABLE + + # ############################################################################# + # Define ECM_DB_ADVANCED_STATS_ENABLE to support XML state output + # ############################################################################# +-ECM_DB_ADVANCED_STATS_ENABLE=y ++ifndef $(ECM_DB_ADVANCED_STATS_ENABLE) ++ ECM_DB_ADVANCED_STATS_ENABLE=y ++endif + ccflags-$(ECM_DB_ADVANCED_STATS_ENABLE) += -DECM_DB_ADVANCED_STATS_ENABLE + + # ############################################################################# + # Define ECM_DB_CONNECTION_CROSS_REFERENCING_ENABLE=y in order to enable + # the database to track relationships between objects. + # ############################################################################# +-ECM_DB_CONNECTION_CROSS_REFERENCING_ENABLE=y ++ifndef $(ECM_DB_CONNECTION_CROSS_REFERENCING_ENABLE) ++ ECM_DB_CONNECTION_CROSS_REFERENCING_ENABLE=y ++endif + ccflags-$(ECM_DB_CONNECTION_CROSS_REFERENCING_ENABLE) += -DECM_DB_XREF_ENABLE + + # ############################################################################# + # Define ECM_TRACKER_DPI_SUPPORT_ENABLE=y in order to enable support for + # deep packet inspection and tracking of data with the trackers. + # ############################################################################# ++ifndef $(ECM_TRACKER_DPI_SUPPORT_ENABLE) ++ ECM_TRACKER_DPI_SUPPORT_ENABLE=y ++endif + ccflags-$(ECM_TRACKER_DPI_SUPPORT_ENABLE) += -DECM_TRACKER_DPI_SUPPORT_ENABLE + + # ############################################################################# +@@ -400,14 +431,18 @@ ccflags-$(ECM_TRACKER_DPI_SUPPORT_ENABLE) += -DECM_TRACKER_DPI_SUPPORT_ENABLE + # support for the database keeping lists of connections that are assigned + # on a per TYPE of classifier basis. + # ############################################################################# +-ECM_DB_CLASSIFIER_TYPE_ASSIGNMENTS_TRACK_ENABLE=y ++ifndef $(ECM_DB_CLASSIFIER_TYPE_ASSIGNMENTS_TRACK_ENABLE) ++ ECM_DB_CLASSIFIER_TYPE_ASSIGNMENTS_TRACK_ENABLE=y ++endif + ccflags-$(ECM_DB_CLASSIFIER_TYPE_ASSIGNMENTS_TRACK_ENABLE) += -DECM_DB_CTA_TRACK_ENABLE + + # ############################################################################# + # Define ECM_BAND_STEERING_ENABLE=y in order to enable + # band steering feature. + # ############################################################################# +-ECM_BAND_STEERING_ENABLE=y ++ifndef $(ECM_BAND_STEERING_ENABLE) ++ ECM_BAND_STEERING_ENABLE=y ++endif + ccflags-$(ECM_BAND_STEERING_ENABLE) += -DECM_BAND_STEERING_ENABLE + + # ############################################################################# +@@ -488,7 +523,6 @@ ccflags-y += -DECM_TRACKER_UDP_DEBUG_LEVEL=1 + ccflags-y += -DECM_BOND_NOTIFIER_DEBUG_LEVEL=1 + ccflags-y += -DECM_INTERFACE_DEBUG_LEVEL=1 + ccflags-y += -DECM_STATE_DEBUG_LEVEL=1 +-ccflags-y += -DECM_OPENWRT_SUPPORT=1 + ccflags-y += -DECM_NOTIFIER_DEBUG_LEVEL=1 + ccflags-y += -DECM_AE_CLASSIFIER_DEBUG_LEVEL=1 + ccflags-y += -DECM_STATS_DEBUG_LEVEL=1 +--- a/Makefile_61.mk ++++ b/Makefile_61.mk +@@ -465,7 +465,6 @@ ccflags-y += -DECM_TRACKER_UDP_DEBUG_LEVEL=1 + ccflags-y += -DECM_BOND_NOTIFIER_DEBUG_LEVEL=1 + ccflags-y += -DECM_INTERFACE_DEBUG_LEVEL=1 + ccflags-y += -DECM_STATE_DEBUG_LEVEL=1 +-ccflags-y += -DECM_OPENWRT_SUPPORT=1 + ccflags-y += -DECM_NOTIFIER_DEBUG_LEVEL=1 + ccflags-y += -DECM_AE_CLASSIFIER_DEBUG_LEVEL=1 + ccflags-y += -DECM_STATS_DEBUG_LEVEL=1 +--- a/ecm_db/ecm_db_connection.c ++++ b/ecm_db/ecm_db_connection.c +@@ -446,7 +446,9 @@ EXPORT_SYMBOL(ecm_db_connection_make_def + */ + void ecm_db_connection_data_totals_update(struct ecm_db_connection_instance *ci, bool is_from, uint64_t size, uint64_t packets) + { ++#ifdef ECM_DB_ADVANCED_STATS_ENABLE + int32_t i; ++#endif + + DEBUG_CHECK_MAGIC(ci, ECM_DB_CONNECTION_INSTANCE_MAGIC, "%px: magic failed\n", ci); + +@@ -545,7 +547,9 @@ EXPORT_SYMBOL(ecm_db_connection_data_tot + */ + void ecm_db_connection_data_totals_update_dropped(struct ecm_db_connection_instance *ci, bool is_from, uint64_t size, uint64_t packets) + { ++#ifdef ECM_DB_ADVANCED_STATS_ENABLE + int32_t i; ++#endif + + DEBUG_CHECK_MAGIC(ci, ECM_DB_CONNECTION_INSTANCE_MAGIC, "%px: magic failed\n", ci); + +@@ -1539,6 +1543,7 @@ void ecm_db_connection_defunct_all(void) + } + EXPORT_SYMBOL(ecm_db_connection_defunct_all); + ++#ifdef ECM_INTERFACE_OVS_BRIDGE_ENABLE + /* + * ecm_db_connection_defunct_by_classifier() + * Make defunct based on masked fields +@@ -1705,6 +1710,7 @@ next_ci: + ECM_IP_ADDR_TO_OCTAL(dest_addr_mask), dest_port_mask, proto_mask, cnt); + } + } ++#endif + + /* + * ecm_db_connection_defunct_by_port() +@@ -1994,6 +2000,7 @@ struct ecm_db_node_instance *ecm_db_conn + } + EXPORT_SYMBOL(ecm_db_connection_node_get_and_ref); + ++#ifdef ECM_DB_XREF_ENABLE + /* + * ecm_db_connection_mapping_get_and_ref_next() + * Return reference to next connection in the mapping chain in the specified direction. +@@ -2035,6 +2042,7 @@ struct ecm_db_connection_instance *ecm_d + return nci; + } + EXPORT_SYMBOL(ecm_db_connection_iface_get_and_ref_next); ++#endif + + /* + * ecm_db_connection_mapping_get_and_ref() +--- a/ecm_db/ecm_db_node.c ++++ b/ecm_db/ecm_db_node.c +@@ -227,9 +227,11 @@ EXPORT_SYMBOL(ecm_db_node_get_and_ref_ne + */ + int ecm_db_node_deref(struct ecm_db_node_instance *ni) + { ++#ifdef ECM_DB_XREF_ENABLE + #if (DEBUG_LEVEL >= 1) + int dir; + #endif ++#endif + DEBUG_CHECK_MAGIC(ni, ECM_DB_NODE_INSTANCE_MAGIC, "%px: magic failed\n", ni); + + spin_lock_bh(&ecm_db_lock); +@@ -489,9 +491,11 @@ EXPORT_SYMBOL(ecm_db_node_iface_get_and_ + void ecm_db_node_add(struct ecm_db_node_instance *ni, struct ecm_db_iface_instance *ii, uint8_t *address, + ecm_db_node_final_callback_t final, void *arg) + { ++#ifdef ECM_DB_XREF_ENABLE + #if (DEBUG_LEVEL >= 1) + int dir; + #endif ++#endif + ecm_db_node_hash_t hash_index; + struct ecm_db_listener_instance *li; + +--- a/ecm_interface.c ++++ b/ecm_interface.c +@@ -1509,6 +1509,7 @@ struct neighbour *ecm_interface_ipv6_nei + */ + bool ecm_interface_is_pptp(struct sk_buff *skb, const struct net_device *out) + { ++#ifdef ECM_INTERFACE_PPTP_ENABLE + struct net_device *in; + + /* +@@ -1533,6 +1534,7 @@ bool ecm_interface_is_pptp(struct sk_buf + } + + dev_put(in); ++#endif + return false; + } + +@@ -1545,6 +1547,7 @@ bool ecm_interface_is_pptp(struct sk_buf + */ + bool ecm_interface_is_l2tp_packet_by_version(struct sk_buff *skb, const struct net_device *out, int ver) + { ++#ifdef ECM_INTERFACE_L2TPV2_PPTP_ENABLE + uint32_t flag = 0; + struct net_device *in; + +@@ -1577,6 +1580,7 @@ bool ecm_interface_is_l2tp_packet_by_ver + } + + dev_put(in); ++#endif + return false; + } + +@@ -1589,6 +1593,7 @@ bool ecm_interface_is_l2tp_packet_by_ver + */ + bool ecm_interface_is_l2tp_pptp(struct sk_buff *skb, const struct net_device *out) + { ++#ifdef ECM_INTERFACE_L2TPV2_PPTP_ENABLE + struct net_device *in; + + /* +@@ -1611,6 +1616,7 @@ bool ecm_interface_is_l2tp_pptp(struct s + } + + dev_put(in); ++#endif + return false; + } + +@@ -7127,6 +7133,7 @@ static void ecm_interface_regenerate_con + return; + } + ++#ifdef ECM_DB_XREF_ENABLE + for (dir = 0; dir < ECM_DB_OBJ_DIR_MAX; dir++) { + /* + * Re-generate all connections associated with this interface +@@ -7142,6 +7149,7 @@ static void ecm_interface_regenerate_con + ci[dir] = cin; + } + } ++#endif + + #ifdef ECM_MULTICAST_ENABLE + /* +--- a/frontends/ecm_front_end_common.c ++++ b/frontends/ecm_front_end_common.c +@@ -517,6 +517,7 @@ bool ecm_front_end_gre_proto_is_accel_al + struct nf_conntrack_tuple *reply_tuple, + int ip_version, uint16_t offset) + { ++#ifdef ECM_INTERFACE_GRE_ENABLE + struct net_device *dev; + struct gre_base_hdr *greh; + +@@ -528,10 +529,12 @@ bool ecm_front_end_gre_proto_is_accel_al + /* + * Case 1: PPTP locally terminated + */ ++#ifdef ECM_INTERFACE_PPTP_ENABLE + if (ecm_interface_is_pptp(skb, outdev)) { + DEBUG_TRACE("%px: PPTP GRE locally terminated - allow acceleration\n", skb); + return true; + } ++#endif + + /* + * Case 2: PPTP pass through +@@ -657,6 +660,10 @@ bool ecm_front_end_gre_proto_is_accel_al + */ + DEBUG_TRACE("%px: GRE IPv%d pass through non NAT - allow acceleration\n", skb, ip_version); + return true; ++#else ++ DEBUG_TRACE("%px: GRE%d feature is disabled - do not allow acceleration\n", skb, ip_version); ++ return false; ++#endif + } + + #ifdef ECM_CLASSIFIER_DSCP_ENABLE diff --git a/lede/package/qca/qca-nss-ecm/patches/0002-treewide-rework-ipv6_dev_find_and_hold.patch b/lede/package/qca/qca-nss-ecm/patches/0002-treewide-rework-ipv6_dev_find_and_hold.patch new file mode 100644 index 0000000000..57765758c6 --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/patches/0002-treewide-rework-ipv6_dev_find_and_hold.patch @@ -0,0 +1,63 @@ +--- a/ecm_interface.c ++++ b/ecm_interface.c +@@ -339,9 +339,9 @@ static struct net_device *ecm_interface_ + + ECM_IP_ADDR_TO_NIN6_ADDR(addr6, addr); + #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 9, 0)) +- dev = (struct net_device *)ipv6_dev_find(&init_net, &addr6, 1); ++ dev = (struct net_device *)ipv6_dev_find_and_hold(&init_net, &addr6, 1); + #else +- dev = (struct net_device *)ipv6_dev_find(&init_net, &addr6, NULL); ++ dev = (struct net_device *)ipv6_dev_find_and_hold(&init_net, &addr6, 1); + #endif + return dev; + } +@@ -802,9 +802,9 @@ static bool ecm_interface_mac_addr_get_i + */ + ECM_IP_ADDR_TO_NIN6_ADDR(daddr, addr); + #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 9, 0)) +- local_dev = ipv6_dev_find(&init_net, &daddr, 1); ++ local_dev = ipv6_dev_find_and_hold(&init_net, &daddr, 1); + #else +- local_dev = ipv6_dev_find(&init_net, &daddr, NULL); ++ local_dev = ipv6_dev_find_and_hold(&init_net, &daddr, 1); + #endif + if (local_dev) { + DEBUG_TRACE("%pi6 is a local address\n", &daddr); +--- a/frontends/ecm_front_end_common.c ++++ b/frontends/ecm_front_end_common.c +@@ -103,6 +103,10 @@ + #endif + #endif + ++#ifdef ECM_IPV6_ENABLE ++#include "ecm_front_end_ipv6.h" ++#endif ++ + #ifdef ECM_FRONT_END_FSE_ENABLE + /* + * Callback object for ECM frontend interaction with wlan driver to add/delete FSE rules. +@@ -614,9 +618,9 @@ bool ecm_front_end_gre_proto_is_accel_al + } else { + #ifdef ECM_IPV6_ENABLE + #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 9, 0)) +- dev = ipv6_dev_find(&init_net, &(orig_tuple->src.u3.in6), 1); ++ dev = ipv6_dev_find_and_hold(&init_net, &(orig_tuple->src.u3.in6), 1); + #else +- dev = ipv6_dev_find(&init_net, &(orig_tuple->src.u3.in6), NULL); ++ dev = ipv6_dev_find_and_hold(&init_net, &(orig_tuple->src.u3.in6), 1); + #endif + if (dev) { + /* +@@ -628,9 +632,9 @@ bool ecm_front_end_gre_proto_is_accel_al + } + + #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 9, 0)) +- dev = ipv6_dev_find(&init_net, &(orig_tuple->dst.u3.in6), 1); ++ dev = ipv6_dev_find_and_hold(&init_net, &(orig_tuple->dst.u3.in6), 1); + #else +- dev = ipv6_dev_find(&init_net, &(orig_tuple->dst.u3.in6), NULL); ++ dev = ipv6_dev_find_and_hold(&init_net, &(orig_tuple->dst.u3.in6), 1); + #endif + if (dev) { + /* diff --git a/lede/package/qca/qca-nss-ecm/patches/0003-qca-nss-ecm-resolve-the-cpu-high-load-regarding-ecm.patch b/lede/package/qca/qca-nss-ecm/patches/0003-qca-nss-ecm-resolve-the-cpu-high-load-regarding-ecm.patch new file mode 100644 index 0000000000..00476932b5 --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/patches/0003-qca-nss-ecm-resolve-the-cpu-high-load-regarding-ecm.patch @@ -0,0 +1,55 @@ +From 65aa71f33891bcf0b75995219e31abaf674c6199 Mon Sep 17 00:00:00 2001 +From: Dirk Buchwalder +Date: Sun, 27 Jun 2021 16:52:39 +0200 +Subject: [PATCH 05/12] qca-nss-ecm: resolve the cpu high load regarding ecm + +If using ECM, cpu load goes up (around 1.0) and stucks there. +This is due to using uninterruptible sleep function, +the patch changes this to interruptible sleep function. + +Signed-off-by: Dirk Buchwalder buchwalder@posteo.de +--- + frontends/nss/ecm_nss_ipv4.c | 4 ++-- + frontends/nss/ecm_nss_ipv6.c | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +--- a/frontends/nss/ecm_nss_ipv4.c ++++ b/frontends/nss/ecm_nss_ipv4.c +@@ -700,7 +700,7 @@ static void ecm_nss_ipv4_stats_sync_req_ + } + spin_unlock_bh(&ecm_nss_ipv4_lock); + +- usleep_range(ECM_NSS_IPV4_STATS_SYNC_UDELAY - 100, ECM_NSS_IPV4_STATS_SYNC_UDELAY); ++ msleep_interruptible(ECM_NSS_IPV4_STATS_SYNC_UDELAY / 1000); + + /* + * If index is 0, we are starting a new round, but if we still have time remain +@@ -714,7 +714,7 @@ static void ecm_nss_ipv4_stats_sync_req_ + } + + if (time_after(ecm_nss_ipv4_next_req_time, current_jiffies)) { +- msleep(jiffies_to_msecs(ecm_nss_ipv4_next_req_time - current_jiffies)); ++ msleep_interruptible(jiffies_to_msecs(ecm_nss_ipv4_next_req_time - current_jiffies)); + } + ecm_nss_ipv4_roll_check_jiffies = jiffies; + ecm_nss_ipv4_next_req_time = ecm_nss_ipv4_roll_check_jiffies + ECM_NSS_IPV4_STATS_SYNC_PERIOD; +--- a/frontends/nss/ecm_nss_ipv6.c ++++ b/frontends/nss/ecm_nss_ipv6.c +@@ -676,7 +676,7 @@ static void ecm_nss_ipv6_stats_sync_req_ + } + spin_unlock_bh(&ecm_nss_ipv6_lock); + +- usleep_range(ECM_NSS_IPV6_STATS_SYNC_UDELAY - 100, ECM_NSS_IPV6_STATS_SYNC_UDELAY); ++ msleep_interruptible(ECM_NSS_IPV6_STATS_SYNC_UDELAY / 1000); + + /* + * If index is 0, we are starting a new round, but if we still have time remain +@@ -690,7 +690,7 @@ static void ecm_nss_ipv6_stats_sync_req_ + } + + if (time_after(ecm_nss_ipv6_next_req_time, current_jiffies)) { +- msleep(jiffies_to_msecs(ecm_nss_ipv6_next_req_time - current_jiffies)); ++ msleep_interruptible(jiffies_to_msecs(ecm_nss_ipv6_next_req_time - current_jiffies)); + } + ecm_nss_ipv6_roll_check_jiffies = jiffies; + ecm_nss_ipv6_next_req_time = ecm_nss_ipv6_roll_check_jiffies + ECM_NSS_IPV6_STATS_SYNC_PERIOD; diff --git a/lede/package/qca/qca-nss-ecm/patches/0005-frontends-drop-use-of-static-be_liberal-and-no_windo.patch b/lede/package/qca/qca-nss-ecm/patches/0005-frontends-drop-use-of-static-be_liberal-and-no_windo.patch new file mode 100644 index 0000000000..fc3ff0e38a --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/patches/0005-frontends-drop-use-of-static-be_liberal-and-no_windo.patch @@ -0,0 +1,88 @@ +--- a/frontends/nss/ecm_nss_ported_ipv4.c ++++ b/frontends/nss/ecm_nss_ported_ipv4.c +@@ -1213,7 +1213,6 @@ static void ecm_nss_ported_ipv4_connection_accelerate(struct ecm_front_end_conne + #else + struct nf_tcp_net *tn = nf_tcp_pernet(nf_ct_net(ct)); + uint32_t tcp_be_liberal = tn->tcp_be_liberal; +- uint32_t tcp_no_window_check = tn->tcp_no_window_check; + #endif + ecm_db_connection_address_get(feci->ci, ECM_DB_OBJ_DIR_FROM, addr); + ecm_front_end_flow_and_return_directions_get(ct, addr, 4, &flow_dir, &return_dir); +@@ -1228,11 +1227,7 @@ static void ecm_nss_ported_ipv4_connection_accelerate(struct ecm_front_end_conne + nircm->tcp_rule.return_max_window = ct->proto.tcp.seen[return_dir].td_maxwin; + nircm->tcp_rule.return_end = ct->proto.tcp.seen[return_dir].td_end; + nircm->tcp_rule.return_max_end = ct->proto.tcp.seen[return_dir].td_maxend; +-#ifdef ECM_OPENWRT_SUPPORT +- if (tcp_be_liberal || tcp_no_window_check +-#else + if (tcp_be_liberal +-#endif + || (ct->proto.tcp.seen[flow_dir].flags & IP_CT_TCP_FLAG_BE_LIBERAL) + || (ct->proto.tcp.seen[return_dir].flags & IP_CT_TCP_FLAG_BE_LIBERAL)) { + nircm->rule_flags |= NSS_IPV4_RULE_CREATE_FLAG_NO_SEQ_CHECK; +--- a/frontends/nss/ecm_nss_ported_ipv6.c ++++ b/frontends/nss/ecm_nss_ported_ipv6.c +@@ -1133,7 +1133,6 @@ static void ecm_nss_ported_ipv6_connection_accelerate(struct ecm_front_end_conne + #else + struct nf_tcp_net *tn = nf_tcp_pernet(nf_ct_net(ct)); + uint32_t tcp_be_liberal = tn->tcp_be_liberal; +- uint32_t tcp_no_window_check = tn->tcp_no_window_check; + #endif + ecm_front_end_flow_and_return_directions_get(ct, src_ip, 6, &flow_dir, &return_dir); + +@@ -1147,11 +1146,7 @@ static void ecm_nss_ported_ipv6_connection_accelerate(struct ecm_front_end_conne + nircm->tcp_rule.return_max_window = ct->proto.tcp.seen[return_dir].td_maxwin; + nircm->tcp_rule.return_end = ct->proto.tcp.seen[return_dir].td_end; + nircm->tcp_rule.return_max_end = ct->proto.tcp.seen[return_dir].td_maxend; +-#ifdef ECM_OPENWRT_SUPPORT +- if (tcp_be_liberal || tcp_no_window_check +-#else + if (tcp_be_liberal +-#endif + || (ct->proto.tcp.seen[flow_dir].flags & IP_CT_TCP_FLAG_BE_LIBERAL) + || (ct->proto.tcp.seen[return_dir].flags & IP_CT_TCP_FLAG_BE_LIBERAL)) { + nircm->rule_flags |= NSS_IPV6_RULE_CREATE_FLAG_NO_SEQ_CHECK; +--- a/frontends/sfe/ecm_sfe_ported_ipv4.c ++++ b/frontends/sfe/ecm_sfe_ported_ipv4.c +@@ -1358,7 +1358,6 @@ static void ecm_sfe_ported_ipv4_connection_accelerate(struct ecm_front_end_conne + #else + struct nf_tcp_net *tn = nf_tcp_pernet(nf_ct_net(ct)); + uint32_t tcp_be_liberal = tn->tcp_be_liberal; +- uint32_t tcp_no_window_check = tn->tcp_no_window_check; + #endif + ecm_db_connection_address_get(feci->ci, ECM_DB_OBJ_DIR_FROM, addr); + ecm_front_end_flow_and_return_directions_get(ct, addr, 4, &flow_dir, &return_dir); +@@ -1374,11 +1373,7 @@ static void ecm_sfe_ported_ipv4_connection_accelerate(struct ecm_front_end_conne + nircm->tcp_rule.return_end = ct->proto.tcp.seen[return_dir].td_end; + nircm->tcp_rule.return_max_end = ct->proto.tcp.seen[return_dir].td_maxend; + +-#ifdef ECM_OPENWRT_SUPPORT +- if (tcp_be_liberal || tcp_no_window_check +-#else + if (tcp_be_liberal +-#endif + || (ct->proto.tcp.seen[flow_dir].flags & IP_CT_TCP_FLAG_BE_LIBERAL) + || (ct->proto.tcp.seen[return_dir].flags & IP_CT_TCP_FLAG_BE_LIBERAL)) { + nircm->rule_flags |= SFE_RULE_CREATE_FLAG_NO_SEQ_CHECK; +--- a/frontends/sfe/ecm_sfe_ported_ipv6.c ++++ b/frontends/sfe/ecm_sfe_ported_ipv6.c +@@ -1371,7 +1371,6 @@ static void ecm_sfe_ported_ipv6_connection_accelerate(struct ecm_front_end_conne + #else + struct nf_tcp_net *tn = nf_tcp_pernet(nf_ct_net(ct)); + uint32_t tcp_be_liberal = tn->tcp_be_liberal; +- uint32_t tcp_no_window_check = tn->tcp_no_window_check; + #endif + ecm_front_end_flow_and_return_directions_get(ct, src_ip, 6, &flow_dir, &return_dir); + +@@ -1385,11 +1384,7 @@ static void ecm_sfe_ported_ipv6_connection_accelerate(struct ecm_front_end_conne + nircm->tcp_rule.return_max_window = ct->proto.tcp.seen[return_dir].td_maxwin; + nircm->tcp_rule.return_end = ct->proto.tcp.seen[return_dir].td_end; + nircm->tcp_rule.return_max_end = ct->proto.tcp.seen[return_dir].td_maxend; +-#ifdef ECM_OPENWRT_SUPPORT +- if (tcp_be_liberal || tcp_no_window_check +-#else + if (tcp_be_liberal +-#endif + || (ct->proto.tcp.seen[flow_dir].flags & IP_CT_TCP_FLAG_BE_LIBERAL) + || (ct->proto.tcp.seen[return_dir].flags & IP_CT_TCP_FLAG_BE_LIBERAL)) { + nircm->rule_flags |= SFE_RULE_CREATE_FLAG_NO_SEQ_CHECK; diff --git a/lede/package/qca/qca-nss-ecm/patches/0006-ecm_tracker_datagram-drop-static-for-EXPORT_SYMBOL.patch b/lede/package/qca/qca-nss-ecm/patches/0006-ecm_tracker_datagram-drop-static-for-EXPORT_SYMBOL.patch new file mode 100644 index 0000000000..aa95ce15df --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/patches/0006-ecm_tracker_datagram-drop-static-for-EXPORT_SYMBOL.patch @@ -0,0 +1,50 @@ +From 9827d8597545ecfee17eba7b08d48dbcdf55c614 Mon Sep 17 00:00:00 2001 +From: Ansuel Smith +Date: Sun, 8 May 2022 18:39:39 +0200 +Subject: [PATCH 09/12] ecm_tracker_datagram: drop static for EXPORT_SYMBOL + +EXPORT_SYMBOL should NOT be static + +Signed-off-by: Ansuel Smith +--- + ecm_tracker_datagram.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/ecm_tracker_datagram.c ++++ b/ecm_tracker_datagram.c +@@ -203,7 +203,7 @@ static void ecm_tracker_datagram_datagra + * ecm_tracker_datagram_discard_all() + * Discard all tracked data + */ +-static void ecm_tracker_datagram_discard_all(struct ecm_tracker_datagram_internal_instance *dtii) ++void ecm_tracker_datagram_discard_all(struct ecm_tracker_datagram_internal_instance *dtii) + { + int32_t src_count; + int32_t dest_count; +@@ -364,7 +364,7 @@ static void ecm_tracker_datagram_datagra + * ecm_tracker_datagram_datagram_size_get() + * Return size in bytes of datagram at index i that was sent to the target + */ +-static int32_t ecm_tracker_datagram_datagram_size_get(struct ecm_tracker_datagram_instance *uti, ecm_tracker_sender_type_t sender, int32_t i) ++int32_t ecm_tracker_datagram_datagram_size_get(struct ecm_tracker_datagram_instance *uti, ecm_tracker_sender_type_t sender, int32_t i) + { + struct ecm_tracker_datagram_internal_instance *dtii = (struct ecm_tracker_datagram_internal_instance *)uti; + +@@ -412,7 +412,7 @@ static int32_t ecm_tracker_datagram_data + * ecm_tracker_datagram_datagram_read() + * Read size bytes from datagram at index i into the buffer + */ +-static int ecm_tracker_datagram_datagram_read(struct ecm_tracker_datagram_instance *uti, ecm_tracker_sender_type_t sender, int32_t i, int32_t offset, int32_t size, void *buffer) ++int ecm_tracker_datagram_datagram_read(struct ecm_tracker_datagram_instance *uti, ecm_tracker_sender_type_t sender, int32_t i, int32_t offset, int32_t size, void *buffer) + { + struct ecm_tracker_datagram_internal_instance *dtii = (struct ecm_tracker_datagram_internal_instance *)uti; + int res; +@@ -466,7 +466,7 @@ static int ecm_tracker_datagram_datagram + * ecm_tracker_datagram_datagram_add() + * Append the datagram onto the tracker queue for the given target + */ +-static bool ecm_tracker_datagram_datagram_add(struct ecm_tracker_datagram_instance *uti, ecm_tracker_sender_type_t sender, struct sk_buff *skb) ++bool ecm_tracker_datagram_datagram_add(struct ecm_tracker_datagram_instance *uti, ecm_tracker_sender_type_t sender, struct sk_buff *skb) + { + struct ecm_tracker_datagram_internal_instance *dtii = (struct ecm_tracker_datagram_internal_instance *)uti; + struct sk_buff *skbc; diff --git a/lede/package/qca/qca-nss-ecm/patches/0007-frontends-drop-udp_get_timeouts-and-use-standard-ups.patch b/lede/package/qca/qca-nss-ecm/patches/0007-frontends-drop-udp_get_timeouts-and-use-standard-ups.patch new file mode 100644 index 0000000000..1554f21382 --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/patches/0007-frontends-drop-udp_get_timeouts-and-use-standard-ups.patch @@ -0,0 +1,63 @@ +From ef638a84405c9f6556a9d7c257ccbba74efd228e Mon Sep 17 00:00:00 2001 +From: Ansuel Smith +Date: Sat, 14 May 2022 20:15:10 +0200 +Subject: [PATCH 10/12] frontends: drop udp_get_timeouts and use standard + upstream api + +Drop udp_get_timeouts and use nf_udp_pernet and ->timeouts +instead or relying on a downstream api not present upstream. +--- + frontends/nss/ecm_nss_ipv4.c | 3 ++- + frontends/nss/ecm_nss_ipv6.c | 3 ++- + frontends/sfe/ecm_sfe_ipv4.c | 3 ++- + frontends/sfe/ecm_sfe_ipv6.c | 3 ++- + 4 files changed, 8 insertions(+), 4 deletions(-) + +--- a/frontends/nss/ecm_nss_ipv4.c ++++ b/frontends/nss/ecm_nss_ipv4.c +@@ -610,7 +610,8 @@ sync_conntrack: + #else + timeouts = nf_ct_timeout_lookup(ct); + if (!timeouts) { +- timeouts = udp_get_timeouts(nf_ct_net(ct)); ++ struct nf_udp_net *un = nf_udp_pernet(nf_ct_net(ct)); ++ timeouts = un->timeouts; + } + + spin_lock_bh(&ct->lock); +--- a/frontends/nss/ecm_nss_ipv6.c ++++ b/frontends/nss/ecm_nss_ipv6.c +@@ -587,7 +587,8 @@ sync_conntrack: + #else + timeouts = nf_ct_timeout_lookup(ct); + if (!timeouts) { +- timeouts = udp_get_timeouts(nf_ct_net(ct)); ++ struct nf_udp_net *un = nf_udp_pernet(nf_ct_net(ct)); ++ timeouts = un->timeouts; + } + + spin_lock_bh(&ct->lock); +--- a/frontends/sfe/ecm_sfe_ipv4.c ++++ b/frontends/sfe/ecm_sfe_ipv4.c +@@ -562,7 +562,8 @@ sync_conntrack: + #else + timeouts = nf_ct_timeout_lookup(ct); + if (!timeouts) { +- timeouts = udp_get_timeouts(nf_ct_net(ct)); ++ struct nf_udp_net *un = nf_udp_pernet(nf_ct_net(ct)); ++ timeouts = un->timeouts; + } + + spin_lock_bh(&ct->lock); +--- a/frontends/sfe/ecm_sfe_ipv6.c ++++ b/frontends/sfe/ecm_sfe_ipv6.c +@@ -556,7 +556,8 @@ sync_conntrack: + #else + timeouts = nf_ct_timeout_lookup(ct); + if (!timeouts) { +- timeouts = udp_get_timeouts(nf_ct_net(ct)); ++ struct nf_udp_net *un = nf_udp_pernet(nf_ct_net(ct)); ++ timeouts = un->timeouts; + } + + spin_lock_bh(&ct->lock); diff --git a/lede/package/qca/qca-nss-ecm/patches/0008-ecm_interface-fix-ppp-generic-function-calls-for-5.15.patch b/lede/package/qca/qca-nss-ecm/patches/0008-ecm_interface-fix-ppp-generic-function-calls-for-5.15.patch new file mode 100644 index 0000000000..e314dc1ef4 --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/patches/0008-ecm_interface-fix-ppp-generic-function-calls-for-5.15.patch @@ -0,0 +1,20 @@ +--- a/ecm_interface.c ++++ b/ecm_interface.c +@@ -3606,7 +3606,7 @@ identifier_update: + if (skb && (skb->skb_iif == dev->ifindex)) { + struct pppol2tp_common_addr info; + +- if (__ppp_is_multilink(dev) > 0) { ++ if (ppp_is_multilink(dev) > 0) { + DEBUG_TRACE("%px: Net device: %px is MULTILINK PPP - Unknown to the ECM\n", feci, dev); + type_info.unknown.os_specific_ident = dev_interface_num; + +@@ -3616,7 +3616,7 @@ identifier_update: + ii = ecm_interface_unknown_interface_establish(&type_info.unknown, dev_name, dev_interface_num, ae_interface_num, dev_mtu); + return ii; + } +- channel_count = __ppp_hold_channels(dev, ppp_chan, 1); ++ channel_count = ppp_hold_channels(dev, ppp_chan, 1); + if (channel_count != 1) { + DEBUG_TRACE("%px: Net device: %px PPP has %d channels - ECM cannot handle this (interface becomes Unknown type)\n", + feci, dev, channel_count); diff --git a/lede/package/qca/qca-nss-ecm/patches/0009-treewide-export-ipv4-and-ipv6-symbols.patch b/lede/package/qca/qca-nss-ecm/patches/0009-treewide-export-ipv4-and-ipv6-symbols.patch new file mode 100644 index 0000000000..6c4cf8b5b5 --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/patches/0009-treewide-export-ipv4-and-ipv6-symbols.patch @@ -0,0 +1,99 @@ +--- a/frontends/nss/ecm_nss_common.c ++++ b/frontends/nss/ecm_nss_common.c +@@ -67,6 +67,7 @@ bool ecm_nss_ipv6_is_conn_limit_reached( + + return false; + } ++EXPORT_SYMBOL(ecm_nss_ipv6_is_conn_limit_reached); + #endif + + /* +@@ -116,3 +117,4 @@ bool ecm_nss_ipv4_is_conn_limit_reached( + + return false; + } ++EXPORT_SYMBOL(ecm_nss_ipv4_is_conn_limit_reached); +--- a/frontends/nss/ecm_nss_non_ported_ipv4.c ++++ b/frontends/nss/ecm_nss_non_ported_ipv4.c +@@ -1831,6 +1831,7 @@ struct ecm_front_end_connection_instance + + return feci; + } ++EXPORT_SYMBOL(ecm_nss_non_ported_ipv4_connection_instance_alloc); + + /* + * ecm_nss_non_ported_ipv4_debugfs_init() +--- a/frontends/nss/ecm_nss_non_ported_ipv4.h ++++ b/frontends/nss/ecm_nss_non_ported_ipv4.h +@@ -19,7 +19,7 @@ + + extern bool ecm_nss_non_ported_ipv4_debugfs_init(struct dentry *dentry); + +-extern struct ecm_front_end_connection_instance *ecm_nss_non_ported_ipv4_connection_instance_alloc( ++struct ecm_front_end_connection_instance *ecm_nss_non_ported_ipv4_connection_instance_alloc( + uint32_t accel_flags, + int protocol, + struct ecm_db_connection_instance **nci); +--- a/frontends/nss/ecm_nss_non_ported_ipv6.c ++++ b/frontends/nss/ecm_nss_non_ported_ipv6.c +@@ -1657,6 +1657,7 @@ struct ecm_front_end_connection_instance + + return feci; + } ++EXPORT_SYMBOL(ecm_nss_non_ported_ipv6_connection_instance_alloc); + + /* + * ecm_nss_non_ported_ipv6_debugfs_init() +--- a/frontends/nss/ecm_nss_non_ported_ipv6.h ++++ b/frontends/nss/ecm_nss_non_ported_ipv6.h +@@ -19,7 +19,7 @@ + + extern bool ecm_nss_non_ported_ipv6_debugfs_init(struct dentry *dentry); + +-extern struct ecm_front_end_connection_instance *ecm_nss_non_ported_ipv6_connection_instance_alloc( ++struct ecm_front_end_connection_instance *ecm_nss_non_ported_ipv6_connection_instance_alloc( + uint32_t accel_flags, + int protocol, + struct ecm_db_connection_instance **nci); +--- a/frontends/nss/ecm_nss_ported_ipv4.c ++++ b/frontends/nss/ecm_nss_ported_ipv4.c +@@ -1906,6 +1906,7 @@ struct ecm_front_end_connection_instance + + return feci; + } ++EXPORT_SYMBOL(ecm_nss_ported_ipv4_connection_instance_alloc); + + /* + * ecm_nss_ported_ipv4_debugfs_init() +--- a/frontends/nss/ecm_nss_ported_ipv4.h ++++ b/frontends/nss/ecm_nss_ported_ipv4.h +@@ -19,7 +19,7 @@ + + extern bool ecm_nss_ported_ipv4_debugfs_init(struct dentry *dentry); + +-extern struct ecm_front_end_connection_instance *ecm_nss_ported_ipv4_connection_instance_alloc( ++struct ecm_front_end_connection_instance *ecm_nss_ported_ipv4_connection_instance_alloc( + uint32_t accel_flags, + int protocol, + struct ecm_db_connection_instance **nci); +--- a/frontends/nss/ecm_nss_ported_ipv6.c ++++ b/frontends/nss/ecm_nss_ported_ipv6.c +@@ -1812,6 +1812,7 @@ struct ecm_front_end_connection_instance + + return feci; + } ++EXPORT_SYMBOL(ecm_nss_ported_ipv6_connection_instance_alloc); + + /* + * ecm_nss_ported_ipv6_debugfs_init() +--- a/frontends/nss/ecm_nss_ported_ipv6.h ++++ b/frontends/nss/ecm_nss_ported_ipv6.h +@@ -19,7 +19,7 @@ + + extern bool ecm_nss_ported_ipv6_debugfs_init(struct dentry *dentry); + +-extern struct ecm_front_end_connection_instance *ecm_nss_ported_ipv6_connection_instance_alloc( ++struct ecm_front_end_connection_instance *ecm_nss_ported_ipv6_connection_instance_alloc( + uint32_t accel_flags, + int protocol, + struct ecm_db_connection_instance **nci); diff --git a/lede/package/qca/qca-nss-ecm/patches/1000-fix-miss-header.patch b/lede/package/qca/qca-nss-ecm/patches/1000-fix-miss-header.patch new file mode 100644 index 0000000000..1148615ca3 --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/patches/1000-fix-miss-header.patch @@ -0,0 +1,24 @@ +From 7caef43a66bf9f5bbd3d48db1fc6af26bdca8f63 Mon Sep 17 00:00:00 2001 +From: JiaY-shi +Date: Fri, 28 Jul 2023 20:44:45 +0800 +Subject: [PATCH] fix miss header + +--- + frontends/ecm_front_end_common.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/frontends/ecm_front_end_common.c b/frontends/ecm_front_end_common.c +index 1339cec..089db07 100644 +--- a/frontends/ecm_front_end_common.c ++++ b/frontends/ecm_front_end_common.c +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + #ifdef ECM_CLASSIFIER_DSCP_ENABLE + #include + #include +-- +2.25.1 + diff --git a/lede/package/qca/qca-nss-ecm/patches/900-qca-nss-ecm-fix-a-memcpy-overflow-in-ecm_db.patch b/lede/package/qca/qca-nss-ecm/patches/900-qca-nss-ecm-fix-a-memcpy-overflow-in-ecm_db.patch new file mode 100644 index 0000000000..529c792928 --- /dev/null +++ b/lede/package/qca/qca-nss-ecm/patches/900-qca-nss-ecm-fix-a-memcpy-overflow-in-ecm_db.patch @@ -0,0 +1,61 @@ +From 1958e34c4c1b8b4fb62eba693fbd7693536947b9 Mon Sep 17 00:00:00 2001 +From: flebourse +Date: Thu, 23 Dec 2021 16:11:06 +0100 +Subject: [PATCH] qca-nss-ecm: fix a memcpy overflow in ecm_db + +Calls to ipv6_addr_prefix() trigger a memcpy overflow if the prefix len +argument is greater than 128, cap it at this value. + +stack bactrace: +detected buffer overflow in memcpy +Kernel BUG at fortify_panic+0x20/0x24 +Internal error: Oops - BUG: 0 [#1] SMP +CPU: 2 PID: 2592 Comm: netifd Not tainted 5.10.80 #0 +Hardware name: Xiaomi AX9000 (DT) +Call trace: + fortify_panic+0x20/0x24 + ecm_db_exit+0x42c/0x49c [ecm] + ecm_db_exit+0x464/0x49c [ecm] + atomic_notifier_call_chain+0x5c/0x90 + ip6_route_add+0x13c/0x1a4 + inet6_rtm_newroute+0x98/0xa0 + rtnetlink_rcv_msg+0x10c/0x34c + netlink_rcv_skb+0x5c/0x130 + rtnetlink_rcv+0x1c/0x2c + netlink_unicast+0x1ec/0x2e0 + netlink_sendmsg+0x1a4/0x394 + ____sys_sendmsg+0x270/0x2b4 + ___sys_sendmsg+0x7c/0xc0 + __sys_sendmsg+0x5c/0xb0 + __arm64_sys_sendmsg+0x28/0x34 + el0_svc_common.constprop.0+0x88/0x190 + do_el0_svc+0x74/0x94 + el0_svc+0x14/0x20 + el0_sync_handler+0xa8/0x130 + el0_sync+0x184/0x1c0 +Code: aa0003e1 912b4040 910003fd 97fff56c (d4210000) + +Signed-off-By: Francis Le Bourse +--- + ecm_db/ecm_db.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/ecm_db/ecm_db.c ++++ b/ecm_db/ecm_db.c +@@ -298,7 +298,7 @@ static int ecm_db_ipv6_route_table_updat + * Compute ECM connection's prefix destination address by masking it with the + * route config's destination address prefix length. + */ +- ipv6_addr_prefix(&prefix_addr, &ecm_in6, cfg->fc_dst_len); ++ ipv6_addr_prefix(&prefix_addr, &ecm_in6, min(128, cfg->fc_dst_len)); + + DEBUG_TRACE("dest addr prefix: %pI6 prefix_len: %d ecm_in6: %pI6\n", &prefix_addr, cfg->fc_dst_len, &ecm_in6); + +@@ -326,7 +326,7 @@ static int ecm_db_ipv6_route_table_updat + * Compute ECM connection's prefix source address by masking it with the + * route config's destination address prefix length. + */ +- ipv6_addr_prefix(&prefix_addr, &ecm_in6, cfg->fc_dst_len); ++ ipv6_addr_prefix(&prefix_addr, &ecm_in6, min(128, cfg->fc_dst_len)); + + DEBUG_TRACE("src addr prefix: %pI6 prefix_len: %d ecm_in6: %pI6\n", &prefix_addr, cfg->fc_dst_len, &ecm_in6); diff --git a/lede/package/qca/qca-ssdk-shell/Makefile b/lede/package/qca/qca-ssdk-shell/Makefile new file mode 100644 index 0000000000..0a83409279 --- /dev/null +++ b/lede/package/qca/qca-ssdk-shell/Makefile @@ -0,0 +1,48 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=qca-ssdk-shell +PKG_RELEASE:=$(AUTORELEASE) + +PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/ssdk-shell.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_DATE:=2023-10-04 +PKG_SOURCE_VERSION:=451c3a26e366ea1acdb4305999a72a0389e74fed +PKG_MIRROR_HASH:=e2da723c12120096f1c851808b868abe1affa14e4d969eff7bedb1e1eb984418 + +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/package.mk + +define Package/qca-ssdk-shell + SECTION:=QCA + CATEGORY:=Utilities + TITLE:=Shell application for QCA SSDK +endef + + +define Package/qca-ssdk-shell/Description + This package contains a qca-ssdk shell application for QCA chipset +endef + +ifndef CONFIG_TOOLCHAIN_BIN_PATH +CONFIG_TOOLCHAIN_BIN_PATH=$(TOOLCHAIN_DIR)/bin +endif + +QCASSDK_CONFIG_OPTS+= TOOL_PATH=$(CONFIG_TOOLCHAIN_BIN_PATH) \ + SYS_PATH=$(LINUX_DIR) \ + TOOLPREFIX=$(TARGET_CROSS) \ + KVER=$(LINUX_VERSION) \ + CFLAGS="$(TARGET_CFLAGS)" \ + LDFLAGS="$(TARGET_LDFLAGS)" \ + ARCH=$(LINUX_KARCH) + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) $(strip $(QCASSDK_CONFIG_OPTS)) +endef + +define Package/qca-ssdk-shell/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/build/bin/ssdk_sh $(1)/usr/sbin/ +endef + + +$(eval $(call BuildPackage,qca-ssdk-shell)) diff --git a/lede/package/qca/qca-ssdk-shell/patches/0001-qca-ssdk-shell-Fix-fal_port_cdt-compilation-error-GCC-13.patch b/lede/package/qca/qca-ssdk-shell/patches/0001-qca-ssdk-shell-Fix-fal_port_cdt-compilation-error-GCC-13.patch new file mode 100644 index 0000000000..9a97ff2d92 --- /dev/null +++ b/lede/package/qca/qca-ssdk-shell/patches/0001-qca-ssdk-shell-Fix-fal_port_cdt-compilation-error-GCC-13.patch @@ -0,0 +1,10 @@ +--- a/src/fal_uk/fal_port_ctrl.c ++++ b/src/fal_uk/fal_port_ctrl.c +@@ -214,7 +214,7 @@ fal_port_hibernate_get(a_uint32_t dev_id + + sw_error_t + fal_port_cdt(a_uint32_t dev_id, fal_port_t port_id, a_uint32_t mdi_pair, +- a_uint32_t *cable_status, a_uint32_t *cable_len) ++ fal_cable_status_t * cable_status, a_uint32_t *cable_len) + { + sw_error_t rv; diff --git a/lede/target/linux/qualcommax/Makefile b/lede/target/linux/qualcommax/Makefile index 87f9190855..5bebfcdec3 100644 --- a/lede/target/linux/qualcommax/Makefile +++ b/lede/target/linux/qualcommax/Makefile @@ -14,8 +14,9 @@ include $(INCLUDE_DIR)/target.mk DEFAULT_PACKAGES += \ kmod-usb3 kmod-usb-dwc3 kmod-usb-dwc3-qcom \ kmod-leds-gpio kmod-gpio-button-hotplug \ - kmod-qca-nss-dp kmod-ath11k-ahb \ - wpad-openssl uboot-envtools \ + kmod-qca-nss-dp kmod-qca-nss-drv kmod-qca-ssdk kmod-ath11k-ahb \ + kmod-qca-nss-ecm kmod-qca-nss-drv-bridge-mgr kmod-qca-nss-drv-vlan kmod-qca-nss-drv-pppoe \ + wpad-openssl uboot-envtools htop autocore-arm\ e2fsprogs kmod-fs-ext4 losetup $(eval $(call BuildTarget)) diff --git a/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-360v6.dts b/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-360v6.dts index d83ea62629..e8872c86f7 100644 --- a/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-360v6.dts +++ b/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-360v6.dts @@ -5,6 +5,7 @@ #include "ipq6018-512m.dtsi" #include "ipq6018-ess.dtsi" #include "ipq6018-mp5496.dtsi" +#include "ipq6018-nss.dtsi" #include #include diff --git a/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-ax18.dts b/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-ax18.dts index 5b28e6981d..e887ff87ae 100644 --- a/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-ax18.dts +++ b/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-ax18.dts @@ -4,6 +4,7 @@ #include "ipq6018-256m.dtsi" #include "ipq6018-ess.dtsi" +#include "ipq6018-nss.dtsi" #include #include diff --git a/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-glinet.dtsi b/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-glinet.dtsi index 9e3b6b04c5..6c2a8e7f5a 100644 --- a/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-glinet.dtsi +++ b/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-glinet.dtsi @@ -2,6 +2,7 @@ #include "ipq6018-512m.dtsi" #include "ipq6018-ess.dtsi" +#include "ipq6018-nss.dtsi" #include #include diff --git a/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-mr7350.dts b/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-mr7350.dts index c9a641efa1..284f9356a6 100644 --- a/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-mr7350.dts +++ b/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-mr7350.dts @@ -5,6 +5,7 @@ #include "ipq6018-512m.dtsi" #include "ipq6018-ess.dtsi" #include "ipq6018-mp5496.dtsi" +#include "ipq6018-nss.dtsi" #include #include diff --git a/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-xiaomi.dtsi b/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-xiaomi.dtsi index ab16fb375e..884f19858d 100644 --- a/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-xiaomi.dtsi +++ b/lede/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq6000-xiaomi.dtsi @@ -5,6 +5,7 @@ #include "ipq6018-512m.dtsi" #include "ipq6018-ess.dtsi" #include "ipq6018-mp5496.dtsi" +#include "ipq6018-nss.dtsi" #include #include diff --git a/lede/target/linux/qualcommax/files/include/dt-bindings/net/qcom-ipq-ess.h b/lede/target/linux/qualcommax/files/include/dt-bindings/net/qcom-ipq-ess.h new file mode 100644 index 0000000000..baa7c89564 --- /dev/null +++ b/lede/target/linux/qualcommax/files/include/dt-bindings/net/qcom-ipq-ess.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _DT_BINDINGS_NET_QCOM_IPQ_ESS_H +#define _DT_BINDINGS_NET_QCOM_IPQ_ESS_H + +#define ESS_PORT0 0x1 +#define ESS_PORT1 0x2 +#define ESS_PORT2 0x4 +#define ESS_PORT3 0x8 +#define ESS_PORT4 0x10 +#define ESS_PORT5 0x20 +#define ESS_PORT6 0x40 +#define ESS_PORT7 0x80 + +/* SSDK MAC/UNIPHY modes */ +#define MAC_MODE_PSGMII 0x0 +#define MAC_MODE_PSGMII_RGMII5 0x1 +#define MAC_MODE_SGMII0_RGMII5 0x2 +#define MAC_MODE_SGMII1_RGMII5 0x3 +#define MAC_MODE_PSGMII_RMII0 0x4 +#define MAC_MODE_PSGMII_RMII1 0x5 +#define MAC_MODE_PSGMII_RMII0_RMII1 0x6 +#define MAC_MODE_PSGMII_RGMII4 0x7 +#define MAC_MODE_SGMII0_RGMII4 0x8 +#define MAC_MODE_SGMII1_RGMII4 0x9 +#define MAC_MODE_SGMII4_RGMII4 0xa +#define MAC_MODE_QSGMII 0xb +#define MAC_MODE_SGMII_PLUS 0xc +#define MAC_MODE_USXGMII 0xd +#define MAC_MODE_10GBASE_R 0xe +#define MAC_MODE_SGMII_CHANNEL0 0xf +#define MAC_MODE_SGMII_CHANNEL1 0x10 +#define MAC_MODE_SGMII_CHANNEL4 0x11 +#define MAC_MODE_RGMII 0x12 +#define MAC_MODE_PSGMII_FIBER 0x13 +#define MAC_MODE_SGMII_FIBER 0x14 +#define MAC_MODE_UQXGMII 0x15 +#define MAC_MODE_UDXGMII 0x16 +#define MAC_MODE_UQXGMII_3CHANNELS 0x17 +#define MAC_MODE_DISABLED 0xff + +#endif /* _DT_BINDINGS_NET_QCOM_IPQ_ESS_H */ diff --git a/lede/target/linux/qualcommax/files/include/net/netfilter/nf_conntrack_dscpremark_ext.h b/lede/target/linux/qualcommax/files/include/net/netfilter/nf_conntrack_dscpremark_ext.h new file mode 100644 index 0000000000..dc6a5004ef --- /dev/null +++ b/lede/target/linux/qualcommax/files/include/net/netfilter/nf_conntrack_dscpremark_ext.h @@ -0,0 +1,95 @@ +/* + ************************************************************************** + * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. + * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + ************************************************************************** + */ + +/* DSCP remark conntrack extension APIs. */ + +#ifndef _NF_CONNTRACK_DSCPREMARK_H +#define _NF_CONNTRACK_DSCPREMARK_H + +#include +#include + +/* Rule flags */ +#define NF_CT_DSCPREMARK_EXT_DSCP_RULE_VALID 0x1 + +/* Rule validity */ +#define NF_CT_DSCPREMARK_EXT_RULE_VALID 0x1 +#define NF_CT_DSCPREMARK_EXT_RULE_NOT_VALID 0x0 + +/* Which QoS features are set flags */ +#define NF_CT_DSCPREMARK_EXT_PRIO 0x1 +#define NF_CT_DSCPREMARK_EXT_DSCP 0x2 +#define NF_CT_DSCPREMARK_EXT_IGS_QOS 0x4 +#define NF_CT_DSCPREMARK_EXT_MARK 0x8 + +/* + * DSCP remark conntrack extension structure. + */ +struct nf_ct_dscpremark_ext { + __u32 flow_priority; /* Original direction packet priority */ + __u32 reply_priority; /* Reply direction packet priority */ + __u32 flow_mark; /* Original direction packet mark */ + __u32 reply_mark; /* Reply direction packet mark */ + __u16 igs_flow_qos_tag; /* Original direction ingress packet priority */ + __u16 igs_reply_qos_tag; /* Reply direction ingress packet priority */ + __u8 flow_dscp; /* IP DSCP value for original direction */ + __u8 reply_dscp; /* IP DSCP value for reply direction */ + __u16 rule_flags; /* Rule Validity flags */ + __u16 flow_set_flags; /* Original direction set flags */ + __u16 return_set_flags; /* Reply direction set flags */ +}; + +/* + * nf_ct_dscpremark_ext_find() + * Finds the extension data of the conntrack entry if it exists. + */ +static inline struct nf_ct_dscpremark_ext * +nf_ct_dscpremark_ext_find(const struct nf_conn *ct) +{ +#ifdef CONFIG_NF_CONNTRACK_DSCPREMARK_EXT + return nf_ct_ext_find(ct, NF_CT_EXT_DSCPREMARK); +#else + return NULL; +#endif +} + +/* + * nf_ct_dscpremark_ext_add() + * Adds the extension data to the conntrack entry. + */ +static inline +struct nf_ct_dscpremark_ext *nf_ct_dscpremark_ext_add(struct nf_conn *ct, + gfp_t gfp) +{ +#ifdef CONFIG_NF_CONNTRACK_DSCPREMARK_EXT + struct nf_ct_dscpremark_ext *ncde; + + ncde = nf_ct_ext_add(ct, NF_CT_EXT_DSCPREMARK, gfp); + if (!ncde) + return NULL; + + return ncde; +#else + return NULL; +#endif +}; + +#ifdef CONFIG_NF_CONNTRACK_DSCPREMARK_EXT +extern int nf_conntrack_dscpremark_ext_set_dscp_rule_valid(struct nf_conn *ct); +extern int nf_conntrack_dscpremark_ext_get_dscp_rule_validity(struct nf_conn *ct); +#endif /* CONFIG_NF_CONNTRACK_DSCPREMARK_EXT */ +#endif /* _NF_CONNTRACK_DSCPREMARK_H */ diff --git a/lede/target/linux/qualcommax/files/include/uapi/linux/tc_act/tc_nss_mirred.h b/lede/target/linux/qualcommax/files/include/uapi/linux/tc_act/tc_nss_mirred.h new file mode 100644 index 0000000000..3a368fcc8c --- /dev/null +++ b/lede/target/linux/qualcommax/files/include/uapi/linux/tc_act/tc_nss_mirred.h @@ -0,0 +1,36 @@ +#ifndef __LINUX_TC_NSS_MIRRED_H +#define __LINUX_TC_NSS_MIRRED_H + +#include + +/* + * Type of nss mirred action. + */ +#define TCA_ACT_MIRRED_NSS 17 + +/* + * Types of parameters for nss mirred action. + */ +enum { + TC_NSS_MIRRED_UNSPEC, + TC_NSS_MIRRED_TM, + TC_NSS_MIRRED_PARMS, + __TC_NSS_MIRRED_MAX +}; +#define TC_NSS_MIRRED_MAX (__TC_NSS_MIRRED_MAX - 1) + +/* + * tc_nss_mirred + * tc command structure for nss mirred action. + */ +struct tc_nss_mirred { + tc_gen; /* General tc structure. */ + __u32 from_ifindex; /* ifindex of the port from which traffic + * will be redirected. + */ + __u32 to_ifindex; /* ifindex of the port to which traffic + * will be redirected. + */ +}; + +#endif /* __LINUX_TC_NSS_MIRRED_H */ diff --git a/lede/target/linux/qualcommax/files/net/netfilter/nf_conntrack_dscpremark_ext.c b/lede/target/linux/qualcommax/files/net/netfilter/nf_conntrack_dscpremark_ext.c new file mode 100644 index 0000000000..678d27ac9d --- /dev/null +++ b/lede/target/linux/qualcommax/files/net/netfilter/nf_conntrack_dscpremark_ext.c @@ -0,0 +1,61 @@ +/* + ************************************************************************** + * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + ************************************************************************** + */ + +/* DSCP remark handling conntrack extension registration. */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +/* nf_conntrack_dscpremark_ext_set_dscp_rule_valid() + * Set DSCP rule validity flag in the extension + */ +int nf_conntrack_dscpremark_ext_set_dscp_rule_valid(struct nf_conn *ct) +{ + struct nf_ct_dscpremark_ext *ncde; + + ncde = nf_ct_dscpremark_ext_find(ct); + if (!ncde) + return -1; + + ncde->rule_flags = NF_CT_DSCPREMARK_EXT_DSCP_RULE_VALID; + return 0; +} +EXPORT_SYMBOL(nf_conntrack_dscpremark_ext_set_dscp_rule_valid); + +/* nf_conntrack_dscpremark_ext_get_dscp_rule_validity() + * Check if the DSCP rule flag is valid from the extension + */ +int nf_conntrack_dscpremark_ext_get_dscp_rule_validity(struct nf_conn *ct) +{ + struct nf_ct_dscpremark_ext *ncde; + + ncde = nf_ct_dscpremark_ext_find(ct); + if (!ncde) + return NF_CT_DSCPREMARK_EXT_RULE_NOT_VALID; + + if (ncde->rule_flags & NF_CT_DSCPREMARK_EXT_DSCP_RULE_VALID) + return NF_CT_DSCPREMARK_EXT_RULE_VALID; + + return NF_CT_DSCPREMARK_EXT_RULE_NOT_VALID; +} +EXPORT_SYMBOL(nf_conntrack_dscpremark_ext_get_dscp_rule_validity); diff --git a/lede/target/linux/qualcommax/image/ipq60xx.mk b/lede/target/linux/qualcommax/image/ipq60xx.mk index 6ef006faf6..73c7ab1d79 100644 --- a/lede/target/linux/qualcommax/image/ipq60xx.mk +++ b/lede/target/linux/qualcommax/image/ipq60xx.mk @@ -98,7 +98,10 @@ define Device/redmi_ax5-jdcloud DEVICE_MODEL := AX5 JDCloud DEVICE_DTS_CONFIG := config@cp03-c1 SOC := ipq6000 - DEVICE_PACKAGES := ipq-wifi-redmi_ax5-jdcloud + KERNEL_SIZE := 6144k + BLOCKSIZE := 64k + IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-rootfs | append-metadata + DEVICE_PACKAGES := ipq-wifi-redmi_ax5-jdcloud kmod-fs-ext4 mkf2fs f2fsck kmod-fs-f2fs endef TARGET_DEVICES += redmi_ax5-jdcloud diff --git a/lede/target/linux/qualcommax/ipq60xx/base-files/lib/upgrade/mmc.sh b/lede/target/linux/qualcommax/ipq60xx/base-files/lib/upgrade/mmc.sh new file mode 100644 index 0000000000..2e37eec6b1 --- /dev/null +++ b/lede/target/linux/qualcommax/ipq60xx/base-files/lib/upgrade/mmc.sh @@ -0,0 +1,83 @@ +# +# Copyright (C) 2016 lede-project.org +# + +# this can be used as a generic mmc upgrade script +# just add a device entry in platform.sh, +# define "kernelname" and "rootfsname" and call mmc_do_upgrade +# after the kernel and rootfs flash a loopdev (as overlay) is +# setup on top of the rootfs partition +# for the proper function a padded rootfs image is needed, basically +# append "pad-to 64k" to the image definition +# this is based on the ipq806x zyxel.sh mmc upgrade + +. /lib/functions.sh + +mmc_do_upgrade() { + local tar_file="$1" + local rootfs= + local kernel= + + [ -z "$kernel" ] && kernel=$(find_mmc_part ${kernelname}) + [ -z "$rootfs" ] && rootfs=$(find_mmc_part ${rootfsname}) + + [ -z "$kernel" ] && echo "Upgrade failed: kernel partition not found! Rebooting..." && reboot -f + [ -z "$rootfs" ] && echo "Upgrade failed: rootfs partition not found! Rebooting..." && reboot -f + + mmc_do_flash $tar_file $kernel $rootfs + + return 0 +} + +mmc_do_flash() { + local tar_file=$1 + local kernel=$2 + local rootfs=$3 + + # keep sure its unbound + losetup --detach-all || { + echo Failed to detach all loop devices. Skip this try. + reboot -f + } + + # use the first found directory in the tar archive + local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$') + board_dir=${board_dir%/} + + echo "flashing kernel to $kernel" + tar xf $tar_file ${board_dir}/kernel -O >$kernel + + echo "flashing rootfs to ${rootfs}" + tar xf $tar_file ${board_dir}/root -O >"${rootfs}" + + # a padded rootfs is needed for overlay fs creation + local offset=$(tar xf $tar_file ${board_dir}/root -O | wc -c) + [ $offset -lt 65536 ] && { + echo Wrong size for rootfs: $offset + sleep 10 + reboot -f + } + + # Mount loop for rootfs_data + local loopdev="$(losetup -f)" + losetup -o $offset $loopdev $rootfs || { + echo "Failed to mount looped rootfs_data." + sleep 10 + reboot -f + } + + echo "Format new rootfs_data at position ${offset}." + mkfs.ext4 -F -L rootfs_data $loopdev + mkdir /tmp/new_root + mount -t ext4 $loopdev /tmp/new_root && { + echo "Saving config to rootfs_data at position ${offset}." + cp -v "$UPGRADE_BACKUP" "/tmp/new_root/$BACKUP_FILE" + umount /tmp/new_root + } + + # Cleanup + losetup -d $loopdev >/dev/null 2>&1 + sync + umount -a + reboot -f +} diff --git a/lede/target/linux/qualcommax/ipq60xx/base-files/lib/upgrade/platform.sh b/lede/target/linux/qualcommax/ipq60xx/base-files/lib/upgrade/platform.sh index b04d230c4f..da6969f4d2 100644 --- a/lede/target/linux/qualcommax/ipq60xx/base-files/lib/upgrade/platform.sh +++ b/lede/target/linux/qualcommax/ipq60xx/base-files/lib/upgrade/platform.sh @@ -34,10 +34,19 @@ platform_do_upgrade() { redmi,ax5-jdcloud) kernelname="0:HLOS" rootfsname="rootfs" - mmc_do_upgrade "$1" + emmc_do_upgrade "$1" ;; *) default_do_upgrade "$1" ;; esac } + +platform_copy_config() { + case "$(board_name)" in + redmi,ax5-jdcloud) + emmc_copy_config + ;; + esac + return 0; +} diff --git a/lede/target/linux/qualcommax/ipq60xx/target.mk b/lede/target/linux/qualcommax/ipq60xx/target.mk index 06a85ab5e4..7f20467f80 100644 --- a/lede/target/linux/qualcommax/ipq60xx/target.mk +++ b/lede/target/linux/qualcommax/ipq60xx/target.mk @@ -1,6 +1,6 @@ SUBTARGET:=ipq60xx BOARDNAME:=Qualcomm Atheros IPQ60xx -DEFAULT_PACKAGES += ath11k-firmware-ipq6018 +DEFAULT_PACKAGES += ath11k-firmware-ipq6018 nss-firmware-ipq6018 define Target/Description Build firmware images for Qualcomm Atheros IPQ60xx based boards. diff --git a/lede/target/linux/qualcommax/patches-6.1/0600-1-qca-nss-ecm-support-CORE.patch b/lede/target/linux/qualcommax/patches-6.1/0600-1-qca-nss-ecm-support-CORE.patch new file mode 100644 index 0000000000..e2e3b969ec --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0600-1-qca-nss-ecm-support-CORE.patch @@ -0,0 +1,785 @@ +--- a/include/linux/if_bridge.h ++++ b/include/linux/if_bridge.h +@@ -69,6 +69,9 @@ void brioctl_set(int (*hook)(struct net + void __user *uarg)); + int br_ioctl_call(struct net *net, struct net_bridge *br, unsigned int cmd, + struct ifreq *ifr, void __user *uarg); ++/* extern void br_dev_update_stats(struct net_device *dev, ++ struct rtnl_link_stats64 *nlstats); */ ++extern bool br_is_hairpin_enabled(struct net_device *dev); + + #if IS_ENABLED(CONFIG_BRIDGE) && IS_ENABLED(CONFIG_BRIDGE_IGMP_SNOOPING) + int br_multicast_list_adjacent(struct net_device *dev, +@@ -211,4 +214,42 @@ static inline clock_t br_get_ageing_time + } + #endif + ++/* QCA NSS ECM support - Start */ ++extern struct net_device *br_port_dev_get(struct net_device *dev, ++ unsigned char *addr, ++ struct sk_buff *skb, ++ unsigned int cookie); ++extern void br_refresh_fdb_entry(struct net_device *dev, const char *addr); ++extern void br_fdb_entry_refresh(struct net_device *dev, const char *addr, __u16 vid); ++extern struct net_bridge_fdb_entry *br_fdb_has_entry(struct net_device *dev, ++ const char *addr, ++ __u16 vid); ++extern void br_fdb_update_register_notify(struct notifier_block *nb); ++extern void br_fdb_update_unregister_notify(struct notifier_block *nb); ++ ++typedef struct net_bridge_port *br_port_dev_get_hook_t(struct net_device *dev, ++ struct sk_buff *skb, ++ unsigned char *addr, ++ unsigned int cookie); ++extern br_port_dev_get_hook_t __rcu *br_port_dev_get_hook; ++ ++#define BR_FDB_EVENT_ADD 0x01 ++#define BR_FDB_EVENT_DEL 0x02 ++ ++struct br_fdb_event { ++ struct net_device *dev; ++ unsigned char addr[6]; ++ unsigned char is_local; ++ struct net_bridge *br; ++ struct net_device *orig_dev; ++}; ++extern void br_fdb_register_notify(struct notifier_block *nb); ++extern void br_fdb_unregister_notify(struct notifier_block *nb); ++ ++typedef struct net_bridge_port *br_get_dst_hook_t( ++ const struct net_bridge_port *src, ++ struct sk_buff **skb); ++extern br_get_dst_hook_t __rcu *br_get_dst_hook; ++/* QCA NSS ECM support - End */ ++ + #endif +--- a/include/linux/if_vlan.h ++++ b/include/linux/if_vlan.h +@@ -227,7 +227,28 @@ extern void vlan_vids_del_by_dev(struct + + extern bool vlan_uses_dev(const struct net_device *dev); + ++/* QCA NSS ECM support - Start */ ++extern void __vlan_dev_update_accel_stats(struct net_device *dev, ++ struct rtnl_link_stats64 *stats); ++extern u16 vlan_dev_get_egress_prio(struct net_device *dev, u32 skb_prio); ++extern struct net_device *vlan_dev_next_dev(const struct net_device *dev); ++/* QCA NSS ECM support - End */ ++ + #else ++/* QCA NSS ECM support - Start */ ++static inline void __vlan_dev_update_accel_stats(struct net_device *dev, ++ struct rtnl_link_stats64 *stats) ++{ ++ ++} ++ ++static inline u16 vlan_dev_get_egress_prio(struct net_device *dev, ++ u32 skb_prio) ++{ ++ return 0; ++} ++/* QCA NSS ECM support - End */ ++ + static inline struct net_device * + __vlan_find_dev_deep_rcu(struct net_device *real_dev, + __be16 vlan_proto, u16 vlan_id) +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -2831,6 +2831,10 @@ enum netdev_cmd { + NETDEV_OFFLOAD_XSTATS_DISABLE, + NETDEV_OFFLOAD_XSTATS_REPORT_USED, + NETDEV_OFFLOAD_XSTATS_REPORT_DELTA, ++ /* QCA NSS ECM Support - Start */ ++ NETDEV_BR_JOIN, ++ NETDEV_BR_LEAVE, ++ /* QCA NSS ECM Support - End */ + }; + const char *netdev_cmd_to_name(enum netdev_cmd cmd); + +--- a/include/net/addrconf.h ++++ b/include/net/addrconf.h +@@ -506,4 +506,9 @@ int if6_proc_init(void); + void if6_proc_exit(void); + #endif + ++/* QCA NSS ECM support - Start */ ++struct net_device *ipv6_dev_find_and_hold(struct net *net, struct in6_addr *addr, ++ int strict); ++/* QCA NSS ECM support - End */ ++ + #endif +--- a/include/net/ip6_route.h ++++ b/include/net/ip6_route.h +@@ -211,6 +211,11 @@ void rt6_multipath_rebalance(struct fib6 + void rt6_uncached_list_add(struct rt6_info *rt); + void rt6_uncached_list_del(struct rt6_info *rt); + ++/* QCA NSS ECM support - Start */ ++int rt6_register_notifier(struct notifier_block *nb); ++int rt6_unregister_notifier(struct notifier_block *nb); ++/* QCA NSS ECM support - End */ ++ + static inline const struct rt6_info *skb_rt6_info(const struct sk_buff *skb) + { + const struct dst_entry *dst = skb_dst(skb); +--- a/include/net/neighbour.h ++++ b/include/net/neighbour.h +@@ -602,4 +602,15 @@ static inline void neigh_update_is_route + *notify = 1; + } + } ++ ++/* QCA NSS ECM support - Start */ ++struct neigh_mac_update { ++ unsigned char old_mac[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))]; ++ unsigned char update_mac[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))]; ++}; ++ ++extern void neigh_mac_update_register_notify(struct notifier_block *nb); ++extern void neigh_mac_update_unregister_notify(struct notifier_block *nb); ++/* QCA NSS ECM support - End */ ++ + #endif +--- a/include/net/route.h ++++ b/include/net/route.h +@@ -240,6 +240,11 @@ struct rtable *rt_dst_alloc(struct net_d + unsigned int flags, u16 type, bool noxfrm); + struct rtable *rt_dst_clone(struct net_device *dev, struct rtable *rt); + ++/* QCA NSS ECM support - Start */ ++int ip_rt_register_notifier(struct notifier_block *nb); ++int ip_rt_unregister_notifier(struct notifier_block *nb); ++/* QCA NSS ECM support - End */ ++ + struct in_ifaddr; + void fib_add_ifaddr(struct in_ifaddr *); + void fib_del_ifaddr(struct in_ifaddr *, struct in_ifaddr *); +--- a/net/bridge/br_private.h ++++ b/net/bridge/br_private.h +@@ -2172,4 +2172,9 @@ void br_do_proxy_suppress_arp(struct sk_ + void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br, + u16 vid, struct net_bridge_port *p, struct nd_msg *msg); + struct nd_msg *br_is_nd_neigh_msg(struct sk_buff *skb, struct nd_msg *m); ++ ++/* QCA NSS ECM support - Start */ ++#define __br_get(__hook, __default, __args ...) \ ++ (__hook ? (__hook(__args)) : (__default)) ++/* QCA NSS ECM support - End */ + #endif +--- a/net/8021q/vlan_core.c ++++ b/net/8021q/vlan_core.c +@@ -548,4 +548,52 @@ static int __init vlan_offload_init(void + return 0; + } + ++/* QCA NSS ECM support - Start */ ++/* Update the VLAN device with statistics from network offload engines */ ++void __vlan_dev_update_accel_stats(struct net_device *dev, ++ struct rtnl_link_stats64 *nlstats) ++{ ++ struct vlan_pcpu_stats *stats; ++ ++ if (!is_vlan_dev(dev)) ++ return; ++ ++ stats = per_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats, 0); ++ ++ u64_stats_update_begin(&stats->syncp); ++ u64_stats_add(&stats->rx_packets, nlstats->rx_packets); ++ u64_stats_add(&stats->rx_bytes, nlstats->rx_bytes); ++ u64_stats_add(&stats->tx_packets, nlstats->tx_packets); ++ u64_stats_add(&stats->tx_bytes, nlstats->tx_bytes); ++ u64_stats_update_end(&stats->syncp); ++} ++EXPORT_SYMBOL(__vlan_dev_update_accel_stats); ++ ++/* Lookup the 802.1p egress_map table and return the 802.1p value */ ++u16 vlan_dev_get_egress_prio(struct net_device *dev, u32 skb_prio) ++{ ++ struct vlan_priority_tci_mapping *mp; ++ ++ mp = vlan_dev_priv(dev)->egress_priority_map[(skb_prio & 0xf)]; ++ while (mp) { ++ if (mp->priority == skb_prio) { ++ /* This should already be shifted ++ * to mask correctly with the ++ * VLAN's TCI ++ */ ++ return mp->vlan_qos; ++ } ++ mp = mp->next; ++ } ++ return 0; ++} ++EXPORT_SYMBOL(vlan_dev_get_egress_prio); ++ ++struct net_device *vlan_dev_next_dev(const struct net_device *dev) ++{ ++ return vlan_dev_priv(dev)->real_dev; ++} ++EXPORT_SYMBOL(vlan_dev_next_dev); ++/* QCA NSS ECM support - End */ ++ + fs_initcall(vlan_offload_init); +--- a/net/bridge/br_fdb.c ++++ b/net/bridge/br_fdb.c +@@ -33,6 +33,35 @@ static const struct rhashtable_params br + + static struct kmem_cache *br_fdb_cache __read_mostly; + ++/* QCA NSS ECM support - Start */ ++ATOMIC_NOTIFIER_HEAD(br_fdb_notifier_list); ++ATOMIC_NOTIFIER_HEAD(br_fdb_update_notifier_list); ++ ++void br_fdb_register_notify(struct notifier_block *nb) ++{ ++ atomic_notifier_chain_register(&br_fdb_notifier_list, nb); ++} ++EXPORT_SYMBOL_GPL(br_fdb_register_notify); ++ ++void br_fdb_unregister_notify(struct notifier_block *nb) ++{ ++ atomic_notifier_chain_unregister(&br_fdb_notifier_list, nb); ++} ++EXPORT_SYMBOL_GPL(br_fdb_unregister_notify); ++ ++void br_fdb_update_register_notify(struct notifier_block *nb) ++{ ++ atomic_notifier_chain_register(&br_fdb_update_notifier_list, nb); ++} ++EXPORT_SYMBOL_GPL(br_fdb_update_register_notify); ++ ++void br_fdb_update_unregister_notify(struct notifier_block *nb) ++{ ++ atomic_notifier_chain_unregister(&br_fdb_update_notifier_list, nb); ++} ++EXPORT_SYMBOL_GPL(br_fdb_update_unregister_notify); ++/* QCA NSS ECM support - End */ ++ + int __init br_fdb_init(void) + { + br_fdb_cache = kmem_cache_create("bridge_fdb_cache", +@@ -185,7 +214,26 @@ static void fdb_notify(struct net_bridge + struct sk_buff *skb; + int err = -ENOBUFS; + +- if (swdev_notify) ++ /* QCA NSS ECM support - Start */ ++ if (fdb->dst) { ++ int event; ++ struct br_fdb_event fdb_event; ++ ++ if (type == RTM_NEWNEIGH) ++ event = BR_FDB_EVENT_ADD; ++ else ++ event = BR_FDB_EVENT_DEL; ++ ++ fdb_event.dev = fdb->dst->dev; ++ ether_addr_copy(fdb_event.addr, fdb->key.addr.addr); ++ fdb_event.is_local = test_bit(BR_FDB_LOCAL, &fdb->flags); ++ atomic_notifier_call_chain(&br_fdb_notifier_list, ++ event, ++ (void *)&fdb_event); ++ } ++ /* QCA NSS ECM support - End */ ++ ++ if (swdev_notify) + br_switchdev_fdb_notify(br, fdb, type); + + skb = nlmsg_new(fdb_nlmsg_size(), GFP_ATOMIC); +@@ -520,6 +568,7 @@ void br_fdb_cleanup(struct work_struct * + unsigned long delay = hold_time(br); + unsigned long work_delay = delay; + unsigned long now = jiffies; ++ u8 mac_addr[6]; /* QCA NSS ECM support */ + + /* this part is tricky, in order to avoid blocking learning and + * consequently forwarding, we rely on rcu to delete objects with +@@ -546,8 +595,15 @@ void br_fdb_cleanup(struct work_struct * + work_delay = min(work_delay, this_timer - now); + } else { + spin_lock_bh(&br->hash_lock); +- if (!hlist_unhashed(&f->fdb_node)) ++ if (!hlist_unhashed(&f->fdb_node)) { ++ ether_addr_copy(mac_addr, f->key.addr.addr); + fdb_delete(br, f, true); ++ /* QCA NSS ECM support - Start */ ++ atomic_notifier_call_chain( ++ &br_fdb_update_notifier_list, 0, ++ (void *)mac_addr); ++ /* QCA NSS ECM support - End */ ++ } + spin_unlock_bh(&br->hash_lock); + } + } +@@ -879,6 +935,12 @@ void br_fdb_update(struct net_bridge *br + &fdb->flags))) + clear_bit(BR_FDB_ADDED_BY_EXT_LEARN, + &fdb->flags); ++ ++ /* QCA NSS ECM support - Start */ ++ atomic_notifier_call_chain( ++ &br_fdb_update_notifier_list, ++ 0, (void *)addr); ++ /* QCA NSS ECM support - End */ + } + + if (unlikely(test_bit(BR_FDB_ADDED_BY_USER, &flags))) +@@ -1466,3 +1528,62 @@ void br_fdb_clear_offload(const struct n + spin_unlock_bh(&p->br->hash_lock); + } + EXPORT_SYMBOL_GPL(br_fdb_clear_offload); ++ ++/* QCA NSS ECM support - Start */ ++/* Refresh FDB entries for bridge packets being forwarded by offload engines */ ++void br_refresh_fdb_entry(struct net_device *dev, const char *addr) ++{ ++ struct net_bridge_port *p = br_port_get_rcu(dev); ++ ++ if (!p || p->state == BR_STATE_DISABLED) ++ return; ++ ++ if (!is_valid_ether_addr(addr)) { ++ pr_info("bridge: Attempt to refresh with invalid ether address %pM\n", ++ addr); ++ return; ++ } ++ ++ rcu_read_lock(); ++ br_fdb_update(p->br, p, addr, 0, true); ++ rcu_read_unlock(); ++} ++EXPORT_SYMBOL_GPL(br_refresh_fdb_entry); ++ ++/* Update timestamp of FDB entries for bridge packets being forwarded by offload engines */ ++void br_fdb_entry_refresh(struct net_device *dev, const char *addr, __u16 vid) ++{ ++ struct net_bridge_fdb_entry *fdb; ++ struct net_bridge_port *p = br_port_get_rcu(dev); ++ ++ if (!p || p->state == BR_STATE_DISABLED) ++ return; ++ ++ rcu_read_lock(); ++ fdb = fdb_find_rcu(&p->br->fdb_hash_tbl, addr, vid); ++ if (likely(fdb)) { ++ fdb->updated = jiffies; ++ } ++ rcu_read_unlock(); ++} ++EXPORT_SYMBOL_GPL(br_fdb_entry_refresh); ++ ++/* Look up the MAC address in the device's bridge fdb table */ ++struct net_bridge_fdb_entry *br_fdb_has_entry(struct net_device *dev, ++ const char *addr, __u16 vid) ++{ ++ struct net_bridge_port *p = br_port_get_rcu(dev); ++ struct net_bridge_fdb_entry *fdb; ++ ++ if (!p || p->state == BR_STATE_DISABLED) ++ return NULL; ++ ++ rcu_read_lock(); ++ fdb = fdb_find_rcu(&p->br->fdb_hash_tbl, addr, vid); ++ rcu_read_unlock(); ++ ++ return fdb; ++} ++EXPORT_SYMBOL_GPL(br_fdb_has_entry); ++/* QCA NSS ECM support - End */ ++ +--- a/net/bridge/br_if.c ++++ b/net/bridge/br_if.c +@@ -26,6 +26,12 @@ + + #include "br_private.h" + ++/* QCA NSS ECM support - Start */ ++/* Hook for external forwarding logic */ ++br_port_dev_get_hook_t __rcu *br_port_dev_get_hook __read_mostly; ++EXPORT_SYMBOL_GPL(br_port_dev_get_hook); ++/* QCA NSS ECM support - End */ ++ + /* + * Determine initial path cost based on speed. + * using recommendations from 802.1d standard +@@ -697,6 +703,8 @@ int br_add_if(struct net_bridge *br, str + + kobject_uevent(&p->kobj, KOBJ_ADD); + ++ call_netdevice_notifiers(NETDEV_BR_JOIN, dev); /* QCA NSS ECM support */ ++ + return 0; + + err6: +@@ -732,6 +740,8 @@ int br_del_if(struct net_bridge *br, str + if (!p || p->br != br) + return -EINVAL; + ++ call_netdevice_notifiers(NETDEV_BR_LEAVE, dev); /* QCA NSS ECM support */ ++ + /* Since more than one interface can be attached to a bridge, + * there still maybe an alternate path for netconsole to use; + * therefore there is no reason for a NETDEV_RELEASE event. +@@ -775,3 +785,96 @@ bool br_port_flag_is_set(const struct ne + return p->flags & flag; + } + EXPORT_SYMBOL_GPL(br_port_flag_is_set); ++ ++/* QCA NSS ECM support - Start */ ++/* API to know if hairpin feature is enabled/disabled on this bridge port */ ++bool br_is_hairpin_enabled(struct net_device *dev) ++{ ++ struct net_bridge_port *port = br_port_get_check_rcu(dev); ++ ++ if (likely(port)) ++ return port->flags & BR_HAIRPIN_MODE; ++ return false; ++} ++EXPORT_SYMBOL_GPL(br_is_hairpin_enabled); ++ ++/* br_port_dev_get() ++ * If a skb is provided, and the br_port_dev_get_hook_t hook exists, ++ * use that to try and determine the egress port for that skb. ++ * If not, or no egress port could be determined, use the given addr ++ * to identify the port to which it is reachable, ++ * returing a reference to the net device associated with that port. ++ * ++ * NOTE: Return NULL if given dev is not a bridge or the mac has no ++ * associated port. ++ */ ++struct net_device *br_port_dev_get(struct net_device *dev, unsigned char *addr, ++ struct sk_buff *skb, ++ unsigned int cookie) ++{ ++ struct net_bridge_fdb_entry *fdbe; ++ struct net_bridge *br; ++ struct net_device *netdev = NULL; ++ ++ /* Is this a bridge? */ ++ if (!(dev->priv_flags & IFF_EBRIDGE)) ++ return NULL; ++ ++ rcu_read_lock(); ++ ++ /* If the hook exists and the skb isn't NULL, try and get the port */ ++ if (skb) { ++ br_port_dev_get_hook_t *port_dev_get_hook; ++ ++ port_dev_get_hook = rcu_dereference(br_port_dev_get_hook); ++ if (port_dev_get_hook) { ++ struct net_bridge_port *pdst = ++ __br_get(port_dev_get_hook, NULL, dev, skb, ++ addr, cookie); ++ if (pdst) { ++ dev_hold(pdst->dev); ++ netdev = pdst->dev; ++ goto out; ++ } ++ } ++ } ++ ++ /* Either there is no hook, or can't ++ * determine the port to use - fall back to using FDB ++ */ ++ ++ br = netdev_priv(dev); ++ ++ /* Lookup the fdb entry and get reference to the port dev */ ++ fdbe = br_fdb_find_rcu(br, addr, 0); ++ if (fdbe && fdbe->dst) { ++ netdev = fdbe->dst->dev; /* port device */ ++ dev_hold(netdev); ++ } ++out: ++ rcu_read_unlock(); ++ return netdev; ++} ++EXPORT_SYMBOL_GPL(br_port_dev_get); ++ ++/* Update bridge statistics for bridge packets processed by offload engines */ ++/* void br_dev_update_stats(struct net_device *dev, ++ struct rtnl_link_stats64 *nlstats) ++{ ++ struct pcpu_sw_netstats *tstats; ++ ++ // Is this a bridge? ++ if (!(dev->priv_flags & IFF_EBRIDGE)) ++ return; ++ ++ tstats = this_cpu_ptr(dev->tstats); ++ ++ u64_stats_update_begin(&tstats->syncp); ++ u64_stats_add(&tstats->rx_packets, nlstats->rx_packets); ++ u64_stats_add(&tstats->rx_bytes, nlstats->rx_bytes); ++ u64_stats_add(&tstats->tx_packets, nlstats->tx_packets); ++ u64_stats_add(&tstats->tx_bytes, nlstats->tx_bytes); ++ u64_stats_update_end(&tstats->syncp); ++} ++EXPORT_SYMBOL_GPL(br_dev_update_stats); */ ++/* QCA NSS ECM support - End */ +--- a/net/core/neighbour.c ++++ b/net/core/neighbour.c +@@ -1268,6 +1268,22 @@ static void neigh_update_hhs(struct neig + } + } + ++/* QCA NSS ECM support - Start */ ++ATOMIC_NOTIFIER_HEAD(neigh_mac_update_notifier_list); ++ ++void neigh_mac_update_register_notify(struct notifier_block *nb) ++{ ++ atomic_notifier_chain_register(&neigh_mac_update_notifier_list, nb); ++} ++EXPORT_SYMBOL_GPL(neigh_mac_update_register_notify); ++ ++void neigh_mac_update_unregister_notify(struct notifier_block *nb) ++{ ++ atomic_notifier_chain_unregister(&neigh_mac_update_notifier_list, nb); ++} ++EXPORT_SYMBOL_GPL(neigh_mac_update_unregister_notify); ++/* QCA NSS ECM support - End */ ++ + /* Generic update routine. + -- lladdr is new lladdr or NULL, if it is not supplied. + -- new is new state. +@@ -1296,6 +1312,7 @@ static int __neigh_update(struct neighbo + struct net_device *dev; + int err, notify = 0; + u8 old; ++ struct neigh_mac_update nmu; /* QCA NSS ECM support */ + + trace_neigh_update(neigh, lladdr, new, flags, nlmsg_pid); + +@@ -1310,7 +1327,10 @@ static int __neigh_update(struct neighbo + new = old; + goto out; + } +- if (!(flags & NEIGH_UPDATE_F_ADMIN) && ++ ++ memset(&nmu, 0, sizeof(struct neigh_mac_update)); /* QCA NSS ECM support */ ++ ++ if (!(flags & NEIGH_UPDATE_F_ADMIN) && + (old & (NUD_NOARP | NUD_PERMANENT))) + goto out; + +@@ -1347,7 +1367,12 @@ static int __neigh_update(struct neighbo + - compare new & old + - if they are different, check override flag + */ +- if ((old & NUD_VALID) && ++ /* QCA NSS ECM update - Start */ ++ memcpy(nmu.old_mac, neigh->ha, dev->addr_len); ++ memcpy(nmu.update_mac, lladdr, dev->addr_len); ++ /* QCA NSS ECM update - End */ ++ ++ if ((old & NUD_VALID) && + !memcmp(lladdr, neigh->ha, dev->addr_len)) + lladdr = neigh->ha; + } else { +@@ -1469,8 +1494,11 @@ out: + neigh_update_gc_list(neigh); + if (managed_update) + neigh_update_managed_list(neigh); +- if (notify) ++ if (notify) { + neigh_update_notify(neigh, nlmsg_pid); ++ atomic_notifier_call_chain(&neigh_mac_update_notifier_list, 0, ++ (struct neigh_mac_update *)&nmu); /* QCA NSS ECM support */ ++ } + trace_neigh_update_done(neigh, err); + return err; + } +--- a/net/ipv4/fib_trie.c ++++ b/net/ipv4/fib_trie.c +@@ -1211,6 +1211,9 @@ static bool fib_valid_key_len(u32 key, u + static void fib_remove_alias(struct trie *t, struct key_vector *tp, + struct key_vector *l, struct fib_alias *old); + ++/* Define route change notification chain. */ ++static BLOCKING_NOTIFIER_HEAD(iproute_chain); /* QCA NSS ECM support */ ++ + /* Caller must hold RTNL. */ + int fib_table_insert(struct net *net, struct fib_table *tb, + struct fib_config *cfg, struct netlink_ext_ack *extack) +@@ -1404,6 +1407,9 @@ int fib_table_insert(struct net *net, st + rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, new_fa->tb_id, + &cfg->fc_nlinfo, nlflags); + succeeded: ++ blocking_notifier_call_chain(&iproute_chain, ++ RTM_NEWROUTE, fi); ++ + return 0; + + out_remove_new_fa: +@@ -1775,6 +1781,9 @@ int fib_table_delete(struct net *net, st + if (fa_to_delete->fa_state & FA_S_ACCESSED) + rt_cache_flush(cfg->fc_nlinfo.nl_net); + ++ blocking_notifier_call_chain(&iproute_chain, ++ RTM_DELROUTE, fa_to_delete->fa_info); ++ + fib_release_info(fa_to_delete->fa_info); + alias_free_mem_rcu(fa_to_delete); + return 0; +@@ -2407,6 +2416,20 @@ void __init fib_trie_init(void) + 0, SLAB_PANIC | SLAB_ACCOUNT, NULL); + } + ++/* QCA NSS ECM support - Start */ ++int ip_rt_register_notifier(struct notifier_block *nb) ++{ ++ return blocking_notifier_chain_register(&iproute_chain, nb); ++} ++EXPORT_SYMBOL(ip_rt_register_notifier); ++ ++int ip_rt_unregister_notifier(struct notifier_block *nb) ++{ ++ return blocking_notifier_chain_unregister(&iproute_chain, nb); ++} ++EXPORT_SYMBOL(ip_rt_unregister_notifier); ++/* QCA NSS ECM support - End */ ++ + struct fib_table *fib_trie_table(u32 id, struct fib_table *alias) + { + struct fib_table *tb; +--- a/net/ipv6/ndisc.c ++++ b/net/ipv6/ndisc.c +@@ -666,6 +666,7 @@ void ndisc_send_ns(struct net_device *de + if (skb) + ndisc_send_skb(skb, daddr, saddr); + } ++EXPORT_SYMBOL(ndisc_send_ns); + + void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr, + const struct in6_addr *daddr) +--- a/net/ipv6/route.c ++++ b/net/ipv6/route.c +@@ -3857,6 +3857,9 @@ out_free: + return ERR_PTR(err); + } + ++/* Define route change notification chain. */ ++ATOMIC_NOTIFIER_HEAD(ip6route_chain); /* QCA NSS ECM support */ ++ + int ip6_route_add(struct fib6_config *cfg, gfp_t gfp_flags, + struct netlink_ext_ack *extack) + { +@@ -3868,6 +3871,10 @@ int ip6_route_add(struct fib6_config *cf + return PTR_ERR(rt); + + err = __ip6_ins_rt(rt, &cfg->fc_nlinfo, extack); ++ if (!err) ++ atomic_notifier_call_chain(&ip6route_chain, ++ RTM_NEWROUTE, rt); ++ + fib6_info_release(rt); + + return err; +@@ -3889,6 +3896,9 @@ static int __ip6_del_rt(struct fib6_info + err = fib6_del(rt, info); + spin_unlock_bh(&table->tb6_lock); + ++ if (!err) ++ atomic_notifier_call_chain(&ip6route_chain, ++ RTM_DELROUTE, rt); + out: + fib6_info_release(rt); + return err; +@@ -6342,6 +6352,20 @@ static int ip6_route_dev_notify(struct n + return NOTIFY_OK; + } + ++/* QCA NSS ECM support - Start */ ++int rt6_register_notifier(struct notifier_block *nb) ++{ ++ return atomic_notifier_chain_register(&ip6route_chain, nb); ++} ++EXPORT_SYMBOL(rt6_register_notifier); ++ ++int rt6_unregister_notifier(struct notifier_block *nb) ++{ ++ return atomic_notifier_chain_unregister(&ip6route_chain, nb); ++} ++EXPORT_SYMBOL(rt6_unregister_notifier); ++/* QCA NSS ECM support - End */ ++ + /* + * /proc + */ +--- a/net/core/dev.c ++++ b/net/core/dev.c +@@ -1639,6 +1639,7 @@ const char *netdev_cmd_to_name(enum netd + N(SVLAN_FILTER_PUSH_INFO) N(SVLAN_FILTER_DROP_INFO) + N(PRE_CHANGEADDR) N(OFFLOAD_XSTATS_ENABLE) N(OFFLOAD_XSTATS_DISABLE) + N(OFFLOAD_XSTATS_REPORT_USED) N(OFFLOAD_XSTATS_REPORT_DELTA) ++ N(BR_JOIN) N(BR_LEAVE) + } + #undef N + return "UNKNOWN_NETDEV_EVENT"; +--- a/net/ipv6/addrconf.c ++++ b/net/ipv6/addrconf.c +@@ -987,6 +987,7 @@ void inet6_ifa_finish_destroy(struct ine + + kfree_rcu(ifp, rcu); + } ++EXPORT_SYMBOL(inet6_ifa_finish_destroy); + + static void + ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp) +@@ -2045,6 +2046,36 @@ struct inet6_ifaddr *ipv6_get_ifaddr(str + + return result; + } ++EXPORT_SYMBOL(ipv6_get_ifaddr); ++ ++/* ipv6_dev_find_and_hold() ++ * Find (and hold) net device that has the given address. ++ * Or NULL on failure. ++ */ ++struct net_device *ipv6_dev_find_and_hold(struct net *net, struct in6_addr *addr, ++ int strict) ++{ ++ struct inet6_ifaddr *ifp; ++ struct net_device *dev; ++ ++ ifp = ipv6_get_ifaddr(net, addr, NULL, strict); ++ if (!ifp) ++ return NULL; ++ ++ if (!ifp->idev) { ++ in6_ifa_put(ifp); ++ return NULL; ++ } ++ ++ dev = ifp->idev->dev; ++ if (dev) ++ dev_hold(dev); ++ ++ in6_ifa_put(ifp); ++ ++ return dev; ++} ++EXPORT_SYMBOL(ipv6_dev_find_and_hold); + + /* Gets referenced address, destroys ifaddr */ + +--- a/include/net/vxlan.h ++++ b/include/net/vxlan.h +@@ -432,6 +432,15 @@ static inline __be32 vxlan_compute_rco(u + return vni_field; + } + ++/* ++ * vxlan_get_vni() ++ * Returns the vni corresponding to tunnel ++ */ ++static inline u32 vxlan_get_vni(struct vxlan_dev *vxlan_tun) ++{ ++ return be32_to_cpu(vxlan_tun->cfg.vni); ++} ++ + static inline unsigned short vxlan_get_sk_family(struct vxlan_sock *vs) + { + return vs->sock->sk->sk_family; diff --git a/lede/target/linux/qualcommax/patches-6.1/0600-2-qca-nss-ecm-support-PPPOE-offload.patch b/lede/target/linux/qualcommax/patches-6.1/0600-2-qca-nss-ecm-support-PPPOE-offload.patch new file mode 100644 index 0000000000..25e21bc091 --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0600-2-qca-nss-ecm-support-PPPOE-offload.patch @@ -0,0 +1,590 @@ +--- a/drivers/net/ppp/ppp_generic.c ++++ b/drivers/net/ppp/ppp_generic.c +@@ -48,6 +48,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -254,6 +255,25 @@ struct ppp_net { + #define seq_before(a, b) ((s32)((a) - (b)) < 0) + #define seq_after(a, b) ((s32)((a) - (b)) > 0) + ++ ++/* ++ * Registration/Unregistration methods ++ * for PPP channel connect and disconnect event notifications. ++ */ ++RAW_NOTIFIER_HEAD(ppp_channel_connection_notifier_list); ++ ++void ppp_channel_connection_register_notify(struct notifier_block *nb) ++{ ++ raw_notifier_chain_register(&ppp_channel_connection_notifier_list, nb); ++} ++EXPORT_SYMBOL_GPL(ppp_channel_connection_register_notify); ++ ++void ppp_channel_connection_unregister_notify(struct notifier_block *nb) ++{ ++ raw_notifier_chain_unregister(&ppp_channel_connection_notifier_list, nb); ++} ++EXPORT_SYMBOL_GPL(ppp_channel_connection_unregister_notify); ++ + /* Prototypes. */ + static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf, + struct file *file, unsigned int cmd, unsigned long arg); +@@ -3453,7 +3473,10 @@ ppp_connect_channel(struct channel *pch, + struct ppp_net *pn; + int ret = -ENXIO; + int hdrlen; ++ int ppp_proto; ++ int version; + ++ int notify = 0; + pn = ppp_pernet(pch->chan_net); + + mutex_lock(&pn->all_ppp_mutex); +@@ -3485,13 +3508,40 @@ ppp_connect_channel(struct channel *pch, + ++ppp->n_channels; + pch->ppp = ppp; + refcount_inc(&ppp->file.refcnt); ++ ++ /* Set the netdev priv flag if the prototype ++ * is L2TP or PPTP. Return success in all cases ++ */ ++ if (!pch->chan) ++ goto out2; ++ ++ ppp_proto = ppp_channel_get_protocol(pch->chan); ++ if (ppp_proto == PX_PROTO_PPTP) { ++ ppp->dev->priv_flags_ext |= IFF_EXT_PPP_PPTP; ++ } else if (ppp_proto == PX_PROTO_OL2TP) { ++ version = ppp_channel_get_proto_version(pch->chan); ++ if (version == 2) ++ ppp->dev->priv_flags_ext |= IFF_EXT_PPP_L2TPV2; ++ else if (version == 3) ++ ppp->dev->priv_flags_ext |= IFF_EXT_PPP_L2TPV3; ++ } ++ notify = 1; ++ ++ out2: + ppp_unlock(ppp); + ret = 0; +- + outl: + write_unlock_bh(&pch->upl); + out: + mutex_unlock(&pn->all_ppp_mutex); ++ ++ if (notify && ppp && ppp->dev) { ++ dev_hold(ppp->dev); ++ raw_notifier_call_chain(&ppp_channel_connection_notifier_list, ++ PPP_CHANNEL_CONNECT, ppp->dev); ++ dev_put(ppp->dev); ++ } ++ + return ret; + } + +@@ -3509,6 +3559,13 @@ ppp_disconnect_channel(struct channel *p + pch->ppp = NULL; + write_unlock_bh(&pch->upl); + if (ppp) { ++ if (ppp->dev) { ++ dev_hold(ppp->dev); ++ raw_notifier_call_chain(&ppp_channel_connection_notifier_list, ++ PPP_CHANNEL_DISCONNECT, ppp->dev); ++ dev_put(ppp->dev); ++ } ++ + /* remove it from the ppp unit's list */ + ppp_lock(ppp); + list_del(&pch->clist); +@@ -3588,6 +3645,222 @@ static void *unit_find(struct idr *p, in + return idr_find(p, n); + } + ++/* Updates the PPP interface statistics. */ ++void ppp_update_stats(struct net_device *dev, unsigned long rx_packets, ++ unsigned long rx_bytes, unsigned long tx_packets, ++ unsigned long tx_bytes, unsigned long rx_errors, ++ unsigned long tx_errors, unsigned long rx_dropped, ++ unsigned long tx_dropped) ++{ ++ struct ppp *ppp; ++ ++ if (!dev) ++ return; ++ ++ if (dev->type != ARPHRD_PPP) ++ return; ++ ++ ppp = netdev_priv(dev); ++ ++ ppp_xmit_lock(ppp); ++ ppp->stats64.tx_packets += tx_packets; ++ ppp->stats64.tx_bytes += tx_bytes; ++ ppp->dev->stats.tx_errors += tx_errors; ++ ppp->dev->stats.tx_dropped += tx_dropped; ++ if (tx_packets) ++ ppp->last_xmit = jiffies; ++ ppp_xmit_unlock(ppp); ++ ++ ppp_recv_lock(ppp); ++ ppp->stats64.rx_packets += rx_packets; ++ ppp->stats64.rx_bytes += rx_bytes; ++ ppp->dev->stats.rx_errors += rx_errors; ++ ppp->dev->stats.rx_dropped += rx_dropped; ++ if (rx_packets) ++ ppp->last_recv = jiffies; ++ ppp_recv_unlock(ppp); ++} ++ ++/* Returns >0 if the device is a multilink PPP netdevice, 0 if not or < 0 if ++ * the device is not PPP. ++ */ ++int ppp_is_multilink(struct net_device *dev) ++{ ++ struct ppp *ppp; ++ unsigned int flags; ++ ++ if (!dev) ++ return -1; ++ ++ if (dev->type != ARPHRD_PPP) ++ return -1; ++ ++ ppp = netdev_priv(dev); ++ ppp_lock(ppp); ++ flags = ppp->flags; ++ ppp_unlock(ppp); ++ ++ if (flags & SC_MULTILINK) ++ return 1; ++ ++ return 0; ++} ++EXPORT_SYMBOL(ppp_is_multilink); ++ ++/* ppp_channel_get_protocol() ++ * Call this to obtain the underlying protocol of the PPP channel, ++ * e.g. PX_PROTO_OE ++ * ++ * NOTE: Some channels do not use PX sockets so the protocol value may be very ++ * different for them. ++ * NOTE: -1 indicates failure. ++ * NOTE: Once you know the channel protocol you may then either cast 'chan' to ++ * its sub-class or use the channel protocol specific API's as provided by that ++ * channel sub type. ++ */ ++int ppp_channel_get_protocol(struct ppp_channel *chan) ++{ ++ if (!chan->ops->get_channel_protocol) ++ return -1; ++ ++ return chan->ops->get_channel_protocol(chan); ++} ++EXPORT_SYMBOL(ppp_channel_get_protocol); ++ ++/* ppp_channel_get_proto_version() ++ * Call this to get channel protocol version ++ */ ++int ppp_channel_get_proto_version(struct ppp_channel *chan) ++{ ++ if (!chan->ops->get_channel_protocol_ver) ++ return -1; ++ ++ return chan->ops->get_channel_protocol_ver(chan); ++} ++EXPORT_SYMBOL(ppp_channel_get_proto_version); ++ ++/* ppp_channel_hold() ++ * Call this to hold a channel. ++ * ++ * Returns true on success or false if the hold could not happen. ++ * ++ * NOTE: chan must be protected against destruction during this call - ++ * either by correct locking etc. or because you already have an implicit ++ * or explicit hold to the channel already and this is an additional hold. ++ */ ++bool ppp_channel_hold(struct ppp_channel *chan) ++{ ++ if (!chan->ops->hold) ++ return false; ++ ++ chan->ops->hold(chan); ++ return true; ++} ++EXPORT_SYMBOL(ppp_channel_hold); ++ ++/* ppp_channel_release() ++ * Call this to release a hold you have upon a channel ++ */ ++void ppp_channel_release(struct ppp_channel *chan) ++{ ++ chan->ops->release(chan); ++} ++EXPORT_SYMBOL(ppp_channel_release); ++ ++/* Check if ppp xmit lock is on hold */ ++bool ppp_is_xmit_locked(struct net_device *dev) ++{ ++ struct ppp *ppp; ++ ++ if (!dev) ++ return false; ++ ++ if (dev->type != ARPHRD_PPP) ++ return false; ++ ++ ppp = netdev_priv(dev); ++ if (!ppp) ++ return false; ++ ++ if (spin_is_locked(&(ppp)->wlock)) ++ return true; ++ ++ return false; ++} ++EXPORT_SYMBOL(ppp_is_xmit_locked); ++ ++/* ppp_hold_channels() ++ * Returns the PPP channels of the PPP device, storing each one into ++ * channels[]. ++ * ++ * channels[] has chan_sz elements. ++ * This function returns the number of channels stored, up to chan_sz. ++ * It will return < 0 if the device is not PPP. ++ * ++ * You MUST release the channels using ppp_release_channels(). ++ */ ++int ppp_hold_channels(struct net_device *dev, struct ppp_channel *channels[], ++ unsigned int chan_sz) ++{ ++ struct ppp *ppp; ++ int c; ++ struct channel *pch; ++ ++ if (!dev) ++ return -1; ++ ++ if (dev->type != ARPHRD_PPP) ++ return -1; ++ ++ ppp = netdev_priv(dev); ++ ++ c = 0; ++ ppp_lock(ppp); ++ list_for_each_entry(pch, &ppp->channels, clist) { ++ struct ppp_channel *chan; ++ ++ if (!pch->chan) { ++ /* Channel is going / gone away */ ++ continue; ++ } ++ ++ if (c == chan_sz) { ++ /* No space to record channel */ ++ ppp_unlock(ppp); ++ return c; ++ } ++ ++ /* Hold the channel, if supported */ ++ chan = pch->chan; ++ if (!chan->ops->hold) ++ continue; ++ ++ chan->ops->hold(chan); ++ ++ /* Record the channel */ ++ channels[c++] = chan; ++ } ++ ppp_unlock(ppp); ++ return c; ++} ++EXPORT_SYMBOL(ppp_hold_channels); ++ ++/* ppp_release_channels() ++ * Releases channels ++ */ ++void ppp_release_channels(struct ppp_channel *channels[], unsigned int chan_sz) ++{ ++ unsigned int c; ++ ++ for (c = 0; c < chan_sz; ++c) { ++ struct ppp_channel *chan; ++ ++ chan = channels[c]; ++ chan->ops->release(chan); ++ } ++} ++EXPORT_SYMBOL(ppp_release_channels); ++ + /* Module/initialization stuff */ + + module_init(ppp_init); +@@ -3604,6 +3877,7 @@ EXPORT_SYMBOL(ppp_input_error); + EXPORT_SYMBOL(ppp_output_wakeup); + EXPORT_SYMBOL(ppp_register_compressor); + EXPORT_SYMBOL(ppp_unregister_compressor); ++EXPORT_SYMBOL(ppp_update_stats); + MODULE_LICENSE("GPL"); + MODULE_ALIAS_CHARDEV(PPP_MAJOR, 0); + MODULE_ALIAS_RTNL_LINK("ppp"); +--- a/drivers/net/ppp/pppoe.c ++++ b/drivers/net/ppp/pppoe.c +@@ -62,6 +62,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -87,7 +88,7 @@ + static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb); + + static const struct proto_ops pppoe_ops; +-static const struct ppp_channel_ops pppoe_chan_ops; ++static const struct pppoe_channel_ops pppoe_chan_ops; + + /* per-net private data for this module */ + static unsigned int pppoe_net_id __read_mostly; +@@ -692,7 +693,7 @@ static int pppoe_connect(struct socket * + + po->chan.mtu = dev->mtu - sizeof(struct pppoe_hdr) - 2; + po->chan.private = sk; +- po->chan.ops = &pppoe_chan_ops; ++ po->chan.ops = (struct ppp_channel_ops *)&pppoe_chan_ops; + + error = ppp_register_net_channel(dev_net(dev), &po->chan); + if (error) { +@@ -995,9 +996,80 @@ static int pppoe_fill_forward_path(struc + return 0; + } + +-static const struct ppp_channel_ops pppoe_chan_ops = { +- .start_xmit = pppoe_xmit, +- .fill_forward_path = pppoe_fill_forward_path, ++/************************************************************************ ++ * ++ * function called by generic PPP driver to hold channel ++ * ++ ***********************************************************************/ ++static void pppoe_hold_chan(struct ppp_channel *chan) ++{ ++ struct sock *sk = (struct sock *)chan->private; ++ ++ sock_hold(sk); ++} ++ ++/************************************************************************ ++ * ++ * function called by generic PPP driver to release channel ++ * ++ ***********************************************************************/ ++static void pppoe_release_chan(struct ppp_channel *chan) ++{ ++ struct sock *sk = (struct sock *)chan->private; ++ ++ sock_put(sk); ++} ++ ++/************************************************************************ ++ * ++ * function called to get the channel protocol type ++ * ++ ***********************************************************************/ ++static int pppoe_get_channel_protocol(struct ppp_channel *chan) ++{ ++ return PX_PROTO_OE; ++} ++ ++/************************************************************************ ++ * ++ * function called to get the PPPoE channel addressing ++ * NOTE: This function returns a HOLD to the netdevice ++ * ++ ***********************************************************************/ ++static int pppoe_get_addressing(struct ppp_channel *chan, ++ struct pppoe_opt *addressing) ++{ ++ struct sock *sk = (struct sock *)chan->private; ++ struct pppox_sock *po = pppox_sk(sk); ++ int err = 0; ++ ++ *addressing = po->proto.pppoe; ++ if (!addressing->dev) ++ return -ENODEV; ++ ++ dev_hold(addressing->dev); ++ return err; ++} ++ ++/* pppoe_channel_addressing_get() ++ * Return PPPoE channel specific addressing information. ++ */ ++int pppoe_channel_addressing_get(struct ppp_channel *chan, ++ struct pppoe_opt *addressing) ++{ ++ return pppoe_get_addressing(chan, addressing); ++} ++EXPORT_SYMBOL(pppoe_channel_addressing_get); ++ ++static const struct pppoe_channel_ops pppoe_chan_ops = { ++ /* PPPoE specific channel ops */ ++ .get_addressing = pppoe_get_addressing, ++ /* General ppp channel ops */ ++ .ops.start_xmit = pppoe_xmit, ++ .ops.get_channel_protocol = pppoe_get_channel_protocol, ++ .ops.hold = pppoe_hold_chan, ++ .ops.release = pppoe_release_chan, ++ .ops.fill_forward_path = pppoe_fill_forward_path, + }; + + static int pppoe_recvmsg(struct socket *sock, struct msghdr *m, +--- a/include/linux/if_pppox.h ++++ b/include/linux/if_pppox.h +@@ -91,4 +91,17 @@ enum { + PPPOX_DEAD = 16 /* dead, useless, please clean me up!*/ + }; + ++/* ++ * PPPoE Channel specific operations ++ */ ++struct pppoe_channel_ops { ++ /* Must be first - general to all PPP channels */ ++ struct ppp_channel_ops ops; ++ int (*get_addressing)(struct ppp_channel *, struct pppoe_opt *); ++}; ++ ++/* Return PPPoE channel specific addressing information */ ++extern int pppoe_channel_addressing_get(struct ppp_channel *chan, ++ struct pppoe_opt *addressing); ++ + #endif /* !(__LINUX_IF_PPPOX_H) */ +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -1709,6 +1709,24 @@ enum netdev_priv_flags { + IFF_NO_IP_ALIGN = BIT_ULL(33), + }; + ++ ++/** ++ * enum netdev_priv_flags_ext - &struct net_device priv_flags_ext ++ * ++ * These flags are used to check for device type and can be ++ * set and used by the drivers ++ * ++ */ ++enum netdev_priv_flags_ext { ++ IFF_EXT_TUN_TAP = 1<<0, ++ IFF_EXT_PPP_L2TPV2 = 1<<1, ++ IFF_EXT_PPP_L2TPV3 = 1<<2, ++ IFF_EXT_PPP_PPTP = 1<<3, ++ IFF_EXT_GRE_V4_TAP = 1<<4, ++ IFF_EXT_GRE_V6_TAP = 1<<5, ++ IFF_EXT_IFB = 1<<6, ++}; ++ + #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN + #define IFF_EBRIDGE IFF_EBRIDGE + #define IFF_BONDING IFF_BONDING +@@ -2051,7 +2069,8 @@ struct net_device { + /* Read-mostly cache-line for fast-path access */ + unsigned int flags; + unsigned long long priv_flags; +- const struct net_device_ops *netdev_ops; ++ unsigned int priv_flags_ext; ++ const struct net_device_ops *netdev_ops; + int ifindex; + unsigned short gflags; + unsigned short hard_header_len; +--- a/include/linux/ppp_channel.h ++++ b/include/linux/ppp_channel.h +@@ -19,6 +19,10 @@ + #include + #include + #include ++#include ++ ++#define PPP_CHANNEL_DISCONNECT 0 ++#define PPP_CHANNEL_CONNECT 1 + + struct net_device_path; + struct net_device_path_ctx; +@@ -30,9 +34,19 @@ struct ppp_channel_ops { + int (*start_xmit)(struct ppp_channel *, struct sk_buff *); + /* Handle an ioctl call that has come in via /dev/ppp. */ + int (*ioctl)(struct ppp_channel *, unsigned int, unsigned long); ++ /* Get channel protocol type, one of PX_PROTO_XYZ or specific to ++ * the channel subtype ++ */ ++ int (*get_channel_protocol)(struct ppp_channel *); ++ /* Get channel protocol version */ ++ int (*get_channel_protocol_ver)(struct ppp_channel *); ++ /* Hold the channel from being destroyed */ ++ void (*hold)(struct ppp_channel *); ++ /* Release hold on the channel */ ++ void (*release)(struct ppp_channel *); + int (*fill_forward_path)(struct net_device_path_ctx *, +- struct net_device_path *, +- const struct ppp_channel *); ++ struct net_device_path *, ++ const struct ppp_channel *); + }; + + struct ppp_channel { +@@ -76,6 +90,51 @@ extern int ppp_unit_number(struct ppp_ch + /* Get the device name associated with a channel, or NULL if none */ + extern char *ppp_dev_name(struct ppp_channel *); + ++/* Call this to obtain the underlying protocol of the PPP channel, ++ * e.g. PX_PROTO_OE ++ */ ++extern int ppp_channel_get_protocol(struct ppp_channel *); ++ ++/* Call this get protocol version */ ++extern int ppp_channel_get_proto_version(struct ppp_channel *); ++ ++/* Call this to hold a channel */ ++extern bool ppp_channel_hold(struct ppp_channel *); ++ ++/* Call this to release a hold you have upon a channel */ ++extern void ppp_channel_release(struct ppp_channel *); ++ ++/* Release hold on PPP channels */ ++extern void ppp_release_channels(struct ppp_channel *channels[], ++ unsigned int chan_sz); ++ ++/* Hold PPP channels for the PPP device */ ++extern int ppp_hold_channels(struct net_device *dev, ++ struct ppp_channel *channels[], ++ unsigned int chan_sz); ++ ++/* Test if ppp xmit lock is locked */ ++extern bool ppp_is_xmit_locked(struct net_device *dev); ++ ++/* Test if the ppp device is a multi-link ppp device */ ++extern int ppp_is_multilink(struct net_device *dev); ++ ++/* Register the PPP channel connect notifier */ ++extern void ppp_channel_connection_register_notify(struct notifier_block *nb); ++ ++/* Unregister the PPP channel connect notifier */ ++extern void ppp_channel_connection_unregister_notify(struct notifier_block *nb); ++ ++/* Update statistics of the PPP net_device by incrementing related ++ * statistics field value with corresponding parameter ++ */ ++extern void ppp_update_stats(struct net_device *dev, unsigned long rx_packets, ++ unsigned long rx_bytes, unsigned long tx_packets, ++ unsigned long tx_bytes, unsigned long rx_errors, ++ unsigned long tx_errors, unsigned long rx_dropped, ++ unsigned long tx_dropped); ++ ++ + /* + * SMP locking notes: + * The channel code must ensure that when it calls ppp_unregister_channel, diff --git a/lede/target/linux/qualcommax/patches-6.1/0600-3-qca-nss-ecm-support-net-bonding.patch b/lede/target/linux/qualcommax/patches-6.1/0600-3-qca-nss-ecm-support-net-bonding.patch new file mode 100644 index 0000000000..508ad0ff58 --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0600-3-qca-nss-ecm-support-net-bonding.patch @@ -0,0 +1,81 @@ +--- a/drivers/net/bonding/bond_main.c ++++ b/drivers/net/bonding/bond_main.c +@@ -252,6 +252,8 @@ static const struct flow_dissector_key f + }, + }; + ++static unsigned long bond_id_mask = 0xFFFFFFF0; /* QCA NSS ECM bonding support */ ++ + static struct flow_dissector flow_keys_bonding __read_mostly; + + /*-------------------------- Forward declarations ---------------------------*/ +@@ -4383,6 +4385,24 @@ static int bond_get_lowest_level_rcu(str + } + #endif + ++/* QCA NSS ECM bonding support */ ++int bond_get_id(struct net_device *bond_dev) ++{ ++ struct bonding *bond; ++ int bond_id = 0; ++ ++ if (!((bond_dev->priv_flags & IFF_BONDING) && ++ (bond_dev->flags & IFF_MASTER))) ++ return -EINVAL; ++ ++ bond = netdev_priv(bond_dev); ++ bond_id = bond->id; ++ ++ return bond_id; ++} ++EXPORT_SYMBOL(bond_get_id); ++/* QCA NSS ECM bonding support */ ++ + static void bond_get_stats(struct net_device *bond_dev, + struct rtnl_link_stats64 *stats) + { +@@ -5795,6 +5815,11 @@ static void bond_destructor(struct net_d + + if (bond->rr_tx_counter) + free_percpu(bond->rr_tx_counter); ++ ++ /* QCA NSS ECM bonding support */ ++ if (bond->id != (~0U)) ++ clear_bit(bond->id, &bond_id_mask); ++ /* QCA NSS ECM bonding support */ + } + + void bond_setup(struct net_device *bond_dev) +@@ -6358,6 +6383,14 @@ int bond_create(struct net *net, const c + + bond_work_init_all(bond); + ++ /* QCA NSS ECM bonding support - Start */ ++ bond->id = ~0U; ++ if (bond_id_mask != (~0UL)) { ++ bond->id = (u32)ffz(bond_id_mask); ++ set_bit(bond->id, &bond_id_mask); ++ } ++ /* QCA NSS ECM bonding support - End */ ++ + out: + rtnl_unlock(); + return res; +--- a/include/net/bonding.h ++++ b/include/net/bonding.h +@@ -265,6 +265,7 @@ struct bonding { + spinlock_t ipsec_lock; + #endif /* CONFIG_XFRM_OFFLOAD */ + struct bpf_prog *xdp_prog; ++ u32 id; /* QCA NSS ECM bonding support */ + }; + + #define bond_slave_get_rcu(dev) \ +@@ -658,6 +659,7 @@ struct bond_net { + + int bond_rcv_validate(const struct sk_buff *skb, struct bonding *bond, struct slave *slave); + netdev_tx_t bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); ++int bond_get_id(struct net_device *bond_dev); /* QCA NSS ECM bonding support */ + int bond_create(struct net *net, const char *name); + int bond_create_sysfs(struct bond_net *net); + void bond_destroy_sysfs(struct bond_net *net); diff --git a/lede/target/linux/qualcommax/patches-6.1/0600-4-qca-nss-ecm-support-net-bonding-over-LAG-interface.patch b/lede/target/linux/qualcommax/patches-6.1/0600-4-qca-nss-ecm-support-net-bonding-over-LAG-interface.patch new file mode 100644 index 0000000000..27d55711fa --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0600-4-qca-nss-ecm-support-net-bonding-over-LAG-interface.patch @@ -0,0 +1,672 @@ +--- a/drivers/net/bonding/bond_3ad.c ++++ b/drivers/net/bonding/bond_3ad.c +@@ -114,7 +114,40 @@ static void ad_marker_info_received(stru + static void ad_marker_response_received(struct bond_marker *marker, + struct port *port); + static void ad_update_actor_keys(struct port *port, bool reset); ++/* QCA NSS ECM bonding support - Start */ ++struct bond_cb __rcu *bond_cb; + ++int bond_register_cb(struct bond_cb *cb) ++{ ++ struct bond_cb *lag_cb; ++ ++ lag_cb = kzalloc(sizeof(*lag_cb), GFP_ATOMIC | __GFP_NOWARN); ++ if (!lag_cb) { ++ return -1; ++ } ++ ++ memcpy((void *)lag_cb, (void *)cb, sizeof(*cb)); ++ ++ rcu_read_lock(); ++ rcu_assign_pointer(bond_cb, lag_cb); ++ rcu_read_unlock(); ++ return 0; ++} ++EXPORT_SYMBOL(bond_register_cb); ++ ++void bond_unregister_cb(void) ++{ ++ struct bond_cb *lag_cb_main; ++ ++ rcu_read_lock(); ++ lag_cb_main = rcu_dereference(bond_cb); ++ rcu_assign_pointer(bond_cb, NULL); ++ rcu_read_unlock(); ++ ++ kfree(lag_cb_main); ++} ++EXPORT_SYMBOL(bond_unregister_cb); ++/* QCA NSS ECM bonding support - End */ + + /* ================= api to bonding and kernel code ================== */ + +@@ -424,7 +457,6 @@ static u16 __ad_timer_to_ticks(u16 timer + return retval; + } + +- + /* ================= ad_rx_machine helper functions ================== */ + + /** +@@ -1064,7 +1096,30 @@ static void ad_mux_machine(struct port * + ad_disable_collecting_distributing(port, + update_slave_arr); + port->ntt = true; +- break; ++ ++ /* QCA NSS ECM bonding support - Start */ ++ /* Send a notificaton about change in state of this ++ * port. We only want to handle case where port moves ++ * from AD_MUX_COLLECTING_DISTRIBUTING -> ++ * AD_MUX_ATTACHED. ++ */ ++ if (bond_slave_is_up(port->slave) && ++ (last_state == AD_MUX_COLLECTING_DISTRIBUTING)) { ++ struct bond_cb *lag_cb_main; ++ ++ rcu_read_lock(); ++ lag_cb_main = rcu_dereference(bond_cb); ++ if (lag_cb_main && ++ lag_cb_main->bond_cb_link_down) { ++ struct net_device *dev; ++ ++ dev = port->slave->dev; ++ lag_cb_main->bond_cb_link_down(dev); ++ } ++ rcu_read_unlock(); ++ } ++ ++ break; /* QCA NSS ECM bonding support - End */ + case AD_MUX_COLLECTING_DISTRIBUTING: + port->actor_oper_port_state |= LACP_STATE_COLLECTING; + port->actor_oper_port_state |= LACP_STATE_DISTRIBUTING; +@@ -1908,13 +1963,24 @@ static void ad_enable_collecting_distrib + bool *update_slave_arr) + { + if (port->aggregator->is_active) { +- slave_dbg(port->slave->bond->dev, port->slave->dev, ++ struct bond_cb *lag_cb_main; /* QCA NSS ECM bonding support */ ++ slave_dbg(port->slave->bond->dev, port->slave->dev, + "Enabling port %d (LAG %d)\n", + port->actor_port_number, + port->aggregator->aggregator_identifier); + __enable_port(port); + /* Slave array needs update */ + *update_slave_arr = true; ++ ++ /* QCA NSS ECM bonding support - Start */ ++ rcu_read_lock(); ++ lag_cb_main = rcu_dereference(bond_cb); ++ ++ if (lag_cb_main && lag_cb_main->bond_cb_link_up) ++ lag_cb_main->bond_cb_link_up(port->slave->dev); ++ ++ rcu_read_unlock(); ++ /* QCA NSS ECM bonding support - End */ + } + } + +@@ -2674,6 +2740,104 @@ int bond_3ad_get_active_agg_info(struct + return ret; + } + ++/* QCA NSS ECM bonding support - Start */ ++/* bond_3ad_get_tx_dev - Calculate egress interface for a given packet, ++ * for a LAG that is configured in 802.3AD mode ++ * @skb: pointer to skb to be egressed ++ * @src_mac: pointer to source L2 address ++ * @dst_mac: pointer to destination L2 address ++ * @src: pointer to source L3 address ++ * @dst: pointer to destination L3 address ++ * @protocol: L3 protocol id from L2 header ++ * @bond_dev: pointer to bond master device ++ * ++ * If @skb is NULL, bond_xmit_hash is used to calculate hash using L2/L3 ++ * addresses. ++ * ++ * Returns: Either valid slave device, or NULL otherwise ++ */ ++struct net_device *bond_3ad_get_tx_dev(struct sk_buff *skb, u8 *src_mac, ++ u8 *dst_mac, void *src, ++ void *dst, u16 protocol, ++ struct net_device *bond_dev, ++ __be16 *layer4hdr) ++{ ++ struct bonding *bond = netdev_priv(bond_dev); ++ struct aggregator *agg; ++ struct ad_info ad_info; ++ struct list_head *iter; ++ struct slave *slave; ++ struct slave *first_ok_slave = NULL; ++ u32 hash = 0; ++ int slaves_in_agg; ++ int slave_agg_no = 0; ++ int agg_id; ++ ++ if (__bond_3ad_get_active_agg_info(bond, &ad_info)) { ++ pr_debug("%s: Error: __bond_3ad_get_active_agg_info failed\n", ++ bond_dev->name); ++ return NULL; ++ } ++ ++ slaves_in_agg = ad_info.ports; ++ agg_id = ad_info.aggregator_id; ++ ++ if (slaves_in_agg == 0) { ++ pr_debug("%s: Error: active aggregator is empty\n", ++ bond_dev->name); ++ return NULL; ++ } ++ ++ if (skb) { ++ hash = bond_xmit_hash(bond, skb); ++ slave_agg_no = hash % slaves_in_agg; ++ } else { ++ if (bond->params.xmit_policy != BOND_XMIT_POLICY_LAYER23 && ++ bond->params.xmit_policy != BOND_XMIT_POLICY_LAYER2 && ++ bond->params.xmit_policy != BOND_XMIT_POLICY_LAYER34) { ++ pr_debug("%s: Error: Unsupported hash policy for 802.3AD fast path\n", ++ bond_dev->name); ++ return NULL; ++ } ++ ++ hash = bond_xmit_hash_without_skb(src_mac, dst_mac, ++ src, dst, protocol, ++ bond_dev, layer4hdr); ++ slave_agg_no = hash % slaves_in_agg; ++ } ++ ++ bond_for_each_slave_rcu(bond, slave, iter) { ++ agg = SLAVE_AD_INFO(slave)->port.aggregator; ++ if (!agg || agg->aggregator_identifier != agg_id) ++ continue; ++ ++ if (slave_agg_no >= 0) { ++ if (!first_ok_slave && bond_slave_can_tx(slave)) ++ first_ok_slave = slave; ++ slave_agg_no--; ++ continue; ++ } ++ ++ if (bond_slave_can_tx(slave)) ++ return slave->dev; ++ } ++ ++ if (slave_agg_no >= 0) { ++ pr_err("%s: Error: Couldn't find a slave to tx on for aggregator ID %d\n", ++ bond_dev->name, agg_id); ++ return NULL; ++ } ++ ++ /* we couldn't find any suitable slave after the agg_no, so use the ++ * first suitable found, if found. ++ */ ++ if (first_ok_slave) ++ return first_ok_slave->dev; ++ ++ return NULL; ++} ++/* QCA NSS ECM bonding support - End */ ++ + int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond, + struct slave *slave) + { +--- a/drivers/net/bonding/bond_main.c ++++ b/drivers/net/bonding/bond_main.c +@@ -1186,6 +1186,23 @@ void bond_change_active_slave(struct bon + if (BOND_MODE(bond) == BOND_MODE_8023AD) + bond_3ad_handle_link_change(new_active, BOND_LINK_UP); + ++ /* QCA NSS ECM bonding support - Start */ ++ if (bond->params.mode == BOND_MODE_XOR) { ++ struct bond_cb *lag_cb_main; ++ ++ rcu_read_lock(); ++ lag_cb_main = rcu_dereference(bond_cb); ++ if (lag_cb_main && ++ lag_cb_main->bond_cb_link_up) { ++ struct net_device *dev; ++ ++ dev = new_active->dev; ++ lag_cb_main->bond_cb_link_up(dev); ++ } ++ rcu_read_unlock(); ++ } ++ /* QCA NSS ECM bonding support - End */ ++ + if (bond_is_lb(bond)) + bond_alb_handle_link_change(bond, new_active, BOND_LINK_UP); + } else { +@@ -1809,7 +1826,8 @@ int bond_enslave(struct net_device *bond + const struct net_device_ops *slave_ops = slave_dev->netdev_ops; + struct slave *new_slave = NULL, *prev_slave; + struct sockaddr_storage ss; +- int link_reporting; ++ struct bond_cb *lag_cb_main; /* QCA NSS ECM bonding support */ ++ int link_reporting; + int res = 0, i; + + if (slave_dev->flags & IFF_MASTER && +@@ -2252,6 +2270,15 @@ int bond_enslave(struct net_device *bond + bond_is_active_slave(new_slave) ? "an active" : "a backup", + new_slave->link != BOND_LINK_DOWN ? "an up" : "a down"); + ++ /* QCA NSS ECM bonding support - Start */ ++ rcu_read_lock(); ++ lag_cb_main = rcu_dereference(bond_cb); ++ if (lag_cb_main && lag_cb_main->bond_cb_enslave) ++ lag_cb_main->bond_cb_enslave(slave_dev); ++ ++ rcu_read_unlock(); ++ /* QCA NSS ECM bonding support - End */ ++ + /* enslave is successful */ + bond_queue_slave_event(new_slave); + return 0; +@@ -2317,6 +2344,15 @@ err_undo_flags: + } + } + ++ /* QCA NSS ECM bonding support - Start */ ++ rcu_read_lock(); ++ lag_cb_main = rcu_dereference(bond_cb); ++ if (lag_cb_main && lag_cb_main->bond_cb_enslave) ++ lag_cb_main->bond_cb_enslave(slave_dev); ++ ++ rcu_read_unlock(); ++ /* QCA NSS ECM bonding support - End */ ++ + return res; + } + +@@ -2339,7 +2375,8 @@ static int __bond_release_one(struct net + struct slave *slave, *oldcurrent; + struct sockaddr_storage ss; + int old_flags = bond_dev->flags; +- netdev_features_t old_features = bond_dev->features; ++ struct bond_cb *lag_cb_main; /* QCA NSS ECM bonding support */ ++ netdev_features_t old_features = bond_dev->features; + + /* slave is not a slave or master is not master of this slave */ + if (!(slave_dev->flags & IFF_SLAVE) || +@@ -2360,6 +2397,15 @@ static int __bond_release_one(struct net + + bond_set_slave_inactive_flags(slave, BOND_SLAVE_NOTIFY_NOW); + ++ /* QCA NSS ECM bonding support - Start */ ++ rcu_read_lock(); ++ lag_cb_main = rcu_dereference(bond_cb); ++ if (lag_cb_main && lag_cb_main->bond_cb_release) ++ lag_cb_main->bond_cb_release(slave_dev); ++ ++ rcu_read_unlock(); ++ /* QCA NSS ECM bonding support - End */ ++ + bond_sysfs_slave_del(slave); + + /* recompute stats just before removing the slave */ +@@ -2679,6 +2725,8 @@ static void bond_miimon_commit(struct bo + struct slave *slave, *primary, *active; + bool do_failover = false; + struct list_head *iter; ++ struct net_device *slave_dev = NULL; /* QCA NSS ECM bonding support */ ++ struct bond_cb *lag_cb_main; /* QCA NSS ECM bonding support */ + + ASSERT_RTNL(); + +@@ -2718,6 +2766,12 @@ static void bond_miimon_commit(struct bo + bond_set_active_slave(slave); + } + ++ /* QCA NSS ECM bonding support - Start */ ++ if ((bond->params.mode == BOND_MODE_XOR) && ++ (!slave_dev)) ++ slave_dev = slave->dev; ++ /* QCA NSS ECM bonding support - End */ ++ + slave_info(bond->dev, slave->dev, "link status definitely up, %u Mbps %s duplex\n", + slave->speed == SPEED_UNKNOWN ? 0 : slave->speed, + slave->duplex ? "full" : "half"); +@@ -2766,6 +2820,16 @@ static void bond_miimon_commit(struct bo + unblock_netpoll_tx(); + } + ++ /* QCA NSS ECM bonding support - Start */ ++ rcu_read_lock(); ++ lag_cb_main = rcu_dereference(bond_cb); ++ ++ if (slave_dev && lag_cb_main && lag_cb_main->bond_cb_link_up) ++ lag_cb_main->bond_cb_link_up(slave_dev); ++ ++ rcu_read_unlock(); ++ /* QCA NSS ECM bonding support - End */ ++ + bond_set_carrier(bond); + } + +@@ -4013,8 +4077,219 @@ static inline u32 bond_eth_hash(struct s + return 0; + + ep = (struct ethhdr *)(data + mhoff); +- return ep->h_dest[5] ^ ep->h_source[5] ^ be16_to_cpu(ep->h_proto); ++ return ep->h_dest[5] ^ ep->h_source[5]; /* QCA NSS ECM bonding support */ ++} ++ ++/* QCA NSS ECM bonding support - Start */ ++/* Extract the appropriate headers based on bond's xmit policy */ ++static bool bond_flow_dissect_without_skb(struct bonding *bond, ++ u8 *src_mac, u8 *dst_mac, ++ void *psrc, void *pdst, ++ u16 protocol, __be16 *layer4hdr, ++ struct flow_keys *fk) ++{ ++ u32 *src = NULL; ++ u32 *dst = NULL; ++ ++ fk->ports.ports = 0; ++ src = (uint32_t *)psrc; ++ dst = (uint32_t *)pdst; ++ ++ if (protocol == htons(ETH_P_IP)) { ++ /* V4 addresses and address type*/ ++ fk->addrs.v4addrs.src = src[0]; ++ fk->addrs.v4addrs.dst = dst[0]; ++ fk->control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS; ++ } else if (protocol == htons(ETH_P_IPV6)) { ++ /* V6 addresses and address type*/ ++ memcpy(&fk->addrs.v6addrs.src, src, sizeof(struct in6_addr)); ++ memcpy(&fk->addrs.v6addrs.dst, dst, sizeof(struct in6_addr)); ++ fk->control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS; ++ } else { ++ return false; ++ } ++ if ((bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER34) && ++ (layer4hdr)) ++ fk->ports.ports = *layer4hdr; ++ ++ return true; ++} ++ ++/* bond_xmit_hash_without_skb - Applies load balancing algorithm for a packet, ++ * to calculate hash for a given set of L2/L3 addresses. Does not ++ * calculate egress interface. ++ */ ++uint32_t bond_xmit_hash_without_skb(u8 *src_mac, u8 *dst_mac, ++ void *psrc, void *pdst, u16 protocol, ++ struct net_device *bond_dev, ++ __be16 *layer4hdr) ++{ ++ struct bonding *bond = netdev_priv(bond_dev); ++ struct flow_keys flow; ++ u32 hash = 0; ++ ++ if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER2 || ++ !bond_flow_dissect_without_skb(bond, src_mac, dst_mac, psrc, ++ pdst, protocol, layer4hdr, &flow)) ++ return (dst_mac[5] ^ src_mac[5]); ++ ++ if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER23) ++ hash = dst_mac[5] ^ src_mac[5]; ++ else if (layer4hdr) ++ hash = (__force u32)flow.ports.ports; ++ ++ hash ^= (__force u32)flow_get_u32_dst(&flow) ^ ++ (__force u32)flow_get_u32_src(&flow); ++ hash ^= (hash >> 16); ++ hash ^= (hash >> 8); ++ ++ return hash; ++} ++ ++/* bond_xor_get_tx_dev - Calculate egress interface for a given packet for a LAG ++ * that is configured in balance-xor mode ++ * @skb: pointer to skb to be egressed ++ * @src_mac: pointer to source L2 address ++ * @dst_mac: pointer to destination L2 address ++ * @src: pointer to source L3 address in network order ++ * @dst: pointer to destination L3 address in network order ++ * @protocol: L3 protocol ++ * @bond_dev: pointer to bond master device ++ * ++ * If @skb is NULL, bond_xmit_hash_without_skb is used to calculate hash using ++ * L2/L3 addresses. ++ * ++ * Returns: Either valid slave device, or NULL otherwise ++ */ ++static struct net_device *bond_xor_get_tx_dev(struct sk_buff *skb, ++ u8 *src_mac, u8 *dst_mac, ++ void *src, void *dst, ++ u16 protocol, ++ struct net_device *bond_dev, ++ __be16 *layer4hdr) ++{ ++ struct bonding *bond = netdev_priv(bond_dev); ++ int slave_cnt = READ_ONCE(bond->slave_cnt); ++ int slave_id = 0, i = 0; ++ u32 hash; ++ struct list_head *iter; ++ struct slave *slave; ++ ++ if (slave_cnt == 0) { ++ pr_debug("%s: Error: No slave is attached to the interface\n", ++ bond_dev->name); ++ return NULL; ++ } ++ ++ if (skb) { ++ hash = bond_xmit_hash(bond, skb); ++ slave_id = hash % slave_cnt; ++ } else { ++ if (bond->params.xmit_policy != BOND_XMIT_POLICY_LAYER23 && ++ bond->params.xmit_policy != BOND_XMIT_POLICY_LAYER2 && ++ bond->params.xmit_policy != BOND_XMIT_POLICY_LAYER34) { ++ pr_debug("%s: Error: Unsupported hash policy for balance-XOR fast path\n", ++ bond_dev->name); ++ return NULL; ++ } ++ ++ hash = bond_xmit_hash_without_skb(src_mac, dst_mac, src, ++ dst, protocol, bond_dev, ++ layer4hdr); ++ slave_id = hash % slave_cnt; ++ } ++ ++ i = slave_id; ++ ++ /* Here we start from the slave with slave_id */ ++ bond_for_each_slave_rcu(bond, slave, iter) { ++ if (--i < 0) { ++ if (bond_slave_can_tx(slave)) ++ return slave->dev; ++ } ++ } ++ ++ /* Here we start from the first slave up to slave_id */ ++ i = slave_id; ++ bond_for_each_slave_rcu(bond, slave, iter) { ++ if (--i < 0) ++ break; ++ if (bond_slave_can_tx(slave)) ++ return slave->dev; ++ } ++ ++ return NULL; ++} ++ ++/* bond_get_tx_dev - Calculate egress interface for a given packet. ++ * ++ * Supports 802.3AD and balance-xor modes ++ * ++ * @skb: pointer to skb to be egressed, if valid ++ * @src_mac: pointer to source L2 address ++ * @dst_mac: pointer to destination L2 address ++ * @src: pointer to source L3 address in network order ++ * @dst: pointer to destination L3 address in network order ++ * @protocol: L3 protocol id from L2 header ++ * @bond_dev: pointer to bond master device ++ * ++ * Returns: Either valid slave device, or NULL for un-supported LAG modes ++ */ ++struct net_device *bond_get_tx_dev(struct sk_buff *skb, uint8_t *src_mac, ++ u8 *dst_mac, void *src, ++ void *dst, u16 protocol, ++ struct net_device *bond_dev, ++ __be16 *layer4hdr) ++{ ++ struct bonding *bond; ++ ++ if (!bond_dev) ++ return NULL; ++ ++ if (!((bond_dev->priv_flags & IFF_BONDING) && ++ (bond_dev->flags & IFF_MASTER))) ++ return NULL; ++ ++ bond = netdev_priv(bond_dev); ++ ++ switch (bond->params.mode) { ++ case BOND_MODE_XOR: ++ return bond_xor_get_tx_dev(skb, src_mac, dst_mac, ++ src, dst, protocol, ++ bond_dev, layer4hdr); ++ case BOND_MODE_8023AD: ++ return bond_3ad_get_tx_dev(skb, src_mac, dst_mac, ++ src, dst, protocol, ++ bond_dev, layer4hdr); ++ default: ++ return NULL; ++ } + } ++EXPORT_SYMBOL(bond_get_tx_dev); ++ ++/* In bond_xmit_xor() , we determine the output device by using a pre- ++ * determined xmit_hash_policy(), If the selected device is not enabled, ++ * find the next active slave. ++ */ ++static int bond_xmit_xor(struct sk_buff *skb, struct net_device *dev) ++{ ++ struct bonding *bond = netdev_priv(dev); ++ struct net_device *outdev; ++ ++ outdev = bond_xor_get_tx_dev(skb, NULL, NULL, NULL, ++ NULL, 0, dev, NULL); ++ if (!outdev) ++ goto out; ++ ++ bond_dev_queue_xmit(bond, skb, outdev); ++ goto final; ++out: ++ /* no suitable interface, frame not sent */ ++ dev_kfree_skb(skb); ++final: ++ return NETDEV_TX_OK; ++} ++/* QCA NSS ECM bonding support - End */ + + static bool bond_flow_ip(struct sk_buff *skb, struct flow_keys *fk, const void *data, + int hlen, __be16 l2_proto, int *nhoff, int *ip_proto, bool l34) +@@ -5211,15 +5486,23 @@ static netdev_tx_t bond_3ad_xor_xmit(str + struct net_device *dev) + { + struct bonding *bond = netdev_priv(dev); +- struct bond_up_slave *slaves; +- struct slave *slave; ++ /* QCA NSS ECM bonding support - Start */ ++ struct net_device *outdev = NULL; ++ outdev = bond_3ad_get_tx_dev(skb, NULL, NULL, NULL, ++ NULL, 0, dev, NULL); + +- slaves = rcu_dereference(bond->usable_slaves); +- slave = bond_xmit_3ad_xor_slave_get(bond, skb, slaves); +- if (likely(slave)) +- return bond_dev_queue_xmit(bond, skb, slave->dev); ++ if (!outdev) ++ goto out; + +- return bond_tx_drop(dev, skb); ++ bond_dev_queue_xmit(bond, skb, outdev); ++ goto final; ++ ++out: ++ dev_kfree_skb(skb); ++ ++final: ++ return NETDEV_TX_OK; ++/* QCA NSS ECM bonding support - End */ + } + + /* in broadcast mode, we send everything to all usable interfaces. */ +@@ -5469,8 +5752,9 @@ static netdev_tx_t __bond_start_xmit(str + return bond_xmit_roundrobin(skb, dev); + case BOND_MODE_ACTIVEBACKUP: + return bond_xmit_activebackup(skb, dev); +- case BOND_MODE_8023AD: + case BOND_MODE_XOR: ++ return bond_xmit_xor(skb, dev); /* QCA NSS ECM bonding support */ ++ case BOND_MODE_8023AD: + return bond_3ad_xor_xmit(skb, dev); + case BOND_MODE_BROADCAST: + return bond_xmit_broadcast(skb, dev); +--- a/include/net/bond_3ad.h ++++ b/include/net/bond_3ad.h +@@ -303,8 +303,15 @@ int bond_3ad_lacpdu_recv(const struct sk + int bond_3ad_set_carrier(struct bonding *bond); + void bond_3ad_update_lacp_active(struct bonding *bond); + void bond_3ad_update_lacp_rate(struct bonding *bond); ++/* QCA NSS ECM bonding support */ ++struct net_device *bond_3ad_get_tx_dev(struct sk_buff *skb, uint8_t *src_mac, ++ uint8_t *dst_mac, void *src, ++ void *dst, uint16_t protocol, ++ struct net_device *bond_dev, ++ __be16 *layer4hdr); ++/* QCA NSS ECM bonding support */ ++ + void bond_3ad_update_ad_actor_settings(struct bonding *bond); + int bond_3ad_stats_fill(struct sk_buff *skb, struct bond_3ad_stats *stats); + size_t bond_3ad_stats_size(void); + #endif /* _NET_BOND_3AD_H */ +- +--- a/include/net/bonding.h ++++ b/include/net/bonding.h +@@ -85,6 +85,8 @@ + #define bond_for_each_slave(bond, pos, iter) \ + netdev_for_each_lower_private((bond)->dev, pos, iter) + ++extern struct bond_cb __rcu *bond_cb; /* QCA NSS ECM bonding support */ ++ + /* Caller must have rcu_read_lock */ + #define bond_for_each_slave_rcu(bond, pos, iter) \ + netdev_for_each_lower_private_rcu((bond)->dev, pos, iter) +@@ -690,6 +692,12 @@ struct bond_vlan_tag *bond_verify_device + int level); + int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave); + void bond_slave_arr_work_rearm(struct bonding *bond, unsigned long delay); ++/* QCA NSS ECM bonding support - Start */ ++uint32_t bond_xmit_hash_without_skb(uint8_t *src_mac, uint8_t *dst_mac, ++ void *psrc, void *pdst, uint16_t protocol, ++ struct net_device *bond_dev, ++ __be16 *layer4hdr); ++/* QCA NSS ECM bonding support - End */ + void bond_work_init_all(struct bonding *bond); + + #ifdef CONFIG_PROC_FS +@@ -794,4 +802,18 @@ static inline netdev_tx_t bond_tx_drop(s + return NET_XMIT_DROP; + } + ++/* QCA NSS ECM bonding support - Start */ ++struct bond_cb { ++ void (*bond_cb_link_up)(struct net_device *slave); ++ void (*bond_cb_link_down)(struct net_device *slave); ++ void (*bond_cb_enslave)(struct net_device *slave); ++ void (*bond_cb_release)(struct net_device *slave); ++ void (*bond_cb_delete_by_slave)(struct net_device *slave); ++ void (*bond_cb_delete_by_mac)(uint8_t *mac_addr); ++}; ++ ++extern int bond_register_cb(struct bond_cb *cb); ++extern void bond_unregister_cb(void); ++/* QCA NSS ECM bonding support - End */ ++ + #endif /* _NET_BONDING_H */ diff --git a/lede/target/linux/qualcommax/patches-6.1/0600-5-qca-nss-ecm-support-macvlan.patch b/lede/target/linux/qualcommax/patches-6.1/0600-5-qca-nss-ecm-support-macvlan.patch new file mode 100644 index 0000000000..5f18c6be73 --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0600-5-qca-nss-ecm-support-macvlan.patch @@ -0,0 +1,96 @@ +--- a/include/linux/if_macvlan.h ++++ b/include/linux/if_macvlan.h +@@ -15,6 +15,13 @@ struct macvlan_port; + #define MACVLAN_MC_FILTER_BITS 8 + #define MACVLAN_MC_FILTER_SZ (1 << MACVLAN_MC_FILTER_BITS) + ++/* QCA NSS ECM Support - Start */ ++/* ++ * Callback for updating interface statistics for macvlan flows offloaded from host CPU. ++ */ ++typedef void (*macvlan_offload_stats_update_cb_t)(struct net_device *dev, struct rtnl_link_stats64 *stats, bool update_mcast_rx_stats); ++/* QCA NSS ECM Support - End */ ++ + struct macvlan_dev { + struct net_device *dev; + struct list_head list; +@@ -35,6 +42,7 @@ struct macvlan_dev { + #ifdef CONFIG_NET_POLL_CONTROLLER + struct netpoll *netpoll; + #endif ++ macvlan_offload_stats_update_cb_t offload_stats_update; /* QCA NSS ECM support */ + }; + + static inline void macvlan_count_rx(const struct macvlan_dev *vlan, +@@ -107,4 +115,26 @@ static inline int macvlan_release_l2fw_o + macvlan->accel_priv = NULL; + return dev_uc_add(macvlan->lowerdev, dev->dev_addr); + } ++ ++/* QCA NSS ECM Support - Start */ ++#if IS_ENABLED(CONFIG_MACVLAN) ++static inline void ++macvlan_offload_stats_update(struct net_device *dev, ++ struct rtnl_link_stats64 *stats, ++ bool update_mcast_rx_stats) ++{ ++ struct macvlan_dev *macvlan = netdev_priv(dev); ++ ++ macvlan->offload_stats_update(dev, stats, update_mcast_rx_stats); ++} ++ ++static inline enum ++macvlan_mode macvlan_get_mode(struct net_device *dev) ++{ ++ struct macvlan_dev *macvlan = netdev_priv(dev); ++ ++ return macvlan->mode; ++} ++#endif ++/* QCA NSS ECM Support - End */ + #endif /* _LINUX_IF_MACVLAN_H */ +--- a/drivers/net/macvlan.c ++++ b/drivers/net/macvlan.c +@@ -933,6 +933,34 @@ static void macvlan_uninit(struct net_de + macvlan_port_destroy(port->dev); + } + ++/* QCA NSS ECM Support - Start */ ++/* Update macvlan statistics processed by offload engines */ ++static void macvlan_dev_update_stats(struct net_device *dev, ++ struct rtnl_link_stats64 *offl_stats, ++ bool update_mcast_rx_stats) ++{ ++ struct vlan_pcpu_stats *stats; ++ struct macvlan_dev *macvlan; ++ ++ /* Is this a macvlan? */ ++ if (!netif_is_macvlan(dev)) ++ return; ++ ++ macvlan = netdev_priv(dev); ++ stats = this_cpu_ptr(macvlan->pcpu_stats); ++ u64_stats_update_begin(&stats->syncp); ++ u64_stats_add(&stats->rx_packets, offl_stats->rx_packets); ++ u64_stats_add(&stats->rx_bytes, offl_stats->rx_bytes); ++ u64_stats_add(&stats->tx_packets, offl_stats->tx_packets); ++ u64_stats_add(&stats->tx_bytes, offl_stats->tx_bytes); ++ /* Update multicast statistics */ ++ if (unlikely(update_mcast_rx_stats)) { ++ u64_stats_add(&stats->rx_multicast, offl_stats->rx_packets); ++ } ++ u64_stats_update_end(&stats->syncp); ++} ++/* QCA NSS ECM Support - End */ ++ + static void macvlan_dev_get_stats64(struct net_device *dev, + struct rtnl_link_stats64 *stats) + { +@@ -1477,6 +1505,7 @@ int macvlan_common_newlink(struct net *s + vlan->dev = dev; + vlan->port = port; + vlan->set_features = MACVLAN_FEATURES; ++ vlan->offload_stats_update = macvlan_dev_update_stats; /* QCA NSS ECM Support */ + + vlan->mode = MACVLAN_MODE_VEPA; + if (data && data[IFLA_MACVLAN_MODE]) diff --git a/lede/target/linux/qualcommax/patches-6.1/0600-6-qca-nss-ecm-support-netfilter-DSCPREMARK.patch b/lede/target/linux/qualcommax/patches-6.1/0600-6-qca-nss-ecm-support-netfilter-DSCPREMARK.patch new file mode 100644 index 0000000000..110b22606f --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0600-6-qca-nss-ecm-support-netfilter-DSCPREMARK.patch @@ -0,0 +1,69 @@ +--- a/net/netfilter/Kconfig ++++ b/net/netfilter/Kconfig +@@ -171,6 +171,13 @@ config NF_CONNTRACK_TIMEOUT + + If unsure, say `N'. + ++config NF_CONNTRACK_DSCPREMARK_EXT ++ bool 'Connection tracking extension for dscp remark target' ++ depends on NETFILTER_ADVANCED ++ help ++ This option enables support for connection tracking extension ++ for dscp remark. ++ + config NF_CONNTRACK_TIMESTAMP + bool 'Connection tracking timestamping' + depends on NETFILTER_ADVANCED +--- a/include/net/netfilter/nf_conntrack_extend.h ++++ b/include/net/netfilter/nf_conntrack_extend.h +@@ -31,6 +31,10 @@ enum nf_ct_ext_id { + #if IS_ENABLED(CONFIG_NET_ACT_CT) + NF_CT_EXT_ACT_CT, + #endif ++#ifdef CONFIG_NF_CONNTRACK_DSCPREMARK_EXT ++ NF_CT_EXT_DSCPREMARK, /* QCA NSS ECM support */ ++#endif ++ + NF_CT_EXT_NUM, + }; + +--- a/net/netfilter/nf_conntrack_extend.c ++++ b/net/netfilter/nf_conntrack_extend.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + #include + + #define NF_CT_EXT_PREALLOC 128u /* conntrack events are on by default */ +@@ -54,6 +55,9 @@ static const u8 nf_ct_ext_type_len[NF_CT + #if IS_ENABLED(CONFIG_NET_ACT_CT) + [NF_CT_EXT_ACT_CT] = sizeof(struct nf_conn_act_ct_ext), + #endif ++#ifdef CONFIG_NF_CONNTRACK_DSCPREMARK_EXT ++ [NF_CT_EXT_DSCPREMARK] = sizeof(struct nf_ct_dscpremark_ext), ++#endif + }; + + static __always_inline unsigned int total_extension_size(void) +@@ -86,6 +90,9 @@ static __always_inline unsigned int tota + #if IS_ENABLED(CONFIG_NET_ACT_CT) + + sizeof(struct nf_conn_act_ct_ext) + #endif ++#ifdef CONFIG_NF_CONNTRACK_DSCPREMARK_EXT ++ + sizeof(struct nf_ct_dscpremark_ext) ++#endif + ; + } + +--- a/net/netfilter/Makefile ++++ b/net/netfilter/Makefile +@@ -14,6 +14,7 @@ nf_conntrack-$(CONFIG_NF_CONNTRACK_LABEL + nf_conntrack-$(CONFIG_NF_CT_PROTO_DCCP) += nf_conntrack_proto_dccp.o + nf_conntrack-$(CONFIG_NF_CT_PROTO_SCTP) += nf_conntrack_proto_sctp.o + nf_conntrack-$(CONFIG_NF_CT_PROTO_GRE) += nf_conntrack_proto_gre.o ++nf_conntrack-$(CONFIG_NF_CONNTRACK_DSCPREMARK_EXT) += nf_conntrack_dscpremark_ext.o + ifeq ($(CONFIG_NF_CONNTRACK),m) + nf_conntrack-$(CONFIG_DEBUG_INFO_BTF_MODULES) += nf_conntrack_bpf.o + else ifeq ($(CONFIG_NF_CONNTRACK),y) diff --git a/lede/target/linux/qualcommax/patches-6.1/0600-7-qca-nss-ecm-add-missing-net-defines.patch b/lede/target/linux/qualcommax/patches-6.1/0600-7-qca-nss-ecm-add-missing-net-defines.patch new file mode 100644 index 0000000000..0ffe0073a5 --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0600-7-qca-nss-ecm-add-missing-net-defines.patch @@ -0,0 +1,35 @@ +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -1724,7 +1724,9 @@ enum netdev_priv_flags_ext { + IFF_EXT_PPP_PPTP = 1<<3, + IFF_EXT_GRE_V4_TAP = 1<<4, + IFF_EXT_GRE_V6_TAP = 1<<5, +- IFF_EXT_IFB = 1<<6, ++ IFF_EXT_IFB = 1<<6, ++ IFF_EXT_MAPT = 1<<7, ++ IFF_EXT_HW_NO_OFFLOAD = 1<<8, + }; + + #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN +--- a/include/uapi/linux/in.h ++++ b/include/uapi/linux/in.h +@@ -63,6 +63,8 @@ enum { + #define IPPROTO_MTP IPPROTO_MTP + IPPROTO_BEETPH = 94, /* IP option pseudo header for BEET */ + #define IPPROTO_BEETPH IPPROTO_BEETPH ++ IPPROTO_ETHERIP = 97, /* ETHERIP protocol number */ ++#define IPPROTO_ETHERIP IPPROTO_ETHERIP + IPPROTO_ENCAP = 98, /* Encapsulation Header */ + #define IPPROTO_ENCAP IPPROTO_ENCAP + IPPROTO_PIM = 103, /* Protocol Independent Multicast */ +--- a/tools/include/uapi/linux/in.h ++++ b/tools/include/uapi/linux/in.h +@@ -63,6 +63,8 @@ enum { + #define IPPROTO_MTP IPPROTO_MTP + IPPROTO_BEETPH = 94, /* IP option pseudo header for BEET */ + #define IPPROTO_BEETPH IPPROTO_BEETPH ++ IPPROTO_ETHERIP = 97, /* ETHERIP protocol number */ ++#define IPPROTO_ETHERIP IPPROTO_ETHERIP + IPPROTO_ENCAP = 98, /* Encapsulation Header */ + #define IPPROTO_ENCAP IPPROTO_ENCAP + IPPROTO_PIM = 103, /* Protocol Independent Multicast */ diff --git a/lede/target/linux/qualcommax/patches-6.1/0600-8-qca-nss-ecm-support-MLO-bonding.patch b/lede/target/linux/qualcommax/patches-6.1/0600-8-qca-nss-ecm-support-MLO-bonding.patch new file mode 100644 index 0000000000..7e64e5941c --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0600-8-qca-nss-ecm-support-MLO-bonding.patch @@ -0,0 +1,536 @@ +From 0403eceee14bb6eb4e417102cae830b7509b1554 Mon Sep 17 00:00:00 2001 +From: Shivani Soni +Date: Thu, 17 Nov 2022 00:16:38 +0530 +Subject: [PATCH] arm/arm64: Add support for MLO bonding + +1. Introduced BOND_MODE_MLO to support MLO bonding +2. Transmit handling according to new mode + +Change-Id: Ib272e77cce56ee50b0a13305fac8fae76743c206 +Signed-off-by: Shivani Soni +--- + drivers/net/bonding/bond_main.c | 212 ++++++++++++++++++++++++----- + drivers/net/bonding/bond_options.c | 1 + + include/net/bonding.h | 30 +++- + include/uapi/linux/if_bonding.h | 1 + + 4 files changed, 210 insertions(+), 34 deletions(-) + +--- a/drivers/net/bonding/bond_main.c ++++ b/drivers/net/bonding/bond_main.c +@@ -1439,6 +1439,10 @@ static netdev_features_t bond_fix_featur + return features; + } + ++#define BOND_MLO_VLAN_FEATURES (NETIF_F_SG | \ ++ NETIF_F_FRAGLIST | \ ++ NETIF_F_HIGHDMA | NETIF_F_LRO) ++ + #define BOND_VLAN_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ + NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE | \ + NETIF_F_HIGHDMA | NETIF_F_LRO) +@@ -1469,13 +1473,25 @@ static void bond_compute_features(struct + + if (!bond_has_slaves(bond)) + goto done; ++ ++ /* ++ * Use features specific to bond MLO ++ */ ++ if (BOND_MODE(bond) == BOND_MODE_MLO) { ++ vlan_features = BOND_MLO_VLAN_FEATURES; ++ } ++ + vlan_features &= NETIF_F_ALL_FOR_ALL; + mpls_features &= NETIF_F_ALL_FOR_ALL; + + bond_for_each_slave(bond, slave, iter) { +- vlan_features = netdev_increment_features(vlan_features, +- slave->dev->vlan_features, BOND_VLAN_FEATURES); +- ++ if (BOND_MODE(bond) == BOND_MODE_MLO) { ++ vlan_features = netdev_increment_features(vlan_features, ++ slave->dev->vlan_features, BOND_MLO_VLAN_FEATURES); ++ } else { ++ vlan_features = netdev_increment_features(vlan_features, ++ slave->dev->vlan_features, BOND_VLAN_FEATURES); ++ } + enc_features = netdev_increment_features(enc_features, + slave->dev->hw_enc_features, + BOND_ENC_FEATURES); +@@ -1620,6 +1636,16 @@ static rx_handler_result_t bond_handle_f + bond->dev->addr_len); + } + ++ /* ++ * Set the PACKET_HOST for MLO mode as ++ * MLO bond netdevice needs to support routing ++ */ ++ if (BOND_MODE(bond) == BOND_MODE_MLO) { ++ if (ether_addr_equal(bond->dev->dev_addr, eth_hdr(skb)->h_dest)) { ++ skb->pkt_type = PACKET_HOST; ++ } ++ } ++ + return ret; + } + +@@ -1837,6 +1863,8 @@ int bond_enslave(struct net_device *bond + return -EPERM; + } + ++ ASSERT_RTNL(); ++ + if (!bond->params.use_carrier && + slave_dev->ethtool_ops->get_link == NULL && + slave_ops->ndo_eth_ioctl == NULL) { +@@ -1950,13 +1978,17 @@ int bond_enslave(struct net_device *bond + call_netdevice_notifiers(NETDEV_JOIN, slave_dev); + + /* If this is the first slave, then we need to set the master's hardware +- * address to be the same as the slave's. ++ * address to be the same as the slave's except for BOND_MODE_MLO. ++ * For BOND_MODE_MLO, master's mac address is MLD address which should ++ * not be same as slave's address. + */ +- if (!bond_has_slaves(bond) && +- bond->dev->addr_assign_type == NET_ADDR_RANDOM) { +- res = bond_set_dev_addr(bond->dev, slave_dev); +- if (res) +- goto err_undo_flags; ++ if (BOND_MODE(bond) != BOND_MODE_MLO) { ++ if (!bond_has_slaves(bond) && ++ bond->dev->addr_assign_type == NET_ADDR_RANDOM) { ++ res = bond_set_dev_addr(bond->dev, slave_dev); ++ if (res) ++ goto err_undo_flags; ++ } + } + + new_slave = bond_alloc_slave(bond, slave_dev); +@@ -1985,18 +2017,21 @@ int bond_enslave(struct net_device *bond + bond_hw_addr_copy(new_slave->perm_hwaddr, slave_dev->dev_addr, + slave_dev->addr_len); + +- if (!bond->params.fail_over_mac || +- BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { +- /* Set slave to master's mac address. The application already +- * set the master's mac address to that of the first slave +- */ +- memcpy(ss.__data, bond_dev->dev_addr, bond_dev->addr_len); +- ss.ss_family = slave_dev->type; +- res = dev_set_mac_address(slave_dev, (struct sockaddr *)&ss, +- extack); +- if (res) { +- slave_err(bond_dev, slave_dev, "Error %d calling set_mac_address\n", res); +- goto err_restore_mtu; ++ /* Set slave to master's mac address except for BOND_MODE_MLO ++ * as for MLO mode master's mac address is not same as slave's mac address. ++ * The application already set the master's mac address to that of the first slave ++ */ ++ if (BOND_MODE(bond) != BOND_MODE_MLO) { ++ if (!bond->params.fail_over_mac || ++ BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { ++ memcpy(ss.__data, bond_dev->dev_addr, bond_dev->addr_len); ++ ss.ss_family = slave_dev->type; ++ res = dev_set_mac_address(slave_dev, (struct sockaddr *)&ss, ++ extack); ++ if (res) { ++ slave_err(bond_dev, slave_dev, "Error %d calling set_mac_address\n", res); ++ goto err_restore_mtu; ++ } + } + } + +@@ -2355,6 +2390,7 @@ err_undo_flags: + + return res; + } ++EXPORT_SYMBOL(bond_enslave); + + /* Try to release the slave device from the bond device + * It is legal to access curr_active_slave without a lock because all the function +@@ -2476,13 +2512,23 @@ static int __bond_release_one(struct net + } + + bond_set_carrier(bond); +- if (!bond_has_slaves(bond)) +- eth_hw_addr_random(bond_dev); ++ ++ /* ++ * Avoid changing the mac address of bond netdevice for MLO case, ++ * This will only be supported from wifi driver. ++ */ ++ if (BOND_MODE(bond) != BOND_MODE_MLO) { ++ if (!bond_has_slaves(bond)) ++ eth_hw_addr_random(bond_dev); ++ } + + unblock_netpoll_tx(); + synchronize_rcu(); + bond->slave_cnt--; + ++ /* ++ * TODO: Avoid MAC address change notification for BOND_MODE_MLO ++ */ + if (!bond_has_slaves(bond)) { + call_netdevice_notifiers(NETDEV_CHANGEADDR, bond->dev); + call_netdevice_notifiers(NETDEV_RELEASE, bond->dev); +@@ -2549,6 +2595,7 @@ int bond_release(struct net_device *bond + { + return __bond_release_one(bond_dev, slave_dev, false, false); + } ++EXPORT_SYMBOL(bond_release); + + /* First release a slave and then destroy the bond if no more slaves are left. + * Must be under rtnl_lock when this function is called. +@@ -2570,6 +2617,29 @@ static int bond_release_and_destroy(stru + return ret; + } + ++/* Destroy the bond for BOND_MODE_MLO if no more slaves are left. ++ * Must be under rtnl_lock when this function is called. ++ */ ++bool bond_destroy_mlo(struct net_device *bond_dev) ++{ ++ struct bonding *bond = netdev_priv(bond_dev); ++ ++ ASSERT_RTNL(); ++ ++ if (!bond_has_slaves(bond)) { ++ bond_dev->priv_flags |= IFF_DISABLE_NETPOLL; ++ netdev_info(bond_dev, "Destroying bond as no slaves are present\n"); ++ bond_remove_proc_entry(bond); ++ unregister_netdevice(bond_dev); ++ return true; ++ } ++ ++ pr_err("%p: Not able to destroy bond netdevice: %s as slaves are present\n", bond_dev, bond_dev->name); ++ ++ return false; ++} ++EXPORT_SYMBOL(bond_destroy_mlo); ++ + static void bond_info_query(struct net_device *bond_dev, struct ifbond *info) + { + struct bonding *bond = netdev_priv(bond_dev); +@@ -4221,6 +4291,24 @@ static struct net_device *bond_xor_get_t + return NULL; + } + ++/* Transmit function for BOND_MODE_MLO. ++ * Get transmit link interface from registered callback. ++ */ ++struct net_device *bond_mlo_get_tx_dev(struct net_device *bond_dev, u8 *dst_mac) ++{ ++ struct net_device *slave_dev = NULL; ++ struct mlo_bond_info *mlo_info = NULL; ++ void *bond_mlo_ctx; ++ ++ mlo_info = bond_get_mlo_priv(bond_dev); ++ if (mlo_info->bond_get_mlo_tx_netdev) { ++ bond_mlo_ctx = bond_get_mlo_ctx(bond_dev); ++ slave_dev = mlo_info->bond_get_mlo_tx_netdev(bond_mlo_ctx, dst_mac); ++ } ++ ++ return slave_dev; ++} ++ + /* bond_get_tx_dev - Calculate egress interface for a given packet. + * + * Supports 802.3AD and balance-xor modes +@@ -4261,6 +4349,9 @@ struct net_device *bond_get_tx_dev(struc + return bond_3ad_get_tx_dev(skb, src_mac, dst_mac, + src, dst, protocol, + bond_dev, layer4hdr); ++ case BOND_MODE_MLO: ++ return bond_mlo_get_tx_dev(bond_dev, dst_mac); ++ + default: + return NULL; + } +@@ -5057,20 +5148,26 @@ static int bond_set_mac_address(struct n + if (!is_valid_ether_addr(ss->__data)) + return -EADDRNOTAVAIL; + +- bond_for_each_slave(bond, slave, iter) { +- slave_dbg(bond_dev, slave->dev, "%s: slave=%p\n", +- __func__, slave); +- res = dev_set_mac_address(slave->dev, addr, NULL); +- if (res) { +- /* TODO: consider downing the slave +- * and retry ? +- * User should expect communications +- * breakage anyway until ARP finish +- * updating, so... +- */ +- slave_dbg(bond_dev, slave->dev, "%s: err %d\n", +- __func__, res); +- goto unwind; ++ /* ++ * Do not allow mac address change for slave netdevice for BOND_MODE_MLO ++ * as master's mac address is not same as slave's mac address. ++ */ ++ if (BOND_MODE(bond) != BOND_MODE_MLO) { ++ bond_for_each_slave(bond, slave, iter) { ++ slave_dbg(bond_dev, slave->dev, "%s: slave=%p\n", ++ __func__, slave); ++ res = dev_set_mac_address(slave->dev, addr, NULL); ++ if (res) { ++ /* TODO: consider downing the slave ++ * and retry ? ++ * User should expect communications ++ * breakage anyway until ARP finish ++ * updating, so... ++ */ ++ slave_dbg(bond_dev, slave->dev, "%s: err %d\n", ++ __func__, res); ++ goto unwind; ++ } + } + } + +@@ -5734,6 +5831,27 @@ static netdev_tx_t bond_tls_device_xmit( + } + #endif + ++/* In bond_xmit_mlo(), we send the packet and bond netdevice ++ * to registered callback for final xmit. ++ */ ++static netdev_tx_t bond_xmit_mlo(struct sk_buff *skb, struct net_device *bond_dev) ++{ ++ struct bonding *bond = netdev_priv(bond_dev); ++ int slave_cnt, ret; ++ struct mlo_bond_info *mlo_info = bond_get_mlo_priv(bond_dev); ++ ++ slave_cnt = READ_ONCE(bond->slave_cnt); ++ if (unlikely(slave_cnt == 0) || unlikely(!mlo_info->bond_mlo_xmit_netdev)) { ++ bond_tx_drop(bond_dev, skb); ++ } else { ++ ret = mlo_info->bond_mlo_xmit_netdev(skb, bond_dev); ++ if (ret != NET_XMIT_SUCCESS) ++ netdev_err(bond_dev, "Xmit failed with mode %d %p\n", BOND_MODE(bond), skb); ++ } ++ ++ return NETDEV_TX_OK; ++} ++ + static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev) + { + struct bonding *bond = netdev_priv(dev); +@@ -5762,6 +5880,8 @@ static netdev_tx_t __bond_start_xmit(str + return bond_alb_xmit(skb, dev); + case BOND_MODE_TLB: + return bond_tlb_xmit(skb, dev); ++ case BOND_MODE_MLO: ++ return bond_xmit_mlo(skb, dev); + default: + /* Should never happen, mode already checked */ + netdev_err(dev, "Unknown bonding mode %d\n", BOND_MODE(bond)); +@@ -6104,6 +6224,15 @@ static void bond_destructor(struct net_d + if (bond->id != (~0U)) + clear_bit(bond->id, &bond_id_mask); + /* QCA NSS ECM bonding support */ ++ ++ /* ++ * Wifi driver registered callback to destroy wiphy for MLO bond netdevice ++ */ ++ if (bond_is_mlo_device(bond_dev)) { ++ if (bond->mlo_info.bond_mlo_netdev_priv_destructor) { ++ bond->mlo_info.bond_mlo_netdev_priv_destructor(bond_dev); ++ } ++ } + } + + void bond_setup(struct net_device *bond_dev) +@@ -6680,6 +6809,76 @@ out: + return res; + } + ++/* bond_create_mlo() ++ * Create bond netdevice for BOND_MODE_MLO with MLO specific callback and context. ++ */ ++struct net_device *bond_create_mlo(struct net *net, const char *name, struct mlo_bond_info *mlo_info) ++{ ++ struct net_device *bond_dev; ++ struct bonding *bond; ++ int res; ++ ++ ASSERT_RTNL(); ++ ++ bond_dev = alloc_netdev_mq(sizeof(struct bonding), ++ name ? name : "bond%d", NET_NAME_UNKNOWN, ++ bond_setup, tx_queues); ++ if (!bond_dev) { ++ pr_err("%s: eek! can't alloc netdev!\n", name); ++ return NULL; ++ } ++ ++ bond = netdev_priv(bond_dev); ++ ++ dev_net_set(bond_dev, net); ++ bond_dev->rtnl_link_ops = &bond_link_ops; ++ ++ /* ++ * MLO specific initialization. ++ */ ++ bond_dev->ieee80211_ptr = mlo_info->wdev; ++ bond->params.mode = BOND_MODE_MLO; ++ mlo_info->wdev->netdev = bond_dev; ++ ++ memcpy((void *)&bond->mlo_info, (void *)mlo_info, sizeof(*mlo_info)); ++ eth_hw_addr_random(bond_dev); ++ ++ /* ++ * Disable HW CSUM as wlan driver doesn't support ++ */ ++ bond_dev->hw_features &= ~(NETIF_F_HW_CSUM); ++ bond_dev->features &= ~(NETIF_F_HW_CSUM); ++ ++ res = register_netdevice(bond_dev); ++ if (res < 0) { ++ free_netdev(bond_dev); ++ return NULL; ++ } ++ ++ netif_carrier_off(bond_dev); ++ bond_work_init_all(bond); ++ ++ bond->id = ~0U; ++ if (bond_id_mask != (~0UL)) { ++ bond->id = (u32)ffz(bond_id_mask); ++ set_bit(bond->id, &bond_id_mask); ++ } ++ ++ return bond_dev; ++} ++EXPORT_SYMBOL(bond_create_mlo); ++ ++/* bond_get_mlo_ctx ++ * Returns MLO context stored in netdev priv of bond netdevice ++ */ ++void *bond_get_mlo_ctx(struct net_device *bond_dev) ++{ ++ struct mlo_bond_info *mlo_info = bond_get_mlo_priv(bond_dev); ++ ++ return mlo_info->bond_mlo_ctx; ++} ++EXPORT_SYMBOL(bond_get_mlo_ctx); ++ + static int __net_init bond_net_init(struct net *net) + { + struct bond_net *bn = net_generic(net, bond_net_id); +--- a/drivers/net/bonding/bond_options.c ++++ b/drivers/net/bonding/bond_options.c +@@ -94,6 +94,7 @@ static const struct bond_opt_value bond_ + { "802.3ad", BOND_MODE_8023AD, 0}, + { "balance-tlb", BOND_MODE_TLB, 0}, + { "balance-alb", BOND_MODE_ALB, 0}, ++ { "mode mlo", BOND_MODE_MLO, 0}, + { NULL, -1, 0}, + }; + +--- a/include/net/bonding.h ++++ b/include/net/bonding.h +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -203,6 +204,22 @@ struct bond_up_slave { + struct slave *arr[]; + }; + ++/** ++ * mlo_bond_info - mlo_bond_info structure maintains members corresponding to wifi 7 ++ * @bond_mlo_xmit_netdev: Callback function to provide skb to wifi driver for xmit ++ * @bond_get_mlo_tx_netdev: Callback function to get link interface from wifi driver for transmit ++ * @bond_mlo_ctx: Private member for wifi driver ++ * @wdev: ieee80211_ptr for wifi VAP ++ * @bond_mlo_netdev_priv_destructor: Callback function to remove wiphy instance from wifi driver ++ */ ++struct mlo_bond_info { ++ int (*bond_mlo_xmit_netdev)(struct sk_buff *skb, struct net_device *bond_dev); ++ struct net_device *(*bond_get_mlo_tx_netdev)(void *bond_mlo_ctx, void *dst); ++ void *bond_mlo_ctx; ++ struct wireless_dev *wdev; ++ void (*bond_mlo_netdev_priv_destructor)(struct net_device *bond_dev); ++}; ++ + /* + * Link pseudo-state only used internally by monitors + */ +@@ -268,6 +285,8 @@ struct bonding { + #endif /* CONFIG_XFRM_OFFLOAD */ + struct bpf_prog *xdp_prog; + u32 id; /* QCA NSS ECM bonding support */ ++ /* MLO mode info */ ++ struct mlo_bond_info mlo_info; + }; + + #define bond_slave_get_rcu(dev) \ +@@ -287,6 +306,19 @@ struct bond_vlan_tag { + bool bond_sk_check(struct bonding *bond); + + /** ++ * Returns False if the net_device is not MLO bond netdvice ++ * ++ */ ++static inline bool bond_is_mlo_device(struct net_device *bond_dev) ++{ ++ struct bonding *bond = netdev_priv(bond_dev); ++ if (BOND_MODE(bond) == BOND_MODE_MLO) ++ return true; ++ ++ return false; ++} ++ ++/** + * Returns NULL if the net_device does not belong to any of the bond's slaves + * + * Caller must hold bond lock for read +@@ -650,6 +682,12 @@ static inline __be32 bond_confirm_addr(s + return addr; + } + ++static inline struct mlo_bond_info *bond_get_mlo_priv(struct net_device *bond_dev) ++{ ++ struct bonding *bond = netdev_priv(bond_dev); ++ return &bond->mlo_info; ++} ++ + struct bond_net { + struct net *net; /* Associated network namespace */ + struct list_head dev_list; +@@ -663,14 +701,17 @@ int bond_rcv_validate(const struct sk_bu + netdev_tx_t bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); + int bond_get_id(struct net_device *bond_dev); /* QCA NSS ECM bonding support */ + int bond_create(struct net *net, const char *name); ++extern struct net_device *bond_create_mlo(struct net *net, const char *name, struct mlo_bond_info *mlo_info); ++extern void *bond_get_mlo_ctx(struct net_device *bond_dev); ++extern bool bond_destroy_mlo(struct net_device *bond_dev); + int bond_create_sysfs(struct bond_net *net); + void bond_destroy_sysfs(struct bond_net *net); + void bond_prepare_sysfs_group(struct bonding *bond); + int bond_sysfs_slave_add(struct slave *slave); + void bond_sysfs_slave_del(struct slave *slave); +-int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, ++extern int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, + struct netlink_ext_ack *extack); +-int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); ++extern int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); + u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb); + int bond_set_carrier(struct bonding *bond); + void bond_select_active_slave(struct bonding *bond); +--- a/include/uapi/linux/if_bonding.h ++++ b/include/uapi/linux/if_bonding.h +@@ -71,6 +71,7 @@ + #define BOND_MODE_8023AD 4 + #define BOND_MODE_TLB 5 + #define BOND_MODE_ALB 6 /* TLB + RLB (receive load balancing) */ ++#define BOND_MODE_MLO 7 /* MLO (Multi link) mode for Wi-Fi 7 AP links */ + + /* each slave's link has 4 states */ + #define BOND_LINK_UP 0 /* link is up and running */ diff --git a/lede/target/linux/qualcommax/patches-6.1/0601-qca-add-nss-bridge-mgr-support.patch b/lede/target/linux/qualcommax/patches-6.1/0601-qca-add-nss-bridge-mgr-support.patch new file mode 100644 index 0000000000..fbc76edef3 --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0601-qca-add-nss-bridge-mgr-support.patch @@ -0,0 +1,94 @@ +From 3c17a0e1112be70071e98d5208da5b55dcec20a6 Mon Sep 17 00:00:00 2001 +From: Simon Casey +Date: Wed, 2 Feb 2022 19:37:29 +0100 +Subject: [PATCH] Update 607-qca-add-add-nss-bridge-mgr-support.patch for kernel 5.15 + +--- + include/linux/if_bridge.h | 4 ++++ + net/bridge/br_fdb.c | 25 +++++++++++++++++++++---- + 2 files changed, 25 insertions(+), 4 deletions(-) + +--- a/include/linux/if_bridge.h ++++ b/include/linux/if_bridge.h +@@ -252,4 +252,8 @@ typedef struct net_bridge_port *br_get_d + extern br_get_dst_hook_t __rcu *br_get_dst_hook; + /* QCA NSS ECM support - End */ + ++/* QCA NSS bridge-mgr support - Start */ ++extern struct net_device *br_fdb_bridge_dev_get_and_hold(struct net_bridge *br); ++/* QCA NSS bridge-mgr support - End */ ++ + #endif +--- a/net/bridge/br_fdb.c ++++ b/net/bridge/br_fdb.c +@@ -62,6 +62,15 @@ void br_fdb_update_unregister_notify(str + EXPORT_SYMBOL_GPL(br_fdb_update_unregister_notify); + /* QCA NSS ECM support - End */ + ++/* QCA NSS bridge-mgr support - Start */ ++struct net_device *br_fdb_bridge_dev_get_and_hold(struct net_bridge *br) ++{ ++ dev_hold(br->dev); ++ return br->dev; ++} ++EXPORT_SYMBOL_GPL(br_fdb_bridge_dev_get_and_hold); ++/* QCA NSS bridge-mgr support - End */ ++ + int __init br_fdb_init(void) + { + br_fdb_cache = kmem_cache_create("bridge_fdb_cache", +@@ -568,7 +577,7 @@ void br_fdb_cleanup(struct work_struct * + unsigned long delay = hold_time(br); + unsigned long work_delay = delay; + unsigned long now = jiffies; +- u8 mac_addr[6]; /* QCA NSS ECM support */ ++ struct br_fdb_event fdb_event; /* QCA NSS bridge-mgr support */ + + /* this part is tricky, in order to avoid blocking learning and + * consequently forwarding, we rely on rcu to delete objects with +@@ -596,12 +605,13 @@ void br_fdb_cleanup(struct work_struct * + } else { + spin_lock_bh(&br->hash_lock); + if (!hlist_unhashed(&f->fdb_node)) { +- ether_addr_copy(mac_addr, f->key.addr.addr); ++ memset(&fdb_event, 0, sizeof(fdb_event)); ++ ether_addr_copy(fdb_event.addr, f->key.addr.addr); + fdb_delete(br, f, true); + /* QCA NSS ECM support - Start */ + atomic_notifier_call_chain( + &br_fdb_update_notifier_list, 0, +- (void *)mac_addr); ++ (void *)&fdb_event); + /* QCA NSS ECM support - End */ + } + spin_unlock_bh(&br->hash_lock); +@@ -903,6 +913,7 @@ void br_fdb_update(struct net_bridge *br + const unsigned char *addr, u16 vid, unsigned long flags) + { + struct net_bridge_fdb_entry *fdb; ++ struct br_fdb_event fdb_event; /* QCA NSS bridge-mgr support */ + + /* some users want to always flood. */ + if (hold_time(br) == 0) +@@ -928,6 +939,12 @@ void br_fdb_update(struct net_bridge *br + if (unlikely(source != READ_ONCE(fdb->dst) && + !test_bit(BR_FDB_STICKY, &fdb->flags))) { + br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH); ++ /* QCA NSS bridge-mgr support - Start */ ++ ether_addr_copy(fdb_event.addr, addr); ++ fdb_event.br = br; ++ fdb_event.orig_dev = READ_ONCE(fdb->dst->dev); ++ fdb_event.dev = source->dev; ++ /* QCA NSS bridge-mgr support - End */ + WRITE_ONCE(fdb->dst, source); + fdb_modified = true; + /* Take over HW learned entry */ +@@ -939,7 +956,7 @@ void br_fdb_update(struct net_bridge *br + /* QCA NSS ECM support - Start */ + atomic_notifier_call_chain( + &br_fdb_update_notifier_list, +- 0, (void *)addr); ++ 0, (void *)&fdb_event); + /* QCA NSS ECM support - End */ + } + diff --git a/lede/target/linux/qualcommax/patches-6.1/0602-qca-nss-drv-add-qdisc-support.patch b/lede/target/linux/qualcommax/patches-6.1/0602-qca-nss-drv-add-qdisc-support.patch new file mode 100644 index 0000000000..bbffeb1f0b --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0602-qca-nss-drv-add-qdisc-support.patch @@ -0,0 +1,44 @@ +--- a/include/linux/skbuff.h ++++ b/include/linux/skbuff.h +@@ -773,6 +773,7 @@ typedef unsigned char *sk_buff_data_t; + * @offload_fwd_mark: Packet was L2-forwarded in hardware + * @offload_l3_fwd_mark: Packet was L3-forwarded in hardware + * @tc_skip_classify: do not classify packet. set by IFB device ++ * @tc_skip_classify_offload: do not classify packet set by offload IFB device + * @tc_at_ingress: used within tc_classify to distinguish in/egress + * @redirected: packet was redirected by packet classifier + * @from_ingress: packet was redirected from the ingress path +@@ -968,6 +969,8 @@ struct sk_buff { + #ifdef CONFIG_NET_CLS_ACT + __u8 tc_skip_classify:1; + __u8 tc_at_ingress:1; /* See TC_AT_INGRESS_MASK */ ++ __u8 tc_skip_classify_offload:1; ++ __u16 tc_verd_qca_nss; /* QCA NSS Qdisc Support */ + #endif + #ifdef CONFIG_IPV6_NDISC_NODETYPE + __u8 ndisc_nodetype:2; +--- a/include/uapi/linux/pkt_cls.h ++++ b/include/uapi/linux/pkt_cls.h +@@ -139,6 +139,7 @@ enum tca_id { + TCA_ID_MPLS, + TCA_ID_CT, + TCA_ID_GATE, ++ TCA_ID_MIRRED_NSS, /* QCA NSS Qdisc IGS Support */ + /* other actions go here */ + __TCA_ID_MAX = 255 + }; +@@ -801,4 +802,14 @@ enum { + TCF_EM_OPND_LT + }; + ++/* QCA NSS Qdisc Support - Start */ ++#define _TC_MAKE32(x) ((x)) ++#define _TC_MAKEMASK1(n) (_TC_MAKE32(1) << _TC_MAKE32(n)) ++ ++#define TC_NCLS _TC_MAKEMASK1(8) ++#define TC_NCLS_NSS _TC_MAKEMASK1(12) ++#define SET_TC_NCLS_NSS(v) ( TC_NCLS_NSS | ((v) & ~TC_NCLS_NSS)) ++#define CLR_TC_NCLS_NSS(v) ( (v) & ~TC_NCLS_NSS) ++/* QCA NSS Qdisc Support - End */ ++ + #endif diff --git a/lede/target/linux/qualcommax/patches-6.1/0603-1-qca-nss-clients-add-qdisc-support.patch b/lede/target/linux/qualcommax/patches-6.1/0603-1-qca-nss-clients-add-qdisc-support.patch new file mode 100644 index 0000000000..e5f87d34e7 --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0603-1-qca-nss-clients-add-qdisc-support.patch @@ -0,0 +1,441 @@ +--- a/include/linux/timer.h ++++ b/include/linux/timer.h +@@ -17,6 +17,7 @@ struct timer_list { + unsigned long expires; + void (*function)(struct timer_list *); + u32 flags; ++ unsigned long cust_data; + + #ifdef CONFIG_LOCKDEP + struct lockdep_map lockdep_map; +--- a/drivers/net/ifb.c ++++ b/drivers/net/ifb.c +@@ -151,6 +151,31 @@ resched: + + } + ++void ifb_update_offload_stats(struct net_device *dev, struct pcpu_sw_netstats *offload_stats) ++{ ++ struct ifb_dev_private *dp; ++ struct ifb_q_private *txp; ++ ++ if (!dev || !offload_stats) { ++ return; ++ } ++ ++ if (!(dev->priv_flags_ext & IFF_EXT_IFB)) { ++ return; ++ } ++ ++ dp = netdev_priv(dev); ++ txp = dp->tx_private; ++ ++ u64_stats_update_begin(&txp->rx_stats.sync); ++ txp->rx_stats.packets += u64_stats_read(&offload_stats->rx_packets); ++ txp->rx_stats.bytes += u64_stats_read(&offload_stats->rx_bytes); ++ txp->tx_stats.packets += u64_stats_read(&offload_stats->tx_packets); ++ txp->tx_stats.bytes += u64_stats_read(&offload_stats->tx_bytes); ++ u64_stats_update_end(&txp->rx_stats.sync); ++} ++EXPORT_SYMBOL(ifb_update_offload_stats); ++ + static void ifb_stats64(struct net_device *dev, + struct rtnl_link_stats64 *stats) + { +@@ -326,6 +351,7 @@ static void ifb_setup(struct net_device + dev->flags |= IFF_NOARP; + dev->flags &= ~IFF_MULTICAST; + dev->priv_flags &= ~IFF_TX_SKB_SHARING; ++ dev->priv_flags_ext |= IFF_EXT_IFB; /* Mark the device as an IFB device. */ + netif_keep_dst(dev); + eth_hw_addr_random(dev); + dev->needs_free_netdev = true; +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -4590,6 +4590,15 @@ void dev_uc_flush(struct net_device *dev + void dev_uc_init(struct net_device *dev); + + /** ++ * ifb_update_offload_stats - Update the IFB interface stats ++ * @dev: IFB device to update the stats ++ * @offload_stats: per CPU stats structure ++ * ++ * Allows update of IFB stats when flows are offloaded to an accelerator. ++ **/ ++void ifb_update_offload_stats(struct net_device *dev, struct pcpu_sw_netstats *offload_stats); ++ ++/** + * __dev_uc_sync - Synchonize device's unicast list + * @dev: device to sync + * @sync: function to call if address should be added +@@ -5135,6 +5144,11 @@ static inline bool netif_is_failover_sla + return dev->priv_flags & IFF_FAILOVER_SLAVE; + } + ++static inline bool netif_is_ifb_dev(const struct net_device *dev) ++{ ++ return dev->priv_flags_ext & IFF_EXT_IFB; ++} ++ + /* This device needs to keep skb dst for qdisc enqueue or ndo_start_xmit() */ + static inline void netif_keep_dst(struct net_device *dev) + { +--- a/include/uapi/linux/pkt_sched.h ++++ b/include/uapi/linux/pkt_sched.h +@@ -1278,4 +1278,248 @@ enum { + + #define TCA_ETS_MAX (__TCA_ETS_MAX - 1) + ++/* QCA NSS Clients Support - Start */ ++enum { ++ TCA_NSS_ACCEL_MODE_NSS_FW, ++ TCA_NSS_ACCEL_MODE_PPE, ++ TCA_NSS_ACCEL_MODE_MAX ++}; ++ ++/* NSSFIFO section */ ++ ++enum { ++ TCA_NSSFIFO_UNSPEC, ++ TCA_NSSFIFO_PARMS, ++ __TCA_NSSFIFO_MAX ++}; ++ ++#define TCA_NSSFIFO_MAX (__TCA_NSSFIFO_MAX - 1) ++ ++struct tc_nssfifo_qopt { ++ __u32 limit; /* Queue length: bytes for bfifo, packets for pfifo */ ++ __u8 set_default; /* Sets qdisc to be the default qdisc for enqueue */ ++ __u8 accel_mode; /* Dictates which data plane offloads the qdisc */ ++}; ++ ++/* NSSWRED section */ ++ ++enum { ++ TCA_NSSWRED_UNSPEC, ++ TCA_NSSWRED_PARMS, ++ __TCA_NSSWRED_MAX ++}; ++ ++#define TCA_NSSWRED_MAX (__TCA_NSSWRED_MAX - 1) ++#define NSSWRED_CLASS_MAX 6 ++struct tc_red_alg_parameter { ++ __u32 min; /* qlen_avg < min: pkts are all enqueued */ ++ __u32 max; /* qlen_avg > max: pkts are all dropped */ ++ __u32 probability;/* Drop probability at qlen_avg = max */ ++ __u32 exp_weight_factor;/* exp_weight_factor for calculate qlen_avg */ ++}; ++ ++struct tc_nsswred_traffic_class { ++ __u32 limit; /* Queue length */ ++ __u32 weight_mode_value; /* Weight mode value */ ++ struct tc_red_alg_parameter rap;/* Parameters for RED alg */ ++}; ++ ++/* ++ * Weight modes for WRED ++ */ ++enum tc_nsswred_weight_modes { ++ TC_NSSWRED_WEIGHT_MODE_DSCP = 0,/* Weight mode is DSCP */ ++ TC_NSSWRED_WEIGHT_MODES, /* Must be last */ ++}; ++ ++struct tc_nsswred_qopt { ++ __u32 limit; /* Queue length */ ++ enum tc_nsswred_weight_modes weight_mode; ++ /* Weight mode */ ++ __u32 traffic_classes; /* How many traffic classes: DPs */ ++ __u32 def_traffic_class; /* Default traffic if no match: def_DP */ ++ __u32 traffic_id; /* The traffic id to be configured: DP */ ++ __u32 weight_mode_value; /* Weight mode value */ ++ struct tc_red_alg_parameter rap;/* RED algorithm parameters */ ++ struct tc_nsswred_traffic_class tntc[NSSWRED_CLASS_MAX]; ++ /* Traffic settings for dumpping */ ++ __u8 ecn; /* Setting ECN bit or dropping */ ++ __u8 set_default; /* Sets qdisc to be the default for enqueue */ ++ __u8 accel_mode; /* Dictates which data plane offloads the qdisc */ ++}; ++ ++/* NSSCODEL section */ ++ ++enum { ++ TCA_NSSCODEL_UNSPEC, ++ TCA_NSSCODEL_PARMS, ++ __TCA_NSSCODEL_MAX ++}; ++ ++#define TCA_NSSCODEL_MAX (__TCA_NSSCODEL_MAX - 1) ++ ++struct tc_nsscodel_qopt { ++ __u32 target; /* Acceptable queueing delay */ ++ __u32 limit; /* Max number of packets that can be held in the queue */ ++ __u32 interval; /* Monitoring interval */ ++ __u32 flows; /* Number of flow buckets */ ++ __u32 quantum; /* Weight (in bytes) used for DRR of flow buckets */ ++ __u8 ecn; /* 0 - disable ECN, 1 - enable ECN */ ++ __u8 set_default; /* Sets qdisc to be the default qdisc for enqueue */ ++ __u8 accel_mode; /* Dictates which data plane offloads the qdisc */ ++}; ++ ++struct tc_nsscodel_xstats { ++ __u32 peak_queue_delay; /* Peak delay experienced by a dequeued packet */ ++ __u32 peak_drop_delay; /* Peak delay experienced by a dropped packet */ ++}; ++ ++/* NSSFQ_CODEL section */ ++ ++struct tc_nssfq_codel_xstats { ++ __u32 new_flow_count; /* Total number of new flows seen */ ++ __u32 new_flows_len; /* Current number of new flows */ ++ __u32 old_flows_len; /* Current number of old flows */ ++ __u32 ecn_mark; /* Number of packets marked with ECN */ ++ __u32 drop_overlimit; /* Number of packets dropped due to overlimit */ ++ __u32 maxpacket; /* The largest packet seen so far in the queue */ ++}; ++ ++/* NSSTBL section */ ++ ++enum { ++ TCA_NSSTBL_UNSPEC, ++ TCA_NSSTBL_PARMS, ++ __TCA_NSSTBL_MAX ++}; ++ ++#define TCA_NSSTBL_MAX (__TCA_NSSTBL_MAX - 1) ++ ++struct tc_nsstbl_qopt { ++ __u32 burst; /* Maximum burst size */ ++ __u32 rate; /* Limiting rate of TBF */ ++ __u32 peakrate; /* Maximum rate at which TBF is allowed to send */ ++ __u32 mtu; /* Max size of packet, or minumim burst size */ ++ __u8 accel_mode; /* Dictates which data plane offloads the qdisc */ ++}; ++ ++/* NSSPRIO section */ ++ ++#define TCA_NSSPRIO_MAX_BANDS 256 ++ ++enum { ++ TCA_NSSPRIO_UNSPEC, ++ TCA_NSSPRIO_PARMS, ++ __TCA_NSSPRIO_MAX ++}; ++ ++#define TCA_NSSPRIO_MAX (__TCA_NSSPRIO_MAX - 1) ++ ++struct tc_nssprio_qopt { ++ __u32 bands; /* Number of bands */ ++ __u8 accel_mode; /* Dictates which data plane offloads the qdisc */ ++}; ++ ++/* NSSBF section */ ++ ++enum { ++ TCA_NSSBF_UNSPEC, ++ TCA_NSSBF_CLASS_PARMS, ++ TCA_NSSBF_QDISC_PARMS, ++ __TCA_NSSBF_MAX ++}; ++ ++#define TCA_NSSBF_MAX (__TCA_NSSBF_MAX - 1) ++ ++struct tc_nssbf_class_qopt { ++ __u32 burst; /* Maximum burst size */ ++ __u32 rate; /* Allowed bandwidth for this class */ ++ __u32 mtu; /* MTU of the associated interface */ ++ __u32 quantum; /* Quantum allocation for DRR */ ++}; ++ ++struct tc_nssbf_qopt { ++ __u16 defcls; /* Default class value */ ++ __u8 accel_mode; /* Dictates which data plane offloads the qdisc */ ++}; ++ ++/* NSSWRR section */ ++ ++enum { ++ TCA_NSSWRR_UNSPEC, ++ TCA_NSSWRR_CLASS_PARMS, ++ TCA_NSSWRR_QDISC_PARMS, ++ __TCA_NSSWRR_MAX ++}; ++ ++#define TCA_NSSWRR_MAX (__TCA_NSSWRR_MAX - 1) ++ ++struct tc_nsswrr_class_qopt { ++ __u32 quantum; /* Weight associated to this class */ ++}; ++ ++struct tc_nsswrr_qopt { ++ __u8 accel_mode; /* Dictates which data plane offloads the qdisc */ ++}; ++ ++/* NSSWFQ section */ ++ ++enum { ++ TCA_NSSWFQ_UNSPEC, ++ TCA_NSSWFQ_CLASS_PARMS, ++ TCA_NSSWFQ_QDISC_PARMS, ++ __TCA_NSSWFQ_MAX ++}; ++ ++#define TCA_NSSWFQ_MAX (__TCA_NSSWFQ_MAX - 1) ++ ++struct tc_nsswfq_class_qopt { ++ __u32 quantum; /* Weight associated to this class */ ++}; ++ ++struct tc_nsswfq_qopt { ++ __u8 accel_mode; /* Dictates which data plane offloads the qdisc */ ++}; ++ ++/* NSSHTB section */ ++ ++enum { ++ TCA_NSSHTB_UNSPEC, ++ TCA_NSSHTB_CLASS_PARMS, ++ TCA_NSSHTB_QDISC_PARMS, ++ __TCA_NSSHTB_MAX ++}; ++ ++#define TCA_NSSHTB_MAX (__TCA_NSSHTB_MAX - 1) ++ ++struct tc_nsshtb_class_qopt { ++ __u32 burst; /* Allowed burst size */ ++ __u32 rate; /* Allowed bandwidth for this class */ ++ __u32 cburst; /* Maximum burst size */ ++ __u32 crate; /* Maximum bandwidth for this class */ ++ __u32 quantum; /* Quantum allocation for DRR */ ++ __u32 priority; /* Priority value associated with this class */ ++ __u32 overhead; /* Overhead in bytes per packet */ ++}; ++ ++struct tc_nsshtb_qopt { ++ __u32 r2q; /* Rate to quantum ratio */ ++ __u8 accel_mode; /* Dictates which data plane offloads the qdisc */ ++}; ++ ++/* NSSBLACKHOLE section */ ++ ++enum { ++ TCA_NSSBLACKHOLE_UNSPEC, ++ TCA_NSSBLACKHOLE_PARMS, ++ __TCA_NSSBLACKHOLE_MAX ++}; ++ ++#define TCA_NSSBLACKHOLE_MAX (__TCA_NSSBLACKHOLE_MAX - 1) ++ ++struct tc_nssblackhole_qopt { ++ __u8 set_default; /* Sets qdisc to be the default qdisc for enqueue */ ++ __u8 accel_mode; /* Dictates which data plane offloads the qdisc */ ++}; ++/* QCA NSS Clients Support - End */ + #endif +--- a/net/sched/sch_api.c ++++ b/net/sched/sch_api.c +@@ -313,6 +313,7 @@ struct Qdisc *qdisc_lookup(struct net_de + out: + return q; + } ++EXPORT_SYMBOL(qdisc_lookup); + + struct Qdisc *qdisc_lookup_rcu(struct net_device *dev, u32 handle) + { +@@ -2386,4 +2387,26 @@ static int __init pktsched_init(void) + return 0; + } + ++/* QCA NSS Qdisc Support - Start */ ++bool tcf_destroy(struct tcf_proto *tp, bool force) ++{ ++ tp->ops->destroy(tp, force, NULL); ++ module_put(tp->ops->owner); ++ kfree_rcu(tp, rcu); ++ ++ return true; ++} ++ ++void tcf_destroy_chain(struct tcf_proto __rcu **fl) ++{ ++ struct tcf_proto *tp; ++ ++ while ((tp = rtnl_dereference(*fl)) != NULL) { ++ RCU_INIT_POINTER(*fl, tp->next); ++ tcf_destroy(tp, true); ++ } ++} ++EXPORT_SYMBOL(tcf_destroy_chain); ++/* QCA NSS Qdisc Support - End */ ++ + subsys_initcall(pktsched_init); +--- a/net/sched/sch_generic.c ++++ b/net/sched/sch_generic.c +@@ -1069,6 +1069,7 @@ static void __qdisc_destroy(struct Qdisc + + call_rcu(&qdisc->rcu, qdisc_free_cb); + } ++EXPORT_SYMBOL(qdisc_destroy); + + void qdisc_destroy(struct Qdisc *qdisc) + { +--- a/include/net/sch_generic.h ++++ b/include/net/sch_generic.h +@@ -94,6 +94,7 @@ struct Qdisc { + #define TCQ_F_INVISIBLE 0x80 /* invisible by default in dump */ + #define TCQ_F_NOLOCK 0x100 /* qdisc does not require locking */ + #define TCQ_F_OFFLOADED 0x200 /* qdisc is offloaded to HW */ ++#define TCQ_F_NSS 0x1000 /* NSS qdisc flag. */ + u32 limit; + const struct Qdisc_ops *ops; + struct qdisc_size_table __rcu *stab; +@@ -719,6 +720,40 @@ static inline bool skb_skip_tc_classify( + return false; + } + ++/* ++ * Set skb classify bit field. ++ */ ++static inline void skb_set_tc_classify_offload(struct sk_buff *skb) ++{ ++#ifdef CONFIG_NET_CLS_ACT ++ skb->tc_skip_classify_offload = 1; ++#endif ++} ++ ++/* ++ * Clear skb classify bit field. ++ */ ++static inline void skb_clear_tc_classify_offload(struct sk_buff *skb) ++{ ++#ifdef CONFIG_NET_CLS_ACT ++ skb->tc_skip_classify_offload = 0; ++#endif ++} ++ ++/* ++ * Skip skb processing if sent from ifb dev. ++ */ ++static inline bool skb_skip_tc_classify_offload(struct sk_buff *skb) ++{ ++#ifdef CONFIG_NET_CLS_ACT ++ if (skb->tc_skip_classify_offload) { ++ skb_clear_tc_classify_offload(skb); ++ return true; ++ } ++#endif ++ return false; ++} ++ + /* Reset all TX qdiscs greater than index of a device. */ + static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i) + { +@@ -1305,4 +1340,9 @@ static inline void qdisc_synchronize(con + msleep(1); + } + ++/* QCA NSS Qdisc Support - Start */ ++void qdisc_destroy(struct Qdisc *qdisc); ++void tcf_destroy_chain(struct tcf_proto __rcu **fl); ++/* QCA NSS Qdisc Support - End */ ++ + #endif diff --git a/lede/target/linux/qualcommax/patches-6.1/0603-2-qca-nss-clients-add-l2tp-support.patch b/lede/target/linux/qualcommax/patches-6.1/0603-2-qca-nss-clients-add-l2tp-support.patch new file mode 100644 index 0000000000..7fa9184df2 --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0603-2-qca-nss-clients-add-l2tp-support.patch @@ -0,0 +1,46 @@ +--- a/net/l2tp/l2tp_core.c ++++ b/net/l2tp/l2tp_core.c +@@ -398,6 +398,31 @@ err_tlock: + } + EXPORT_SYMBOL_GPL(l2tp_session_register); + ++void l2tp_stats_update(struct l2tp_tunnel *tunnel, ++ struct l2tp_session *session, ++ struct l2tp_stats *stats) ++{ ++ atomic_long_add(atomic_long_read(&stats->rx_packets), ++ &tunnel->stats.rx_packets); ++ atomic_long_add(atomic_long_read(&stats->rx_bytes), ++ &tunnel->stats.rx_bytes); ++ atomic_long_add(atomic_long_read(&stats->tx_packets), ++ &tunnel->stats.tx_packets); ++ atomic_long_add(atomic_long_read(&stats->tx_bytes), ++ &tunnel->stats.tx_bytes); ++ ++ atomic_long_add(atomic_long_read(&stats->rx_packets), ++ &session->stats.rx_packets); ++ atomic_long_add(atomic_long_read(&stats->rx_bytes), ++ &session->stats.rx_bytes); ++ atomic_long_add(atomic_long_read(&stats->tx_packets), ++ &session->stats.tx_packets); ++ atomic_long_add(atomic_long_read(&stats->tx_bytes), ++ &session->stats.tx_bytes); ++} ++EXPORT_SYMBOL_GPL(l2tp_stats_update); ++ ++ + /***************************************************************************** + * Receive data handling + *****************************************************************************/ +--- a/net/l2tp/l2tp_core.h ++++ b/net/l2tp/l2tp_core.h +@@ -232,6 +232,9 @@ struct l2tp_session *l2tp_session_get_nt + struct l2tp_session *l2tp_session_get_by_ifname(const struct net *net, + const char *ifname); + ++void l2tp_stats_update(struct l2tp_tunnel *tunnel, struct l2tp_session *session, ++ struct l2tp_stats *stats); ++ + /* Tunnel and session lifetime management. + * Creation of a new instance is a two-step process: create, then register. + * Destruction is triggered using the *_delete functions, and completes asynchronously. diff --git a/lede/target/linux/qualcommax/patches-6.1/0603-3-qca-nss-clients-add-PPTP-support.patch b/lede/target/linux/qualcommax/patches-6.1/0603-3-qca-nss-clients-add-PPTP-support.patch new file mode 100644 index 0000000000..5fb9917bc9 --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0603-3-qca-nss-clients-add-PPTP-support.patch @@ -0,0 +1,478 @@ +--- a/include/linux/if_pppox.h ++++ b/include/linux/if_pppox.h +@@ -36,6 +36,7 @@ struct pptp_opt { + u32 ack_sent, ack_recv; + u32 seq_sent, seq_recv; + int ppp_flags; ++ bool pptp_offload_mode; + }; + #include + +@@ -100,8 +101,40 @@ struct pppoe_channel_ops { + int (*get_addressing)(struct ppp_channel *, struct pppoe_opt *); + }; + ++/* PPTP client callback */ ++typedef int (*pptp_gre_seq_offload_callback_t)(struct sk_buff *skb, ++ struct net_device *pptp_dev); ++ + /* Return PPPoE channel specific addressing information */ + extern int pppoe_channel_addressing_get(struct ppp_channel *chan, + struct pppoe_opt *addressing); + ++/* Lookup PPTP session info and return PPTP session using sip, dip and local call id */ ++extern int pptp_session_find_by_src_callid(struct pptp_opt *opt, __be16 src_call_id, ++ __be32 daddr, __be32 saddr); ++ ++/* Lookup PPTP session info and return PPTP session using dip and peer call id */ ++extern int pptp_session_find(struct pptp_opt *opt, __be16 peer_call_id, ++ __be32 peer_ip_addr); ++ ++/* Return PPTP session information given the channel */ ++extern void pptp_channel_addressing_get(struct pptp_opt *opt, ++ struct ppp_channel *chan); ++ ++/* Enable the PPTP session offload flag */ ++extern int pptp_session_enable_offload_mode(__be16 peer_call_id, ++ __be32 peer_ip_addr); ++ ++/* Disable the PPTP session offload flag */ ++extern int pptp_session_disable_offload_mode(__be16 peer_call_id, ++ __be32 peer_ip_addr); ++ ++/* Register the PPTP GRE packets sequence number offload callback */ ++extern int ++pptp_register_gre_seq_offload_callback(pptp_gre_seq_offload_callback_t ++ pptp_client_cb); ++ ++/* Unregister the PPTP GRE packets sequence number offload callback */ ++extern void pptp_unregister_gre_seq_offload_callback(void); ++ + #endif /* !(__LINUX_IF_PPPOX_H) */ +--- a/drivers/net/ppp/ppp_generic.c ++++ b/drivers/net/ppp/ppp_generic.c +@@ -2973,6 +2973,20 @@ char *ppp_dev_name(struct ppp_channel *c + return name; + } + ++/* Return the PPP net device index */ ++int ppp_dev_index(struct ppp_channel *chan) ++{ ++ struct channel *pch = chan->ppp; ++ int ifindex = 0; ++ ++ if (pch) { ++ read_lock_bh(&pch->upl); ++ if (pch->ppp && pch->ppp->dev) ++ ifindex = pch->ppp->dev->ifindex; ++ read_unlock_bh(&pch->upl); ++ } ++ return ifindex; ++} + + /* + * Disconnect a channel from the generic layer. +@@ -3681,6 +3695,28 @@ void ppp_update_stats(struct net_device + ppp_recv_unlock(ppp); + } + ++/* Returns true if Compression is enabled on PPP device ++ */ ++bool ppp_is_cp_enabled(struct net_device *dev) ++{ ++ struct ppp *ppp; ++ bool flag = false; ++ ++ if (!dev) ++ return false; ++ ++ if (dev->type != ARPHRD_PPP) ++ return false; ++ ++ ppp = netdev_priv(dev); ++ ppp_lock(ppp); ++ flag = !!(ppp->xstate & SC_COMP_RUN) || !!(ppp->rstate & SC_DECOMP_RUN); ++ ppp_unlock(ppp); ++ ++ return flag; ++} ++EXPORT_SYMBOL(ppp_is_cp_enabled); ++ + /* Returns >0 if the device is a multilink PPP netdevice, 0 if not or < 0 if + * the device is not PPP. + */ +@@ -3872,6 +3908,7 @@ EXPORT_SYMBOL(ppp_unregister_channel); + EXPORT_SYMBOL(ppp_channel_index); + EXPORT_SYMBOL(ppp_unit_number); + EXPORT_SYMBOL(ppp_dev_name); ++EXPORT_SYMBOL(ppp_dev_index); + EXPORT_SYMBOL(ppp_input); + EXPORT_SYMBOL(ppp_input_error); + EXPORT_SYMBOL(ppp_output_wakeup); +--- a/include/linux/ppp_channel.h ++++ b/include/linux/ppp_channel.h +@@ -84,6 +84,9 @@ extern void ppp_unregister_channel(struc + /* Get the channel number for a channel */ + extern int ppp_channel_index(struct ppp_channel *); + ++/* Get the device index associated with a channel, or 0, if none */ ++extern int ppp_dev_index(struct ppp_channel *); ++ + /* Get the unit number associated with a channel, or -1 if none */ + extern int ppp_unit_number(struct ppp_channel *); + +@@ -116,6 +119,7 @@ extern int ppp_hold_channels(struct net_ + /* Test if ppp xmit lock is locked */ + extern bool ppp_is_xmit_locked(struct net_device *dev); + ++bool ppp_is_cp_enabled(struct net_device *dev); + /* Test if the ppp device is a multi-link ppp device */ + extern int ppp_is_multilink(struct net_device *dev); + +--- a/drivers/net/ppp/pptp.c ++++ b/drivers/net/ppp/pptp.c +@@ -50,6 +50,8 @@ static struct proto pptp_sk_proto __read + static const struct ppp_channel_ops pptp_chan_ops; + static const struct proto_ops pptp_ops; + ++static pptp_gre_seq_offload_callback_t __rcu pptp_gre_offload_xmit_cb; ++ + static struct pppox_sock *lookup_chan(u16 call_id, __be32 s_addr) + { + struct pppox_sock *sock; +@@ -91,6 +93,79 @@ static int lookup_chan_dst(u16 call_id, + return i < MAX_CALLID; + } + ++/* Search a pptp session based on local call id, local and remote ip address */ ++static int lookup_session_src(struct pptp_opt *opt, u16 call_id, __be32 daddr, __be32 saddr) ++{ ++ struct pppox_sock *sock; ++ int i = 1; ++ ++ rcu_read_lock(); ++ for_each_set_bit_from(i, callid_bitmap, MAX_CALLID) { ++ sock = rcu_dereference(callid_sock[i]); ++ if (!sock) ++ continue; ++ ++ if (sock->proto.pptp.src_addr.call_id == call_id && ++ sock->proto.pptp.dst_addr.sin_addr.s_addr == daddr && ++ sock->proto.pptp.src_addr.sin_addr.s_addr == saddr) { ++ sock_hold(sk_pppox(sock)); ++ memcpy(opt, &sock->proto.pptp, sizeof(struct pptp_opt)); ++ sock_put(sk_pppox(sock)); ++ rcu_read_unlock(); ++ return 0; ++ } ++ } ++ rcu_read_unlock(); ++ return -EINVAL; ++} ++ ++/* Search a pptp session based on peer call id and peer ip address */ ++static int lookup_session_dst(struct pptp_opt *opt, u16 call_id, __be32 d_addr) ++{ ++ struct pppox_sock *sock; ++ int i = 1; ++ ++ rcu_read_lock(); ++ for_each_set_bit_from(i, callid_bitmap, MAX_CALLID) { ++ sock = rcu_dereference(callid_sock[i]); ++ if (!sock) ++ continue; ++ ++ if (sock->proto.pptp.dst_addr.call_id == call_id && ++ sock->proto.pptp.dst_addr.sin_addr.s_addr == d_addr) { ++ sock_hold(sk_pppox(sock)); ++ memcpy(opt, &sock->proto.pptp, sizeof(struct pptp_opt)); ++ sock_put(sk_pppox(sock)); ++ rcu_read_unlock(); ++ return 0; ++ } ++ } ++ rcu_read_unlock(); ++ return -EINVAL; ++} ++ ++/* If offload mode set then this function sends all packets to ++ * offload module instead of network stack ++ */ ++static int pptp_client_skb_xmit(struct sk_buff *skb, ++ struct net_device *pptp_dev) ++{ ++ pptp_gre_seq_offload_callback_t pptp_gre_offload_cb_f; ++ int ret; ++ ++ rcu_read_lock(); ++ pptp_gre_offload_cb_f = rcu_dereference(pptp_gre_offload_xmit_cb); ++ ++ if (!pptp_gre_offload_cb_f) { ++ rcu_read_unlock(); ++ return -1; ++ } ++ ++ ret = pptp_gre_offload_cb_f(skb, pptp_dev); ++ rcu_read_unlock(); ++ return ret; ++} ++ + static int add_chan(struct pppox_sock *sock, + struct pptp_addr *sa) + { +@@ -136,7 +211,7 @@ static struct rtable *pptp_route_output( + struct net *net; + + net = sock_net(sk); +- flowi4_init_output(fl4, sk->sk_bound_dev_if, sk->sk_mark, 0, ++ flowi4_init_output(fl4, 0, sk->sk_mark, 0, + RT_SCOPE_UNIVERSE, IPPROTO_GRE, 0, + po->proto.pptp.dst_addr.sin_addr.s_addr, + po->proto.pptp.src_addr.sin_addr.s_addr, +@@ -163,8 +238,11 @@ static int pptp_xmit(struct ppp_channel + + struct rtable *rt; + struct net_device *tdev; ++ struct net_device *pptp_dev; + struct iphdr *iph; + int max_headroom; ++ int pptp_ifindex; ++ int ret; + + if (sk_pppox(po)->sk_state & PPPOX_DEAD) + goto tx_error; +@@ -258,7 +336,32 @@ static int pptp_xmit(struct ppp_channel + ip_select_ident(net, skb, NULL); + ip_send_check(iph); + +- ip_local_out(net, skb->sk, skb); ++ pptp_ifindex = ppp_dev_index(chan); ++ ++ /* set incoming interface as the ppp interface */ ++ if (skb->skb_iif) ++ skb->skb_iif = pptp_ifindex; ++ ++ /* If the PPTP GRE seq number offload module is not enabled yet ++ * then sends all PPTP GRE packets through linux network stack ++ */ ++ if (!opt->pptp_offload_mode) { ++ ip_local_out(net, skb->sk, skb); ++ return 1; ++ } ++ ++ pptp_dev = dev_get_by_index(&init_net, pptp_ifindex); ++ if (!pptp_dev) ++ goto tx_error; ++ ++ /* If PPTP offload module is enabled then forward all PPTP GRE ++ * packets to PPTP GRE offload module ++ */ ++ ret = pptp_client_skb_xmit(skb, pptp_dev); ++ dev_put(pptp_dev); ++ if (ret < 0) ++ goto tx_error; ++ + return 1; + + tx_error: +@@ -314,6 +417,13 @@ static int pptp_rcv_core(struct sock *sk + goto drop; + + payload = skb->data + headersize; ++ ++ /* If offload is enabled, we expect the offload module ++ * to handle PPTP GRE sequence number checks ++ */ ++ if (opt->pptp_offload_mode) ++ goto allow_packet; ++ + /* check for expected sequence number */ + if (seq < opt->seq_recv + 1 || WRAPPED(opt->seq_recv, seq)) { + if ((payload[0] == PPP_ALLSTATIONS) && (payload[1] == PPP_UI) && +@@ -371,6 +481,7 @@ static int pptp_rcv(struct sk_buff *skb) + if (po) { + skb_dst_drop(skb); + nf_reset_ct(skb); ++ skb->skb_iif = ppp_dev_index(&po->chan); + return sk_receive_skb(sk_pppox(po), skb, 0); + } + drop: +@@ -473,7 +584,7 @@ static int pptp_connect(struct socket *s + + opt->dst_addr = sp->sa_addr.pptp; + sk->sk_state |= PPPOX_CONNECTED; +- ++ opt->pptp_offload_mode = false; + end: + release_sock(sk); + return error; +@@ -603,9 +714,169 @@ static int pptp_ppp_ioctl(struct ppp_cha + return err; + } + ++/* pptp_channel_addressing_get() ++ * Return PPTP channel specific addressing information. ++ */ ++void pptp_channel_addressing_get(struct pptp_opt *opt, struct ppp_channel *chan) ++{ ++ struct sock *sk; ++ struct pppox_sock *po; ++ ++ if (!opt) ++ return; ++ ++ sk = (struct sock *)chan->private; ++ if (!sk) ++ return; ++ ++ sock_hold(sk); ++ ++ /* This is very unlikely, but check the socket is connected state */ ++ if (unlikely(sock_flag(sk, SOCK_DEAD) || ++ !(sk->sk_state & PPPOX_CONNECTED))) { ++ sock_put(sk); ++ return; ++ } ++ ++ po = pppox_sk(sk); ++ memcpy(opt, &po->proto.pptp, sizeof(struct pptp_opt)); ++ sock_put(sk); ++} ++EXPORT_SYMBOL(pptp_channel_addressing_get); ++ ++/* pptp_session_find() ++ * Search and return a PPTP session info based on peer callid and IP ++ * address. The function accepts the parameters in network byte order. ++ */ ++int pptp_session_find(struct pptp_opt *opt, __be16 peer_call_id, ++ __be32 peer_ip_addr) ++{ ++ if (!opt) ++ return -EINVAL; ++ ++ return lookup_session_dst(opt, ntohs(peer_call_id), peer_ip_addr); ++} ++EXPORT_SYMBOL(pptp_session_find); ++ ++/* pptp_session_find_by_src_callid() ++ * Search and return a PPTP session info based on src callid and IP ++ * address. The function accepts the parameters in network byte order. ++ */ ++int pptp_session_find_by_src_callid(struct pptp_opt *opt, __be16 src_call_id, ++ __be32 daddr, __be32 saddr) ++{ ++ if (!opt) ++ return -EINVAL; ++ ++ return lookup_session_src(opt, ntohs(src_call_id), daddr, saddr); ++} ++EXPORT_SYMBOL(pptp_session_find_by_src_callid); ++ ++ /* Function to change the offload mode true/false for a PPTP session */ ++static int pptp_set_offload_mode(bool accel_mode, ++ __be16 peer_call_id, __be32 peer_ip_addr) ++{ ++ struct pppox_sock *sock; ++ int i = 1; ++ ++ rcu_read_lock(); ++ for_each_set_bit_from(i, callid_bitmap, MAX_CALLID) { ++ sock = rcu_dereference(callid_sock[i]); ++ if (!sock) ++ continue; ++ ++ if (sock->proto.pptp.dst_addr.call_id == peer_call_id && ++ sock->proto.pptp.dst_addr.sin_addr.s_addr == peer_ip_addr) { ++ sock_hold(sk_pppox(sock)); ++ sock->proto.pptp.pptp_offload_mode = accel_mode; ++ sock_put(sk_pppox(sock)); ++ rcu_read_unlock(); ++ return 0; ++ } ++ } ++ rcu_read_unlock(); ++ return -EINVAL; ++} ++ ++/* Enable the PPTP session offload flag */ ++int pptp_session_enable_offload_mode(__be16 peer_call_id, __be32 peer_ip_addr) ++{ ++ return pptp_set_offload_mode(true, peer_call_id, peer_ip_addr); ++} ++EXPORT_SYMBOL(pptp_session_enable_offload_mode); ++ ++/* Disable the PPTP session offload flag */ ++int pptp_session_disable_offload_mode(__be16 peer_call_id, __be32 peer_ip_addr) ++{ ++ return pptp_set_offload_mode(false, peer_call_id, peer_ip_addr); ++} ++EXPORT_SYMBOL(pptp_session_disable_offload_mode); ++ ++/* Register the offload callback function on behalf of the module which ++ * will own the sequence and acknowledgment number updates for all ++ * PPTP GRE packets. All PPTP GRE packets are then transmitted to this ++ * module after encapsulation in order to ensure the correct seq/ack ++ * fields are set in the packets before transmission. This is required ++ * when PPTP flows are offloaded to acceleration engines, in-order to ++ * ensure consistency in sequence and ack numbers between PPTP control ++ * (PPP LCP) and data packets ++ */ ++int pptp_register_gre_seq_offload_callback(pptp_gre_seq_offload_callback_t ++ pptp_gre_offload_cb) ++{ ++ pptp_gre_seq_offload_callback_t pptp_gre_offload_cb_f; ++ ++ rcu_read_lock(); ++ pptp_gre_offload_cb_f = rcu_dereference(pptp_gre_offload_xmit_cb); ++ ++ if (pptp_gre_offload_cb_f) { ++ rcu_read_unlock(); ++ return -1; ++ } ++ ++ rcu_assign_pointer(pptp_gre_offload_xmit_cb, pptp_gre_offload_cb); ++ rcu_read_unlock(); ++ return 0; ++} ++EXPORT_SYMBOL(pptp_register_gre_seq_offload_callback); ++ ++/* Unregister the PPTP GRE packets sequence number offload callback */ ++void pptp_unregister_gre_seq_offload_callback(void) ++{ ++ rcu_assign_pointer(pptp_gre_offload_xmit_cb, NULL); ++} ++EXPORT_SYMBOL(pptp_unregister_gre_seq_offload_callback); ++ ++/* pptp_hold_chan() */ ++static void pptp_hold_chan(struct ppp_channel *chan) ++{ ++ struct sock *sk = (struct sock *)chan->private; ++ ++ sock_hold(sk); ++} ++ ++/* pptp_release_chan() */ ++static void pptp_release_chan(struct ppp_channel *chan) ++{ ++ struct sock *sk = (struct sock *)chan->private; ++ ++ sock_put(sk); ++} ++ ++/* pptp_get_channel_protocol() ++ * Return the protocol type of the PPTP over PPP protocol ++ */ ++static int pptp_get_channel_protocol(struct ppp_channel *chan) ++{ ++ return PX_PROTO_PPTP; ++} ++ + static const struct ppp_channel_ops pptp_chan_ops = { + .start_xmit = pptp_xmit, + .ioctl = pptp_ppp_ioctl, ++ .get_channel_protocol = pptp_get_channel_protocol, ++ .hold = pptp_hold_chan, ++ .release = pptp_release_chan, + }; + + static struct proto pptp_sk_proto __read_mostly = { diff --git a/lede/target/linux/qualcommax/patches-6.1/0603-4-qca-nss-clients-add-iptunnel-support.patch b/lede/target/linux/qualcommax/patches-6.1/0603-4-qca-nss-clients-add-iptunnel-support.patch new file mode 100644 index 0000000000..928510087d --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0603-4-qca-nss-clients-add-iptunnel-support.patch @@ -0,0 +1,77 @@ +--- a/include/net/ip6_tunnel.h ++++ b/include/net/ip6_tunnel.h +@@ -36,6 +36,7 @@ struct __ip6_tnl_parm { + __u8 proto; /* tunnel protocol */ + __u8 encap_limit; /* encapsulation limit for tunnel */ + __u8 hop_limit; /* hop limit for tunnel */ ++ __u8 draft03; /* FMR using draft03 of map-e - QCA NSS Clients Support */ + bool collect_md; + __be32 flowinfo; /* traffic class and flowlabel for tunnel */ + __u32 flags; /* tunnel flags */ +--- a/include/net/ip_tunnels.h ++++ b/include/net/ip_tunnels.h +@@ -553,4 +553,9 @@ static inline void ip_tunnel_info_opts_s + + #endif /* CONFIG_INET */ + ++/* QCA NSS Clients Support - Start */ ++void ipip6_update_offload_stats(struct net_device *dev, void *ptr); ++void ip6_update_offload_stats(struct net_device *dev, void *ptr); ++/* QCA NSS Clients Support - End */ ++ + #endif /* __NET_IP_TUNNELS_H */ +--- a/net/ipv6/ip6_tunnel.c ++++ b/net/ipv6/ip6_tunnel.c +@@ -2398,6 +2398,26 @@ nla_put_failure: + return -EMSGSIZE; + } + ++/* QCA NSS Client Support - Start */ ++/* ++ * Update offload stats ++ */ ++void ip6_update_offload_stats(struct net_device *dev, void *ptr) ++{ ++ struct pcpu_sw_netstats *tstats = per_cpu_ptr(dev->tstats, 0); ++ const struct pcpu_sw_netstats *offload_stats = ++ (struct pcpu_sw_netstats *)ptr; ++ ++ u64_stats_update_begin(&tstats->syncp); ++ u64_stats_add(&tstats->tx_packets, u64_stats_read(&offload_stats->tx_packets)); ++ u64_stats_add(&tstats->tx_bytes, u64_stats_read(&offload_stats->tx_bytes)); ++ u64_stats_add(&tstats->rx_packets, u64_stats_read(&offload_stats->rx_packets)); ++ u64_stats_add(&tstats->rx_bytes, u64_stats_read(&offload_stats->rx_bytes)); ++ u64_stats_update_end(&tstats->syncp); ++} ++EXPORT_SYMBOL(ip6_update_offload_stats); ++/* QCA NSS Client Support - End */ ++ + struct net *ip6_tnl_get_link_net(const struct net_device *dev) + { + struct ip6_tnl *tunnel = netdev_priv(dev); +--- a/net/ipv6/sit.c ++++ b/net/ipv6/sit.c +@@ -1733,6 +1733,23 @@ nla_put_failure: + return -EMSGSIZE; + } + ++/* QCA NSS Clients Support - Start */ ++void ipip6_update_offload_stats(struct net_device *dev, void *ptr) ++{ ++ struct pcpu_sw_netstats *tstats = per_cpu_ptr(dev->tstats, 0); ++ const struct pcpu_sw_netstats *offload_stats = ++ (struct pcpu_sw_netstats *)ptr; ++ ++ u64_stats_update_begin(&tstats->syncp); ++ u64_stats_add(&tstats->tx_packets, u64_stats_read(&offload_stats->tx_packets)); ++ u64_stats_add(&tstats->tx_bytes, u64_stats_read(&offload_stats->tx_bytes)); ++ u64_stats_add(&tstats->rx_packets, u64_stats_read(&offload_stats->rx_packets)); ++ u64_stats_add(&tstats->rx_bytes, u64_stats_read(&offload_stats->rx_bytes)); ++ u64_stats_update_end(&tstats->syncp); ++} ++EXPORT_SYMBOL(ipip6_update_offload_stats); ++/* QCA NSS Clients Support - End */ ++ + static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = { + [IFLA_IPTUN_LINK] = { .type = NLA_U32 }, + [IFLA_IPTUN_LOCAL] = { .type = NLA_U32 }, diff --git a/lede/target/linux/qualcommax/patches-6.1/0603-5-qca-nss-clients-add-vxlan-support.patch b/lede/target/linux/qualcommax/patches-6.1/0603-5-qca-nss-clients-add-vxlan-support.patch new file mode 100644 index 0000000000..8c14040bb5 --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0603-5-qca-nss-clients-add-vxlan-support.patch @@ -0,0 +1,107 @@ +--- a/drivers/net/vxlan/vxlan_core.c ++++ b/drivers/net/vxlan/vxlan_core.c +@@ -71,6 +71,20 @@ static inline bool vxlan_collect_metadat + ip_tunnel_collect_metadata(); + } + ++ATOMIC_NOTIFIER_HEAD(vxlan_fdb_notifier_list); ++ ++void vxlan_fdb_register_notify(struct notifier_block *nb) ++{ ++ atomic_notifier_chain_register(&vxlan_fdb_notifier_list, nb); ++} ++EXPORT_SYMBOL(vxlan_fdb_register_notify); ++ ++void vxlan_fdb_unregister_notify(struct notifier_block *nb) ++{ ++ atomic_notifier_chain_unregister(&vxlan_fdb_notifier_list, nb); ++} ++EXPORT_SYMBOL(vxlan_fdb_unregister_notify); ++ + #if IS_ENABLED(CONFIG_IPV6) + static int vxlan_nla_get_addr(union vxlan_addr *ip, struct nlattr *nla) + { +@@ -307,6 +321,7 @@ static void __vxlan_fdb_notify(struct vx + { + struct net *net = dev_net(vxlan->dev); + struct sk_buff *skb; ++ struct vxlan_fdb_event vfe; + int err = -ENOBUFS; + + skb = nlmsg_new(vxlan_nlmsg_size(), GFP_ATOMIC); +@@ -322,7 +337,11 @@ static void __vxlan_fdb_notify(struct vx + } + + rtnl_notify(skb, net, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC); +- return; ++ vfe.dev = vxlan->dev; ++ vfe.rdst = rd; ++ ether_addr_copy(vfe.eth_addr, fdb->eth_addr); ++ atomic_notifier_call_chain(&vxlan_fdb_notifier_list, type, (void *)&vfe); ++ return; + errout: + if (err < 0) + rtnl_set_sk_err(net, RTNLGRP_NEIGH, err); +@@ -488,6 +507,18 @@ static struct vxlan_fdb *vxlan_find_mac( + return f; + } + ++/* Find and update age of fdb entry corresponding to MAC. */ ++void vxlan_fdb_update_mac(struct vxlan_dev *vxlan, const u8 *mac, uint32_t vni) ++{ ++ u32 hash_index; ++ ++ hash_index = fdb_head_index(vxlan, mac, vni); ++ spin_lock_bh(&vxlan->hash_lock[hash_index]); ++ vxlan_find_mac(vxlan, mac, vni); ++ spin_unlock_bh(&vxlan->hash_lock[hash_index]); ++} ++EXPORT_SYMBOL(vxlan_fdb_update_mac); ++ + /* caller should hold vxlan->hash_lock */ + static struct vxlan_rdst *vxlan_fdb_find_rdst(struct vxlan_fdb *f, + union vxlan_addr *ip, __be16 port, +@@ -2654,6 +2685,9 @@ static void vxlan_xmit_one(struct sk_buf + goto out_unlock; + } + ++ /* Reset the skb_iif to Tunnels interface index */ ++ skb->skb_iif = dev->ifindex; ++ + tos = ip_tunnel_ecn_encap(tos, old_iph, skb); + ttl = ttl ? : ip4_dst_hoplimit(&rt->dst); + err = vxlan_build_skb(skb, ndst, sizeof(struct iphdr), +@@ -2725,7 +2759,10 @@ static void vxlan_xmit_one(struct sk_buf + if (err < 0) + goto tx_error; + +- udp_tunnel6_xmit_skb(ndst, sock6->sock->sk, skb, dev, ++ /* Reset the skb_iif to Tunnels interface index */ ++ skb->skb_iif = dev->ifindex; ++ ++ udp_tunnel6_xmit_skb(ndst, sock6->sock->sk, skb, dev, + &local_ip.sin6.sin6_addr, + &dst->sin6.sin6_addr, tos, ttl, + label, src_port, dst_port, !udp_sum); +--- a/include/net/vxlan.h ++++ b/include/net/vxlan.h +@@ -344,6 +344,19 @@ struct vxlan_dev { + VXLAN_F_COLLECT_METADATA | \ + VXLAN_F_VNIFILTER) + ++/* ++ * Application data for fdb notifier event ++ */ ++struct vxlan_fdb_event { ++ struct net_device *dev; ++ struct vxlan_rdst *rdst; ++ u8 eth_addr[ETH_ALEN]; ++}; ++ ++extern void vxlan_fdb_register_notify(struct notifier_block *nb); ++extern void vxlan_fdb_unregister_notify(struct notifier_block *nb); ++extern void vxlan_fdb_update_mac(struct vxlan_dev *vxlan, const u8 *mac, uint32_t vni); ++ + struct net_device *vxlan_dev_create(struct net *net, const char *name, + u8 name_assign_type, struct vxlan_config *conf); + diff --git a/lede/target/linux/qualcommax/patches-6.1/0603-6-qca-nss-clients-add-l2tp-offloading-support.patch b/lede/target/linux/qualcommax/patches-6.1/0603-6-qca-nss-clients-add-l2tp-offloading-support.patch new file mode 100644 index 0000000000..4032eb3c22 --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0603-6-qca-nss-clients-add-l2tp-offloading-support.patch @@ -0,0 +1,368 @@ +--- a/include/linux/ppp_channel.h ++++ b/include/linux/ppp_channel.h +@@ -61,6 +61,51 @@ struct ppp_channel { + }; + + #ifdef __KERNEL__ ++/* Call this to obtain the underlying protocol of the PPP channel, ++ * e.g. PX_PROTO_OE ++ */ ++extern int ppp_channel_get_protocol(struct ppp_channel *); ++ ++/* Call this to hold a channel */ ++extern bool ppp_channel_hold(struct ppp_channel *); ++ ++/* Call this to release a hold you have upon a channel */ ++extern void ppp_channel_release(struct ppp_channel *); ++ ++/* Release hold on PPP channels */ ++extern void ppp_release_channels(struct ppp_channel *channels[], ++ unsigned int chan_sz); ++ ++/* Test if ppp xmit lock is locked */ ++extern bool ppp_is_xmit_locked(struct net_device *dev); ++ ++/* Call this get protocol version */ ++extern int ppp_channel_get_proto_version(struct ppp_channel *); ++ ++/* Get the device index associated with a channel, or 0, if none */ ++extern int ppp_dev_index(struct ppp_channel *); ++ ++/* Hold PPP channels for the PPP device */ ++extern int ppp_hold_channels(struct net_device *dev, ++ struct ppp_channel *channels[], ++ unsigned int chan_sz); ++extern int __ppp_hold_channels(struct net_device *dev, ++ struct ppp_channel *channels[], ++ unsigned int chan_sz); ++ ++/* Test if the ppp device is a multi-link ppp device */ ++extern int ppp_is_multilink(struct net_device *dev); ++extern int __ppp_is_multilink(struct net_device *dev); ++ ++/* Update statistics of the PPP net_device by incrementing related ++ * statistics field value with corresponding parameter ++ */ ++extern void ppp_update_stats(struct net_device *dev, unsigned long rx_packets, ++ unsigned long rx_bytes, unsigned long tx_packets, ++ unsigned long tx_bytes, unsigned long rx_errors, ++ unsigned long tx_errors, unsigned long rx_dropped, ++ unsigned long tx_dropped); ++ + /* Called by the channel when it can send some more data. */ + extern void ppp_output_wakeup(struct ppp_channel *); + +@@ -148,5 +193,17 @@ extern void ppp_update_stats(struct net_ + * that ppp_unregister_channel returns. + */ + ++/* QCA NSS Clients Support - Start */ ++/* PPP channel connection event types */ ++#define PPP_CHANNEL_DISCONNECT 0 ++#define PPP_CHANNEL_CONNECT 1 ++ ++/* Register the PPP channel connect notifier */ ++extern void ppp_channel_connection_register_notify(struct notifier_block *nb); ++ ++/* Unregister the PPP channel connect notifier */ ++extern void ppp_channel_connection_unregister_notify(struct notifier_block *nb); ++/* QCA NSS Clients Support - End */ ++ + #endif /* __KERNEL__ */ + #endif +--- a/include/linux/if_pppol2tp.h ++++ b/include/linux/if_pppol2tp.h +@@ -12,4 +12,30 @@ + #include + #include + ++/* QCA NSS ECM support - Start */ ++/* ++ * Holds L2TP channel info ++ */ ++struct pppol2tp_common_addr { ++ int tunnel_version; /* v2 or v3 */ ++ __u32 local_tunnel_id, remote_tunnel_id; /* tunnel id */ ++ __u32 local_session_id, remote_session_id; /* session id */ ++ struct sockaddr_in local_addr, remote_addr; /* ip address and port */ ++}; ++ ++/* ++ * L2TP channel operations ++ */ ++struct pppol2tp_channel_ops { ++ struct ppp_channel_ops ops; /* ppp channel ops */ ++}; ++ ++/* ++ * exported function which calls pppol2tp channel's get addressing ++ * function ++ */ ++extern int pppol2tp_channel_addressing_get(struct ppp_channel *, ++ struct pppol2tp_common_addr *); ++/* QCA NSS ECM support - End */ ++ + #endif +--- a/net/l2tp/l2tp_ppp.c ++++ b/net/l2tp/l2tp_ppp.c +@@ -123,9 +123,17 @@ struct pppol2tp_session { + }; + + static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb); +- +-static const struct ppp_channel_ops pppol2tp_chan_ops = { +- .start_xmit = pppol2tp_xmit, ++static int pppol2tp_get_channel_protocol(struct ppp_channel *); ++static int pppol2tp_get_channel_protocol_ver(struct ppp_channel *); ++static void pppol2tp_hold_chan(struct ppp_channel *); ++static void pppol2tp_release_chan(struct ppp_channel *); ++ ++static const struct pppol2tp_channel_ops pppol2tp_chan_ops = { ++ .ops.start_xmit = pppol2tp_xmit, ++ .ops.get_channel_protocol = pppol2tp_get_channel_protocol, ++ .ops.get_channel_protocol_ver = pppol2tp_get_channel_protocol_ver, ++ .ops.hold = pppol2tp_hold_chan, ++ .ops.release = pppol2tp_release_chan, + }; + + static const struct proto_ops pppol2tp_ops; +@@ -373,6 +381,13 @@ static int pppol2tp_xmit(struct ppp_chan + skb->data[0] = PPP_ALLSTATIONS; + skb->data[1] = PPP_UI; + ++ /* QCA NSS ECM support - start */ ++ /* set incoming interface as the ppp interface */ ++ if ((skb->protocol == htons(ETH_P_IP)) || ++ (skb->protocol == htons(ETH_P_IPV6))) ++ skb->skb_iif = ppp_dev_index(chan); ++ /* QCA NSS ECM support - End */ ++ + local_bh_disable(); + l2tp_xmit_skb(session, skb); + local_bh_enable(); +@@ -818,7 +833,7 @@ static int pppol2tp_connect(struct socke + po->chan.hdrlen = PPPOL2TP_L2TP_HDR_SIZE_NOSEQ; + + po->chan.private = sk; +- po->chan.ops = &pppol2tp_chan_ops; ++ po->chan.ops = (struct ppp_channel_ops *)&pppol2tp_chan_ops.ops; + po->chan.mtu = pppol2tp_tunnel_mtu(tunnel); + + error = ppp_register_net_channel(sock_net(sk), &po->chan); +@@ -1732,6 +1747,109 @@ static void __exit pppol2tp_exit(void) + unregister_pernet_device(&pppol2tp_net_ops); + } + ++/* QCA NSS ECM support - Start */ ++/* pppol2tp_hold_chan() */ ++static void pppol2tp_hold_chan(struct ppp_channel *chan) ++{ ++ struct sock *sk = (struct sock *)chan->private; ++ ++ sock_hold(sk); ++} ++ ++/* pppol2tp_release_chan() */ ++static void pppol2tp_release_chan(struct ppp_channel *chan) ++{ ++ struct sock *sk = (struct sock *)chan->private; ++ ++ sock_put(sk); ++} ++ ++/* pppol2tp_get_channel_protocol() ++ * Return the protocol type of the L2TP over PPP protocol ++ */ ++static int pppol2tp_get_channel_protocol(struct ppp_channel *chan) ++{ ++ return PX_PROTO_OL2TP; ++} ++ ++/* pppol2tp_get_channel_protocol_ver() ++ * Return the protocol version of the L2TP over PPP protocol ++ */ ++static int pppol2tp_get_channel_protocol_ver(struct ppp_channel *chan) ++{ ++ struct sock *sk; ++ struct l2tp_session *session; ++ struct l2tp_tunnel *tunnel; ++ int version = 0; ++ ++ if (chan && chan->private) ++ sk = (struct sock *)chan->private; ++ else ++ return -1; ++ ++ /* Get session and tunnel contexts from the socket */ ++ session = pppol2tp_sock_to_session(sk); ++ if (!session) ++ return -1; ++ ++ tunnel = session->tunnel; ++ if (!tunnel) { ++ sock_put(sk); ++ return -1; ++ } ++ ++ version = tunnel->version; ++ ++ sock_put(sk); ++ ++ return version; ++} ++ ++/* pppol2tp_get_addressing() */ ++static int pppol2tp_get_addressing(struct ppp_channel *chan, ++ struct pppol2tp_common_addr *addr) ++{ ++ struct sock *sk = (struct sock *)chan->private; ++ struct l2tp_session *session; ++ struct l2tp_tunnel *tunnel; ++ struct inet_sock *isk = NULL; ++ int err = -ENXIO; ++ ++ /* Get session and tunnel contexts from the socket */ ++ session = pppol2tp_sock_to_session(sk); ++ if (!session) ++ return err; ++ ++ tunnel = session->tunnel; ++ if (!tunnel) { ++ sock_put(sk); ++ return err; ++ } ++ isk = inet_sk(tunnel->sock); ++ ++ addr->local_tunnel_id = tunnel->tunnel_id; ++ addr->remote_tunnel_id = tunnel->peer_tunnel_id; ++ addr->local_session_id = session->session_id; ++ addr->remote_session_id = session->peer_session_id; ++ ++ addr->local_addr.sin_port = isk->inet_sport; ++ addr->remote_addr.sin_port = isk->inet_dport; ++ addr->local_addr.sin_addr.s_addr = isk->inet_saddr; ++ addr->remote_addr.sin_addr.s_addr = isk->inet_daddr; ++ ++ sock_put(sk); ++ return 0; ++} ++ ++/* pppol2tp_channel_addressing_get() */ ++int pppol2tp_channel_addressing_get(struct ppp_channel *chan, ++ struct pppol2tp_common_addr *addr) ++{ ++ return pppol2tp_get_addressing(chan, addr); ++} ++EXPORT_SYMBOL(pppol2tp_channel_addressing_get); ++/* QCA NSS ECM support - End */ ++ + module_init(pppol2tp_init); + module_exit(pppol2tp_exit); + +--- a/drivers/net/ppp/ppp_generic.c ++++ b/drivers/net/ppp/ppp_generic.c +@@ -3743,6 +3743,32 @@ int ppp_is_multilink(struct net_device * + } + EXPORT_SYMBOL(ppp_is_multilink); + ++/* __ppp_is_multilink() ++ * Returns >0 if the device is a multilink PPP netdevice, 0 if not or < 0 ++ * if the device is not PPP. Caller should acquire ppp_lock before calling ++ * this function ++ */ ++int __ppp_is_multilink(struct net_device *dev) ++{ ++ struct ppp *ppp; ++ unsigned int flags; ++ ++ if (!dev) ++ return -1; ++ ++ if (dev->type != ARPHRD_PPP) ++ return -1; ++ ++ ppp = netdev_priv(dev); ++ flags = ppp->flags; ++ ++ if (flags & SC_MULTILINK) ++ return 1; ++ ++ return 0; ++} ++EXPORT_SYMBOL(__ppp_is_multilink); ++ + /* ppp_channel_get_protocol() + * Call this to obtain the underlying protocol of the PPP channel, + * e.g. PX_PROTO_OE +@@ -3881,6 +3907,59 @@ int ppp_hold_channels(struct net_device + } + EXPORT_SYMBOL(ppp_hold_channels); + ++/* __ppp_hold_channels() ++ * Returns the PPP channels of the PPP device, storing each one into ++ * channels[]. ++ * ++ * channels[] has chan_sz elements. ++ * This function returns the number of channels stored, up to chan_sz. ++ * It will return < 0 if the device is not PPP. ++ * ++ * You MUST release the channels using ppp_release_channels(). ++ */ ++int __ppp_hold_channels(struct net_device *dev, struct ppp_channel *channels[], ++ unsigned int chan_sz) ++{ ++ struct ppp *ppp; ++ int c; ++ struct channel *pch; ++ ++ if (!dev) ++ return -1; ++ ++ if (dev->type != ARPHRD_PPP) ++ return -1; ++ ++ ppp = netdev_priv(dev); ++ ++ c = 0; ++ list_for_each_entry(pch, &ppp->channels, clist) { ++ struct ppp_channel *chan; ++ ++ if (!pch->chan) { ++ /* Channel is going / gone away */ ++ continue; ++ } ++ ++ if (c == chan_sz) { ++ /* No space to record channel */ ++ return c; ++ } ++ ++ /* Hold the channel, if supported */ ++ chan = pch->chan; ++ if (!chan->ops->hold) ++ continue; ++ ++ chan->ops->hold(chan); ++ ++ /* Record the channel */ ++ channels[c++] = chan; ++ } ++ return c; ++} ++EXPORT_SYMBOL(__ppp_hold_channels); ++ + /* ppp_release_channels() + * Releases channels + */ +--- a/net/l2tp/l2tp_core.h ++++ b/net/l2tp/l2tp_core.h +@@ -235,6 +235,9 @@ struct l2tp_session *l2tp_session_get_by + void l2tp_stats_update(struct l2tp_tunnel *tunnel, struct l2tp_session *session, + struct l2tp_stats *stats); + ++void l2tp_stats_update(struct l2tp_tunnel *tunnel, struct l2tp_session *session, ++ struct l2tp_stats *stats); ++ + /* Tunnel and session lifetime management. + * Creation of a new instance is a two-step process: create, then register. + * Destruction is triggered using the *_delete functions, and completes asynchronously. diff --git a/lede/target/linux/qualcommax/patches-6.1/0603-7-qca-nss-clients-iptunnel-lock-this-cpu.patch b/lede/target/linux/qualcommax/patches-6.1/0603-7-qca-nss-clients-iptunnel-lock-this-cpu.patch new file mode 100644 index 0000000000..faba23d863 --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0603-7-qca-nss-clients-iptunnel-lock-this-cpu.patch @@ -0,0 +1,22 @@ +--- a/net/ipv6/ip6_tunnel.c ++++ b/net/ipv6/ip6_tunnel.c +@@ -2404,7 +2404,7 @@ nla_put_failure: + */ + void ip6_update_offload_stats(struct net_device *dev, void *ptr) + { +- struct pcpu_sw_netstats *tstats = per_cpu_ptr(dev->tstats, 0); ++ struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); + const struct pcpu_sw_netstats *offload_stats = + (struct pcpu_sw_netstats *)ptr; + +--- a/net/ipv6/sit.c ++++ b/net/ipv6/sit.c +@@ -1736,7 +1736,7 @@ nla_put_failure: + /* QCA NSS Clients Support - Start */ + void ipip6_update_offload_stats(struct net_device *dev, void *ptr) + { +- struct pcpu_sw_netstats *tstats = per_cpu_ptr(dev->tstats, 0); ++ struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); + const struct pcpu_sw_netstats *offload_stats = + (struct pcpu_sw_netstats *)ptr; + diff --git a/lede/target/linux/qualcommax/patches-6.1/0603-8-qca-nss-clients-add-tls-mgr-support.patch b/lede/target/linux/qualcommax/patches-6.1/0603-8-qca-nss-clients-add-tls-mgr-support.patch new file mode 100644 index 0000000000..0499e237f6 --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0603-8-qca-nss-clients-add-tls-mgr-support.patch @@ -0,0 +1,24 @@ +--- /dev/null ++++ b/include/uapi/linux/tlshdr.h +@@ -0,0 +1,21 @@ ++#ifndef _UAPI_LINUX_TLSHDR_H ++#define _UAPI_LINUX_TLSHDR_H ++ ++#include ++ ++struct tlshdr { ++ __u8 type; ++ __be16 version; ++ __be16 len; ++} __attribute__((packed)); ++ ++#define TLSHDR_REC_TYPE_CCS 20 /* TLS packet is change cipher specification */ ++#define TLSHDR_REC_TYPE_ALERT 21 /* TLS packet is Alert */ ++#define TLSHDR_REC_TYPE_HANDSHAKE 22 /* TLS packet is Handshake */ ++#define TLSHDR_REC_TYPE_DATA 23 /* TLS packet is Application data */ ++ ++#define TLSHDR_VERSION_1_1 0x0302 /* TLS Header Version(tls 1.1) */ ++#define TLSHDR_VERSION_1_2 0x0303 /* TLS Header Version(tls 1.2) */ ++#define TLSHDR_VERSION_1_3 0x0304 /* TLS Header Version(tls 1.3) */ ++ ++#endif /* _UAPI_LINUX_TLSHDR_H */ diff --git a/lede/target/linux/qualcommax/patches-6.1/0605-qca-nss-cfi-support.patch b/lede/target/linux/qualcommax/patches-6.1/0605-qca-nss-cfi-support.patch new file mode 100644 index 0000000000..67e85a18fa --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0605-qca-nss-cfi-support.patch @@ -0,0 +1,111 @@ +--- a/crypto/authenc.c ++++ b/crypto/authenc.c +@@ -417,6 +417,8 @@ static int crypto_authenc_create(struct + enc->base.cra_driver_name) >= CRYPTO_MAX_ALG_NAME) + goto err_free_inst; + ++ inst->alg.base.cra_flags |= (auth_base->cra_flags | ++ enc->base.cra_flags) & CRYPTO_ALG_NOSUPP_SG; + inst->alg.base.cra_priority = enc->base.cra_priority * 10 + + auth_base->cra_priority; + inst->alg.base.cra_blocksize = enc->base.cra_blocksize; +--- a/include/linux/crypto.h ++++ b/include/linux/crypto.h +@@ -101,6 +101,11 @@ + #define CRYPTO_NOLOAD 0x00008000 + + /* ++ * Set this flag if algorithm does not support SG list transforms ++ */ ++#define CRYPTO_ALG_NOSUPP_SG 0x0000c000 ++ ++/* + * The algorithm may allocate memory during request processing, i.e. during + * encryption, decryption, or hashing. Users can request an algorithm with this + * flag unset if they can't handle memory allocation failures. +--- a/net/ipv4/esp4.c ++++ b/net/ipv4/esp4.c +@@ -658,6 +658,7 @@ static int esp_output(struct xfrm_state + struct ip_esp_hdr *esph; + struct crypto_aead *aead; + struct esp_info esp; ++ bool nosupp_sg; + + esp.inplace = true; + +@@ -669,6 +670,11 @@ static int esp_output(struct xfrm_state + aead = x->data; + alen = crypto_aead_authsize(aead); + ++ nosupp_sg = crypto_tfm_alg_type(&aead->base) & CRYPTO_ALG_NOSUPP_SG; ++ if (nosupp_sg && skb_linearize(skb)) { ++ return -ENOMEM; ++ } ++ + esp.tfclen = 0; + if (x->tfcpad) { + struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb); +@@ -890,6 +896,7 @@ static int esp_input(struct xfrm_state * + u8 *iv; + struct scatterlist *sg; + int err = -EINVAL; ++ bool nosupp_sg; + + if (!pskb_may_pull(skb, sizeof(struct ip_esp_hdr) + ivlen)) + goto out; +@@ -897,6 +904,12 @@ static int esp_input(struct xfrm_state * + if (elen <= 0) + goto out; + ++ nosupp_sg = crypto_tfm_alg_type(&aead->base) & CRYPTO_ALG_NOSUPP_SG; ++ if (nosupp_sg && skb_linearize(skb)) { ++ err = -ENOMEM; ++ goto out; ++ } ++ + assoclen = sizeof(struct ip_esp_hdr); + seqhilen = 0; + +--- a/net/ipv6/esp6.c ++++ b/net/ipv6/esp6.c +@@ -696,6 +696,7 @@ static int esp6_output(struct xfrm_state + struct ip_esp_hdr *esph; + struct crypto_aead *aead; + struct esp_info esp; ++ bool nosupp_sg; + + esp.inplace = true; + +@@ -707,6 +708,11 @@ static int esp6_output(struct xfrm_state + aead = x->data; + alen = crypto_aead_authsize(aead); + ++ nosupp_sg = crypto_tfm_alg_type(&aead->base) & CRYPTO_ALG_NOSUPP_SG; ++ if (nosupp_sg && skb_linearize(skb)) { ++ return -ENOMEM; ++ } ++ + esp.tfclen = 0; + if (x->tfcpad) { + struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb); +@@ -934,6 +940,7 @@ static int esp6_input(struct xfrm_state + __be32 *seqhi; + u8 *iv; + struct scatterlist *sg; ++ bool nosupp_sg; + + if (!pskb_may_pull(skb, sizeof(struct ip_esp_hdr) + ivlen)) { + ret = -EINVAL; +@@ -945,6 +952,12 @@ static int esp6_input(struct xfrm_state + goto out; + } + ++ nosupp_sg = crypto_tfm_alg_type(&aead->base) & CRYPTO_ALG_NOSUPP_SG; ++ if (nosupp_sg && skb_linearize(skb)) { ++ ret = -ENOMEM; ++ goto out; ++ } ++ + assoclen = sizeof(struct ip_esp_hdr); + seqhilen = 0; + diff --git a/lede/target/linux/qualcommax/patches-6.1/0611-ipv6-Fix-null-pointer-dereference-in-ipv6-output.patch b/lede/target/linux/qualcommax/patches-6.1/0611-ipv6-Fix-null-pointer-dereference-in-ipv6-output.patch new file mode 100644 index 0000000000..25f99fc4ad --- /dev/null +++ b/lede/target/linux/qualcommax/patches-6.1/0611-ipv6-Fix-null-pointer-dereference-in-ipv6-output.patch @@ -0,0 +1,80 @@ +From eee3a7956b943dd3e23a74fbb5bfe89405eb0782 Mon Sep 17 00:00:00 2001 +From: Andrea Righi +Date: Mon, 6 Dec 2021 17:34:47 +0100 +Subject: UBUNTU: SAUCE: ipv6: fix NULL pointer dereference in ip6_output() + +It is possible to trigger a NULL pointer dereference by running the srv6 +net kselftest (tools/testing/selftests/net/srv6_end_dt46_l3vpn_test.sh): + +[ 249.051216] BUG: kernel NULL pointer dereference, address: 0000000000000378 +[ 249.052331] #PF: supervisor read access in kernel mode +[ 249.053137] #PF: error_code(0x0000) - not-present page +[ 249.053960] PGD 0 P4D 0 +[ 249.054376] Oops: 0000 [#1] PREEMPT SMP NOPTI +[ 249.055083] CPU: 1 PID: 21 Comm: ksoftirqd/1 Tainted: G E 5.16.0-rc4 #2 +[ 249.056328] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014 +[ 249.057632] RIP: 0010:ip6_forward+0x53c/0xab0 +[ 249.058354] Code: 49 c7 44 24 20 00 00 00 00 48 83 e0 fe 48 8b 40 30 48 3d 70 b2 b5 81 0f 85 b5 04 00 00 e8 7c f2 ff ff 41 89 c5 e9 17 01 00 00 <44> 8b 93 78 03 00 00 45 85 d2 0f 85 92 fb ff ff 49 8b 54 24 10 48 +[ 249.061274] RSP: 0018:ffffc900000cbb30 EFLAGS: 00010246 +[ 249.062042] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff8881051d3400 +[ 249.063141] RDX: ffff888104bda000 RSI: 00000000000002c0 RDI: 0000000000000000 +[ 249.064264] RBP: ffffc900000cbbc8 R08: 0000000000000000 R09: 0000000000000000 +[ 249.065376] R10: 0000000000000040 R11: 0000000000000000 R12: ffff888103409800 +[ 249.066498] R13: ffff8881051d3410 R14: ffff888102725280 R15: ffff888103525000 +[ 249.067619] FS: 0000000000000000(0000) GS:ffff88813bc80000(0000) knlGS:0000000000000000 +[ 249.068881] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +[ 249.069777] CR2: 0000000000000378 CR3: 0000000104980000 CR4: 0000000000750ee0 +[ 249.070907] PKRU: 55555554 +[ 249.071337] Call Trace: +[ 249.071730] +[ 249.072070] ? debug_smp_processor_id+0x17/0x20 +[ 249.072807] seg6_input_core+0x2bb/0x2d0 +[ 249.073436] ? _raw_spin_unlock_irqrestore+0x29/0x40 +[ 249.074225] seg6_input+0x3b/0x130 +[ 249.074768] lwtunnel_input+0x5e/0xa0 +[ 249.075357] ip_rcv+0x17b/0x190 +[ 249.075867] ? update_load_avg+0x82/0x600 +[ 249.076514] __netif_receive_skb_one_core+0x86/0xa0 +[ 249.077231] __netif_receive_skb+0x15/0x60 +[ 249.077843] process_backlog+0x97/0x160 +[ 249.078389] __napi_poll+0x31/0x170 +[ 249.078912] net_rx_action+0x229/0x270 +[ 249.079506] __do_softirq+0xef/0x2ed +[ 249.080085] run_ksoftirqd+0x37/0x50 +[ 249.080663] smpboot_thread_fn+0x193/0x230 +[ 249.081312] kthread+0x17a/0x1a0 +[ 249.081847] ? smpboot_register_percpu_thread+0xe0/0xe0 +[ 249.082677] ? set_kthread_struct+0x50/0x50 +[ 249.083340] ret_from_fork+0x22/0x30 +[ 249.083926] +[ 249.090295] ---[ end trace 1998d7ba5965a365 ]--- + +It looks like commit 0857d6f8c759 ("ipv6: When forwarding count rx stats +on the orig netdev") tries to determine the right netdev to account the +rx stats, but in this particular case it's failing and the netdev is +NULL. + +Fallback to the previous method of determining the netdev interface (via +skb->dev) to account the rx stats when the orig netdev can't be +determined. + +Fixes: 0857d6f8c759 ("ipv6: When forwarding count rx stats on the orig netdev") +Signed-off-by: Andrea Righi +(cherry picked from https://lore.kernel.org/lkml/20211206163447.991402-1-andrea.righi@canonical.com/T/#u) +Signed-off-by: Andrea Righi +--- + net/ipv6/ip6_output.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/net/ipv6/ip6_output.c ++++ b/net/ipv6/ip6_output.c +@@ -498,6 +498,9 @@ int ip6_forward(struct sk_buff *skb) + u32 mtu; + + idev = __in6_dev_get_safely(dev_get_by_index_rcu(net, IP6CB(skb)->iif)); ++ if (unlikely(!idev)) ++ idev = __in6_dev_get_safely(skb->dev); ++ + if (net->ipv6.devconf_all->forwarding == 0) + goto error; + diff --git a/mieru/go.mod b/mieru/go.mod index 374bf57f03..01f81d9bb7 100644 --- a/mieru/go.mod +++ b/mieru/go.mod @@ -4,15 +4,14 @@ go 1.20 require ( github.com/google/btree v1.1.2 - golang.org/x/crypto v0.21.0 - golang.org/x/sys v0.18.0 - google.golang.org/grpc v1.62.0 - google.golang.org/protobuf v1.33.0 + golang.org/x/crypto v0.24.0 + golang.org/x/sys v0.21.0 + google.golang.org/grpc v1.64.0 + google.golang.org/protobuf v1.34.2 ) require ( - github.com/golang/protobuf v1.5.3 // indirect golang.org/x/net v0.23.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect + golang.org/x/text v0.16.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 // indirect ) diff --git a/mieru/go.sum b/mieru/go.sum index 074667d4f7..e81a2cb806 100644 --- a/mieru/go.sum +++ b/mieru/go.sum @@ -1,24 +1,17 @@ -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= -google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk= -google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 h1:9Xyg6I9IWQZhRVfCWjKK+l6kI0jHcPesVlMnT//aHNo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= +google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= diff --git a/mihomo/dns/dialer.go b/mihomo/dns/dialer.go new file mode 100644 index 0000000000..309b6c1886 --- /dev/null +++ b/mihomo/dns/dialer.go @@ -0,0 +1,12 @@ +package dns + +// export functions from tunnel module + +import "github.com/metacubex/mihomo/tunnel" + +const RespectRules = tunnel.DnsRespectRules + +type dialHandler = tunnel.DnsDialHandler + +var getDialHandler = tunnel.GetDnsDialHandler +var listenPacket = tunnel.DnsListenPacket diff --git a/mihomo/dns/dial.go b/mihomo/tunnel/dns_dialer.go similarity index 77% rename from mihomo/dns/dial.go rename to mihomo/tunnel/dns_dialer.go index 431707c56f..f4c0be7139 100644 --- a/mihomo/dns/dial.go +++ b/mihomo/tunnel/dns_dialer.go @@ -1,4 +1,6 @@ -package dns +package tunnel + +// WARNING: all function in this file should only be using in dns module import ( "context" @@ -11,15 +13,14 @@ import ( "github.com/metacubex/mihomo/component/dialer" "github.com/metacubex/mihomo/component/resolver" C "github.com/metacubex/mihomo/constant" - "github.com/metacubex/mihomo/tunnel" "github.com/metacubex/mihomo/tunnel/statistic" ) -const RespectRules = "RULES" +const DnsRespectRules = "RULES" -type dialHandler func(ctx context.Context, network, addr string) (net.Conn, error) +type DnsDialHandler func(ctx context.Context, network, addr string) (net.Conn, error) -func getDialHandler(r *Resolver, proxyAdapter C.ProxyAdapter, proxyName string, opts ...dialer.Option) dialHandler { +func GetDnsDialHandler(r resolver.Resolver, proxyAdapter C.ProxyAdapter, proxyName string, opts ...dialer.Option) DnsDialHandler { return func(ctx context.Context, network, addr string) (net.Conn, error) { if len(proxyName) == 0 && proxyAdapter == nil { opts = append(opts, dialer.WithResolver(r)) @@ -47,22 +48,22 @@ func getDialHandler(r *Resolver, proxyAdapter C.ProxyAdapter, proxyName string, var rule C.Rule if proxyAdapter == nil { - if proxyName == RespectRules { + if proxyName == DnsRespectRules { if !metadata.Resolved() { - // resolve here before ResolveMetadata to avoid its inner resolver.ResolveIP + // resolve here before resolveMetadata to avoid its inner resolver.ResolveIP dstIP, err := resolver.ResolveIPWithResolver(ctx, metadata.Host, r) if err != nil { return nil, err } metadata.DstIP = dstIP } - proxyAdapter, rule, err = tunnel.ResolveMetadata(metadata) + proxyAdapter, rule, err = resolveMetadata(metadata) if err != nil { return nil, err } } else { var ok bool - proxyAdapter, ok = tunnel.Proxies()[proxyName] + proxyAdapter, ok = Proxies()[proxyName] if !ok { opts = append(opts, dialer.WithInterface(proxyName)) } @@ -88,8 +89,10 @@ func getDialHandler(r *Resolver, proxyAdapter C.ProxyAdapter, proxyName string, conn, err := proxyAdapter.DialContext(ctx, metadata, opts...) if err != nil { + logMetadataErr(metadata, rule, proxyAdapter, err) return nil, err } + logMetadata(metadata, rule, conn) conn = statistic.NewTCPTracker(conn, statistic.DefaultManager, metadata, rule, 0, 0, false) @@ -105,8 +108,10 @@ func getDialHandler(r *Resolver, proxyAdapter C.ProxyAdapter, proxyName string, packetConn, err := proxyAdapter.ListenPacketContext(ctx, metadata, opts...) if err != nil { + logMetadataErr(metadata, rule, proxyAdapter, err) return nil, err } + logMetadata(metadata, rule, packetConn) packetConn = statistic.NewUDPTracker(packetConn, statistic.DefaultManager, metadata, rule, 0, 0, false) @@ -116,7 +121,7 @@ func getDialHandler(r *Resolver, proxyAdapter C.ProxyAdapter, proxyName string, } } -func listenPacket(ctx context.Context, proxyAdapter C.ProxyAdapter, proxyName string, network string, addr string, r *Resolver, opts ...dialer.Option) (net.PacketConn, error) { +func DnsListenPacket(ctx context.Context, proxyAdapter C.ProxyAdapter, proxyName string, network string, addr string, r resolver.Resolver, opts ...dialer.Option) (net.PacketConn, error) { metadata := &C.Metadata{ NetWork: C.UDP, Type: C.INNER, @@ -136,14 +141,14 @@ func listenPacket(ctx context.Context, proxyAdapter C.ProxyAdapter, proxyName st var rule C.Rule if proxyAdapter == nil { - if proxyName == RespectRules { - proxyAdapter, rule, err = tunnel.ResolveMetadata(metadata) + if proxyName == DnsRespectRules { + proxyAdapter, rule, err = resolveMetadata(metadata) if err != nil { return nil, err } } else { var ok bool - proxyAdapter, ok = tunnel.Proxies()[proxyName] + proxyAdapter, ok = Proxies()[proxyName] if !ok { opts = append(opts, dialer.WithInterface(proxyName)) } @@ -160,8 +165,10 @@ func listenPacket(ctx context.Context, proxyAdapter C.ProxyAdapter, proxyName st packetConn, err := proxyAdapter.ListenPacketContext(ctx, metadata, opts...) if err != nil { + logMetadataErr(metadata, rule, proxyAdapter, err) return nil, err } + logMetadata(metadata, rule, packetConn) packetConn = statistic.NewUDPTracker(packetConn, statistic.DefaultManager, metadata, rule, 0, 0, false) diff --git a/mihomo/tunnel/tunnel.go b/mihomo/tunnel/tunnel.go index 78628a5687..2c1b894f9d 100644 --- a/mihomo/tunnel/tunnel.go +++ b/mihomo/tunnel/tunnel.go @@ -8,6 +8,7 @@ import ( "net/netip" "path/filepath" "runtime" + "strings" "sync" "time" @@ -278,7 +279,7 @@ func preHandleMetadata(metadata *C.Metadata) error { return nil } -func ResolveMetadata(metadata *C.Metadata) (proxy C.Proxy, rule C.Rule, err error) { +func resolveMetadata(metadata *C.Metadata) (proxy C.Proxy, rule C.Rule, err error) { if metadata.SpecialProxy != "" { var exist bool proxy, exist = proxies[metadata.SpecialProxy] @@ -375,7 +376,7 @@ func handleUDPConn(packet C.PacketAdapter) { cond.Broadcast() }() - proxy, rule, err := ResolveMetadata(metadata) + proxy, rule, err := resolveMetadata(metadata) if err != nil { log.Warnln("[UDP] Parse metadata failed: %s", err.Error()) return @@ -386,43 +387,18 @@ func handleUDPConn(packet C.PacketAdapter) { rawPc, err := retry(ctx, func(ctx context.Context) (C.PacketConn, error) { return proxy.ListenPacketContext(ctx, metadata.Pure()) }, func(err error) { - if rule == nil { - log.Warnln( - "[UDP] dial %s %s --> %s error: %s", - proxy.Name(), - metadata.SourceDetail(), - metadata.RemoteAddress(), - err.Error(), - ) - } else { - log.Warnln("[UDP] dial %s (match %s/%s) %s --> %s error: %s", proxy.Name(), rule.RuleType().String(), rule.Payload(), metadata.SourceDetail(), metadata.RemoteAddress(), err.Error()) - } + logMetadataErr(metadata, rule, proxy, err) }) if err != nil { return } + logMetadata(metadata, rule, rawPc) pc := statistic.NewUDPTracker(rawPc, statistic.DefaultManager, metadata, rule, 0, 0, true) - switch true { - case metadata.SpecialProxy != "": - log.Infoln("[UDP] %s --> %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), metadata.SpecialProxy) - case rule != nil: - if rule.Payload() != "" { - log.Infoln("[UDP] %s --> %s match %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), fmt.Sprintf("%s(%s)", rule.RuleType().String(), rule.Payload()), rawPc.Chains().String()) - if rawPc.Chains().Last() == "REJECT-DROP" { - pc.Close() - return - } - } else { - log.Infoln("[UDP] %s --> %s match %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), rule.Payload(), rawPc.Chains().String()) - } - case mode == Global: - log.Infoln("[UDP] %s --> %s using GLOBAL", metadata.SourceDetail(), metadata.RemoteAddress()) - case mode == Direct: - log.Infoln("[UDP] %s --> %s using DIRECT", metadata.SourceDetail(), metadata.RemoteAddress()) - default: - log.Infoln("[UDP] %s --> %s doesn't match any rule using DIRECT", metadata.SourceDetail(), metadata.RemoteAddress()) + if rawPc.Chains().Last() == "REJECT-DROP" { + pc.Close() + return } oAddrPort := metadata.AddrPort() @@ -486,7 +462,7 @@ func handleTCPConn(connCtx C.ConnContext) { }() } - proxy, rule, err := ResolveMetadata(metadata) + proxy, rule, err := resolveMetadata(metadata) if err != nil { log.Warnln("[Metadata] parse failed: %s", err.Error()) return @@ -539,48 +515,18 @@ func handleTCPConn(connCtx C.ConnContext) { } return }, func(err error) { - if rule == nil { - log.Warnln( - "[TCP] dial %s %s --> %s error: %s", - proxy.Name(), - metadata.SourceDetail(), - metadata.RemoteAddress(), - err.Error(), - ) - } else { - log.Warnln("[TCP] dial %s (match %s/%s) %s --> %s error: %s", proxy.Name(), rule.RuleType().String(), rule.Payload(), metadata.SourceDetail(), metadata.RemoteAddress(), err.Error()) - } + logMetadataErr(metadata, rule, proxy, err) }) if err != nil { return } + logMetadata(metadata, rule, remoteConn) remoteConn = statistic.NewTCPTracker(remoteConn, statistic.DefaultManager, metadata, rule, 0, int64(peekLen), true) defer func(remoteConn C.Conn) { _ = remoteConn.Close() }(remoteConn) - switch true { - case metadata.SpecialProxy != "": - log.Infoln("[TCP] %s --> %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), metadata.SpecialProxy) - case rule != nil: - if rule.Payload() != "" { - log.Infoln("[TCP] %s --> %s match %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), fmt.Sprintf("%s(%s)", rule.RuleType().String(), rule.Payload()), remoteConn.Chains().String()) - } else { - log.Infoln("[TCP] %s --> %s match %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), rule.RuleType().String(), remoteConn.Chains().String()) - } - case mode == Global: - log.Infoln("[TCP] %s --> %s using GLOBAL", metadata.SourceDetail(), metadata.RemoteAddress()) - case mode == Direct: - log.Infoln("[TCP] %s --> %s using DIRECT", metadata.SourceDetail(), metadata.RemoteAddress()) - default: - log.Infoln( - "[TCP] %s --> %s doesn't match any rule using DIRECT", - metadata.SourceDetail(), - metadata.RemoteAddress(), - ) - } - _ = conn.SetReadDeadline(time.Now()) // stop unfinished peek peekMutex.Lock() defer peekMutex.Unlock() @@ -588,6 +534,33 @@ func handleTCPConn(connCtx C.ConnContext) { handleSocket(conn, remoteConn) } +func logMetadataErr(metadata *C.Metadata, rule C.Rule, proxy C.ProxyAdapter, err error) { + if rule == nil { + log.Warnln("[%s] dial %s %s --> %s error: %s", strings.ToUpper(metadata.NetWork.String()), proxy.Name(), metadata.SourceDetail(), metadata.RemoteAddress(), err.Error()) + } else { + log.Warnln("[%s] dial %s (match %s/%s) %s --> %s error: %s", strings.ToUpper(metadata.NetWork.String()), proxy.Name(), rule.RuleType().String(), rule.Payload(), metadata.SourceDetail(), metadata.RemoteAddress(), err.Error()) + } +} + +func logMetadata(metadata *C.Metadata, rule C.Rule, remoteConn C.Connection) { + switch { + case metadata.SpecialProxy != "": + log.Infoln("[%s] %s --> %s using %s", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress(), metadata.SpecialProxy) + case rule != nil: + if rule.Payload() != "" { + log.Infoln("[%s] %s --> %s match %s using %s", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress(), fmt.Sprintf("%s(%s)", rule.RuleType().String(), rule.Payload()), remoteConn.Chains().String()) + } else { + log.Infoln("[%s] %s --> %s match %s using %s", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress(), rule.RuleType().String(), remoteConn.Chains().String()) + } + case mode == Global: + log.Infoln("[%s] %s --> %s using GLOBAL", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress()) + case mode == Direct: + log.Infoln("[%s] %s --> %s using DIRECT", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress()) + default: + log.Infoln("[%s] %s --> %s doesn't match any rule using %s", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress(), remoteConn.Chains().Last()) + } +} + func shouldResolveIP(rule C.Rule, metadata *C.Metadata) bool { return rule.ShouldResolveIP() && metadata.Host != "" && !metadata.DstIP.IsValid() } diff --git a/openwrt-packages/ddns-go/Makefile b/openwrt-packages/ddns-go/Makefile index 6395fe41bb..b1debd21bd 100644 --- a/openwrt-packages/ddns-go/Makefile +++ b/openwrt-packages/ddns-go/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ddns-go -PKG_VERSION:=6.6.1 +PKG_VERSION:=6.6.2 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/jeessy2/ddns-go/tar.gz/v$(PKG_VERSION)? -PKG_HASH:=8dce0f8eea963986abee19d44296ed9263c0f1ae45173178804adec4846c5922 +PKG_HASH:=2e4910d5c0854f98e782a8cdc97d630ee0138de41a3b98d0ada588b1007337f3 PKG_LICENSE:=MIT PKG_LICENSE_FILES:=LICENSE diff --git a/openwrt-packages/luci-app-ikoolproxy/README.md b/openwrt-packages/luci-app-ikoolproxy/README.md index d5070022cd..2b78bfc6b5 100644 --- a/openwrt-packages/luci-app-ikoolproxy/README.md +++ b/openwrt-packages/luci-app-ikoolproxy/README.md @@ -64,7 +64,7 @@ CONFIG_PACKAGE_ca-bundle=y CONFIG_PACKAGE_ca-certificates=y -CONFIG_PACKAGE_libustream-openssl=n +CONFIG_PACKAGE_libustream-openssl=y CONFIG_PACKAGE_lua-openssl=y diff --git a/shadowsocks-rust/snap/snapcraft.yaml b/shadowsocks-rust/snap/snapcraft.yaml index e241a78fec..489421c9d2 100644 --- a/shadowsocks-rust/snap/snapcraft.yaml +++ b/shadowsocks-rust/snap/snapcraft.yaml @@ -10,8 +10,8 @@ architectures: - build-on: amd64 - build-on: arm64 - build-on: armhf - # - build-on: ppc64el - # - build-on: s390x + - build-on: ppc64el + - build-on: s390x - build-on: riscv64 license: MIT source-code: https://github.com/shadowsocks/shadowsocks-rust diff --git a/small/v2ray-geodata/Makefile b/small/v2ray-geodata/Makefile index ed36a2a812..26697fe985 100644 --- a/small/v2ray-geodata/Makefile +++ b/small/v2ray-geodata/Makefile @@ -12,13 +12,13 @@ PKG_MAINTAINER:=Tianling Shen include $(INCLUDE_DIR)/package.mk -GEOIP_VER:=202406060042 +GEOIP_VER:=202406130042 GEOIP_FILE:=geoip.dat.$(GEOIP_VER) define Download/geoip URL:=https://github.com/v2fly/geoip/releases/download/$(GEOIP_VER)/ URL_FILE:=geoip.dat FILE:=$(GEOIP_FILE) - HASH:=19d53a38cfaaac6e5a2be6d0b2710ebf094979d33380cdcb5fd5d073f07a2248 + HASH:=e3ebf15b59b42c3bb6db1b88614e7a63af94da199e1398826105557f52124cd5 endef GEOSITE_VER:=20240612095513 diff --git a/yass/.github/workflows/releases-deb.yml b/yass/.github/workflows/releases-deb.yml index 8570137b90..dd064bed79 100644 --- a/yass/.github/workflows/releases-deb.yml +++ b/yass/.github/workflows/releases-deb.yml @@ -46,11 +46,20 @@ jobs: matrix: distro: [xenial] arch: [amd64, i386] + gui_variant: [gtk3] include: - distro: bionic arch: arm64 + gui_variant: gtk3 + - distro: jammy + arch: amd64 + gui_variant: gtk4 + - distro: bookworm + arch: amd64 + gui_variant: qt6 - distro: sid arch: riscv64 + gui_variant: none # XFAIL stretch # XFAIL focal-i386,jammy-i386,noble-i386 # XFAIL sid-riscv64 (gui, curl) @@ -75,7 +84,7 @@ jobs: git fetch --tags --unshallow git submodule update --init --depth 1 - name: Patch libcxxabi for both of armel and armhf - if: ${{ env.HOST_ARCH == 'armel' || env.HOST_ARCH == 'armhf' }} + if: ${{ matrix.arch == 'armel' || matrix.arch == 'armhf' }} run: | cd third_party/libc++abi patch -p1 < v8-6.7.17-fix-gcc-unwind-header.patch @@ -114,7 +123,7 @@ jobs: sudo apt-get update -qq sudo apt-get install -y sbuild debhelper schroot debootstrap ubuntu-dev-tools qemu-user-static - name: Populate dependencies (deboostrap update for sid fix) - if: ${{ env.HOST_DISTRO == 'sid' }} + if: ${{ matrix.distro == 'sid' }} run: | curl -L -O http://mirrors.kernel.org/ubuntu/pool/main/d/debootstrap/debootstrap_1.0.132ubuntu1_all.deb sudo apt-get update -qq && sudo apt-get install -f -y $PWD/debootstrap*.deb @@ -127,32 +136,32 @@ jobs: sudo chown -R sbuild:sbuild /var/lib/sbuild/ sudo chmod g+rws /var/lib/sbuild/ - name: Pre-Populate sysroot (distro option) - if: ${{ env.HOST_DISTRO == 'stretch' || env.HOST_DISTRO == 'buster' || env.HOST_DISTRO == 'bullseye' || env.HOST_DISTRO == 'bookworm' || env.HOST_DISTRO == 'sid' }} + if: ${{ matrix.distro == 'stretch' || matrix.distro == 'buster' || matrix.distro == 'bullseye' || matrix.distro == 'bookworm' || matrix.distro == 'sid' }} run: | echo "mksbuild_distro_opts=--distro=debian" >> $GITHUB_ENV - name: Pre-Populate BUILD_ARCH (i386) - if: ${{ env.HOST_ARCH == 'i386' }} + if: ${{ matrix.arch == 'i386' }} run: | echo "mksbuild_arch_opts=--arch=i386" >> $GITHUB_ENV echo "BUILD_ARCH=i386" >> $GITHUB_ENV - name: Pre-Populate BUILD_ARCH (amd64) - if: ${{ env.HOST_ARCH != 'i386' }} + if: ${{ matrix.arch != 'i386' }} run: | echo "mksbuild_arch_opts=--arch=amd64" >> $GITHUB_ENV echo "BUILD_ARCH=$(dpkg-architecture -q DEB_BUILD_ARCH)" >> $GITHUB_ENV - name: Set check build profile - if: ${{ env.HOST_ARCH == 'i386' || env.HOST_ARCH == 'amd64' }} + if: ${{ matrix.arch == 'i386' || matrix.arch == 'amd64' }} run: | echo "DEB_BUILD_PROFILES=check ${{ env.DEB_BUILD_PROFILES }}" >> $GITHUB_ENV - name: Set cross build profile - if: ${{ env.HOST_ARCH != 'i386' && env.HOST_ARCH != 'amd64' }} + if: ${{ matrix.arch != 'i386' && matrix.arch != 'amd64' }} run: | echo "DEB_BUILD_PROFILES=nocheck cross ${{ env.DEB_BUILD_PROFILES }}" >> $GITHUB_ENV - - name: Set gtk3 build profile (none of armel/mipsel/mips64el and riscv64) - if: ${{ env.HOST_ARCH != 'armel' && env.HOST_ARCH != 'mipsel' && env.HOST_ARCH != 'mips64el' && env.HOST_ARCH != 'riscv64' }} + - name: Set gui build profile (none of armel/mipsel/mips64el and riscv64) + if: ${{ matrix.gui_variant != 'none' }} run: | - echo "DEB_BUILD_PROFILES=gtk3 ${{ env.DEB_BUILD_PROFILES }}" >> $GITHUB_ENV - echo "APT_DEB_BUILD_PROFILES=-o Apt::Build-Profiles=gtk3" >> $GITHUB_ENV + echo "DEB_BUILD_PROFILES=${{ matrix.gui_variant }} ${{ env.DEB_BUILD_PROFILES }}" >> $GITHUB_ENV + echo "APT_DEB_BUILD_PROFILES=-o Apt::Build-Profiles=${{ matrix.gui_variant }}" >> $GITHUB_ENV - name: Set clang build profile run: | echo "DEB_BUILD_PROFILES=clang ${{ env.DEB_BUILD_PROFILES }}" >> $GITHUB_ENV @@ -169,7 +178,7 @@ jobs: path: | /etc/schroot/chroot.d /var/lib/schroot/chroots - key: ${{ runner.os }}-22.04-schroot-${{ env.HOST_DISTRO }}-${{ env.HOST_ARCH }}-v3 + key: ${{ runner.os }}-22.04-schroot-${{ matrix.distro }}-${{ matrix.arch }}-${{ matrix.gui_variant }}-v0 - name: Fix schroot permissions (restore root permissions) run: | sudo chown -R root:root /etc/schroot/chroot.d /var/lib/schroot/chroots @@ -178,63 +187,63 @@ jobs: - name: Populate sysroot if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' }} run: | - sudo -n sudo -u "$USER" -g sbuild mk-sbuild ${{ env.mksbuild_arch_opts }} ${{ env.HOST_DISTRO }} --target=${{ env.HOST_ARCH }} ${{ env.mksbuild_distro_opts }} || true + sudo -n sudo -u "$USER" -g sbuild mk-sbuild ${{ env.mksbuild_arch_opts }} ${{ matrix.distro }} --target=${{ matrix.arch }} ${{ env.mksbuild_distro_opts }} || true sudo sed -i '/profile/d' /etc/schroot/chroot.d/* - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ apt-get clean - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ apt-get update -qq - name: Populate sysroot (crosscompile toolchain) - if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && env.HOST_ARCH != 'i386' && env.HOST_ARCH != 'amd64' }} + if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && matrix.arch != 'i386' && matrix.arch != 'amd64' }} run: | - export HOST_GNU_TYPE=$(dpkg-architecture -a ${{ env.HOST_ARCH }} -q DEB_HOST_GNU_TYPE) - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ - dpkg --add-architecture ${{ env.HOST_ARCH }} - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + export HOST_GNU_TYPE=$(dpkg-architecture -a ${{ matrix.arch }} -q DEB_HOST_GNU_TYPE) + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ + dpkg --add-architecture ${{ matrix.arch }} + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ apt-get update -qq - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ - apt-get install -y dpkg-cross pkg-config gcc-$HOST_GNU_TYPE g++-$HOST_GNU_TYPE libc6:${{ env.HOST_ARCH }} libstdc++6:${{ env.HOST_ARCH }} linux-libc-dev:${{ env.HOST_ARCH }} - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ + apt-get install -y dpkg-cross pkg-config gcc-$HOST_GNU_TYPE g++-$HOST_GNU_TYPE libc6:${{ matrix.arch }} libstdc++6:${{ matrix.arch }} linux-libc-dev:${{ matrix.arch }} + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ ln -sf /usr/share/pkg-config-crosswrapper /usr/bin/${HOST_GNU_TYPE}-pkg-config - name: Populate sysroot (crosscompile toolchain, for bookworm and later distro) - if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && env.HOST_ARCH != 'i386' && env.HOST_ARCH != 'amd64' }} + if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && matrix.arch != 'i386' && matrix.arch != 'amd64' }} run: | - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ bash -c "[ ! -f /usr/share/pkg-config-crosswrapper ] && cp -v $PWD/debian/pkg-config-crosswrapper /usr/share/pkg-config-crosswrapper || :" - name: Populate sysroot (standard toolchain) if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' }} run: | - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ apt-get install -y fakeroot advancecomp apt-utils file build-essential pkg-config debhelper lockfile-progs optipng tzdata ucf - name: Populate sysroot (amd64 runtime for clang) - if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && env.HOST_ARCH == 'i386' }} + if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && matrix.arch == 'i386' }} run: | - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ cp -f /etc/apt/sources.list /etc/apt/sources.list.amd64 - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ sed -i s/i386/amd64/g /etc/apt/sources.list.amd64 - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ bash -c "cat /etc/apt/sources.list /etc/apt/sources.list.amd64 | tee /tmp/sources.list" - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ mv -f /tmp/sources.list /etc/apt/sources.list - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ dpkg --add-architecture amd64 - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ apt-get update -qq - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ apt-get install -y libc6:amd64 libstdc++6:amd64 zlib1g:amd64 - name: Populate sysroot (ca-certificates, git) if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' }} run: | - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ apt-get install -y ca-certificates git - name: Populate sysroot (golang, new distro) - if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && env.HOST_DISTRO != 'trusty' && env.HOST_DISTRO != 'xenial' && env.HOST_DISTRO != 'bionic' && env.HOST_DISTRO != 'stretch' && env.HOST_DISTRO != 'buster' && env.HOST_DISTRO != 'bullseye' }} + if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && matrix.distro != 'trusty' && matrix.distro != 'xenial' && matrix.distro != 'bionic' && matrix.distro != 'stretch' && matrix.distro != 'buster' && matrix.distro != 'bullseye' }} run: | - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ apt-get install -y golang - name: Populate sysroot (golang, old distro) - if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && (env.HOST_DISTRO == 'trusty' || env.HOST_DISTRO == 'xenial' || env.HOST_DISTRO == 'bionic' || env.HOST_DISTRO == 'stretch' || env.HOST_DISTRO == 'buster' || env.HOST_DISTRO == 'bullseye') }} + if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && (matrix.distro == 'trusty' || matrix.distro == 'xenial' || matrix.distro == 'bionic' || matrix.distro == 'stretch' || matrix.distro == 'buster' || matrix.distro == 'bullseye') }} run: | # shipped with debian bullseye curl -O http://ftp.us.debian.org/debian/pool/main/g/golang-defaults/golang_1.15~1_${{ env.BUILD_ARCH }}.deb @@ -245,48 +254,58 @@ jobs: curl -O http://ftp.us.debian.org/debian/pool/main/g/golang-1.15/golang-1.15-go_1.15.15-1~deb11u4_${{ env.BUILD_ARCH }}.deb curl -O http://ftp.us.debian.org/debian/pool/main/g/golang-1.15/golang-1.15-src_1.15.15-1~deb11u4_${{ env.BUILD_ARCH }}.deb curl -O http://ftp.us.debian.org/debian/pool/main/g/golang-1.15/golang-1.15-doc_1.15.15-1~deb11u4_all.deb - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ dpkg --force-depends -i $PWD/*.deb || true - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ apt-get install -y -f rm -f *.deb - name: Populate dependencie (cmake) if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' }} run: | - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ apt-get install -y cmake ninja-build - name: Populate dependencie (cmake, overwrite) if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' }} run: | curl -L -O https://github.com/Kitware/CMake/releases/download/v3.28.5/cmake-3.28.5-linux-x86_64.tar.gz - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ tar -C /usr/local --strip-components=1 -xf cmake-3.28.5-linux-x86_64.tar.gz - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ cmake --version rm -f *.tar.gz - name: Populate dependencie (base) if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' }} run: | - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ apt-get install -y perl gcc g++ ninja-build - name: Populate dependencie (zlib) if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' }} run: | - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ - apt-get install -y zlib1g-dev:${{ env.HOST_ARCH }} - - name: Populate dependencie (gui, exclude some arches) - if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && env.HOST_ARCH != 'armel' && env.HOST_ARCH != 'mipsel' && env.HOST_ARCH != 'mips64el' && env.HOST_ARCH != 'riscv64' }} + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ + apt-get install -y zlib1g-dev:${{ matrix.arch }} + - name: Populate dependencie (qt6) + if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && matrix.gui_variant == 'qt6' }} run: | - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ - apt-get -o DPkg::Options::="--force-confnew" install -y libglib2.0-dev:${{ env.HOST_ARCH }} libgtk-3-dev:${{ env.HOST_ARCH }} + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ + apt-get -o DPkg::Options::="--force-confnew" install -y qt6-base-dev:${{ matrix.arch }} + - name: Populate dependencie (gtk4) + if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && matrix.gui_variant == 'gtk4' }} + run: | + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ + apt-get -o DPkg::Options::="--force-confnew" install -y libglib2.0-dev:${{ matrix.arch }} libgtk-4-dev:${{ matrix.arch }} + - name: Populate dependencie (gtk3) + if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && matrix.gui_variant == 'gtk3' }} + run: | + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ + apt-get -o DPkg::Options::="--force-confnew" install -y libglib2.0-dev:${{ matrix.arch }} libgtk-3-dev:${{ matrix.arch }} - name: Populate dependencie (curl, for test purpose, exclude some arches) - if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && env.HOST_ARCH != 'armel' && env.HOST_ARCH != 'mipsel' && env.HOST_ARCH != 'mips64el' && env.HOST_ARCH != 'riscv64' }} + if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' && matrix.arch != 'armel' && matrix.arch != 'mipsel' && matrix.arch != 'mips64el' && matrix.arch != 'riscv64' }} run: | - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ - apt-get install -y libcurl4-openssl-dev:${{ env.HOST_ARCH }} + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ + apt-get install -y libcurl4-openssl-dev:${{ matrix.arch }} - name: Populate dependencie (list upgradable packages) run: | - sudo schroot --chroot "source:${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}" --user root -- \ + sudo schroot --chroot "source:${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}" --user root -- \ apt list --upgradeable || true - name: Build deb run: | @@ -298,14 +317,14 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release upload ${{ github.event.release.tag_name }} yass*.deb + gh release upload --clobber ${{ github.event.release.tag_name }} yass*.deb - name: Shutdown schroot sessions run: | sudo schroot --end-session --all-sessions - name: Fix schroot dev nodes permissions if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' }} run: | - sudo rm -rf /var/lib/schroot/chroots/${{ env.HOST_DISTRO }}-${{ env.BUILD_ARCH }}-${{ env.HOST_ARCH }}/dev + sudo rm -rf /var/lib/schroot/chroots/${{ matrix.distro }}-${{ env.BUILD_ARCH }}-${{ matrix.arch }}/dev - name: Fix schroot permissions (restore store permissions) if: ${{ steps.schroot-cache.outputs.cache-hit != 'true' }} run: | diff --git a/yass/.github/workflows/releases-rpm.yml b/yass/.github/workflows/releases-rpm.yml index 683b1ecb20..83d92db152 100644 --- a/yass/.github/workflows/releases-rpm.yml +++ b/yass/.github/workflows/releases-rpm.yml @@ -45,11 +45,11 @@ jobs: container: - 'centos7' - 'centos8' + - 'centos9' - 'fedora39' - 'alpine320' - 'i386-alpine320' - 'opensuse15' - # - 'centos9' runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -83,18 +83,32 @@ jobs: strategy: fail-fast: false matrix: - container: - - 'centos7' - - 'centos8' - - 'fedora39' - - 'opensuse15' - # - 'centos9' + include: + - container: 'centos7' + gui_variant: gtk3 + - container: 'centos8' + gui_variant: gtk3 + - container: 'centos9' + gui_variant: gtk3 + - container: 'centos9' + gui_variant: gtk4 + # qt6 sits on epel repo, disabling + # - container: 'centos9' + # gui_variant: qt6 + - container: 'opensuse15' + gui_variant: gtk3 + # - container: 'opensuse15' + # gui_variant: gtk4 + # - container: 'fedora39' + # gui_variant: gtk3 + # - container: 'fedora39' + # gui_variant: gtk4 + - container: 'fedora39' + gui_variant: qt6 runs-on: ubuntu-22.04 needs: docker_publish container: image: 'ghcr.io/chilledheart/${{ matrix.container }}' - env: - DISTRO: ${{ matrix.container }} steps: - uses: actions/checkout@v3 - name: Checkout with shallow submodules @@ -107,7 +121,7 @@ jobs: - name: Cache clang id: clang-cache uses: actions/cache@v4 - if: ${{ env.DISTRO != 'centos7' }} + if: ${{ matrix.container != 'centos7' }} with: path: | third_party/llvm-build/Release+Asserts @@ -115,7 +129,7 @@ jobs: - name: Cache clang (el7) id: clang-cache-el7 uses: actions/cache@v3 - if: ${{ env.DISTRO == 'centos7' }} + if: ${{ matrix.container == 'centos7' }} with: path: | third_party/llvm-build/Release+Asserts @@ -130,26 +144,40 @@ jobs: restore-keys: | ${{ runner.os }}-go-docker- - name: "Install dependency: prebuilt clang and clang-tidy binaries" - if: ${{ steps.clang-cache.outputs.cache-hit != 'true' && env.DISTRO != 'centos7' }} + if: ${{ steps.clang-cache.outputs.cache-hit != 'true' && matrix.container != 'centos7' }} run: | ./scripts/download-clang-prebuilt-binaries.py rm -f third_party/llvm-build/Release+Asserts/*.tgz - name: "Install dependency: prebuilt clang and clang-tidy binaries (el7 patch)" - if: ${{ steps.clang-cache-el7.outputs.cache-hit != 'true' && env.DISTRO == 'centos7' }} + if: ${{ steps.clang-cache-el7.outputs.cache-hit != 'true' && matrix.container == 'centos7' }} run: | ./scripts/download-clang-prebuilt-binaries.py rm -f third_party/llvm-build/Release+Asserts/*.tgz ./scripts/libstdc++-el7.sh - - name: Set clang environment (centos and opensuse only) - if: ${{ env.DISTRO == 'centos7' || env.DISTRO == 'centos8' || env.DISTRO == 'centos9' || env.DISTRO == 'opensuse15' }} + - name: Set clang environment run: | + # use custom compiler echo "CC=${{ github.workspace }}/third_party/llvm-build/Release+Asserts/bin/clang" >> $GITHUB_ENV echo "CXX=${{ github.workspace }}/third_party/llvm-build/Release+Asserts/bin/clang++" >> $GITHUB_ENV - - name: Set LTO environment - if: ${{ env.DISTRO == 'centos7' }} + echo "USE_CLANG=1" >> $GITHUB_ENV + - name: Set c++ standard library environment + if: ${{ matrix.container == 'centos7' || matrix.container == 'centos8' || matrix.container == 'opensuse15' }} + run: | + # use custom libc++ + echo "USE_LIBCXX=1" >> $GITHUB_ENV + - name: Set LLD environment + if: ${{ matrix.container == 'centos7' }} run: | # newer ld.lld doesn't work on glibc 2.17 echo "DISABLE_LLD=1" >> $GITHUB_ENV + - name: Set QT6 environment + if: ${{ matrix.gui_variant == 'qt6' }} + run: | + echo "USE_QT6=1" >> $GITHUB_ENV + - name: Set GTK4 environment + if: ${{ matrix.gui_variant == 'gtk4' }} + run: | + echo "USE_GTK4=1" >> $GITHUB_ENV - name: Build RPM packages run: | ./scripts/build-rpm.sh diff --git a/yass/.github/workflows/releases-src.yml b/yass/.github/workflows/releases-src.yml index f7419b0ebb..d738d37285 100644 --- a/yass/.github/workflows/releases-src.yml +++ b/yass/.github/workflows/releases-src.yml @@ -69,4 +69,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release upload ${{ github.event.release.tag_name }} yass*.tar.gz yass*.tar.bz2 yass*.zip + gh release upload ${{ github.event.release.tag_name }} yass*.tar.gz yass*.tar.bz2 yass*.tar.zst yass*.zip diff --git a/yass/PACKAGING.md b/yass/PACKAGING.md index b65b6d968a..12c0e712e6 100644 --- a/yass/PACKAGING.md +++ b/yass/PACKAGING.md @@ -60,13 +60,27 @@ Generate Packages under parent directory DEB_BUILD_PROFILES=qt6 ./scripts/build-deb.sh ``` -## Fedora/RHEL/CentOS/AlmaLinux/Rocky Linux/Gtk3/Gtk4 Packaging +## Fedora/RHEL/CentOS/AlmaLinux/Rocky Gtk3 Packaging Generate Packages under current directory ``` ./scripts/build-rpm.sh ``` +## Fedora/RHEL/CentOS/AlmaLinux/Rocky Gtk4 Packaging + +Generate Packages under current directory +``` +USE_GTK4=1 ./scripts/build-rpm.sh +``` + +## Fedora/RHEL/CentOS/AlmaLinux/Rocky Qt6 Packaging + +Generate Packages under current directory +``` +USE_QT6=1 ./scripts/build-rpm.sh +``` + ## FreeBSD/Packaging Generate Packages under current directory diff --git a/yass/README.md b/yass/README.md index 434e606493..ab4086ff4e 100644 --- a/yass/README.md +++ b/yass/README.md @@ -31,14 +31,16 @@ Post Quantum Kyber Support (not enabled by default) is added on all of supported See [Protecting Chrome Traffic with Hybrid Kyber KEM](https://blog.chromium.org/2023/08/protecting-chrome-traffic-with-hybrid.html) for more. ### Prebuilt binaries -- Android [download apk](https://github.com/Chilledheart/yass/releases/download/1.11.0/yass-android-release-arm64-1.11.0.apk) or [download 32-bit apk](https://github.com/Chilledheart/yass/releases/download/1.11.0/yass-android-release-arm-1.11.0.apk) +- Android [download apk](https://github.com/Chilledheart/yass/releases/download/1.11.1/yass-android-release-arm64-1.11.1.apk) or [download 32-bit apk](https://github.com/Chilledheart/yass/releases/download/1.11.1/yass-android-release-arm-1.11.1.apk) - iOS [join via TestFlight](https://testflight.apple.com/join/6AkiEq09) -- Windows [download installer](https://github.com/Chilledheart/yass/releases/download/1.11.0/yass-mingw-win7-release-x86_64-1.11.0-system-installer.exe) [(require KB2999226 below windows 10)][KB2999226] or [download 32-bit installer](https://github.com/Chilledheart/yass/releases/download/1.11.0/yass-mingw-winxp-release-i686-1.11.0-system-installer.exe) [(require vc 2010 runtime)][vs2010_x86] or [download woa arm64 installer](https://github.com/Chilledheart/yass/releases/download/1.11.0/yass-mingw-release-aarch64-1.11.0-system-installer.exe) -- macOS [download intel dmg](https://github.com/Chilledheart/yass/releases/download/1.11.0/yass-macos-release-x64-1.11.0.dmg) or [download apple silicon dmg](https://github.com/Chilledheart/yass/releases/download/1.11.0/yass-macos-release-arm64-1.11.0.dmg) +- Windows [download installer](https://github.com/Chilledheart/yass/releases/download/1.11.1/yass-mingw-win7-release-x86_64-1.11.1-system-installer.exe) [(require KB2999226 below windows 10)][KB2999226] or [download 32-bit installer](https://github.com/Chilledheart/yass/releases/download/1.11.1/yass-mingw-winxp-release-i686-1.11.1-system-installer.exe) [(require vc 2010 runtime)][vs2010_x86] or [download woa arm64 installer](https://github.com/Chilledheart/yass/releases/download/1.11.1/yass-mingw-release-aarch64-1.11.1-system-installer.exe) +- macOS [download intel dmg](https://github.com/Chilledheart/yass/releases/download/1.11.1/yass-macos-release-x64-1.11.1.dmg) or [download apple silicon dmg](https://github.com/Chilledheart/yass/releases/download/1.11.1/yass-macos-release-arm64-1.11.1.dmg) > via homebrew: `brew install --cask yass` -- Linux [download rpm](https://github.com/Chilledheart/yass/releases/download/1.11.0/yass.el7.x86_64.1.11.0.rpm) or [download deb](https://github.com/Chilledheart/yass/releases/download/1.11.0/yass-ubuntu-16.04-xenial_amd64.1.11.0.deb) +- Linux/GTK3 [download rpm](https://github.com/Chilledheart/yass/releases/download/1.11.1/yass-gtk3.el7.x86_64.1.11.1.rpm) or [download deb](https://github.com/Chilledheart/yass/releases/download/1.11.1/yass-gtk3-ubuntu-16.04-xenial_amd64.1.11.1.deb) (require glibc >= 2.16) +- Linux/GTK4 [download rpm](https://github.com/Chilledheart/yass/releases/download/1.11.1/yass-gtk4.el9.x86_64.1.11.1.rpm) or [download deb](https://github.com/Chilledheart/yass/releases/download/1.11.1/yass-gtk4-ubuntu-22.04-jammy_amd64.1.11.1.deb) (require glibc >= 2.34) +- Linux/Qt6 [download rpm](https://github.com/Chilledheart/yass/releases/download/1.11.1/yass-qt6.fc39.x86_64.1.11.1.rpm) or [download deb](https://github.com/Chilledheart/yass/releases/download/1.11.1/yass-qt6-debian-12-bookworm_amd64.1.11.1.deb) (require glibc >= 2.36) -View more at [Release Page](https://github.com/Chilledheart/yass/releases/tag/1.11.0) +View more at [Release Page](https://github.com/Chilledheart/yass/releases/tag/1.11.1) ### NaïveProxy-Compatible Protocol Support Cipher http2 and https are NaïveProxy-compatible. diff --git a/yass/debian/changelog b/yass/debian/changelog index 9796609e7c..f9bbb3400c 100644 --- a/yass/debian/changelog +++ b/yass/debian/changelog @@ -1,7 +1,13 @@ +yass (1.11.1-1) UNRELEASED; urgency=medium + + * miscellaneous fixes + * add gtk3/gtk4/qt6 build profile (deb) + + -- Chilledheart Thu, 13 Jun 2024 16:31:11 +0800 yass (1.11.0-1) UNRELEASED; urgency=medium * bump to chromium 127 dependents - * add gtk3/gtk4/qt6 build profile + * add gtk3/gtk4/qt6 build profile (source) -- Chilledheart Tue, 11 Jun 2024 11:02:21 +0800 yass (1.10.5-1) UNRELEASED; urgency=medium diff --git a/yass/docker/centos9.Dockerfile b/yass/docker/centos9.Dockerfile index 1004338acc..8958a3e182 100644 --- a/yass/docker/centos9.Dockerfile +++ b/yass/docker/centos9.Dockerfile @@ -10,7 +10,8 @@ RUN yum clean all && \ git make python39 bash coreutils gh \ rpm-build rpm-devel rpmlint diffutils patch rpmdevtools \ cmake ninja-build pkg-config golang \ - gtk4-devel zlib-devel curl-devel && \ + gtk3-devel gtk4-devel \ + zlib-devel curl-devel && \ yum clean all && \ rm -rf /var/cache/yum && rm -rf /var/cache/dnf diff --git a/yass/docker/fedora39.Dockerfile b/yass/docker/fedora39.Dockerfile index 680039e0f6..ad50c32865 100644 --- a/yass/docker/fedora39.Dockerfile +++ b/yass/docker/fedora39.Dockerfile @@ -9,18 +9,12 @@ RUN yum clean all && \ git make python3 bash coreutils gh systemd \ rpm-build rpm-devel rpmlint diffutils patch rpmdevtools \ cmake ninja-build pkg-config perl golang \ - gtk4-devel zlib-devel c-ares-devel libnghttp2-devel curl-devel \ + gtk3-devel gtk4-devel qt6-qtbase-devel \ + zlib-devel c-ares-devel libnghttp2-devel curl-devel \ json-devel mbedtls-devel gperftools-devel && \ yum clean all && \ rm -rf /var/cache/yum && rm -rf /var/cache/dnf -# Install toolchain -RUN yum clean all && \ - rm -rf /var/cache/yum && rm -rf /var/cache/dnf && \ - yum install -y clang lld && \ - yum clean all && \ - rm -rf /var/cache/yum && rm -rf /var/cache/dnf - # Install cmake 3.28.5 RUN curl -L https://github.com/Kitware/CMake/releases/download/v3.28.5/cmake-3.28.5-linux-x86_64.tar.gz | \ tar -C /usr/local --strip-components=1 --gz -xf - && \ diff --git a/yass/docker/opensuse15.Dockerfile b/yass/docker/opensuse15.Dockerfile index 8062715158..ee2b6593b6 100644 --- a/yass/docker/opensuse15.Dockerfile +++ b/yass/docker/opensuse15.Dockerfile @@ -10,7 +10,8 @@ RUN zypper cc -a && \ git make python3 bash coreutils gh \ rpm-build rpm-devel rpmlint diffutils patch rpmdevtools \ cmake ninja pkg-config perl golang \ - gtk4-devel zlib-devel c-ares-devel libnghttp2-devel curl-devel \ + gtk3-devel gtk4-devel \ + zlib-devel c-ares-devel libnghttp2-devel curl-devel \ http-parser-devel mbedtls-devel && \ zypper cc -a diff --git a/yass/scripts/build-deb.sh b/yass/scripts/build-deb.sh index 68cacd3c60..f52fb60935 100755 --- a/yass/scripts/build-deb.sh +++ b/yass/scripts/build-deb.sh @@ -97,9 +97,21 @@ fi ARCH=${HOST_ARCH:-$BUILD_ARCH} DISTRO=$(scripts/get-debian-name.py $HOST_DISTRO) +USE_QT6=$(echo $DEB_BUILD_PROFILES | grep qt6 || :) +USE_GTK4=$(echo $DEB_BUILD_PROFILES | grep gtk4 || :) +USE_GTK3=$(echo $DEB_BUILD_PROFILES | grep gtk3 || :) + +if [ ! -z "$USE_QT6" ]; then + GUI_SUFFIX=-qt6 +elif [ ! -z "$USE_GTK4" ]; then + GUI_SUFFIX=-gtk4 +elif [ ! -z "$USE_GTK3" ]; then + GUI_SUFFIX=-gtk3 +fi + if [ -f ../"yass_${VERSION}-${SUBVERSION}_${ARCH}.deb" ]; then - mv -f ../"yass_${VERSION}-${SUBVERSION}_${ARCH}.deb" "yass-${DISTRO}_${ARCH}.${TAG}${SUBVERSION_SUFFIX}.deb" - mv -f ../"yass-dbg_${VERSION}-${SUBVERSION}_${ARCH}.deb" "yass-${DISTRO}-dbg_${ARCH}.${TAG}${SUBVERSION_SUFFIX}.deb" + mv -f ../"yass_${VERSION}-${SUBVERSION}_${ARCH}.deb" "yass${GUI_SUFFIX}-${DISTRO}_${ARCH}.${TAG}${SUBVERSION_SUFFIX}.deb" + mv -f ../"yass-dbg_${VERSION}-${SUBVERSION}_${ARCH}.deb" "yass${GUI_SUFFIX}-${DISTRO}-dbg_${ARCH}.${TAG}${SUBVERSION_SUFFIX}.deb" fi mv -f ../"yass-server_${VERSION}-${SUBVERSION}_${ARCH}.deb" "yass-server-${DISTRO}_${ARCH}.${TAG}${SUBVERSION_SUFFIX}.deb" diff --git a/yass/scripts/build-rpm.sh b/yass/scripts/build-rpm.sh index 3286b1c0e3..d98f4e2ff2 100755 --- a/yass/scripts/build-rpm.sh +++ b/yass/scripts/build-rpm.sh @@ -46,8 +46,10 @@ mkdir -p $HOME/rpmbuild/SPECS mv -fv yass.spec $HOME/rpmbuild/SPECS [ "a$DISABLE_LLD" != "a" ] && rpm_options="--with=disable_lld" - -rpm_options="--with=toolchain_clang $rpm_options" +[ "a$USE_QT6" != "a" ] && rpm_options="--with=use_qt6" +[ "a$USE_GTK4" != "a" ] && rpm_options="--with=use_gtk4" +[ "a$USE_LIBCXX" != "a" ] && rpm_options="--with=use_libcxx $rpm_options" +[ "a$USE_CLANG" != "a" ] && rpm_options="--with=toolchain_clang $rpm_options" rpm_options="--with=tests_dns $rpm_options" # from rpm --querytags @@ -71,6 +73,14 @@ elif [ ${ID} = "opensuse-leap" ]; then REAL_SUFFIX=.lp${VERSION_ID} fi +if [ ! -z "$USE_QT6" ]; then + GUI_SUFFIX=-qt6 +elif [ ! -z "$USE_GTK4" ]; then + GUI_SUFFIX=-gtk4 +else + GUI_SUFFIX=-gtk3 +fi + pushd $HOME/rpmbuild/SPECS/ rpmbuild --define "_topdir $HOME/rpmbuild" -v $rpm_options -bs yass.spec rpmlint "$HOME/rpmbuild/SRPMS/yass-${RPM_VERSION}-${RPM_SUBVERSION}${SUFFIX}.src.rpm" @@ -81,8 +91,8 @@ popd # under centos 7, some commands might fail because it doesn't separate debuginfo # for sub package: https://fedoraproject.org/wiki/Changes/SubpackageAndSourceDebuginfo -cp -vf "$HOME/rpmbuild/RPMS/${ARCH}/yass-${RPM_VERSION}-${RPM_SUBVERSION}${SUFFIX}.${ARCH}.rpm" "yass${REAL_SUFFIX}.${ARCH}.${RPM_VERSION}${RPM_SUBVERSION_SUFFIX}.rpm" -cp -vf "$HOME/rpmbuild/RPMS/${ARCH}/yass-debuginfo-${RPM_VERSION}-${RPM_SUBVERSION}${SUFFIX}.${ARCH}.rpm" "yass-debuginfo${REAL_SUFFIX}.${ARCH}.${RPM_VERSION}${RPM_SUBVERSION_SUFFIX}.rpm" || true +cp -vf "$HOME/rpmbuild/RPMS/${ARCH}/yass-${RPM_VERSION}-${RPM_SUBVERSION}${SUFFIX}.${ARCH}.rpm" "yass${GUI_SUFFIX}${REAL_SUFFIX}.${ARCH}.${RPM_VERSION}${RPM_SUBVERSION_SUFFIX}.rpm" +cp -vf "$HOME/rpmbuild/RPMS/${ARCH}/yass-debuginfo-${RPM_VERSION}-${RPM_SUBVERSION}${SUFFIX}.${ARCH}.rpm" "yass${GUI_SUFFIX}-debuginfo${REAL_SUFFIX}.${ARCH}.${RPM_VERSION}${RPM_SUBVERSION_SUFFIX}.rpm" || true cp -vf "$HOME/rpmbuild/RPMS/${ARCH}/yass-server-${RPM_VERSION}-${RPM_SUBVERSION}${SUFFIX}.${ARCH}.rpm" "yass-server${REAL_SUFFIX}.${ARCH}.${RPM_VERSION}${RPM_SUBVERSION_SUFFIX}.rpm" cp -vf "$HOME/rpmbuild/RPMS/${ARCH}/yass-server-debuginfo-${RPM_VERSION}-${RPM_SUBVERSION}${SUFFIX}.${ARCH}.rpm" "yass-server-debuginfo${REAL_SUFFIX}.${ARCH}.${RPM_VERSION}${RPM_SUBVERSION_SUFFIX}.rpm" || true cp -vf "$HOME/rpmbuild/RPMS/${ARCH}/yass-client-${RPM_VERSION}-${RPM_SUBVERSION}${SUFFIX}.${ARCH}.rpm" "yass-client${REAL_SUFFIX}.${ARCH}.${RPM_VERSION}${RPM_SUBVERSION_SUFFIX}.rpm" diff --git a/yass/yass.spec.in b/yass/yass.spec.in index b65f3b3fbc..41fad52bde 100644 --- a/yass/yass.spec.in +++ b/yass/yass.spec.in @@ -45,19 +45,25 @@ %endif # libc++ is only built with clang now +%bcond_with use_libcxx +%if %{with use_libcxx} +%global enable_libcxx_opt on +%else +%global enable_libcxx_opt off +%endif + +# disable some warnings on clang compiler in fedora %bcond_with toolchain_clang %if %{with toolchain_clang} %global _clang_extra_ldflags %nil %global toolchain clang -%global enable_libcxx_opt on %else %global toolchain gcc -%global enable_libcxx_opt off %endif # on centos 8, gperftools sits in epel repo # and it is not compatible with custom libc++ -%if 0%{?fedora} && !%{with toolchain_clang} +%if 0%{?fedora} && !%{with use_libcxx} %global enable_system_gperftools_opt on %else %global enable_system_gperftools_opt off @@ -71,6 +77,22 @@ %global enable_lld_opt on %endif +# use_qt6 +%bcond_with use_qt6 +%if %{with use_qt6} && !%{with use_libcxx} +%global enable_use_qt6_opt on +%else +%global enable_use_qt6_opt off +%endif + +# use_gtk4 +%bcond_with use_gtk4 +%if !%{with use_qt6} && %{with use_gtk4} +%global enable_use_gtk4_opt on +%else +%global enable_use_gtk4_opt off +%endif + # force use old systemd unit files %if 0%{?rhel} == 7 %global use_old_systemd_service on @@ -94,11 +116,18 @@ License: GPLv2 %endif URL: https://github.com/Chilledheart/%{name} Source0: %{url}/releases/download/%{version}/%{name}-%{version}.tar.gz -%if 0%{?rhel} == 9 || 0%{?fedora} || 0%{?sle_version} +%if %{with use_qt6} && !%{with use_libcxx} +BuildRequires: qt6-qtbase-devel +%endif +%if !%{with use_qt6} && %{with use_gtk4} BuildRequires: gtk4-devel -%else +%endif +%if !%{with use_qt6} && !%{with use_gtk4} BuildRequires: gtk3-devel %endif +%if !%{with use_qt6} +BuildRequires: glib2-devel +%endif %if 0%{?rhel} < 9 || 0%{?fedora} || 0%{?sle_version} BuildRequires: perl %endif @@ -109,13 +138,12 @@ BuildRequires: cmake >= 3.12, pkg-config BuildRequires: cmake3 >= 3.12, pkgconfig %endif %if 0%{?fedora} -BuildRequires: clang, lld BuildRequires: c-ares-devel %endif %if 0%{?fedora} || 0%{?sle_version} BuildRequires: mbedtls-devel %endif -%if 0%{?fedora} && !%{with toolchain_clang} +%if 0%{?fedora} && !%{with use_libcxx} BuildRequires: gperftools-devel %endif %if 0%{?fedora} @@ -131,7 +159,6 @@ BuildRequires: ninja %else BuildRequires: ninja-build %endif -BuildRequires: glib2-devel BuildRequires: curl-devel BuildRequires: desktop-file-utils BuildRequires: systemd @@ -156,7 +183,8 @@ cd build # old c-ares doesn't contain ares_getaddrinfo api %cmake_alias -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DBUILD_BENCHMARKS=on -DBUILD_TESTS=on \ - -DUSE_GTK4=on -DGUI=on -DCLI=on -DSERVER=on \ + -DUSE_QT6="%enable_use_qt6_opt" -DUSE_GTK4="%enable_use_gtk4_opt" -DGUI=on \ + -DCLI=on -DSERVER=on \ -DUSE_OLD_SYSTEMD_SERVICE="%use_old_systemd_service" \ -DUSE_TCMALLOC=on -DUSE_SYSTEM_TCMALLOC="%enable_system_gperftools_opt" \ -DUSE_SYSTEM_ZLIB=on \ @@ -260,6 +288,9 @@ for embedded devices and low end boxes. %systemd_postun_with_restart yass-redir.service %changelog +* Thu Jun 13 2024 Chilledheart - 1.11.1-1 + - miscellaneous fixes + - add gtk3/gtk4/qt6 build profile (rpm) * Tue Jun 11 2024 Chilledheart - 1.11.0-1 - bump to chromium 127 dependents - add gtk3/gtk4/qt6 build profile (source)