gluon-ebtables: use Lua instead of sh for the rule DSL to increase flexibility
This commit is contained in:
parent
ee829e8c90
commit
0953c9befb
@ -1 +1 @@
|
|||||||
chain MULTICAST_OUT DROP
|
chain('MULTICAST_OUT', 'DROP')
|
||||||
|
@ -1 +1 @@
|
|||||||
rule MULTICAST_OUT -p ARP -j RETURN
|
rule 'MULTICAST_OUT -p ARP -j RETURN'
|
||||||
|
@ -1 +1 @@
|
|||||||
rule MULTICAST_OUT -p IPv6 --ip6-protocol udp --ip6-destination-port 6696 -j RETURN
|
rule 'MULTICAST_OUT -p IPv6 --ip6-protocol udp --ip6-destination-port 6696 -j RETURN'
|
||||||
|
@ -1 +1 @@
|
|||||||
rule MULTICAST_OUT -p IPv4 --ip-destination 239.192.152.143 --ip-protocol udp --ip-destination-port 6771 -j RETURN
|
rule 'MULTICAST_OUT -p IPv4 --ip-destination 239.192.152.143 --ip-protocol udp --ip-destination-port 6771 -j RETURN'
|
||||||
|
@ -1 +1 @@
|
|||||||
rule MULTICAST_OUT -p IPv4 --ip-protocol udp --ip-destination-port 67 -j RETURN
|
rule 'MULTICAST_OUT -p IPv4 --ip-protocol udp --ip-destination-port 67 -j RETURN'
|
||||||
|
@ -1 +1 @@
|
|||||||
rule MULTICAST_OUT -p IPv6 --ip6-protocol udp --ip6-destination-port 546 -j RETURN
|
rule 'MULTICAST_OUT -p IPv6 --ip6-protocol udp --ip6-destination-port 546 -j RETURN'
|
||||||
|
@ -1 +1 @@
|
|||||||
rule MULTICAST_OUT -p IPv4 --ip-protocol icmp -j RETURN
|
rule 'MULTICAST_OUT -p IPv4 --ip-protocol icmp -j RETURN'
|
||||||
|
@ -1 +1 @@
|
|||||||
rule MULTICAST_OUT -p IPv6 --ip6-protocol ipv6-icmp -j RETURN
|
rule 'MULTICAST_OUT -p IPv6 --ip6-protocol ipv6-icmp -j RETURN'
|
||||||
|
@ -1 +1 @@
|
|||||||
rule MULTICAST_OUT -p IPv4 --ip-protocol igmp -j RETURN
|
rule 'MULTICAST_OUT -p IPv4 --ip-protocol igmp -j RETURN'
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
rule MULTICAST_OUT -p IPv4 --ip-protocol ospf -j RETURN
|
rule 'MULTICAST_OUT -p IPv4 --ip-protocol ospf -j RETURN'
|
||||||
rule MULTICAST_OUT -p IPv6 --ip6-protocol ospf -j RETURN
|
rule 'MULTICAST_OUT -p IPv6 --ip6-protocol ospf -j RETURN'
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
rule FORWARD --logical-out br-client -o bat0 -d Multicast -j MULTICAST_OUT
|
rule 'FORWARD --logical-out br-client -o bat0 -d Multicast -j MULTICAST_OUT'
|
||||||
rule OUTPUT --logical-out br-client -o bat0 -d Multicast -j MULTICAST_OUT
|
rule 'OUTPUT --logical-out br-client -o bat0 -d Multicast -j MULTICAST_OUT'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
rule FORWARD -p IPv4 --ip-protocol udp --ip-destination-port 67 -j OUT_ONLY
|
rule 'FORWARD -p IPv4 --ip-protocol udp --ip-destination-port 67 -j OUT_ONLY'
|
||||||
rule OUTPUT -p IPv4 --ip-protocol udp --ip-destination-port 67 -j OUT_ONLY
|
rule 'OUTPUT -p IPv4 --ip-protocol udp --ip-destination-port 67 -j OUT_ONLY'
|
||||||
|
|
||||||
rule FORWARD -p IPv4 --ip-protocol udp --ip-destination-port 68 -j IN_ONLY
|
rule 'FORWARD -p IPv4 --ip-protocol udp --ip-destination-port 68 -j IN_ONLY'
|
||||||
rule INPUT -p IPv4 --ip-protocol udp --ip-destination-port 68 -j IN_ONLY
|
rule 'INPUT -p IPv4 --ip-protocol udp --ip-destination-port 68 -j IN_ONLY'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
rule FORWARD -p IPv6 --ip6-protocol udp --ip6-destination-port 546 -j OUT_ONLY
|
rule 'FORWARD -p IPv6 --ip6-protocol udp --ip6-destination-port 546 -j OUT_ONLY'
|
||||||
rule OUTPUT -p IPv6 --ip6-protocol udp --ip6-destination-port 546 -j OUT_ONLY
|
rule 'OUTPUT -p IPv6 --ip6-protocol udp --ip6-destination-port 546 -j OUT_ONLY'
|
||||||
|
|
||||||
rule FORWARD -p IPv6 --ip6-protocol udp --ip6-destination-port 547 -j IN_ONLY
|
rule 'FORWARD -p IPv6 --ip6-protocol udp --ip6-destination-port 547 -j IN_ONLY'
|
||||||
rule INPUT -p IPv6 --ip6-protocol udp --ip6-destination-port 547 -j IN_ONLY
|
rule 'INPUT -p IPv6 --ip6-protocol udp --ip6-destination-port 547 -j IN_ONLY'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
rule FORWARD -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type router-solicitation -j OUT_ONLY
|
rule 'FORWARD -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type router-solicitation -j OUT_ONLY'
|
||||||
rule OUTPUT -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type router-solicitation -j OUT_ONLY
|
rule 'OUTPUT -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type router-solicitation -j OUT_ONLY'
|
||||||
|
|
||||||
rule FORWARD -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type router-advertisement -j IN_ONLY
|
rule 'FORWARD -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type router-advertisement -j IN_ONLY'
|
||||||
rule INPUT -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type router-advertisement -j IN_ONLY
|
rule 'INPUT -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type router-advertisement -j IN_ONLY'
|
||||||
|
@ -23,15 +23,14 @@ STOP=91
|
|||||||
exec_file() {
|
exec_file() {
|
||||||
local file="$1"
|
local file="$1"
|
||||||
|
|
||||||
sh -c "
|
/usr/bin/lua -e "
|
||||||
eval 'rule() {
|
function rule(command)
|
||||||
$EBTABLES_RULE
|
os.execute($EBTABLES_RULE)
|
||||||
}'
|
end
|
||||||
eval 'chain() {
|
function chain(name, policy)
|
||||||
$EBTABLES_CHAIN
|
os.execute($EBTABLES_CHAIN)
|
||||||
}'
|
end
|
||||||
source \"$1\"
|
" "$file"
|
||||||
" - "$file"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exec_all() {
|
exec_all() {
|
||||||
@ -49,8 +48,8 @@ exec_all() {
|
|||||||
|
|
||||||
start() {
|
start() {
|
||||||
(
|
(
|
||||||
export EBTABLES_RULE='ebtables -A "$@"'
|
export EBTABLES_RULE='"ebtables -A " .. command'
|
||||||
export EBTABLES_CHAIN='ebtables -N "$1" -P "$2"'
|
export EBTABLES_CHAIN='"ebtables -N " .. name .. " -P " .. policy'
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
exec_all ''
|
exec_all ''
|
||||||
@ -62,8 +61,8 @@ start() {
|
|||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
(
|
(
|
||||||
export EBTABLES_RULE='ebtables -D "$@"'
|
export EBTABLES_RULE='"ebtables -D " .. command'
|
||||||
export EBTABLES_CHAIN='ebtables -X "$1"'
|
export EBTABLES_CHAIN='"ebtables -X " .. name'
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
exec_all '-r'
|
exec_all '-r'
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
chain IN_ONLY RETURN
|
chain('IN_ONLY', 'RETURN')
|
||||||
chain OUT_ONLY RETURN
|
chain('OUT_ONLY', 'RETURN')
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
rule IN_ONLY --logical-in br-client -i ! bat0 -j DROP
|
rule 'IN_ONLY --logical-in br-client -i ! bat0 -j DROP'
|
||||||
rule OUT_ONLY --logical-out br-client -o ! bat0 -j DROP
|
rule 'OUT_ONLY --logical-out br-client -o ! bat0 -j DROP'
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
rule FORWARD --logical-out br-client -o bat0 -d @next_node.mac@ -j DROP
|
rule 'FORWARD --logical-out br-client -o bat0 -d @next_node.mac@ -j DROP'
|
||||||
rule OUTPUT --logical-out br-client -o bat0 -d @next_node.mac@ -j DROP
|
rule 'OUTPUT --logical-out br-client -o bat0 -d @next_node.mac@ -j DROP'
|
||||||
rule FORWARD --logical-out br-client -o bat0 -s @next_node.mac@ -j DROP
|
rule 'FORWARD --logical-out br-client -o bat0 -s @next_node.mac@ -j DROP'
|
||||||
rule OUTPUT --logical-out br-client -o bat0 -s @next_node.mac@ -j DROP
|
rule 'OUTPUT --logical-out br-client -o bat0 -s @next_node.mac@ -j DROP'
|
||||||
|
|
||||||
rule FORWARD --logical-out br-client -o bat0 -p IPv4 --ip-destination @next_node.ip4@ -j DROP
|
rule 'FORWARD --logical-out br-client -o bat0 -p IPv4 --ip-destination @next_node.ip4@ -j DROP'
|
||||||
rule OUTPUT --logical-out br-client -o bat0 -p IPv4 --ip-destination @next_node.ip4@ -j DROP
|
rule 'OUTPUT --logical-out br-client -o bat0 -p IPv4 --ip-destination @next_node.ip4@ -j DROP'
|
||||||
rule FORWARD --logical-out br-client -o bat0 -p IPv4 --ip-source @next_node.ip4@ -j DROP
|
rule 'FORWARD --logical-out br-client -o bat0 -p IPv4 --ip-source @next_node.ip4@ -j DROP'
|
||||||
rule OUTPUT --logical-out br-client -o bat0 -p IPv4 --ip-source @next_node.ip4@ -j DROP
|
rule 'OUTPUT --logical-out br-client -o bat0 -p IPv4 --ip-source @next_node.ip4@ -j DROP'
|
||||||
|
|
||||||
rule FORWARD --logical-out br-client -o bat0 -p IPv6 --ip6-destination @next_node.ip6@ -j DROP
|
rule 'FORWARD --logical-out br-client -o bat0 -p IPv6 --ip6-destination @next_node.ip6@ -j DROP'
|
||||||
rule OUTPUT --logical-out br-client -o bat0 -p IPv6 --ip6-destination @next_node.ip6@ -j DROP
|
rule 'OUTPUT --logical-out br-client -o bat0 -p IPv6 --ip6-destination @next_node.ip6@ -j DROP'
|
||||||
rule FORWARD --logical-out br-client -o bat0 -p IPv6 --ip6-source @next_node.ip6@ -j DROP
|
rule 'FORWARD --logical-out br-client -o bat0 -p IPv6 --ip6-source @next_node.ip6@ -j DROP'
|
||||||
rule OUTPUT --logical-out br-client -o bat0 -p IPv6 --ip6-source @next_node.ip6@ -j DROP
|
rule 'OUTPUT --logical-out br-client -o bat0 -p IPv6 --ip6-source @next_node.ip6@ -j DROP'
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
rule INPUT -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type router-solicitation -i bat0 -j DROP
|
rule 'INPUT -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type router-solicitation -i bat0 -j DROP'
|
||||||
rule OUTPUT -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type router-advertisement -o bat0 -j DROP
|
rule 'OUTPUT -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type router-advertisement -o bat0 -j DROP'
|
||||||
|
Loading…
Reference in New Issue
Block a user