diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-05-08 15:39:04 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-05-08 15:44:54 -0700 |
commit | cfd30665c1d857f20dd05e67c6da6833770e2141 (patch) | |
tree | 223515237833691eeeaf1fc1ef19218a98b26831 /test/iptables/iptables_util.go | |
parent | e4d2d21f6b1b93146378ed5edc0c55d2ae4fb3af (diff) |
iptables - filter packets using outgoing interface.
Enables commands with -o (--out-interface) for iptables rules.
$ iptables -A OUTPUT -o eth0 -j ACCEPT
PiperOrigin-RevId: 310642286
Diffstat (limited to 'test/iptables/iptables_util.go')
-rw-r--r-- | test/iptables/iptables_util.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/iptables/iptables_util.go b/test/iptables/iptables_util.go index 2f988cd18..7146edbb9 100644 --- a/test/iptables/iptables_util.go +++ b/test/iptables/iptables_util.go @@ -169,3 +169,18 @@ func localAddrs() ([]string, error) { } return addrStrs, nil } + +// getInterfaceName returns the name of the interface other than loopback. +func getInterfaceName() (string, bool) { + var ifname string + if interfaces, err := net.Interfaces(); err == nil { + for _, intf := range interfaces { + if intf.Name != "lo" { + ifname = intf.Name + break + } + } + } + + return ifname, ifname != "" +} |