Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 1 | /* |
Florin Coras | 5e06257 | 2019-03-14 19:07:51 -0700 | [diff] [blame] | 2 | * Copyright (c) 2018-2019 Cisco and/or its affiliates. |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #include <vcl/vcl_private.h> |
| 17 | |
| 18 | /* NOTE: _vppcom_main is only used until the heap is allocated. |
| 19 | * Do not access it directly -- use vcm which will point to |
| 20 | * the heap allocated copy after init. |
| 21 | */ |
Florin Coras | ce815de | 2020-04-16 18:47:27 +0000 | [diff] [blame] | 22 | vppcom_main_t _vppcom_main = { |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 23 | .debug = VPPCOM_DEBUG_INIT, |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 24 | .is_init = 0, |
Florin Coras | c1f5a43 | 2018-11-20 11:31:26 -0800 | [diff] [blame] | 25 | .app_index = ~0, |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 26 | }; |
| 27 | |
| 28 | vppcom_main_t *vcm = &_vppcom_main; |
| 29 | |
| 30 | void |
| 31 | vppcom_cfg_init (vppcom_cfg_t * vcl_cfg) |
| 32 | { |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 33 | ASSERT (vcl_cfg); |
| 34 | |
| 35 | vcl_cfg->heapsize = (256ULL << 20); |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 36 | vcl_cfg->max_workers = 16; |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 37 | vcl_cfg->vpp_api_q_length = 1024; |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 38 | vcl_cfg->segment_baseva = HIGH_SEGMENT_BASEVA; |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 39 | vcl_cfg->segment_size = (256 << 20); |
| 40 | vcl_cfg->add_segment_size = (128 << 20); |
| 41 | vcl_cfg->preallocated_fifo_pairs = 8; |
| 42 | vcl_cfg->rx_fifo_size = (1 << 20); |
| 43 | vcl_cfg->tx_fifo_size = (1 << 20); |
| 44 | vcl_cfg->event_queue_size = 2048; |
| 45 | vcl_cfg->listen_queue_size = CLIB_CACHE_LINE_BYTES / sizeof (u32); |
| 46 | vcl_cfg->app_timeout = 10 * 60.0; |
| 47 | vcl_cfg->session_timeout = 10 * 60.0; |
| 48 | vcl_cfg->accept_timeout = 60.0; |
| 49 | vcl_cfg->event_ring_size = (128 << 10); |
| 50 | vcl_cfg->event_log_path = "/dev/shm"; |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 53 | #define VCFG_DBG(_lvl, _fmt, _args...) \ |
| 54 | { \ |
Florin Coras | 54693d2 | 2018-07-17 10:46:29 -0700 | [diff] [blame] | 55 | if (vcm->debug > _lvl) \ |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 56 | fprintf (stderr, _fmt "\n", ##_args); \ |
| 57 | } |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 58 | void |
| 59 | vppcom_cfg_heapsize (char *conf_fname) |
| 60 | { |
| 61 | vppcom_cfg_t *vcl_cfg = &vcm->cfg; |
| 62 | FILE *fp; |
| 63 | char inbuf[4096]; |
| 64 | int argc = 1; |
| 65 | char **argv = NULL; |
| 66 | char *arg = NULL; |
| 67 | char *p; |
| 68 | int i; |
| 69 | u8 *sizep; |
| 70 | u32 size; |
| 71 | void *vcl_mem; |
| 72 | void *heap; |
| 73 | |
| 74 | fp = fopen (conf_fname, "r"); |
| 75 | if (fp == NULL) |
| 76 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 77 | VCFG_DBG (0, "VCL<%d>: using default heapsize %lu (0x%lx)", |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 78 | getpid (), (unsigned long) vcl_cfg->heapsize, |
| 79 | (unsigned long) vcl_cfg->heapsize); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 80 | goto defaulted; |
| 81 | } |
| 82 | |
| 83 | argv = calloc (1, sizeof (char *)); |
| 84 | if (argv == NULL) |
| 85 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 86 | VCFG_DBG (0, "VCL<%d>: calloc failed, using default heapsize %lu" |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 87 | " (0x%lx)", getpid (), (unsigned long) vcl_cfg->heapsize, |
| 88 | (unsigned long) vcl_cfg->heapsize); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 89 | goto defaulted; |
| 90 | } |
| 91 | |
| 92 | while (1) |
| 93 | { |
| 94 | if (fgets (inbuf, 4096, fp) == 0) |
| 95 | break; |
| 96 | p = strtok (inbuf, " \t\n"); |
| 97 | while (p != NULL) |
| 98 | { |
| 99 | if (*p == '#') |
| 100 | break; |
| 101 | argc++; |
| 102 | char **tmp = realloc (argv, argc * sizeof (char *)); |
| 103 | if (tmp == NULL) |
| 104 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 105 | VCFG_DBG (0, "VCL<%d>: realloc failed, using default " |
| 106 | "heapsize %lu (0x%lx)", getpid (), |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 107 | (unsigned long) vcl_cfg->heapsize, |
| 108 | (unsigned long) vcl_cfg->heapsize); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 109 | goto defaulted; |
| 110 | } |
| 111 | argv = tmp; |
| 112 | arg = strndup (p, 1024); |
| 113 | if (arg == NULL) |
| 114 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 115 | VCFG_DBG (0, "VCL<%d>: strndup failed, using default " |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 116 | "heapsize %lu (0x%lx)", getpid (), |
| 117 | (unsigned long) vcl_cfg->heapsize, |
| 118 | (unsigned long) vcl_cfg->heapsize); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 119 | goto defaulted; |
| 120 | } |
| 121 | argv[argc - 1] = arg; |
| 122 | p = strtok (NULL, " \t\n"); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | fclose (fp); |
| 127 | fp = NULL; |
| 128 | |
| 129 | char **tmp = realloc (argv, (argc + 1) * sizeof (char *)); |
| 130 | if (tmp == NULL) |
| 131 | { |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 132 | VCFG_DBG (0, "VCL<%d>: realloc failed, using default heapsize %lu " |
| 133 | "(0x%lx)", getpid (), (unsigned long) vcl_cfg->heapsize, |
| 134 | (unsigned long) vcl_cfg->heapsize); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 135 | goto defaulted; |
| 136 | } |
| 137 | argv = tmp; |
| 138 | argv[argc] = NULL; |
| 139 | |
| 140 | /* |
| 141 | * Look for and parse the "heapsize" config parameter. |
| 142 | * Manual since none of the clib infra has been bootstrapped yet. |
| 143 | * |
| 144 | * Format: heapsize <nn>[mM][gG] |
| 145 | */ |
| 146 | |
| 147 | for (i = 1; i < (argc - 1); i++) |
| 148 | { |
| 149 | if (!strncmp (argv[i], "heapsize", 8)) |
| 150 | { |
| 151 | sizep = (u8 *) argv[i + 1]; |
| 152 | size = 0; |
| 153 | while (*sizep >= '0' && *sizep <= '9') |
| 154 | { |
| 155 | size *= 10; |
| 156 | size += *sizep++ - '0'; |
| 157 | } |
| 158 | if (size == 0) |
| 159 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 160 | VCFG_DBG (0, "VCL<%d>: parse error '%s %s', using default " |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 161 | "heapsize %lu (0x%lx)", getpid (), argv[i], |
| 162 | argv[i + 1], (unsigned long) vcl_cfg->heapsize, |
| 163 | (unsigned long) vcl_cfg->heapsize); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 164 | goto defaulted; |
| 165 | } |
| 166 | |
| 167 | if (*sizep == 'g' || *sizep == 'G') |
| 168 | vcl_cfg->heapsize = size << 30; |
| 169 | else if (*sizep == 'm' || *sizep == 'M') |
| 170 | vcl_cfg->heapsize = size << 20; |
| 171 | else |
| 172 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 173 | VCFG_DBG (0, "VCL<%d>: parse error '%s %s', using default " |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 174 | "heapsize %lu (0x%lx)", getpid (), argv[i], |
| 175 | argv[i + 1], (unsigned long) vcl_cfg->heapsize, |
| 176 | (unsigned long) vcl_cfg->heapsize); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 177 | goto defaulted; |
| 178 | } |
| 179 | } |
Florin Coras | 053a0e4 | 2018-11-13 15:52:38 -0800 | [diff] [blame] | 180 | free (argv[i]); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | defaulted: |
| 184 | if (fp != NULL) |
| 185 | fclose (fp); |
| 186 | if (argv != NULL) |
| 187 | free (argv); |
| 188 | |
| 189 | vcl_mem = mmap (0, vcl_cfg->heapsize, PROT_READ | PROT_WRITE, |
| 190 | MAP_SHARED | MAP_ANONYMOUS, -1, 0); |
| 191 | if (vcl_mem == MAP_FAILED) |
| 192 | { |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 193 | VCFG_DBG (0, "VCL<%d>: ERROR: mmap(0, %lu == 0x%lx, " |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 194 | "PROT_READ | PROT_WRITE,MAP_SHARED | MAP_ANONYMOUS, " |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 195 | "-1, 0) failed!", getpid (), |
| 196 | (unsigned long) vcl_cfg->heapsize, |
| 197 | (unsigned long) vcl_cfg->heapsize); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 198 | ASSERT (vcl_mem != MAP_FAILED); |
| 199 | return; |
| 200 | } |
Dave Barach | 6a5adc3 | 2018-07-04 10:56:23 -0400 | [diff] [blame] | 201 | heap = clib_mem_init_thread_safe (vcl_mem, vcl_cfg->heapsize); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 202 | if (!heap) |
| 203 | { |
Florin Coras | 54693d2 | 2018-07-17 10:46:29 -0700 | [diff] [blame] | 204 | fprintf (stderr, "VCL<%d>: ERROR: clib_mem_init() failed!", getpid ()); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 205 | ASSERT (heap); |
| 206 | return; |
| 207 | } |
| 208 | vcl_mem = clib_mem_alloc (sizeof (_vppcom_main)); |
| 209 | if (!vcl_mem) |
| 210 | { |
| 211 | clib_warning ("VCL<%d>: ERROR: clib_mem_alloc() failed!", getpid ()); |
| 212 | ASSERT (vcl_mem); |
| 213 | return; |
| 214 | } |
| 215 | |
| 216 | clib_memcpy (vcl_mem, &_vppcom_main, sizeof (_vppcom_main)); |
| 217 | vcm = vcl_mem; |
| 218 | |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 219 | VCFG_DBG (0, "VCL<%d>: allocated VCL heap = %p, size %lu (0x%lx)", |
| 220 | getpid (), heap, (unsigned long) vcl_cfg->heapsize, |
| 221 | (unsigned long) vcl_cfg->heapsize); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | void |
| 225 | vppcom_cfg_read_file (char *conf_fname) |
| 226 | { |
| 227 | vppcom_cfg_t *vcl_cfg = &vcm->cfg; |
| 228 | int fd; |
| 229 | unformat_input_t _input, *input = &_input; |
| 230 | unformat_input_t _line_input, *line_input = &_line_input; |
Florin Coras | d4c7092 | 2019-11-28 14:21:21 -0800 | [diff] [blame] | 231 | u8 vc_cfg_input = 0; |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 232 | struct stat s; |
| 233 | u32 uid, gid, q_len; |
| 234 | |
| 235 | fd = open (conf_fname, O_RDONLY); |
| 236 | if (fd < 0) |
| 237 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 238 | VCFG_DBG (0, "VCL<%d>: using default configuration.", getpid ()); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 239 | goto file_done; |
| 240 | } |
| 241 | |
| 242 | if (fstat (fd, &s) < 0) |
| 243 | { |
Florin Coras | 053a0e4 | 2018-11-13 15:52:38 -0800 | [diff] [blame] | 244 | VCFG_DBG (0, "VCL<%d>: failed to stat `%s' using default configuration", |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 245 | getpid (), conf_fname); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 246 | goto file_done; |
| 247 | } |
| 248 | |
| 249 | if (!(S_ISREG (s.st_mode) || S_ISLNK (s.st_mode))) |
| 250 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 251 | VCFG_DBG (0, "VCL<%d>: not a regular file `%s', using default " |
| 252 | "configuration", getpid (), conf_fname); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 253 | goto file_done; |
| 254 | } |
| 255 | |
| 256 | unformat_init_clib_file (input, fd); |
| 257 | |
| 258 | while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) |
| 259 | { |
| 260 | (void) unformat_user (input, unformat_line_input, line_input); |
| 261 | unformat_skip_white_space (line_input); |
| 262 | |
| 263 | if (unformat (line_input, "vcl {")) |
| 264 | { |
| 265 | vc_cfg_input = 1; |
Florin Coras | 053a0e4 | 2018-11-13 15:52:38 -0800 | [diff] [blame] | 266 | unformat_free (line_input); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 267 | continue; |
| 268 | } |
| 269 | |
| 270 | if (vc_cfg_input) |
| 271 | { |
Florin Coras | 053a0e4 | 2018-11-13 15:52:38 -0800 | [diff] [blame] | 272 | if (unformat (line_input, "heapsize %U", unformat_memory_size, |
| 273 | &vcl_cfg->heapsize)) |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 274 | { |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 275 | VCFG_DBG (0, "VCL<%d>: configured heapsize %lu", getpid (), |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 276 | (unsigned long) vcl_cfg->heapsize); |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 277 | } |
Florin Coras | 053a0e4 | 2018-11-13 15:52:38 -0800 | [diff] [blame] | 278 | else |
| 279 | if (unformat |
| 280 | (line_input, "max-workers %u", &vcl_cfg->max_workers)) |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 281 | { |
| 282 | VCFG_DBG (0, "VCL<%d>: configured max-workers %u", getpid (), |
| 283 | vcl_cfg->max_workers); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 284 | } |
Florin Coras | d4c7092 | 2019-11-28 14:21:21 -0800 | [diff] [blame] | 285 | else if (unformat (line_input, "api-prefix %s", |
| 286 | &vcl_cfg->vpp_api_chroot)) |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 287 | { |
Florin Coras | d4c7092 | 2019-11-28 14:21:21 -0800 | [diff] [blame] | 288 | vec_terminate_c_string (vcl_cfg->vpp_api_chroot); |
| 289 | VCFG_DBG (0, "VCL<%d>: configured api-prefix (%s) ", getpid (), |
| 290 | vcl_cfg->vpp_api_chroot); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 291 | } |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 292 | else if (unformat (line_input, "api-socket-name %s", |
| 293 | &vcl_cfg->vpp_api_socket_name)) |
| 294 | { |
| 295 | vec_terminate_c_string (vcl_cfg->vpp_api_socket_name); |
| 296 | VCFG_DBG (0, "VCL<%d>: configured api-socket-name (%s)", |
| 297 | getpid (), vcl_cfg->vpp_api_socket_name); |
| 298 | } |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 299 | else if (unformat (line_input, "vpp-api-q-length %d", &q_len)) |
| 300 | { |
| 301 | if (q_len < vcl_cfg->vpp_api_q_length) |
| 302 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 303 | fprintf (stderr, |
| 304 | "VCL<%d>: ERROR: configured vpp-api-q-length " |
| 305 | "(%u) is too small! Using default: %u ", getpid (), |
| 306 | q_len, vcl_cfg->vpp_api_q_length); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 307 | } |
| 308 | else |
| 309 | { |
| 310 | vcl_cfg->vpp_api_q_length = q_len; |
| 311 | |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 312 | VCFG_DBG (0, "VCL<%d>: configured vpp-api-q-length %u", |
| 313 | getpid (), vcl_cfg->vpp_api_q_length); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 314 | } |
| 315 | } |
| 316 | else if (unformat (line_input, "uid %d", &uid)) |
| 317 | { |
| 318 | vl_set_memory_uid (uid); |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 319 | VCFG_DBG (0, "VCL<%d>: configured uid %d", getpid (), uid); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 320 | } |
| 321 | else if (unformat (line_input, "gid %d", &gid)) |
| 322 | { |
| 323 | vl_set_memory_gid (gid); |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 324 | VCFG_DBG (0, "VCL<%d>: configured gid %d", getpid (), gid); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 325 | } |
Florin Coras | d18528f | 2020-03-27 18:41:54 +0000 | [diff] [blame] | 326 | else if (unformat (line_input, "segment-baseva 0x%lx", |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 327 | &vcl_cfg->segment_baseva)) |
| 328 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 329 | VCFG_DBG (0, "VCL<%d>: configured segment_baseva 0x%lx", |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 330 | getpid (), (unsigned long) vcl_cfg->segment_baseva); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 331 | } |
Florin Coras | d18528f | 2020-03-27 18:41:54 +0000 | [diff] [blame] | 332 | else if (unformat (line_input, "segment-size 0x%lx", |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 333 | &vcl_cfg->segment_size)) |
| 334 | { |
Florin Coras | d18528f | 2020-03-27 18:41:54 +0000 | [diff] [blame] | 335 | VCFG_DBG (0, "VCL<%d>: configured segment_size 0x%lx (%lu)", |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 336 | getpid (), vcl_cfg->segment_size, |
| 337 | vcl_cfg->segment_size); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 338 | } |
Florin Coras | d18528f | 2020-03-27 18:41:54 +0000 | [diff] [blame] | 339 | else if (unformat (line_input, "segment-size %lu", |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 340 | &vcl_cfg->segment_size)) |
| 341 | { |
Florin Coras | d18528f | 2020-03-27 18:41:54 +0000 | [diff] [blame] | 342 | VCFG_DBG (0, "VCL<%d>: configured segment_size %lu (0x%lx)", |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 343 | getpid (), vcl_cfg->segment_size, |
| 344 | vcl_cfg->segment_size); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 345 | } |
Florin Coras | d18528f | 2020-03-27 18:41:54 +0000 | [diff] [blame] | 346 | else if (unformat (line_input, "add-segment-size 0x%lx", |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 347 | &vcl_cfg->add_segment_size)) |
| 348 | { |
Florin Coras | d18528f | 2020-03-27 18:41:54 +0000 | [diff] [blame] | 349 | VCFG_DBG (0, "VCL<%d>: configured add_segment_size 0x%lx (%lu)", |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 350 | getpid (), vcl_cfg->add_segment_size, |
| 351 | vcl_cfg->add_segment_size); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 352 | } |
Florin Coras | d18528f | 2020-03-27 18:41:54 +0000 | [diff] [blame] | 353 | else if (unformat (line_input, "add-segment-size %lu", |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 354 | &vcl_cfg->add_segment_size)) |
| 355 | { |
Florin Coras | d18528f | 2020-03-27 18:41:54 +0000 | [diff] [blame] | 356 | VCFG_DBG (0, "VCL<%d>: configured add_segment_size %lu (0x%lx)", |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 357 | getpid (), vcl_cfg->add_segment_size, |
| 358 | vcl_cfg->add_segment_size); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 359 | } |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 360 | else if (unformat (line_input, "preallocated-fifo-pairs %u", |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 361 | &vcl_cfg->preallocated_fifo_pairs)) |
| 362 | { |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 363 | VCFG_DBG (0, "VCL<%d>: configured preallocated_fifo_pairs %u " |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 364 | "(0x%x)", getpid (), vcl_cfg->preallocated_fifo_pairs, |
| 365 | vcl_cfg->preallocated_fifo_pairs); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 366 | } |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 367 | else if (unformat (line_input, "rx-fifo-size 0x%x", |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 368 | &vcl_cfg->rx_fifo_size)) |
| 369 | { |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 370 | VCFG_DBG (0, "VCL<%d>: configured rx_fifo_size 0x%x (%u)", |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 371 | getpid (), vcl_cfg->rx_fifo_size, |
| 372 | vcl_cfg->rx_fifo_size); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 373 | } |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 374 | else if (unformat (line_input, "rx-fifo-size %u", |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 375 | &vcl_cfg->rx_fifo_size)) |
| 376 | { |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 377 | VCFG_DBG (0, "VCL<%d>: configured rx_fifo_size %u (0x%x)", |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 378 | getpid (), vcl_cfg->rx_fifo_size, |
| 379 | vcl_cfg->rx_fifo_size); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 380 | } |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 381 | else if (unformat (line_input, "tx-fifo-size 0x%x", |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 382 | &vcl_cfg->tx_fifo_size)) |
| 383 | { |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 384 | VCFG_DBG (0, "VCL<%d>: configured tx_fifo_size 0x%x (%u)", |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 385 | getpid (), vcl_cfg->tx_fifo_size, |
| 386 | vcl_cfg->tx_fifo_size); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 387 | } |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 388 | else if (unformat (line_input, "tx-fifo-size %u", |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 389 | &vcl_cfg->tx_fifo_size)) |
| 390 | { |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 391 | VCFG_DBG (0, "VCL<%d>: configured tx_fifo_size %u (0x%x)", |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 392 | getpid (), vcl_cfg->tx_fifo_size, |
| 393 | vcl_cfg->tx_fifo_size); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 394 | } |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 395 | else if (unformat (line_input, "event-queue-size 0x%x", |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 396 | &vcl_cfg->event_queue_size)) |
| 397 | { |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 398 | VCFG_DBG (0, "VCL<%d>: configured event_queue_size 0x%x (%u)", |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 399 | getpid (), vcl_cfg->event_queue_size, |
| 400 | vcl_cfg->event_queue_size); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 401 | } |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 402 | else if (unformat (line_input, "event-queue-size %u", |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 403 | &vcl_cfg->event_queue_size)) |
| 404 | { |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 405 | VCFG_DBG (0, "VCL<%d>: configured event_queue_size %u (0x%x)", |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 406 | getpid (), vcl_cfg->event_queue_size, |
| 407 | vcl_cfg->event_queue_size); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 408 | } |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 409 | else if (unformat (line_input, "listen-queue-size 0x%x", |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 410 | &vcl_cfg->listen_queue_size)) |
| 411 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 412 | VCFG_DBG (0, "VCL<%d>: configured listen_queue_size 0x%x (%u)", |
| 413 | getpid (), vcl_cfg->listen_queue_size, |
| 414 | vcl_cfg->listen_queue_size); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 415 | } |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 416 | else if (unformat (line_input, "listen-queue-size %u", |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 417 | &vcl_cfg->listen_queue_size)) |
| 418 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 419 | VCFG_DBG (0, "VCL<%d>: configured listen_queue_size %u (0x%x)", |
| 420 | getpid (), vcl_cfg->listen_queue_size, |
| 421 | vcl_cfg->listen_queue_size); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 422 | } |
| 423 | else if (unformat (line_input, "app-timeout %f", |
| 424 | &vcl_cfg->app_timeout)) |
| 425 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 426 | VCFG_DBG (0, "VCL<%d>: configured app_timeout %f", |
| 427 | getpid (), vcl_cfg->app_timeout); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 428 | } |
| 429 | else if (unformat (line_input, "session-timeout %f", |
| 430 | &vcl_cfg->session_timeout)) |
| 431 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 432 | VCFG_DBG (0, "VCL<%d>: configured session_timeout %f", |
| 433 | getpid (), vcl_cfg->session_timeout); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 434 | } |
| 435 | else if (unformat (line_input, "accept-timeout %f", |
| 436 | &vcl_cfg->accept_timeout)) |
| 437 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 438 | VCFG_DBG (0, "VCL<%d>: configured accept_timeout %f", |
| 439 | getpid (), vcl_cfg->accept_timeout); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 440 | } |
| 441 | else if (unformat (line_input, "app-proxy-transport-tcp")) |
| 442 | { |
| 443 | vcl_cfg->app_proxy_transport_tcp = 1; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 444 | VCFG_DBG (0, "VCL<%d>: configured app_proxy_transport_tcp (%d)", |
| 445 | getpid (), vcl_cfg->app_proxy_transport_tcp); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 446 | } |
| 447 | else if (unformat (line_input, "app-proxy-transport-udp")) |
| 448 | { |
| 449 | vcl_cfg->app_proxy_transport_udp = 1; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 450 | VCFG_DBG (0, "VCL<%d>: configured app_proxy_transport_udp (%d)", |
| 451 | getpid (), vcl_cfg->app_proxy_transport_udp); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 452 | } |
| 453 | else if (unformat (line_input, "app-scope-local")) |
| 454 | { |
| 455 | vcl_cfg->app_scope_local = 1; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 456 | VCFG_DBG (0, "VCL<%d>: configured app_scope_local (%d)", |
| 457 | getpid (), vcl_cfg->app_scope_local); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 458 | } |
| 459 | else if (unformat (line_input, "app-scope-global")) |
| 460 | { |
| 461 | vcl_cfg->app_scope_global = 1; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 462 | VCFG_DBG (0, "VCL<%d>: configured app_scope_global (%d)", |
| 463 | getpid (), vcl_cfg->app_scope_global); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 464 | } |
| 465 | else if (unformat (line_input, "namespace-secret %lu", |
| 466 | &vcl_cfg->namespace_secret)) |
| 467 | { |
Florin Coras | 1a3d237 | 2019-07-28 10:25:40 -0700 | [diff] [blame] | 468 | VCFG_DBG (0, "VCL<%d>: configured namespace_secret %llu " |
| 469 | "(0x%llx)", getpid (), |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 470 | (unsigned long long) vcl_cfg->namespace_secret, |
| 471 | (unsigned long long) vcl_cfg->namespace_secret); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 472 | } |
| 473 | else if (unformat (line_input, "namespace-id %v", |
| 474 | &vcl_cfg->namespace_id)) |
| 475 | { |
| 476 | u32 max_nsid_vec_len = vcl_max_nsid_len (); |
| 477 | u32 nsid_vec_len = vec_len (vcl_cfg->namespace_id); |
| 478 | if (nsid_vec_len > max_nsid_vec_len) |
| 479 | { |
| 480 | _vec_len (vcl_cfg->namespace_id) = max_nsid_vec_len; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 481 | VCFG_DBG (0, "VCL<%d>: configured namespace_id is too long," |
| 482 | " truncated to %d characters!", |
| 483 | getpid (), max_nsid_vec_len); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 484 | } |
| 485 | |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 486 | VCFG_DBG (0, "VCL<%d>: configured namespace_id %s", |
| 487 | getpid (), (char *) vcl_cfg->namespace_id); |
| 488 | } |
| 489 | else if (unformat (line_input, "use-mq-eventfd")) |
| 490 | { |
| 491 | vcl_cfg->use_mq_eventfd = 1; |
| 492 | VCFG_DBG (0, "VCL<%d>: configured with mq with eventfd", |
| 493 | getpid ()); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 494 | } |
Florin Coras | d747c3c | 2019-10-20 19:55:56 -0700 | [diff] [blame] | 495 | else if (unformat (line_input, "tls-engine %u", |
| 496 | &vcl_cfg->tls_engine)) |
| 497 | { |
| 498 | VCFG_DBG (0, "VCL<%d>: configured tls-engine %u (0x%x)", |
| 499 | getpid (), vcl_cfg->tls_engine, vcl_cfg->tls_engine); |
| 500 | } |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 501 | else if (unformat (line_input, "}")) |
| 502 | { |
| 503 | vc_cfg_input = 0; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 504 | VCFG_DBG (0, "VCL<%d>: completed parsing vppcom config!", |
| 505 | getpid ()); |
Florin Coras | 053a0e4 | 2018-11-13 15:52:38 -0800 | [diff] [blame] | 506 | unformat_free (line_input); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 507 | goto input_done; |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | if (line_input->buffer[line_input->index] != '#') |
| 512 | { |
| 513 | clib_warning ("VCL<%d>: Unknown vppcom config option: '%s'", |
| 514 | getpid (), (char *) |
| 515 | &line_input->buffer[line_input->index]); |
| 516 | } |
| 517 | } |
Florin Coras | 053a0e4 | 2018-11-13 15:52:38 -0800 | [diff] [blame] | 518 | unformat_free (line_input); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 519 | } |
| 520 | } |
| 521 | |
| 522 | input_done: |
| 523 | unformat_free (input); |
| 524 | |
| 525 | file_done: |
| 526 | if (fd >= 0) |
| 527 | close (fd); |
| 528 | } |
| 529 | |
| 530 | void |
| 531 | vppcom_cfg (vppcom_cfg_t * vcl_cfg) |
| 532 | { |
| 533 | char *conf_fname, *env_var_str; |
| 534 | |
| 535 | vppcom_cfg_init (vcl_cfg); |
| 536 | env_var_str = getenv (VPPCOM_ENV_DEBUG); |
| 537 | if (env_var_str) |
| 538 | { |
| 539 | u32 tmp; |
| 540 | if (sscanf (env_var_str, "%u", &tmp) != 1) |
Florin Coras | 9686eac | 2018-08-01 17:24:08 -0700 | [diff] [blame] | 541 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 542 | VCFG_DBG (0, "VCL<%d>: WARNING: Invalid debug level specified " |
| 543 | "in the environment variable " VPPCOM_ENV_DEBUG |
| 544 | " (%s)!\n", getpid (), env_var_str); |
Florin Coras | 9686eac | 2018-08-01 17:24:08 -0700 | [diff] [blame] | 545 | } |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 546 | else |
| 547 | { |
| 548 | vcm->debug = tmp; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 549 | VCFG_DBG (0, "VCL<%d>: configured VCL debug level (%u) from " |
| 550 | VPPCOM_ENV_DEBUG "!", getpid (), vcm->debug); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 551 | } |
| 552 | } |
| 553 | conf_fname = getenv (VPPCOM_ENV_CONF); |
| 554 | if (!conf_fname) |
| 555 | conf_fname = VPPCOM_CONF_DEFAULT; |
| 556 | vppcom_cfg_heapsize (conf_fname); |
| 557 | vppcom_cfg_read_file (conf_fname); |
| 558 | |
Florin Coras | d4c7092 | 2019-11-28 14:21:21 -0800 | [diff] [blame] | 559 | /* Regrab cfg after heap initialization */ |
| 560 | vcl_cfg = &vcm->cfg; |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 561 | env_var_str = getenv (VPPCOM_ENV_API_PREFIX); |
| 562 | if (env_var_str) |
| 563 | { |
Florin Coras | d4c7092 | 2019-11-28 14:21:21 -0800 | [diff] [blame] | 564 | vcl_cfg->vpp_api_chroot = format (0, "%s", env_var_str); |
| 565 | vec_terminate_c_string (vcl_cfg->vpp_api_chroot); |
| 566 | VCFG_DBG (0, "VCL<%d>: configured api prefix (%s) from " |
| 567 | VPPCOM_ENV_API_PREFIX "!", getpid (), env_var_str); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 568 | } |
| 569 | env_var_str = getenv (VPPCOM_ENV_APP_NAMESPACE_ID); |
| 570 | if (env_var_str) |
| 571 | { |
| 572 | u32 ns_id_vec_len = strlen (env_var_str); |
| 573 | |
| 574 | vec_reset_length (vcm->cfg.namespace_id); |
| 575 | vec_validate (vcm->cfg.namespace_id, ns_id_vec_len - 1); |
| 576 | clib_memcpy (vcm->cfg.namespace_id, env_var_str, ns_id_vec_len); |
| 577 | |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 578 | VCFG_DBG (0, "VCL<%d>: configured namespace_id (%s) from " |
BenoƮt Ganne | fe67afd | 2019-07-12 11:53:07 +0200 | [diff] [blame] | 579 | VPPCOM_ENV_APP_NAMESPACE_ID "!", getpid (), env_var_str); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 580 | } |
| 581 | env_var_str = getenv (VPPCOM_ENV_APP_NAMESPACE_SECRET); |
| 582 | if (env_var_str) |
| 583 | { |
| 584 | u64 tmp; |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 585 | if (sscanf (env_var_str, "%llu", (unsigned long long *) &tmp) != 1) |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 586 | { |
| 587 | VCFG_DBG (0, "VCL<%d>: WARNING: Invalid namespace secret specified" |
| 588 | " in the environment variable " |
| 589 | VPPCOM_ENV_APP_NAMESPACE_SECRET " (%s)!\n", getpid (), |
| 590 | env_var_str); |
| 591 | } |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 592 | else |
| 593 | { |
| 594 | vcm->cfg.namespace_secret = tmp; |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 595 | VCFG_DBG (0, "VCL<%d>: configured namespace secret (%llu) from " |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 596 | VPPCOM_ENV_APP_NAMESPACE_SECRET "!", getpid (), |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 597 | (unsigned long long) vcm->cfg.namespace_secret); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 598 | } |
| 599 | } |
| 600 | if (getenv (VPPCOM_ENV_APP_PROXY_TRANSPORT_TCP)) |
| 601 | { |
| 602 | vcm->cfg.app_proxy_transport_tcp = 1; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 603 | VCFG_DBG (0, "VCL<%d>: configured app_proxy_transport_tcp (%u) from " |
| 604 | VPPCOM_ENV_APP_PROXY_TRANSPORT_TCP "!", getpid (), |
| 605 | vcm->cfg.app_proxy_transport_tcp); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 606 | } |
| 607 | if (getenv (VPPCOM_ENV_APP_PROXY_TRANSPORT_UDP)) |
| 608 | { |
| 609 | vcm->cfg.app_proxy_transport_udp = 1; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 610 | VCFG_DBG (0, "VCL<%d>: configured app_proxy_transport_udp (%u) from " |
| 611 | VPPCOM_ENV_APP_PROXY_TRANSPORT_UDP "!", getpid (), |
| 612 | vcm->cfg.app_proxy_transport_udp); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 613 | } |
| 614 | if (getenv (VPPCOM_ENV_APP_SCOPE_LOCAL)) |
| 615 | { |
| 616 | vcm->cfg.app_scope_local = 1; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 617 | VCFG_DBG (0, "VCL<%d>: configured app_scope_local (%u) from " |
| 618 | VPPCOM_ENV_APP_SCOPE_LOCAL "!", getpid (), |
| 619 | vcm->cfg.app_scope_local); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 620 | } |
| 621 | if (getenv (VPPCOM_ENV_APP_SCOPE_GLOBAL)) |
| 622 | { |
| 623 | vcm->cfg.app_scope_global = 1; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 624 | VCFG_DBG (0, "VCL<%d>: configured app_scope_global (%u) from " |
| 625 | VPPCOM_ENV_APP_SCOPE_GLOBAL "!", getpid (), |
| 626 | vcm->cfg.app_scope_global); |
| 627 | } |
| 628 | env_var_str = getenv (VPPCOM_ENV_VPP_API_SOCKET); |
| 629 | if (env_var_str) |
| 630 | { |
| 631 | vcm->cfg.vpp_api_socket_name = format (0, "%s%c", env_var_str, 0); |
| 632 | VCFG_DBG (0, "VCL<%d>: configured api-socket-name (%s)", getpid (), |
| 633 | vcl_cfg->vpp_api_socket_name); |
Florin Coras | 697faea | 2018-06-27 17:10:49 -0700 | [diff] [blame] | 634 | } |
| 635 | } |
| 636 | |
| 637 | /* |
| 638 | * fd.io coding-style-patch-verification: ON |
| 639 | * |
| 640 | * Local Variables: |
| 641 | * eval: (c-set-style "gnu") |
| 642 | * End: |
| 643 | */ |