Three changes were made to common files in order to support the TDI targets.
-
When built for the DPDK target,
ConfigMonitoringService::DoSet()no longer pushes the updated chassis configuration to the switch. -
When built for the DPDK target,
P4Service::SetForwardingPipelineConfig()returns an error if an attempt is made to overwrite an existing pipeline. -
ConfigMonitoringService::PushSavedChassisConfig()returns an error if the configuration file path is a symlink. This change was made to mitigate a security weakness.
Changes 1 and 2 are controlled by #ifdef DPDK_TARGET. Change 3 is
not conditionalized. It is currently disabled via #if 0 because it breaks
unit test cases that use symlinks to manage the test environment.
-
The Stratum code has very few compile-time conditionals, none of which are in common code. The DPDK_TARGET conditionals go against this convention.
-
Compile-time conditionals complicate the Bazel build and lead to recompilation when we change targets. This is undesirable, especially in common source files.
-
Change 3 is sensitive to which target is being built and whether the code is being compiled for unit test purposes. We do not want to introduce more compile-time conditionals, and we do not want to have to recompile a file for unit testing.
-
Introduce a parameter object (
TargetOptions) that can be passed to theConfigMonitoringServiceandP4Serviceclasses to influence their behavior. -
Define Boolean members to enable/disable each of the TDI changes.
-
Instantiate the object in the target's main class, initialize its member values according to the needs of the target, and pass the object to the service classes when instantiating them.
-
Have each option default to a value that maintains backward compatibility with previous versions of Stratum.
-
Make the TargetOptions parameter optional, with the default options being used if the parameter is not specified. This removes the need to update legacy code.
Changes:
-
Create
target_options.ccandtarget_options.h. -
Implement
target_optionsparameter andtarget_options_member variable in theDpdkHal,Es2kHal,ConfigMonitoringService, andP4Serviceclasses. -
Modify
DpdkMainandEs2kMainto create and initialize aTargetOptionsobject and specify it when instantiating theDpdkHalandEs2kHalobjects. -
Modify
DpdkHalandEs2kHalto specify thetarget_optionsparameter when creating theConfigMonitoringServiceandP4Serviceobjects. -
Modify
ConfigMonitoringServiceandP4Serviceto use the appropriate member of theTargetOptionsclass, instead of a compile-time conditional, to enable the new behavior in those classes. -
Remove logic to define the
DPDK_TARGETfrom the Bazel build files.
Notes:
-
The security mitigation in
ConfigMonitoringServicehas been reenabled. The unit test that caused the mitigation to be disabled now passes. -
There are no remaining occurrences of the
DPDK_TARGETconditional in Stratum. -
The Tofino target (which is in "minimal maintenance" state) is unmodified. It compiles, and its unit tests pass, providing some assurance that we have maintained backward compatibility with existing code.