From b0005edfd08e35b28a3f9de2a000cc51349549a9 Mon Sep 17 00:00:00 2001 From: davidcc73 Date: Sun, 10 Mar 2024 18:03:12 +0000 Subject: [PATCH] project no longer uses clone3() clone3() has been depecrated, this commit removes it and replaces it, so now the project can run in newer P4c versions. Now makefile uses new docker syntax --- .gitignore | 12 +++++ Extra instructions.txt | 49 ++++++++++++++++++ Makefile | 12 ++--- .../srv6_usid/Ipv6RoutingComponent.java | 1 - mininet/host6.pyc | Bin 1583 -> 1583 bytes p4src/include/define.p4 | 15 ++++++ p4src/include/header.p4 | 13 ++++- p4src/main.p4 | 49 +++++++++++++----- util/docker/Makefile.vars | 4 +- 9 files changed, 132 insertions(+), 23 deletions(-) create mode 100644 .gitignore create mode 100644 Extra instructions.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e051528 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ + +*.jar +Rubbish/ +*.class +desktop.ini +Code/ngsdn-tutorial/topopoly.png +Documents/* +**/log/ +**/target/ +**/tmp/ + +*.log \ No newline at end of file diff --git a/Extra instructions.txt b/Extra instructions.txt new file mode 100644 index 0000000..e323174 --- /dev/null +++ b/Extra instructions.txt @@ -0,0 +1,49 @@ +make stop +make clean +make deps +make start + +make app-build +make app-reload +make netcfg + +#--------------------at ONOS cli (make onos-cli) +source /config/routing_tables.txt +source /config/ua_config.txT + + + +#--------------------at ONOS cli (make onos-cli) +#---srv6_insert.txt (go and return from h1->h2) +#--use case1: Insert the uSID routing directive to the the two end routers +srv6-insert device:r1 fcbb:bb00:8:7:2:fd00:: 2001:1:2::1 +srv6-insert device:r2 fcbb:bb00:7:8:1:fd00:: 2001:1:1::1 + +#--use case 2 (only go from h1 to h2, on the back path the packet will vary route) +srv6-insert device:r1 fcbb:bb00:9:fa94:a:faa5:b:c fcbb:bb00:e:2:fd00:: 2001:1:2::1 + + + +#--------------------at mininet cli (make mn-cli) +h1 ping h2 +h2 ping h1 + + + + +#--------------------For INT +# Run the following commands in another terminal +sudo python collector_influxdb.py + + +# At a h1 terminal run: +python receive/receive.py + +# At a h2 terminal run: +python send/send.py --ip 2001:db8::2 --l4 udp --port 443 --m INTH1 --c 1 + + +#The generated telemetry should be visible in the grafana dashboard + + + diff --git a/Makefile b/Makefile index e7a80aa..821dc9f 100644 --- a/Makefile +++ b/Makefile @@ -35,22 +35,22 @@ deps: _docker_pull_all start: $(info *** Starting ONOS and Mininet (${NGSDN_TOPO_PY})... ) @mkdir -p tmp/onos - docker-compose up -d + docker compose up -d stop: $(info *** Stopping ONOS and Mininet...) - docker-compose down + docker compose down restart: reset start onos-cli: $(info *** Connecting to the ONOS CLI... password: rocks) - $(info *** Top exit press Ctrl-D) - @ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -o LogLevel=ERROR -p 8101 onos@localhost + $(info *** Top exit press Ctrl-D WARNING: NON SECURE CONNECTION, ADDED -o HostKeyAlgorithms=ssh-rsa TO AVOID ERROR***) + @ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -o HostKeyAlgorithms=ssh-rsa -o LogLevel=ERROR -p 8101 onos@localhost onos-log: - docker-compose logs -f onos + docker compose logs -f onos onos-ui: open ${onos_url}/ui @@ -58,7 +58,7 @@ onos-ui: mn-cli: $(info *** Attaching to Mininet CLI...) $(info *** To detach press Ctrl-D (Mininet will keep running)) - -@docker attach --detach-keys "ctrl-d" $(shell docker-compose ps -q mininet) || echo "*** Detached from Mininet CLI" + -@docker attach --detach-keys "ctrl-d" $(shell docker compose ps -q mininet) || echo "*** Detached from Mininet CLI" mn-log: docker logs -f mininet diff --git a/app/src/main/java/org/onosproject/srv6_usid/Ipv6RoutingComponent.java b/app/src/main/java/org/onosproject/srv6_usid/Ipv6RoutingComponent.java index 485453f..dc2d223 100644 --- a/app/src/main/java/org/onosproject/srv6_usid/Ipv6RoutingComponent.java +++ b/app/src/main/java/org/onosproject/srv6_usid/Ipv6RoutingComponent.java @@ -365,7 +365,6 @@ public void insertRoutingRule(DeviceId routerId, Ip6Address ipv6Addr, // Action param value. nextHopMac.toBytes())) .build(); - flowRuleService.applyFlowRules(Utils .buildFlowRule(routerId, appId, tableId, match, action)); diff --git a/mininet/host6.pyc b/mininet/host6.pyc index 9b08225368b6e392de0f07971ee9d7e4a4eee67c..6f20e41b0fae573e23b2b1e7daefaff12dbebe21 100644 GIT binary patch delta 17 YcmZ3_vz~{8`7 NDP_FLAG_ROUTER = 0x80000000; const bit<32> NDP_FLAG_SOLICITED = 0x40000000; const bit<32> NDP_FLAG_OVERRIDE = 0x20000000; + + +//transition from clone3() +const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_NORMAL = 0; +const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_INGRESS_CLONE = 1; +const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_EGRESS_CLONE = 2; +const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_COALESCED = 3; +const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_RECIRC = 4; +const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_REPLICATION = 5; +const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_RESUBMIT = 6; + + + + + #endif diff --git a/p4src/include/header.p4 b/p4src/include/header.p4 index 7214fc6..c01caa6 100644 --- a/p4src/include/header.p4 +++ b/p4src/include/header.p4 @@ -135,8 +135,16 @@ header ndp_option_t { bit<48> value; } +const bit<8> CLONE_FL_clone3 = 3; +struct preserving_metadata_CPU_t { + @field_list(CLONE_FL_clone3) + bit<9> ingress_port; + @field_list(CLONE_FL_clone3) + bit<9> egress_port; +} + //Custom metadata definition -struct local_metadata_t { +struct local_metadata_t { bool is_multicast; bool skip_l2; bool xconnect; @@ -147,8 +155,11 @@ struct local_metadata_t { l4_port_t l4_src_port; l4_port_t l4_dst_port; bool ipv4_update; + preserving_metadata_CPU_t perserv_CPU_meta; //to migrate from clone3() to clone_preserving() in the clone_to_CPU scenario } + + struct parsed_headers_t { ethernet_t ethernet; ipv6_t ipv6; diff --git a/p4src/main.p4 b/p4src/main.p4 index 62dc01e..999ab58 100644 --- a/p4src/main.p4 +++ b/p4src/main.p4 @@ -17,13 +17,14 @@ #include #include + #include "include/header.p4" #include "include/parser.p4" #include "include/checksum.p4" #define CPU_CLONE_SESSION_ID 99 #define UN_BLOCK_MASK 0xffffffff000000000000000000000000 - + control IngressPipeImpl (inout parsed_headers_t hdr, inout local_metadata_t local_metadata, @@ -86,7 +87,7 @@ control IngressPipeImpl (inout parsed_headers_t hdr, } // TODO: implement ecmp with ipv6.src+ipv6.dst+ipv6.flow_label - action_selector(HashAlgorithm.crc16, 32w64, 32w10) ip6_ecmp_selector; + //action_selector(HashAlgorithm.crc16, 32w64, 32w10) ip6_ecmp_selector; direct_counter(CounterType.packets_and_bytes) routing_v6_counter; table routing_v6 { key = { @@ -100,7 +101,7 @@ control IngressPipeImpl (inout parsed_headers_t hdr, set_next_hop; } counters = routing_v6_counter; - implementation = ip6_ecmp_selector; + //implementation = ip6_ecmp_selector; } // TODO calc checksum @@ -389,7 +390,10 @@ control IngressPipeImpl (inout parsed_headers_t hdr, */ action clone_to_cpu() { - clone3(CloneType.I2E, CPU_CLONE_SESSION_ID, standard_metadata); + //clone3(CloneType.I2E, CPU_CLONE_SESSION_ID, standard_metadata); //DEPRACTED need OG project compiler + local_metadata.perserv_CPU_meta.ingress_port = standard_metadata.ingress_port; + local_metadata.perserv_CPU_meta.egress_port = CPU_PORT; //the packet only gets the egress right before egress, so we use CPU_PORT value + clone_preserving_field_list(CloneType.I2E, CPU_CLONE_SESSION_ID, CLONE_FL_clone3); } direct_counter(CounterType.packets_and_bytes) acl_counter; @@ -464,7 +468,7 @@ control IngressPipeImpl (inout parsed_headers_t hdr, multicast.apply(); } } - + acl.apply(); } @@ -474,14 +478,33 @@ control EgressPipeImpl (inout parsed_headers_t hdr, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { apply { - if (standard_metadata.egress_port == CPU_PORT) { - hdr.packet_in.setValid(); - hdr.packet_in.ingress_port = standard_metadata.ingress_port; - } - - if (local_metadata.is_multicast == true - && standard_metadata.ingress_port == standard_metadata.egress_port) { - mark_to_drop(standard_metadata); + if (standard_metadata.instance_type == BMV2_V1MODEL_INSTANCE_TYPE_INGRESS_CLONE) { + // write code here that works the same was as the original, except it uses + // only metadata field values that you have explicitly preserved. + if (local_metadata.perserv_CPU_meta.egress_port == CPU_PORT) { //packets for the controller, being a cloned packet we look at the struct + hdr.packet_in.setValid(); + hdr.packet_in.ingress_port = local_metadata.perserv_CPU_meta.ingress_port; + } + if (local_metadata.is_multicast == true && local_metadata.perserv_CPU_meta.ingress_port == local_metadata.perserv_CPU_meta.egress_port) { + mark_to_drop(standard_metadata); + } + } else if ((standard_metadata.instance_type == BMV2_V1MODEL_INSTANCE_TYPE_NORMAL) || (standard_metadata.instance_type == BMV2_V1MODEL_INSTANCE_TYPE_REPLICATION)) { + // Put a copy of the original egress code here, which seems to have been + // written assuming that all standard_metadata fields were preserved, which + // should be the case for NORMAL packets. + if (standard_metadata.egress_port == CPU_PORT) { + hdr.packet_in.setValid(); + hdr.packet_in.ingress_port = standard_metadata.ingress_port; + } + if (local_metadata.is_multicast == true && standard_metadata.ingress_port == standard_metadata.egress_port) { + mark_to_drop(standard_metadata); + } + } else { + // Not clear to me whether you need any further branches to handle other + // cases of the value of instance_type, but if. you want to be cautious + // I would put a log_msg() extern call here that prints a special message + // you can easily 'grep' for in the log files to see if this ever happens. + log_msg("Unexpected instance_type in EgressPipeImpl: ", { standard_metadata.instance_type }); } } } diff --git a/util/docker/Makefile.vars b/util/docker/Makefile.vars index dc237d1..6b12118 100644 --- a/util/docker/Makefile.vars +++ b/util/docker/Makefile.vars @@ -1,6 +1,6 @@ ONOS_IMG := onosproject/onos:2.2.2 P4RT_SH_IMG := p4lang/p4runtime-sh:latest -P4C_IMG := opennetworking/p4c:stable +P4C_IMG := p4lang/p4c:1.2.4.5 STRATUM_BMV2_IMG := opennetworking/ngsdn-tutorial:stratum_bmv2 MVN_IMG := opennetworking/ngsdn-tutorial:mvn GNMI_CLI_IMG := bocon/gnmi-cli:latest @@ -9,7 +9,7 @@ SSHPASS_IMG := ictu/sshpass ONOS_SHA := sha256:438815ab20300cd7a31702b7dea635152c4c4b5b2fed9b14970bd2939a139d2a P4RT_SH_SHA := sha256:6ae50afb5bde620acb9473ce6cd7b990ff6cc63fe4113cf5584c8e38fe42176c -P4C_SHA := sha256:8f9d27a6edf446c3801db621359fec5de993ebdebc6844d8b1292e369be5dfea +P4C_SHA := sha256:c57157460bbe8829a9c30246bf4e60e348b0768fd6fab63c0491012b788733d3 STRATUM_BMV2_SHA := sha256:f31faa5e83abbb2d9cf39d28b3578f6e113225641337ec7d16d867b0667524ef MVN_SHA := sha256:d85eb93ac909a90f49b16b33cb872620f9b4f640e7a6451859aec704b21f9243 GNMI_CLI_SHA := sha256:6f1590c35e71c07406539d0e1e288e87e1e520ef58de25293441c3b9c81dffc0