[dpdk-dev] [PATCH v4 1/2] librte_ether: add protection against overwrite device data
Pattan, Reshma
reshma.pattan at intel.com
Wed Sep 28 16:03:54 CEST 2016
> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Marcin Kerlin
> Sent: Tuesday, September 27, 2016 12:13 PM
> To: dev at dpdk.org
> Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch at intel.com>;
> thomas.monjalon at 6wind.com; Kerlin, MarcinX <marcinx.kerlin at intel.com>
> Subject: [dpdk-dev] [PATCH v4 1/2] librte_ether: add protection against
> overwrite device data
>
> +int
> +rte_eth_dev_release_dev_data(uint8_t port_id) {
> + char device[RTE_ETH_NAME_MAX_LEN];
> + struct rte_eth_dev_data *eth_dev_data = NULL;
> +
> +
> @@ -631,6 +691,8 @@ int
> rte_eth_dev_detach(uint8_t port_id, char *name) {
> struct rte_pci_addr addr;
> + struct rte_eth_dev_data *eth_dev_data = NULL;
> + char device[RTE_ETH_NAME_MAX_LEN];
> int ret = -1;
>
> if (name == NULL) {
> @@ -642,6 +704,15 @@ rte_eth_dev_detach(uint8_t port_id, char *name)
> if (rte_eth_dev_is_detachable(port_id))
> goto err;
>
> + /* get device name by port id */
> + if (rte_eth_dev_get_name_by_port(port_id, device))
> + goto err;
> +
> + /* look for an entry in the shared device data */
> + eth_dev_data = rte_eth_dev_get_dev_data_by_name(device);
> + if (eth_dev_data == NULL)
> + goto err;
> +
> if (rte_eth_dev_get_device_type(port_id) == RTE_ETH_DEV_PCI) {
> ret = rte_eth_dev_get_addr_by_port(port_id, &addr);
> if (ret < 0)
> @@ -661,6 +732,9 @@ rte_eth_dev_detach(uint8_t port_id, char *name)
> goto err;
> }
>
> + /* clear an entry in the shared device data */
> + memset(eth_dev_data, 0, sizeof(struct rte_eth_dev_data));
> +
> return 0;
>
In this function, the new code chunks together is nothing but the function " rte_eth_dev_release_dev_data()".
So u can call the function itself rather than a duplicate code.
Thanks,
Reshma
More information about the dev
mailing list