| 1229 | } |
| 1230 | |
| 1231 | static int |
| 1232 | ff_check_config(struct ff_config *cfg) |
| 1233 | { |
| 1234 | if(cfg->kni.enable && !cfg->kni.method) { |
| 1235 | fprintf(stderr, "conf dpdk.method is necessary\n"); |
| 1236 | return -1; |
| 1237 | } |
| 1238 | |
| 1239 | if(cfg->kni.method) { |
| 1240 | if(strcasecmp(cfg->kni.method,"accept") && |
| 1241 | strcasecmp(cfg->kni.method,"reject")) { |
| 1242 | fprintf(stderr, "conf kni.method[accept|reject] is error(%s)\n", |
| 1243 | cfg->kni.method); |
| 1244 | return -1; |
| 1245 | } |
| 1246 | } |
| 1247 | |
| 1248 | if(cfg->kni.kni_action) { |
| 1249 | if (strcasecmp(cfg->kni.kni_action,"alltokni") && |
| 1250 | strcasecmp(cfg->kni.kni_action,"alltoff") && |
| 1251 | strcasecmp(cfg->kni.kni_action,"default")){ |
| 1252 | fprintf(stderr, "conf kni.kni_action[alltokni|alltoff|default] is error(%s)\n", |
| 1253 | cfg->kni.kni_action); |
| 1254 | return -1; |
| 1255 | } |
| 1256 | } |
| 1257 | |
| 1258 | if (cfg->pcap.save_len < PCAP_SAVE_MINLEN) |
| 1259 | cfg->pcap.save_len = PCAP_SAVE_MINLEN; |
| 1260 | if (cfg->pcap.snap_len < PCAP_SNAP_MINLEN) |
| 1261 | cfg->pcap.snap_len = PCAP_SNAP_MINLEN; |
| 1262 | if (cfg->pcap.save_path==NULL || strlen(cfg->pcap.save_path) ==0) |
| 1263 | cfg->pcap.save_path = strdup("."); |
| 1264 | |
| 1265 | #define CHECK_VALID(n) \ |
| 1266 | do { \ |
| 1267 | if (!pc->n) { \ |
| 1268 | fprintf(stderr, "port%d if config error: no %s\n", \ |
| 1269 | pc->port_id, #n); \ |
| 1270 | return -1; \ |
| 1271 | } \ |
| 1272 | } while (0) |
| 1273 | |
| 1274 | int i; |
| 1275 | for (i = 0; i < cfg->dpdk.nb_ports; i++) { |
| 1276 | uint16_t portid = cfg->dpdk.portid_list[i]; |
| 1277 | struct ff_port_cfg *pc = &cfg->dpdk.port_cfgs[portid]; |
| 1278 | CHECK_VALID(addr); |
| 1279 | CHECK_VALID(netmask); |
| 1280 | CHECK_VALID(broadcast); |
| 1281 | CHECK_VALID(gateway); |
| 1282 | // check if the lcores in lcore_list are enabled. |
| 1283 | int k; |
| 1284 | for (k = 0; k < pc->nb_lcores; k++) { |
| 1285 | uint16_t lcore_id = pc->lcore_list[k]; |
| 1286 | if (uint16_binary_search(cfg->dpdk.proc_lcore, 0, |
| 1287 | cfg->dpdk.nb_procs-1, lcore_id) < 0) { |
| 1288 | fprintf(stderr, "lcore %d is not enabled.\n", lcore_id); |
no test coverage detected