Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Commit 851bf93

Browse files
authored
Improve set/get forwarding pipeline config errors (#257)
* Improve set/get forwarding pipeline config errors * Fix error * Update pfcp-agent docker image
1 parent cc73200 commit 851bf93

File tree

3 files changed

+38
-34
lines changed

3 files changed

+38
-34
lines changed

.env.stable

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33
#
44

5-
PFCP_AGENT_IMAGE=omecproject/upf-epc-pfcpiface:master-f3a2c33
5+
PFCP_AGENT_IMAGE=omecproject/upf-epc-pfcpiface:master-dac1f1d
66
ONOS_IMAGE=opennetworking/sdfabric-onos:master-2022-03-05
77
PFCPSIM_IMAGE=opennetworking/pfcpsim:1da9a55c
88
ATOMIX_IMAGE=atomix/atomix:3.1.12

app/app/src/main/java/org/omecproject/up4/impl/Up4NorthComponent.java

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,9 @@ private void handleErrorResponse(io.grpc.Status status) {
672672
}
673673

674674
/**
675-
* Receives a pipeline config from a client. Discards all but the p4info file and cookie,
676-
* and compares the received p4info to the already present hardcoded p4info. If the two
677-
* match, the cookie is stored and a success response is sent. If they do not, the cookie is
678-
* disarded and an error is reported.
675+
* Receives a pipeline config from a client. We don't support this feature
676+
* in UP4. UP4 has a pre-configured pipeline config, that is populated
677+
* at runtime with sizes coming from the data plane.
679678
*
680679
* @param request A request containing a p4info and cookie
681680
* @param responseObserver The thing that is fed a response to the config request.
@@ -684,19 +683,12 @@ private void handleErrorResponse(io.grpc.Status status) {
684683
public void setForwardingPipelineConfig(P4RuntimeOuterClass.SetForwardingPipelineConfigRequest request,
685684
StreamObserver<P4RuntimeOuterClass.SetForwardingPipelineConfigResponse>
686685
responseObserver) {
687-
// Currently ignoring device_id, role_id, election_id, action
688-
log.info("Received setForwardingPipelineConfig message.");
689-
P4InfoOuterClass.P4Info otherP4Info = request.getConfig().getP4Info();
690-
if (!otherP4Info.equals(p4Info)) {
691-
log.warn("Someone attempted to write a p4info file that doesn't match our hardcoded one! What a jerk");
692-
} else {
693-
log.info("Received p4info correctly matches hardcoded p4info. Saving cookie.");
694-
pipeconfCookie = request.getConfig().getCookie().getCookie();
695-
}
696-
697-
// Response is currently defined to be empty per p4runtime.proto
698-
responseObserver.onNext(P4RuntimeOuterClass.SetForwardingPipelineConfigResponse.getDefaultInstance());
699-
responseObserver.onCompleted();
686+
log.info("Attempted setForwardingPipelineConfig, not supported in UP4");
687+
responseObserver.onError(
688+
io.grpc.Status.UNIMPLEMENTED
689+
.withDescription("setForwardingPipelineConfig not supported in UP4")
690+
.asException()
691+
);
700692
}
701693

702694
/**
@@ -709,31 +701,45 @@ public void setForwardingPipelineConfig(P4RuntimeOuterClass.SetForwardingPipelin
709701
public void getForwardingPipelineConfig(P4RuntimeOuterClass.GetForwardingPipelineConfigRequest request,
710702
StreamObserver<P4RuntimeOuterClass.GetForwardingPipelineConfigResponse>
711703
responseObserver) {
712-
713-
responseObserver.onNext(
714-
P4RuntimeOuterClass.GetForwardingPipelineConfigResponse.newBuilder()
715-
.setConfig(
716-
P4RuntimeOuterClass.ForwardingPipelineConfig.newBuilder()
717-
.setCookie(P4RuntimeOuterClass.ForwardingPipelineConfig.Cookie.newBuilder()
718-
.setCookie(pipeconfCookie))
719-
.setP4Info(setPhysicalSizes(p4Info))
720-
.build())
721-
.build());
722-
responseObserver.onCompleted();
704+
try {
705+
errorIfSwitchNotReady();
706+
responseObserver.onNext(
707+
P4RuntimeOuterClass.GetForwardingPipelineConfigResponse.newBuilder().setConfig(
708+
P4RuntimeOuterClass.ForwardingPipelineConfig.newBuilder()
709+
.setCookie(P4RuntimeOuterClass.ForwardingPipelineConfig.Cookie.newBuilder()
710+
.setCookie(pipeconfCookie))
711+
.setP4Info(setPhysicalSizes(p4Info))
712+
.build())
713+
.build());
714+
responseObserver.onCompleted();
715+
} catch (StatusException e) {
716+
// FIXME: make it p4rt-compliant
717+
// From P4RT specs: "If a P4Runtime server is in a state where
718+
// the forwarding-pipeline config is not known, the top-level config
719+
// field will be unset in the response. Examples are (i) a server
720+
// that only allows configuration via SetForwardingPipelineConfig
721+
// but this RPC hasn't been invoked yet, (ii) a server that is
722+
// configured using a different mechanism but this configuration
723+
// hasn't yet occurred." - (ii) is the UP4 case -.
724+
// So, we shouldn't return an error, but simply set an empty config.
725+
// However, we do return an error in this way it's easier for
726+
// pfcp-agent to manage this case.
727+
responseObserver.onError(e);
728+
}
723729
}
724730

725731

726732
private void errorIfSwitchNotReady() throws StatusException {
727733
if (!up4Service.configIsLoaded()) {
728734
log.warn("UP4 client attempted to read or write to logical switch before an app config was loaded.");
729-
throw io.grpc.Status.UNAVAILABLE
735+
throw io.grpc.Status.FAILED_PRECONDITION
730736
.withDescription("App config not loaded.")
731737
.asException();
732738
}
733739
if (!up4Service.isReady()) {
734740
log.warn("UP4 client attempted to read or write to logical switch " +
735741
"while the physical device was unavailable.");
736-
throw io.grpc.Status.UNAVAILABLE
742+
throw io.grpc.Status.FAILED_PRECONDITION
737743
.withDescription("Physical switch unavailable.")
738744
.asException();
739745
}

app/app/src/test/java/org/omecproject/up4/impl/Up4NorthComponentTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ public void packetOutUpfProgNotSetTest() {
578578
public void setPipelineConfigTest() {
579579
MockStreamObserver<P4RuntimeOuterClass.SetForwardingPipelineConfigResponse> responseObserver
580580
= new MockStreamObserver<>();
581+
responseObserver.setErrorExpected(io.grpc.Status.UNIMPLEMENTED.asException());
581582
var setPipeRequest = P4RuntimeOuterClass.SetForwardingPipelineConfigRequest.newBuilder()
582583
.setDeviceId(NorthTestConstants.P4RUNTIME_DEVICE_ID)
583584
.setConfig(P4RuntimeOuterClass.ForwardingPipelineConfig.newBuilder()
@@ -587,9 +588,6 @@ public void setPipelineConfigTest() {
587588
.build())
588589
.build();
589590
up4NorthService.setForwardingPipelineConfig(setPipeRequest, responseObserver);
590-
var response = responseObserver.lastResponse();
591-
assertThat(response,
592-
equalTo(P4RuntimeOuterClass.SetForwardingPipelineConfigResponse.getDefaultInstance()));
593591
}
594592

595593
@Test

0 commit comments

Comments
 (0)