mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
networkd: use BridgeFDB as well on bridge ports (#4253)
[BridgeFDB] did not apply to bridge ports so far. This patch adds the proper handling. In case of a bridge interface the correct flag NTF_MASTER is now set in the netlink call. FDB MAC addresses are now applied in link_enter_set_addresses to make sure the link is setup.
This commit is contained in:
parent
110b7e909a
commit
f6bb7ac5c6
@ -107,20 +107,28 @@ int fdb_entry_configure(Link *link, FdbEntry *fdb_entry) {
|
||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
|
||||
sd_netlink *rtnl;
|
||||
int r;
|
||||
uint8_t flags;
|
||||
Bridge *bridge;
|
||||
|
||||
assert(link);
|
||||
assert(link->network);
|
||||
assert(link->manager);
|
||||
assert(fdb_entry);
|
||||
|
||||
rtnl = link->manager->rtnl;
|
||||
bridge = BRIDGE(link->network->bridge);
|
||||
|
||||
/* create new RTM message */
|
||||
r = sd_rtnl_message_new_neigh(rtnl, &req, RTM_NEWNEIGH, link->ifindex, PF_BRIDGE);
|
||||
if (r < 0)
|
||||
return rtnl_log_create_error(r);
|
||||
|
||||
/* only NTF_SELF flag supported. */
|
||||
r = sd_rtnl_message_neigh_set_flags(req, NTF_SELF);
|
||||
if (bridge)
|
||||
flags = NTF_MASTER;
|
||||
else
|
||||
flags = NTF_SELF;
|
||||
|
||||
r = sd_rtnl_message_neigh_set_flags(req, flags);
|
||||
if (r < 0)
|
||||
return rtnl_log_create_error(r);
|
||||
|
||||
|
@ -942,6 +942,20 @@ static int link_push_ntp_to_dhcp_server(Link *link, sd_dhcp_server *s) {
|
||||
return sd_dhcp_server_set_ntp(s, addresses, n_addresses);
|
||||
}
|
||||
|
||||
static int link_set_bridge_fdb(Link *link) {
|
||||
FdbEntry *fdb_entry;
|
||||
int r = 0;
|
||||
|
||||
LIST_FOREACH(static_fdb_entries, fdb_entry, link->network->static_fdb_entries) {
|
||||
r = fdb_entry_configure(link, fdb_entry);
|
||||
if (r < 0) {
|
||||
return log_link_error_errno(link, r, "Failed to add MAC entry to static MAC table: %m");
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int link_enter_set_addresses(Link *link) {
|
||||
Address *ad;
|
||||
int r;
|
||||
@ -950,6 +964,10 @@ static int link_enter_set_addresses(Link *link) {
|
||||
assert(link->network);
|
||||
assert(link->state != _LINK_STATE_INVALID);
|
||||
|
||||
r = link_set_bridge_fdb(link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
link_set_state(link, LINK_STATE_SETTING_ADDRESSES);
|
||||
|
||||
LIST_FOREACH(addresses, ad, link->network->static_addresses) {
|
||||
@ -1119,21 +1137,6 @@ static int link_set_bridge_vlan(Link *link) {
|
||||
return r;
|
||||
}
|
||||
|
||||
static int link_set_bridge_fdb(Link *link) {
|
||||
FdbEntry *fdb_entry;
|
||||
int r = 0;
|
||||
|
||||
LIST_FOREACH(static_fdb_entries, fdb_entry, link->network->static_fdb_entries) {
|
||||
r = fdb_entry_configure(link, fdb_entry);
|
||||
if (r < 0) {
|
||||
log_link_error_errno(link, r, "Failed to add MAC entry to static MAC table: %m");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int link_set_proxy_arp(Link *link) {
|
||||
const char *p = NULL;
|
||||
int r;
|
||||
@ -2477,10 +2480,6 @@ static int link_configure(Link *link) {
|
||||
return r;
|
||||
}
|
||||
|
||||
r = link_set_bridge_fdb(link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = link_set_proxy_arp(link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
Loading…
x
Reference in New Issue
Block a user