core,udev,networkd: add ConditionKernelVersion=
This adds a simple condition/assert/match to the service manager, to udev's .link handling and to networkd, for matching the kernel version string. In this version we only do fnmatch() based globbing, but we might want to extend that to version comparisons later on, if we like, by slightly extending the syntax with ">=", "<=", ">", "<" and "==" expressions.
This commit is contained in:
@@ -33,7 +33,8 @@ struct ConfigPerfItem;
|
||||
%%
|
||||
Match.Host, config_parse_net_condition, CONDITION_HOST, offsetof(NetDev, match_host)
|
||||
Match.Virtualization, config_parse_net_condition, CONDITION_VIRTUALIZATION, offsetof(NetDev, match_virt)
|
||||
Match.KernelCommandLine, config_parse_net_condition, CONDITION_KERNEL_COMMAND_LINE, offsetof(NetDev, match_kernel)
|
||||
Match.KernelCommandLine, config_parse_net_condition, CONDITION_KERNEL_COMMAND_LINE, offsetof(NetDev, match_kernel_cmdline)
|
||||
Match.KernelVersion, config_parse_net_condition, CONDITION_KERNEL_VERSION, offsetof(NetDev, match_kernel_version)
|
||||
Match.Architecture, config_parse_net_condition, CONDITION_ARCHITECTURE, offsetof(NetDev, match_arch)
|
||||
NetDev.Description, config_parse_string, 0, offsetof(NetDev, description)
|
||||
NetDev.Name, config_parse_ifname, 0, offsetof(NetDev, ifname)
|
||||
|
||||
@@ -149,7 +149,8 @@ static void netdev_free(NetDev *netdev) {
|
||||
|
||||
condition_free_list(netdev->match_host);
|
||||
condition_free_list(netdev->match_virt);
|
||||
condition_free_list(netdev->match_kernel);
|
||||
condition_free_list(netdev->match_kernel_cmdline);
|
||||
condition_free_list(netdev->match_kernel_version);
|
||||
condition_free_list(netdev->match_arch);
|
||||
|
||||
if (NETDEV_VTABLE(netdev) &&
|
||||
@@ -642,7 +643,8 @@ static int netdev_load_one(Manager *manager, const char *filename) {
|
||||
/* skip out early if configuration does not match the environment */
|
||||
if (net_match_config(NULL, NULL, NULL, NULL, NULL,
|
||||
netdev_raw->match_host, netdev_raw->match_virt,
|
||||
netdev_raw->match_kernel, netdev_raw->match_arch,
|
||||
netdev_raw->match_kernel_cmdline, netdev_raw->match_kernel_version,
|
||||
netdev_raw->match_arch,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL) <= 0)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -93,7 +93,8 @@ typedef struct NetDev {
|
||||
|
||||
Condition *match_host;
|
||||
Condition *match_virt;
|
||||
Condition *match_kernel;
|
||||
Condition *match_kernel_cmdline;
|
||||
Condition *match_kernel_version;
|
||||
Condition *match_arch;
|
||||
|
||||
NetDevState state;
|
||||
|
||||
Reference in New Issue
Block a user