mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
Merge pull request #12288 from yuwata/resolve-bond-rafactoring
resolve,network: tiny cleanups
This commit is contained in:
commit
d90a044f49
@ -34,6 +34,10 @@ static inline int ordered_set_put(OrderedSet *s, void *p) {
|
||||
return ordered_hashmap_put((OrderedHashmap*) s, p, p);
|
||||
}
|
||||
|
||||
static inline unsigned ordered_set_size(OrderedSet *s) {
|
||||
return ordered_hashmap_size((OrderedHashmap*) s);
|
||||
}
|
||||
|
||||
static inline bool ordered_set_isempty(OrderedSet *s) {
|
||||
return ordered_hashmap_isempty((OrderedHashmap*) s);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
Copyright © 2014 Axis Communications AB. All rights reserved.
|
||||
***/
|
||||
|
||||
#include <netinet/if_ether.h>
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#include "socket-util.h"
|
||||
#include "sparse-endian.h"
|
||||
|
@ -1,16 +1,12 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <netinet/ether.h>
|
||||
#include <linux/if_bonding.h>
|
||||
|
||||
#include "sd-netlink.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "bond.h"
|
||||
#include "conf-parser.h"
|
||||
#include "ether-addr-util.h"
|
||||
#include "extract-word.h"
|
||||
#include "missing.h"
|
||||
#include "netdev/bond.h"
|
||||
#include "string-table.h"
|
||||
#include "string-util.h"
|
||||
|
||||
@ -125,48 +121,9 @@ static const char *const bond_primary_reselect_table[_NETDEV_BOND_PRIMARY_RESELE
|
||||
DEFINE_STRING_TABLE_LOOKUP(bond_primary_reselect, BondPrimaryReselect);
|
||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_primary_reselect, bond_primary_reselect, BondPrimaryReselect, "Failed to parse bond primary reselect");
|
||||
|
||||
static uint8_t bond_mode_to_kernel(BondMode mode) {
|
||||
switch (mode) {
|
||||
case NETDEV_BOND_MODE_BALANCE_RR:
|
||||
return BOND_MODE_ROUNDROBIN;
|
||||
case NETDEV_BOND_MODE_ACTIVE_BACKUP:
|
||||
return BOND_MODE_ACTIVEBACKUP;
|
||||
case NETDEV_BOND_MODE_BALANCE_XOR:
|
||||
return BOND_MODE_XOR;
|
||||
case NETDEV_BOND_MODE_BROADCAST:
|
||||
return BOND_MODE_BROADCAST;
|
||||
case NETDEV_BOND_MODE_802_3AD:
|
||||
return BOND_MODE_8023AD;
|
||||
case NETDEV_BOND_MODE_BALANCE_TLB:
|
||||
return BOND_MODE_TLB;
|
||||
case NETDEV_BOND_MODE_BALANCE_ALB:
|
||||
return BOND_MODE_ALB;
|
||||
default:
|
||||
return (uint8_t) -1;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t bond_xmit_hash_policy_to_kernel(BondXmitHashPolicy policy) {
|
||||
switch (policy) {
|
||||
case NETDEV_BOND_XMIT_HASH_POLICY_LAYER2:
|
||||
return BOND_XMIT_POLICY_LAYER2;
|
||||
case NETDEV_BOND_XMIT_HASH_POLICY_LAYER34:
|
||||
return BOND_XMIT_POLICY_LAYER34;
|
||||
case NETDEV_BOND_XMIT_HASH_POLICY_LAYER23:
|
||||
return BOND_XMIT_POLICY_LAYER23;
|
||||
case NETDEV_BOND_XMIT_HASH_POLICY_ENCAP23:
|
||||
return BOND_XMIT_POLICY_ENCAP23;
|
||||
case NETDEV_BOND_XMIT_HASH_POLICY_ENCAP34:
|
||||
return BOND_XMIT_POLICY_ENCAP34;
|
||||
default:
|
||||
return (uint8_t) -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) {
|
||||
Bond *b;
|
||||
ArpIpTarget *target = NULL;
|
||||
int r, i = 0;
|
||||
int r;
|
||||
|
||||
assert(netdev);
|
||||
assert(!link);
|
||||
@ -177,14 +134,13 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_netlin
|
||||
assert(b);
|
||||
|
||||
if (b->mode != _NETDEV_BOND_MODE_INVALID) {
|
||||
r = sd_netlink_message_append_u8(m, IFLA_BOND_MODE, bond_mode_to_kernel(b->mode));
|
||||
r = sd_netlink_message_append_u8(m, IFLA_BOND_MODE, b->mode);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_MODE attribute: %m");
|
||||
}
|
||||
|
||||
if (b->xmit_hash_policy != _NETDEV_BOND_XMIT_HASH_POLICY_INVALID) {
|
||||
r = sd_netlink_message_append_u8(m, IFLA_BOND_XMIT_HASH_POLICY,
|
||||
bond_xmit_hash_policy_to_kernel(b->xmit_hash_policy));
|
||||
r = sd_netlink_message_append_u8(m, IFLA_BOND_XMIT_HASH_POLICY, b->xmit_hash_policy);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_XMIT_HASH_POLICY attribute: %m");
|
||||
}
|
||||
@ -296,8 +252,8 @@ 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_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 (!ether_addr_is_null(&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");
|
||||
}
|
||||
@ -312,13 +268,17 @@ 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_TLB_DYNAMIC_LB attribute: %m");
|
||||
}
|
||||
|
||||
if (b->arp_interval > 0 && b->n_arp_ip_targets > 0) {
|
||||
if (b->arp_interval > 0 && !ordered_set_isempty(b->arp_ip_targets)) {
|
||||
Iterator i;
|
||||
void *val;
|
||||
int n = 0;
|
||||
|
||||
r = sd_netlink_message_open_container(m, IFLA_BOND_ARP_IP_TARGET);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not open contaniner IFLA_BOND_ARP_IP_TARGET : %m");
|
||||
|
||||
LIST_FOREACH(arp_ip_target, target, b->arp_ip_targets) {
|
||||
r = sd_netlink_message_append_u32(m, i++, target->ip.in.s_addr);
|
||||
ORDERED_SET_FOREACH(val, b->arp_ip_targets, i) {
|
||||
r = sd_netlink_message_append_u32(m, n++, PTR_TO_UINT32(val));
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_ALL_TARGETS attribute: %m");
|
||||
}
|
||||
@ -331,16 +291,18 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_netlin
|
||||
return 0;
|
||||
}
|
||||
|
||||
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_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) {
|
||||
|
||||
Bond *b = userdata;
|
||||
int r;
|
||||
|
||||
@ -349,57 +311,64 @@ int config_parse_arp_ip_target_address(const char *unit,
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
b->arp_ip_targets = ordered_set_free(b->arp_ip_targets);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
_cleanup_free_ ArpIpTarget *buffer = NULL;
|
||||
_cleanup_free_ char *n = NULL;
|
||||
int f;
|
||||
union in_addr_union ip;
|
||||
|
||||
r = extract_first_word(&rvalue, &n, NULL, 0);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse Bond ARP ip target address, ignoring assignment: %s", rvalue);
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Failed to parse Bond ARP ip target address, ignoring assignment: %s",
|
||||
rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (r == 0)
|
||||
break;
|
||||
return 0;
|
||||
|
||||
buffer = new0(ArpIpTarget, 1);
|
||||
if (!buffer)
|
||||
return -ENOMEM;
|
||||
|
||||
r = in_addr_from_string_auto(n, &f, &buffer->ip);
|
||||
r = in_addr_from_string(AF_INET, n, &ip);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Bond ARP ip target address is invalid, ignoring assignment: %s", n);
|
||||
return 0;
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Bond ARP ip target address is invalid, ignoring assignment: %s", n);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (f != AF_INET) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Bond ARP ip target address is invalid, ignoring assignment: %s", n);
|
||||
return 0;
|
||||
r = ordered_set_ensure_allocated(&b->arp_ip_targets, NULL);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
if (ordered_set_size(b->arp_ip_targets) >= NETDEV_BOND_ARP_TARGETS_MAX) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
"Too many ARP ip targets are specified. The maximum number is %d. Ignoring assignment: %s",
|
||||
NETDEV_BOND_ARP_TARGETS_MAX, n);
|
||||
continue;
|
||||
}
|
||||
|
||||
LIST_PREPEND(arp_ip_target, b->arp_ip_targets, TAKE_PTR(buffer));
|
||||
b->n_arp_ip_targets++;
|
||||
r = ordered_set_put(b->arp_ip_targets, UINT32_TO_PTR(ip.in.s_addr));
|
||||
if (r == -EEXIST)
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Bond ARP ip target address is duplicated, ignoring assignment: %s", n);
|
||||
if (r < 0)
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Failed to store bond ARP ip target address '%s', ignoring assignment: %m", n);
|
||||
}
|
||||
|
||||
if (b->n_arp_ip_targets > NETDEV_BOND_ARP_TARGETS_MAX)
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
"More than the maximum number of kernel-supported ARP ip targets specified: %d > %d",
|
||||
b->n_arp_ip_targets, NETDEV_BOND_ARP_TARGETS_MAX);
|
||||
|
||||
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) {
|
||||
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;
|
||||
@ -411,12 +380,15 @@ int config_parse_ad_actor_sys_prio(const char *unit,
|
||||
|
||||
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);
|
||||
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, 0, "Failed to parse actor system priority '%s'. Range is [1,65535], ignoring.", rvalue);
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0,
|
||||
"Failed to parse actor system priority '%s'. Range is [1,65535], ignoring.",
|
||||
rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -425,16 +397,17 @@ int config_parse_ad_actor_sys_prio(const char *unit,
|
||||
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) {
|
||||
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;
|
||||
@ -446,12 +419,14 @@ int config_parse_ad_user_port_key(const char *unit,
|
||||
|
||||
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);
|
||||
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, 0, "Failed to parse user port key '%s'. Range is [0,1023], ignoring.", rvalue);
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0,
|
||||
"Failed to parse user port key '%s'. Range is [0…1023], ignoring.", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -460,18 +435,19 @@ int config_parse_ad_user_port_key(const char *unit,
|
||||
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) {
|
||||
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;
|
||||
struct ether_addr n;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
@ -479,42 +455,33 @@ int config_parse_ad_actor_system(const char *unit,
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
n = new0(struct ether_addr, 1);
|
||||
if (!n)
|
||||
return log_oom();
|
||||
|
||||
r = ether_addr_from_string(rvalue, n);
|
||||
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);
|
||||
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, 0,
|
||||
"Not a valid MAC address %s, can not be null or multicast. Ignoring assignment.",
|
||||
rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ether_addr_is_null(n) || (n->ether_addr_octet[0] & 0x01)) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Not a valid MAC address %s, can not be null or multicast. Ignoring assignment.", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
free_and_replace(b->ad_actor_system, n);
|
||||
b->ad_actor_system = n;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bond_done(NetDev *netdev) {
|
||||
ArpIpTarget *t = NULL, *n = NULL;
|
||||
Bond *b;
|
||||
|
||||
assert(netdev);
|
||||
|
||||
b = BOND(netdev);
|
||||
|
||||
assert(b);
|
||||
|
||||
free(b->ad_actor_system);
|
||||
|
||||
LIST_FOREACH_SAFE(arp_ip_target, t, n, b->arp_ip_targets)
|
||||
free(t);
|
||||
|
||||
b->arp_ip_targets = NULL;
|
||||
ordered_set_free(b->arp_ip_targets);
|
||||
}
|
||||
|
||||
static void bond_init(NetDev *netdev) {
|
||||
@ -542,9 +509,6 @@ static void bond_init(NetDev *netdev) {
|
||||
b->packets_per_slave = PACKETS_PER_SLAVE_DEFAULT;
|
||||
b->num_grat_arp = GRATUITOUS_ARP_DEFAULT;
|
||||
b->lp_interval = LEARNING_PACKETS_INTERVAL_MIN_SEC;
|
||||
|
||||
LIST_HEAD_INIT(b->arp_ip_targets);
|
||||
b->n_arp_ip_targets = 0;
|
||||
}
|
||||
|
||||
const NetDevVTable bond_vtable = {
|
||||
|
@ -1,10 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include "in-addr-util.h"
|
||||
#include "list.h"
|
||||
#include <linux/if_bonding.h>
|
||||
|
||||
#include "netdev/netdev.h"
|
||||
#include "in-addr-util.h"
|
||||
#include "netdev.h"
|
||||
#include "ordered-set.h"
|
||||
|
||||
/*
|
||||
* Maximum number of targets supported by the kernel for a single
|
||||
@ -13,23 +14,23 @@
|
||||
#define NETDEV_BOND_ARP_TARGETS_MAX 16
|
||||
|
||||
typedef enum BondMode {
|
||||
NETDEV_BOND_MODE_BALANCE_RR,
|
||||
NETDEV_BOND_MODE_ACTIVE_BACKUP,
|
||||
NETDEV_BOND_MODE_BALANCE_XOR,
|
||||
NETDEV_BOND_MODE_BROADCAST,
|
||||
NETDEV_BOND_MODE_802_3AD,
|
||||
NETDEV_BOND_MODE_BALANCE_TLB,
|
||||
NETDEV_BOND_MODE_BALANCE_ALB,
|
||||
NETDEV_BOND_MODE_BALANCE_RR = BOND_MODE_ROUNDROBIN,
|
||||
NETDEV_BOND_MODE_ACTIVE_BACKUP = BOND_MODE_ACTIVEBACKUP,
|
||||
NETDEV_BOND_MODE_BALANCE_XOR = BOND_MODE_XOR,
|
||||
NETDEV_BOND_MODE_BROADCAST = BOND_MODE_BROADCAST,
|
||||
NETDEV_BOND_MODE_802_3AD = BOND_MODE_8023AD,
|
||||
NETDEV_BOND_MODE_BALANCE_TLB = BOND_MODE_TLB,
|
||||
NETDEV_BOND_MODE_BALANCE_ALB = BOND_MODE_ALB,
|
||||
_NETDEV_BOND_MODE_MAX,
|
||||
_NETDEV_BOND_MODE_INVALID = -1
|
||||
_NETDEV_BOND_MODE_INVALID = -1
|
||||
} BondMode;
|
||||
|
||||
typedef enum BondXmitHashPolicy {
|
||||
NETDEV_BOND_XMIT_HASH_POLICY_LAYER2,
|
||||
NETDEV_BOND_XMIT_HASH_POLICY_LAYER34,
|
||||
NETDEV_BOND_XMIT_HASH_POLICY_LAYER23,
|
||||
NETDEV_BOND_XMIT_HASH_POLICY_ENCAP23,
|
||||
NETDEV_BOND_XMIT_HASH_POLICY_ENCAP34,
|
||||
NETDEV_BOND_XMIT_HASH_POLICY_LAYER2 = BOND_XMIT_POLICY_LAYER2,
|
||||
NETDEV_BOND_XMIT_HASH_POLICY_LAYER34 = BOND_XMIT_POLICY_LAYER34,
|
||||
NETDEV_BOND_XMIT_HASH_POLICY_LAYER23 = BOND_XMIT_POLICY_LAYER23,
|
||||
NETDEV_BOND_XMIT_HASH_POLICY_ENCAP23 = BOND_XMIT_POLICY_ENCAP23,
|
||||
NETDEV_BOND_XMIT_HASH_POLICY_ENCAP34 = BOND_XMIT_POLICY_ENCAP34,
|
||||
_NETDEV_BOND_XMIT_HASH_POLICY_MAX,
|
||||
_NETDEV_BOND_XMIT_HASH_POLICY_INVALID = -1
|
||||
} BondXmitHashPolicy;
|
||||
@ -81,12 +82,6 @@ typedef enum BondPrimaryReselect {
|
||||
_NETDEV_BOND_PRIMARY_RESELECT_INVALID = -1,
|
||||
} BondPrimaryReselect;
|
||||
|
||||
typedef struct ArpIpTarget {
|
||||
union in_addr_union ip;
|
||||
|
||||
LIST_FIELDS(struct ArpIpTarget, arp_ip_target);
|
||||
} ArpIpTarget;
|
||||
|
||||
typedef struct Bond {
|
||||
NetDev meta;
|
||||
|
||||
@ -110,7 +105,7 @@ typedef struct Bond {
|
||||
|
||||
uint16_t ad_actor_sys_prio;
|
||||
uint16_t ad_user_port_key;
|
||||
struct ether_addr *ad_actor_system;
|
||||
struct ether_addr ad_actor_system;
|
||||
|
||||
usec_t miimon;
|
||||
usec_t updelay;
|
||||
@ -118,8 +113,7 @@ typedef struct Bond {
|
||||
usec_t arp_interval;
|
||||
usec_t lp_interval;
|
||||
|
||||
int n_arp_ip_targets;
|
||||
ArpIpTarget *arp_ip_targets;
|
||||
OrderedSet *arp_ip_targets;
|
||||
} Bond;
|
||||
|
||||
DEFINE_NETDEV_CAST(BOND, Bond);
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "conf-files.h"
|
||||
|
@ -67,7 +67,7 @@ int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol protocol, int
|
||||
dns_scope_llmnr_membership(s, true);
|
||||
dns_scope_mdns_membership(s, true);
|
||||
|
||||
log_debug("New scope on link %s, protocol %s, family %s", l ? l->name : "*", dns_protocol_to_string(protocol), family == AF_UNSPEC ? "*" : af_to_name(family));
|
||||
log_debug("New scope on link %s, protocol %s, family %s", l ? l->ifname : "*", dns_protocol_to_string(protocol), family == AF_UNSPEC ? "*" : af_to_name(family));
|
||||
|
||||
/* Enforce ratelimiting for the multicast protocols */
|
||||
RATELIMIT_INIT(s->ratelimit, MULTICAST_RATELIMIT_INTERVAL_USEC, MULTICAST_RATELIMIT_BURST);
|
||||
@ -98,7 +98,7 @@ DnsScope* dns_scope_free(DnsScope *s) {
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
log_debug("Removing scope on link %s, protocol %s, family %s", s->link ? s->link->name : "*", dns_protocol_to_string(s->protocol), s->family == AF_UNSPEC ? "*" : af_to_name(s->family));
|
||||
log_debug("Removing scope on link %s, protocol %s, family %s", s->link ? s->link->ifname : "*", dns_protocol_to_string(s->protocol), s->family == AF_UNSPEC ? "*" : af_to_name(s->family));
|
||||
|
||||
dns_scope_llmnr_membership(s, false);
|
||||
dns_scope_mdns_membership(s, false);
|
||||
@ -1137,7 +1137,7 @@ void dns_scope_dump(DnsScope *s, FILE *f) {
|
||||
|
||||
if (s->link) {
|
||||
fputs(" interface=", f);
|
||||
fputs(s->link->name, f);
|
||||
fputs(s->link->ifname, f);
|
||||
}
|
||||
|
||||
if (s->family != AF_UNSPEC) {
|
||||
|
@ -836,7 +836,7 @@ void dns_server_dump(DnsServer *s, FILE *f) {
|
||||
assert(s->link);
|
||||
|
||||
fputs(" interface=", f);
|
||||
fputs(s->link->name, f);
|
||||
fputs(s->link->ifname, f);
|
||||
}
|
||||
|
||||
fputs("]\n", f);
|
||||
|
@ -268,7 +268,7 @@ static void dns_transaction_tentative(DnsTransaction *t, DnsPacket *p) {
|
||||
t->id,
|
||||
dns_resource_key_to_string(t->key, key_str, sizeof key_str),
|
||||
dns_protocol_to_string(t->scope->protocol),
|
||||
t->scope->link ? t->scope->link->name : "*",
|
||||
t->scope->link ? t->scope->link->ifname : "*",
|
||||
af_to_name_short(t->scope->family),
|
||||
strnull(pretty));
|
||||
|
||||
@ -333,7 +333,7 @@ void dns_transaction_complete(DnsTransaction *t, DnsTransactionState state) {
|
||||
t->id,
|
||||
dns_resource_key_to_string(t->key, key_str, sizeof key_str),
|
||||
dns_protocol_to_string(t->scope->protocol),
|
||||
t->scope->link ? t->scope->link->name : "*",
|
||||
t->scope->link ? t->scope->link->ifname : "*",
|
||||
af_to_name_short(t->scope->family),
|
||||
st,
|
||||
t->answer_source < 0 ? "none" : dns_transaction_source_to_string(t->answer_source),
|
||||
@ -1648,7 +1648,7 @@ int dns_transaction_go(DnsTransaction *t) {
|
||||
t->id,
|
||||
dns_resource_key_to_string(t->key, key_str, sizeof key_str),
|
||||
dns_protocol_to_string(t->scope->protocol),
|
||||
t->scope->link ? t->scope->link->name : "*",
|
||||
t->scope->link ? t->scope->link->ifname : "*",
|
||||
af_to_name_short(t->scope->family));
|
||||
|
||||
if (!t->initial_jitter_scheduled &&
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "bus-common-errors.h"
|
||||
#include "bus-util.h"
|
||||
@ -190,9 +192,9 @@ static int verify_unmanaged_link(Link *l, sd_bus_error *error) {
|
||||
assert(l);
|
||||
|
||||
if (l->flags & IFF_LOOPBACK)
|
||||
return sd_bus_error_setf(error, BUS_ERROR_LINK_BUSY, "Link %s is loopback device.", l->name);
|
||||
return sd_bus_error_setf(error, BUS_ERROR_LINK_BUSY, "Link %s is loopback device.", l->ifname);
|
||||
if (l->is_managed)
|
||||
return sd_bus_error_setf(error, BUS_ERROR_LINK_BUSY, "Link %s is managed.", l->name);
|
||||
return sd_bus_error_setf(error, BUS_ERROR_LINK_BUSY, "Link %s is managed.", l->ifname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <net/if.h>
|
||||
#include <linux/if.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -10,6 +9,7 @@
|
||||
#include "env-file.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "log-link.h"
|
||||
#include "mkdir.h"
|
||||
#include "parse-util.h"
|
||||
#include "resolved-link.h"
|
||||
@ -98,6 +98,7 @@ Link *link_free(Link *l) {
|
||||
dns_scope_free(l->mdns_ipv6_scope);
|
||||
|
||||
free(l->state_file);
|
||||
free(l->ifname);
|
||||
|
||||
return mfree(l);
|
||||
}
|
||||
@ -239,8 +240,9 @@ int link_process_rtnl(Link *l, sd_netlink_message *m) {
|
||||
(void) sd_netlink_message_read_u8(m, IFLA_OPERSTATE, &l->operstate);
|
||||
|
||||
if (sd_netlink_message_read_string(m, IFLA_IFNAME, &n) >= 0) {
|
||||
strncpy(l->name, n, sizeof(l->name)-1);
|
||||
char_array_0(l->name);
|
||||
r = free_and_strdup(&l->ifname, n);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
link_allocate_scopes(l);
|
||||
@ -596,7 +598,7 @@ static void link_read_settings(Link *l) {
|
||||
|
||||
r = link_is_managed(l);
|
||||
if (r < 0) {
|
||||
log_warning_errno(r, "Failed to determine whether interface %s is managed: %m", l->name);
|
||||
log_link_warning_errno(l, r, "Failed to determine whether the interface is managed: %m");
|
||||
return;
|
||||
}
|
||||
if (r == 0) {
|
||||
@ -613,35 +615,35 @@ static void link_read_settings(Link *l) {
|
||||
|
||||
r = link_update_dns_servers(l);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to read DNS servers for interface %s, ignoring: %m", l->name);
|
||||
log_link_warning_errno(l, r, "Failed to read DNS servers for the interface, ignoring: %m");
|
||||
|
||||
r = link_update_llmnr_support(l);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to read LLMNR support for interface %s, ignoring: %m", l->name);
|
||||
log_link_warning_errno(l, r, "Failed to read LLMNR support for the interface, ignoring: %m");
|
||||
|
||||
r = link_update_mdns_support(l);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to read mDNS support for interface %s, ignoring: %m", l->name);
|
||||
log_link_warning_errno(l, r, "Failed to read mDNS support for the interface, ignoring: %m");
|
||||
|
||||
r = link_update_dns_over_tls_mode(l);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to read DNS-over-TLS mode for interface %s, ignoring: %m", l->name);
|
||||
log_link_warning_errno(l, r, "Failed to read DNS-over-TLS mode for the interface, ignoring: %m");
|
||||
|
||||
r = link_update_dnssec_mode(l);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to read DNSSEC mode for interface %s, ignoring: %m", l->name);
|
||||
log_link_warning_errno(l, r, "Failed to read DNSSEC mode for the interface, ignoring: %m");
|
||||
|
||||
r = link_update_dnssec_negative_trust_anchors(l);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to read DNSSEC negative trust anchors for interface %s, ignoring: %m", l->name);
|
||||
log_link_warning_errno(l, r, "Failed to read DNSSEC negative trust anchors for the interface, ignoring: %m");
|
||||
|
||||
r = link_update_search_domains(l);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to read search domains for interface %s, ignoring: %m", l->name);
|
||||
log_link_warning_errno(l, r, "Failed to read search domains for the interface, ignoring: %m");
|
||||
|
||||
r = link_update_default_route(l);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to read default route setting for interface %s, proceeding anyway: %m", l->name);
|
||||
log_link_warning_errno(l, r, "Failed to read default route setting for the interface, proceeding anyway: %m");
|
||||
}
|
||||
|
||||
int link_update(Link *l) {
|
||||
@ -728,7 +730,7 @@ DnsServer* link_set_dns_server(Link *l, DnsServer *s) {
|
||||
return s;
|
||||
|
||||
if (s)
|
||||
log_debug("Switching to DNS server %s for interface %s.", dns_server_string(s), l->name);
|
||||
log_debug("Switching to DNS server %s for interface %s.", dns_server_string(s), l->ifname);
|
||||
|
||||
dns_server_unref(l->current_dns_server);
|
||||
l->current_dns_server = dns_server_ref(s);
|
||||
|
@ -1,8 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include "in-addr-util.h"
|
||||
#include "ratelimit.h"
|
||||
#include "resolve-util.h"
|
||||
@ -67,7 +65,7 @@ struct Link {
|
||||
|
||||
bool is_managed;
|
||||
|
||||
char name[IF_NAMESIZE];
|
||||
char *ifname;
|
||||
uint32_t mtu;
|
||||
uint8_t operstate;
|
||||
|
||||
|
@ -82,14 +82,14 @@ static int manager_process_link(sd_netlink *rtnl, sd_netlink_message *mm, void *
|
||||
goto fail;
|
||||
|
||||
if (is_new)
|
||||
log_debug("Found new link %i/%s", ifindex, l->name);
|
||||
log_debug("Found new link %i/%s", ifindex, l->ifname);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case RTM_DELLINK:
|
||||
if (l) {
|
||||
log_debug("Removing link %i/%s", l->ifindex, l->name);
|
||||
log_debug("Removing link %i/%s", l->ifindex, l->ifname);
|
||||
link_remove_user(l);
|
||||
link_free(l);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user