| 158 | } |
| 159 | |
| 160 | static struct rte_swx_table_entry * |
| 161 | parse_table_entry(struct rte_swx_ctl_pipeline *p, |
| 162 | char *table_name, |
| 163 | char **tokens, |
| 164 | uint32_t n_tokens) |
| 165 | { |
| 166 | struct rte_swx_table_entry *entry; |
| 167 | char *line; |
| 168 | uint32_t i; |
| 169 | |
| 170 | /* Buffer allocation. */ |
| 171 | line = malloc(MAX_LINE_SIZE); |
| 172 | if (!line) |
| 173 | return NULL; |
| 174 | |
| 175 | /* Copy tokens to buffer. Since the tokens were initially part of a buffer of size |
| 176 | * MAX_LINE_LENGTH, it is guaranteed that putting back some of them into a buffer of the |
| 177 | * same size separated by a single space will not result in buffer overrun. |
| 178 | */ |
| 179 | line[0] = 0; |
| 180 | for (i = 0; i < n_tokens; i++) { |
| 181 | if (i) |
| 182 | strcat(line, " "); |
| 183 | |
| 184 | strcat(line, tokens[i]); |
| 185 | } |
| 186 | |
| 187 | /* Read the table entry from the input buffer. */ |
| 188 | entry = rte_swx_ctl_pipeline_table_entry_read(p, table_name, line, NULL); |
| 189 | |
| 190 | /* Buffer free. */ |
| 191 | free(line); |
| 192 | |
| 193 | return entry; |
| 194 | } |
| 195 | |
| 196 | static const char cmd_mempool_help[] = |
| 197 | "mempool <mempool_name> " |
no test coverage detected