diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-11-06 04:58:01 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-11-09 08:00:49 +0100 |
commit | e331889a5ebfe8625727f1bd37ebb542a2cfb7b2 (patch) | |
tree | 1f83f3b60493a932705465d0c2a6ef09db7e0751 /src/network | |
parent | network: geneve: use fill_message_create (diff) | |
download | systemd-e331889a5ebfe8625727f1bd37ebb542a2cfb7b2.tar.xz systemd-e331889a5ebfe8625727f1bd37ebb542a2cfb7b2.zip |
network: bareudp: use fill_message_create
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/netdev/bareudp.c | 64 |
1 files changed, 4 insertions, 60 deletions
diff --git a/src/network/netdev/bareudp.c b/src/network/netdev/bareudp.c index e210625ac5..8c0c895a0d 100644 --- a/src/network/netdev/bareudp.c +++ b/src/network/netdev/bareudp.c @@ -17,55 +17,17 @@ DEFINE_STRING_TABLE_LOOKUP(bare_udp_protocol, BareUDPProtocol); DEFINE_CONFIG_PARSE_ENUM(config_parse_bare_udp_iftype, bare_udp_protocol, BareUDPProtocol, "Failed to parse EtherType="); -/* callback for bareudp netdev's created without a backing Link */ -static int bare_udp_netdev_create_handler(sd_netlink *rtnl, sd_netlink_message *m, NetDev *netdev) { - int r; - - assert(netdev); - assert(netdev->state != _NETDEV_STATE_INVALID); - - r = sd_netlink_message_get_errno(m); - if (r == -EEXIST) - log_netdev_info(netdev, "BareUDP netdev exists, using existing without changing its parameters."); - else if (r < 0) { - log_netdev_warning_errno(netdev, r, "BareUDP netdev could not be created: %m"); - netdev_enter_failed(netdev); - - return 1; - } - - log_netdev_debug(netdev, "BareUDP created."); - - return 1; -} - -static int netdev_bare_udp_create(NetDev *netdev) { - _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL; +static int netdev_bare_udp_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) { BareUDP *u; int r; assert(netdev); + assert(m); u = BAREUDP(netdev); assert(u); - r = sd_rtnl_message_new_link(netdev->manager->rtnl, &m, RTM_NEWLINK, 0); - if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not allocate RTM_NEWLINK message: %m"); - - r = sd_netlink_message_append_string(m, IFLA_IFNAME, netdev->ifname); - if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_IFNAME, attribute: %m"); - - r = sd_netlink_message_open_container(m, IFLA_LINKINFO); - if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_LINKINFO attribute: %m"); - - r = sd_netlink_message_open_container_union(m, IFLA_INFO_DATA, netdev_kind_to_string(netdev->kind)); - if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_INFO_DATA attribute: %m"); - r = sd_netlink_message_append_u16(m, IFLA_BAREUDP_ETHERTYPE, htobe16(u->iftype)); if (r < 0) return log_netdev_error_errno(netdev, r, "Could not append IFLA_BAREUDP_ETHERTYPE attribute: %m"); @@ -74,25 +36,7 @@ static int netdev_bare_udp_create(NetDev *netdev) { if (r < 0) return log_netdev_error_errno(netdev, r, "Could not append IFLA_BAREUDP_PORT attribute: %m"); - r = sd_netlink_message_close_container(m); - if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_INFO_DATA attribute: %m"); - - r = sd_netlink_message_close_container(m); - if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_LINKINFO attribute: %m"); - - r = netlink_call_async(netdev->manager->rtnl, NULL, m, bare_udp_netdev_create_handler, - netdev_destroy_callback, netdev); - if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not send rtnetlink message: %m"); - - netdev_ref(netdev); - netdev->state = NETDEV_STATE_CREATING; - - log_netdev_debug(netdev, "Creating"); - - return r; + return 0; } static int netdev_bare_udp_verify(NetDev *netdev, const char *filename) { @@ -133,6 +77,6 @@ const NetDevVTable bare_udp_vtable = { .sections = NETDEV_COMMON_SECTIONS "BareUDP\0", .init = bare_udp_init, .config_verify = netdev_bare_udp_verify, - .create = netdev_bare_udp_create, + .fill_message_create = netdev_bare_udp_fill_message_create, .create_type = NETDEV_CREATE_INDEPENDENT, }; |