DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] kni: fix rte_kni_update_link
@ 2019-01-24 20:47 Igor Ryzhov
  2019-01-28 11:45 ` Igor Ryzhov
  2019-02-05 22:45 ` Stephen Hemminger
  0 siblings, 2 replies; 5+ messages in thread
From: Igor Ryzhov @ 2019-01-24 20:47 UTC (permalink / raw)
  To: dev; +Cc: stable

After read, file offset must be set to 0 before write.
Otherwise, the third byte will be overwritten instead of the first.

Fixes: c6fd54f28c24 ("kni: add function to set link state on kernel interface")
Cc: stable@dpdk.org

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
---
 lib/librte_kni/rte_kni.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index 73aeccccf..5899bb14a 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -746,6 +746,12 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup)
 	}
 	old_linkup = (old_carrier[0] == '1');
 
+	if (lseek(fd, 0, SEEK_SET) == -1) {
+		RTE_LOG(ERR, KNI, "Failed to change file position: %s.\n", path);
+		close(fd);
+		return -1;
+	}
+
 	new_carrier = linkup ? "1" : "0";
 	ret = write(fd, new_carrier, 1);
 	if (ret < 1) {
-- 
2.20.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] kni: fix rte_kni_update_link
  2019-01-24 20:47 [dpdk-dev] [PATCH] kni: fix rte_kni_update_link Igor Ryzhov
@ 2019-01-28 11:45 ` Igor Ryzhov
  2019-01-28 13:49   ` Igor Ryzhov
  2019-02-05 22:45 ` Stephen Hemminger
  1 sibling, 1 reply; 5+ messages in thread
From: Igor Ryzhov @ 2019-01-28 11:45 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: stable, dev

Hi Ferruh,

Can you, please, take a look at this patch?
The current implementation is broken, I think the patch should be merged
into 19.02 and 18.11.1.

Best regards,
Igor

On Thu, Jan 24, 2019 at 11:47 PM Igor Ryzhov <iryzhov@nfware.com> wrote:

> After read, file offset must be set to 0 before write.
> Otherwise, the third byte will be overwritten instead of the first.
>
> Fixes: c6fd54f28c24 ("kni: add function to set link state on kernel
> interface")
> Cc: stable@dpdk.org
>
> Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
> ---
>  lib/librte_kni/rte_kni.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
> index 73aeccccf..5899bb14a 100644
> --- a/lib/librte_kni/rte_kni.c
> +++ b/lib/librte_kni/rte_kni.c
> @@ -746,6 +746,12 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int
> linkup)
>         }
>         old_linkup = (old_carrier[0] == '1');
>
> +       if (lseek(fd, 0, SEEK_SET) == -1) {
> +               RTE_LOG(ERR, KNI, "Failed to change file position: %s.\n",
> path);
> +               close(fd);
> +               return -1;
> +       }
> +
>         new_carrier = linkup ? "1" : "0";
>         ret = write(fd, new_carrier, 1);
>         if (ret < 1) {
> --
> 2.20.1
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] kni: fix rte_kni_update_link
  2019-01-28 11:45 ` Igor Ryzhov
@ 2019-01-28 13:49   ` Igor Ryzhov
  2019-01-28 14:00     ` Ferruh Yigit
  0 siblings, 1 reply; 5+ messages in thread
From: Igor Ryzhov @ 2019-01-28 13:49 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: stable, dev

Hi again,

Sorry for bothering, I should have done more testing. It works as it is now.
So, self NACK on the patch.

Best regards,
Igor

On Mon, Jan 28, 2019 at 2:45 PM Igor Ryzhov <iryzhov@nfware.com> wrote:

> Hi Ferruh,
>
> Can you, please, take a look at this patch?
> The current implementation is broken, I think the patch should be merged
> into 19.02 and 18.11.1.
>
> Best regards,
> Igor
>
> On Thu, Jan 24, 2019 at 11:47 PM Igor Ryzhov <iryzhov@nfware.com> wrote:
>
>> After read, file offset must be set to 0 before write.
>> Otherwise, the third byte will be overwritten instead of the first.
>>
>> Fixes: c6fd54f28c24 ("kni: add function to set link state on kernel
>> interface")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
>> ---
>>  lib/librte_kni/rte_kni.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
>> index 73aeccccf..5899bb14a 100644
>> --- a/lib/librte_kni/rte_kni.c
>> +++ b/lib/librte_kni/rte_kni.c
>> @@ -746,6 +746,12 @@ rte_kni_update_link(struct rte_kni *kni, unsigned
>> int linkup)
>>         }
>>         old_linkup = (old_carrier[0] == '1');
>>
>> +       if (lseek(fd, 0, SEEK_SET) == -1) {
>> +               RTE_LOG(ERR, KNI, "Failed to change file position:
>> %s.\n", path);
>> +               close(fd);
>> +               return -1;
>> +       }
>> +
>>         new_carrier = linkup ? "1" : "0";
>>         ret = write(fd, new_carrier, 1);
>>         if (ret < 1) {
>> --
>> 2.20.1
>>
>>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] kni: fix rte_kni_update_link
  2019-01-28 13:49   ` Igor Ryzhov
@ 2019-01-28 14:00     ` Ferruh Yigit
  0 siblings, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2019-01-28 14:00 UTC (permalink / raw)
  To: Igor Ryzhov; +Cc: stable, dev, Dan Gora

On 1/28/2019 1:49 PM, Igor Ryzhov wrote:
> Hi again,
> 
> Sorry for bothering, I should have done more testing. It works as it is now.
> So, self NACK on the patch.

Thanks for the update Igor.

Since the file is pseudo-file, sysfs, I would expect no seek operation should be
required, your update confirms this.
Meanwhile there is a unit test 'kni_autotest' when you want to test link update.

Thanks,
ferruh

> 
> Best regards,
> Igor
> 
> On Mon, Jan 28, 2019 at 2:45 PM Igor Ryzhov <iryzhov@nfware.com> wrote:
> 
>> Hi Ferruh,
>>
>> Can you, please, take a look at this patch?
>> The current implementation is broken, I think the patch should be merged
>> into 19.02 and 18.11.1.
>>
>> Best regards,
>> Igor
>>
>> On Thu, Jan 24, 2019 at 11:47 PM Igor Ryzhov <iryzhov@nfware.com> wrote:
>>
>>> After read, file offset must be set to 0 before write.
>>> Otherwise, the third byte will be overwritten instead of the first.
>>>
>>> Fixes: c6fd54f28c24 ("kni: add function to set link state on kernel
>>> interface")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
>>> ---
>>>  lib/librte_kni/rte_kni.c | 6 ++++++
>>>  1 file changed, 6 insertions(+)
>>>
>>> diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
>>> index 73aeccccf..5899bb14a 100644
>>> --- a/lib/librte_kni/rte_kni.c
>>> +++ b/lib/librte_kni/rte_kni.c
>>> @@ -746,6 +746,12 @@ rte_kni_update_link(struct rte_kni *kni, unsigned
>>> int linkup)
>>>         }
>>>         old_linkup = (old_carrier[0] == '1');
>>>
>>> +       if (lseek(fd, 0, SEEK_SET) == -1) {
>>> +               RTE_LOG(ERR, KNI, "Failed to change file position:
>>> %s.\n", path);
>>> +               close(fd);
>>> +               return -1;
>>> +       }
>>> +
>>>         new_carrier = linkup ? "1" : "0";
>>>         ret = write(fd, new_carrier, 1);
>>>         if (ret < 1) {
>>> --
>>> 2.20.1
>>>
>>>
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] kni: fix rte_kni_update_link
  2019-01-24 20:47 [dpdk-dev] [PATCH] kni: fix rte_kni_update_link Igor Ryzhov
  2019-01-28 11:45 ` Igor Ryzhov
@ 2019-02-05 22:45 ` Stephen Hemminger
  1 sibling, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2019-02-05 22:45 UTC (permalink / raw)
  To: Igor Ryzhov; +Cc: dev, stable

On Thu, 24 Jan 2019 23:47:49 +0300
Igor Ryzhov <iryzhov@nfware.com> wrote:

> After read, file offset must be set to 0 before write.
> Otherwise, the third byte will be overwritten instead of the first.
> 
> Fixes: c6fd54f28c24 ("kni: add function to set link state on kernel interface")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
> ---
>  lib/librte_kni/rte_kni.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
> index 73aeccccf..5899bb14a 100644
> --- a/lib/librte_kni/rte_kni.c
> +++ b/lib/librte_kni/rte_kni.c
> @@ -746,6 +746,12 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup)
>  	}
>  	old_linkup = (old_carrier[0] == '1');
>  
> +	if (lseek(fd, 0, SEEK_SET) == -1) {
> +		RTE_LOG(ERR, KNI, "Failed to change file position: %s.\n", path);
> +		close(fd);
> +		return -1;
> +	}
> +
>  	new_carrier = linkup ? "1" : "0";
>  	ret = write(fd, new_carrier, 1);
>  	if (ret < 1) {

Why not use pwrite() which is atomic?

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-02-05 22:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-24 20:47 [dpdk-dev] [PATCH] kni: fix rte_kni_update_link Igor Ryzhov
2019-01-28 11:45 ` Igor Ryzhov
2019-01-28 13:49   ` Igor Ryzhov
2019-01-28 14:00     ` Ferruh Yigit
2019-02-05 22:45 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).