Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ignore NRF URI containing a specific IP on registration #26

Merged
merged 4 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions factory/config.example.yaml
gab-arrobo marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## SPDX-FileCopyrightText: 2023 Open Networking Foundation <[email protected]>
##
## SPDX-License-Identifier: Apache-2.0
##
info:
version: 1.0.0
description: UDR initial local configuration

configuration:
sbi: # Service Based Interface
scheme: https
registerIPv4: 127.0.0.4
bindingIPv4: 0.0.0.0
port: 8000
plmnSupportList:
- plmnId:
mcc: "208"
mnc: "93"
snssaiList:
- sst: 1
sd: "010203"

2 changes: 1 addition & 1 deletion factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
package factory

import (
protos "github.com/omec-project/config5g/proto/sdcoreConfig"
"github.com/omec-project/logger_util"
"github.com/omec-project/openapi/models"
"github.com/omec-project/udr/logger"
protos "github.com/omec-project/config5g/proto/sdcoreConfig"
)

const (
Expand Down
8 changes: 3 additions & 5 deletions service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func (udr *UDR) configUpdateDb() {
if err == nil {
initLog.Infof("added entry to sm policy table success")
} else {
initLog.Errorln("entry add failed ", err)
initLog.Errorf("entry add failed %+v", err)
}
}
}
Expand Down Expand Up @@ -386,15 +386,13 @@ func (udr *UDR) registerNF() {
initLog.Infof("Minimum configuration from config pod available %v", msg)
self := udr_context.UDR_Self()
profile := consumer.BuildNFInstance(self)
var newNrfUri string
var err error
var prof models.NfProfile
// send registration with updated PLMN Ids.
prof, newNrfUri, self.NfId, err = consumer.SendRegisterNFInstance(self.NrfUri, profile.NfInstanceId, profile)
prof, _, self.NfId, err = consumer.SendRegisterNFInstance(self.NrfUri, profile.NfInstanceId, profile)
if err == nil {
udr.StartKeepAliveTimer(prof)
logger.CfgLog.Infof("Sent Register NF Instance with updated profile")
self.NrfUri = newNrfUri
logger.CfgLog.Infoln("Sent Register NF Instance with updated profile")
} else {
initLog.Errorf("Send Register NFInstance Error[%s]", err.Error())
}
Expand Down
39 changes: 39 additions & 0 deletions service/init_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Open Networking Foundation <[email protected]>
//

package service

import (
"fmt"
"net/http"
"net/http/httptest"
"testing"
"time"

"github.com/omec-project/udr/context"
"github.com/omec-project/udr/factory"
)

func Test_nrf_url_is_not_overwritten_when_registering(t *testing.T) {
svr := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "banana")
}))
svr.EnableHTTP2 = true
svr.StartTLS()
defer svr.Close()
if err := factory.InitConfigFactory("../factory/config.example.yaml"); err != nil {
t.Fatalf("Could not read example configuration file")
}
self := context.UDR_Self()
self.NrfUri = svr.URL
self.RegisterIPv4 = "127.0.0.2"
var udr *UDR
go udr.registerNF()
factory.ConfigPodTrigger <- true

time.Sleep(1 * time.Second)
if self.NrfUri != svr.URL {
t.Errorf("Expected NRF URL to stay %v, but was %v", svr.URL, self.NrfUri)
}
}