[dpdk-dev] [PATCH 6/6] net/tap: implement link up and down callbacks

Pascal Mazon pascal.mazon at 6wind.com
Tue Jan 31 15:31:04 CET 2017


On 01/31/2017 02:21 PM, Ferruh Yigit wrote:
> On 1/31/2017 9:42 AM, Pascal Mazon wrote:
>> Signed-off-by: Pascal Mazon <pascal.mazon at 6wind.com>
>> ---
>>  drivers/net/tap/rte_eth_tap.c | 59 +++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 59 insertions(+)
>>
>> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
>> index 734e3a579219..9b6bbff5fd81 100644
>> --- a/drivers/net/tap/rte_eth_tap.c
>> +++ b/drivers/net/tap/rte_eth_tap.c
>> @@ -405,6 +405,63 @@ tap_link_update(struct rte_eth_dev *dev __rte_unused,
>>  	return 0;
>>  }
>>
>> +static int tap_link_set(struct pmd_internals *pmd, int state)
>> +{
>> +	struct ifreq ifr;
>> +	int err, s;
>> +
>> +	/*
>> +	 * An AF_INET/DGRAM socket is needed for
>> +	 * SIOCGIFFLAGS/SIOCSIFFLAGS, using fd won't work.
>> +	 */
>> +	s = socket(AF_INET, SOCK_DGRAM, 0);
>> +	if (s < 0) {
>> +		RTE_LOG(ERR, PMD,
>> +			"Unable to get a socket to set flags: %s\n",
>> +			strerror(errno));
>> +		return -1;
>> +	}
>> +	memset(&ifr, 0, sizeof(ifr));
>> +	strncpy(ifr.ifr_name, pmd->name, IFNAMSIZ);
>
> Again how this will behave for multiple queue setup.

The link status is not related to the number of queues.
As long as there is at least one queue configured (if the last queue is
closed, then the netdevice is effectively deleted entirely), it is
possible to set the link up or down.
With the link down, no queues will be able to receive or send packets.

>
> Rest looks good.
>
>> +	err = ioctl(s, SIOCGIFFLAGS, &ifr);
>> +	if (err < 0) {
>> +		RTE_LOG(ERR, PMD, "Unable to get tap netdevice flags: %s\n",
>> +			strerror(errno));
>> +		close(s);
>> +		return -1;
>> +	}
> <...>
>


-- 
Pascal Mazon
www.6wind.com


More information about the dev mailing list