mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
networkd: Add support to configure destination address for bridge FDB
Closes #5145. Example conf: ``` [Match] Name=vxlan1309 [BridgeFDB] MACAddress=00:00:00:00:00:00 Destination=10.0.0.2 [BridgeFDB] MACAddress=00:00:00:00:00:00 Destination=10.0.0.4 [BridgeFDB] MACAddress=00:00:00:00:00:00 Destination=10.0.0.5 ```
This commit is contained in:
parent
f143c650a3
commit
c2c2793f39
@ -1913,6 +1913,12 @@
|
||||
key is mandatory.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>Destination=</varname></term>
|
||||
<listitem>
|
||||
<para>Takes an IP address of the destination VXLAN tunnel endpoint.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>VLANId=</varname></term>
|
||||
<listitem>
|
||||
|
@ -145,6 +145,12 @@ int fdb_entry_configure(Link *link, FdbEntry *fdb_entry) {
|
||||
return rtnl_log_create_error(r);
|
||||
}
|
||||
|
||||
if (!in_addr_is_null(fdb_entry->family, &fdb_entry->destination_addr)) {
|
||||
r = netlink_message_append_in_addr_union(req, NDA_DST, fdb_entry->family, &fdb_entry->destination_addr);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not append NDA_DST attribute: %m");
|
||||
}
|
||||
|
||||
/* send message to the kernel to update its internal static MAC table. */
|
||||
r = netlink_call_async(rtnl, NULL, req, set_fdb_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
@ -258,3 +264,40 @@ int config_parse_fdb_vlan_id(
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_fdb_destination(
|
||||
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) {
|
||||
|
||||
_cleanup_(fdb_entry_free_or_set_invalidp) FdbEntry *fdb_entry = NULL;
|
||||
Network *network = userdata;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(section);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
r = fdb_entry_new_static(network, filename, section_line, &fdb_entry);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
r = in_addr_from_string_auto(rvalue, &fdb_entry->family, &fdb_entry->destination_addr);
|
||||
if (r < 0)
|
||||
return log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"FDB destination IP address is invalid, ignoring assignment: %s",
|
||||
rvalue);
|
||||
|
||||
fdb_entry = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -19,9 +19,12 @@ struct FdbEntry {
|
||||
Network *network;
|
||||
NetworkConfigSection *section;
|
||||
|
||||
struct ether_addr *mac_addr;
|
||||
int family;
|
||||
uint16_t vlan_id;
|
||||
|
||||
struct ether_addr *mac_addr;
|
||||
union in_addr_union destination_addr;
|
||||
|
||||
LIST_FIELDS(FdbEntry, static_fdb_entries);
|
||||
};
|
||||
|
||||
@ -32,3 +35,4 @@ DEFINE_NETWORK_SECTION_FUNCTIONS(FdbEntry, fdb_entry_free);
|
||||
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_fdb_hwaddr);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_fdb_vlan_id);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_fdb_destination);
|
||||
|
@ -179,6 +179,7 @@ Bridge.Learning, config_parse_tristate,
|
||||
Bridge.Priority, config_parse_bridge_port_priority, 0, offsetof(Network, priority)
|
||||
BridgeFDB.MACAddress, config_parse_fdb_hwaddr, 0, 0
|
||||
BridgeFDB.VLANId, config_parse_fdb_vlan_id, 0, 0
|
||||
BridgeFDB.Destination, config_parse_fdb_destination, 0, 0
|
||||
BridgeVLAN.PVID, config_parse_brvlan_pvid, 0, 0
|
||||
BridgeVLAN.VLAN, config_parse_brvlan_vlan, 0, 0
|
||||
BridgeVLAN.EgressUntagged, config_parse_brvlan_untagged, 0, 0
|
||||
|
@ -32,6 +32,7 @@ MACAddress=
|
||||
[BridgeFDB]
|
||||
VLANId=
|
||||
MACAddress=
|
||||
Destination=
|
||||
[DHCP]
|
||||
UseDomains=
|
||||
UseRoutes=
|
||||
|
Loading…
x
Reference in New Issue
Block a user