Fix AMF/SMF match filters, add TAI filter, cache regex - #173
Conversation
Signed-off-by: Arrobo, Gabriel <gabriel.arrobo@intel.com>
There was a problem hiding this comment.
Pull request overview
Updates NRF cache discovery matching to align more closely with 3GPP TS 29.510 semantics for AMF/SMF filtering, adds AMF TAI-based filtering, and introduces regex compilation caching to reduce repeated SUPI-pattern compilation overhead.
Changes:
- Adjust AMF target PLMN handling so profiles without
plmnListmatch anytarget-plmn-listfilter; addtaifiltering viaamfInfo.taiList. - Fix SMF DNN matching so
dnnis evaluated within the matched S-NSSAI context whensnssaisis provided. - Cache compiled SUPI regex patterns to avoid recompiling on each match; add tests covering the AMF/SMF behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| VERSION | Bumps project version to 2.2.0. |
| nrfcache/nrfcache_test.go | Adds unit tests for AMF PLMN-list absence behavior, AMF TAI filtering, and SMF DNN scoping to matched S-NSSAI. |
| nrfcache/match_filters.go | Implements AMF PLMN-list/TAI filter semantics, scopes SMF DNN matching to matching S-NSSAI entries, and adds regex compile caching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (2)
nrfcache/match_filters.go:170
- The SUPI regex cache size check is not concurrency-safe: multiple goroutines can observe the count below the cap and all store new patterns, so the cache can grow beyond maxRegexpCacheEntries despite the comment saying it is capped. Consider enforcing the cap with an atomic CAS around the counter and deleting the just-stored entry if the cap is reached.
if regexpCacheCount.Load() < maxRegexpCacheEntries {
if _, loaded := regexpCache.LoadOrStore(pattern, r); !loaded {
regexpCacheCount.Add(1)
}
}
nrfcache/match_filters.go:336
- taiInList compares Nid via GetNid(), which collapses an unset Nid to the empty string. That makes the behavior slightly broader than the comment suggests (a present-but-empty Nid would match an absent Nid). If you want the documented behavior ("absent matches only absent"), also compare Nid presence via HasNid().
// taiInList matches PlmnId, Tac, and Nid; an absent Nid (PLMN context) matches only another absent Nid.
func taiInList(tai models.Tai, list []models.Tai) bool {
for _, t := range list {
if t.GetPlmnId() == tai.GetPlmnId() && t.GetTac() == tai.GetTac() && t.GetNid() == tai.GetNid() {
return true
Signed-off-by: Arrobo, Gabriel <gabriel.arrobo@intel.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (1)
nrfcache/match_filters.go:316
- TAI filtering is only applied against amfInfo.taiList. If a profile uses amfInfo.taiRangeList (and taiList is empty), the current logic will treat it as unrestricted and allow it through even when the queried TAI is outside the allowed TAC ranges. This can make cached discovery results diverge from live NRF filtering for AMFs that rely on taiRangeList.
tai := opts.GetTai()
// Absent taiList and taiRangeList means unrestricted (TS 29.510 Table 6.1.6.2.11-1).
// taiRangeList matching is not yet implemented; profiles with only taiRangeList pass through.
if tai != nil && len(amfInfo.GetTaiList()) > 0 && !taiInList(*tai, amfInfo.GetTaiList()) {
logger.NrfcacheLog.Debugf("amf match failed: TAI mismatch for %s", profile.GetNfInstanceId())
return false, nil
No description provided.