Skip to contentSkip to conversation

pktgen: Fix invalid clone_skb override

PATCH Superseded Nicholas Richardson 4 participants 7 messages Aug 2, 2021 – Aug 4, 2021 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20210802071126.3b311638@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com

#1 lore raw

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!

#2 lore raw

PATCH v2 1/1 pktgen: Fix invalid clone_skb override

In reply to a message not in the archive

From: Nick Richardson <[email protected]>

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.

---
 net/core/pktgen.c | 5 -----
 1 file changed, 5 deletions(-)
net/core/pktgen.c +0 -5
index 7e258d255e90..314f97acf39d 100644
@@ -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;
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
maintainer
#3 lore raw
Quoted 7 lines · On Mon, 2 Aug 2021 17:12:07 +0000 Nicholas Richardson wrote:

From: Nick Richardson <[email protected]>

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/

Quoted 2 lines

-ENOTSUPP is returned
if clone_skb is more than zero.

That's already mentioned in the previous paragraph.

Quoted 2 lines

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.

#4 lore raw

PATCH v3 1/1 pktgen: Fix invalid clone_skb override

From: Nick Richardson <[email protected]>

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.

---
 net/core/pktgen.c | 5 -----
 1 file changed, 5 deletions(-)
net/core/pktgen.c +0 -5
index 7e258d255e90..314f97acf39d 100644
@@ -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;
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
#5 lore raw
Quoted 12 lines

From: Nick Richardson <[email protected]>

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.

Quoted 6 lines

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.

Quoted 27 lines

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.

---
 net/core/pktgen.c | 5 -----
 1 file changed, 5 deletions(-)
net/core/pktgen.c +0 -6
index 7e258d255e90..314f97acf39d 100644
@@ -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

#6 lore raw

PATCH v4 1/1 pktgen: Remove redundant clone_skb override

From: Nick Richardson <[email protected]>

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.

---
 net/core/pktgen.c | 5 -----
 1 file changed, 5 deletions(-)
net/core/pktgen.c +0 -5
index 7e258d255e90..314f97acf39d 100644
@@ -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;
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
#7 lore raw

Re: [PATCH v4] pktgen: Remove redundant clone_skb override

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

Hello:

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

Quoted 8 lines · On Tue, 3 Aug 2021 16:27:35 +0000 you wrote:

From: Nick Richardson <[email protected]>

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