diff options
author | Susant Sahani <ssahani@redhat.com> | 2019-04-30 14:53:39 +0530 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-05-03 06:11:52 +0200 |
commit | c2c2793f39352c554b05ebf299374ed02290d816 (patch) | |
tree | 49dd9c0cf6b3b257117137a4048c2b0635fba6e8 /src/network/networkd-fdb.c | |
parent | f143c650a35b9f04e25ac58a838a825ab42a955e (diff) | |
download | systemd-c2c2793f39352c554b05ebf299374ed02290d816.tar.gz systemd-c2c2793f39352c554b05ebf299374ed02290d816.tar.bz2 systemd-c2c2793f39352c554b05ebf299374ed02290d816.zip |
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
```
Diffstat (limited to 'src/network/networkd-fdb.c')
-rw-r--r-- | src/network/networkd-fdb.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/network/networkd-fdb.c b/src/network/networkd-fdb.c index 1934bc66eb..6ebc45267f 100644 --- a/src/network/networkd-fdb.c +++ b/src/network/networkd-fdb.c @@ -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; +} |