MT#55283 remove vestiges of kernel<>user stats

Change-Id: I447959e65cea837431b8b602d6339ba4f98e70c5
pull/1826/head
Richard Fuchs 2 years ago
parent f389b42ab4
commit 74f07ccc41

@ -93,14 +93,13 @@ bool kernel_init_table(void) {
.msg_size = { .msg_size = {
[REMG_INIT] = sizeof(struct rtpengine_command_init), [REMG_INIT] = sizeof(struct rtpengine_command_init),
[REMG_ADD_TARGET] = sizeof(struct rtpengine_command_add_target), [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_DESTINATION] = sizeof(struct rtpengine_command_destination),
[REMG_ADD_CALL] = sizeof(struct rtpengine_command_add_call), [REMG_ADD_CALL] = sizeof(struct rtpengine_command_add_call),
[REMG_DEL_CALL] = sizeof(struct rtpengine_command_del_call), [REMG_DEL_CALL] = sizeof(struct rtpengine_command_del_call),
[REMG_ADD_STREAM] = sizeof(struct rtpengine_command_add_stream), [REMG_ADD_STREAM] = sizeof(struct rtpengine_command_add_stream),
[REMG_DEL_STREAM] = sizeof(struct rtpengine_command_del_stream), [REMG_DEL_STREAM] = sizeof(struct rtpengine_command_del_stream),
[REMG_PACKET] = sizeof(struct rtpengine_command_packet), [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), [REMG_SEND_RTCP] = sizeof(struct rtpengine_command_send_packet),
}, },
.rtpe_stats = rtpe_stats, .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; ssize_t ret;
if (!kernel.is_open) if (!kernel.is_open)
return false; 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)) if (ret == sizeof(*cmd))
return true; 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; 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) { void kernel_send_rtcp(struct rtpengine_send_packet_info *info, const char *buf, size_t len) {
if (!kernel.is_open) if (!kernel.is_open)
return; return;

@ -1764,9 +1764,9 @@ void __unkernelize(struct packet_stream *p, const char *reason) {
ilog(LOG_INFO, "Removing media stream from kernel: local %s (%s)", ilog(LOG_INFO, "Removing media stream from kernel: local %s (%s)",
endpoint_print_buf(&p->selected_sfd->socket.local), endpoint_print_buf(&p->selected_sfd->socket.local),
reason); 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); __re_address_translate_ep(&cmd.local, &p->selected_sfd->socket.local);
kernel_del_stream_stats(&cmd); kernel_del_stream(&cmd);
} }
PS_CLEAR(p, KERNELIZED); PS_CLEAR(p, KERNELIZED);

@ -34,8 +34,7 @@ void kernel_shutdown_table(void);
void kernel_add_stream(struct rtpengine_target_info *); void kernel_add_stream(struct rtpengine_target_info *);
void kernel_add_destination(struct rtpengine_destination_info *); void kernel_add_destination(struct rtpengine_destination_info *);
bool kernel_del_stream_stats(struct rtpengine_command_del_target_stats *); bool kernel_del_stream(struct rtpengine_command_del_target *);
bool kernel_update_stats(struct rtpengine_command_stats *);
unsigned int kernel_add_call(const char *id); unsigned int kernel_add_call(const char *id);
void kernel_del_call(unsigned int); void kernel_del_call(unsigned int);

@ -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 // 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) { static struct rtpengine_target *table_steal_target(struct rtpengine_table *t, const struct re_address *local) {
unsigned char hi, lo; unsigned char hi, lo;
@ -1793,9 +1775,7 @@ out:
// removes target from table and returns the stats before releasing the target // 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, static int table_del_target(struct rtpengine_table *t, const struct re_address *local) {
struct rtpengine_stats_info *i, int reset)
{
struct rtpengine_target *g = table_steal_target(t, local); struct rtpengine_target *g = table_steal_target(t, local);
if (IS_ERR(g)) if (IS_ERR(g))
@ -3667,35 +3647,28 @@ out:
static const size_t min_req_sizes[__REMG_LAST] = { static const size_t min_req_sizes[__REMG_LAST] = {
[REMG_INIT] = sizeof(struct rtpengine_command_init), [REMG_INIT] = sizeof(struct rtpengine_command_init),
[REMG_ADD_TARGET] = sizeof(struct rtpengine_command_add_target), [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_DESTINATION] = sizeof(struct rtpengine_command_destination),
[REMG_ADD_CALL] = sizeof(struct rtpengine_command_add_call), [REMG_ADD_CALL] = sizeof(struct rtpengine_command_add_call),
[REMG_DEL_CALL] = sizeof(struct rtpengine_command_del_call), [REMG_DEL_CALL] = sizeof(struct rtpengine_command_del_call),
[REMG_ADD_STREAM] = sizeof(struct rtpengine_command_add_stream), [REMG_ADD_STREAM] = sizeof(struct rtpengine_command_add_stream),
[REMG_DEL_STREAM] = sizeof(struct rtpengine_command_del_stream), [REMG_DEL_STREAM] = sizeof(struct rtpengine_command_del_stream),
[REMG_PACKET] = sizeof(struct rtpengine_command_packet), [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), [REMG_SEND_RTCP] = sizeof(struct rtpengine_command_send_packet),
}; };
static const size_t max_req_sizes[__REMG_LAST] = { static const size_t max_req_sizes[__REMG_LAST] = {
[REMG_INIT] = sizeof(struct rtpengine_command_init), [REMG_INIT] = sizeof(struct rtpengine_command_init),
[REMG_ADD_TARGET] = sizeof(struct rtpengine_command_add_target), [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_DESTINATION] = sizeof(struct rtpengine_command_destination),
[REMG_ADD_CALL] = sizeof(struct rtpengine_command_add_call), [REMG_ADD_CALL] = sizeof(struct rtpengine_command_add_call),
[REMG_DEL_CALL] = sizeof(struct rtpengine_command_del_call), [REMG_DEL_CALL] = sizeof(struct rtpengine_command_del_call),
[REMG_ADD_STREAM] = sizeof(struct rtpengine_command_add_stream), [REMG_ADD_STREAM] = sizeof(struct rtpengine_command_add_stream),
[REMG_DEL_STREAM] = sizeof(struct rtpengine_command_del_stream), [REMG_DEL_STREAM] = sizeof(struct rtpengine_command_del_stream),
[REMG_PACKET] = sizeof(struct rtpengine_command_packet) + 65535, [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, [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) { static int rtpengine_init_table(struct rtpengine_table *t, struct rtpengine_init_info *init) {
int i; int i;
@ -3722,20 +3695,17 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub
int err; int err;
enum rtpengine_command cmd; enum rtpengine_command cmd;
char scratchbuf[512]; char scratchbuf[512];
size_t readlen, writelen, writeoffset;
union { union {
struct rtpengine_command_init *init; struct rtpengine_command_init *init;
struct rtpengine_command_add_target *add_target; struct rtpengine_command_add_target *add_target;
struct rtpengine_command_del_target *del_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_destination *destination;
struct rtpengine_command_add_call *add_call; struct rtpengine_command_add_call *add_call;
struct rtpengine_command_del_call *del_call; struct rtpengine_command_del_call *del_call;
struct rtpengine_command_add_stream *add_stream; struct rtpengine_command_add_stream *add_stream;
struct rtpengine_command_del_stream *del_stream; struct rtpengine_command_del_stream *del_stream;
struct rtpengine_command_packet *packet; struct rtpengine_command_packet *packet;
struct rtpengine_command_stats *stats;
struct rtpengine_command_send_packet *send_packet; struct rtpengine_command_send_packet *send_packet;
char *storage; char *storage;
@ -3779,18 +3749,8 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub
goto err_free; goto err_free;
// copy in the entire request // 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; err = -EFAULT;
if (copy_from_user(msg.storage, ubuf, readlen)) if (copy_from_user(msg.storage, ubuf, buflen))
goto err_table_free; goto err_table_free;
// execute command // 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); err = table_new_target(t, &msg.add_target->target);
break; break;
case REMG_DEL_TARGET_STATS: case REMG_DEL_TARGET:
err = -EINVAL; err = table_del_target(t, &msg.del_target->local);
if (writeable)
err = table_del_target_stats(t, &msg.del_target_stats->local,
&msg.del_target_stats->stats, 0);
break; break;
case REMG_ADD_DESTINATION: case REMG_ADD_DESTINATION:
err = table_add_destination(t, &msg.destination->destination); err = table_add_destination(t, &msg.destination->destination);
break; 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: case REMG_ADD_CALL:
err = -EINVAL; err = -EINVAL;
if (writeable) if (writeable)
@ -3863,7 +3814,7 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub
if (writeable) { if (writeable) {
err = -EFAULT; err = -EFAULT;
if (copy_to_user(ubuf + writeoffset, msg.storage + writeoffset, writelen)) if (copy_to_user(ubuf, msg.storage, buflen))
goto err_free; goto err_free;
} }

@ -159,11 +159,6 @@ struct rtpengine_packet_info {
unsigned char data[]; 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 { enum rtpengine_command {
REMG_INIT = 1, REMG_INIT = 1,
REMG_ADD_TARGET, REMG_ADD_TARGET,
@ -173,8 +168,7 @@ enum rtpengine_command {
REMG_ADD_STREAM, REMG_ADD_STREAM,
REMG_DEL_STREAM, REMG_DEL_STREAM,
REMG_PACKET, REMG_PACKET,
REMG_GET_RESET_STATS, REMG_DEL_TARGET,
REMG_DEL_TARGET_STATS,
REMG_SEND_RTCP, REMG_SEND_RTCP,
__REMG_LAST __REMG_LAST
@ -204,10 +198,9 @@ struct rtpengine_command_add_target {
struct rtpengine_target_info target; struct rtpengine_target_info target;
}; };
struct rtpengine_command_del_target_stats { struct rtpengine_command_del_target {
enum rtpengine_command cmd; enum rtpengine_command cmd;
struct re_address local; // input struct re_address local;
struct rtpengine_stats_info stats; // output
}; };
struct rtpengine_command_destination { struct rtpengine_command_destination {
@ -240,12 +233,6 @@ struct rtpengine_command_packet {
struct rtpengine_packet_info 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 { struct rtpengine_command_send_packet {
enum rtpengine_command cmd; enum rtpengine_command cmd;
struct rtpengine_send_packet_info send_packet; struct rtpengine_send_packet_info send_packet;

Loading…
Cancel
Save