static int handle_userspace_msg(struct sk_buff *skb, struct genl_info *info) { int error; mutex_lock(&config_mutex); error_pool_activate(); switch (info->genlhdr->cmd) { case COMMAND_EXPECT_ADD: error = handle_expect_add(info); break; case COMMAND_EXPECT_FLUSH: error = handle_expect_flush(info); break; case COMMAND_SEND: error = handle_send(info); break; case COMMAND_STATS_DISPLAY: error = handle_stats_display(info); break; case COMMAND_STATS_FLUSH: error = handle_stats_flush(info); break; default: log_err("Unknown command code: %d", info->genlhdr->cmd); error_pool_deactivate(); return genl_respond(info, -EINVAL); } error_pool_deactivate(); mutex_unlock(&config_mutex); return error; }
/** * Gets called by Netlink when the userspace application wants to interact with us. * * @param skb packet received from userspace. */ static void receive_from_userspace(struct sk_buff *skb) { mutex_lock(&config_mutex); error_pool_activate(); netlink_rcv_skb(skb, &handle_netlink_message); error_pool_deactivate(); mutex_unlock(&config_mutex); }
int handle_jool_message(struct sk_buff *skb, struct genl_info *info) { int error; mutex_lock(&config_mutex); error_pool_activate(); error = __handle_jool_message(info); error_pool_deactivate(); mutex_unlock(&config_mutex); return error; }