Conversation
|
Hi @adjivas , As with the free5gc/ausf#34, we are going to release the latest version on the 'next' branch. |
4ee9258 to
31b0c06
Compare
|
Please rebase to the latest release, thanks! |
|
Hi @adjivas , The commit history should not be like this. |
|
Hello @andy89923 |
There was a problem hiding this comment.
Pull Request Overview
This PR adds IPv6 support by introducing generic RegisterIP/BindingIP fields alongside the deprecated IPv4-specific ones, updates SB I defaulting and resolution logic, and refactors URI generation and context initialization to use netip and DNS lookups.
- Add
RegisterIP/BindingIPinSbiand migrate deprecated IPv4 fields. - Update
getSbiUri,SearchNFServiceUri, and server binding to usenetip.AddrPort. - Replace string-based IPs in context with
netip.Addr, implementresolveIPandGetIpEndPoint, and extend tests for IPv6.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/factory/config.go | Renamed default IPv4 constants, added RegisterIP/BindingIP, refactored Sbi.validate defaults |
| internal/util/search_nf_service.go | Enhanced IPv6 lookups, updated getSbiUri to parse addresses with netip |
| internal/util/init_context.go | Removed legacy init logic in favor of new context-based initialization |
| internal/sbi/server.go | Updated server binding address construction to use netip.AddrPort |
| internal/sbi/consumer/nrf_service.go | Populating NF profile IPv4/IPv6 addresses based on new RegisterIP |
| internal/context/context_test.go | Added tests covering IPv4, IPv6, deprecated fields, defaults, and ENV resolution |
| internal/context/context.go | Switched to netip.Addr for IPs, implemented resolveIP, GetIpEndPoint, and replaced URI methods |
Comments suppressed due to low confidence (1)
internal/context/context.go:475
- Function GetIpEndPoint handles both IPv4 and IPv6 cases but lacks direct unit tests. Consider adding tests to verify correct endpoint output for each IP family.
func GetIpEndPoint(context *UDMContext) []models.IpEndPoint {
| func getSbiUri(scheme models.UriScheme, ipAddress string, port int32) (uri string) { | ||
| addr, err := netip.ParseAddr(ipAddress) | ||
| if err != nil { | ||
| logger.InitLog.Errorf("Parse RegisterIP hostname %s failed: %+v", ipAddress, err) |
There was a problem hiding this comment.
After logging the parse error, the function continues using a zero-value Addr, which may produce an incorrect URI. Consider returning early or falling back to the raw ipAddress to avoid silently generating invalid addresses.
| logger.InitLog.Errorf("Parse RegisterIP hostname %s failed: %+v", ipAddress, err) | |
| logger.InitLog.Errorf("Parse RegisterIP hostname %s failed: %+v", ipAddress, err) | |
| return "" // Return early if parsing fails |
| } | ||
| resolvedIP := resolvedIPs[0].Unmap() | ||
| if resolvedIP := resolvedIP.String(); resolvedIP != ip { | ||
| logger.UtilLog.Infof("Lookup revolved %s into %s", ip, resolvedIP) |
There was a problem hiding this comment.
Indexing into resolvedIPs without checking its length may panic if the lookup returns no addresses. Add a length check on resolvedIPs before accessing element [0], and handle empty results.
| } | |
| resolvedIP := resolvedIPs[0].Unmap() | |
| if resolvedIP := resolvedIP.String(); resolvedIP != ip { | |
| logger.UtilLog.Infof("Lookup revolved %s into %s", ip, resolvedIP) | |
| return netip.Addr{} // Return zero-value address on error | |
| } | |
| if len(resolvedIPs) == 0 { | |
| logger.InitLog.Errorf("No addresses resolved for %s", ip) | |
| return netip.Addr{} // Return zero-value address if no IPs are resolved | |
| } | |
| resolvedIP := resolvedIPs[0].Unmap() | |
| if resolvedIP := resolvedIP.String(); resolvedIP != ip { | |
| logger.UtilLog.Infof("Lookup resolved %s into %s", ip, resolvedIP) |
| } | ||
| resolvedIP := resolvedIPs[0].Unmap() | ||
| if resolvedIP := resolvedIP.String(); resolvedIP != ip { | ||
| logger.UtilLog.Infof("Lookup revolved %s into %s", ip, resolvedIP) |
There was a problem hiding this comment.
Typo in log message: "Lookup revolved" should be "Lookup resolved" to accurately describe the operation.
| logger.UtilLog.Infof("Lookup revolved %s into %s", ip, resolvedIP) | |
| logger.UtilLog.Infof("Lookup resolved %s into %s", ip, resolvedIP) |
Hello,
This PR adds the RegisterIP/BindingIP new fields for the IPv6 support and some refactors of the Sbi
For not break the previous configurations, the RegisterIPv4/BindingIPv4 are set into RegisterIP/BindingIP
The Sbi is now optional, because we can set it from the default udmSbi configurationA lookup resolution is added to both RegisterIP/BindingIP