1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Change in programming iptables in container

- iptables to provide a native API
- resolver.go to invoke the iptables native API
  when programming tables in the container

Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
Alessandro Boch 2016-02-05 10:34:48 -08:00 committed by aboch
parent 6f8712cd01
commit defcd4afb9
2 changed files with 13 additions and 2 deletions

View file

@ -325,9 +325,11 @@ func Raw(args ...string) ([]byte, error) {
if err == nil || !strings.Contains(err.Error(), "was not provided by any .service files") {
return output, err
}
}
return raw(args...)
}
func raw(args ...string) ([]byte, error) {
if err := initCheck(); err != nil {
return nil, err
}
@ -362,6 +364,15 @@ func RawCombinedOutput(args ...string) error {
return nil
}
// RawCombinedOutputNative behave as RawCombinedOutput with the difference it
// will always invoke `iptables` binary
func RawCombinedOutputNative(args ...string) error {
if output, err := raw(args...); err != nil || len(output) != 0 {
return fmt.Errorf("%s (%v)", string(output), err)
}
return nil
}
// ExistChain checks if a chain exists
func ExistChain(chain string, table Table) bool {
if _, err := Raw("-t", string(table), "-L", chain); err == nil {

View file

@ -95,7 +95,7 @@ func (r *resolver) SetupFunc() func() {
}
for _, rule := range rules {
r.err = iptables.RawCombinedOutput(rule...)
r.err = iptables.RawCombinedOutputNative(rule...)
if r.err != nil {
return
}