multipath-tcp / mptcp_net-next

Development version of the Upstream MultiPath TCP Linux kernel 🐧
https://mptcp.dev
Other
281 stars 41 forks source link

selftests: print (and set?) random seed #462

Open matttbe opened 10 months ago

matttbe commented 10 months ago

As reported by Willem on netdev, some inputs are randomised (mptcp_connect.c and mptcp_inq.c).

It was certainly used to increase the coverage but we don't print anything about that and there is no way to force re-using the same seed.

The minimal thing to do is to log the random seed. We cannot simply print it when we initialise it because mptcp_connect is used a lot of time by the .sh scripts: printing such thing info each time will "flood" the logs. Maybe we should only print that at the end, in case of errors: e.g. in xerror() and die_perror() for example, but I see exit(1) is directly used in other places so some refactoring is needed first...

Note that it will be needed to log this to stderr: mptcp_connect prints what has been received from the other peer to stdout.

matttbe commented 10 months ago

Another idea from Willem:

Another option to avoid flooding the logs might be to choose a pseudo random number in the script and pass the explicit value mptcp_connect.

I haven't looked closely, but for transport layer tests it is likely that the payload is entirely ignored. Bar perhaps checksum coverage. If it does not increase code coverage, randomization can also just be turned off.

From the .c file, we can indeed check if an env var is set (e.g. MPTCP_RND_SEED) and use it. If not, we generate a random one. The .sh script should generate a random one (if the env var is not already set) and print it.

matttbe commented 9 months ago

Note from a previous weekly meeting: It might not be even useful to print it:

So this is probably not needed?