Skip to content

Commit

Permalink
Merge pull request #889 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
#675 Initial support for proxy protocol v2
  • Loading branch information
UltraInstinct14 authored Nov 27, 2024
2 parents 35b5e0e + a99bcb3 commit 9b6d66c
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 2 deletions.
3 changes: 3 additions & 0 deletions api/models/loadbalance_entry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions api/restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/restapi/handler/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func ConfigPostLoadbalancer(params operations.PostConfigLoadbalancerParams) midd
lbRules.Serv.Name = params.Attr.ServiceArguments.Name
lbRules.Serv.Oper = cmn.LBOp(params.Attr.ServiceArguments.Oper)
lbRules.Serv.HostUrl = params.Attr.ServiceArguments.Host
lbRules.Serv.ProxyProtocolV2 = params.Attr.ServiceArguments.Proxyprotocolv2

if lbRules.Serv.Proto == "sctp" {
for _, data := range params.Attr.SecondaryIPs {
Expand Down Expand Up @@ -173,6 +174,7 @@ func ConfigGetLoadbalancer(params operations.GetConfigLoadbalancerAllParams) mid
tmpSvc.Name = lb.Serv.Name
tmpSvc.Snat = lb.Serv.Snat
tmpSvc.Host = lb.Serv.HostUrl
tmpSvc.Proxyprotocolv2 = lb.Serv.ProxyProtocolV2

tmpLB.ServiceArguments = &tmpSvc

Expand Down
3 changes: 3 additions & 0 deletions api/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3038,6 +3038,9 @@ definitions:
host:
type: string
description: Ingress specific host URL path
proxyprotocolv2:
type: boolean
description: flag to enable proxy protocol v2

endpoints:
type: array
Expand Down
2 changes: 2 additions & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,8 @@ type LbServiceArg struct {
Snat bool `json:"snat"`
// HostUrl - Ingress Specific URL path
HostUrl string `json:"path"`
// ProxyProtocolV2 - Enable proxy protocol v2
ProxyProtocolV2 bool `json:"proxyprotocolv2"`
}

// LbEndPointArg - Information related to load-balancer end-point
Expand Down
1 change: 1 addition & 0 deletions pkg/loxinet/dpbroker.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ type LBDpWorkQ struct {
DsrMode bool
CsumDis bool
SrcCheck bool
Ppv2En bool
SecMode SecT
HostURL string
Proto uint8
Expand Down
7 changes: 6 additions & 1 deletion pkg/loxinet/dpebpf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,10 @@ func DpLBRuleMod(w *LBDpWorkQ) int {
dat.ca.oaux = 1
}
if w.SrcCheck {
dat.chksrc = 1
dat.opflags = C.NAT_LB_OP_CHKSRC
}
if w.Ppv2En {
dat.ppv2 = 1
}

nxfa := (*nxfrmAct)(unsafe.Pointer(&dat.nxfrms[0]))
Expand Down Expand Up @@ -1265,6 +1268,8 @@ func (ct *DpCtInfo) convDPCt2GoObjFixup(ctKey *C.struct_dp_ct_key, ctDat *C.stru
ct.CState = "sync-ack"
case t.state == C.CT_TCP_EST:
ct.CState = "est"
case t.state == C.CT_TCP_PEST:
ct.CState = "est"
case t.state == C.CT_TCP_ERR:
ct.CState = "h/e"
case t.state == C.CT_TCP_CW:
Expand Down
6 changes: 6 additions & 0 deletions pkg/loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ type ruleEnt struct {
name string
inst string
secMode cmn.LBSec
ppv2En bool
srcList []*allowedSrcElem
locIPs map[string]struct{}
}
Expand Down Expand Up @@ -819,6 +820,7 @@ func (R *RuleH) GetLBRule() ([]cmn.LbRuleMod, error) {
ret.Serv.ProbeResp = data.hChk.prbResp
ret.Serv.Name = data.name
ret.Serv.HostUrl = data.tuples.path
ret.Serv.ProxyProtocolV2 = data.ppv2En
if data.act.actType == RtActSnat {
ret.Serv.Snat = true
}
Expand Down Expand Up @@ -1661,6 +1663,7 @@ func (R *RuleH) AddLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg, al
eRule.hChk.prbReq != serv.ProbeReq || eRule.hChk.prbResp != serv.ProbeResp ||
eRule.pTO != serv.PersistTimeout || eRule.act.action.(*ruleLBActs).sel != lBActs.sel ||
eRule.act.action.(*ruleLBActs).mode != lBActs.mode ||
eRule.ppv2En != serv.ProxyProtocolV2 ||
len(allowedSources) != len(eRule.srcList) {
ruleChg = true
}
Expand Down Expand Up @@ -1736,6 +1739,7 @@ func (R *RuleH) AddLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg, al
eRule.hChk.prbRetries = serv.ProbeRetries
eRule.hChk.prbTimeo = serv.ProbeTimeout
eRule.pTO = serv.PersistTimeout
eRule.ppv2En = serv.ProxyProtocolV2
eRule.act.action.(*ruleLBActs).sel = lBActs.sel
eRule.act.action.(*ruleLBActs).endPoints = retEps
eRule.act.action.(*ruleLBActs).mode = lBActs.mode
Expand Down Expand Up @@ -1781,6 +1785,7 @@ func (R *RuleH) AddLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg, al
r.managed = serv.Managed
r.secIP = nSecIP
r.secMode = serv.Security
r.ppv2En = serv.ProxyProtocolV2

// Per LB end-point health-check is supposed to be handled at kube-loxilb/CCM,
// but it certain cases like stand-alone mode, loxilb can do its own
Expand Down Expand Up @@ -2795,6 +2800,7 @@ func (r *ruleEnt) LB2DP(work DpWorkT) int {
nWork.InActTo = uint64(r.iTO)
nWork.PersistTo = uint64(r.pTO)
nWork.HostURL = r.tuples.path
nWork.Ppv2En = r.ppv2En
if len(r.srcList) > 0 {
nWork.SrcCheck = true
}
Expand Down

0 comments on commit 9b6d66c

Please sign in to comment.