mirror of
https://github.com/systemd/systemd
synced 2026-03-25 16:25:04 +01:00
Compare commits
3 Commits
7c58ee5f8c
...
6f795ad2e2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f795ad2e2 | ||
|
|
c2f2250e5c | ||
|
|
0db68800c7 |
@ -501,16 +501,26 @@ static int set_features_bit(
|
|||||||
return found ? 0 : -ENODATA;
|
return found ? 0 : -ENODATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ethtool_set_features(int *ethtool_fd, const char *ifname, const int *features) {
|
int ethtool_set_features(int *ethtool_fd, const char *ifname, const int features[static _NET_DEV_FEAT_MAX]) {
|
||||||
_cleanup_free_ struct ethtool_gstrings *strings = NULL;
|
_cleanup_free_ struct ethtool_gstrings *strings = NULL;
|
||||||
struct ethtool_sfeatures *sfeatures;
|
struct ethtool_sfeatures *sfeatures;
|
||||||
struct ifreq ifr = {};
|
struct ifreq ifr = {};
|
||||||
int i, r;
|
bool have = false;
|
||||||
|
int r;
|
||||||
|
|
||||||
assert(ethtool_fd);
|
assert(ethtool_fd);
|
||||||
assert(ifname);
|
assert(ifname);
|
||||||
assert(features);
|
assert(features);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < _NET_DEV_FEAT_MAX; i++)
|
||||||
|
if (features[i] >= 0) {
|
||||||
|
have = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!have)
|
||||||
|
return 0;
|
||||||
|
|
||||||
r = ethtool_connect(ethtool_fd);
|
r = ethtool_connect(ethtool_fd);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
@ -525,8 +535,8 @@ int ethtool_set_features(int *ethtool_fd, const char *ifname, const int *feature
|
|||||||
sfeatures->cmd = ETHTOOL_SFEATURES;
|
sfeatures->cmd = ETHTOOL_SFEATURES;
|
||||||
sfeatures->size = DIV_ROUND_UP(strings->len, 32U);
|
sfeatures->size = DIV_ROUND_UP(strings->len, 32U);
|
||||||
|
|
||||||
for (i = 0; i < _NET_DEV_FEAT_MAX; i++)
|
for (size_t i = 0; i < _NET_DEV_FEAT_MAX; i++)
|
||||||
if (features[i] != -1) {
|
if (features[i] >= 0) {
|
||||||
r = set_features_bit(strings, netdev_feature_table[i], features[i], sfeatures);
|
r = set_features_bit(strings, netdev_feature_table[i], features[i], sfeatures);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_debug_errno(r, "ethtool: could not find feature, ignoring: %s", netdev_feature_table[i]);
|
log_debug_errno(r, "ethtool: could not find feature, ignoring: %s", netdev_feature_table[i]);
|
||||||
|
|||||||
@ -88,7 +88,7 @@ int ethtool_get_link_info(int *ethtool_fd, const char *ifname,
|
|||||||
int ethtool_get_permanent_macaddr(int *ethtool_fd, const char *ifname, struct ether_addr *ret);
|
int ethtool_get_permanent_macaddr(int *ethtool_fd, const char *ifname, struct ether_addr *ret);
|
||||||
int ethtool_set_wol(int *ethtool_fd, const char *ifname, uint32_t wolopts);
|
int ethtool_set_wol(int *ethtool_fd, const char *ifname, uint32_t wolopts);
|
||||||
int ethtool_set_nic_buffer_size(int *ethtool_fd, const char *ifname, const netdev_ring_param *ring);
|
int ethtool_set_nic_buffer_size(int *ethtool_fd, const char *ifname, const netdev_ring_param *ring);
|
||||||
int ethtool_set_features(int *ethtool_fd, const char *ifname, const int *features);
|
int ethtool_set_features(int *ethtool_fd, const char *ifname, const int features[static _NET_DEV_FEAT_MAX]);
|
||||||
int ethtool_set_glinksettings(int *ethtool_fd, const char *ifname,
|
int ethtool_set_glinksettings(int *ethtool_fd, const char *ifname,
|
||||||
int autonegotiation, const uint32_t advertise[static N_ADVERTISE],
|
int autonegotiation, const uint32_t advertise[static N_ADVERTISE],
|
||||||
uint64_t speed, Duplex duplex, NetDevPort port);
|
uint64_t speed, Duplex duplex, NetDevPort port);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user