network,udev: make .network and .link file can match with hardware address longer or shorter than ETH_ALEN
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
81e1590e2d
commit
5213507113
+10
-11
@@ -17,8 +17,8 @@ void net_match_clear(NetMatch *match) {
|
||||
if (!match)
|
||||
return;
|
||||
|
||||
match->mac = set_free(match->mac);
|
||||
match->permanent_mac = set_free(match->permanent_mac);
|
||||
match->hw_addr = set_free(match->hw_addr);
|
||||
match->permanent_hw_addr = set_free(match->permanent_hw_addr);
|
||||
match->path = strv_free(match->path);
|
||||
match->driver = strv_free(match->driver);
|
||||
match->iftype = strv_free(match->iftype);
|
||||
@@ -33,8 +33,8 @@ bool net_match_is_empty(const NetMatch *match) {
|
||||
assert(match);
|
||||
|
||||
return
|
||||
set_isempty(match->mac) &&
|
||||
set_isempty(match->permanent_mac) &&
|
||||
set_isempty(match->hw_addr) &&
|
||||
set_isempty(match->permanent_hw_addr) &&
|
||||
strv_isempty(match->path) &&
|
||||
strv_isempty(match->driver) &&
|
||||
strv_isempty(match->iftype) &&
|
||||
@@ -122,8 +122,8 @@ static int net_condition_test_property(char * const *match_property, sd_device *
|
||||
int net_match_config(
|
||||
const NetMatch *match,
|
||||
sd_device *device,
|
||||
const struct ether_addr *mac,
|
||||
const struct ether_addr *permanent_mac,
|
||||
const struct hw_addr_data *hw_addr,
|
||||
const struct hw_addr_data *permanent_hw_addr,
|
||||
const char *driver,
|
||||
unsigned short iftype,
|
||||
const char *ifname,
|
||||
@@ -150,13 +150,12 @@ int net_match_config(
|
||||
(void) sd_device_get_sysname(device, &ifname);
|
||||
}
|
||||
|
||||
if (match->mac && (!mac || !set_contains(match->mac, mac)))
|
||||
if (match->hw_addr && (!hw_addr || !set_contains(match->hw_addr, hw_addr)))
|
||||
return false;
|
||||
|
||||
if (match->permanent_mac &&
|
||||
(!permanent_mac ||
|
||||
ether_addr_is_null(permanent_mac) ||
|
||||
!set_contains(match->permanent_mac, permanent_mac)))
|
||||
if (match->permanent_hw_addr &&
|
||||
(!permanent_hw_addr ||
|
||||
!set_contains(match->permanent_hw_addr, permanent_hw_addr)))
|
||||
return false;
|
||||
|
||||
if (!net_condition_test_strv(match->path, path))
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include "set.h"
|
||||
|
||||
typedef struct NetMatch {
|
||||
Set *mac;
|
||||
Set *permanent_mac;
|
||||
Set *hw_addr;
|
||||
Set *permanent_hw_addr;
|
||||
char **path;
|
||||
char **driver;
|
||||
char **iftype;
|
||||
@@ -29,8 +29,8 @@ bool net_match_is_empty(const NetMatch *match);
|
||||
int net_match_config(
|
||||
const NetMatch *match,
|
||||
sd_device *device,
|
||||
const struct ether_addr *mac,
|
||||
const struct ether_addr *permanent_mac,
|
||||
const struct hw_addr_data *hw_addr,
|
||||
const struct hw_addr_data *permanent_hw_addr,
|
||||
const char *driver,
|
||||
unsigned short iftype,
|
||||
const char *ifname,
|
||||
|
||||
Reference in New Issue
Block a user