From 3282dc5675ef00eb10b248e10c2f2af0aae896ac Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 14 Jul 2018 19:40:34 +0200 Subject: [PATCH] netconfig: GetRule filtering is not supported by Linux 4.4.0 (trusty) --- internal/netconfig/netconfig.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/netconfig/netconfig.go b/internal/netconfig/netconfig.go index 17b5c2f..02b74da 100644 --- a/internal/netconfig/netconfig.go +++ b/internal/netconfig/netconfig.go @@ -477,6 +477,19 @@ func getCounter(c *nftables.Conn, table *nftables.Table, chain *nftables.Chain) if err != nil { return DefaultCounter } + { + // TODO: remove this workaround once travis has workers with a newer kernel + // than its current Ubuntu trusty kernel (Linux 4.4.0): + var filtered []*nftables.Rule + for _, rule := range rules { + if rule.Table.Name != table.Name || + rule.Chain.Name != chain.Name { + continue + } + filtered = append(filtered, rule) + } + rules = filtered + } if got, want := len(rules), 1; got != want { log.Printf("could not carry counter values: unexpected number of rules in table %v, chain %v: got %d, want %d", table.Name, chain.Name, got, want) return DefaultCounter