X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=VNFs%2FvFW%2Finit.c;h=c3d4a6c3869a7d78a630690c8fbf06a1b61ffab6;hb=00f643ee70f45b3a361b578d90d393137b00fd0a;hp=4e98b33506175d820fa2d89497433ba5454003a5;hpb=d88705d806228f3b5688d4d9256de6d106d206df;p=samplevnf.git diff --git a/VNFs/vFW/init.c b/VNFs/vFW/init.c index 4e98b335..c3d4a6c3 100644 --- a/VNFs/vFW/init.c +++ b/VNFs/vFW/init.c @@ -97,14 +97,21 @@ app_init_eal(struct app_params *app) uint32_t i; int status; + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; + app->eal_argv[n_args++] = strdup(app->app_name); app_core_build_core_mask_string(app, core_mask_str); snprintf(buffer, sizeof(buffer), "-c%s", core_mask_str); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); if (p->coremap) { snprintf(buffer, sizeof(buffer), "--lcores=%s", p->coremap); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -113,19 +120,27 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--master-lcore=%" PRIu32, p->master_lcore); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } snprintf(buffer, sizeof(buffer), "-n%" PRIu32, p->channels); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); if (p->memory_present) { snprintf(buffer, sizeof(buffer), "-m%" PRIu32, p->memory); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if (p->ranks_present) { snprintf(buffer, sizeof(buffer), "-r%" PRIu32, p->ranks); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -137,6 +152,8 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--pci-blacklist=%s", p->pci_blacklist[i]); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -149,6 +166,8 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--pci-whitelist=%s", p->pci_whitelist[i]); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } else @@ -159,6 +178,8 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--pci-whitelist=%s", pci_bdf); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -170,11 +191,15 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--vdev=%s", p->vdev[i]); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->vmware_tsc_map_present) && p->vmware_tsc_map) { snprintf(buffer, sizeof(buffer), "--vmware-tsc-map"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -183,11 +208,15 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--proc-type=%s", p->proc_type); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if (p->syslog) { snprintf(buffer, sizeof(buffer), "--syslog=%s", p->syslog); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -196,41 +225,57 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--log-level=%" PRIu32, p->log_level); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->version_present) && p->version) { snprintf(buffer, sizeof(buffer), "-v"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->help_present) && p->help) { snprintf(buffer, sizeof(buffer), "--help"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->no_huge_present) && p->no_huge) { snprintf(buffer, sizeof(buffer), "--no-huge"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->no_pci_present) && p->no_pci) { snprintf(buffer, sizeof(buffer), "--no-pci"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->no_hpet_present) && p->no_hpet) { snprintf(buffer, sizeof(buffer), "--no-hpet"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->no_shconf_present) && p->no_shconf) { snprintf(buffer, sizeof(buffer), "--no-shconf"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if (p->add_driver) { snprintf(buffer, sizeof(buffer), "-d=%s", p->add_driver); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -239,11 +284,15 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--socket-mem=%s", p->socket_mem); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if (p->huge_dir) { snprintf(buffer, sizeof(buffer), "--huge-dir=%s", p->huge_dir); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -252,6 +301,8 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--file-prefix=%s", p->file_prefix); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -260,11 +311,15 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--base-virtaddr=%s", p->base_virtaddr); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->create_uio_dev_present) && p->create_uio_dev) { snprintf(buffer, sizeof(buffer), "--create-uio-dev"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -273,15 +328,21 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--vfio-intr=%s", p->vfio_intr); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->xen_dom0_present) && (p->xen_dom0)) { snprintf(buffer, sizeof(buffer), "--xen-dom0"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } snprintf(buffer, sizeof(buffer), "--"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); app->eal_argc = n_args; @@ -297,8 +358,10 @@ app_init_eal(struct app_params *app) } status = rte_eal_init(app->eal_argc, app->eal_argv); - if (status < 0) + if (status < 0) { +error_exit: rte_panic("EAL init error\n"); + } } static inline int app_link_filter_arp_add(struct app_link_params *link) @@ -557,7 +620,7 @@ app_link_up_internal(__rte_unused struct app_params *app, struct app_link_params *cp) { if(app == NULL || cp == NULL) - printf("NULL Pointers"); + rte_panic("NULL Pointers"); #if RTE_VERSION < 0x100b0000 if (app_link_is_virtual(cp)) { @@ -576,7 +639,8 @@ app_link_down_internal(__rte_unused struct app_params *app, struct app_link_params *cp) { if(app == NULL || cp == NULL) - printf("NULL Pointers"); + rte_panic("NULL Pointers"); + #if RTE_VERSION < 0x100b0000 if (app_link_is_virtual(cp)) { @@ -705,7 +769,7 @@ app_init_link(struct app_params *app) port_config = rte_zmalloc(NULL, (app->n_links * size), RTE_CACHE_LINE_SIZE); if (port_config == NULL) - rte_panic("port_config is NULL: Memory Allocation failure\n"); + rte_panic("port_config is NULL: Memory Allocation failure num_links %d %d\n", app->n_links, app->n_links * size); for (i = 0; i < app->n_links; i++) { struct app_link_params *p_link = &app->link_params[i];