MCPcopy Index your code
hub / github.com/F-Stack/f-stack / sysctl

Function sysctl

tools/compat/sysctl.c:33–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31#include "ff_ipc.h"
32
33int
34sysctl(int *name, unsigned namelen, void *old,
35 size_t *oldlenp, const void *new, size_t newlen)
36{
37 struct ff_msg *msg, *retmsg = NULL;
38 char *extra_buf = NULL;
39 size_t total_len;
40
41 if (old != NULL && oldlenp == NULL) {
42 errno = EINVAL;
43 return -1;
44 }
45
46 msg = ff_ipc_msg_alloc();
47 if (msg == NULL) {
48 errno = ENOMEM;
49 return -1;
50 }
51
52 size_t oldlen = 0;
53 if (old && oldlenp) {
54 oldlen = *oldlenp;
55 }
56
57 total_len = namelen * sizeof(int) + sizeof(size_t) + oldlen + newlen;
58 if (total_len > msg->buf_len) {
59 extra_buf = rte_malloc(NULL, total_len, 0);
60 if (extra_buf == NULL) {
61 errno = ENOMEM;
62 ff_ipc_msg_free(msg);
63 return -1;
64 }
65 msg->original_buf = msg->buf_addr;
66 msg->original_buf_len = msg->buf_len;
67 msg->buf_addr = extra_buf;
68 msg->buf_len = total_len;
69 }
70
71 char *buf_addr = msg->buf_addr;
72
73 msg->msg_type = FF_SYSCTL;
74 msg->sysctl.name = (int *)buf_addr;
75 msg->sysctl.namelen = namelen;
76 memcpy(msg->sysctl.name, name, namelen * sizeof(int));
77
78 buf_addr += namelen * sizeof(int);
79
80 if (new != NULL && newlen != 0) {
81 msg->sysctl.new = buf_addr;
82 msg->sysctl.newlen = newlen;
83 memcpy(msg->sysctl.new, new, newlen);
84
85 buf_addr += newlen;
86 } else {
87 msg->sysctl.new = NULL;
88 msg->sysctl.newlen = 0;
89 }
90

Callers 15

parseFunction · 0.85
name2oidFunction · 0.85
oidfmtFunction · 0.85
show_varFunction · 0.85
sysctl.cFile · 0.85
sysctl_allFunction · 0.85
getifmaddrsFunction · 0.85
sysctlbynameFunction · 0.85
sysctlnametomibFunction · 0.85
getifaddrsFunction · 0.85
dumpFunction · 0.85
rtrlistFunction · 0.85

Calls 6

ff_ipc_msg_allocFunction · 0.85
rte_mallocFunction · 0.85
ff_ipc_msg_freeFunction · 0.85
ff_ipc_sendFunction · 0.85
ff_ipc_recvFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected