summaryrefslogtreecommitdiff
path: root/src/network/networkd-netdev-macvlan.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-07-16 13:17:10 +0200
committerTom Gundersen <teg@jklm.no>2014-07-21 13:32:27 +0200
commitaa9f11405829fd4755fef28602a7167dba3ddc89 (patch)
treef86bcda9b90b0e72b1f1e7ffe3f50e9c5d736612 /src/network/networkd-netdev-macvlan.c
parent653912918f594ebbca46806b302ef6b477402575 (diff)
networkd: netdev - split NetDev struct into per-kind structs
Similarly to how unit types work.
Diffstat (limited to 'src/network/networkd-netdev-macvlan.c')
-rw-r--r--src/network/networkd-netdev-macvlan.c88
1 files changed, 17 insertions, 71 deletions
diff --git a/src/network/networkd-netdev-macvlan.c b/src/network/networkd-netdev-macvlan.c
index bfa1ff1acd..2e5554a172 100644
--- a/src/network/networkd-netdev-macvlan.c
+++ b/src/network/networkd-netdev-macvlan.c
@@ -37,67 +37,16 @@ DEFINE_STRING_TABLE_LOOKUP(macvlan_mode, MacVlanMode);
DEFINE_CONFIG_PARSE_ENUM(config_parse_macvlan_mode, macvlan_mode, MacVlanMode, "Failed to parse macvlan mode");
static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_message *req) {
+ MacVlan *m = MACVLAN(netdev);
int r;
assert(netdev);
- assert(netdev->kind == NETDEV_KIND_MACVLAN);
+ assert(m);
assert(link);
assert(netdev->ifname);
- r = sd_rtnl_message_append_u32(req, IFLA_LINK, link->ifindex);
- if (r < 0) {
- log_error_netdev(netdev,
- "Could not append IFLA_LINK attribute: %s",
- strerror(-r));
- return r;
- }
-
- r = sd_rtnl_message_append_string(req, IFLA_IFNAME, netdev->ifname);
- if (r < 0) {
- log_error_netdev(netdev,
- "Could not append IFLA_IFNAME attribute: %s",
- strerror(-r));
- return r;
- }
-
- if (netdev->mtu) {
- r = sd_rtnl_message_append_u32(req, IFLA_MTU, netdev->mtu);
- if (r < 0) {
- log_error_netdev(netdev,
- "Could not append IFLA_MTU attribute: %s",
- strerror(-r));
- return r;
- }
- }
-
- if (netdev->mac) {
- r = sd_rtnl_message_append_ether_addr(req, IFLA_ADDRESS, netdev->mac);
- if (r < 0) {
- log_error_netdev(netdev,
- "Could not append IFLA_ADDRESS attribute: %s",
- strerror(-r));
- return r;
- }
- }
-
- r = sd_rtnl_message_open_container(req, IFLA_LINKINFO);
- if (r < 0) {
- log_error_netdev(netdev,
- "Could not open IFLA_LINKINFO container: %s",
- strerror(-r));
- return r;
- }
-
- r = sd_rtnl_message_open_container_union(req, IFLA_INFO_DATA, "macvlan");
- if (r < 0) {
- log_error_netdev(netdev,
- "Could not open IFLA_INFO_DATA container: %s",
- strerror(-r));
- return r;
- }
-
- if (netdev->macvlan_mode != _NETDEV_MACVLAN_MODE_INVALID) {
- r = sd_rtnl_message_append_u32(req, IFLA_MACVLAN_MODE, netdev->macvlan_mode);
+ if (m->mode != _NETDEV_MACVLAN_MODE_INVALID) {
+ r = sd_rtnl_message_append_u32(req, IFLA_MACVLAN_MODE, m->mode);
if (r < 0) {
log_error_netdev(netdev,
"Could not append IFLA_MACVLAN_MODE attribute: %s",
@@ -106,25 +55,22 @@ static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_rtn
}
}
- r = sd_rtnl_message_close_container(req);
- if (r < 0) {
- log_error_netdev(netdev,
- "Could not close IFLA_INFO_DATA container %s",
- strerror(-r));
- return r;
- }
+ return 0;
+}
- r = sd_rtnl_message_close_container(req);
- if (r < 0) {
- log_error_netdev(netdev,
- "Could not close IFLA_LINKINFO container %s",
- strerror(-r));
- return r;
- }
+static void macvlan_init(NetDev *n) {
+ MacVlan *m = MACVLAN(n);
- return 0;
+ assert(n);
+ assert(m);
+
+ m->mode = _NETDEV_MACVLAN_MODE_INVALID;
}
const NetDevVTable macvlan_vtable = {
- .fill_message_create_on_link = netdev_macvlan_fill_message_create,
+ .object_size = sizeof(MacVlan),
+ .init = macvlan_init,
+ .sections = "Match\0NetDev\0MACVLAN\0",
+ .fill_message_create = netdev_macvlan_fill_message_create,
+ .create_type = NETDEV_CREATE_STACKED,
};