From 56375f3687e9697d7480f1c84b836f971cb51eb7 Mon Sep 17 00:00:00 2001 From: Madhu Venugopal Date: Tue, 19 May 2015 15:28:48 -0700 Subject: [PATCH] Porting https://github.com/docker/docker/pull/12437 Signed-off-by: Madhu Venugopal --- libnetwork/iptables/iptables.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/libnetwork/iptables/iptables.go b/libnetwork/iptables/iptables.go index 949bff3971..4299a7e2b6 100644 --- a/libnetwork/iptables/iptables.go +++ b/libnetwork/iptables/iptables.go @@ -5,7 +5,6 @@ import ( "fmt" "net" "os/exec" - "regexp" "strconv" "strings" "sync" @@ -282,14 +281,7 @@ func Exists(table Table, chain string, rule ...string) bool { ruleString := strings.Join(rule, " ") existingRules, _ := exec.Command(iptablesPath, "-t", string(table), "-S", chain).Output() - // regex to replace ips in rule - // because MASQUERADE rule will not be exactly what was passed - re := regexp.MustCompile(`[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\/[0-9]{1,2}`) - - return strings.Contains( - re.ReplaceAllString(string(existingRules), "?"), - re.ReplaceAllString(ruleString, "?"), - ) + return strings.Contains(string(existingRules), ruleString) } // Raw calls 'iptables' system command, passing supplied arguments.