-
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.
Merge pull request #543 from NethServer/nathelper
Refactor NAT helpers #544
- Loading branch information
Showing
10 changed files
with
123 additions
and
15 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,4 @@ | ||
CONFIG_PACKAGE_kmod-nf-nathelper=y | ||
CONFIG_PACKAGE_kmod-asn1-decoder=y | ||
CONFIG_PACKAGE_kmod-lib-textsearch=y | ||
CONFIG_PACKAGE_kmod-nf-nathelper-extra=y |
This file was deleted.
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
Empty file.
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
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,30 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Copyright (C) 2024 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
# | ||
|
||
# Load all kernel modules from /etc/modules.d/ns-nathelpers | ||
# Example: | ||
# nf_conntrack_sip sip_external_media=1 sip_direct_media=1 | ||
|
||
exit_code=0 | ||
|
||
# Load all module | ||
for line in "$(grep -v '^#' /etc/modules.d/ns-nathelpers)"; do | ||
module=$(echo $line | awk '{print $1}') | ||
modprobe $module | ||
for param in $(echo $line | awk '{for(i=2;i<=NF;++i)print $i}'); do | ||
# Set parameter using /sys since modprobe doesn't support parameters | ||
key=$(echo $param | cut -d= -f1) | ||
value=$(echo $param | cut -d= -f2) | ||
echo $value > /sys/module/$module/parameters/$key | ||
if [ $? -ne 0 ]; then | ||
exit_code=99 | ||
fi | ||
done | ||
done | ||
|
||
# Special exit code 99 means that at least one parameter failed to be set | ||
exit $exit_code |
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,31 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Copyright (C) 2024 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
# | ||
|
||
# Load all kernel modules from /etc/modules.d/ns-nathelpers | ||
# Example: | ||
# nf_conntrack_sip sip_external_media=1 sip_direct_media=1 | ||
|
||
exit_code=0 | ||
|
||
# Load all module | ||
for line in "$(grep -v '^#' /etc/modules.d/ns-nathelpers)"; do | ||
module=$(echo $line | awk '{print $1}') | ||
modprobe $module | ||
exit_code=$? | ||
for param in $(echo $line | awk '{for(i=2;i<=NF;++i)print $i}'); do | ||
# Set parameter using /sys since modprobe doesn't support parameters | ||
key=$(echo $param | cut -d= -f1) | ||
value=$(echo $param | cut -d= -f2) | ||
echo $value > /sys/module/$module/parameters/$key | ||
if [ $? -ne 0 ]; then | ||
exit_code=99 | ||
fi | ||
done | ||
done | ||
|
||
# Special exit code 99 means that at least one parameter failed to be set | ||
exit $exit_code |
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 @@ | ||
/etc/modules.d/ns-nathelpers |
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
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,24 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# Copyright (C) 2024 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
# | ||
|
||
|
||
> /etc/modules.d/ns-nathelpers | ||
|
||
# Configure FTP helpers | ||
for m in $(opkg files kmod-nf-nathelper | grep -e '\.ko$' | cut -d'/' -f 5 | cut -d'.' -f1); do | ||
echo $m >> /etc/modules.d/ns-nathelpers | ||
done | ||
|
||
# Configure all extra helpers | ||
for m in $(opkg files kmod-nf-nathelper-extra | grep -e '\.ko$' | cut -d'/' -f 5 | cut -d'.' -f1); do | ||
echo $m >> /etc/modules.d/ns-nathelpers | ||
done | ||
|
||
# Load all helpers | ||
for m in $(cat /etc/modules.d/ns-nathelpers); do | ||
modprobe $m | ||
done |