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