diff options
author | Tom Gundersen <teg@jklm.no> | 2014-07-05 14:53:54 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-07-14 16:47:04 +0200 |
commit | 3f2650377631aed3bc26fdbc3a2eef6e33cdf7e7 (patch) | |
tree | 29ade8c7586393e652acf2b8e95c525fb0936876 /src/network/networkd-netdev.c | |
parent | 7c1cff4ff79f3121189403a8c1b7c350925b3aaa (diff) |
networkd: netdev - rename 'enslave' to 'join'
Enslave only really makes sense when referring to bridges and bonds, so try to be
a bit more neutral.
Diffstat (limited to 'src/network/networkd-netdev.c')
-rw-r--r-- | src/network/networkd-netdev.c | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c index 88b692fbab..f6951526fb 100644 --- a/src/network/networkd-netdev.c +++ b/src/network/networkd-netdev.c @@ -51,7 +51,7 @@ DEFINE_CONFIG_PARSE_ENUM(config_parse_netdev_kind, netdev_kind, NetDevKind, "Fai static void netdev_cancel_callbacks(NetDev *netdev) { _cleanup_rtnl_message_unref_ sd_rtnl_message *m = NULL; - netdev_enslave_callback *callback; + netdev_join_callback *callback; if (!netdev) return; @@ -161,6 +161,7 @@ static int netdev_enslave_ready(NetDev *netdev, Link* link, sd_rtnl_message_hand assert(netdev->state == NETDEV_STATE_READY); assert(netdev->manager); assert(netdev->manager->rtnl); + assert(IN_SET(netdev->kind, NETDEV_KIND_BRIDGE, NETDEV_KIND_BOND)); assert(link); assert(callback); @@ -197,7 +198,7 @@ static int netdev_enslave_ready(NetDev *netdev, Link* link, sd_rtnl_message_hand } static int netdev_enter_ready(NetDev *netdev) { - netdev_enslave_callback *callback, *callback_next; + netdev_join_callback *callback, *callback_next; int r; assert(netdev); @@ -345,25 +346,11 @@ static int netdev_create(NetDev *netdev) { return 0; } -/* the callback must be called, possibly after a timeout, as otherwise the Link will hang */ -int netdev_enslave(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callback) { +static int netdev_enslave(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callback) { int r; - switch(netdev->kind) { - case NETDEV_KIND_VLAN: - return netdev_create_vlan(netdev, link, callback); - case NETDEV_KIND_MACVLAN: - return netdev_create_macvlan(netdev, link, callback); - case NETDEV_KIND_VXLAN: - return netdev_create_vxlan(netdev, link, callback); - case NETDEV_KIND_IPIP: - case NETDEV_KIND_GRE: - case NETDEV_KIND_SIT: - case NETDEV_KIND_VTI: - return netdev_create_tunnel(netdev, link, callback); - default: - break; - } + assert(netdev); + assert(IN_SET(netdev->kind, NETDEV_KIND_BRIDGE, NETDEV_KIND_BOND)); if (netdev->state == NETDEV_STATE_READY) { r = netdev_enslave_ready(netdev, link, callback); @@ -371,9 +358,9 @@ int netdev_enslave(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callbac return r; } else { /* the netdev is not yet read, save this request for when it is*/ - netdev_enslave_callback *cb; + netdev_join_callback *cb; - cb = new0(netdev_enslave_callback, 1); + cb = new0(netdev_join_callback, 1); if (!cb) return log_oom(); @@ -387,6 +374,33 @@ int netdev_enslave(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callbac return 0; } +/* the callback must be called, possibly after a timeout, as otherwise the Link will hang */ +int netdev_join(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callback) { + + assert(netdev); + + switch(netdev->kind) { + case NETDEV_KIND_VLAN: + return netdev_create_vlan(netdev, link, callback); + case NETDEV_KIND_MACVLAN: + return netdev_create_macvlan(netdev, link, callback); + case NETDEV_KIND_VXLAN: + return netdev_create_vxlan(netdev, link, callback); + case NETDEV_KIND_IPIP: + case NETDEV_KIND_GRE: + case NETDEV_KIND_SIT: + case NETDEV_KIND_VTI: + return netdev_create_tunnel(netdev, link, callback); + case NETDEV_KIND_BRIDGE: + case NETDEV_KIND_BOND: + return netdev_enslave(netdev, link, callback); + default: + assert_not_reached("Enslaving by invalid netdev kind"); + } + + return 0; +} + int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *message) { uint16_t type; const char *kind; |