@@ -99,15 +99,17 @@ func NewChain(name, bridge string, table Table, hairpinMode bool) (*Chain, error
9999 case Nat :
100100 preroute := []string {
101101 "-m" , "addrtype" ,
102- "--dst-type" , "LOCAL" }
102+ "--dst-type" , "LOCAL" ,
103+ "-j" , c .Name }
103104 if ! Exists (Nat , "PREROUTING" , preroute ... ) {
104105 if err := c .Prerouting (Append , preroute ... ); err != nil {
105106 return nil , fmt .Errorf ("Failed to inject docker in PREROUTING chain: %s" , err )
106107 }
107108 }
108109 output := []string {
109110 "-m" , "addrtype" ,
110- "--dst-type" , "LOCAL" }
111+ "--dst-type" , "LOCAL" ,
112+ "-j" , c .Name }
111113 if ! hairpinMode {
112114 output = append (output , "!" , "--dst" , "127.0.0.0/8" )
113115 }
@@ -228,7 +230,7 @@ func (c *Chain) Prerouting(action Action, args ...string) error {
228230 if len (args ) > 0 {
229231 a = append (a , args ... )
230232 }
231- if output , err := Raw (append ( a , "-j" , c . Name ) ... ); err != nil {
233+ if output , err := Raw (a ... ); err != nil {
232234 return err
233235 } else if len (output ) != 0 {
234236 return ChainError {Chain : "PREROUTING" , Output : output }
@@ -242,7 +244,7 @@ func (c *Chain) Output(action Action, args ...string) error {
242244 if len (args ) > 0 {
243245 a = append (a , args ... )
244246 }
245- if output , err := Raw (append ( a , "-j" , c . Name ) ... ); err != nil {
247+ if output , err := Raw (a ... ); err != nil {
246248 return err
247249 } else if len (output ) != 0 {
248250 return ChainError {Chain : "OUTPUT" , Output : output }
@@ -254,9 +256,9 @@ func (c *Chain) Output(action Action, args ...string) error {
254256func (c * Chain ) Remove () error {
255257 // Ignore errors - This could mean the chains were never set up
256258 if c .Table == Nat {
257- c .Prerouting (Delete , "-m" , "addrtype" , "--dst-type" , "LOCAL" )
258- c .Output (Delete , "-m" , "addrtype" , "--dst-type" , "LOCAL" , "!" , "--dst" , "127.0.0.0/8" )
259- c .Output (Delete , "-m" , "addrtype" , "--dst-type" , "LOCAL" ) // Created in versions <= 0.1.6
259+ c .Prerouting (Delete , "-m" , "addrtype" , "--dst-type" , "LOCAL" , "-j" , c . Name )
260+ c .Output (Delete , "-m" , "addrtype" , "--dst-type" , "LOCAL" , "!" , "--dst" , "127.0.0.0/8" , "-j" , c . Name )
261+ c .Output (Delete , "-m" , "addrtype" , "--dst-type" , "LOCAL" , "-j" , c . Name ) // Created in versions <= 0.1.6
260262
261263 c .Prerouting (Delete )
262264 c .Output (Delete )
0 commit comments