All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH net-next] pktgen: Fix invalid clone_skb override
       [not found] <20210802071126.3b311638@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
@ 2021-08-02 17:09 ` Nicholas Richardson
  2021-08-02 17:12 ` [PATCH v2] " Nicholas Richardson
  1 sibling, 0 replies; 7+ messages in thread
From: Nicholas Richardson @ 2021-08-02 17:09 UTC (permalink / raw)
  To: kuba; +Cc: nrrichar, arunkaly, netdev, Nicholas Richardson

When a user passes a negative value for clone_skb, the num_args() function stops parsing at the first nonnumeric value. This makes it impossible for clone_skb to be set to a negative value. For example: "clone_skb -200" would stop parsing at the first char ('-') and return zero for the new clone_skb value.

So to answer your question: No clone_skb cannot be negative.

Apologies for the email format errors and thanks for the quick reply!

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

* [PATCH v2] pktgen: Fix invalid clone_skb override
       [not found] <20210802071126.3b311638@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
  2021-08-02 17:09 ` [PATCH net-next] pktgen: Fix invalid clone_skb override Nicholas Richardson
@ 2021-08-02 17:12 ` Nicholas Richardson
  2021-08-02 17:21   ` Jakub Kicinski
  1 sibling, 1 reply; 7+ messages in thread
From: Nicholas Richardson @ 2021-08-02 17:12 UTC (permalink / raw)
  To: davem, kuba
  Cc: nrrichar, arunkaly, Nick Richardson, Gustavo A. R. Silva,
	Leesoo Ahn, Di Zhu, Yejune Deng, Ye Bin, netdev, linux-kernel

From: Nick Richardson <richardsonnick@google.com>

When the netif_receive xmit_mode is set, a line is supposed to set
clone_skb to a default 0 value. This line is not reached due to a line
that checks if clone_skb is more than zero and returns -ENOTSUPP.

Removes line that defaults clone_skb to zero. -ENOTSUPP is returned
if clone_skb is more than zero. If clone_skb is equal to zero then the
xmit_mode is set to netif_receive as usual and no error is returned.

Signed-off-by: Nick Richardson <richardsonnick@google.com>
---
 net/core/pktgen.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 7e258d255e90..314f97acf39d 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -1190,11 +1190,6 @@ static ssize_t pktgen_if_write(struct file *file,
 			 * pktgen_xmit() is called
 			 */
 			pkt_dev->last_ok = 1;
-
-			/* override clone_skb if user passed default value
-			 * at module loading time
-			 */
-			pkt_dev->clone_skb = 0;
 		} else if (strcmp(f, "queue_xmit") == 0) {
 			pkt_dev->xmit_mode = M_QUEUE_XMIT;
 			pkt_dev->last_ok = 1;
-- 
2.32.0.554.ge1b32706d8-goog


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

* Re: [PATCH v2] pktgen: Fix invalid clone_skb override
  2021-08-02 17:12 ` [PATCH v2] " Nicholas Richardson
@ 2021-08-02 17:21   ` Jakub Kicinski
  2021-08-02 18:20     ` [PATCH v3] " Nicholas Richardson
  0 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2021-08-02 17:21 UTC (permalink / raw)
  To: Nicholas Richardson
  Cc: davem, nrrichar, arunkaly, Gustavo A. R. Silva, Leesoo Ahn,
	Di Zhu, Yejune Deng, Ye Bin, netdev, linux-kernel

On Mon,  2 Aug 2021 17:12:07 +0000 Nicholas Richardson wrote:
> From: Nick Richardson <richardsonnick@google.com>
> 
> When the netif_receive xmit_mode is set, a line is supposed to set
> clone_skb to a default 0 value. This line is not reached due to a line
> that checks if clone_skb is more than zero and returns -ENOTSUPP.
> 
> Removes line that defaults clone_skb to zero.

s/Removes/Remove/
s/defaults/sets/

> -ENOTSUPP is returned
> if clone_skb is more than zero. 

That's already mentioned in the previous paragraph.

> If clone_skb is equal to zero then the
> xmit_mode is set to netif_receive as usual and no error is returned.

Please add the explanation why clone_skb can't be negative to the
commit message.

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

* [PATCH v3] pktgen: Fix invalid clone_skb override
  2021-08-02 17:21   ` Jakub Kicinski
@ 2021-08-02 18:20     ` Nicholas Richardson
  2021-08-03  2:17       ` 答复: " zhudi (J)
  0 siblings, 1 reply; 7+ messages in thread
From: Nicholas Richardson @ 2021-08-02 18:20 UTC (permalink / raw)
  To: davem, kuba
  Cc: nrrichar, arunkaly, Nick Richardson, Gustavo A. R. Silva, Di Zhu,
	Ye Bin, Yejune Deng, Leesoo Ahn, netdev, linux-kernel

From: Nick Richardson <richardsonnick@google.com>

When the netif_receive xmit_mode is set, a line is supposed to set
clone_skb to a default 0 value. This line is made redundant due to a
preceding line that checks if clone_skb is more than zero and returns
-ENOTSUPP.

Only the positive case for clone_skb needs to be checked. It
is impossible for a user to set clone_skb to a negative number.
When a user passes a negative value for clone_skb, the num_arg()
function stops parsing at the first nonnumeric value.

For example: "clone_skb -200" would stop parsing at the
first char ('-') and return zero for the new clone_skb value.

The value read by num_arg() cannot be overflow-ed into the negative
range, since it is an unsigned long.

Remove redundant line that sets clone_skb to zero. If clone_skb is
equal to zero then set xmit_mode to netif_receive as usual and return
no error.

Signed-off-by: Nick Richardson <richardsonnick@google.com>
---
 net/core/pktgen.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 7e258d255e90..314f97acf39d 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -1190,11 +1190,6 @@ static ssize_t pktgen_if_write(struct file *file,
 			 * pktgen_xmit() is called
 			 */
 			pkt_dev->last_ok = 1;
-
-			/* override clone_skb if user passed default value
-			 * at module loading time
-			 */
-			pkt_dev->clone_skb = 0;
 		} else if (strcmp(f, "queue_xmit") == 0) {
 			pkt_dev->xmit_mode = M_QUEUE_XMIT;
 			pkt_dev->last_ok = 1;
-- 
2.32.0.554.ge1b32706d8-goog


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

* 答复: [PATCH v3] pktgen: Fix invalid clone_skb override
  2021-08-02 18:20     ` [PATCH v3] " Nicholas Richardson
@ 2021-08-03  2:17       ` zhudi (J)
  2021-08-03 16:27         ` [PATCH v4] pktgen: Remove redundant " Nicholas Richardson
  0 siblings, 1 reply; 7+ messages in thread
From: zhudi (J) @ 2021-08-03  2:17 UTC (permalink / raw)
  To: Nicholas Richardson, davem, kuba
  Cc: nrrichar, arunkaly, Gustavo A. R. Silva, yebin (H),
	Yejune Deng, Leesoo Ahn, netdev, linux-kernel

> From: Nick Richardson <richardsonnick@google.com>
> 
> When the netif_receive xmit_mode is set, a line is supposed to set
> clone_skb to a default 0 value. This line is made redundant due to a
> preceding line that checks if clone_skb is more than zero and returns
> -ENOTSUPP.
> 
> Only the positive case for clone_skb needs to be checked. It
> is impossible for a user to set clone_skb to a negative number.
> When a user passes a negative value for clone_skb, the num_arg()
> function stops parsing at the first nonnumeric value.
> 
> For example: "clone_skb -200" would stop parsing at the
> first char ('-') and return zero for the new clone_skb value.
> 
> The value read by num_arg() cannot be overflow-ed into the negative
> range, since it is an unsigned long.
> 

module_param(pg_clone_skb_d, int, 0);

This kernel parameter can also set the value of pkt_dev->clone_skb
In pktgen_add_device() and the value can be negative.


> Remove redundant line that sets clone_skb to zero. If clone_skb is
> equal to zero then set xmit_mode to netif_receive as usual and return
> no error.
> 
> Signed-off-by: Nick Richardson <richardsonnick@google.com>
> ---
>  net/core/pktgen.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/net/core/pktgen.c b/net/core/pktgen.c
> index 7e258d255e90..314f97acf39d 100644
> --- a/net/core/pktgen.c
> +++ b/net/core/pktgen.c
> @@ -1190,11 +1190,6 @@ static ssize_t pktgen_if_write(struct file *file,
>  			 * pktgen_xmit() is called
>  			 */
>  			pkt_dev->last_ok = 1;
> -
> -			/* override clone_skb if user passed default value
> -			 * at module loading time
> -			 */
> -			pkt_dev->clone_skb = 0;
>  		} else if (strcmp(f, "queue_xmit") == 0) {
>  			pkt_dev->xmit_mode = M_QUEUE_XMIT;
>  			pkt_dev->last_ok = 1;
> --
> 2.32.0.554.ge1b32706d8-goog


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

* [PATCH v4] pktgen: Remove redundant clone_skb override
  2021-08-03  2:17       ` 答复: " zhudi (J)
@ 2021-08-03 16:27         ` Nicholas Richardson
  2021-08-04 12:00           ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 7+ messages in thread
From: Nicholas Richardson @ 2021-08-03 16:27 UTC (permalink / raw)
  To: davem, kuba
  Cc: nrrichar, arunkaly, Nick Richardson, Gustavo A. R. Silva,
	Leesoo Ahn, Ye Bin, Di Zhu, Yejune Deng, netdev, linux-kernel

From: Nick Richardson <richardsonnick@google.com>

When the netif_receive xmit_mode is set, a line is supposed to set
clone_skb to a default 0 value. This line is made redundant due to a
preceding line that checks if clone_skb is more than zero and returns
-ENOTSUPP.

Overriding clone_skb to 0 does not make any difference to the behavior
because if it was positive we return error. So it can be either 0 or
negative, and in both cases the behavior is the same.

Remove redundant line that sets clone_skb to zero.

Signed-off-by: Nick Richardson <richardsonnick@google.com>
---
 net/core/pktgen.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 7e258d255e90..314f97acf39d 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -1190,11 +1190,6 @@ static ssize_t pktgen_if_write(struct file *file,
 			 * pktgen_xmit() is called
 			 */
 			pkt_dev->last_ok = 1;
-
-			/* override clone_skb if user passed default value
-			 * at module loading time
-			 */
-			pkt_dev->clone_skb = 0;
 		} else if (strcmp(f, "queue_xmit") == 0) {
 			pkt_dev->xmit_mode = M_QUEUE_XMIT;
 			pkt_dev->last_ok = 1;
-- 
2.32.0.554.ge1b32706d8-goog


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

* Re: [PATCH v4] pktgen: Remove redundant clone_skb override
  2021-08-03 16:27         ` [PATCH v4] pktgen: Remove redundant " Nicholas Richardson
@ 2021-08-04 12:00           ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-08-04 12:00 UTC (permalink / raw)
  To: Nicholas Richardson
  Cc: davem, kuba, nrrichar, arunkaly, gustavoars, dev, yebin10,
	zhudi21, yejune.deng, netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Tue,  3 Aug 2021 16:27:35 +0000 you wrote:
> From: Nick Richardson <richardsonnick@google.com>
> 
> When the netif_receive xmit_mode is set, a line is supposed to set
> clone_skb to a default 0 value. This line is made redundant due to a
> preceding line that checks if clone_skb is more than zero and returns
> -ENOTSUPP.
> 
> [...]

Here is the summary with links:
  - [v4] pktgen: Remove redundant clone_skb override
    https://git.kernel.org/netdev/net-next/c/c2eecaa193ff

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-08-04 12:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210802071126.3b311638@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
2021-08-02 17:09 ` [PATCH net-next] pktgen: Fix invalid clone_skb override Nicholas Richardson
2021-08-02 17:12 ` [PATCH v2] " Nicholas Richardson
2021-08-02 17:21   ` Jakub Kicinski
2021-08-02 18:20     ` [PATCH v3] " Nicholas Richardson
2021-08-03  2:17       ` 答复: " zhudi (J)
2021-08-03 16:27         ` [PATCH v4] pktgen: Remove redundant " Nicholas Richardson
2021-08-04 12:00           ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.