Skip to content

Commit

Permalink
Make SDF filter configurable during session creation (#39)
Browse files Browse the repository at this point in the history
* Add SDF filtering cli argument

* Make wildcard SDF as default

* Update compiled protobuf

* Make SDF Filter configurable

* Refactor flag name

* Address review comments

* Fix changed Protobuf message field

* Fix parameter in flag parser
  • Loading branch information
EmanueleGallone committed Feb 24, 2022
1 parent 66e28ca commit 19a69dc
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 64 deletions.
118 changes: 64 additions & 54 deletions api/pfcpsim.pb.go

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

1 change: 1 addition & 0 deletions api/pfcpsim.proto
Expand Up @@ -13,6 +13,7 @@ message CreateSessionRequest {
int32 baseID = 2;
string nodeBAddress = 3;
string ueAddressPool = 4;
string sdfFilter = 5;
}

message ModifySessionRequest {
Expand Down
4 changes: 3 additions & 1 deletion cmd/pfcpctl/main.go
Expand Up @@ -42,11 +42,12 @@ func main() {
baseId := getopt.IntLong("baseID", 'i', 1, "First ID used to generate all other ID fields.")
n3Addr := getopt.StringLong("n3-addr", 'a', "", "The IPv4 address of the UPF's N3 interface")
ueAddrPool := getopt.StringLong("ue-pool", 'u', "", "The IPv4 prefix from which UE addresses will be drawn.")
nodeBAddr := getopt.StringLong("nb-addr", 'g', "", "The IPv4 address of the NodeB")
nodeBAddr := getopt.StringLong("gnb-addr", 'g', "", "The IPv4 address of the NodeB")
remotePeer := getopt.StringLong("remote-peer", 'r', "", "The remote PFCP Agent address")

bufferFlag := getopt.BoolLong("buffer", 'b', "If set, downlink FARs will have the buffer flag set to true")
notifyCPFlag := getopt.BoolLong("notifycp", 'm', "If set, downlink FARs will have the notify CP flag set to true")
sdfFilter := getopt.StringLong("sdf-filter", 'f', "" ,"Allows to set a custom SDF filter")

optHelp := getopt.BoolLong("help", 0, "Help")

Expand Down Expand Up @@ -96,6 +97,7 @@ func main() {
BaseID: int32(*baseId),
NodeBAddress: *nodeBAddr,
UeAddressPool: *ueAddrPool,
SdfFilter: *sdfFilter,
})
if err != nil {
log.Errorf("Error while associating: %v", err)
Expand Down
18 changes: 9 additions & 9 deletions internal/pfcpsim/server.go
Expand Up @@ -20,12 +20,6 @@ import (
"google.golang.org/grpc/status"
)

const (
// FIXME: the SDF Filter is not spec-compliant. We should fix it once SD-Core supports the spec-compliant format.
// TODO make SDF filter configurable using the cli
defaultSDFfilter = "permit out ip from 0.0.0.0/0 to assigned 80-80"
)

// pfcpSimService implements the Protobuf interface and keeps a connection to a remote PFCP Agent peer.
// Its state is handled in internal/pfcpsim/state.go
type pfcpSimService struct{}
Expand All @@ -35,7 +29,7 @@ func NewPFCPSimService(iface string) *pfcpSimService {
return &pfcpSimService{}
}

func checkServerStatus() error{
func checkServerStatus() error {
if !isConfigured() {
return status.Error(codes.Aborted, "Server is not configured")
}
Expand Down Expand Up @@ -132,6 +126,12 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes
return &pb.Response{}, status.Error(codes.Aborted, errMsg)
}

var SDFFilter = ""

if request.SdfFilter != "" {
SDFFilter = request.SdfFilter
}

for i := baseID; i < (count*2 + baseID); i = i + 2 {
// using variables to ease comprehension on how rules are linked together
uplinkTEID := uint32(i)
Expand Down Expand Up @@ -160,7 +160,7 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes
AddQERID(sessQerID).
AddQERID(uplinkAppQerID).
WithN3Address(upfN3Address).
WithSDFFilter(defaultSDFfilter).
WithSDFFilter(SDFFilter).
WithPrecedence(100).
MarkAsUplink().
BuildPDR(),
Expand All @@ -171,7 +171,7 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes
WithMethod(session.Create).
WithPrecedence(100).
WithUEAddress(ueAddress.String()).
WithSDFFilter(defaultSDFfilter).
WithSDFFilter(SDFFilter).
AddQERID(sessQerID).
AddQERID(downlinkAppQerID).
WithFARID(downlinkFarID).
Expand Down

0 comments on commit 19a69dc

Please sign in to comment.