From 2e7ebb57b5facd42877726487a7975b8f54105f3 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Mon, 21 Mar 2022 09:19:38 +0100 Subject: [PATCH 01/22] First commit --- api/pfcpsim.pb.go | 128 +++++++++++++------------- api/pfcpsim.proto | 2 +- internal/pfcpctl/commands/sessions.go | 20 ++-- internal/pfcpsim/server.go | 64 ++++++++++--- 4 files changed, 130 insertions(+), 84 deletions(-) diff --git a/api/pfcpsim.pb.go b/api/pfcpsim.pb.go index cbaf33f..4c25fc7 100644 --- a/api/pfcpsim.pb.go +++ b/api/pfcpsim.pb.go @@ -40,11 +40,11 @@ type CreateSessionRequest struct { // count represents the number of session Count int32 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` // baseID is used to create incremental IDs for PDRs, FARs, QERs - BaseID int32 `protobuf:"varint,2,opt,name=baseID,proto3" json:"baseID,omitempty"` - NodeBAddress string `protobuf:"bytes,3,opt,name=nodeBAddress,proto3" json:"nodeBAddress,omitempty"` - UeAddressPool string `protobuf:"bytes,4,opt,name=ueAddressPool,proto3" json:"ueAddressPool,omitempty"` - AppFilter string `protobuf:"bytes,5,opt,name=appFilter,proto3" json:"appFilter,omitempty"` - Qfi int32 `protobuf:"varint,6,opt,name=qfi,proto3" json:"qfi,omitempty"` // Should be uint8 + BaseID int32 `protobuf:"varint,2,opt,name=baseID,proto3" json:"baseID,omitempty"` + NodeBAddress string `protobuf:"bytes,3,opt,name=nodeBAddress,proto3" json:"nodeBAddress,omitempty"` + UeAddressPool string `protobuf:"bytes,4,opt,name=ueAddressPool,proto3" json:"ueAddressPool,omitempty"` + AppFilters []string `protobuf:"bytes,5,rep,name=appFilters,proto3" json:"appFilters,omitempty"` + Qfi int32 `protobuf:"varint,6,opt,name=qfi,proto3" json:"qfi,omitempty"` // Should be uint8 } func (x *CreateSessionRequest) Reset() { @@ -107,11 +107,11 @@ func (x *CreateSessionRequest) GetUeAddressPool() string { return "" } -func (x *CreateSessionRequest) GetAppFilter() string { +func (x *CreateSessionRequest) GetAppFilters() []string { if x != nil { - return x.AppFilter + return x.AppFilters } - return "" + return nil } func (x *CreateSessionRequest) GetQfi() int32 { @@ -420,7 +420,7 @@ var File_pfcpsim_proto protoreflect.FileDescriptor var file_pfcpsim_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x70, 0x66, 0x63, 0x70, 0x73, 0x69, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x03, 0x61, 0x70, 0x69, 0x22, 0xbe, 0x01, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, + 0x03, 0x61, 0x70, 0x69, 0x22, 0xc0, 0x01, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x61, 0x73, 0x65, 0x49, 0x44, 0x18, 0x02, 0x20, @@ -429,62 +429,62 @@ var file_pfcpsim_proto_rawDesc = []byte{ 0x09, 0x52, 0x0c, 0x6e, 0x6f, 0x64, 0x65, 0x42, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x75, 0x65, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x75, 0x65, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x50, 0x6f, 0x6f, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x70, 0x70, 0x46, 0x69, 0x6c, 0x74, - 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x70, 0x70, 0x46, 0x69, 0x6c, - 0x74, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x71, 0x66, 0x69, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x03, 0x71, 0x66, 0x69, 0x22, 0xd2, 0x01, 0x0a, 0x14, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, - 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, - 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x61, 0x73, 0x65, 0x49, 0x44, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x61, 0x73, 0x65, 0x49, 0x44, 0x12, 0x22, 0x0a, 0x0c, - 0x6e, 0x6f, 0x64, 0x65, 0x42, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x6f, 0x64, 0x65, 0x42, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x12, 0x24, 0x0a, 0x0d, 0x75, 0x65, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x6f, - 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x75, 0x65, 0x41, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x50, 0x6f, 0x6f, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, - 0x46, 0x6c, 0x61, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x62, 0x75, 0x66, 0x66, - 0x65, 0x72, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, - 0x43, 0x50, 0x46, 0x6c, 0x61, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6e, 0x6f, - 0x74, 0x69, 0x66, 0x79, 0x43, 0x50, 0x46, 0x6c, 0x61, 0x67, 0x22, 0x64, 0x0a, 0x10, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, - 0x0a, 0x0c, 0x75, 0x70, 0x66, 0x4e, 0x33, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x75, 0x70, 0x66, 0x4e, 0x33, 0x41, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x12, 0x2c, 0x0a, 0x11, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x65, 0x65, 0x72, - 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x72, - 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x65, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x22, 0x44, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, - 0x0a, 0x06, 0x62, 0x61, 0x73, 0x65, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, - 0x62, 0x61, 0x73, 0x65, 0x49, 0x44, 0x22, 0x0e, 0x0a, 0x0c, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x45, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, - 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0xda, 0x02, - 0x0a, 0x07, 0x50, 0x46, 0x43, 0x50, 0x53, 0x69, 0x6d, 0x12, 0x33, 0x0a, 0x09, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x12, 0x15, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x2f, - 0x0a, 0x09, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x65, 0x12, 0x11, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x32, 0x0a, 0x0c, 0x44, 0x69, 0x73, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x65, 0x12, - 0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x73, 0x50, 0x6f, 0x6f, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x70, 0x70, 0x46, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, 0x70, 0x46, 0x69, + 0x6c, 0x74, 0x65, 0x72, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x71, 0x66, 0x69, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x03, 0x71, 0x66, 0x69, 0x22, 0xd2, 0x01, 0x0a, 0x14, 0x4d, 0x6f, 0x64, 0x69, + 0x66, 0x79, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x61, 0x73, 0x65, 0x49, 0x44, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x61, 0x73, 0x65, 0x49, 0x44, 0x12, 0x22, + 0x0a, 0x0c, 0x6e, 0x6f, 0x64, 0x65, 0x42, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x6f, 0x64, 0x65, 0x42, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x75, 0x65, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, + 0x6f, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x75, 0x65, 0x41, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x6f, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x62, 0x75, 0x66, 0x66, + 0x65, 0x72, 0x46, 0x6c, 0x61, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x62, 0x75, + 0x66, 0x66, 0x65, 0x72, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x6e, 0x6f, 0x74, 0x69, + 0x66, 0x79, 0x43, 0x50, 0x46, 0x6c, 0x61, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, + 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x43, 0x50, 0x46, 0x6c, 0x61, 0x67, 0x22, 0x64, 0x0a, 0x10, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x22, 0x0a, 0x0c, 0x75, 0x70, 0x66, 0x4e, 0x33, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x75, 0x70, 0x66, 0x4e, 0x33, 0x41, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x12, 0x2c, 0x0a, 0x11, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x65, + 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x11, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x65, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x22, 0x44, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x16, 0x0a, 0x06, 0x62, 0x61, 0x73, 0x65, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x06, 0x62, 0x61, 0x73, 0x65, 0x49, 0x44, 0x22, 0x0e, 0x0a, 0x0c, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x45, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, + 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, + 0xda, 0x02, 0x0a, 0x07, 0x50, 0x46, 0x43, 0x50, 0x53, 0x69, 0x6d, 0x12, 0x33, 0x0a, 0x09, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x12, 0x15, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x3b, 0x0a, 0x0d, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x53, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, - 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x19, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x3b, - 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x2f, 0x0a, 0x09, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x65, 0x12, 0x11, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x0d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x32, 0x0a, 0x0c, 0x44, 0x69, 0x73, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, + 0x65, 0x12, 0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x0d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x0d, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, + 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x3b, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x12, 0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x07, 0x5a, 0x05, + 0x2e, 0x3b, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/pfcpsim.proto b/api/pfcpsim.proto index 4a623cd..af84bb5 100644 --- a/api/pfcpsim.proto +++ b/api/pfcpsim.proto @@ -13,7 +13,7 @@ message CreateSessionRequest { int32 baseID = 2; string nodeBAddress = 3; string ueAddressPool = 4; - string appFilter = 5; + repeated string appFilters = 5; int32 qfi = 6; // Should be uint8 } diff --git a/internal/pfcpctl/commands/sessions.go b/internal/pfcpctl/commands/sessions.go index c505097..e2d1b9c 100644 --- a/internal/pfcpctl/commands/sessions.go +++ b/internal/pfcpctl/commands/sessions.go @@ -12,12 +12,12 @@ import ( ) type commonArgs struct { - Count int `short:"c" long:"count" default:"1" description:"The number of sessions to create"` - BaseID int `short:"i" long:"baseID" default:"1" description:"The base ID to use"` - UePool string `short:"u" long:"ue-pool" default:"17.0.0.0/24" description:"The UE pool address"` - GnBAddress string `short:"g" long:"gnb-addr" description:"The UE pool address"` - AppFilterString string `short:"a" long:"app-filter" description:"Specify an application filter. Format: '{ip | udp | tcp}:{IPv4 Prefix | any}:{- | any}:{allow | deny}' . e.g. 'udp:10.0.0.0/8:80-88:allow'"` - QFI uint8 `short:"q" long:"qfi" description:"The QFI value for QERs. Max value 64."` + Count int `short:"c" long:"count" default:"1" description:"The number of sessions to create"` + BaseID int `short:"i" long:"baseID" default:"1" description:"The base ID to use"` + UePool string `short:"u" long:"ue-pool" default:"17.0.0.0/24" description:"The UE pool address"` + GnBAddress string `short:"g" long:"gnb-addr" description:"The UE pool address"` + AppFilterString []string `short:"a" long:"app-filter" description:"Specify an application filter. Format: '{ip | udp | tcp}:{IPv4 Prefix | any}:{- | any}:{allow | deny}' . e.g. 'udp:10.0.0.0/8:80-88:allow'"` + QFI uint8 `short:"q" long:"qfi" description:"The QFI value for QERs. Max value 64."` } type sessionCreate struct { @@ -59,12 +59,18 @@ func (s *sessionCreate) Execute(args []string) error { client := connect() defer disconnect() + var appFilters []string + + for _, s := range s.Args.AppFilterString { + appFilters = append(appFilters, s) + } + res, err := client.CreateSession(context.Background(), &pb.CreateSessionRequest{ Count: int32(s.Args.Count), BaseID: int32(s.Args.BaseID), NodeBAddress: s.Args.GnBAddress, UeAddressPool: s.Args.UePool, - AppFilter: s.Args.AppFilterString, + AppFilters: appFilters, Qfi: int32(s.Args.QFI), }) diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index ded8067..d60e112 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -22,6 +22,10 @@ import ( // Its state is handled in internal/pfcpsim/state.go type pfcpSimService struct{} +// SessionStep identifies the step in loops, used while creating/modifying/deleting sessions and rules IDs. +// It should be high enough to avoid IDs overlap when creating sessions. +const SessionStep = 10 + func NewPFCPSimService(iface string) *pfcpSimService { interfaceName = iface return &pfcpSimService{} @@ -127,20 +131,11 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes var SDFFilter = "" var qfi, gateStatus uint8 = 0, ieLib.GateStatusOpen - if request.AppFilter != "" { - SDFFilter, gateStatus, err = parseAppFilter(request.AppFilter) - if err != nil { - return &pb.Response{}, status.Error(codes.Aborted, err.Error()) - } - - log.Infof("Successfully parsed application filter. SDF Filter: %v", SDFFilter) - } - if request.Qfi != 0 { qfi = uint8(request.Qfi) } - for i := baseID; i < (count*2 + baseID); i = i + 2 { + for i := baseID; i < (count*SessionStep + baseID); i = i + SessionStep { // using variables to ease comprehension on how rules are linked together uplinkTEID := uint32(i) @@ -237,6 +232,51 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes Build(), } + // create as many PDRs as the number of app filters provided through pfcpctl + if len(request.AppFilters) > 0 { + pdrs = []*ieLib.IE{} // reset pdr slice + ID := uint16(i) + + for _, appFilter := range request.AppFilters { + SDFFilter, gateStatus, err = parseAppFilter(appFilter) + if err != nil { + return &pb.Response{}, status.Error(codes.Aborted, err.Error()) + } + + log.Infof("Successfully parsed application filter. SDF Filter: %v", SDFFilter) + + uplinkPDR := session.NewPDRBuilder(). + WithID(ID). + WithMethod(session.Create). + WithTEID(uplinkTEID). + WithFARID(uplinkFarID). + AddQERID(sessQerID). + AddQERID(uplinkAppQerID). + WithN3Address(upfN3Address). + WithSDFFilter(SDFFilter). + WithPrecedence(100). + MarkAsUplink(). + BuildPDR() + + downlinkPDR := session.NewPDRBuilder(). + WithID(ID + 1). + WithMethod(session.Create). + WithPrecedence(100). + WithUEAddress(ueAddress.String()). + WithSDFFilter(SDFFilter). + AddQERID(sessQerID). + AddQERID(downlinkAppQerID). + WithFARID(downlinkFarID). + MarkAsDownlink(). + BuildPDR() + + pdrs = append(pdrs, uplinkPDR) + pdrs = append(pdrs, downlinkPDR) + + ID++ + } + } + sess, err := sim.EstablishSession(pdrs, fars, qers) if err != nil { return &pb.Response{}, status.Error(codes.Internal, err.Error()) @@ -280,7 +320,7 @@ func (P pfcpSimService) ModifySession(ctx context.Context, request *pb.ModifySes actions |= session.ActionForward } - for i := baseID; i < (count*2 + baseID); i = i + 2 { + for i := baseID; i < (count*SessionStep + baseID); i = i + SessionStep { teid := uint32(i + 1) if request.BufferFlag || request.NotifyCPFlag { @@ -335,7 +375,7 @@ func (P pfcpSimService) DeleteSession(ctx context.Context, request *pb.DeleteSes return &pb.Response{}, status.Error(codes.Aborted, err.Error()) } - for i := baseID; i < (count*2 + baseID); i = i + 2 { + for i := baseID; i < (count*SessionStep + baseID); i = i + SessionStep { sess, ok := getSession(i) if !ok { errMsg := "Session was nil. Check baseID" From 979f4ccc3345a0c9550f253a4d027108ec5e3af0 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Tue, 22 Mar 2022 09:10:07 +0100 Subject: [PATCH 02/22] Refactor --- internal/pfcpctl/commands/sessions.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/internal/pfcpctl/commands/sessions.go b/internal/pfcpctl/commands/sessions.go index e2d1b9c..b61be0c 100644 --- a/internal/pfcpctl/commands/sessions.go +++ b/internal/pfcpctl/commands/sessions.go @@ -59,18 +59,12 @@ func (s *sessionCreate) Execute(args []string) error { client := connect() defer disconnect() - var appFilters []string - - for _, s := range s.Args.AppFilterString { - appFilters = append(appFilters, s) - } - res, err := client.CreateSession(context.Background(), &pb.CreateSessionRequest{ Count: int32(s.Args.Count), BaseID: int32(s.Args.BaseID), NodeBAddress: s.Args.GnBAddress, UeAddressPool: s.Args.UePool, - AppFilters: appFilters, + AppFilters: s.Args.AppFilterString, Qfi: int32(s.Args.QFI), }) From 8990edfb76d0c201956ad4036fa3bbe79f2af497 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Wed, 23 Mar 2022 11:05:07 +0100 Subject: [PATCH 03/22] Generate new FARs and Application QERs for each app filter flag --- internal/pfcpsim/server.go | 133 +++++++++++++++---------------------- 1 file changed, 52 insertions(+), 81 deletions(-) diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index d60e112..adcdf93 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -142,67 +142,11 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes ueAddress := iplib.NextIP(lastUEAddr) lastUEAddr = ueAddress - uplinkFarID := uint32(i) - downlinkFarID := uint32(i + 1) - - uplinkPdrID := uint16(i) - downlinkPdrID := uint16(i + 1) - sessQerID := uint32(i + 3) - uplinkAppQerID := uint32(i) - downlinkAppQerID := uint32(i + 1) - - pdrs := []*ieLib.IE{ - // UplinkPDR - session.NewPDRBuilder(). - WithID(uplinkPdrID). - WithMethod(session.Create). - WithTEID(uplinkTEID). - WithFARID(uplinkFarID). - AddQERID(sessQerID). - AddQERID(uplinkAppQerID). - WithN3Address(upfN3Address). - WithSDFFilter(SDFFilter). - WithPrecedence(100). - MarkAsUplink(). - BuildPDR(), - - // DownlinkPDR - session.NewPDRBuilder(). - WithID(downlinkPdrID). - WithMethod(session.Create). - WithPrecedence(100). - WithUEAddress(ueAddress.String()). - WithSDFFilter(SDFFilter). - AddQERID(sessQerID). - AddQERID(downlinkAppQerID). - WithFARID(downlinkFarID). - MarkAsDownlink(). - BuildPDR(), - } - - fars := []*ieLib.IE{ - // UplinkFAR - session.NewFARBuilder(). - WithID(uplinkFarID). - WithAction(session.ActionForward). - WithDstInterface(ieLib.DstInterfaceCore). - WithMethod(session.Create). - BuildFAR(), - - // DownlinkFAR - session.NewFARBuilder(). - WithID(downlinkFarID). - WithAction(session.ActionDrop). - WithMethod(session.Create). - WithDstInterface(ieLib.DstInterfaceAccess). - WithZeroBasedOuterHeaderCreation(). - BuildFAR(), - } + var pdrs, fars []*ieLib.IE qers := []*ieLib.IE{ - // TODO make rates configurable by pfcpctl // session QER session.NewQERBuilder(). WithID(sessQerID). @@ -210,33 +154,21 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes WithUplinkMBR(60000). WithDownlinkMBR(60000). Build(), - - // Uplink application QER - session.NewQERBuilder(). - WithID(uplinkAppQerID). - WithMethod(session.Create). - WithQFI(qfi). - WithUplinkMBR(50000). - WithDownlinkMBR(30000). - WithGateStatus(gateStatus). - Build(), - - // Downlink application QER - session.NewQERBuilder(). - WithID(downlinkAppQerID). - WithMethod(session.Create). - WithQFI(qfi). - WithUplinkMBR(50000). - WithDownlinkMBR(30000). - WithGateStatus(gateStatus). - Build(), } - // create as many PDRs as the number of app filters provided through pfcpctl + // create as many PDRs, FARs and App QERs as the number of app filters provided through pfcpctl if len(request.AppFilters) > 0 { - pdrs = []*ieLib.IE{} // reset pdr slice ID := uint16(i) + uplinkPdrID := ID + downlinkPdrID := ID + 1 + + uplinkFarID := uint32(ID) + downlinkFarID := uint32(ID + 1) + + uplinkAppQerID := uint32(ID) + downlinkAppQerID := uint32(ID + 1) + for _, appFilter := range request.AppFilters { SDFFilter, gateStatus, err = parseAppFilter(appFilter) if err != nil { @@ -246,7 +178,7 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes log.Infof("Successfully parsed application filter. SDF Filter: %v", SDFFilter) uplinkPDR := session.NewPDRBuilder(). - WithID(ID). + WithID(uplinkPdrID). WithMethod(session.Create). WithTEID(uplinkTEID). WithFARID(uplinkFarID). @@ -259,7 +191,7 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes BuildPDR() downlinkPDR := session.NewPDRBuilder(). - WithID(ID + 1). + WithID(downlinkPdrID). WithMethod(session.Create). WithPrecedence(100). WithUEAddress(ueAddress.String()). @@ -273,6 +205,45 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes pdrs = append(pdrs, uplinkPDR) pdrs = append(pdrs, downlinkPDR) + uplinkFAR := session.NewFARBuilder(). + WithID(uint32(ID)). + WithAction(session.ActionForward). + WithDstInterface(ieLib.DstInterfaceCore). + WithMethod(session.Create). + BuildFAR() + + downlinkFAR := session.NewFARBuilder(). + WithID(uint32(ID + 1)). + WithAction(session.ActionDrop). + WithMethod(session.Create). + WithDstInterface(ieLib.DstInterfaceAccess). + WithZeroBasedOuterHeaderCreation(). + BuildFAR() + + fars = append(fars, uplinkFAR) + fars = append(fars, downlinkFAR) + + uplinkAppQER := session.NewQERBuilder(). + WithID(uplinkAppQerID). + WithMethod(session.Create). + WithQFI(qfi). + WithUplinkMBR(50000). + WithDownlinkMBR(30000). + WithGateStatus(gateStatus). + Build() + + downlinkAppQER := session.NewQERBuilder(). + WithID(downlinkAppQerID). + WithMethod(session.Create). + WithQFI(qfi). + WithUplinkMBR(50000). + WithDownlinkMBR(30000). + WithGateStatus(gateStatus). + Build() + + qers = append(qers, uplinkAppQER) + qers = append(qers, downlinkAppQER) + ID++ } } From f6dc2a71c05f0413590b609a74a92126d7ac3259 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Wed, 23 Mar 2022 11:20:12 +0100 Subject: [PATCH 04/22] Refactor --- internal/pfcpctl/commands/sessions.go | 2 +- internal/pfcpsim/helpers.go | 5 +++++ internal/pfcpsim/server.go | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/pfcpctl/commands/sessions.go b/internal/pfcpctl/commands/sessions.go index b61be0c..34f1c73 100644 --- a/internal/pfcpctl/commands/sessions.go +++ b/internal/pfcpctl/commands/sessions.go @@ -16,7 +16,7 @@ type commonArgs struct { BaseID int `short:"i" long:"baseID" default:"1" description:"The base ID to use"` UePool string `short:"u" long:"ue-pool" default:"17.0.0.0/24" description:"The UE pool address"` GnBAddress string `short:"g" long:"gnb-addr" description:"The UE pool address"` - AppFilterString []string `short:"a" long:"app-filter" description:"Specify an application filter. Format: '{ip | udp | tcp}:{IPv4 Prefix | any}:{- | any}:{allow | deny}' . e.g. 'udp:10.0.0.0/8:80-88:allow'"` + AppFilterString []string `short:"a" long:"app-filter" default:"" description:"Specify an application filter. Format: '{ip | udp | tcp}:{IPv4 Prefix | any}:{- | any}:{allow | deny}' . e.g. 'udp:10.0.0.0/8:80-88:allow'"` QFI uint8 `short:"q" long:"qfi" description:"The QFI value for QERs. Max value 64."` } diff --git a/internal/pfcpsim/helpers.go b/internal/pfcpsim/helpers.go index 4737076..0e12743 100644 --- a/internal/pfcpsim/helpers.go +++ b/internal/pfcpsim/helpers.go @@ -82,6 +82,11 @@ func getLocalAddress(interfaceName string) (net.IP, error) { // parseAppFilter parses an application filter. Returns a tuple formed by a formatted SDF filter // and a uint8 representing the Application QER gate status. Returns error if fail occurs while validating the filter string. func parseAppFilter(filter string) (string, uint8, error) { + if filter == "" { + // Processing a wildcard filter + return "", ie.GateStatusOpen, nil + } + result := strings.Split(filter, ":") if len(result) != 4 { return "", 0, pfcpsim.NewInvalidFormatError("Parser was not able to generate the correct number of arguments." + diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index adcdf93..23b3b0a 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -114,9 +114,9 @@ func (P pfcpSimService) Disassociate(ctx context.Context, empty *pb.EmptyRequest } func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSessionRequest) (*pb.Response, error) { - if err := checkServerStatus(); err != nil { - return &pb.Response{}, err - } + //if err := checkServerStatus(); err != nil { + // return &pb.Response{}, err + //} baseID := int(request.BaseID) count := int(request.Count) From f306eab54d32f5295fbc5fdff72f0cd14f479d9a Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Wed, 23 Mar 2022 11:25:53 +0100 Subject: [PATCH 05/22] Refactor --- internal/pfcpctl/commands/sessions.go | 2 +- internal/pfcpsim/helpers.go | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/internal/pfcpctl/commands/sessions.go b/internal/pfcpctl/commands/sessions.go index 34f1c73..3b3c200 100644 --- a/internal/pfcpctl/commands/sessions.go +++ b/internal/pfcpctl/commands/sessions.go @@ -16,7 +16,7 @@ type commonArgs struct { BaseID int `short:"i" long:"baseID" default:"1" description:"The base ID to use"` UePool string `short:"u" long:"ue-pool" default:"17.0.0.0/24" description:"The UE pool address"` GnBAddress string `short:"g" long:"gnb-addr" description:"The UE pool address"` - AppFilterString []string `short:"a" long:"app-filter" default:"" description:"Specify an application filter. Format: '{ip | udp | tcp}:{IPv4 Prefix | any}:{- | any}:{allow | deny}' . e.g. 'udp:10.0.0.0/8:80-88:allow'"` + AppFilterString []string `short:"a" long:"app-filter" default:"any:any:any:allow" description:"Specify an application filter. Format: '{ip | udp | tcp}:{IPv4 Prefix | any}:{- | any}:{allow | deny}' . e.g. 'udp:10.0.0.0/8:80-88:allow'"` QFI uint8 `short:"q" long:"qfi" description:"The QFI value for QERs. Max value 64."` } diff --git a/internal/pfcpsim/helpers.go b/internal/pfcpsim/helpers.go index 0e12743..2485fa9 100644 --- a/internal/pfcpsim/helpers.go +++ b/internal/pfcpsim/helpers.go @@ -82,11 +82,6 @@ func getLocalAddress(interfaceName string) (net.IP, error) { // parseAppFilter parses an application filter. Returns a tuple formed by a formatted SDF filter // and a uint8 representing the Application QER gate status. Returns error if fail occurs while validating the filter string. func parseAppFilter(filter string) (string, uint8, error) { - if filter == "" { - // Processing a wildcard filter - return "", ie.GateStatusOpen, nil - } - result := strings.Split(filter, ":") if len(result) != 4 { return "", 0, pfcpsim.NewInvalidFormatError("Parser was not able to generate the correct number of arguments." + @@ -105,8 +100,10 @@ func parseAppFilter(filter string) (string, uint8, error) { return "", 0, pfcpsim.NewInvalidFormatError("Action. Please make sure to use 'allow' or 'deny'") } - if !(proto == "ip" || proto == "udp" || proto == "tcp") { - return "", 0, pfcpsim.NewInvalidFormatError("Unsupported or unknown protocol.") + if proto != "any" { + if !(proto == "ip" || proto == "udp" || proto == "tcp") { + return "", 0, pfcpsim.NewInvalidFormatError("Unsupported or unknown protocol.") + } } if ipNetAddr != "any" { @@ -115,6 +112,7 @@ func parseAppFilter(filter string) (string, uint8, error) { return "", 0, pfcpsim.NewInvalidFormatError("IP and subnet mask.", err) } } + if portRange != "any" { portList := strings.Split(portRange, "-") if !(len(portList) == 2) { From 9d94720a3c9d75d80cbc4b59d9d1cfc2681c4d91 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Wed, 23 Mar 2022 11:55:13 +0100 Subject: [PATCH 06/22] Refactor --- internal/pfcpctl/commands/sessions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/pfcpctl/commands/sessions.go b/internal/pfcpctl/commands/sessions.go index 3b3c200..817c7ac 100644 --- a/internal/pfcpctl/commands/sessions.go +++ b/internal/pfcpctl/commands/sessions.go @@ -16,7 +16,7 @@ type commonArgs struct { BaseID int `short:"i" long:"baseID" default:"1" description:"The base ID to use"` UePool string `short:"u" long:"ue-pool" default:"17.0.0.0/24" description:"The UE pool address"` GnBAddress string `short:"g" long:"gnb-addr" description:"The UE pool address"` - AppFilterString []string `short:"a" long:"app-filter" default:"any:any:any:allow" description:"Specify an application filter. Format: '{ip | udp | tcp}:{IPv4 Prefix | any}:{- | any}:{allow | deny}' . e.g. 'udp:10.0.0.0/8:80-88:allow'"` + AppFilterString []string `short:"a" long:"app-filter" default:"any:any:any:allow" description:"Specify an application filter. Format: '{ip | udp | tcp | any}:{IPv4 Prefix | any}:{- | any}:{allow | deny}' . e.g. 'udp:10.0.0.0/8:80-88:allow'"` QFI uint8 `short:"q" long:"qfi" description:"The QFI value for QERs. Max value 64."` } From 75af06d05a3e3251b895c7668994f29f950ac1c8 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Wed, 23 Mar 2022 12:29:07 +0100 Subject: [PATCH 07/22] Refactor --- internal/pfcpsim/server.go | 174 ++++++++++++++++++------------------- 1 file changed, 86 insertions(+), 88 deletions(-) diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index 23b3b0a..705ae8c 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -157,95 +157,93 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes } // create as many PDRs, FARs and App QERs as the number of app filters provided through pfcpctl - if len(request.AppFilters) > 0 { - ID := uint16(i) - - uplinkPdrID := ID - downlinkPdrID := ID + 1 - - uplinkFarID := uint32(ID) - downlinkFarID := uint32(ID + 1) - - uplinkAppQerID := uint32(ID) - downlinkAppQerID := uint32(ID + 1) - - for _, appFilter := range request.AppFilters { - SDFFilter, gateStatus, err = parseAppFilter(appFilter) - if err != nil { - return &pb.Response{}, status.Error(codes.Aborted, err.Error()) - } - - log.Infof("Successfully parsed application filter. SDF Filter: %v", SDFFilter) - - uplinkPDR := session.NewPDRBuilder(). - WithID(uplinkPdrID). - WithMethod(session.Create). - WithTEID(uplinkTEID). - WithFARID(uplinkFarID). - AddQERID(sessQerID). - AddQERID(uplinkAppQerID). - WithN3Address(upfN3Address). - WithSDFFilter(SDFFilter). - WithPrecedence(100). - MarkAsUplink(). - BuildPDR() - - downlinkPDR := session.NewPDRBuilder(). - WithID(downlinkPdrID). - WithMethod(session.Create). - WithPrecedence(100). - WithUEAddress(ueAddress.String()). - WithSDFFilter(SDFFilter). - AddQERID(sessQerID). - AddQERID(downlinkAppQerID). - WithFARID(downlinkFarID). - MarkAsDownlink(). - BuildPDR() - - pdrs = append(pdrs, uplinkPDR) - pdrs = append(pdrs, downlinkPDR) - - uplinkFAR := session.NewFARBuilder(). - WithID(uint32(ID)). - WithAction(session.ActionForward). - WithDstInterface(ieLib.DstInterfaceCore). - WithMethod(session.Create). - BuildFAR() - - downlinkFAR := session.NewFARBuilder(). - WithID(uint32(ID + 1)). - WithAction(session.ActionDrop). - WithMethod(session.Create). - WithDstInterface(ieLib.DstInterfaceAccess). - WithZeroBasedOuterHeaderCreation(). - BuildFAR() - - fars = append(fars, uplinkFAR) - fars = append(fars, downlinkFAR) - - uplinkAppQER := session.NewQERBuilder(). - WithID(uplinkAppQerID). - WithMethod(session.Create). - WithQFI(qfi). - WithUplinkMBR(50000). - WithDownlinkMBR(30000). - WithGateStatus(gateStatus). - Build() - - downlinkAppQER := session.NewQERBuilder(). - WithID(downlinkAppQerID). - WithMethod(session.Create). - WithQFI(qfi). - WithUplinkMBR(50000). - WithDownlinkMBR(30000). - WithGateStatus(gateStatus). - Build() - - qers = append(qers, uplinkAppQER) - qers = append(qers, downlinkAppQER) - - ID++ + ID := uint16(i) + + uplinkPdrID := ID + downlinkPdrID := ID + 1 + + uplinkFarID := uint32(ID) + downlinkFarID := uint32(ID + 1) + + uplinkAppQerID := uint32(ID) + downlinkAppQerID := uint32(ID + 1) + + for _, appFilter := range request.AppFilters { + SDFFilter, gateStatus, err = parseAppFilter(appFilter) + if err != nil { + return &pb.Response{}, status.Error(codes.Aborted, err.Error()) } + + log.Infof("Successfully parsed application filter. SDF Filter: %v", SDFFilter) + + uplinkPDR := session.NewPDRBuilder(). + WithID(uplinkPdrID). + WithMethod(session.Create). + WithTEID(uplinkTEID). + WithFARID(uplinkFarID). + AddQERID(sessQerID). + AddQERID(uplinkAppQerID). + WithN3Address(upfN3Address). + WithSDFFilter(SDFFilter). + WithPrecedence(100). + MarkAsUplink(). + BuildPDR() + + downlinkPDR := session.NewPDRBuilder(). + WithID(downlinkPdrID). + WithMethod(session.Create). + WithPrecedence(100). + WithUEAddress(ueAddress.String()). + WithSDFFilter(SDFFilter). + AddQERID(sessQerID). + AddQERID(downlinkAppQerID). + WithFARID(downlinkFarID). + MarkAsDownlink(). + BuildPDR() + + pdrs = append(pdrs, uplinkPDR) + pdrs = append(pdrs, downlinkPDR) + + uplinkFAR := session.NewFARBuilder(). + WithID(uint32(ID)). + WithAction(session.ActionForward). + WithDstInterface(ieLib.DstInterfaceCore). + WithMethod(session.Create). + BuildFAR() + + downlinkFAR := session.NewFARBuilder(). + WithID(uint32(ID + 1)). + WithAction(session.ActionDrop). + WithMethod(session.Create). + WithDstInterface(ieLib.DstInterfaceAccess). + WithZeroBasedOuterHeaderCreation(). + BuildFAR() + + fars = append(fars, uplinkFAR) + fars = append(fars, downlinkFAR) + + uplinkAppQER := session.NewQERBuilder(). + WithID(uplinkAppQerID). + WithMethod(session.Create). + WithQFI(qfi). + WithUplinkMBR(50000). + WithDownlinkMBR(30000). + WithGateStatus(gateStatus). + Build() + + downlinkAppQER := session.NewQERBuilder(). + WithID(downlinkAppQerID). + WithMethod(session.Create). + WithQFI(qfi). + WithUplinkMBR(50000). + WithDownlinkMBR(30000). + WithGateStatus(gateStatus). + Build() + + qers = append(qers, uplinkAppQER) + qers = append(qers, downlinkAppQER) + + ID++ } sess, err := sim.EstablishSession(pdrs, fars, qers) From 8f9f408c377e4b2b784b5f803cf8bc648a1598db Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Wed, 23 Mar 2022 16:00:36 +0100 Subject: [PATCH 08/22] Remove debug code --- internal/pfcpsim/server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index 705ae8c..9d3010f 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -114,9 +114,9 @@ func (P pfcpSimService) Disassociate(ctx context.Context, empty *pb.EmptyRequest } func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSessionRequest) (*pb.Response, error) { - //if err := checkServerStatus(); err != nil { - // return &pb.Response{}, err - //} + if err := checkServerStatus(); err != nil { + return &pb.Response{}, err + } baseID := int(request.BaseID) count := int(request.Count) From 10cd759a2ce46472baf8d8dbbb9a113393c45ded Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Wed, 23 Mar 2022 16:51:42 +0100 Subject: [PATCH 09/22] Fix incorrect handling of IDs --- internal/pfcpsim/server.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index 9d3010f..3c8dc5d 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -159,15 +159,6 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes // create as many PDRs, FARs and App QERs as the number of app filters provided through pfcpctl ID := uint16(i) - uplinkPdrID := ID - downlinkPdrID := ID + 1 - - uplinkFarID := uint32(ID) - downlinkFarID := uint32(ID + 1) - - uplinkAppQerID := uint32(ID) - downlinkAppQerID := uint32(ID + 1) - for _, appFilter := range request.AppFilters { SDFFilter, gateStatus, err = parseAppFilter(appFilter) if err != nil { @@ -176,6 +167,15 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes log.Infof("Successfully parsed application filter. SDF Filter: %v", SDFFilter) + uplinkPdrID := ID + downlinkPdrID := ID + 1 + + uplinkFarID := uint32(ID) + downlinkFarID := uint32(ID + 1) + + uplinkAppQerID := uint32(ID) + downlinkAppQerID := uint32(ID + 1) + uplinkPDR := session.NewPDRBuilder(). WithID(uplinkPdrID). WithMethod(session.Create). @@ -243,7 +243,7 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes qers = append(qers, uplinkAppQER) qers = append(qers, downlinkAppQER) - ID++ + ID += 2 } sess, err := sim.EstablishSession(pdrs, fars, qers) From 4f4c13df0368efdcec6faadcd62d12cc61b6c1d0 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Wed, 23 Mar 2022 17:07:50 +0100 Subject: [PATCH 10/22] Fix default protocol --- internal/pfcpctl/commands/sessions.go | 2 +- internal/pfcpsim/helpers.go | 6 ++---- internal/pfcpsim/server.go | 4 ++++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/pfcpctl/commands/sessions.go b/internal/pfcpctl/commands/sessions.go index 817c7ac..3a214ce 100644 --- a/internal/pfcpctl/commands/sessions.go +++ b/internal/pfcpctl/commands/sessions.go @@ -16,7 +16,7 @@ type commonArgs struct { BaseID int `short:"i" long:"baseID" default:"1" description:"The base ID to use"` UePool string `short:"u" long:"ue-pool" default:"17.0.0.0/24" description:"The UE pool address"` GnBAddress string `short:"g" long:"gnb-addr" description:"The UE pool address"` - AppFilterString []string `short:"a" long:"app-filter" default:"any:any:any:allow" description:"Specify an application filter. Format: '{ip | udp | tcp | any}:{IPv4 Prefix | any}:{- | any}:{allow | deny}' . e.g. 'udp:10.0.0.0/8:80-88:allow'"` + AppFilterString []string `short:"a" long:"app-filter" default:"ip:any:any:allow" description:"Specify an application filter. Format: '{ip | udp | tcp | any}:{IPv4 Prefix | any}:{- | any}:{allow | deny}' . e.g. 'udp:10.0.0.0/8:80-88:allow'"` QFI uint8 `short:"q" long:"qfi" description:"The QFI value for QERs. Max value 64."` } diff --git a/internal/pfcpsim/helpers.go b/internal/pfcpsim/helpers.go index 2485fa9..be9c7ac 100644 --- a/internal/pfcpsim/helpers.go +++ b/internal/pfcpsim/helpers.go @@ -100,10 +100,8 @@ func parseAppFilter(filter string) (string, uint8, error) { return "", 0, pfcpsim.NewInvalidFormatError("Action. Please make sure to use 'allow' or 'deny'") } - if proto != "any" { - if !(proto == "ip" || proto == "udp" || proto == "tcp") { - return "", 0, pfcpsim.NewInvalidFormatError("Unsupported or unknown protocol.") - } + if !(proto == "ip" || proto == "udp" || proto == "tcp") { + return "", 0, pfcpsim.NewInvalidFormatError("Unsupported or unknown protocol.") } if ipNetAddr != "any" { diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index 3c8dc5d..c1b11a9 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -135,6 +135,10 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes qfi = uint8(request.Qfi) } + if len(request.AppFilters) > SessionStep/2 { + return &pb.Response{}, status.Error(codes.Aborted, "Too many application filters") + } + for i := baseID; i < (count*SessionStep + baseID); i = i + SessionStep { // using variables to ease comprehension on how rules are linked together uplinkTEID := uint32(i) From aeeedc274ee0dfac57c6325fd4bca992f2eaf322 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Wed, 23 Mar 2022 17:33:16 +0100 Subject: [PATCH 11/22] Refactor comment --- internal/pfcpsim/server.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index c1b11a9..4b54a2d 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -23,7 +23,9 @@ import ( type pfcpSimService struct{} // SessionStep identifies the step in loops, used while creating/modifying/deleting sessions and rules IDs. -// It should be high enough to avoid IDs overlap when creating sessions. +// It should be high enough to avoid IDs overlap when creating sessions. 5 Applications should be enough. +// In theory with ROC limitations, we should expect max 8 applications (5 explicit applications + 3 filters +// to deny traffic to the RFC1918 IPs, in case we have a ALLOW-PUBLIC) const SessionStep = 10 func NewPFCPSimService(iface string) *pfcpSimService { From d4d0e964ea110b9e1cc2209884af8918a8a84c12 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Wed, 23 Mar 2022 18:32:21 +0100 Subject: [PATCH 12/22] Sync changes when modifying sessions --- api/pfcpsim.pb.go | 24 +++++++++++++++++------- api/pfcpsim.proto | 1 + internal/pfcpsim/server.go | 16 +++++++++++----- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/api/pfcpsim.pb.go b/api/pfcpsim.pb.go index 4c25fc7..cb3136c 100644 --- a/api/pfcpsim.pb.go +++ b/api/pfcpsim.pb.go @@ -129,11 +129,12 @@ type ModifySessionRequest struct { // count represents the number of session Count int32 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` // baseID is used to create incremental IDs for PDRs, FARs, QERs - BaseID int32 `protobuf:"varint,2,opt,name=baseID,proto3" json:"baseID,omitempty"` - NodeBAddress string `protobuf:"bytes,3,opt,name=nodeBAddress,proto3" json:"nodeBAddress,omitempty"` - UeAddressPool string `protobuf:"bytes,4,opt,name=ueAddressPool,proto3" json:"ueAddressPool,omitempty"` - BufferFlag bool `protobuf:"varint,5,opt,name=bufferFlag,proto3" json:"bufferFlag,omitempty"` - NotifyCPFlag bool `protobuf:"varint,6,opt,name=notifyCPFlag,proto3" json:"notifyCPFlag,omitempty"` + BaseID int32 `protobuf:"varint,2,opt,name=baseID,proto3" json:"baseID,omitempty"` + NodeBAddress string `protobuf:"bytes,3,opt,name=nodeBAddress,proto3" json:"nodeBAddress,omitempty"` + UeAddressPool string `protobuf:"bytes,4,opt,name=ueAddressPool,proto3" json:"ueAddressPool,omitempty"` + BufferFlag bool `protobuf:"varint,5,opt,name=bufferFlag,proto3" json:"bufferFlag,omitempty"` + NotifyCPFlag bool `protobuf:"varint,6,opt,name=notifyCPFlag,proto3" json:"notifyCPFlag,omitempty"` + AppFilters []string `protobuf:"bytes,7,rep,name=appFilters,proto3" json:"appFilters,omitempty"` } func (x *ModifySessionRequest) Reset() { @@ -210,6 +211,13 @@ func (x *ModifySessionRequest) GetNotifyCPFlag() bool { return false } +func (x *ModifySessionRequest) GetAppFilters() []string { + if x != nil { + return x.AppFilters + } + return nil +} + type ConfigureRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -432,7 +440,7 @@ var file_pfcpsim_proto_rawDesc = []byte{ 0x73, 0x50, 0x6f, 0x6f, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x70, 0x70, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, 0x70, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x71, 0x66, 0x69, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x03, 0x71, 0x66, 0x69, 0x22, 0xd2, 0x01, 0x0a, 0x14, 0x4d, 0x6f, 0x64, 0x69, + 0x28, 0x05, 0x52, 0x03, 0x71, 0x66, 0x69, 0x22, 0xf2, 0x01, 0x0a, 0x14, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x61, 0x73, 0x65, 0x49, 0x44, @@ -445,7 +453,9 @@ var file_pfcpsim_proto_rawDesc = []byte{ 0x65, 0x72, 0x46, 0x6c, 0x61, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x43, 0x50, 0x46, 0x6c, 0x61, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, - 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x43, 0x50, 0x46, 0x6c, 0x61, 0x67, 0x22, 0x64, 0x0a, 0x10, + 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x43, 0x50, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x1e, 0x0a, 0x0a, + 0x61, 0x70, 0x70, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x0a, 0x61, 0x70, 0x70, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x22, 0x64, 0x0a, 0x10, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x75, 0x70, 0x66, 0x4e, 0x33, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x75, 0x70, 0x66, 0x4e, 0x33, 0x41, 0x64, 0x64, diff --git a/api/pfcpsim.proto b/api/pfcpsim.proto index af84bb5..1b092b8 100644 --- a/api/pfcpsim.proto +++ b/api/pfcpsim.proto @@ -26,6 +26,7 @@ message ModifySessionRequest { string ueAddressPool = 4; bool bufferFlag = 5; bool notifyCPFlag = 6; + repeated string appFilters = 7; } message ConfigureRequest { diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index 4b54a2d..66911f8 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -296,22 +296,28 @@ func (P pfcpSimService) ModifySession(ctx context.Context, request *pb.ModifySes } for i := baseID; i < (count*SessionStep + baseID); i = i + SessionStep { + var newFARs []*ieLib.IE + + ID := uint32(i) teid := uint32(i + 1) if request.BufferFlag || request.NotifyCPFlag { teid = 0 // When buffering, TEID = 0. } - newFARs := []*ieLib.IE{ - // Downlink FAR - session.NewFARBuilder(). - WithID(uint32(i + 1)). // Same FARID that was generated in create sessions + for _, _ = range request.AppFilters { + downlinkFAR := session.NewFARBuilder(). + WithID(ID + 1). // Same FARID that was generated in create sessions WithMethod(session.Update). WithAction(actions). WithDstInterface(ieLib.DstInterfaceAccess). WithTEID(teid). WithDownlinkIP(nodeBaddress). - BuildFAR(), + BuildFAR() + + newFARs = append(newFARs, downlinkFAR) + + ID += 2 } sess, ok := getSession(i) From 00053c0d8197fa094244122c5a2d8bf1bb80b5df Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Wed, 23 Mar 2022 18:43:25 +0100 Subject: [PATCH 13/22] Use app filters also when modifying sessions to generate the correct IDs --- internal/pfcpsim/server.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index 66911f8..634cae1 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -138,6 +138,7 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes } if len(request.AppFilters) > SessionStep/2 { + log.Errorf("Too many application filters: %v", request.AppFilters) return &pb.Response{}, status.Error(codes.Aborted, "Too many application filters") } @@ -211,14 +212,14 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes pdrs = append(pdrs, downlinkPDR) uplinkFAR := session.NewFARBuilder(). - WithID(uint32(ID)). + WithID(uplinkFarID). WithAction(session.ActionForward). WithDstInterface(ieLib.DstInterfaceCore). WithMethod(session.Create). BuildFAR() downlinkFAR := session.NewFARBuilder(). - WithID(uint32(ID + 1)). + WithID(downlinkFarID). WithAction(session.ActionDrop). WithMethod(session.Create). WithDstInterface(ieLib.DstInterfaceAccess). @@ -295,6 +296,11 @@ func (P pfcpSimService) ModifySession(ctx context.Context, request *pb.ModifySes actions |= session.ActionForward } + if len(request.AppFilters) > SessionStep/2 { + log.Errorf("Too many application filters: %v", request.AppFilters) + return &pb.Response{}, status.Error(codes.Aborted, "Too many application filters") + } + for i := baseID; i < (count*SessionStep + baseID); i = i + SessionStep { var newFARs []*ieLib.IE From e1fd009d691c4c8f2d42e57879f914c8f0c1d0ba Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Thu, 24 Mar 2022 11:02:10 +0100 Subject: [PATCH 14/22] Fix missing app filters when modifying sessions --- internal/pfcpctl/commands/sessions.go | 1 + internal/pfcpsim/server.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/pfcpctl/commands/sessions.go b/internal/pfcpctl/commands/sessions.go index 3a214ce..91d671e 100644 --- a/internal/pfcpctl/commands/sessions.go +++ b/internal/pfcpctl/commands/sessions.go @@ -88,6 +88,7 @@ func (s *sessionModify) Execute(args []string) error { UeAddressPool: s.Args.UePool, BufferFlag: s.Args.BufferFlag, NotifyCPFlag: s.Args.NotifyCPFlag, + AppFilters: s.Args.AppFilterString, }) if err != nil { diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index 634cae1..96cc820 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -304,7 +304,7 @@ func (P pfcpSimService) ModifySession(ctx context.Context, request *pb.ModifySes for i := baseID; i < (count*SessionStep + baseID); i = i + SessionStep { var newFARs []*ieLib.IE - ID := uint32(i) + ID := uint32(i + 1) teid := uint32(i + 1) if request.BufferFlag || request.NotifyCPFlag { @@ -313,7 +313,7 @@ func (P pfcpSimService) ModifySession(ctx context.Context, request *pb.ModifySes for _, _ = range request.AppFilters { downlinkFAR := session.NewFARBuilder(). - WithID(ID + 1). // Same FARID that was generated in create sessions + WithID(ID). // Same FARID that was generated in create sessions WithMethod(session.Update). WithAction(actions). WithDstInterface(ieLib.DstInterfaceAccess). From 2797c7eb7018f08333a837920ee4109f11b9d377 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Thu, 24 Mar 2022 11:12:09 +0100 Subject: [PATCH 15/22] Refactor --- internal/pfcpsim/helpers.go | 13 +++++++++++++ internal/pfcpsim/server.go | 10 ++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/internal/pfcpsim/helpers.go b/internal/pfcpsim/helpers.go index be9c7ac..afb6913 100644 --- a/internal/pfcpsim/helpers.go +++ b/internal/pfcpsim/helpers.go @@ -10,7 +10,10 @@ import ( "strings" "github.com/omec-project/pfcpsim/pkg/pfcpsim" + log "github.com/sirupsen/logrus" "github.com/wmnsk/go-pfcp/ie" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) const sdfFilterFormatWPort = "permit out %v from %v to assigned %v-%v" @@ -48,6 +51,16 @@ func isRemotePeerConnected() bool { return remotePeerConnected } +// isNumOfAppFiltersCorrect returns error if the number of the passed filter exceed the max number of supported application filters. +func isNumOfAppFiltersCorrect(filters []string) error { + if len(filters) > SessionStep/2 { + log.Errorf("Too many application filters: %v", filters) + return status.Error(codes.Aborted, "Too many application filters") + } + + return nil +} + // getLocalAddress returns the first IP address of the interfaceName, if specified, // otherwise returns the IP address of the first non-loopback interface // Returns error if fail occurs at any stage. diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index 96cc820..bb2a535 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -137,9 +137,8 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes qfi = uint8(request.Qfi) } - if len(request.AppFilters) > SessionStep/2 { - log.Errorf("Too many application filters: %v", request.AppFilters) - return &pb.Response{}, status.Error(codes.Aborted, "Too many application filters") + if err = isNumOfAppFiltersCorrect(request.AppFilters); err != nil { + return &pb.Response{}, err } for i := baseID; i < (count*SessionStep + baseID); i = i + SessionStep { @@ -296,9 +295,8 @@ func (P pfcpSimService) ModifySession(ctx context.Context, request *pb.ModifySes actions |= session.ActionForward } - if len(request.AppFilters) > SessionStep/2 { - log.Errorf("Too many application filters: %v", request.AppFilters) - return &pb.Response{}, status.Error(codes.Aborted, "Too many application filters") + if err := isNumOfAppFiltersCorrect(request.AppFilters); err != nil { + return &pb.Response{}, err } for i := baseID; i < (count*SessionStep + baseID); i = i + SessionStep { From 479fa0580e0d75183b7c2f29a0a05cd18bc0ab95 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Thu, 24 Mar 2022 12:02:59 +0100 Subject: [PATCH 16/22] Add precedence in app filter format --- internal/pfcpctl/commands/sessions.go | 2 +- internal/pfcpsim/helpers.go | 40 +++++++++++++++++---------- internal/pfcpsim/server.go | 15 +++++----- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/internal/pfcpctl/commands/sessions.go b/internal/pfcpctl/commands/sessions.go index 91d671e..384d549 100644 --- a/internal/pfcpctl/commands/sessions.go +++ b/internal/pfcpctl/commands/sessions.go @@ -16,7 +16,7 @@ type commonArgs struct { BaseID int `short:"i" long:"baseID" default:"1" description:"The base ID to use"` UePool string `short:"u" long:"ue-pool" default:"17.0.0.0/24" description:"The UE pool address"` GnBAddress string `short:"g" long:"gnb-addr" description:"The UE pool address"` - AppFilterString []string `short:"a" long:"app-filter" default:"ip:any:any:allow" description:"Specify an application filter. Format: '{ip | udp | tcp | any}:{IPv4 Prefix | any}:{- | any}:{allow | deny}' . e.g. 'udp:10.0.0.0/8:80-88:allow'"` + AppFilterString []string `short:"a" long:"app-filter" default:"ip:any:any:allow:100" description:"Specify an application filter. Format: '{ip | udp | tcp | any}:{IPv4 Prefix | any}:{- | any}:{allow | deny}:{rule precedence}' . e.g. 'udp:10.0.0.0/8:80-88:allow:100'"` QFI uint8 `short:"q" long:"qfi" description:"The QFI value for QERs. Max value 64."` } diff --git a/internal/pfcpsim/helpers.go b/internal/pfcpsim/helpers.go index afb6913..63e5b85 100644 --- a/internal/pfcpsim/helpers.go +++ b/internal/pfcpsim/helpers.go @@ -93,15 +93,20 @@ func getLocalAddress(interfaceName string) (net.IP, error) { } // parseAppFilter parses an application filter. Returns a tuple formed by a formatted SDF filter -// and a uint8 representing the Application QER gate status. Returns error if fail occurs while validating the filter string. -func parseAppFilter(filter string) (string, uint8, error) { +// and a uint8 representing the Application QER gate status and a precedence. Returns error if fail occurs while validating the filter string. +func parseAppFilter(filter string) (string, uint8, uint32, error) { + if filter == "" { + // parsing a wildcard app filter + return "", ie.GateStatusOpen, 100, nil + } + result := strings.Split(filter, ":") - if len(result) != 4 { - return "", 0, pfcpsim.NewInvalidFormatError("Parser was not able to generate the correct number of arguments." + + if len(result) != 5 { + return "", 0, 0, pfcpsim.NewInvalidFormatError("Parser was not able to generate the correct number of arguments." + " Please make sure to use the right format") } - proto, ipNetAddr, portRange, action := result[0], result[1], result[2], result[3] + proto, ipNetAddr, portRange, action, precedence := result[0], result[1], result[2], result[3], result[4] var gateStatus uint8 switch action { @@ -110,41 +115,48 @@ func parseAppFilter(filter string) (string, uint8, error) { case "deny": gateStatus = ie.GateStatusClosed default: - return "", 0, pfcpsim.NewInvalidFormatError("Action. Please make sure to use 'allow' or 'deny'") + return "", 0, 0, pfcpsim.NewInvalidFormatError("Action. Please make sure to use 'allow' or 'deny'") } if !(proto == "ip" || proto == "udp" || proto == "tcp") { - return "", 0, pfcpsim.NewInvalidFormatError("Unsupported or unknown protocol.") + return "", 0, 0, pfcpsim.NewInvalidFormatError("Unsupported or unknown protocol.") + } + + precedenceConverted, err := strconv.Atoi(precedence) + if err != nil { + return "", 0, 0, pfcpsim.NewInvalidFormatError("Precedence. Please make sure it is a number", err) } + precedenceUint := uint32(precedenceConverted) + if ipNetAddr != "any" { _, _, err := net.ParseCIDR(ipNetAddr) if err != nil { - return "", 0, pfcpsim.NewInvalidFormatError("IP and subnet mask.", err) + return "", 0, 0, pfcpsim.NewInvalidFormatError("IP and subnet mask.", err) } } if portRange != "any" { portList := strings.Split(portRange, "-") if !(len(portList) == 2) { - return "", 0, pfcpsim.NewInvalidFormatError("Port range. Please make sure to use dash '-' to separate the two ports") + return "", 0, 0, pfcpsim.NewInvalidFormatError("Port range. Please make sure to use dash '-' to separate the two ports") } lowerPort, err := strconv.Atoi(portList[0]) if err != nil { - return "", 0, pfcpsim.NewInvalidFormatError("Port range.", err) + return "", 0, 0, pfcpsim.NewInvalidFormatError("Port range.", err) } upperPort, err := strconv.Atoi(portList[1]) if err != nil { - return "", 0, pfcpsim.NewInvalidFormatError("Port range.", err) + return "", 0, 0, pfcpsim.NewInvalidFormatError("Port range.", err) } if lowerPort > upperPort { - return "", 0, pfcpsim.NewInvalidFormatError("Port range. Lower port is greater than upper port") + return "", 0, 0, pfcpsim.NewInvalidFormatError("Port range. Lower port is greater than upper port") } - return fmt.Sprintf(sdfFilterFormatWPort, proto, ipNetAddr, lowerPort, upperPort), gateStatus, nil + return fmt.Sprintf(sdfFilterFormatWPort, proto, ipNetAddr, lowerPort, upperPort), gateStatus, precedenceUint, nil } else { - return fmt.Sprintf(sdfFilterFormatWOPort, proto, ipNetAddr), gateStatus, nil + return fmt.Sprintf(sdfFilterFormatWOPort, proto, ipNetAddr), gateStatus, precedenceUint, nil } } diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index bb2a535..7b4b285 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -116,9 +116,9 @@ func (P pfcpSimService) Disassociate(ctx context.Context, empty *pb.EmptyRequest } func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSessionRequest) (*pb.Response, error) { - if err := checkServerStatus(); err != nil { - return &pb.Response{}, err - } + //if err := checkServerStatus(); err != nil { + // return &pb.Response{}, err + //} baseID := int(request.BaseID) count := int(request.Count) @@ -130,8 +130,7 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes return &pb.Response{}, status.Error(codes.Aborted, errMsg) } - var SDFFilter = "" - var qfi, gateStatus uint8 = 0, ieLib.GateStatusOpen + var qfi uint8 = 0 if request.Qfi != 0 { qfi = uint8(request.Qfi) @@ -166,7 +165,7 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes ID := uint16(i) for _, appFilter := range request.AppFilters { - SDFFilter, gateStatus, err = parseAppFilter(appFilter) + SDFFilter, gateStatus, precedence, err := parseAppFilter(appFilter) if err != nil { return &pb.Response{}, status.Error(codes.Aborted, err.Error()) } @@ -191,14 +190,14 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes AddQERID(uplinkAppQerID). WithN3Address(upfN3Address). WithSDFFilter(SDFFilter). - WithPrecedence(100). + WithPrecedence(precedence). MarkAsUplink(). BuildPDR() downlinkPDR := session.NewPDRBuilder(). WithID(downlinkPdrID). WithMethod(session.Create). - WithPrecedence(100). + WithPrecedence(precedence). WithUEAddress(ueAddress.String()). WithSDFFilter(SDFFilter). AddQERID(sessQerID). From 2da62e6bbf0764b057b699fe9675cb5e4821eb81 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Thu, 24 Mar 2022 12:05:02 +0100 Subject: [PATCH 17/22] Remove debug code --- internal/pfcpsim/server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index 7b4b285..91b1e7b 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -116,9 +116,9 @@ func (P pfcpSimService) Disassociate(ctx context.Context, empty *pb.EmptyRequest } func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSessionRequest) (*pb.Response, error) { - //if err := checkServerStatus(); err != nil { - // return &pb.Response{}, err - //} + if err := checkServerStatus(); err != nil { + return &pb.Response{}, err + } baseID := int(request.BaseID) count := int(request.Count) From 3674e85e21971a144014550cc781aa6d788bfcaf Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Thu, 24 Mar 2022 12:08:43 +0100 Subject: [PATCH 18/22] Add test cases for app filter parser --- internal/pfcpsim/helpers_test.go | 36 +++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/internal/pfcpsim/helpers_test.go b/internal/pfcpsim/helpers_test.go index 06a8197..fa82fa8 100644 --- a/internal/pfcpsim/helpers_test.go +++ b/internal/pfcpsim/helpers_test.go @@ -18,6 +18,7 @@ func Test_parseAppFilter(t *testing.T) { type want struct { SDFFilter string gateStatus uint8 + precedence uint32 } tests := []struct { @@ -28,56 +29,62 @@ func Test_parseAppFilter(t *testing.T) { }{ {name: "Correct app filter", args: &args{ - filterString: "udp:10.0.0.0/8:80-80:allow", + filterString: "udp:10.0.0.0/8:80-80:allow:100", }, want: &want{ SDFFilter: "permit out udp from 10.0.0.0/8 to assigned 80-80", gateStatus: ie.GateStatusOpen, + precedence: 100, }, }, {name: "Correct app filter with deny", args: &args{ - filterString: "udp:10.0.0.0/8:80-80:deny", + filterString: "udp:10.0.0.0/8:80-80:deny:101", }, want: &want{ SDFFilter: "permit out udp from 10.0.0.0/8 to assigned 80-80", gateStatus: ie.GateStatusClosed, + precedence: 101, }, }, {name: "Correct app filter with deny-all policy", args: &args{ - filterString: "ip:0.0.0.0/0:any:deny", + filterString: "ip:0.0.0.0/0:any:deny:102", }, want: &want{ SDFFilter: "permit out ip from 0.0.0.0/0 to assigned", gateStatus: ie.GateStatusClosed, + precedence: 102, }, }, {name: "Correct app filter with deny-all policy 2", args: &args{ - filterString: "ip:any:any:deny", + filterString: "ip:any:any:deny:100", }, want: &want{ SDFFilter: "permit out ip from any to assigned", gateStatus: ie.GateStatusClosed, + precedence: 100, }, }, {name: "Correct app filter with allow-all policy", args: &args{ - filterString: "ip:any:any:allow", + filterString: "ip:any:any:allow:100", }, want: &want{ SDFFilter: "permit out ip from any to assigned", gateStatus: ie.GateStatusOpen, + precedence: 100, }, }, {name: "Correct app filter with allow-all policy 2", args: &args{ - filterString: "ip:0.0.0.0/0:any:allow", + filterString: "ip:0.0.0.0/0:any:allow:103", }, want: &want{ SDFFilter: "permit out ip from 0.0.0.0/0 to assigned", gateStatus: ie.GateStatusOpen, + precedence: 103, }, }, {name: "incorrect app filter bad protocol", @@ -94,12 +101,26 @@ func Test_parseAppFilter(t *testing.T) { want: &want{}, wantErr: true, }, + {name: "incorrect app filter missing precedence", + args: &args{ + filterString: "ip:10/8:80-80:allow", + }, + want: &want{}, + wantErr: true, + }, + {name: "incorrect app filter bad precedence", + args: &args{ + filterString: "ip:10/8:80-80:allow:test", + }, + want: &want{}, + wantErr: true, + }, } for _, tt := range tests { t.Run( tt.name, func(t *testing.T) { - filter, gateStatus, err := parseAppFilter(tt.args.filterString) + filter, gateStatus, precedence, err := parseAppFilter(tt.args.filterString) if tt.wantErr { require.Error(t, err) return @@ -107,6 +128,7 @@ func Test_parseAppFilter(t *testing.T) { require.Equal(t, tt.want.SDFFilter, filter) require.Equal(t, tt.want.gateStatus, gateStatus) + require.Equal(t, tt.want.precedence, precedence) }, ) } From f4c65731896599c74c5b9406307ee5298f977e55 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Thu, 24 Mar 2022 12:20:51 +0100 Subject: [PATCH 19/22] Fix format in app filter flag --- internal/pfcpctl/commands/sessions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/pfcpctl/commands/sessions.go b/internal/pfcpctl/commands/sessions.go index 384d549..da0f12f 100644 --- a/internal/pfcpctl/commands/sessions.go +++ b/internal/pfcpctl/commands/sessions.go @@ -16,7 +16,7 @@ type commonArgs struct { BaseID int `short:"i" long:"baseID" default:"1" description:"The base ID to use"` UePool string `short:"u" long:"ue-pool" default:"17.0.0.0/24" description:"The UE pool address"` GnBAddress string `short:"g" long:"gnb-addr" description:"The UE pool address"` - AppFilterString []string `short:"a" long:"app-filter" default:"ip:any:any:allow:100" description:"Specify an application filter. Format: '{ip | udp | tcp | any}:{IPv4 Prefix | any}:{- | any}:{allow | deny}:{rule precedence}' . e.g. 'udp:10.0.0.0/8:80-88:allow:100'"` + AppFilterString []string `short:"a" long:"app-filter" default:"ip:any:any:allow:100" description:"Specify an application filter. Format: '{ip | udp | tcp}:{IPv4 Prefix | any}:{- | any}:{allow | deny}:{rule-precedence}' . e.g. 'udp:10.0.0.0/8:80-88:allow:100'"` QFI uint8 `short:"q" long:"qfi" description:"The QFI value for QERs. Max value 64."` } From 00207157d920a4d463ac2e4d9cddeed1d0c26158 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Thu, 24 Mar 2022 15:43:22 +0100 Subject: [PATCH 20/22] Add check on baseID --- internal/pfcpctl/commands/helpers.go | 6 ++++++ internal/pfcpctl/commands/sessions.go | 6 ++++++ internal/pfcpsim/server.go | 8 ++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/pfcpctl/commands/helpers.go b/internal/pfcpctl/commands/helpers.go index 7431bd1..6a55a3f 100644 --- a/internal/pfcpctl/commands/helpers.go +++ b/internal/pfcpctl/commands/helpers.go @@ -24,6 +24,12 @@ func connect() pb.PFCPSimClient { return pb.NewPFCPSimClient(conn) } +func isBaseIDValid(baseID int) { + if baseID <= 0 { + log.Fatalf("BaseID cannot be 0 or a negative number.") + } +} + func disconnect() { if conn != nil { conn.Close() diff --git a/internal/pfcpctl/commands/sessions.go b/internal/pfcpctl/commands/sessions.go index da0f12f..5ca7369 100644 --- a/internal/pfcpctl/commands/sessions.go +++ b/internal/pfcpctl/commands/sessions.go @@ -59,6 +59,8 @@ func (s *sessionCreate) Execute(args []string) error { client := connect() defer disconnect() + isBaseIDValid(s.Args.BaseID) + res, err := client.CreateSession(context.Background(), &pb.CreateSessionRequest{ Count: int32(s.Args.Count), BaseID: int32(s.Args.BaseID), @@ -81,6 +83,8 @@ func (s *sessionModify) Execute(args []string) error { client := connect() defer disconnect() + isBaseIDValid(s.Args.BaseID) + res, err := client.ModifySession(context.Background(), &pb.ModifySessionRequest{ Count: int32(s.Args.Count), BaseID: int32(s.Args.BaseID), @@ -104,6 +108,8 @@ func (s *sessionDelete) Execute(args []string) error { client := connect() defer disconnect() + isBaseIDValid(s.Args.BaseID) + res, err := client.DeleteSession(context.Background(), &pb.DeleteSessionRequest{ Count: int32(s.Args.Count), BaseID: int32(s.Args.BaseID), diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index 91b1e7b..91fcd6f 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -116,9 +116,9 @@ func (P pfcpSimService) Disassociate(ctx context.Context, empty *pb.EmptyRequest } func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSessionRequest) (*pb.Response, error) { - if err := checkServerStatus(); err != nil { - return &pb.Response{}, err - } + //if err := checkServerStatus(); err != nil { + // return &pb.Response{}, err + //} baseID := int(request.BaseID) count := int(request.Count) @@ -147,7 +147,7 @@ func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSes ueAddress := iplib.NextIP(lastUEAddr) lastUEAddr = ueAddress - sessQerID := uint32(i + 3) + sessQerID := uint32(0) var pdrs, fars []*ieLib.IE From a50bb9d1279b78b1e0dbcb561fefd56cf4bdc3e3 Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Thu, 24 Mar 2022 16:03:01 +0100 Subject: [PATCH 21/22] Add validation step --- internal/pfcpctl/commands/helpers.go | 6 ++---- internal/pfcpctl/commands/sessions.go | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/internal/pfcpctl/commands/helpers.go b/internal/pfcpctl/commands/helpers.go index 6a55a3f..c4f9549 100644 --- a/internal/pfcpctl/commands/helpers.go +++ b/internal/pfcpctl/commands/helpers.go @@ -24,10 +24,8 @@ func connect() pb.PFCPSimClient { return pb.NewPFCPSimClient(conn) } -func isBaseIDValid(baseID int) { - if baseID <= 0 { - log.Fatalf("BaseID cannot be 0 or a negative number.") - } +func validateArgs(args *commonArgs) { + } func disconnect() { diff --git a/internal/pfcpctl/commands/sessions.go b/internal/pfcpctl/commands/sessions.go index 5ca7369..c60b6f6 100644 --- a/internal/pfcpctl/commands/sessions.go +++ b/internal/pfcpctl/commands/sessions.go @@ -20,6 +20,16 @@ type commonArgs struct { QFI uint8 `short:"q" long:"qfi" description:"The QFI value for QERs. Max value 64."` } +func (a *commonArgs) validate() { + if a.BaseID <= 0 { + log.Fatalf("BaseID cannot be 0 or a negative number.") + } + + if a.Count <= 0 { + log.Fatalf("Count cannot be 0 or a negative number.") + } +} + type sessionCreate struct { Args struct { commonArgs @@ -36,8 +46,7 @@ type sessionModify struct { type sessionDelete struct { Args struct { - Count int `short:"c" long:"count" default:"1" description:"The number of sessions to create"` - BaseID int `short:"i" long:"baseID" default:"1" description:"The base ID to use"` + commonArgs } } @@ -59,7 +68,7 @@ func (s *sessionCreate) Execute(args []string) error { client := connect() defer disconnect() - isBaseIDValid(s.Args.BaseID) + s.Args.validate() res, err := client.CreateSession(context.Background(), &pb.CreateSessionRequest{ Count: int32(s.Args.Count), @@ -83,7 +92,7 @@ func (s *sessionModify) Execute(args []string) error { client := connect() defer disconnect() - isBaseIDValid(s.Args.BaseID) + s.Args.validate() res, err := client.ModifySession(context.Background(), &pb.ModifySessionRequest{ Count: int32(s.Args.Count), @@ -108,7 +117,7 @@ func (s *sessionDelete) Execute(args []string) error { client := connect() defer disconnect() - isBaseIDValid(s.Args.BaseID) + s.Args.validate() res, err := client.DeleteSession(context.Background(), &pb.DeleteSessionRequest{ Count: int32(s.Args.Count), From b867dda6f6938ec3a132b017beace42fbe87f99b Mon Sep 17 00:00:00 2001 From: Emanuele Gallone Date: Thu, 24 Mar 2022 20:26:14 +0100 Subject: [PATCH 22/22] Remove debug code --- internal/pfcpsim/server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/pfcpsim/server.go b/internal/pfcpsim/server.go index 91fcd6f..010cc5a 100644 --- a/internal/pfcpsim/server.go +++ b/internal/pfcpsim/server.go @@ -116,9 +116,9 @@ func (P pfcpSimService) Disassociate(ctx context.Context, empty *pb.EmptyRequest } func (P pfcpSimService) CreateSession(ctx context.Context, request *pb.CreateSessionRequest) (*pb.Response, error) { - //if err := checkServerStatus(); err != nil { - // return &pb.Response{}, err - //} + if err := checkServerStatus(); err != nil { + return &pb.Response{}, err + } baseID := int(request.BaseID) count := int(request.Count)