p4lang / behavioral-model

The reference P4 software switch
Apache License 2.0
532 stars 327 forks source link

--use-files should create files for outputs even if the interface is not provided #1205

Open fruffy opened 11 months ago

fruffy commented 11 months ago

Currently, --use-files seems to generate a .pcap file per interface provided via -i. The problem with this approach is that packets that are emitted on ports which are not provided via -i are not written to a file. This makes testing harder since you can not make sure that a particular packet is dropped unless you pass all 511 ports as arguments.

Is there a way to easily fix this and just generate an output file? Since no name is provided we can freely choose a basename.

jafingerhut commented 11 months ago

I can think of a couple of options:

I guess for v1model there is a well-defined maximum port of 511 because of the bit<9> for the egress_spec field size? I ask mainly because I half-recall someone maybe wanting to specify a drop port value larger than that at one point, but maybe that was only a control plane API port number, not a v1model data plane port number.

antoninbas commented 11 months ago

I think it's ok if someone wants to change that behavior: https://github.com/p4lang/behavioral-model/blob/6ee70b5eff7f510b32c074aaa4f00358f594fecb/src/bm_sim/pcap_file.cpp#L381-L392

A command-line option to toggle that behavior (and maybe specify a basename for the files) would be a good idea.

That being said, when it comes to testing simple_switch_grpc, using the gRPC service to read / write packets should pretty much always be a better idea: https://github.com/p4lang/behavioral-model/blob/main/services/p4/bm/dataplane_interface.proto. And you should always be getting the packets, no matter whether the egress port number matches a valid "front panel" port.

fruffy commented 11 months ago

That being said, when it comes to testing simple_switch_grpc, using the gRPC service to read / write packets should pretty much always be a better idea: https://github.com/p4lang/behavioral-model/blob/main/services/p4/bm/dataplane_interface.proto. And you should always be getting the packets, no matter whether the egress port number matches a valid "front panel" port.

This is definitely something I am considering for the PTF tests, but I have not written the PTF extension for it yet sadly.

In this particularly case I am hitting the limitations with the Thrift-based version, so it might make more sense to augment options there. Seems like it should be straightforward, thanks!

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment, or this will be closed in 180 days