chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
network/link: Match - filter on kernel cmdline, host and virt
[elogind.git]
/
src
/
network
/
networkd-network.c
diff --git
a/src/network/networkd-network.c
b/src/network/networkd-network.c
index 94138cd55814cbdc826ae185dcd402d9f26ea5fa..fd1befcebffcce019893b73226d9add99e8ed5de 100644
(file)
--- a/
src/network/networkd-network.c
+++ b/
src/network/networkd-network.c
@@
-53,6
+53,10
@@
static int network_load_one(Manager *manager, const char *filename) {
LIST_HEAD_INIT(network->static_addresses);
LIST_HEAD_INIT(network->static_routes);
LIST_HEAD_INIT(network->static_addresses);
LIST_HEAD_INIT(network->static_routes);
+ network->vlans = hashmap_new(uint64_hash_func, uint64_compare_func);
+ if (!network->vlans)
+ return log_oom();
+
network->addresses_by_section = hashmap_new(uint64_hash_func, uint64_compare_func);
if (!network->addresses_by_section)
return log_oom();
network->addresses_by_section = hashmap_new(uint64_hash_func, uint64_compare_func);
if (!network->addresses_by_section)
return log_oom();
@@
-144,6
+148,8
@@
void network_free(Network *network) {
address_free(network->dns);
address_free(network->dns);
+ hashmap_free(network->vlans);
+
while ((route = network->static_routes))
route_free(route);
while ((route = network->static_routes))
route_free(route);
@@
-169,10
+175,11
@@
int network_get(Manager *manager, struct udev_device *device, Network **ret) {
LIST_FOREACH(networks, network, manager->networks) {
if (net_match_config(network->match_mac, network->match_path,
network->match_driver, network->match_type,
LIST_FOREACH(networks, network, manager->networks) {
if (net_match_config(network->match_mac, network->match_path,
network->match_driver, network->match_type,
- network->match_name,
+ network->match_name, network->match_host,
+ network->match_virt, network->match_kernel,
udev_device_get_sysattr_value(device, "address"),
udev_device_get_property_value(device, "ID_PATH"),
udev_device_get_sysattr_value(device, "address"),
udev_device_get_property_value(device, "ID_PATH"),
- udev_device_get_driver(
device
),
+ udev_device_get_driver(
udev_device_get_parent(device)
),
udev_device_get_devtype(device),
udev_device_get_sysname(device))) {
log_debug("%s: found matching network '%s'",
udev_device_get_devtype(device),
udev_device_get_sysname(device))) {
log_debug("%s: found matching network '%s'",
@@
-217,7
+224,7
@@
int config_parse_bridge(const char *unit,
void *data,
void *userdata) {
Network *network = userdata;
void *data,
void *userdata) {
Network *network = userdata;
- Net
d
ev *netdev;
+ Net
D
ev *netdev;
int r;
assert(filename);
int r;
assert(filename);
@@
-234,7
+241,7
@@
int config_parse_bridge(const char *unit,
if (netdev->kind != NETDEV_KIND_BRIDGE) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
if (netdev->kind != NETDEV_KIND_BRIDGE) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
- "Net
d
ev is not a bridge, ignoring assignment: %s", rvalue);
+ "Net
D
ev is not a bridge, ignoring assignment: %s", rvalue);
return 0;
}
return 0;
}
@@
-254,7
+261,7
@@
int config_parse_bond(const char *unit,
void *data,
void *userdata) {
Network *network = userdata;
void *data,
void *userdata) {
Network *network = userdata;
- Net
d
ev *netdev;
+ Net
D
ev *netdev;
int r;
assert(filename);
int r;
assert(filename);
@@
-271,7
+278,7
@@
int config_parse_bond(const char *unit,
if (netdev->kind != NETDEV_KIND_BOND) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
if (netdev->kind != NETDEV_KIND_BOND) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
- "Net
d
ev is not a bond, ignoring assignment: %s", rvalue);
+ "Net
D
ev is not a bond, ignoring assignment: %s", rvalue);
return 0;
}
return 0;
}
@@
-291,7
+298,7
@@
int config_parse_vlan(const char *unit,
void *data,
void *userdata) {
Network *network = userdata;
void *data,
void *userdata) {
Network *network = userdata;
- Net
d
ev *netdev;
+ Net
D
ev *netdev;
int r;
assert(filename);
int r;
assert(filename);
@@
-308,11
+315,16
@@
int config_parse_vlan(const char *unit,
if (netdev->kind != NETDEV_KIND_VLAN) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
if (netdev->kind != NETDEV_KIND_VLAN) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
- "Net
d
ev is not a VLAN, ignoring assignment: %s", rvalue);
+ "Net
D
ev is not a VLAN, ignoring assignment: %s", rvalue);
return 0;
}
return 0;
}
- network->vlan = netdev;
+ r = hashmap_put(network->vlans, &netdev->vlanid, netdev);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Can not add VLAN to network: %s", rvalue);
+ return 0;
+ }
return 0;
}
return 0;
}