Skip to content

Commit

Permalink
gh-681 base framework for elasticIP reassociation
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed May 23, 2024
1 parent 58278f3 commit a836c19
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
12 changes: 8 additions & 4 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,15 @@ func RunAPIServer() {
server.ConfigureAPI()
// API server host list
server.Host = options.Opts.Host
server.TLSHost = options.Opts.TLSHost
server.TLSCertificateKey = options.Opts.TLSCertificateKey
server.TLSCertificate = options.Opts.TLSCertificate
server.Port = options.Opts.Port
server.TLSPort = options.Opts.TLSPort

if options.Opts.TLS {
server.TLSHost = options.Opts.TLSHost
server.TLSCertificateKey = options.Opts.TLSCertificateKey
server.TLSCertificate = options.Opts.TLSCertificate
server.TLSPort = options.Opts.TLSPort
}

api.ServerShutdown = func() {
waitApiServerShutOk()
os.Exit(0)
Expand Down
15 changes: 14 additions & 1 deletion pkg/loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ type ruleEnt struct {
sT time.Time
iTo uint32
act ruleAct
privIP net.IP
secIP []ruleNatSIP
stat ruleStat
name string
Expand Down Expand Up @@ -1443,6 +1444,7 @@ func (R *RuleH) AddNatLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg,
r.iTo = serv.InactiveTimeout
r.bgp = serv.Bgp
r.ci = cmn.CIDefault
r.privIP, _ = R.RuleVIP2PrivIP(sNetAddr.IP)

R.FoldRecursiveEPs(r)

Expand Down Expand Up @@ -2316,7 +2318,11 @@ func (r *ruleEnt) Nat2DP(work DpWorkT) int {
nWork.Work = work
nWork.Status = &r.sync
nWork.ZoneNum = r.zone.ZoneNum
nWork.ServiceIP = r.tuples.l3Dst.addr.IP.Mask(r.tuples.l3Dst.addr.Mask)
if r.privIP == nil || r.privIP.IsUnspecified() {
nWork.ServiceIP = r.tuples.l3Dst.addr.IP.Mask(r.tuples.l3Dst.addr.Mask)
} else {
nWork.ServiceIP = r.privIP
}
nWork.L4Port = r.tuples.l4Dst.val
nWork.Proto = r.tuples.l4Prot.val
nWork.Mark = int(r.ruleNum)
Expand Down Expand Up @@ -2700,3 +2706,10 @@ func (R *RuleH) RuleVIPSyncToClusterState() {
}
}
}

func (R *RuleH) RuleVIP2PrivIP(vip net.IP) (net.IP, error) {
if mh.cloudLabel == "aws" {
return AWSPrivateIpMapper(vip)
}
return nil, nil
}
4 changes: 4 additions & 0 deletions pkg/loxinet/utils_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,7 @@ func AWSApiInit() error {
tk.LogIt(tk.LogInfo, "AWS API init\n")
return nil
}

func AWSPrivateIpMapper(vip net.IP) (net.IP, error) {
return vip, nil
}

0 comments on commit a836c19

Please sign in to comment.