coreos / go-iptables

Go wrapper around iptables utility
Apache License 2.0
1.12k stars 256 forks source link

Only use alternative exit code for certain versions #60

Closed robbertkl closed 5 years ago

robbertkl commented 5 years ago

Fix for #59.

I've compiled different versions of iptables to see where the exit code changed. Starting with 1.8.1 it exits with 1, just like it does in legacy mode:

ip6tables v1.8.0 (nf_tables):  CHAIN_USER_ADD failed (File exists): chain DOCKER
4

ip6tables v1.8.1 (nf_tables): Chain already exists
1

I've added version checks similar to the other checks, to determine when to use the alternative exit code for comparison.

My fork is already used by https://github.com/robbertkl/docker-ipv6nat ; it would be awesome if the changes could be merged upstream so I can switch back.

robbertkl commented 5 years ago

Not sure why the tests fail on gofmt. I'm not getting any errors myself:

Building go-iptables...
Checking gofmt...
Running tests...
PASS
coverage: 72.1% of statements
Success
squeed commented 5 years ago

Given that 1.8.0 basically wasn't released, we just removed the workarounds from go-iptables. I think this can be closed, would you agree?

robbertkl commented 5 years ago

Sure, that would be OK, I'll switch my project to upstream again. I guess #59 can also be closed.