@@ -7,8 +7,10 @@ https://github.com/kubernetes/kubernetes/blob/master/pkg/util/iptables
77package iptm
88
99import (
10+ "fmt"
1011 "os"
1112 "os/exec"
13+ "strings"
1214 "syscall"
1315 "time"
1416
@@ -21,11 +23,13 @@ import (
2123
2224// IptEntry represents an iptables rule.
2325type IptEntry struct {
24- Name string
25- HashedName string
26- Chain string
27- Flag string
28- Specs []string
26+ Command string
27+ Name string
28+ HashedName string
29+ Chain string
30+ Flag string
31+ LockWaitTimeInSeconds string
32+ Specs []string
2933}
3034
3135// IptablesManager stores iptables entries.
@@ -329,10 +333,15 @@ func (iptMgr *IptablesManager) Delete(entry *IptEntry) error {
329333
330334// Run execute an iptables command to update iptables.
331335func (iptMgr * IptablesManager ) Run (entry * IptEntry ) (int , error ) {
332- cmdName := util .Iptables
333- cmdArgs := append ([]string {util .IptablesWaitFlag , iptMgr .OperationFlag , entry .Chain }, entry .Specs ... )
336+ if entry .Command == "" {
337+ entry .Command = util .Iptables
338+ }
339+
340+ waitFlag := fmt .Sprintf ("%s %s" , util .IptablesWaitFlag , entry .LockWaitTimeInSeconds )
341+ waitFlag = strings .TrimSpace (waitFlag )
342+ cmdArgs := append ([]string {waitFlag , iptMgr .OperationFlag , entry .Chain }, entry .Specs ... )
334343
335- cmdOut , err := exec .Command (cmdName , cmdArgs ... ).Output ()
344+ cmdOut , err := exec .Command (entry . Command , cmdArgs ... ).Output ()
336345 log .Printf ("%s\n " , string (cmdOut ))
337346
338347 if msg , failed := err .(* exec.ExitError ); failed {
0 commit comments