opennetworkinglab / ngsdn-tutorial

Hands-on tutorial to learn the building blocks of the Next-Gen SDN architecture
https://www.opennetworking.org/ng-sdn/
Apache License 2.0
321 stars 187 forks source link

[question] Problem with exercise 5 #84

Closed elhpavtat closed 3 years ago

elhpavtat commented 3 years ago

Hi. I am a beginner and have just started to learn P4. I have completed 4 tasks, however, I have a problem with task 5 and I can't figure out what my error is. I have been struggling with this problem for a week now. I have reread the task and its instructions several times and looked at the answers. However, I still get these errors, I understand what it is about, but I don't understand how to solve it. I've compared it with the solution and I seem to do everything exactly the same. Could you tell me in which direction to look for a solution?

Thank you very much.

sdn@tutorial-vm:~/ngsdn-tutorial$ make p4-build
*** Building P4 program...
docker run --rm -v /home/sdn/ngsdn-tutorial:/workdir -w /workdir opennetworking/p4c:stable \
        p4c-bm2-ss --arch v1model -o p4src/build/bmv2.json \
        --p4runtime-files p4src/build/p4info.txt --Wdisable=unsupported \
        p4src/main.p4
p4src/main.p4(482): [--Wwarn=unused] warning: Table my_station_table is not used; removing
    table my_station_table {
          ^^^^^^^^^^^^^^^^
p4src/main.p4(501): [--Wwarn=unused] warning: Table routing_v6_table is not used; removing
    table routing_v6_table {
          ^^^^^^^^^^^^^^^^
p4src/main.p4(493): [--Wwarn=unused] warning: ecmp_selector: unused instance
    action_selector(HashAlgorithm.crc16, 32w1024, 32w16) ecmp_selector;
                                                         ^^^^^^^^^^^^^
p4src/main.p4(493): warning: Action selector 'IngressPipeImpl.ecmp_selector' is never referenced by a table and cannot be included in bmv2 JSON
    action_selector(HashAlgorithm.crc16, 32w1024, 32w16) ecmp_selector;
                                                         ^^^^^^^^^^^^^
*** P4 program compiled successfully! Output files are in p4src/build
sdn@tutorial-vm:~/ngsdn-tutorial$
ederollora commented 3 years ago

Hi,

It is quite some time ago that I did the exercises, but I will still try to answer your question.

I think you do not necessarily have an error here, but a warning. While means that the p4 program still compiled (P4 program compiled successfully!), but some things do not make sense. For instance, if you declare a table but do not apply it, this is something that would trigger a warning. Let's see:

[--Wwarn=unused] warning: Table my_station_table is not used;

This means that you created a table named my_station_table but never applied it (I think). There should be a my_station_table.apply() somewhere in your Ingress or Egressapply block. It happens the same for the routing_v6_table table.

warning: Action selector 'IngressPipeImpl.ecmp_selector' is never referenced

This warning means that this selector should have been referred by a table. It seems that you have declared the selector but the table that uses it (which seems to be routing_v6_table), needs an implementation line like the following one:

table routing_v6_table {
      key = {
          //some table keys
      }
      actions = {
          //some table actions
      }
      implementation = ecmp_selector; //this one
      //add counters here if you need them
    }

I hope this are the problems you might experience. If you already apply the tables and reference the selector, then…

Cheers,

elhpavtat commented 3 years ago

Yes, I understand that this is not a critical error, but these tables are needed to complete the task, so I think this may be the reason why it doesn't work ping between h2 and h3. Looks like you're right! There really is no .apply() for these tables anywhere for exersice 5.

Thanks for the help, I was confused by the comment that this part of the code refers to exercise 6. By deleting the bolded part, the compile error is gone, but the ping doesn't work. However, that's another story, I'll look into it further. Thanks so much for your help!

if (hdr.ipv6.isValid() && my_station_table.apply().hit) {

                i**f (srv6_my_sid.apply().hit) {
                    // PSP logic -- enabled for all packets
                    if (hdr.srv6h.isValid() && hdr.srv6h.segment_left == 0) {
                        srv6_pop();
                    }
                } else {
                    srv6_transit.apply();
                }**

                routing_v6_table.apply();
                // Check TTL, drop packet if necessary to avoid loops.
                if(hdr.ipv6.hop_limit == 0) { drop(); }
            }
ederollora commented 3 years ago

That's alright! :)

Good luck