MT#55283 push global rtpe_stats in shm to kernel

Require rtpe_stats to be set before allowing a target to be created.
Refactor init method into its own function.
Otherwise currently unused.

Change-Id: Ic66e7f92f875ede1a3a2d55fee4ed53c39ff93be
pull/1826/head
Richard Fuchs 2 years ago
parent 7e8acd6102
commit fa259767f1

@ -14,6 +14,7 @@
#include "log.h"
#include "bufferpool.h"
#include "main.h"
#include "statistics.h"
#include "xt_RTPENGINE.h"
@ -102,6 +103,7 @@ bool kernel_init_table(void) {
[REMG_GET_RESET_STATS] = sizeof(struct rtpengine_command_stats),
[REMG_SEND_RTCP] = sizeof(struct rtpengine_command_send_packet),
},
.rtpe_stats = rtpe_stats,
};
ret = write(kernel.fd, &cmd, sizeof(cmd));

@ -289,6 +289,13 @@ static inline int bitfield_clear(unsigned long *bf, unsigned int i);
// mirror global_stats_counter from userspace
struct global_stats_counter {
#define F(x) atomic64_t x;
#include "kernel_counter_stats_fields.inc"
#undef F
};
struct re_crypto_context {
spinlock_t lock; /* protects roc and last_*_index */
unsigned char session_key[32];
@ -433,6 +440,8 @@ struct rtpengine_table {
spinlock_t shm_lock;
struct list_head shm_list;
struct global_stats_counter *rtpe_stats;
};
struct re_cipher {
@ -2415,6 +2424,8 @@ static int table_new_target(struct rtpengine_table *t, struct rtpengine_target_i
/* validation */
if (!t->rtpe_stats)
return -EIO;
if (!is_valid_address(&i->local))
return -EINVAL;
if (i->num_destinations > RTPE_MAX_FORWARD_DESTINATIONS)
@ -3825,6 +3836,22 @@ static const size_t input_req_sizes[__REMG_LAST] = {
- sizeof(struct rtpengine_stats_info),
};
static int rtpengine_init_table(struct rtpengine_table *t, struct rtpengine_init_info *init) {
int i;
if (t->rtpe_stats)
return -EBUSY;
t->rtpe_stats = shm_map_resolve(init->rtpe_stats, sizeof(*t->rtpe_stats));
if (!t->rtpe_stats)
return -EFAULT;
if (init->last_cmd != __REMG_LAST)
return -ERANGE;
for (i = 0; i < __REMG_LAST; i++)
if (init->msg_size[i] != min_req_sizes[i])
return -EMSGSIZE;
return 0;
}
static inline ssize_t proc_control_read_write(struct file *file, char __user *ubuf, size_t buflen,
int writeable)
{
@ -3835,7 +3862,6 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub
enum rtpengine_command cmd;
char scratchbuf[512];
size_t readlen, writelen, writeoffset;
int i;
union {
struct rtpengine_command_init *init;
@ -3911,11 +3937,7 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub
switch (cmd) {
case REMG_INIT:
if (msg.init->init.last_cmd != __REMG_LAST)
err = -ERANGE;
for (i = 0; i < __REMG_LAST; i++)
if (msg.init->init.msg_size[i] != min_req_sizes[i])
err = -EMSGSIZE;
err = rtpengine_init_table(t, &msg.init->init);
break;
case REMG_ADD_TARGET:

@ -11,6 +11,8 @@
struct global_stats_counter;
struct xt_rtpengine_info {
unsigned int id;
};
@ -200,6 +202,7 @@ enum rtpengine_command {
struct rtpengine_init_info {
int last_cmd;
size_t msg_size[__REMG_LAST];
struct global_stats_counter *rtpe_stats;
};
struct rtpengine_send_packet_info {

Loading…
Cancel
Save