networkd: add missing bonding options (#10542)
Add support for bonding options system prio, port key and actor system mac. These options exist in the linux kernel since 4.2 (torvalds/linux@171a42c38c) Details: https://www.kernel.org/doc/Documentation/networking/bonding.txt
This commit is contained in:
committed by
Yu Watanabe
parent
9cbdf5db48
commit
99f68ef02d
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "conf-parser.h"
|
||||
#include "ether-addr-util.h"
|
||||
#include "extract-word.h"
|
||||
#include "missing.h"
|
||||
#include "netdev/bond.h"
|
||||
@@ -284,6 +285,24 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_netlin
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_MIN_LINKS attribute: %m");
|
||||
}
|
||||
|
||||
if (b->ad_actor_sys_prio != 0) {
|
||||
r = sd_netlink_message_append_u16(m, IFLA_BOND_AD_ACTOR_SYS_PRIO, b->ad_actor_sys_prio);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_AD_ACTOR_SYS_PRIO attribute: %m");
|
||||
}
|
||||
|
||||
if (b->ad_user_port_key != 0) {
|
||||
r = sd_netlink_message_append_u16(m, IFLA_BOND_AD_USER_PORT_KEY, b->ad_user_port_key);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_AD_USER_PORT_KEY attribute: %m");
|
||||
}
|
||||
|
||||
if (b->ad_actor_system) {
|
||||
r = sd_netlink_message_append_ether_addr(m, IFLA_BOND_AD_ACTOR_SYSTEM, b->ad_actor_system);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_AD_ACTOR_SYSTEM attribute: %m");
|
||||
}
|
||||
|
||||
r = sd_netlink_message_append_u8(m, IFLA_BOND_ALL_SLAVES_ACTIVE, b->all_slaves_active);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ALL_SLAVES_ACTIVE attribute: %m");
|
||||
@@ -371,6 +390,115 @@ int config_parse_arp_ip_target_address(const char *unit,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_ad_actor_sys_prio(const char *unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
const char *section,
|
||||
unsigned section_line,
|
||||
const char *lvalue,
|
||||
int ltype,
|
||||
const char *rvalue,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
Bond *b = userdata;
|
||||
uint16_t v;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
r = safe_atou16(rvalue, &v);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse actor system priority '%s', ignoring: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (v == 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse actor system priority '%s'. Range is [1,65535], ignoring: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
b->ad_actor_sys_prio = v;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_ad_user_port_key(const char *unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
const char *section,
|
||||
unsigned section_line,
|
||||
const char *lvalue,
|
||||
int ltype,
|
||||
const char *rvalue,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
Bond *b = userdata;
|
||||
uint16_t v;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
r = safe_atou16(rvalue, &v);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse user port key '%s', ignoring: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (v > 1023) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse user port key '%s'. Range is [0,1023], ignoring: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
b->ad_user_port_key = v;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_ad_actor_system(const char *unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
const char *section,
|
||||
unsigned section_line,
|
||||
const char *lvalue,
|
||||
int ltype,
|
||||
const char *rvalue,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
Bond *b = userdata;
|
||||
_cleanup_free_ struct ether_addr *n = NULL;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
n = new0(struct ether_addr, 1);
|
||||
if (!n)
|
||||
return log_oom();
|
||||
|
||||
r = ether_addr_from_string(rvalue, n);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Not a valid MAC address %s. Ignoring assignment: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ether_addr_is_null(n) || (n->ether_addr_octet[0] & 0x01)) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Not a valid MAC address %s, can not be null or multicast. Ignoring assignment: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
free_and_replace(b->ad_actor_system, n);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bond_done(NetDev *netdev) {
|
||||
ArpIpTarget *t = NULL, *n = NULL;
|
||||
Bond *b;
|
||||
@@ -381,6 +509,8 @@ static void bond_done(NetDev *netdev) {
|
||||
|
||||
assert(b);
|
||||
|
||||
free(b->ad_actor_system);
|
||||
|
||||
LIST_FOREACH_SAFE(arp_ip_target, t, n, b->arp_ip_targets)
|
||||
free(t);
|
||||
|
||||
|
||||
@@ -106,6 +106,10 @@ typedef struct Bond {
|
||||
unsigned num_grat_arp;
|
||||
unsigned min_links;
|
||||
|
||||
uint16_t ad_actor_sys_prio;
|
||||
uint16_t ad_user_port_key;
|
||||
struct ether_addr *ad_actor_system;
|
||||
|
||||
usec_t miimon;
|
||||
usec_t updelay;
|
||||
usec_t downdelay;
|
||||
@@ -152,3 +156,6 @@ int config_parse_bond_arp_validate(const char *unit, const char *filename, unsig
|
||||
int config_parse_bond_arp_all_targets(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
int config_parse_bond_primary_reselect(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
int config_parse_arp_ip_target_address(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
int config_parse_ad_actor_sys_prio(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
int config_parse_ad_user_port_key(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
int config_parse_ad_actor_system(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
|
||||
@@ -141,6 +141,9 @@ Bond.UpDelaySec, config_parse_sec, 0,
|
||||
Bond.DownDelaySec, config_parse_sec, 0, offsetof(Bond, downdelay)
|
||||
Bond.ARPIntervalSec, config_parse_sec, 0, offsetof(Bond, arp_interval)
|
||||
Bond.LearnPacketIntervalSec, config_parse_sec, 0, offsetof(Bond, lp_interval)
|
||||
Bond.AdActorSysPrio, config_parse_ad_actor_sys_prio, 0, offsetof(Bond, ad_actor_sys_prio)
|
||||
Bond.AdUserPortKey, config_parse_ad_user_port_key, 0, offsetof(Bond, ad_user_port_key)
|
||||
Bond.AdActorSystem, config_parse_ad_actor_system, 0, offsetof(Bond, ad_actor_system)
|
||||
Bridge.HelloTimeSec, config_parse_sec, 0, offsetof(Bridge, hello_time)
|
||||
Bridge.MaxAgeSec, config_parse_sec, 0, offsetof(Bridge, max_age)
|
||||
Bridge.AgeingTimeSec, config_parse_sec, 0, offsetof(Bridge, ageing_time)
|
||||
|
||||
Reference in New Issue
Block a user