|
@@ -142,7 +142,7 @@ func (n *network) addLBBackend(ip net.IP, lb *loadBalancer) {
|
|
|
}
|
|
|
|
|
|
logrus.Debugf("Creating service for vip %s fwMark %d ingressPorts %#v in sbox %.7s (%.7s)", lb.vip, lb.fwMark, lb.service.ingressPorts, sb.ID(), sb.ContainerID())
|
|
|
- if err := invokeFWMarker(sb.Key(), lb.vip, lb.fwMark, lb.service.ingressPorts, eIP, false); err != nil {
|
|
|
+ if err := invokeFWMarker(sb.Key(), lb.vip, lb.fwMark, lb.service.ingressPorts, eIP, false, n.ingress); err != nil {
|
|
|
logrus.Errorf("Failed to add firewall mark rule in sbox %.7s (%.7s): %v", sb.ID(), sb.ContainerID(), err)
|
|
|
return
|
|
|
}
|
|
@@ -158,6 +158,9 @@ func (n *network) addLBBackend(ip net.IP, lb *loadBalancer) {
|
|
|
Address: ip,
|
|
|
Weight: 1,
|
|
|
}
|
|
|
+ if !n.ingress {
|
|
|
+ d.ConnectionFlags = ipvs.ConnFwdDirectRoute
|
|
|
+ }
|
|
|
|
|
|
// Remove the sched name before using the service to add
|
|
|
// destination.
|
|
@@ -203,6 +206,9 @@ func (n *network) rmLBBackend(ip net.IP, lb *loadBalancer, rmService bool, fullR
|
|
|
Address: ip,
|
|
|
Weight: 1,
|
|
|
}
|
|
|
+ if !n.ingress {
|
|
|
+ d.ConnectionFlags = ipvs.ConnFwdDirectRoute
|
|
|
+ }
|
|
|
|
|
|
if fullRemove {
|
|
|
if err := i.DelDestination(s, d); err != nil && err != syscall.ENOENT {
|
|
@@ -231,7 +237,7 @@ func (n *network) rmLBBackend(ip net.IP, lb *loadBalancer, rmService bool, fullR
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if err := invokeFWMarker(sb.Key(), lb.vip, lb.fwMark, lb.service.ingressPorts, eIP, true); err != nil {
|
|
|
+ if err := invokeFWMarker(sb.Key(), lb.vip, lb.fwMark, lb.service.ingressPorts, eIP, true, n.ingress); err != nil {
|
|
|
logrus.Errorf("Failed to delete firewall mark rule in sbox %.7s (%.7s): %v", sb.ID(), sb.ContainerID(), err)
|
|
|
}
|
|
|
|
|
@@ -566,7 +572,7 @@ func readPortsFromFile(fileName string) ([]*PortConfig, error) {
|
|
|
|
|
|
// Invoke fwmarker reexec routine to mark vip destined packets with
|
|
|
// the passed firewall mark.
|
|
|
-func invokeFWMarker(path string, vip net.IP, fwMark uint32, ingressPorts []*PortConfig, eIP *net.IPNet, isDelete bool) error {
|
|
|
+func invokeFWMarker(path string, vip net.IP, fwMark uint32, ingressPorts []*PortConfig, eIP *net.IPNet, isDelete bool, isIngress bool) error {
|
|
|
var ingressPortsFile string
|
|
|
|
|
|
if len(ingressPorts) != 0 {
|
|
@@ -584,9 +590,14 @@ func invokeFWMarker(path string, vip net.IP, fwMark uint32, ingressPorts []*Port
|
|
|
addDelOpt = "-D"
|
|
|
}
|
|
|
|
|
|
+ isIngressOpt := "false"
|
|
|
+ if isIngress {
|
|
|
+ isIngressOpt = "true"
|
|
|
+ }
|
|
|
+
|
|
|
cmd := &exec.Cmd{
|
|
|
Path: reexec.Self(),
|
|
|
- Args: append([]string{"fwmarker"}, path, vip.String(), fmt.Sprintf("%d", fwMark), addDelOpt, ingressPortsFile, eIP.String()),
|
|
|
+ Args: append([]string{"fwmarker"}, path, vip.String(), fmt.Sprintf("%d", fwMark), addDelOpt, ingressPortsFile, eIP.String(), isIngressOpt),
|
|
|
Stdout: os.Stdout,
|
|
|
Stderr: os.Stderr,
|
|
|
}
|
|
@@ -603,7 +614,7 @@ func fwMarker() {
|
|
|
runtime.LockOSThread()
|
|
|
defer runtime.UnlockOSThread()
|
|
|
|
|
|
- if len(os.Args) < 7 {
|
|
|
+ if len(os.Args) < 8 {
|
|
|
logrus.Error("invalid number of arguments..")
|
|
|
os.Exit(1)
|
|
|
}
|
|
@@ -645,7 +656,8 @@ func fwMarker() {
|
|
|
os.Exit(5)
|
|
|
}
|
|
|
|
|
|
- if addDelOpt == "-A" {
|
|
|
+ isIngressOpt := os.Args[7]
|
|
|
+ if addDelOpt == "-A" && isIngressOpt == "true" {
|
|
|
eIP, subnet, err := net.ParseCIDR(os.Args[6])
|
|
|
if err != nil {
|
|
|
logrus.Errorf("Failed to parse endpoint IP %s: %v", os.Args[6], err)
|