This repository has been archived by the owner on Jun 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e0db2c2
Showing
12 changed files
with
9,048 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Build Kernel Module | ||
|
||
on: | ||
push: | ||
branches: | ||
- "master" | ||
tags: | ||
- "*" | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
|
||
jobs: | ||
get-firmware-list: | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
firmwares: ${{ steps.get-firmwares.outputs.directories }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build firmware list from directories in ./firmware | ||
id: get-firmwares | ||
run: | ||
python3 ci/dir_to_json.py ./firmware >> $GITHUB_OUTPUT | ||
|
||
build-module: | ||
runs-on: ubuntu-22.04 | ||
needs: get-firmware-list | ||
strategy: | ||
matrix: | ||
firmware: ${{ fromJSON(needs.get-firmware-list.outputs.firmwares) }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Load configuration for this firmware | ||
run: echo CONFIG=$(jq -c . firmware/${{ matrix.firmware }}/config.json) >> $GITHUB_ENV | ||
- name: Download kernel | ||
run: | | ||
curl -o kernel.tar.gz "${{ fromJson(env.CONFIG).kernel_tar_uri }}" | ||
mkdir linux-source | ||
tar -xf kernel.tar.gz --strip-components=1 -C linux-source | ||
- name: Copy kernel config file into kernel directory | ||
run: cp firmware/${{ matrix.firmware }}/kernel-config linux-source/.config | ||
- name: Apply firmware-specific patches | ||
run: find firmware/${{ matrix.firmware }}/patches -type f -name '*.patch' -print0 | sort -z | xargs -t -0 -n 1 patch -p0 -i | ||
- name: Prepare for building | ||
run: | | ||
sudo apt install gcc-aarch64-linux-gnu | ||
cd linux-source | ||
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- olddefconfig prepare modules_prepare | ||
- name: Build the module | ||
run: | | ||
cd linux-source | ||
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- drivers/net/macvlan.ko | ||
- name: Add the module to the artifact directory | ||
run: | | ||
mkdir modules | ||
cp linux-source/drivers/net/macvlan.ko modules/${{matrix.firmware}}-macvlan.ko | ||
- name: Store the artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: modules | ||
path: modules | ||
|
||
release: | ||
if: startsWith(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- build-module | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: modules | ||
path: modules | ||
- name: Create setup_macvlan.sh | ||
run: | | ||
sed 's/%%GITHUB_TAG%%/${{ github.ref_name }}/' ci/setup_macvlan.sh.tpl > setup_macvlan.sh | ||
- name: Create release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
modules/* | ||
setup_macvlan.sh |
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# macvlan.ko for Unifi UDR | ||
|
||
Ui stopped including the macvlan kernel module for the UDR. This brings it back | ||
|
||
## Installation | ||
|
||
1. Get the file `setup_macvlan.sh` from the [latest release](https://github.com/whi-tw/macvlan-unifi-udr/releases/latest) and transfer it to the UDR | ||
1. Run it on the UDR via ssh `bash ./setup_macvlan.sh` | ||
1. Run the script `/data/on_boot.d/01-load-macvlan-module.sh` | ||
1. Continue what you were doing before that relied on having `macvlan` available | ||
|
||
## Updates | ||
|
||
This relies on the GPL archives provided by Ui. Unfortunately, these need to be requested manually for every firmware release. This means that there's no good automatic way of keeping it updated. | ||
|
||
There is a check in place - this will only attempt to load the module build for the current firmware, so if you update UnifiOS on the UDR, the module will stop loading. I'd recommend turning auto update off, so this doesn't happen. | ||
|
||
If I haven't noticed a new firmware release, please raise an issue and I'll get onto UI to get the GPL dump out. | ||
|
||
Theoretically, the module will work on any release with the same kernel version (eg. the current dump is for 2.2.12, but the module works on 3.0.13 as they use the same kernel.). If you test this and it works fine, let me know and I'll short-circuit the update process. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
import os | ||
import sys | ||
|
||
target_dir = os.path.abspath(sys.argv[1]) | ||
|
||
directories = [] | ||
|
||
contents = os.listdir(target_dir) | ||
|
||
for item in contents: | ||
item_full_path = os.path.join(target_dir, item) | ||
if os.path.isdir(item_full_path): | ||
directories.append(item) | ||
|
||
print(f"directories={json.dumps(directories)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
RUNNING_FIRMWARE_VERSION="$(ubnt-device-info firmware)" | ||
MODULE_FILE_NAME="${RUNNING_FIRMWARE_VERSION}-macvlan.ko" | ||
|
||
RELEASE_DOWNLOAD_URL_BASE="https://github.com/whi-tw/macvlan-unifi-udr/releases/download/%%GITHUB_TAG%%" | ||
RELEASE_DOWNLOAD_URL="${RELEASE_DOWNLOAD_URL_BASE}/${MODULE_FILE_NAME}" | ||
|
||
DATA_DIR="/data" | ||
MODULE_DIR="/data/macvlan-module" | ||
|
||
mkdir -p "${MODULE_DIR}" | ||
|
||
curl -Lo "${MODULE_DIR}/${MODULE_FILE_NAME}" "${RELEASE_DOWNLOAD_URL}" | ||
|
||
cat <<'EOF'> /data/on_boot.d/01-load-macvlan-module.sh | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
RUNNING_FIRMWARE_VERSION="$(ubnt-device-info firmware)" | ||
MODULE_FILE_NAME="${RUNNING_FIRMWARE_VERSION}-macvlan.ko" | ||
insmod /data/macvlan-module/${MODULE_FILE_NAME} | ||
EOF | ||
|
||
chmod +x /data/on_boot.d/01-load-macvlan-module.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"kernel_tar_uri": "https://unifios.s3.us-west-2.amazonaws.com/linux-udr-2.2.12.tar.gz" | ||
} |
Oops, something went wrong.