Skip to content

Commit 04e09bb

Browse files
authored
Merge pull request moby#50845 from robmry/iterate_over_nftables_rules
nftables: iterate over rules
2 parents 4021bd7 + ed78637 commit 04e09bb

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

daemon/libnetwork/internal/nftables/nftables_linux.go

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import (
4949
"errors"
5050
"fmt"
5151
"io"
52+
"iter"
5253
"os/exec"
5354
"runtime"
5455
"slices"
@@ -1036,9 +1037,9 @@ func (t *table) updatesApplied() {
10361037
t.MustFlush = false
10371038
}
10381039

1039-
/* Can't make text/template range over this, not sure why ...
1040+
// Rules returns an iterator that yields the chain's rules in order.
10401041
func (c *chain) Rules() iter.Seq[string] {
1041-
groups := make([]int, 0, len(c.ruleGroups))
1042+
groups := make([]RuleGroup, 0, len(c.ruleGroups))
10421043
for group := range c.ruleGroups {
10431044
groups = append(groups, group)
10441045
}
@@ -1053,23 +1054,6 @@ func (c *chain) Rules() iter.Seq[string] {
10531054
}
10541055
}
10551056
}
1056-
*/
1057-
1058-
// Rules returns the chain's rules, in order.
1059-
func (c *chain) Rules() []string {
1060-
groups := make([]RuleGroup, 0, len(c.ruleGroups))
1061-
nRules := 0
1062-
for group := range c.ruleGroups {
1063-
groups = append(groups, group)
1064-
nRules += len(c.ruleGroups[group])
1065-
}
1066-
slices.Sort(groups)
1067-
rules := make([]string, 0, nRules)
1068-
for _, group := range groups {
1069-
rules = append(rules, c.ruleGroups[group]...)
1070-
}
1071-
return rules
1072-
}
10731057

10741058
func parseTemplate() error {
10751059
var err error

0 commit comments

Comments
 (0)