• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3set -e
4#set -x
5
6# there is no legacy backend to test
7[[ $XT_MULTI == */xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
8
9# fill arptables manually
10
11$XT_MULTI arptables -F
12$XT_MULTI arptables -A INPUT -s 10.0.0.0/8 -j ACCEPT
13$XT_MULTI arptables -A INPUT -d 192.168.123.1 -j ACCEPT
14$XT_MULTI arptables -A INPUT --source-mac fe:ed:ba:be:00:01 -j ACCEPT
15$XT_MULTI arptables -A INPUT --destination-mac fe:ed:ba:be:00:01 -j ACCEPT
16$XT_MULTI arptables -N foo
17$XT_MULTI arptables -A foo -i lo -j ACCEPT
18$XT_MULTI arptables -A foo -l 6 -j ACCEPT
19$XT_MULTI arptables -A foo -j MARK --set-mark 12345
20$XT_MULTI arptables -A foo --opcode Request -j ACCEPT
21$XT_MULTI arptables -A foo --h-type 1 --proto-type 0x800 -j ACCEPT
22$XT_MULTI arptables -A foo -l 6 --h-type 1 --proto-type 0x800 -i lo --opcode Request -j ACCEPT
23$XT_MULTI arptables -A INPUT -j foo
24$XT_MULTI arptables -A INPUT
25
26$XT_MULTI arptables -A OUTPUT -o lo -j ACCEPT
27$XT_MULTI arptables -A OUTPUT -o eth134 -j mangle --mangle-ip-s 10.0.0.1
28$XT_MULTI arptables -A OUTPUT -o eth432 -j CLASSIFY --set-class feed:babe
29$XT_MULTI arptables -A OUTPUT -o eth432 --opcode Request -j CLASSIFY --set-class feed:babe
30$XT_MULTI arptables -P OUTPUT DROP
31
32# compare against stored arptables dump
33
34DUMP='*filter
35:INPUT ACCEPT
36:OUTPUT DROP
37:foo -
38-A INPUT -j ACCEPT -s 10.0.0.0/8
39-A INPUT -j ACCEPT -d 192.168.123.1
40-A INPUT -j ACCEPT --src-mac fe:ed:ba:be:00:01
41-A INPUT -j ACCEPT --dst-mac fe:ed:ba:be:00:01
42-A INPUT -j foo
43-A INPUT
44-A OUTPUT -j ACCEPT -o lo
45-A OUTPUT -j mangle -o eth134 --mangle-ip-s 10.0.0.1
46-A OUTPUT -j CLASSIFY -o eth432 --set-class feed:babe
47-A OUTPUT -j CLASSIFY -o eth432 --opcode 1 --set-class feed:babe
48-A foo -j ACCEPT -i lo
49-A foo -j ACCEPT
50-A foo -j MARK --set-mark 12345
51-A foo -j ACCEPT --opcode 1
52-A foo -j ACCEPT --proto-type 0x800
53-A foo -j ACCEPT -i lo --opcode 1 --proto-type 0x800'
54
55diff -u <(echo -e "$DUMP") <($XT_MULTI arptables-save | grep -v "^#")
56
57# make sure dump can be restored and check it didn't change
58
59$XT_MULTI arptables -F
60$XT_MULTI arptables-restore <<<$DUMP
61diff -u <(echo -e "$DUMP") <($XT_MULTI arptables-save | grep -v "^#")
62