Skip to content

Commit

Permalink
feat: allow configuring n2 interface (#383)
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Belanger <[email protected]>
  • Loading branch information
gruyaume authored Jan 21, 2025
1 parent db079bb commit e0d7ce7
Show file tree
Hide file tree
Showing 27 changed files with 323 additions and 365 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
run: |
kubectl create ns dev2
pip install tox
make test
tox -e integration
- name: Show logs
if: always()
Expand Down
20 changes: 10 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
### Set up MicroK8s

```shell
sudo snap install microk8s --channel=1.31/stable --classic
sudo snap install microk8s --channel=1.32/stable --classic
```

Add the community repository MicroK8s addon:
Enable the required addons:
```shell
sudo microk8s addons repo add community https://github.com/canonical/microk8s-community-addons --reference feat/strict-fix-multus
```

Enable the following MicroK8s addons.

```shell
sudo microk8s enable hostpath-storage
sudo microk8s enable multus
```
Expand Down Expand Up @@ -45,13 +40,18 @@ sudo snap install rockcraft --classic
Build the image and push it to the local registry

```shell
make oci-build
rockcraft pack
sudo rockcraft.skopeo --insecure-policy copy oci-archive:$(ROCK_FILE) docker-daemon:$(OCI_IMAGE_NAME)
docker tag ella-core:latest localhost:5000/ella-core:latest
docker push localhost:5000/ella-core:latest
```

Deploy Ella and its dependencies
Run End-to-End tests

```shell
make deploy
kubectl create ns dev2
pip install tox
tox -e integration
```

## How-to Guides
Expand Down
36 changes: 0 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
UI_DIR := ui
GO_CMD := cmd/core/main.go
OUTPUT := core
ROCK_FILE := ella-core_0.0.4_amd64.rock
TAR_FILE := ella.tar
K8S_NAMESPACE := dev2
OCI_IMAGE_NAME := ella-core:latest

.PHONY: all clean build ui-build go-build oci-build deploy nad-create rebuild

all: build

build: ui-build go-build oci-build
@echo "Build completed successfully."

ui-build:
@echo "Installing and building UI..."
Expand All @@ -22,36 +12,10 @@ go-build:
@echo "Building Go application..."
go build -o $(OUTPUT) $(GO_CMD)

oci-build:
@echo "Building OCI image..."
rockcraft pack
@echo "Copying OCI image to Docker daemon with skopeo..."
sudo rockcraft.skopeo --insecure-policy copy oci-archive:$(ROCK_FILE) docker-daemon:$(OCI_IMAGE_NAME)
@echo "Pushing image to local registry..."
docker tag ella-core:latest localhost:5000/ella-core:latest
docker push localhost:5000/ella-core:latest

hotswap: go-build
@echo "Copying the binary to the running container..."
@POD_NAME=$$(kubectl get pods -n $(K8S_NAMESPACE) -l app=ella-core -o jsonpath="{.items[0].metadata.name}"); \
CONTAINER_NAME=$$(kubectl get pod $$POD_NAME -n $(K8S_NAMESPACE) -o jsonpath="{.spec.containers[0].name}"); \
kubectl cp $(OUTPUT) $$POD_NAME:/bin/core -c $$CONTAINER_NAME -n $(K8S_NAMESPACE); \
kubectl exec -i $$POD_NAME -n $(K8S_NAMESPACE) -c $$CONTAINER_NAME -- pebble restart ella-core
@echo "Hotswap completed successfully."

test:
@echo "Running end-to-end tests..."
tox -e integration
@echo "End-to-end tests completed successfully."

hotswap-test: hotswap test

clean:
@echo "Cleaning build artifacts..."
rm -rf $(OUTPUT)
rm -rf $(UI_DIR)/node_modules
rm -rf $(UI_DIR)/dist
rm -f $(ROCK_FILE) $(TAR_FILE)

rebuild: clean build
@echo "Rebuild completed."
2 changes: 1 addition & 1 deletion cmd/core/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func startNetwork(dbInstance *db.Database, cfg config.Config) error {
if err != nil {
return err
}
err = amf.Start(dbInstance)
err = amf.Start(dbInstance, cfg.Interfaces.N2.Address, cfg.Interfaces.N2.Port)
if err != nil {
return err
}
Expand Down
10 changes: 7 additions & 3 deletions core.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
log-level: "debug"
db:
path: "core.db"
interfaces:
n3:
interfaces:
n2:
name: "wlp131s0"
address: "127.0.0.1"
address: "172.16.6.100"
port: 38412
n3:
name: "eno1"
address: "10.42.0.1"
n6:
name: "lo"
api:
Expand Down
4 changes: 2 additions & 2 deletions docs/explanation/subscriber_authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ The subscriber's Universal Subscriber Identity Module (USIM) stores critical inf

Ella Core implements both the 5G-AKA and EAP-AKA mechanisms as part of its subscriber authentication process.

Users can update the Operator Key (OP) via the [Operator API](../api/operator) or the UI.
Users can update the Operator Key (OP) via the [Operator API](../reference/api/operator.md) or the UI.

When creating a new subscriber via the [Subscribers API](../api/subscribers) or the UI, Ella Core automatically computes the OPc using the provided Ki (subscriber key) and the current OP value.
When creating a new subscriber via the [Subscribers API](../reference/api/subscribers.md) or the UI, Ella Core automatically computes the OPc using the provided Ki (subscriber key) and the current OP value.

The UI provides a user-friendly interface for automatically generating IMSI's, Ki's, and SQN's for new subscribers.
10 changes: 9 additions & 1 deletion docs/reference/config_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Start Ella core with the `--config` flag to specify the path to the configuratio
- `db` (object): The database configuration.
- `path` (string): The path to the database file.
- `interfaces` (object): The network interfaces configuration.
- `n2` (object): The configuration for the n2 interface. This interface should be connected to the radios.
- `name` (string): The name of the network interface.
- `address` (string): The IP address of the network interface.
- `port` (int): The port to listen on.
- `n3` (object): The configuration for the n3 interface. This interface should be connected to the radios.
- `name` (string): The name of the network interface.
- `address` (string): The IP address of the network interface.
Expand All @@ -32,7 +36,11 @@ Start Ella core with the `--config` flag to specify the path to the configuratio
log-level: "debug"
db:
path: "core.db"
interfaces:
interfaces:
n2:
name: "enp2s0"
address: "127.0.0.1"
port: 38412
n3:
name: "enp3s0"
address: "127.0.0.1"
Expand Down
10 changes: 3 additions & 7 deletions internal/amf/amf.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ import (
"github.com/omec-project/openapi/models"
)

const (
NGAPP_PORT = 38412
)

func Start(dbInstance *db.Database) error {
func Start(dbInstance *db.Database, n2Address string, n2Port int) error {
self := context.AMF_Self()
self.Name = "AMF"
self.NgapIpList = []string{"0.0.0.0"}
self.NgapPort = NGAPP_PORT
self.NgapIpList = []string{n2Address}
self.NgapPort = n2Port
self.NetworkFeatureSupport5GS = &context.NetworkFeatureSupport5GS{
Emc: 0,
EmcN3: 0,
Expand Down
41 changes: 11 additions & 30 deletions internal/amf/consumer/am_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
package consumer

import (
"fmt"

"github.com/ellanetworks/core/internal/amf/context"
"github.com/ellanetworks/core/internal/logger"
"github.com/ellanetworks/core/internal/pcf"
"github.com/omec-project/openapi/models"
)

func AMPolicyControlCreate(ue *context.AmfUe, anType models.AccessType) (*models.ProblemDetails, error) {
func AMPolicyControlCreate(ue *context.AmfUe, anType models.AccessType) error {
amfSelf := context.AMF_Self()
guamiList := context.GetServedGuamiList()

Expand All @@ -36,17 +37,9 @@ func AMPolicyControlCreate(ue *context.AmfUe, anType models.AccessType) (*models

res, locationHeader, err := pcf.CreateAMPolicy(policyAssociationRequest)
if err != nil {
logger.AmfLog.Warnf("Failed to create policy: %+v", err)
problem := &models.ProblemDetails{
Status: 500,
Cause: "SYSTEM_FAILURE",
Detail: err.Error(),
}
return problem, err
return fmt.Errorf("failed to create policy: %+v", err)
}
ue.AmPolicyUri = locationHeader
// re := regexp.MustCompile("/policies/.*")
// match := re.FindStringSubmatch(locationHeader)
ue.PolicyAssociationId = locationHeader
ue.AmPolicyAssociation = res
if res.Triggers != nil {
Expand All @@ -56,20 +49,13 @@ func AMPolicyControlCreate(ue *context.AmfUe, anType models.AccessType) (*models
}
}
}
return nil, nil
return nil
}

func AMPolicyControlUpdate(ue *context.AmfUe, updateRequest models.PolicyAssociationUpdateRequest) (
*models.ProblemDetails, error,
) {
func AMPolicyControlUpdate(ue *context.AmfUe, updateRequest models.PolicyAssociationUpdateRequest) error {
res, err := pcf.UpdateAMPolicy(ue.PolicyAssociationId, updateRequest)
if err != nil {
problemDetails := &models.ProblemDetails{
Status: 500,
Cause: "SYSTEM_FAILURE",
Detail: err.Error(),
}
return problemDetails, err
return fmt.Errorf("failed to update policy: %+v", err)
}
if res.ServAreaRes != nil {
ue.AmPolicyAssociation.ServAreaRes = res.ServAreaRes
Expand All @@ -84,19 +70,14 @@ func AMPolicyControlUpdate(ue *context.AmfUe, updateRequest models.PolicyAssocia
ue.RequestTriggerLocationChange = true
}
}
return nil, nil
return nil
}

func AMPolicyControlDelete(ue *context.AmfUe) (*models.ProblemDetails, error) {
func AMPolicyControlDelete(ue *context.AmfUe) error {
err := pcf.DeleteAMPolicy(ue.PolicyAssociationId)
if err != nil {
problemDetails := &models.ProblemDetails{
Status: 500,
Cause: "SYSTEM_FAILURE",
Detail: err.Error(),
}
return problemDetails, err
return fmt.Errorf("could not delete policy: %+v", err)
}
ue.RemoveAmPolicyAssociation()
return nil, nil
return nil
}
6 changes: 2 additions & 4 deletions internal/amf/consumer/nsselection.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import (
"github.com/omec-project/openapi/models"
)

func NSSelectionGetForRegistration(ue *context.AmfUe, requestedNssai []models.MappingOfSnssai) (
*models.ProblemDetails, error,
) {
func NSSelectionGetForRegistration(ue *context.AmfUe, requestedNssai []models.MappingOfSnssai) error {
res := &models.AuthorizedNetworkSliceInfo{
AllowedNssaiList: []models.AllowedNssai{
{
Expand All @@ -30,5 +28,5 @@ func NSSelectionGetForRegistration(ue *context.AmfUe, requestedNssai []models.Ma
for _, allowedNssai := range res.AllowedNssaiList {
ue.AllowedNssai[allowedNssai.AccessType] = allowedNssai.AllowedSnssaiList
}
return nil, nil
return nil
}
Loading

0 comments on commit e0d7ce7

Please sign in to comment.