summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-07-05 14:53:54 +0200
committerTom Gundersen <teg@jklm.no>2014-07-14 16:47:04 +0200
commit3f2650377631aed3bc26fdbc3a2eef6e33cdf7e7 (patch)
tree29ade8c7586393e652acf2b8e95c525fb0936876 /src/network
parent7c1cff4ff79f3121189403a8c1b7c350925b3aaa (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')
-rw-r--r--src/network/networkd-link.c40
-rw-r--r--src/network/networkd-netdev.c56
-rw-r--r--src/network/networkd.h10
3 files changed, 60 insertions, 46 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 9e057ce0ff..ccf818115b 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1732,14 +1732,14 @@ static int link_up(Link *link) {
return 0;
}
-static int link_enslaved(Link *link) {
+static int link_joined(Link *link) {
int r;
assert(link);
assert(link->state == LINK_STATE_ENSLAVING);
assert(link->network);
- log_debug_link(link, "enslaved");
+ log_debug_link(link, "joined netdev");
if (!(link->flags & IFF_UP)) {
r = link_up(link);
@@ -1752,7 +1752,7 @@ static int link_enslaved(Link *link) {
return link_enter_set_addresses(link);
}
-static int enslave_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
+static int netdev_join_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
_cleanup_link_unref_ Link *link = userdata;
int r;
@@ -1769,7 +1769,7 @@ static int enslave_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST) {
log_struct_link(LOG_ERR, link,
- "MESSAGE=%-*s: could not enslave: %s",
+ "MESSAGE=%-*s: could not join netdev: %s",
IFNAMSIZ,
link->ifname, strerror(-r),
"ERRNO=%d", -r,
@@ -1779,12 +1779,12 @@ static int enslave_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
}
if (link->enslaving <= 0)
- link_enslaved(link);
+ link_joined(link);
return 1;
}
-static int link_enter_enslave(Link *link) {
+static int link_enter_join_netdev(Link *link) {
NetDev *vlan, *macvlan, *vxlan;
Iterator i;
int r;
@@ -1803,7 +1803,7 @@ static int link_enter_enslave(Link *link) {
hashmap_isempty(link->network->vlans) &&
hashmap_isempty(link->network->macvlans) &&
hashmap_isempty(link->network->vxlans))
- return link_enslaved(link);
+ return link_joined(link);
if (link->network->bond) {
log_struct_link(LOG_DEBUG, link,
@@ -1813,10 +1813,10 @@ static int link_enter_enslave(Link *link) {
NETDEV(link->network->bond),
NULL);
- r = netdev_enslave(link->network->bond, link, &enslave_handler);
+ r = netdev_join(link->network->bond, link, &netdev_join_handler);
if (r < 0) {
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%-*s: could not enslave by '%s': %s",
+ "MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, link->network->bond->ifname, strerror(-r),
NETDEV(link->network->bond),
@@ -1836,10 +1836,10 @@ static int link_enter_enslave(Link *link) {
NETDEV(link->network->bridge),
NULL);
- r = netdev_enslave(link->network->bridge, link, &enslave_handler);
+ r = netdev_join(link->network->bridge, link, &netdev_join_handler);
if (r < 0) {
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%-*s: could not enslave by '%s': %s",
+ "MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, link->network->bridge->ifname, strerror(-r),
NETDEV(link->network->bridge),
@@ -1859,10 +1859,10 @@ static int link_enter_enslave(Link *link) {
NETDEV(link->network->tunnel),
NULL);
- r = netdev_enslave(link->network->tunnel, link, &enslave_handler);
+ r = netdev_join(link->network->tunnel, link, &netdev_join_handler);
if (r < 0) {
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%-*s: could not enslave by '%s': %s",
+ "MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, link->network->tunnel->ifname, strerror(-r),
NETDEV(link->network->tunnel),
@@ -1880,10 +1880,10 @@ static int link_enter_enslave(Link *link) {
IFNAMSIZ,
link->ifname, vlan->ifname, NETDEV(vlan), NULL);
- r = netdev_enslave(vlan, link, &enslave_handler);
+ r = netdev_join(vlan, link, &netdev_join_handler);
if (r < 0) {
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%-*s: could not enslave by '%s': %s",
+ "MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, vlan->ifname, strerror(-r),
NETDEV(vlan), NULL);
@@ -1900,10 +1900,10 @@ static int link_enter_enslave(Link *link) {
IFNAMSIZ,
link->ifname, macvlan->ifname, NETDEV(macvlan), NULL);
- r = netdev_enslave(macvlan, link, &enslave_handler);
+ r = netdev_join(macvlan, link, &netdev_join_handler);
if (r < 0) {
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%-*s: could not enslave by '%s': %s",
+ "MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, macvlan->ifname, strerror(-r),
NETDEV(macvlan), NULL);
@@ -1920,10 +1920,10 @@ static int link_enter_enslave(Link *link) {
IFNAMSIZ,
link->ifname, vxlan->ifname, NETDEV(vxlan), NULL);
- r = netdev_enslave(vxlan, link, &enslave_handler);
+ r = netdev_join(vxlan, link, &netdev_join_handler);
if (r < 0) {
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%*s: could not enslave by '%s': %s",
+ "MESSAGE=%*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, vxlan->ifname, strerror(-r),
NETDEV(vxlan), NULL);
@@ -2074,7 +2074,7 @@ static int link_configure(Link *link) {
return r;
}
- return link_enter_enslave(link);
+ return link_enter_join_netdev(link);
}
static int link_initialized_and_synced(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
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;
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 0f0ecd5c43..d09ab61adf 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -53,13 +53,13 @@ typedef struct Route Route;
typedef struct Manager Manager;
typedef struct AddressPool AddressPool;
-typedef struct netdev_enslave_callback netdev_enslave_callback;
+typedef struct netdev_join_callback netdev_join_callback;
-struct netdev_enslave_callback {
+struct netdev_join_callback {
sd_rtnl_message_handler_t callback;
Link *link;
- LIST_FIELDS(netdev_enslave_callback, callbacks);
+ LIST_FIELDS(netdev_join_callback, callbacks);
};
typedef enum MacVlanMode {
@@ -153,7 +153,7 @@ struct NetDev {
union in_addr_union remote;
union in_addr_union group;
- LIST_HEAD(netdev_enslave_callback, callbacks);
+ LIST_HEAD(netdev_join_callback, callbacks);
};
typedef enum DHCPSupport {
@@ -378,7 +378,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(NetDev*, netdev_unref);
int netdev_get(Manager *manager, const char *name, NetDev **ret);
int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *newlink);
-int netdev_enslave(NetDev *netdev, Link *link, sd_rtnl_message_handler_t cb);
+int netdev_join(NetDev *netdev, Link *link, sd_rtnl_message_handler_t cb);
int netdev_create_tunnel(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callback);
int netdev_create_veth(NetDev *netdev, sd_rtnl_message_handler_t callback);
int netdev_create_vxlan(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callback);