-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Network stack runtime configuration #97266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the info, I will look into converting the code.
|
fc41654
to
f5dd020
Compare
Add a way to convert a user supplied yaml file to a configuration file. For networking, a C header file is generated which can then be included to the application. Add a cmake function that calls the generate config macros with suitable values for networking needs. Signed-off-by: Jukka Rissanen <[email protected]>
This contains rules to validate network configuration in yaml format. Signed-off-by: Jukka Rissanen <[email protected]>
f5dd020
to
9d1bacb
Compare
@pdgendt compliance checker complains about python code
The code looks like this
The code looks correct or am I missing something here? |
There's a distinction between python built-in libraries vs third-party libraries. You can run the following to fix it: $ ruff check --fix --select I scripts/net/net-yaml-config.py |
Add a python script that converts a user supplied network configuration yaml file to a valid network configuration C header file. Signed-off-by: Jukka Rissanen <[email protected]>
If CONFIG_NET_CONFIG_SETTINGS is enabled, then the network configuration library will check if a yaml file net-init-config.yaml is found in the application directory and use it to generate network initial configuration that is then applied when the device boots. If the yaml file is not there, then the relevant Kconfig options are used to create initial network configuration. Signed-off-by: Jukka Rissanen <[email protected]>
User can set NET_INIT_CONFIG_FILE to override the name of the default configuration file name which is net-init-config.yaml This way a substitute yaml config file can be used instead of the default one. Signed-off-by: Jukka Rissanen <[email protected]>
Example networking yaml configuration file. This contains more complex network setup that can be used to see what can be done. Signed-off-by: Jukka Rissanen <[email protected]>
Add documentation about the network stack initialization using a yaml file. Signed-off-by: Jukka Rissanen <[email protected]>
If user is not interested in the mask length, the value can be set to NULL so that it is not been returned to the caller. Signed-off-by: Jukka Rissanen <[email protected]>
If user has supplied a yaml file, it is used as configuration data that is applied to network configuration. In this case the CONFIG_NET_CONFIG_* Kconfig variables used for configuration are ignored. Signed-off-by: Jukka Rissanen <[email protected]>
Add simple unit tests that verify that options specified in yaml file can be used to configure network stack. Signed-off-by: Jukka Rissanen <[email protected]>
The hash value is used to detect if the yaml format file has changed so that we know that the data format is changed and the previous configuration in settings should be abandoned. Signed-off-by: Jukka Rissanen <[email protected]>
Add __xxx_changed boolean flag to the strcut definition so that we know if the value was changed by the user. Signed-off-by: Jukka Rissanen <[email protected]>
3289b2a
to
5462c42
Compare
|
Add set and get functions that return/set either the default settings or if user has changed them, the user adjusted value. Make these two functions to use settings API. Signed-off-by: Jukka Rissanen <[email protected]>
The hash is used to detect whether the yaml schema file is changed. If the data format in the settings is different that what is found in the ROM, then the settings db must be discarded because the data is now incompatible. Signed-off-by: Jukka Rissanen <[email protected]>
Add "net config" command to view the current configuration and modify or remove the configuration data. Signed-off-by: Jukka Rissanen <[email protected]>
Convert network configuration schema in pykwalify format to jsonschema format because pykwalify is being deprecated in zephyr and jsonschema is used in the future. Signed-off-by: Jukka Rissanen <[email protected]>
As pykwalify is no longer used in zephyr, the yaml schema format is changed to jsonschema format. This requires changes to python script that generates C struct configuration definitions. Signed-off-by: Jukka Rissanen <[email protected]>
Change "if ()" to "if()" so that CI compliance checker passes. Signed-off-by: Jukka Rissanen <[email protected]>
Define max length of the IPv6 address as a string without IPv4 mapping. Useful if you have to print IPv6 address string that will never contain IPv4 mapping address. Signed-off-by: Jukka Rissanen <[email protected]>
5462c42
to
64825cb
Compare
Note that this PR is continuing the work started on #68127. Most of the commits come directly from that PR, couple of latest ones are new as they add settings db support.
Executive summary of how the PR works:
More detailed description follows:
This PR adds support to autoconfigure the network sub-system when the device boots. It is mainly meant to be used when there are multiple network interfaces in the system. In that case Kconfig based network configure parameters cannot be used easily as the system will only apply the configuration to one of the network interfaces.
This is related to old enhancement #29750 request. There it was pondered to use devicetree to configuring network stack. As DT is only meant to describe hardware configuration some other way of configuration is needed.
This PR uses yaml file to describe network stack configuration. The configuration data in yaml file is not restricted to network configuration but any subsystem configuration could be done via it. I concentrated to network configuration as we need this multi network interface autoconfiguration in networking.
The PR provides minimal infrastructure to validate a user supplied yaml file and then generate a C configuration data file from it. So we do not import the yaml file directly to the zephyr image, but we use a generator script to generate C header file that is then included by the network config library. When the device boots, the network configuration library (
subsys/net/lib/config/init.c
) reads the configuration stored in flash, and applies the configuration to relevant network interface. When the user creates the yaml file in host system, they should know the network configuration in order to map the yaml file data to the device network configuration. The configuration data from flash is used as a default read-only configuration.The user supplied yaml file can be stored outside of zephyr. When building the network application, the location of the yaml file is given so the build system can then utilize it.
At runtime, user is able to adjust the configuration values stored in flash. The changes will be stored in settings database, the backend can be selected by the user. The changes to the network configuration can be done via
net_config_get/set()
API or via anet config
shell which provides commands (view/set/remove) to adjust the values in the network configuration. When the device boots, the default network configuration in flash is used as a base and any user changed network configuration values from settings db are applied on top of the default network configuration.