Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [patch net-next v2] devlink: append split port number to the port name
@ 2021-05-27 10:48 Jiri Pirko
  2021-05-27 21:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 4+ messages in thread
From: Jiri Pirko @ 2021-05-27 10:48 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, mlxsw

From: Jiri Pirko <jiri@nvidia.com>

Instead of doing sprintf twice in case the port is split or not, append
the split port suffix in case the port is split.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
v1->v2:
- added check for buffer overflow
---
 net/core/devlink.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 06b2b1941dce..8f9a5de44117 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -8632,12 +8632,10 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
 	switch (attrs->flavour) {
 	case DEVLINK_PORT_FLAVOUR_PHYSICAL:
 	case DEVLINK_PORT_FLAVOUR_VIRTUAL:
-		if (!attrs->split)
-			n = snprintf(name, len, "p%u", attrs->phys.port_number);
-		else
-			n = snprintf(name, len, "p%us%u",
-				     attrs->phys.port_number,
-				     attrs->phys.split_subport_number);
+		n = snprintf(name, len, "p%u", attrs->phys.port_number);
+		if (n < len && attrs->split)
+			n += snprintf(name + n, len - n, "s%u",
+				      attrs->phys.split_subport_number);
 		break;
 	case DEVLINK_PORT_FLAVOUR_CPU:
 	case DEVLINK_PORT_FLAVOUR_DSA:
-- 
2.31.1


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

* Re: [patch net-next v2] devlink: append split port number to the port name
  2021-05-27 10:48 [patch net-next v2] devlink: append split port number to the port name Jiri Pirko
@ 2021-05-27 21:30 ` patchwork-bot+netdevbpf
  2021-07-23  9:33   ` Jiri Pirko
  0 siblings, 1 reply; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-05-27 21:30 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, kuba, mlxsw

Hello:

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

On Thu, 27 May 2021 12:48:19 +0200 you wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> Instead of doing sprintf twice in case the port is split or not, append
> the split port suffix in case the port is split.
> 
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
> 
> [...]

Here is the summary with links:
  - [net-next,v2] devlink: append split port number to the port name
    https://git.kernel.org/netdev/net-next/c/f285f37cb1e6

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] 4+ messages in thread

* Re: [patch net-next v2] devlink: append split port number to the port name
  2021-05-27 21:30 ` patchwork-bot+netdevbpf
@ 2021-07-23  9:33   ` Jiri Pirko
  2021-07-30 12:18     ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Jiri Pirko @ 2021-07-23  9:33 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, davem, kuba, mlxsw

Thu, May 27, 2021 at 11:30:03PM CEST, patchwork-bot+netdevbpf@kernel.org wrote:
>Hello:
>
>This patch was applied to netdev/net-next.git (refs/heads/master):
>
>On Thu, 27 May 2021 12:48:19 +0200 you wrote:
>> From: Jiri Pirko <jiri@nvidia.com>
>> 
>> Instead of doing sprintf twice in case the port is split or not, append
>> the split port suffix in case the port is split.
>> 
>> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
>> 
>> [...]
>
>Here is the summary with links:
>  - [net-next,v2] devlink: append split port number to the port name
>    https://git.kernel.org/netdev/net-next/c/f285f37cb1e6
>
>You are awesome, thank you!

Something wrong happened. The patch was applied but eventually, the
removed lines are back:

acf1ee44ca5da (Parav Pandit    2020-03-03 08:12:42 -0600 9331)  case DEVLINK_PORT_FLAVOUR_VIRTUAL:
f285f37cb1e6b (Jiri Pirko      2021-05-27 12:48:19 +0200 9332)          n = snprintf(name, len, "p%u", attrs->phys.port_number);
f285f37cb1e6b (Jiri Pirko      2021-05-27 12:48:19 +0200 9333)          if (n < len && attrs->split)
f285f37cb1e6b (Jiri Pirko      2021-05-27 12:48:19 +0200 9334)                  n += snprintf(name + n, len - n, "s%u",
f285f37cb1e6b (Jiri Pirko      2021-05-27 12:48:19 +0200 9335)                                attrs->phys.split_subport_number);
08474c1a9df0c (Jiri Pirko      2018-05-18 09:29:02 +0200 9336)          if (!attrs->split)
378ef01b5f75e (Parav Pandit    2019-07-08 23:17:35 -0500 9337)                  n = snprintf(name, len, "p%u", attrs->phys.port_number);
08474c1a9df0c (Jiri Pirko      2018-05-18 09:29:02 +0200 9338)          else
378ef01b5f75e (Parav Pandit    2019-07-08 23:17:35 -0500 9339)                  n = snprintf(name, len, "p%us%u",
378ef01b5f75e (Parav Pandit    2019-07-08 23:17:35 -0500 9340)                               attrs->phys.port_number,
378ef01b5f75e (Parav Pandit    2019-07-08 23:17:35 -0500 9341)                               attrs->phys.split_subport_number);
126285651b7f9 (David S. Miller 2021-06-07 13:01:52 -0700 9342) 
08474c1a9df0c (Jiri Pirko      2018-05-18 09:29:02 +0200 9343)          break;

If I do "git reset --hard f285f37cb1e6b", everything is looking fine,
in the current net-next, the removed lines are still present :O
I see ghosts...

Could you check & fix?

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

* Re: [patch net-next v2] devlink: append split port number to the port name
  2021-07-23  9:33   ` Jiri Pirko
@ 2021-07-30 12:18     ` Jakub Kicinski
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2021-07-30 12:18 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: davem, netdev, mlxsw

On Fri, 23 Jul 2021 11:33:36 +0200 Jiri Pirko wrote:
> Something wrong happened. The patch was applied but eventually, the
> removed lines are back:
> 
> acf1ee44ca5da (Parav Pandit    2020-03-03 08:12:42 -0600 9331)  case DEVLINK_PORT_FLAVOUR_VIRTUAL:
> f285f37cb1e6b (Jiri Pirko      2021-05-27 12:48:19 +0200 9332)          n = snprintf(name, len, "p%u", attrs->phys.port_number);
> f285f37cb1e6b (Jiri Pirko      2021-05-27 12:48:19 +0200 9333)          if (n < len && attrs->split)
> f285f37cb1e6b (Jiri Pirko      2021-05-27 12:48:19 +0200 9334)                  n += snprintf(name + n, len - n, "s%u",
> f285f37cb1e6b (Jiri Pirko      2021-05-27 12:48:19 +0200 9335)                                attrs->phys.split_subport_number);
> 08474c1a9df0c (Jiri Pirko      2018-05-18 09:29:02 +0200 9336)          if (!attrs->split)
> 378ef01b5f75e (Parav Pandit    2019-07-08 23:17:35 -0500 9337)                  n = snprintf(name, len, "p%u", attrs->phys.port_number);
> 08474c1a9df0c (Jiri Pirko      2018-05-18 09:29:02 +0200 9338)          else
> 378ef01b5f75e (Parav Pandit    2019-07-08 23:17:35 -0500 9339)                  n = snprintf(name, len, "p%us%u",
> 378ef01b5f75e (Parav Pandit    2019-07-08 23:17:35 -0500 9340)                               attrs->phys.port_number,
> 378ef01b5f75e (Parav Pandit    2019-07-08 23:17:35 -0500 9341)                               attrs->phys.split_subport_number);
> 126285651b7f9 (David S. Miller 2021-06-07 13:01:52 -0700 9342) 
> 08474c1a9df0c (Jiri Pirko      2018-05-18 09:29:02 +0200 9343)          break;
> 
> If I do "git reset --hard f285f37cb1e6b", everything is looking fine,
> in the current net-next, the removed lines are still present :O
> I see ghosts...
> 
> Could you check & fix?

Looks like it was fixed by commit 149ea30fdd5c ("devlink: Fix
phys_port_name of virtual port and merge error") in net. I'll 
merge net -> net-next soon, sorry for the breakage.

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

end of thread, other threads:[~2021-07-30 12:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 10:48 [patch net-next v2] devlink: append split port number to the port name Jiri Pirko
2021-05-27 21:30 ` patchwork-bot+netdevbpf
2021-07-23  9:33   ` Jiri Pirko
2021-07-30 12:18     ` Jakub Kicinski

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).