diff options
author | Tom Gundersen <teg@jklm.no> | 2014-01-11 20:20:14 +0000 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-01-12 15:37:21 +0100 |
commit | 924fe4304af981ffd849346b4a1d415f11e9dd79 (patch) | |
tree | 90529fee628a28cc8d112850eedf4ce5f242f81c | |
parent | f46685a4c0780173e5291fb7c3caa1c35cb1d0af (diff) |
networkd: bridge - remove redundant state
We will not insist on getting the reply from rtnl that the bridge
was created before considering the bridge ready, as we will be
notified about that via udev. We will listen for the rtnl response
however, in case the creation of the bridge failed.
-rw-r--r-- | src/network/networkd-bridge.c | 20 | ||||
-rw-r--r-- | src/network/networkd.h | 1 |
2 files changed, 9 insertions, 12 deletions
diff --git a/src/network/networkd-bridge.c b/src/network/networkd-bridge.c index 7de7546358..ce48878991 100644 --- a/src/network/networkd-bridge.c +++ b/src/network/networkd-bridge.c @@ -113,6 +113,9 @@ static int bridge_join_ready(Bridge *bridge, Link* link, sd_rtnl_message_handler static int bridge_enter_ready(Bridge *bridge) { bridge_join_callback *callback; + assert(bridge); + assert(bridge->name); + bridge->state = BRIDGE_STATE_READY; log_info_bridge(bridge, "bridge ready"); @@ -130,7 +133,7 @@ static int bridge_create_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userda Bridge *bridge = userdata; int r; - assert(bridge->state == BRIDGE_STATE_CREATING); + assert(bridge->state != _BRIDGE_STATE_INVALID); r = sd_rtnl_message_get_errno(m); if (r < 0) { @@ -140,11 +143,6 @@ static int bridge_create_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userda return 1; } - if (bridge->link) - bridge_enter_ready(bridge); - else - bridge->state = BRIDGE_STATE_CREATED; - return 1; } @@ -234,18 +232,18 @@ int bridge_join(Bridge *bridge, Link *link, sd_rtnl_message_handler_t callback) int bridge_set_link(Manager *m, Link *link) { Bridge *bridge; + int r; - bridge = hashmap_get(m->bridges, link->ifname); - if (!bridge) - return -ENOENT; + r = bridge_get(m, link->ifname, &bridge); + if (r < 0) + return r; if (bridge->link && bridge->link != link) return -EEXIST; bridge->link = link; - if (bridge->state == BRIDGE_STATE_CREATED) - bridge_enter_ready(bridge); + bridge_enter_ready(bridge); return 0; } diff --git a/src/network/networkd.h b/src/network/networkd.h index 4f44f78655..55181f2bbc 100644 --- a/src/network/networkd.h +++ b/src/network/networkd.h @@ -52,7 +52,6 @@ struct bridge_join_callback { typedef enum BridgeState { BRIDGE_STATE_FAILED, BRIDGE_STATE_CREATING, - BRIDGE_STATE_CREATED, BRIDGE_STATE_READY, _BRIDGE_STATE_MAX, _BRIDGE_STATE_INVALID = -1, |