Signed-off-by: Andrey Epifanov <aepifanov@mirantis.com>
| ... | ... |
@@ -390,13 +390,6 @@ func programIngress(gwIP net.IP, ingressPorts []*PortConfig, isDelete bool) erro |
| 390 | 390 |
// TODO IPv6 support |
| 391 | 391 |
iptable := iptables.GetIptable(iptables.IPv4) |
| 392 | 392 |
|
| 393 |
- addDelOpt := "-I" |
|
| 394 |
- rollbackAddDelOpt := "-D" |
|
| 395 |
- if isDelete {
|
|
| 396 |
- addDelOpt = "-D" |
|
| 397 |
- rollbackAddDelOpt = "-I" |
|
| 398 |
- } |
|
| 399 |
- |
|
| 400 | 393 |
ingressMu.Lock() |
| 401 | 394 |
defer ingressMu.Unlock() |
| 402 | 395 |
|
| ... | ... |
@@ -408,6 +401,19 @@ func programIngress(gwIP net.IP, ingressPorts []*PortConfig, isDelete bool) erro |
| 408 | 408 |
|
| 409 | 409 |
// Filter the ingress ports until port rules start to be added/deleted |
| 410 | 410 |
filteredPorts := filterPortConfigs(ingressPorts, isDelete) |
| 411 |
+ |
|
| 412 |
+ return programIngressPorts(gwIP, filteredPorts, iptable, isDelete) |
|
| 413 |
+} |
|
| 414 |
+ |
|
| 415 |
+func programIngressPorts(gwIP net.IP, filteredPorts []*PortConfig, iptable *iptables.IPTable, isDelete bool) error {
|
|
| 416 |
+ |
|
| 417 |
+ addDelOpt := "-I" |
|
| 418 |
+ rollbackAddDelOpt := "-D" |
|
| 419 |
+ if isDelete {
|
|
| 420 |
+ addDelOpt = "-D" |
|
| 421 |
+ rollbackAddDelOpt = "-I" |
|
| 422 |
+ } |
|
| 423 |
+ |
|
| 411 | 424 |
rollbackRules := make([][]string, 0, len(filteredPorts)*3) |
| 412 | 425 |
var portErr error |
| 413 | 426 |
defer func() {
|