diff options
Diffstat (limited to 'src/network/netdev/batadv.c')
-rw-r--r-- | src/network/netdev/batadv.c | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/src/network/netdev/batadv.c b/src/network/netdev/batadv.c index 15f3aee3a6..2a13aa31dd 100644 --- a/src/network/netdev/batadv.c +++ b/src/network/netdev/batadv.c @@ -114,64 +114,73 @@ static int netdev_batman_set_handler(sd_netlink *rtnl, sd_netlink_message *m, Ne return 1; } -static int netdev_batadv_post_create(NetDev *netdev, Link *link, sd_netlink_message *m) { +static int netdev_batadv_post_create_message(NetDev *netdev, sd_netlink_message *message) { BatmanAdvanced *b; int r; - _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL; - assert(netdev); - - b = BATADV(netdev); - assert(b); - - r = sd_genl_message_new(netdev->manager->genl, BATADV_NL_NAME, BATADV_CMD_SET_MESH, &message); - if (r < 0) - return log_netdev_error_errno(netdev, r, "Failed to allocate generic netlink message: %m"); + assert_se(b = BATADV(netdev)); r = sd_netlink_message_append_u32(message, BATADV_ATTR_MESH_IFINDEX, netdev->ifindex); if (r < 0) - return log_netdev_error_errno(netdev, r, "Failed to set ifindex: %m"); + return r; r = sd_netlink_message_append_u8(message, BATADV_ATTR_GW_MODE, b->gateway_mode); if (r < 0) - return log_netdev_error_errno(netdev, r, "Failed to set gateway_mode: %m"); + return r; r = sd_netlink_message_append_u8(message, BATADV_ATTR_AGGREGATED_OGMS_ENABLED, b->aggregation); if (r < 0) - return log_netdev_error_errno(netdev, r, "Failed to set aggregation: %m"); + return r; r = sd_netlink_message_append_u8(message, BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED, b->bridge_loop_avoidance); if (r < 0) - return log_netdev_error_errno(netdev, r, "Failed to set bridge_loop_avoidance: %m"); + return r; r = sd_netlink_message_append_u8(message, BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED, b->distributed_arp_table); if (r < 0) - return log_netdev_error_errno(netdev, r, "Failed to set distributed_arp_table: %m"); + return r; r = sd_netlink_message_append_u8(message, BATADV_ATTR_FRAGMENTATION_ENABLED, b->fragmentation); if (r < 0) - return log_netdev_error_errno(netdev, r, "Failed to set fragmentation: %m"); + return r; r = sd_netlink_message_append_u8(message, BATADV_ATTR_HOP_PENALTY, b->hop_penalty); if (r < 0) - return log_netdev_error_errno(netdev, r, "Failed to set hop_penalty: %m"); + return r; r = sd_netlink_message_append_u32(message, BATADV_ATTR_ORIG_INTERVAL, DIV_ROUND_UP(b->originator_interval, USEC_PER_MSEC)); if (r < 0) - return log_netdev_error_errno(netdev, r, "Failed to set orig_interval: %m"); + return r; r = sd_netlink_message_append_u32(message, BATADV_ATTR_GW_BANDWIDTH_DOWN, b->gateway_bandwidth_down); if (r < 0) - return log_netdev_error_errno(netdev, r, "Failed to set gateway_bandwidth_down: %m"); + return r; r = sd_netlink_message_append_u32(message, BATADV_ATTR_GW_BANDWIDTH_UP, b->gateway_bandwidth_up); if (r < 0) - return log_netdev_error_errno(netdev, r, "Failed to set gateway_bandwidth_up: %m"); + return r; + + return 0; +} + +static int netdev_batadv_post_create(NetDev *netdev, Link *link, sd_netlink_message *m) { + _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL; + int r; + + assert(netdev); + + r = sd_genl_message_new(netdev->manager->genl, BATADV_NL_NAME, BATADV_CMD_SET_MESH, &message); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not allocate netlink message: %m"); + + r = netdev_batadv_post_create_message(netdev, message); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not create netlink message: %m"); r = netlink_call_async(netdev->manager->genl, NULL, message, netdev_batman_set_handler, netdev_destroy_callback, netdev); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not send batman device message: %m"); + return log_netdev_error_errno(netdev, r, "Could not send netlink message: %m"); netdev_ref(netdev); @@ -190,9 +199,9 @@ static int netdev_batadv_fill_message_create(NetDev *netdev, Link *link, sd_netl r = sd_netlink_message_append_string(m, IFLA_BATADV_ALGO_NAME, batadv_routing_algorithm_kernel_to_string(b->routing_algorithm)); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BATADV_ALGO_NAME attribute: %m"); + return r; - return r; + return 0; } const NetDevVTable batadv_vtable = { |