mirror of
https://github.com/systemd/systemd.git
synced 2024-11-05 15:21:37 +03:00
parent
ce96c9cb1a
commit
5029912157
@ -4771,7 +4771,7 @@ void unit_dump_config_items(FILE *f) {
|
||||
{ config_parse_unsigned, "UNSIGNED" },
|
||||
{ config_parse_iec_size, "SIZE" },
|
||||
{ config_parse_iec_uint64, "SIZE" },
|
||||
{ config_parse_si_size, "SIZE" },
|
||||
{ config_parse_si_uint64, "SIZE" },
|
||||
{ config_parse_bool, "BOOLEAN" },
|
||||
{ config_parse_string, "STRING" },
|
||||
{ config_parse_path, "PATH" },
|
||||
|
@ -170,7 +170,7 @@ typedef struct LinkInfo {
|
||||
|
||||
/* ethtool info */
|
||||
int autonegotiation;
|
||||
size_t speed;
|
||||
uint64_t speed;
|
||||
Duplex duplex;
|
||||
NetDevPort port;
|
||||
|
||||
@ -1495,7 +1495,7 @@ static int link_status_one(
|
||||
r = table_add_many(table,
|
||||
TABLE_EMPTY,
|
||||
TABLE_STRING, "Speed:",
|
||||
TABLE_BPS, (uint64_t) info->speed);
|
||||
TABLE_BPS, info->speed);
|
||||
if (r < 0)
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ static int link_set_can(Link *link) {
|
||||
};
|
||||
|
||||
if (link->network->can_bitrate > UINT32_MAX) {
|
||||
log_link_error(link, "bitrate (%zu) too big.", link->network->can_bitrate);
|
||||
log_link_error(link, "bitrate (%" PRIu64 ") too big.", link->network->can_bitrate);
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ IPv6Prefix.ValidLifetimeSec, config_parse_prefix_lifetime,
|
||||
IPv6Prefix.PreferredLifetimeSec, config_parse_prefix_lifetime, 0, 0
|
||||
IPv6RoutePrefix.Route, config_parse_route_prefix, 0, 0
|
||||
IPv6RoutePrefix.LifetimeSec, config_parse_route_prefix_lifetime, 0, 0
|
||||
CAN.BitRate, config_parse_si_size, 0, offsetof(Network, can_bitrate)
|
||||
CAN.BitRate, config_parse_si_uint64, 0, offsetof(Network, can_bitrate)
|
||||
CAN.SamplePoint, config_parse_permille, 0, offsetof(Network, can_sample_point)
|
||||
CAN.RestartSec, config_parse_sec, 0, offsetof(Network, can_restart_us)
|
||||
CAN.TripleSampling, config_parse_tristate, 0, offsetof(Network, can_triple_sampling)
|
||||
|
@ -194,7 +194,7 @@ struct Network {
|
||||
uint32_t br_untagged_bitmap[BRIDGE_VLAN_BITMAP_LEN];
|
||||
|
||||
/* CAN support */
|
||||
size_t can_bitrate;
|
||||
uint64_t can_bitrate;
|
||||
unsigned can_sample_point;
|
||||
usec_t can_restart_us;
|
||||
int can_triple_sampling;
|
||||
|
@ -555,7 +555,7 @@ int config_parse_iec_size(const char* unit,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_si_size(
|
||||
int config_parse_si_uint64(
|
||||
const char* unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
@ -567,8 +567,7 @@ int config_parse_si_size(
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
size_t *sz = data;
|
||||
uint64_t v;
|
||||
uint64_t *sz = data;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
@ -576,15 +575,12 @@ int config_parse_si_size(
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
r = parse_size(rvalue, 1000, &v);
|
||||
if (r >= 0 && (uint64_t) (size_t) v != v)
|
||||
r = -ERANGE;
|
||||
r = parse_size(rvalue, 1000, sz);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse size value '%s', ignoring: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*sz = (size_t) v;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_uint32);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_uint64);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_double);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_iec_size);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_si_size);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_si_uint64);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_iec_uint64);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_bool);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_tristate);
|
||||
|
@ -177,7 +177,7 @@ int ethtool_get_driver(int *ethtool_fd, const char *ifname, char **ret) {
|
||||
}
|
||||
|
||||
int ethtool_get_link_info(int *ethtool_fd, const char *ifname,
|
||||
int *ret_autonegotiation, size_t *ret_speed,
|
||||
int *ret_autonegotiation, uint64_t *ret_speed,
|
||||
Duplex *ret_duplex, NetDevPort *ret_port) {
|
||||
struct ethtool_cmd ecmd = {
|
||||
.cmd = ETHTOOL_GSET,
|
||||
@ -734,7 +734,7 @@ int ethtool_set_glinksettings(
|
||||
const char *ifname,
|
||||
int autonegotiation,
|
||||
uint32_t advertise[static N_ADVERTISE],
|
||||
size_t speed,
|
||||
uint64_t speed,
|
||||
Duplex duplex,
|
||||
NetDevPort port) {
|
||||
_cleanup_free_ struct ethtool_link_usettings *u = NULL;
|
||||
|
@ -90,7 +90,7 @@ typedef struct netdev_ring_param {
|
||||
|
||||
int ethtool_get_driver(int *ethtool_fd, const char *ifname, char **ret);
|
||||
int ethtool_get_link_info(int *ethtool_fd, const char *ifname,
|
||||
int *ret_autonegotiation, size_t *ret_speed,
|
||||
int *ret_autonegotiation, uint64_t *ret_speed,
|
||||
Duplex *ret_duplex, NetDevPort *ret_port);
|
||||
int ethtool_get_permanent_macaddr(int *ethtool_fd, const char *ifname, struct ether_addr *ret);
|
||||
int ethtool_set_speed(int *ethtool_fd, const char *ifname, unsigned speed, Duplex duplex);
|
||||
@ -99,7 +99,7 @@ int ethtool_set_nic_buffer_size(int *ethtool_fd, const char *ifname, netdev_ring
|
||||
int ethtool_set_features(int *ethtool_fd, const char *ifname, int *features);
|
||||
int ethtool_set_glinksettings(int *ethtool_fd, const char *ifname,
|
||||
int autonegotiation, uint32_t advertise[static N_ADVERTISE],
|
||||
size_t speed, Duplex duplex, NetDevPort port);
|
||||
uint64_t speed, Duplex duplex, NetDevPort port);
|
||||
int ethtool_set_channels(int *ethtool_fd, const char *ifname, netdev_channels *channels);
|
||||
|
||||
const char *duplex_to_string(Duplex d) _const_;
|
||||
|
@ -38,11 +38,11 @@ static void test_config_parse_iec_size_one(const char *rvalue, size_t expected)
|
||||
assert_se(expected == iec_size);
|
||||
}
|
||||
|
||||
static void test_config_parse_si_size_one(const char *rvalue, size_t expected) {
|
||||
size_t si_size = 0;
|
||||
static void test_config_parse_si_uint64_one(const char *rvalue, uint64_t expected) {
|
||||
uint64_t si_uint64 = 0;
|
||||
|
||||
assert_se(config_parse_si_size("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &si_size, NULL) >= 0);
|
||||
assert_se(expected == si_size);
|
||||
assert_se(config_parse_si_uint64("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &si_uint64, NULL) >= 0);
|
||||
assert_se(expected == si_uint64);
|
||||
}
|
||||
|
||||
static void test_config_parse_int_one(const char *rvalue, int expected) {
|
||||
@ -125,17 +125,17 @@ static void test_config_parse_iec_size(void) {
|
||||
test_config_parse_iec_size_one("garbage", 0);
|
||||
}
|
||||
|
||||
static void test_config_parse_si_size(void) {
|
||||
test_config_parse_si_size_one("1024", 1024);
|
||||
test_config_parse_si_size_one("2K", 2000);
|
||||
test_config_parse_si_size_one("10M", 10 * 1000 * 1000);
|
||||
test_config_parse_si_size_one("1G", 1 * 1000 * 1000 * 1000);
|
||||
test_config_parse_si_size_one("0G", 0);
|
||||
test_config_parse_si_size_one("0", 0);
|
||||
static void test_config_parse_si_uint64(void) {
|
||||
test_config_parse_si_uint64_one("1024", 1024);
|
||||
test_config_parse_si_uint64_one("2K", 2000);
|
||||
test_config_parse_si_uint64_one("10M", 10 * 1000 * 1000);
|
||||
test_config_parse_si_uint64_one("1G", 1 * 1000 * 1000 * 1000);
|
||||
test_config_parse_si_uint64_one("0G", 0);
|
||||
test_config_parse_si_uint64_one("0", 0);
|
||||
|
||||
test_config_parse_si_size_one("-982", 0);
|
||||
test_config_parse_si_size_one("49874444198739873000000G", 0);
|
||||
test_config_parse_si_size_one("garbage", 0);
|
||||
test_config_parse_si_uint64_one("-982", 0);
|
||||
test_config_parse_si_uint64_one("49874444198739873000000G", 0);
|
||||
test_config_parse_si_uint64_one("garbage", 0);
|
||||
}
|
||||
|
||||
static void test_config_parse_int(void) {
|
||||
@ -391,7 +391,7 @@ int main(int argc, char **argv) {
|
||||
test_config_parse_log_level();
|
||||
test_config_parse_log_facility();
|
||||
test_config_parse_iec_size();
|
||||
test_config_parse_si_size();
|
||||
test_config_parse_si_uint64();
|
||||
test_config_parse_int();
|
||||
test_config_parse_unsigned();
|
||||
test_config_parse_strv();
|
||||
|
@ -40,7 +40,7 @@ Link.AlternativeName, config_parse_ifnames, 1,
|
||||
Link.AlternativeNamesPolicy, config_parse_alternative_names_policy, 0, offsetof(link_config, alternative_names_policy)
|
||||
Link.Alias, config_parse_ifalias, 0, offsetof(link_config, alias)
|
||||
Link.MTUBytes, config_parse_mtu, AF_UNSPEC, offsetof(link_config, mtu)
|
||||
Link.BitsPerSecond, config_parse_si_size, 0, offsetof(link_config, speed)
|
||||
Link.BitsPerSecond, config_parse_si_uint64, 0, offsetof(link_config, speed)
|
||||
Link.Duplex, config_parse_duplex, 0, offsetof(link_config, duplex)
|
||||
Link.AutoNegotiation, config_parse_tristate, 0, offsetof(link_config, autonegotiation)
|
||||
Link.WakeOnLan, config_parse_wol, 0, offsetof(link_config, wol)
|
||||
|
@ -160,9 +160,6 @@ int link_load_one(link_config_ctx *ctx, const char *filename) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (link->speed > UINT_MAX)
|
||||
return -ERANGE;
|
||||
|
||||
if (set_isempty(link->match_mac) && set_isempty(link->match_permanent_mac) &&
|
||||
strv_isempty(link->match_path) && strv_isempty(link->match_driver) && strv_isempty(link->match_type) &&
|
||||
strv_isempty(link->match_name) && strv_isempty(link->match_property) && !link->conditions)
|
||||
|
@ -53,7 +53,7 @@ struct link_config {
|
||||
char **alternative_names;
|
||||
char *alias;
|
||||
uint32_t mtu;
|
||||
size_t speed;
|
||||
uint64_t speed;
|
||||
Duplex duplex;
|
||||
int autonegotiation;
|
||||
uint32_t advertise[N_ADVERTISE];
|
||||
|
Loading…
Reference in New Issue
Block a user