[dpdk-dev] net/ixgbe: fix API parameter checking
Checks
Commit Message
Add checks to rte_pmd_ixgbe_* API's to ensure that the port
is an ixgbe port.
Fixes: 49e248223e9f ("net/ixgbe: add API for VF management")
CC: stable@dpdk.org
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
drivers/net/ixgbe/ixgbe_ethdev.c | 71 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 69 insertions(+), 2 deletions(-)
Comments
On 1/11/2017 2:25 PM, Bernard Iremonger wrote:
> Add checks to rte_pmd_ixgbe_* API's to ensure that the port
> is an ixgbe port.
>
> Fixes: 49e248223e9f ("net/ixgbe: add API for VF management")
>
> CC: stable@dpdk.org
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
> drivers/net/ixgbe/ixgbe_ethdev.c | 71 ++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 69 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
> index b7ddd4f..ca14104 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -1,7 +1,7 @@
> /*-
> * BSD LICENSE
> *
> - * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
> + * Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
> * All rights reserved.
> *
> * Redistribution and use in source and binary forms, with or without
> @@ -4066,6 +4066,12 @@ rte_pmd_ixgbe_set_vf_mac_addr(uint8_t port, uint16_t vf,
> dev = &rte_eth_devices[port];
> rte_eth_dev_info_get(port, &dev_info);
>
> + if (!strstr(dev_info.driver_name, "ixgbe"))
> + return -ENOTSUP;
> +
> + if (strstr(dev_info.driver_name, "ixgbe_vf"))
> + return -ENOTSUP;
> +
This part seems common for all functions, what do you think exporting
this into a static function?
Also in the feature if you need to update the method to decide if this
port_id is supported or not, only that function will be effected.
<...>
Hi Ferruh,
> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Wednesday, January 11, 2017 3:15 PM
> To: Iremonger, Bernard <bernard.iremonger@intel.com>; dev@dpdk.org;
> Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Cc: stable@dpdk.org
> Subject: Re: [dpdk-stable] [PATCH] net/ixgbe: fix API parameter checking
>
> On 1/11/2017 2:25 PM, Bernard Iremonger wrote:
> > Add checks to rte_pmd_ixgbe_* API's to ensure that the port is an
> > ixgbe port.
> >
> > Fixes: 49e248223e9f ("net/ixgbe: add API for VF management")
> >
> > CC: stable@dpdk.org
> > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > ---
> > drivers/net/ixgbe/ixgbe_ethdev.c | 71
> > ++++++++++++++++++++++++++++++++++++++--
> > 1 file changed, 69 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c
> > b/drivers/net/ixgbe/ixgbe_ethdev.c
> > index b7ddd4f..ca14104 100644
> > --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> > @@ -1,7 +1,7 @@
> > /*-
> > * BSD LICENSE
> > *
> > - * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
> > + * Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
> > * All rights reserved.
> > *
> > * Redistribution and use in source and binary forms, with or without
> > @@ -4066,6 +4066,12 @@ rte_pmd_ixgbe_set_vf_mac_addr(uint8_t port,
> uint16_t vf,
> > dev = &rte_eth_devices[port];
> > rte_eth_dev_info_get(port, &dev_info);
> >
> > + if (!strstr(dev_info.driver_name, "ixgbe"))
> > + return -ENOTSUP;
> > +
> > + if (strstr(dev_info.driver_name, "ixgbe_vf"))
> > + return -ENOTSUP;
> > +
>
> This part seems common for all functions, what do you think exporting this
> into a static function?
>
> Also in the feature if you need to update the method to decide if this port_id
> is supported or not, only that function will be effected.
>
> <...>
Ok, I will put the checks into a static function and send a v2.
Regards,
Bernard.
@@ -1,7 +1,7 @@
/*-
* BSD LICENSE
*
- * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
+ * Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -4066,6 +4066,12 @@ rte_pmd_ixgbe_set_vf_mac_addr(uint8_t port, uint16_t vf,
dev = &rte_eth_devices[port];
rte_eth_dev_info_get(port, &dev_info);
+ if (!strstr(dev_info.driver_name, "ixgbe"))
+ return -ENOTSUP;
+
+ if (strstr(dev_info.driver_name, "ixgbe_vf"))
+ return -ENOTSUP;
+
if (vf >= dev_info.max_vfs)
return -EINVAL;
@@ -4564,6 +4570,12 @@ rte_pmd_ixgbe_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
dev = &rte_eth_devices[port];
rte_eth_dev_info_get(port, &dev_info);
+ if (!strstr(dev_info.driver_name, "ixgbe"))
+ return -ENOTSUP;
+
+ if (strstr(dev_info.driver_name, "ixgbe_vf"))
+ return -ENOTSUP;
+
if (vf >= dev_info.max_vfs)
return -EINVAL;
@@ -4591,6 +4603,12 @@ rte_pmd_ixgbe_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
dev = &rte_eth_devices[port];
rte_eth_dev_info_get(port, &dev_info);
+ if (!strstr(dev_info.driver_name, "ixgbe"))
+ return -ENOTSUP;
+
+ if (strstr(dev_info.driver_name, "ixgbe_vf"))
+ return -ENOTSUP;
+
if (vf >= dev_info.max_vfs)
return -EINVAL;
@@ -4617,10 +4635,16 @@ rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf, uint16_t vlan_id)
dev = &rte_eth_devices[port];
rte_eth_dev_info_get(port, &dev_info);
+ if (!strstr(dev_info.driver_name, "ixgbe"))
+ return -ENOTSUP;
+
+ if (strstr(dev_info.driver_name, "ixgbe_vf"))
+ return -ENOTSUP;
+
if (vf >= dev_info.max_vfs)
return -EINVAL;
- if (vlan_id > 4095)
+ if (vlan_id > ETHER_MAX_VLAN_ID)
return -EINVAL;
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -4643,10 +4667,18 @@ rte_pmd_ixgbe_set_tx_loopback(uint8_t port, uint8_t on)
struct ixgbe_hw *hw;
uint32_t ctrl;
struct rte_eth_dev *dev;
+ struct rte_eth_dev_info dev_info;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
dev = &rte_eth_devices[port];
+ rte_eth_dev_info_get(port, &dev_info);
+
+ if (!strstr(dev_info.driver_name, "ixgbe"))
+ return -ENOTSUP;
+
+ if (strstr(dev_info.driver_name, "ixgbe_vf"))
+ return -ENOTSUP;
if (on > 1)
return -EINVAL;
@@ -4672,10 +4704,18 @@ rte_pmd_ixgbe_set_all_queues_drop_en(uint8_t port, uint8_t on)
int i;
int num_queues = (int)(IXGBE_QDE_IDX_MASK >> IXGBE_QDE_IDX_SHIFT);
struct rte_eth_dev *dev;
+ struct rte_eth_dev_info dev_info;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
dev = &rte_eth_devices[port];
+ rte_eth_dev_info_get(port, &dev_info);
+
+ if (!strstr(dev_info.driver_name, "ixgbe"))
+ return -ENOTSUP;
+
+ if (strstr(dev_info.driver_name, "ixgbe_vf"))
+ return -ENOTSUP;
if (on > 1)
return -EINVAL;
@@ -4704,6 +4744,12 @@ rte_pmd_ixgbe_set_vf_split_drop_en(uint8_t port, uint16_t vf, uint8_t on)
dev = &rte_eth_devices[port];
rte_eth_dev_info_get(port, &dev_info);
+ if (!strstr(dev_info.driver_name, "ixgbe"))
+ return -ENOTSUP;
+
+ if (strstr(dev_info.driver_name, "ixgbe_vf"))
+ return -ENOTSUP;
+
/* only support VF's 0 to 63 */
if ((vf >= dev_info.max_vfs) || (vf > 63))
return -EINVAL;
@@ -4736,6 +4782,12 @@ rte_pmd_ixgbe_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on)
dev = &rte_eth_devices[port];
rte_eth_dev_info_get(port, &dev_info);
+ if (!strstr(dev_info.driver_name, "ixgbe"))
+ return -ENOTSUP;
+
+ if (strstr(dev_info.driver_name, "ixgbe_vf"))
+ return -ENOTSUP;
+
if (vf >= dev_info.max_vfs)
return -EINVAL;
@@ -4775,6 +4827,9 @@ rte_pmd_ixgbe_set_vf_rxmode(uint8_t port, uint16_t vf, uint16_t rx_mask, uint8_t
dev = &rte_eth_devices[port];
rte_eth_dev_info_get(port, &dev_info);
+ if (!strstr(dev_info.driver_name, "ixgbe"))
+ return -ENOTSUP;
+
if (strstr(dev_info.driver_name, "ixgbe_vf"))
return -ENOTSUP;
@@ -4822,6 +4877,9 @@ rte_pmd_ixgbe_set_vf_rx(uint8_t port, uint16_t vf, uint8_t on)
dev = &rte_eth_devices[port];
rte_eth_dev_info_get(port, &dev_info);
+ if (!strstr(dev_info.driver_name, "ixgbe"))
+ return -ENOTSUP;
+
if (strstr(dev_info.driver_name, "ixgbe_vf"))
return -ENOTSUP;
@@ -4873,6 +4931,9 @@ rte_pmd_ixgbe_set_vf_tx(uint8_t port, uint16_t vf, uint8_t on)
dev = &rte_eth_devices[port];
rte_eth_dev_info_get(port, &dev_info);
+ if (!strstr(dev_info.driver_name, "ixgbe"))
+ return -ENOTSUP;
+
if (strstr(dev_info.driver_name, "ixgbe_vf"))
return -ENOTSUP;
@@ -4922,6 +4983,9 @@ rte_pmd_ixgbe_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
dev = &rte_eth_devices[port];
rte_eth_dev_info_get(port, &dev_info);
+ if (!strstr(dev_info.driver_name, "ixgbe"))
+ return -ENOTSUP;
+
if (strstr(dev_info.driver_name, "ixgbe_vf"))
return -ENOTSUP;
@@ -4965,6 +5029,9 @@ int rte_pmd_ixgbe_set_vf_rate_limit(uint8_t port, uint16_t vf,
rte_eth_dev_info_get(port, &dev_info);
rte_eth_link_get_nowait(port, &link);
+ if (!strstr(dev_info.driver_name, "ixgbe"))
+ return -ENOTSUP;
+
if (strstr(dev_info.driver_name, "ixgbe_vf"))
return -ENOTSUP;