diff --git a/pfcpiface/p4rt_translator.go b/pfcpiface/p4rt_translator.go index 0c2cb1fa0..7dcd2f08f 100644 --- a/pfcpiface/p4rt_translator.go +++ b/pfcpiface/p4rt_translator.go @@ -10,11 +10,11 @@ import ( "math/bits" "net" - "github.com/wmnsk/go-pfcp/ie" - + "github.com/omec-project/upf-epc/internal/p4constants" p4ConfigV1 "github.com/p4lang/p4runtime/go/p4/config/v1" p4 "github.com/p4lang/p4runtime/go/p4/v1" log "github.com/sirupsen/logrus" + "github.com/wmnsk/go-pfcp/ie" ) // P4 constants @@ -43,27 +43,6 @@ const ( FieldSessionMeterIndex = "session_meter_idx" FieldAppMeterIndex = "app_meter_idx" - TableInterfaces = "PreQosPipe.interfaces" - TableTunnelPeers = "PreQosPipe.tunnel_peers" - TableDownlinkTerminations = "PreQosPipe.terminations_downlink" - TableUplinkTerminations = "PreQosPipe.terminations_uplink" - TableDownlinkSessions = "PreQosPipe.sessions_downlink" - TableUplinkSessions = "PreQosPipe.sessions_uplink" - TableApplications = "PreQosPipe.applications" - - ActSetSourceIface = "PreQosPipe.set_source_iface" - ActSetUplinkSession = "PreQosPipe.set_session_uplink" - ActSetDownlinkSession = "PreQosPipe.set_session_downlink" - ActSetDownlinkSessionBuff = "PreQosPipe.set_session_downlink_buff" - ActUplinkTermDrop = "PreQosPipe.uplink_term_drop" - ActUplinkTermFwd = "PreQosPipe.uplink_term_fwd" - ActUplinkTermFwdNoTC = "PreQosPipe.uplink_term_fwd_no_tc" - ActDownlinkTermDrop = "PreQosPipe.downlink_term_drop" - ActDownlinkTermFwd = "PreQosPipe.downlink_term_fwd" - ActDownlinkTermFwdNoTC = "PreQosPipe.downlink_term_fwd_no_tc" - ActLoadTunnelParams = "PreQosPipe.load_tunnel_param" - ActSetAppID = "PreQosPipe.set_app_id" - DefaultPriority = 0 DefaultApplicationID = 0 // NoTC assuming bit<2> type of TC in UP4, @@ -134,44 +113,34 @@ func convertValueToBinary(value interface{}) ([]byte, error) { } } -func (t *P4rtTranslator) tableID(name string) uint32 { - for _, table := range t.p4Info.Tables { - if table.Preamble.Name == name { - return table.Preamble.Id +func (t *P4rtTranslator) getActionByID(actionID uint32) (*p4ConfigV1.Action, error) { + for _, action := range t.p4Info.Actions { + if action.Preamble.Id == actionID { + return action, nil } } - return invalidID + return nil, ErrNotFoundWithParam("action", "ID", actionID) } -func (t *P4rtTranslator) meterID(name string) uint32 { +func (t *P4rtTranslator) getMeterSizeByID(meterID uint32) (int64, error) { for _, meter := range t.p4Info.Meters { - if meter.Preamble.Name == name { - return meter.Preamble.Id + if meter.Preamble.Id == meterID { + return meter.GetSize(), nil } } - return invalidID + return 0, ErrNotFoundWithParam("meter", "ID", meterID) } -func (t *P4rtTranslator) actionID(name string) uint32 { - for _, action := range t.p4Info.Actions { - if action.Preamble.Name == name { - return action.Preamble.Id - } - } - - return invalidID -} - -func (t *P4rtTranslator) getActionByID(actionID uint32) (*p4ConfigV1.Action, error) { - for _, action := range t.p4Info.Actions { - if action.Preamble.Id == actionID { - return action, nil +func (t *P4rtTranslator) getCounterSizeByID(counterID uint32) (int64, error) { + for _, counter := range t.p4Info.Counters { + if counter.Preamble.Id == counterID { + return counter.GetSize(), nil } } - return nil, ErrNotFoundWithParam("action", "ID", actionID) + return 0, ErrNotFoundWithParam("counter", "ID", counterID) } func (t *P4rtTranslator) getTableByID(tableID uint32) (*p4ConfigV1.Table, error) { @@ -184,36 +153,6 @@ func (t *P4rtTranslator) getTableByID(tableID uint32) (*p4ConfigV1.Table, error) return nil, ErrNotFoundWithParam("table", "ID", tableID) } -func (t *P4rtTranslator) getTableIDByName(name string) (uint32, error) { - for _, table := range t.p4Info.Tables { - if table.Preamble.Name == name { - return table.Preamble.Id, nil - } - } - - return 0, ErrNotFoundWithParam("table", "name", name) -} - -func (t *P4rtTranslator) getCounterByName(name string) (*p4ConfigV1.Counter, error) { - for _, ctr := range t.p4Info.Counters { - if ctr.Preamble.Name == name { - return ctr, nil - } - } - - return nil, ErrNotFoundWithParam("counter", "name", name) -} - -func (t *P4rtTranslator) getMeterByName(name string) (*p4ConfigV1.Meter, error) { - for _, mtr := range t.p4Info.Meters { - if mtr.Preamble.Name == name { - return mtr, nil - } - } - - return nil, ErrNotFoundWithParam("meter", "name", name) -} - //nolint:unused func (t *P4rtTranslator) getMatchFieldIDByName(table *p4ConfigV1.Table, fieldName string) uint32 { for _, field := range table.MatchFields { @@ -496,10 +435,8 @@ func (t *P4rtTranslator) getLPMMatchFieldValue(tableEntry *p4.TableEntry, name s } func (t *P4rtTranslator) BuildInterfaceTableEntryNoAction() *p4.TableEntry { - tableID := t.tableID(TableInterfaces) - entry := &p4.TableEntry{ - TableId: tableID, + TableId: p4constants.TablePreQosPipeInterfaces, Priority: DefaultPriority, } @@ -507,8 +444,6 @@ func (t *P4rtTranslator) BuildInterfaceTableEntryNoAction() *p4.TableEntry { } func (t *P4rtTranslator) BuildInterfaceTableEntry(ipNet *net.IPNet, sliceID uint8, isCore bool) (*p4.TableEntry, error) { - tableID := t.tableID(TableInterfaces) - srcIface := access direction := DirectionUplink @@ -518,7 +453,7 @@ func (t *P4rtTranslator) BuildInterfaceTableEntry(ipNet *net.IPNet, sliceID uint } entry := &p4.TableEntry{ - TableId: tableID, + TableId: p4constants.TablePreQosPipeInterfaces, Priority: DefaultPriority, } @@ -528,7 +463,7 @@ func (t *P4rtTranslator) BuildInterfaceTableEntry(ipNet *net.IPNet, sliceID uint } action := &p4.Action{ - ActionId: t.actionID(ActSetSourceIface), + ActionId: p4constants.ActionPreQosPipeSetSourceIface, } if err := t.withActionParam(action, FieldSrcIface, srcIface); err != nil { @@ -556,9 +491,8 @@ func (t *P4rtTranslator) BuildApplicationsTableEntry(pdr pdr, sliceID uint8, int }) applicationsBuilderLog.Trace("Building P4rt table entry for applications table") - tableID := t.tableID(TableApplications) entry := &p4.TableEntry{ - TableId: tableID, + TableId: p4constants.TablePreQosPipeApplications, // priority for UP4 cannot be greater than 65535 Priority: int32(math.MaxUint16 - pdr.precedence), } @@ -602,7 +536,7 @@ func (t *P4rtTranslator) BuildApplicationsTableEntry(pdr pdr, sliceID uint8, int } action := &p4.Action{ - ActionId: t.actionID(ActSetAppID), + ActionId: p4constants.ActionPreQosPipeSetAppId, } if err := t.withActionParam(action, FieldApplicationID, internalAppID); err != nil { @@ -626,10 +560,8 @@ func (t *P4rtTranslator) buildUplinkSessionsEntry(pdr pdr, sessMeterIdx uint32) }) uplinkBuilderLog.Trace("Building P4rt table entry for sessions_uplink table") - tableID := t.tableID(TableUplinkSessions) - entry := &p4.TableEntry{ - TableId: tableID, + TableId: p4constants.TablePreQosPipeSessionsUplink, Priority: DefaultPriority, } @@ -642,7 +574,7 @@ func (t *P4rtTranslator) buildUplinkSessionsEntry(pdr pdr, sessMeterIdx uint32) } action := &p4.Action{ - ActionId: t.actionID(ActSetUplinkSession), + ActionId: p4constants.ActionPreQosPipeSetSessionUplink, } if err := t.withActionParam(action, FieldSessionMeterIndex, sessMeterIdx); err != nil { @@ -667,9 +599,8 @@ func (t *P4rtTranslator) buildDownlinkSessionsEntry(pdr pdr, sessMeterIdx uint32 }) builderLog.Trace("Building P4rt table entry for sessions_downlink table") - tableID := t.tableID(TableDownlinkSessions) entry := &p4.TableEntry{ - TableId: tableID, + TableId: p4constants.TablePreQosPipeSessionsDownlink, Priority: DefaultPriority, } @@ -680,11 +611,11 @@ func (t *P4rtTranslator) buildDownlinkSessionsEntry(pdr pdr, sessMeterIdx uint32 var action *p4.Action if needsBuffering { action = &p4.Action{ - ActionId: t.actionID(ActSetDownlinkSessionBuff), + ActionId: p4constants.ActionPreQosPipeSetSessionDownlinkBuff, } } else { action = &p4.Action{ - ActionId: t.actionID(ActSetDownlinkSession), + ActionId: p4constants.ActionPreQosPipeSetSessionDownlink, } if err := t.withActionParam(action, FieldTunnelPeerID, tunnelPeerID); err != nil { return nil, err @@ -723,9 +654,8 @@ func (t *P4rtTranslator) buildUplinkTerminationsEntry(pdr pdr, appMeterIdx uint3 }) builderLog.Debug("Building P4rt table entry for UP4 terminations_uplink table") - tableID := t.tableID(TableUplinkTerminations) entry := &p4.TableEntry{ - TableId: tableID, + TableId: p4constants.TablePreQosPipeTerminationsUplink, Priority: DefaultPriority, } @@ -745,11 +675,11 @@ func (t *P4rtTranslator) buildUplinkTerminationsEntry(pdr pdr, appMeterIdx uint3 var action *p4.Action if shouldDrop { action = &p4.Action{ - ActionId: t.actionID(ActUplinkTermDrop), + ActionId: p4constants.ActionPreQosPipeUplinkTermDrop, } } else if !shouldDrop && tc != NoTC { action = &p4.Action{ - ActionId: t.actionID(ActUplinkTermFwd), + ActionId: p4constants.ActionPreQosPipeUplinkTermFwd, } if err := t.withActionParam(action, FieldTrafficClass, tc); err != nil { @@ -760,7 +690,7 @@ func (t *P4rtTranslator) buildUplinkTerminationsEntry(pdr pdr, appMeterIdx uint3 } } else { action = &p4.Action{ - ActionId: t.actionID(ActUplinkTermFwdNoTC), + ActionId: p4constants.ActionPreQosPipeUplinkTermFwdNoTc, } if err := t.withActionParam(action, FieldAppMeterIndex, appMeterIdx); err != nil { return nil, err @@ -790,9 +720,8 @@ func (t *P4rtTranslator) buildDownlinkTerminationsEntry(pdr pdr, appMeterIdx uin }) builderLog.Debug("Building P4rt table entry for UP4 terminations_downlink table") - tableID := t.tableID(TableDownlinkTerminations) entry := &p4.TableEntry{ - TableId: tableID, + TableId: p4constants.TablePreQosPipeTerminationsDownlink, Priority: DefaultPriority, } @@ -812,11 +741,11 @@ func (t *P4rtTranslator) buildDownlinkTerminationsEntry(pdr pdr, appMeterIdx uin var action *p4.Action if shouldDrop { action = &p4.Action{ - ActionId: t.actionID(ActDownlinkTermDrop), + ActionId: p4constants.ActionPreQosPipeDownlinkTermDrop, } } else if !shouldDrop && tc != NoTC { action = &p4.Action{ - ActionId: t.actionID(ActDownlinkTermFwd), + ActionId: p4constants.ActionPreQosPipeDownlinkTermFwd, } if err := t.withActionParam(action, FieldTEID, relatedFAR.tunnelTEID); err != nil { @@ -836,7 +765,7 @@ func (t *P4rtTranslator) buildDownlinkTerminationsEntry(pdr pdr, appMeterIdx uin } } else { action = &p4.Action{ - ActionId: t.actionID(ActDownlinkTermFwdNoTC), + ActionId: p4constants.ActionPreQosPipeDownlinkTermFwdNoTc, } if err := t.withActionParam(action, FieldTEID, relatedFAR.tunnelTEID); err != nil { @@ -883,14 +812,13 @@ func (t *P4rtTranslator) BuildGTPTunnelPeerTableEntry(tunnelPeerID uint8, tunnel }) builderLog.Trace("Building P4rt table entry for GTP Tunnel Peers table") - tableID := t.tableID(TableTunnelPeers) entry := &p4.TableEntry{ - TableId: tableID, + TableId: p4constants.TablePreQosPipeTunnelPeers, Priority: DefaultPriority, Action: &p4.TableAction{ Type: &p4.TableAction_Action{ Action: &p4.Action{ - ActionId: t.actionID(ActLoadTunnelParams), + ActionId: p4constants.ActionPreQosPipeLoadTunnelParam, }, }, }, @@ -917,14 +845,15 @@ func (t *P4rtTranslator) BuildGTPTunnelPeerTableEntry(tunnelPeerID uint8, tunnel return entry, nil } -func (t *P4rtTranslator) BuildMeterEntry(meter string, cellID uint32, config *p4.MeterConfig) *p4.MeterEntry { +func (t *P4rtTranslator) BuildMeterEntry(meterID uint32, cellID uint32, config *p4.MeterConfig) *p4.MeterEntry { + meterName := p4constants.GetMeterIDToNameMap()[meterID] + builderLog := log.WithFields(log.Fields{ - "Meter": meter, + "Meter": meterName, "Cell ID": cellID, }) builderLog.Trace("Building Meter entry") - meterID := t.meterID(meter) entry := &p4.MeterEntry{ MeterId: meterID, Index: &p4.Index{Index: int64(cellID)}, diff --git a/pfcpiface/up4.go b/pfcpiface/up4.go index 83acdeb4e..856be7369 100644 --- a/pfcpiface/up4.go +++ b/pfcpiface/up4.go @@ -12,6 +12,7 @@ import ( "net" "time" + "github.com/omec-project/upf-epc/internal/p4constants" "google.golang.org/grpc/codes" p4 "github.com/p4lang/p4runtime/go/p4/v1" @@ -30,9 +31,6 @@ const ( maxGTPTunnelPeerIDs = 253 maxApplicationIDs = 254 - applicationMeter = "PreQosPipe.app_meter" - sessionMeter = "PreQosPipe.session_meter" - meterTypeApplication uint8 = 1 meterTypeSession uint8 = 2 @@ -132,23 +130,16 @@ func (up4 *UP4) sessionStats(*PfcpNodeCollector, chan<- prometheus.Metric) error func (up4 *UP4) portStats(uc *upfCollector, ch chan<- prometheus.Metric) { } -func (up4 *UP4) initCounter(counterID uint8, name string) error { - ctr, err := up4.p4RtTranslator.getCounterByName(name) - if err != nil { - return err - } - - up4.counters[counterID].maxSize = uint64(ctr.Size) - up4.counters[counterID].counterID = uint64(ctr.Preamble.Id) +func (up4 *UP4) initCounter(counterID uint8, name string, counterSize uint64) { + up4.counters[counterID].maxSize = counterSize + up4.counters[counterID].counterID = uint64(counterID) log.WithFields(log.Fields{ "counterID": counterID, "name": name, - "max-size": ctr.Size, - "UP4 counter ID": ctr.Preamble.Id, + "max-size": counterSize, + "UP4 counter ID": counterID, }).Debug("Counter initialized successfully") - - return nil } func resetCounterVal(p *UP4, counterID uint8, val uint64) { @@ -207,65 +198,69 @@ func (up4 *UP4) setupChannel() error { return nil } -func (up4 *UP4) initAllCounters() error { - log.Debug("Initializing counter for UP4") +func (up4 *UP4) initAllCounters() { + log.Debug("Initializing counters for UP4") - err := up4.initCounter(preQosCounterID, "PreQosPipe.pre_qos_counter") - if err != nil { - return ErrOperationFailedWithReason("init preQosCounterID counter", err.Error()) + counters := []uint32{ + p4constants.CounterPreQosPipePreQosCounter, + p4constants.CounterPostQosPipePostQosCounter, } - err = up4.initCounter(postQosCounterID, "PostQosPipe.post_qos_counter") - if err != nil { - return ErrOperationFailedWithReason("init postQosCounterID counter", err.Error()) - } + for _, counterID := range counters { + counterName := p4constants.GetCounterIDToNameMap()[counterID] - return nil + counterSize, err := up4.p4RtTranslator.getCounterSizeByID(counterID) + if err != nil { + log.Error(err) + } + + switch counterID { + case p4constants.CounterPreQosPipePreQosCounter: + up4.initCounter(preQosCounterID, counterName, uint64(counterSize)) + case p4constants.CounterPostQosPipePostQosCounter: + up4.initCounter(postQosCounterID, counterName, uint64(counterSize)) + } + } } -func (up4 *UP4) initMetersPools() error { +func (up4 *UP4) initMetersPools() { log.Debug("Initializing P4 Meters pools for UP4") - appMeter, err := up4.p4RtTranslator.getMeterByName(applicationMeter) - if err != nil { - return err + meters := []uint32{ + p4constants.MeterPreQosPipeAppMeter, + p4constants.MeterPreQosPipeSessionMeter, } - log.WithFields(log.Fields{ - "name": applicationMeter, - "meter": appMeter, - }).Trace("Found P4 meter by name") + for _, meterID := range meters { + meterName := p4constants.GetMeterIDToNameMap()[meterID] - up4.appMeterCellIDsPool = set.NewSet() - for i := 1; i < int(appMeter.Size); i++ { - up4.appMeterCellIDsPool.Add(uint32(i)) - } - - log.Trace("Application meter IDs pool initialized: ", up4.appMeterCellIDsPool.String()) + meterSize, err := up4.p4RtTranslator.getMeterSizeByID(meterID) + if err != nil { + log.Errorf("Could not find meter size of %v", meterName) + } - sessMeter, err := up4.p4RtTranslator.getMeterByName(sessionMeter) - if err != nil { - return err - } + switch meterID { + case p4constants.MeterPreQosPipeAppMeter: + up4.appMeterCellIDsPool = set.NewSet() + for i := 1; i < int(meterSize); i++ { + up4.appMeterCellIDsPool.Add(uint32(i)) + } - log.WithFields(log.Fields{ - "name": sessionMeter, - "meter": sessMeter, - }).Trace("Found P4 meter by name") + log.Trace("Application meter IDs pool initialized: ", up4.appMeterCellIDsPool.String()) + case p4constants.MeterPreQosPipeSessionMeter: + up4.sessMeterCellIDsPool = set.NewSet() + for i := 1; i < int(meterSize); i++ { + up4.sessMeterCellIDsPool.Add(uint32(i)) + } - up4.sessMeterCellIDsPool = set.NewSet() - for i := 1; i < int(sessMeter.Size); i++ { - up4.sessMeterCellIDsPool.Add(uint32(i)) + log.Trace("Session meter IDs pool initialized: ", up4.sessMeterCellIDsPool.String()) + } } - log.Trace("Session meter IDs pool initialized: ", up4.sessMeterCellIDsPool.String()) - log.WithFields(log.Fields{ "applicationMeter pool size": up4.appMeterCellIDsPool.Cardinality(), "sessMeter pool size": up4.sessMeterCellIDsPool.Cardinality(), }).Debug("P4 Meters pools initialized successfully") - - return nil } func (up4 *UP4) initTunnelPeerIDs() { @@ -367,31 +362,18 @@ func (up4 *UP4) setUpfInfo(u *upf, conf *Conf) { } } -func (up4 *UP4) clearAllTables() error { - tables := []string{TableUplinkSessions, TableDownlinkSessions, TableUplinkTerminations, TableDownlinkTerminations, TableTunnelPeers, TableApplications} - tableIDs := make([]uint32, 0, len(tables)) - - for _, table := range tables { - tableID, err := up4.p4RtTranslator.getTableIDByName(table) - if err != nil { - return err - } - - tableIDs = append(tableIDs, tableID) - } - - err := up4.p4client.ClearTables(tableIDs) - if err != nil { - return err +func (up4 *UP4) clearTables() error { + tableIDs := []uint32{ + p4constants.TablePreQosPipeSessionsUplink, + p4constants.TablePreQosPipeSessionsDownlink, + p4constants.TablePreQosPipeTerminationsUplink, + p4constants.TablePreQosPipeTerminationsDownlink, + p4constants.TablePreQosPipeTunnelPeers, + p4constants.TablePreQosPipeInterfaces, + p4constants.TablePreQosPipeApplications, } - interfacesTableID, err := up4.p4RtTranslator.getTableIDByName(TableInterfaces) - if err != nil { - return err - } - - err = up4.p4client.ClearTable(interfacesTableID) - if err != nil { + if err := up4.p4client.ClearTables(tableIDs); err != nil { return err } @@ -453,20 +435,13 @@ func (up4 *UP4) tryConnect() error { up4.p4RtTranslator = newP4RtTranslator(up4.p4client.P4Info) - err = up4.clearAllTables() + err = up4.clearTables() if err != nil { log.Warningf("failed to clear tables: %v", err) } - err = up4.initAllCounters() - if err != nil { - return ErrOperationFailedWithReason("counters initialization", err.Error()) - } - - err = up4.initMetersPools() - if err != nil { - return ErrOperationFailedWithReason("meters pools initialization", err.Error()) - } + up4.initAllCounters() + up4.initMetersPools() go up4.listenToDDNs() @@ -870,7 +845,7 @@ func (up4 *UP4) configureApplicationMeter(q qer, bidirectional bool) (meter, err if appMeter.uplinkCellID != 0 { meterConfig := getMeterConfigurationFromQER(q.ulMbr, q.ulGbr) - meterEntry := up4.p4RtTranslator.BuildMeterEntry(applicationMeter, appMeter.uplinkCellID, meterConfig) + meterEntry := up4.p4RtTranslator.BuildMeterEntry(p4constants.MeterPreQosPipeAppMeter, appMeter.uplinkCellID, meterConfig) entries = append(entries, meterEntry) } @@ -878,7 +853,7 @@ func (up4 *UP4) configureApplicationMeter(q qer, bidirectional bool) (meter, err if appMeter.downlinkCellID != appMeter.uplinkCellID { meterConfig := getMeterConfigurationFromQER(q.dlMbr, q.dlGbr) - meterEntry := up4.p4RtTranslator.BuildMeterEntry(applicationMeter, appMeter.downlinkCellID, meterConfig) + meterEntry := up4.p4RtTranslator.BuildMeterEntry(p4constants.MeterPreQosPipeAppMeter, appMeter.downlinkCellID, meterConfig) entries = append(entries, meterEntry) } @@ -919,10 +894,10 @@ func (up4 *UP4) configureSessionMeter(q qer) (meter, error) { logger.Debug("Configuring Session Meter from QER") uplinkMeterConfig := getMeterConfigurationFromQER(q.ulMbr, q.ulGbr) - uplinkMeterEntry := up4.p4RtTranslator.BuildMeterEntry(sessionMeter, uplinkCellID, uplinkMeterConfig) + uplinkMeterEntry := up4.p4RtTranslator.BuildMeterEntry(p4constants.MeterPreQosPipeSessionMeter, uplinkCellID, uplinkMeterConfig) downlinkMeterConfig := getMeterConfigurationFromQER(q.dlMbr, q.dlGbr) - downlinkMeterEntry := up4.p4RtTranslator.BuildMeterEntry(sessionMeter, downlinkCellID, downlinkMeterConfig) + downlinkMeterEntry := up4.p4RtTranslator.BuildMeterEntry(p4constants.MeterPreQosPipeSessionMeter, downlinkCellID, downlinkMeterConfig) logger = logger.WithFields(log.Fields{ "uplink meter entry": uplinkMeterEntry, @@ -1005,8 +980,7 @@ func verifyPDR(pdr pdr) error { return nil } -func (up4 *UP4) resetMeter(name string, meter meter) { - meterID := up4.p4RtTranslator.meterID(name) +func (up4 *UP4) resetMeter(meterID uint32, meter meter) { entries := make([]*p4.MeterEntry, 0, 2) entry := &p4.MeterEntry{ @@ -1026,7 +1000,7 @@ func (up4 *UP4) resetMeter(name string, meter meter) { err := up4.p4client.ApplyMeterEntries(p4.Update_MODIFY, entries...) if err != nil { - log.Errorf("Failed to reset %v meter entries: %v", name, err) + log.Errorf("Failed to reset %v meter entries: %v", p4constants.GetMeterIDToNameMap()[meterID], err) } } @@ -1051,14 +1025,14 @@ func (up4 *UP4) resetMeters(qers []qer) { } if meter.meterType == meterTypeApplication { - up4.resetMeter(applicationMeter, meter) + up4.resetMeter(p4constants.MeterPreQosPipeAppMeter, meter) up4.releaseAppMeterCellID(meter.uplinkCellID) if meter.downlinkCellID != meter.uplinkCellID { up4.releaseAppMeterCellID(meter.downlinkCellID) } } else if meter.meterType == meterTypeSession { - up4.resetMeter(sessionMeter, meter) + up4.resetMeter(p4constants.MeterPreQosPipeSessionMeter, meter) up4.releaseSessionMeterCellID(meter.uplinkCellID) up4.releaseSessionMeterCellID(meter.downlinkCellID) }