Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: iptables stats tests for iptables >= 1.8.9 #113

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions iptables/iptables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,25 @@ func runRulesTests(t *testing.T, ipt *IPTables) {
}

opt := "--"
if ipt.proto == ProtocolIPv6 {
prot := "0"
if ipt.proto == ProtocolIPv6 &&
ipt.v1 == 1 && ipt.v2 <= 8 && ipt.v3 < 9 {
// this is fixed in iptables 1.8.9 via iptables/6e41c2d874
opt = " "
// this is fixed in iptables 1.8.9 via iptables/da8ecc62dd
prot = "all"
}
if ipt.proto == ProtocolIPv4 &&
ipt.v1 == 1 && ipt.v2 <= 8 && ipt.v3 < 9 {
// this is fixed in iptables 1.8.9 via iptables/da8ecc62dd
prot = "all"
}

expectedStats := [][]string{
{"0", "0", "ACCEPT", "all", opt, "*", "*", subnet1, address1, ""},
{"0", "0", "ACCEPT", "all", opt, "*", "*", subnet2, address2, ""},
{"0", "0", "ACCEPT", "all", opt, "*", "*", subnet2, address1, ""},
{"0", "0", "ACCEPT", "all", opt, "*", "*", address1, subnet2, ""},
{"0", "0", "ACCEPT", prot, opt, "*", "*", subnet1, address1, ""},
{"0", "0", "ACCEPT", prot, opt, "*", "*", subnet2, address2, ""},
{"0", "0", "ACCEPT", prot, opt, "*", "*", subnet2, address1, ""},
{"0", "0", "ACCEPT", prot, opt, "*", "*", address1, subnet2, ""},
}

if !reflect.DeepEqual(stats, expectedStats) {
Expand All @@ -400,10 +410,10 @@ func runRulesTests(t *testing.T, ipt *IPTables) {
_, subnet2CIDR, _ := net.ParseCIDR(subnet2)

expectedStructStats := []Stat{
{0, 0, "ACCEPT", "all", opt, "*", "*", subnet1CIDR, address1CIDR, ""},
{0, 0, "ACCEPT", "all", opt, "*", "*", subnet2CIDR, address2CIDR, ""},
{0, 0, "ACCEPT", "all", opt, "*", "*", subnet2CIDR, address1CIDR, ""},
{0, 0, "ACCEPT", "all", opt, "*", "*", address1CIDR, subnet2CIDR, ""},
{0, 0, "ACCEPT", prot, opt, "*", "*", subnet1CIDR, address1CIDR, ""},
{0, 0, "ACCEPT", prot, opt, "*", "*", subnet2CIDR, address2CIDR, ""},
{0, 0, "ACCEPT", prot, opt, "*", "*", subnet2CIDR, address1CIDR, ""},
{0, 0, "ACCEPT", prot, opt, "*", "*", address1CIDR, subnet2CIDR, ""},
}

if !reflect.DeepEqual(structStats, expectedStructStats) {
Expand Down
Loading