Skip to content

Commit

Permalink
Handle FAR flags for Buffer and notify CP (#202)
Browse files Browse the repository at this point in the history
Co-authored-by: badhri85 <badhri85@node.onf2.cord-testdrive-pg0.wisc.cloudlab.us>
Co-authored-by: Saikrishna Edupuganti <krsna1729@users.noreply.github.com>
  • Loading branch information
3 people committed Jan 28, 2021
1 parent ca08074 commit 44f27a2
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 19 deletions.
2 changes: 2 additions & 0 deletions conf/up4.bess
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ GTPUEncap = 1
farForwardUAction = 0
farForwardDAction = 1
farDropAction = 2
farBufferAction = 3
farNotifyCPAction = 4
pdrFailGate = 2
farFailGate = 2
Expand Down Expand Up @@ -216,6 +217,7 @@ pdrLookup:pdrFailGate -> pdrLookupFail::Sink()
farLookup:farFailGate -> farLookupFail::Sink()
executeFAR:farDropAction -> farDrop::Sink()
executeFAR:farNotifyCPAction -> farNotifyCP::Sink()
executeFAR:farBufferAction -> farBuffer::Sink()
gtpuEncap:0 -> gtpuEncapFail::Sink()

# Set default gates for relevant modules
Expand Down
13 changes: 8 additions & 5 deletions pfcpiface/bess.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ func (b *bess) sim(u *upf, method string) {
farID: n3,
fseID: n3TEID + i,

action: farForwardD,
applyAction: Action_Forward,
dstIntf: access,
tunnelType: 0x1,
tunnelIP4Src: ip2int(u.accessIP),
tunnelIP4Dst: ip2int(enbip) + enbIdx,
Expand All @@ -430,14 +431,16 @@ func (b *bess) sim(u *upf, method string) {
farID: n6,
fseID: n3TEID + i,

action: farForwardU,
applyAction: Action_Forward,
dstIntf: core,
}

farN9Up := far{
farID: n9,
fseID: n3TEID + i,

action: farForwardU,
applyAction: Action_Forward,
dstIntf: core,
tunnelType: 0x1,
tunnelIP4Src: ip2int(u.coreIP),
tunnelIP4Dst: ip2int(aupfip),
Expand Down Expand Up @@ -641,15 +644,15 @@ func (b *bess) addFAR(ctx context.Context, done chan<- bool, far far) {
go func() {
var any *anypb.Any
var err error

var action uint8 = far.setActionValue()
f := &pb.ExactMatchCommandAddArg{
Gate: uint64(far.tunnelType),
Fields: []*pb.FieldData{
intEnc(uint64(far.farID)), /* far_id */
intEnc(uint64(far.fseID)), /* fseid */
},
Values: []*pb.FieldData{
intEnc(uint64(far.action)), /* action */
intEnc(uint64(action)), /* action */
intEnc(uint64(far.tunnelType)), /* tunnel_out_type */
intEnc(uint64(far.tunnelIP4Src)), /* access-ip */
intEnc(uint64(far.tunnelIP4Dst)), /* enb ip */
Expand Down
51 changes: 37 additions & 14 deletions pfcpiface/parse-far.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ const (
FwdIE_DestinationIntf
)

const (
Action_Forward = 0x2
Action_Drop = 0x1
Action_Buffer = 0x4
Action_Notify = 0x8
)

const (
create operation = iota
update
Expand All @@ -27,7 +34,7 @@ type far struct {
fseID uint32
fseidIP uint32

action uint8
dstIntf uint8
applyAction uint8
tunnelType uint8
tunnelIP4Src uint32
Expand All @@ -41,7 +48,7 @@ func (f *far) printFAR() {
log.Println("FAR ID:", f.farID)
log.Println("fseID:", f.fseID)
log.Println("fseIDIP:", f.fseidIP)
log.Println("action:", f.action)
log.Println("dstIntf:", f.dstIntf)
log.Println("applyAction:", f.applyAction)
log.Println("tunnelType:", f.tunnelType)
log.Println("tunnelIP4Src:", f.tunnelIP4Src)
Expand All @@ -51,6 +58,31 @@ func (f *far) printFAR() {
log.Println("--------------------------------------------")
}

func (f *far) setActionValue() uint8 {
if (f.applyAction & Action_Forward) != 0 {
if f.dstIntf == ie.DstInterfaceAccess {
log.Println("Set Action forwardD")
return farForwardD
} else if f.dstIntf == ie.DstInterfaceCore {
log.Println("Set Action forwardU")
return farForwardU
}
} else if (f.applyAction & Action_Drop) != 0 {
log.Println("Set Action drop")
return farDrop
} else if (f.applyAction & Action_Buffer) != 0 {
log.Println("Set Action buffer")
return farBuffer
} else if (f.applyAction & Action_Notify) != 0 {
log.Println("Set Action notify")
return farNotify
}

//default action
log.Println("Set Action drop default")
return farDrop
}

func (f *far) parseFAR(farIE *ie.IE, fseid uint64, upf *upf, op operation) error {
f.fseID = uint32(fseid)

Expand All @@ -65,13 +97,6 @@ func (f *far) parseFAR(farIE *ie.IE, fseid uint64, upf *upf, op operation) error
return err
}

if (action&0x02)>>1 == 0 {
log.Println("Handling forward action only")
// TODO: Handle buffer
f.action = farDrop
return nil
}

f.applyAction = action
var fwdIEs []*ie.IE

Expand Down Expand Up @@ -104,16 +129,14 @@ func (f *far) parseFAR(farIE *ie.IE, fseid uint64, upf *upf, op operation) error
f.tunnelPort = tunnelGTPUPort
case ie.DestinationInterface:
fields = Set(fields, FwdIE_DestinationIntf)
dstIface, err := fwdIE.DestinationInterface()
f.dstIntf, err = fwdIE.DestinationInterface()
if err != nil {
log.Println("Unable to parse DestinationInterface field")
continue
}
if dstIface == ie.DstInterfaceAccess {
f.action = farForwardD
if f.dstIntf == ie.DstInterfaceAccess {
f.tunnelIP4Src = ip2int(upf.accessIP)
} else if dstIface == ie.DstInterfaceCore {
f.action = farForwardU
} else if f.dstIntf == ie.DstInterfaceCore {
f.tunnelIP4Src = ip2int(upf.coreIP)
}
}
Expand Down
2 changes: 2 additions & 0 deletions pfcpiface/upf.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const (
farForwardU = 0x0
farForwardD = 0x1
farDrop = 0x2
farBuffer = 0x3
farNotify = 0x4
)

func (u *upf) sendMsgToUPF(method string, pdrs []pdr, fars []far) uint8 {
Expand Down

0 comments on commit 44f27a2

Please sign in to comment.