mirror of
https://github.com/moby/moby.git
synced 2026-08-03 22:51:03 +00:00
libnetwork: extract programIngressPorts steps in a separate functions
Signed-off-by: Andrey Epifanov <aepifanov@mirantis.com>
This commit is contained in:
committed by
Cory Snider
parent
752758ae77
commit
51ed289b06
@@ -390,13 +390,6 @@ func programIngress(gwIP net.IP, ingressPorts []*PortConfig, isDelete bool) erro
|
||||
// TODO IPv6 support
|
||||
iptable := iptables.GetIptable(iptables.IPv4)
|
||||
|
||||
addDelOpt := "-I"
|
||||
rollbackAddDelOpt := "-D"
|
||||
if isDelete {
|
||||
addDelOpt = "-D"
|
||||
rollbackAddDelOpt = "-I"
|
||||
}
|
||||
|
||||
ingressMu.Lock()
|
||||
defer ingressMu.Unlock()
|
||||
|
||||
@@ -408,6 +401,19 @@ func programIngress(gwIP net.IP, ingressPorts []*PortConfig, isDelete bool) erro
|
||||
|
||||
// Filter the ingress ports until port rules start to be added/deleted
|
||||
filteredPorts := filterPortConfigs(ingressPorts, isDelete)
|
||||
|
||||
return programIngressPorts(gwIP, filteredPorts, iptable, isDelete)
|
||||
}
|
||||
|
||||
func programIngressPorts(gwIP net.IP, filteredPorts []*PortConfig, iptable *iptables.IPTable, isDelete bool) error {
|
||||
|
||||
addDelOpt := "-I"
|
||||
rollbackAddDelOpt := "-D"
|
||||
if isDelete {
|
||||
addDelOpt = "-D"
|
||||
rollbackAddDelOpt = "-I"
|
||||
}
|
||||
|
||||
rollbackRules := make([][]string, 0, len(filteredPorts)*3)
|
||||
var portErr error
|
||||
defer func() {
|
||||
|
||||
Reference in New Issue
Block a user