Skip to content

Commit

Permalink
loxilb-iogh-219 Continued implementation - Use session for decapsulation
Browse files Browse the repository at this point in the history
  • Loading branch information
PacketCrunch committed Feb 8, 2023
1 parent bfe1a13 commit 3d976b4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions loxinet/dpbroker.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ type UlClDpWorkQ struct {
TDip net.IP
TSip net.IP
TTeID uint32
Type DpTunT
}

// DpSyncOpT - Sync Operation type
Expand Down
7 changes: 6 additions & 1 deletion loxinet/dpebpf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,12 @@ func (e *DpEbpfH) DpUlClMod(w *UlClDpWorkQ) int {
C.memset(unsafe.Pointer(dat), 0, C.sizeof_struct_dp_sess_tact)

if key.teid != 0 {
dat.ca.act_type = C.DP_SET_RM_GTP
if w.Type == DpTunIPIP {
dat.ca.act_type = C.DP_SET_RM_IPIP
} else {
dat.ca.act_type = C.DP_SET_RM_GTP
}

dat.ca.cidx = C.uint(w.HwMark)
dat.qfi = C.uchar(w.Qfi)
} else {
Expand Down
31 changes: 29 additions & 2 deletions loxinet/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ type PortSwInfo struct {
PortActive bool
PortReal *Port
PortOvl *Port
SessMark int
BpfLoaded bool
}

Expand Down Expand Up @@ -209,7 +210,7 @@ func (P *PortsH) PortAdd(name string, osid int, ptype int, zone string,
p.HInfo.Link = hwi.Link
p.HInfo.State = hwi.State
p.HInfo.Mtu = hwi.Mtu
if bytes.Equal(hwi.MacAddr[:], p.HInfo.MacAddr[:]) == false {
if !p.IsL3TunPort() && bytes.Equal(hwi.MacAddr[:], p.HInfo.MacAddr[:]) == false {
p.HInfo.MacAddr = hwi.MacAddr
p.DP(DpCreate)
}
Expand Down Expand Up @@ -379,6 +380,13 @@ func (P *PortsH) PortAdd(name string, osid int, ptype int, zone string,
}
p.L2.IsPvid = true
p.L2.Vid = int(p.HInfo.TunID)
case cmn.PortIPTun:
p.SInfo.SessMark, err = zn.Sess.HwMark.GetCounter()
if err != nil {
tk.LogIt(tk.LogError, "port add - %s sess-alloc fail\n", name)
p.SInfo.SessMark = 0
}
p.L2 = l2i
default:
tk.LogIt(tk.LogDebug, "port add - %s isPvid %v\n", name, p.L2.IsPvid)
p.L2 = l2i
Expand Down Expand Up @@ -480,7 +488,8 @@ func (P *PortsH) PortDel(name string, ptype int) (int, error) {
if zone != nil {
zone.Vlans.VlanDelete(p.L2.Vid)
}
break
case cmn.PortIPTun:
zone.Sess.HwMark.PutCounter(p.SInfo.SessMark)
}

p.SInfo.PortReal = nil
Expand Down Expand Up @@ -879,6 +888,24 @@ func (p *Port) DP(work DpWorkT) int {
return -1
}

// If it is a IP-in-IP tunnel, we add a session entry
// to decapsulate the tunnel
if p.SInfo.PortType == cmn.PortIPTun {
ipts := new(UlClDpWorkQ)
ipts.Work = work
ipts.MDip = p.HInfo.TunDst
ipts.MSip = p.HInfo.TunSrc
ipts.mTeID = 1
ipts.Zone = zoneNum
ipts.HwMark = p.SInfo.SessMark
ipts.Type = DpTunIPIP
ipts.Qfi = 0
ipts.TTeID = 0

mh.dp.ToDpCh <- ipts
return 0
}

// When a vxlan interface is created
if p.SInfo.PortType == cmn.PortVxlanBr {
// Do nothing
Expand Down

0 comments on commit 3d976b4

Please sign in to comment.