diff --git a/daemon/kernel.c b/daemon/kernel.c index b54f24dfd..93bf3e0ed 100644 --- a/daemon/kernel.c +++ b/daemon/kernel.c @@ -93,14 +93,13 @@ bool kernel_init_table(void) { .msg_size = { [REMG_INIT] = sizeof(struct rtpengine_command_init), [REMG_ADD_TARGET] = sizeof(struct rtpengine_command_add_target), - [REMG_DEL_TARGET_STATS] = sizeof(struct rtpengine_command_del_target_stats), + [REMG_DEL_TARGET] = sizeof(struct rtpengine_command_del_target), [REMG_ADD_DESTINATION] = sizeof(struct rtpengine_command_destination), [REMG_ADD_CALL] = sizeof(struct rtpengine_command_add_call), [REMG_DEL_CALL] = sizeof(struct rtpengine_command_del_call), [REMG_ADD_STREAM] = sizeof(struct rtpengine_command_add_stream), [REMG_DEL_STREAM] = sizeof(struct rtpengine_command_del_stream), [REMG_PACKET] = sizeof(struct rtpengine_command_packet), - [REMG_GET_RESET_STATS] = sizeof(struct rtpengine_command_stats), [REMG_SEND_RTCP] = sizeof(struct rtpengine_command_send_packet), }, .rtpe_stats = rtpe_stats, @@ -189,15 +188,15 @@ void kernel_add_destination(struct rtpengine_destination_info *mdi) { } -bool kernel_del_stream_stats(struct rtpengine_command_del_target_stats *cmd) { +bool kernel_del_stream(struct rtpengine_command_del_target *cmd) { ssize_t ret; if (!kernel.is_open) return false; - cmd->cmd = REMG_DEL_TARGET_STATS; + cmd->cmd = REMG_DEL_TARGET; - ret = read(kernel.fd, cmd, sizeof(*cmd)); + ret = write(kernel.fd, cmd, sizeof(*cmd)); if (ret == sizeof(*cmd)) return true; @@ -255,24 +254,6 @@ unsigned int kernel_add_intercept_stream(unsigned int call_idx, const char *id) return cmd.stream.idx.stream_idx; } -// cmd->local must be filled in -bool kernel_update_stats(struct rtpengine_command_stats *cmd) { - ssize_t ret; - - if (!kernel.is_open) - return false; - - cmd->cmd = REMG_GET_RESET_STATS; - - ret = read(kernel.fd, cmd, sizeof(*cmd)); - if (ret != sizeof(*cmd)) { - ilog(LOG_ERROR, "Failed to get stream stats from kernel: %s", strerror(errno)); - return false; - } - - return true; -} - void kernel_send_rtcp(struct rtpengine_send_packet_info *info, const char *buf, size_t len) { if (!kernel.is_open) return; diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 616e23b0d..4f1f426e8 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -1764,9 +1764,9 @@ void __unkernelize(struct packet_stream *p, const char *reason) { ilog(LOG_INFO, "Removing media stream from kernel: local %s (%s)", endpoint_print_buf(&p->selected_sfd->socket.local), reason); - struct rtpengine_command_del_target_stats cmd; + struct rtpengine_command_del_target cmd; __re_address_translate_ep(&cmd.local, &p->selected_sfd->socket.local); - kernel_del_stream_stats(&cmd); + kernel_del_stream(&cmd); } PS_CLEAR(p, KERNELIZED); diff --git a/include/kernel.h b/include/kernel.h index 1a0798d01..8d22d6c24 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -34,8 +34,7 @@ void kernel_shutdown_table(void); void kernel_add_stream(struct rtpengine_target_info *); void kernel_add_destination(struct rtpengine_destination_info *); -bool kernel_del_stream_stats(struct rtpengine_command_del_target_stats *); -bool kernel_update_stats(struct rtpengine_command_stats *); +bool kernel_del_stream(struct rtpengine_command_del_target *); unsigned int kernel_add_call(const char *id); void kernel_del_call(unsigned int); diff --git a/kernel-module/xt_RTPENGINE.c b/kernel-module/xt_RTPENGINE.c index e3b3bc24d..d45302858 100644 --- a/kernel-module/xt_RTPENGINE.c +++ b/kernel-module/xt_RTPENGINE.c @@ -1723,24 +1723,6 @@ static struct re_dest_addr *find_dest_addr(const struct re_dest_addr_hash *h, co - -// retrieve and return the current stats for a target -static int table_get_target_stats(struct rtpengine_table *t, const struct re_address *local, - struct rtpengine_stats_info *i) -{ - struct rtpengine_target *g; - - g = get_target(t, local); - if (!g) - return -ENOENT; - - target_put(g); - - return 0; -} - - - // removes a target from the table and returns it static struct rtpengine_target *table_steal_target(struct rtpengine_table *t, const struct re_address *local) { unsigned char hi, lo; @@ -1793,9 +1775,7 @@ out: // removes target from table and returns the stats before releasing the target -static int table_del_target_stats(struct rtpengine_table *t, const struct re_address *local, - struct rtpengine_stats_info *i, int reset) -{ +static int table_del_target(struct rtpengine_table *t, const struct re_address *local) { struct rtpengine_target *g = table_steal_target(t, local); if (IS_ERR(g)) @@ -3667,35 +3647,28 @@ out: static const size_t min_req_sizes[__REMG_LAST] = { [REMG_INIT] = sizeof(struct rtpengine_command_init), [REMG_ADD_TARGET] = sizeof(struct rtpengine_command_add_target), - [REMG_DEL_TARGET_STATS] = sizeof(struct rtpengine_command_del_target_stats), + [REMG_DEL_TARGET] = sizeof(struct rtpengine_command_del_target), [REMG_ADD_DESTINATION] = sizeof(struct rtpengine_command_destination), [REMG_ADD_CALL] = sizeof(struct rtpengine_command_add_call), [REMG_DEL_CALL] = sizeof(struct rtpengine_command_del_call), [REMG_ADD_STREAM] = sizeof(struct rtpengine_command_add_stream), [REMG_DEL_STREAM] = sizeof(struct rtpengine_command_del_stream), [REMG_PACKET] = sizeof(struct rtpengine_command_packet), - [REMG_GET_RESET_STATS] = sizeof(struct rtpengine_command_stats), [REMG_SEND_RTCP] = sizeof(struct rtpengine_command_send_packet), }; static const size_t max_req_sizes[__REMG_LAST] = { [REMG_INIT] = sizeof(struct rtpengine_command_init), [REMG_ADD_TARGET] = sizeof(struct rtpengine_command_add_target), - [REMG_DEL_TARGET_STATS] = sizeof(struct rtpengine_command_del_target_stats), + [REMG_DEL_TARGET] = sizeof(struct rtpengine_command_del_target), [REMG_ADD_DESTINATION] = sizeof(struct rtpengine_command_destination), [REMG_ADD_CALL] = sizeof(struct rtpengine_command_add_call), [REMG_DEL_CALL] = sizeof(struct rtpengine_command_del_call), [REMG_ADD_STREAM] = sizeof(struct rtpengine_command_add_stream), [REMG_DEL_STREAM] = sizeof(struct rtpengine_command_del_stream), [REMG_PACKET] = sizeof(struct rtpengine_command_packet) + 65535, - [REMG_GET_RESET_STATS] = sizeof(struct rtpengine_command_stats), [REMG_SEND_RTCP] = sizeof(struct rtpengine_command_send_packet) + 65535, }; -static const size_t input_req_sizes[__REMG_LAST] = { - [REMG_GET_RESET_STATS] = sizeof(struct rtpengine_command_stats) - sizeof(struct rtpengine_stats_info), - [REMG_DEL_TARGET_STATS] = sizeof(struct rtpengine_command_del_target_stats) - - sizeof(struct rtpengine_stats_info), -}; static int rtpengine_init_table(struct rtpengine_table *t, struct rtpengine_init_info *init) { int i; @@ -3722,20 +3695,17 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub int err; enum rtpengine_command cmd; char scratchbuf[512]; - size_t readlen, writelen, writeoffset; union { struct rtpengine_command_init *init; struct rtpengine_command_add_target *add_target; struct rtpengine_command_del_target *del_target; - struct rtpengine_command_del_target_stats *del_target_stats; struct rtpengine_command_destination *destination; struct rtpengine_command_add_call *add_call; struct rtpengine_command_del_call *del_call; struct rtpengine_command_add_stream *add_stream; struct rtpengine_command_del_stream *del_stream; struct rtpengine_command_packet *packet; - struct rtpengine_command_stats *stats; struct rtpengine_command_send_packet *send_packet; char *storage; @@ -3779,18 +3749,8 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub goto err_free; // copy in the entire request - readlen = input_req_sizes[cmd]; - if (!readlen) { - readlen = buflen; - writelen = buflen; - writeoffset = 0; - } - else { - writelen = buflen - readlen; - writeoffset = readlen; - } err = -EFAULT; - if (copy_from_user(msg.storage, ubuf, readlen)) + if (copy_from_user(msg.storage, ubuf, buflen)) goto err_table_free; // execute command @@ -3805,23 +3765,14 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub err = table_new_target(t, &msg.add_target->target); break; - case REMG_DEL_TARGET_STATS: - err = -EINVAL; - if (writeable) - err = table_del_target_stats(t, &msg.del_target_stats->local, - &msg.del_target_stats->stats, 0); + case REMG_DEL_TARGET: + err = table_del_target(t, &msg.del_target->local); break; case REMG_ADD_DESTINATION: err = table_add_destination(t, &msg.destination->destination); break; - case REMG_GET_RESET_STATS: - err = -EINVAL; - if (writeable) - err = table_get_target_stats(t, &msg.stats->local, &msg.stats->stats); - break; - case REMG_ADD_CALL: err = -EINVAL; if (writeable) @@ -3863,7 +3814,7 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub if (writeable) { err = -EFAULT; - if (copy_to_user(ubuf + writeoffset, msg.storage + writeoffset, writelen)) + if (copy_to_user(ubuf, msg.storage, buflen)) goto err_free; } diff --git a/kernel-module/xt_RTPENGINE.h b/kernel-module/xt_RTPENGINE.h index 639daa321..dc8458f08 100644 --- a/kernel-module/xt_RTPENGINE.h +++ b/kernel-module/xt_RTPENGINE.h @@ -159,11 +159,6 @@ struct rtpengine_packet_info { unsigned char data[]; }; -struct rtpengine_stats_info { - uint32_t ssrc[RTPE_NUM_SSRC_TRACKING]; - struct ssrc_stats ssrc_stats[RTPE_NUM_SSRC_TRACKING]; -}; - enum rtpengine_command { REMG_INIT = 1, REMG_ADD_TARGET, @@ -173,8 +168,7 @@ enum rtpengine_command { REMG_ADD_STREAM, REMG_DEL_STREAM, REMG_PACKET, - REMG_GET_RESET_STATS, - REMG_DEL_TARGET_STATS, + REMG_DEL_TARGET, REMG_SEND_RTCP, __REMG_LAST @@ -204,10 +198,9 @@ struct rtpengine_command_add_target { struct rtpengine_target_info target; }; -struct rtpengine_command_del_target_stats { +struct rtpengine_command_del_target { enum rtpengine_command cmd; - struct re_address local; // input - struct rtpengine_stats_info stats; // output + struct re_address local; }; struct rtpengine_command_destination { @@ -240,12 +233,6 @@ struct rtpengine_command_packet { struct rtpengine_packet_info packet; }; -struct rtpengine_command_stats { - enum rtpengine_command cmd; - struct re_address local; // input - struct rtpengine_stats_info stats; // output -}; - struct rtpengine_command_send_packet { enum rtpengine_command cmd; struct rtpengine_send_packet_info send_packet;