diff options
author | Tom Gundersen <teg@jklm.no> | 2015-02-10 20:40:41 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-02-10 22:30:35 +0100 |
commit | ea6ec096db5f9f3562b9bbf438da7fe21411c74d (patch) | |
tree | 2cb4cb42f485faef82570b0143894759c0065d69 /src | |
parent | 9198e12ca32db7812b2a79b5922233ec80890306 (diff) |
networkd: fdb - refactor a bit
Pass around Link objcets rather than FdbEntry objects. The link objects have an up-to-date
ifname we can use for logging. match_name sholud _never_ be used for anything except
matching. Firstly, it may be unset (usually is), and secondly it may not be up-to-date.
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-fdb.c | 26 | ||||
-rw-r--r-- | src/network/networkd-link.c | 2 | ||||
-rw-r--r-- | src/network/networkd.h | 2 |
3 files changed, 16 insertions, 14 deletions
diff --git a/src/network/networkd-fdb.c b/src/network/networkd-fdb.c index 9bb45e33d1..78488c9d25 100644 --- a/src/network/networkd-fdb.c +++ b/src/network/networkd-fdb.c @@ -86,31 +86,33 @@ int fdb_entry_new_static(Network *const network, } static int set_fdb_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) { - _cleanup_fdbentry_free_ FdbEntry *fdb_entry = userdata; + Link *link = userdata; int r; - assert(fdb_entry); + assert(link); r = sd_rtnl_message_get_errno(m); - if ((r < 0) && (r != (-EEXIST))) - log_error("Could not add FDB entry for interface: %s error: %s", - fdb_entry->network->match_name, strerror(-r)); + if (r < 0 && r != -EEXIST) + log_link_error(link, "Could not add FDB entry: %s", strerror(-r)); return 1; } /* send a request to the kernel to add a FDB entry in its static MAC table. */ -int fdb_entry_configure(sd_rtnl *const rtnl, - FdbEntry *const fdb_entry, - const int ifindex) { +int fdb_entry_configure(Link *link, + FdbEntry *const fdb_entry) { _cleanup_rtnl_message_unref_ sd_rtnl_message *req = NULL; + sd_rtnl *rtnl; int r; + assert(link); + assert(link->manager); assert(fdb_entry); - assert(rtnl); + + rtnl = link->manager->rtnl; /* create new RTM message */ - r = sd_rtnl_message_new_neigh(rtnl, &req, RTM_NEWNEIGH, ifindex, PF_BRIDGE); + r = sd_rtnl_message_new_neigh(rtnl, &req, RTM_NEWNEIGH, link->ifindex, PF_BRIDGE); if (r < 0) return rtnl_log_create_error(r); @@ -136,9 +138,9 @@ int fdb_entry_configure(sd_rtnl *const rtnl, } /* send message to the kernel to update its internal static MAC table. */ - r = sd_rtnl_call_async(rtnl, req, set_fdb_handler, fdb_entry, 0, NULL); + r = sd_rtnl_call_async(rtnl, req, set_fdb_handler, link, 0, NULL); if (r < 0) { - log_error("Could not send rtnetlink message: %s", strerror(-r)); + log_link_error(link, "Could not send rtnetlink message: %s", strerror(-r)); return r; } diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 0b1cac1055..3f1539454f 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -733,7 +733,7 @@ static int link_set_bridge_fdb(const Link *const link) { int r = 0; LIST_FOREACH(static_fdb_entries, fdb_entry, link->network->static_fdb_entries) { - r = fdb_entry_configure(link->manager->rtnl, fdb_entry, link->ifindex); + r = fdb_entry_configure(link, fdb_entry); if(r < 0) { log_link_error(link, "Failed to add MAC entry to static MAC table: %s", strerror(-r)); break; diff --git a/src/network/networkd.h b/src/network/networkd.h index 22cc51d933..691d603020 100644 --- a/src/network/networkd.h +++ b/src/network/networkd.h @@ -383,7 +383,7 @@ int config_parse_label(const char *unit, const char *filename, unsigned line, int ltype, const char *rvalue, void *data, void *userdata); /* Forwarding database table. */ -int fdb_entry_configure(sd_rtnl *const rtnl, FdbEntry *const fdb_entry, const int ifindex); +int fdb_entry_configure(Link *link, FdbEntry *const fdb_entry); void fdb_entry_free(FdbEntry *fdb_entry); int fdb_entry_new_static(Network *const network, const unsigned section, FdbEntry **ret); |