netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] tc: f_u32: fix json object leak
@ 2023-02-28  7:31 Hangbin Liu
  2023-03-05 17:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Hangbin Liu @ 2023-02-28  7:31 UTC (permalink / raw)
  To: netdev; +Cc: David Ahern, Stephen Hemminger, Wen Liang, Hangbin Liu

Previously, the code returned directly within the switch statement in
the functions print_{ipv4, ipv6}. While this approach was functional,
after the commit 721435dc, we can no longer return directly because we
need to close the match object. To resolve this issue, replace the return
statement with break.

Fixes: 721435dcfd92 ("tc: u32: add json support in `print_raw`, `print_ipv4`, `print_ipv6`")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 tc/f_u32.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/tc/f_u32.c b/tc/f_u32.c
index de2d0c9e..936dbd65 100644
--- a/tc/f_u32.c
+++ b/tc/f_u32.c
@@ -828,12 +828,12 @@ static void print_ipv4(FILE *f, const struct tc_u32_key *key)
 			print_nl();
 			print_uint(PRINT_ANY, "ip_ihl", "  match IP ihl %u",
 				   ntohl(key->val) >> 24);
-			return;
+			break;
 		case 0x00ff0000:
 			print_nl();
 			print_0xhex(PRINT_ANY, "ip_dsfield", "  match IP dsfield %#x",
 				    ntohl(key->val) >> 16);
-			return;
+			break;
 		}
 		break;
 	case 8:
@@ -841,7 +841,6 @@ static void print_ipv4(FILE *f, const struct tc_u32_key *key)
 			print_nl();
 			print_int(PRINT_ANY, "ip_protocol", "  match IP protocol %d",
 				  ntohl(key->val) >> 16);
-			return;
 		}
 		break;
 	case 12:
@@ -864,7 +863,6 @@ static void print_ipv4(FILE *f, const struct tc_u32_key *key)
 				print_string(PRINT_ANY, "address", "%s", addr);
 				print_int(PRINT_ANY, "prefixlen", "/%d", bits);
 				close_json_object();
-				return;
 			}
 		}
 		break;
@@ -874,19 +872,19 @@ static void print_ipv4(FILE *f, const struct tc_u32_key *key)
 		case 0x0000ffff:
 			print_uint(PRINT_ANY, "dport", "match dport %u",
 				   ntohl(key->val) & 0xffff);
-			return;
+			break;
 		case 0xffff0000:
 			print_nl();
 			print_uint(PRINT_ANY, "sport", "  match sport %u",
 				   ntohl(key->val) >> 16);
-			return;
+			break;
 		case 0xffffffff:
 			print_nl();
 			print_uint(PRINT_ANY, "dport", "  match dport %u, ",
 				   ntohl(key->val) & 0xffff);
 			print_uint(PRINT_ANY, "sport", "match sport %u",
 				   ntohl(key->val) >> 16);
-			return;
+			break;
 		}
 		/* XXX: Default print_raw */
 	}
@@ -905,12 +903,12 @@ static void print_ipv6(FILE *f, const struct tc_u32_key *key)
 			print_nl();
 			print_uint(PRINT_ANY, "ip_ihl", "  match IP ihl %u",
 				   ntohl(key->val) >> 24);
-			return;
+			break;
 		case 0x00ff0000:
 			print_nl();
 			print_0xhex(PRINT_ANY, "ip_dsfield", "  match IP dsfield %#x",
 				    ntohl(key->val) >> 16);
-			return;
+			break;
 		}
 		break;
 	case 8:
@@ -918,7 +916,6 @@ static void print_ipv6(FILE *f, const struct tc_u32_key *key)
 			print_nl();
 			print_int(PRINT_ANY, "ip_protocol", "  match IP protocol %d",
 				  ntohl(key->val) >> 16);
-			return;
 		}
 		break;
 	case 12:
@@ -941,7 +938,6 @@ static void print_ipv6(FILE *f, const struct tc_u32_key *key)
 				print_string(PRINT_ANY, "address", "%s", addr);
 				print_int(PRINT_ANY, "prefixlen", "/%d", bits);
 				close_json_object();
-				return;
 			}
 		}
 		break;
@@ -952,11 +948,11 @@ static void print_ipv6(FILE *f, const struct tc_u32_key *key)
 			print_nl();
 			print_uint(PRINT_ANY, "sport", "  match sport %u",
 				   ntohl(key->val) & 0xffff);
-			return;
+			break;
 		case 0xffff0000:
 			print_uint(PRINT_ANY, "dport", "match dport %u",
 				   ntohl(key->val) >> 16);
-			return;
+			break;
 		case 0xffffffff:
 			print_nl();
 			print_uint(PRINT_ANY, "sport", "  match sport %u, ",
@@ -964,7 +960,7 @@ static void print_ipv6(FILE *f, const struct tc_u32_key *key)
 			print_uint(PRINT_ANY, "dport", "match dport %u",
 				   ntohl(key->val) >> 16);
 
-			return;
+			break;
 		}
 		/* XXX: Default print_raw */
 	}
-- 
2.38.1


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

* Re: [PATCH iproute2] tc: f_u32: fix json object leak
  2023-02-28  7:31 [PATCH iproute2] tc: f_u32: fix json object leak Hangbin Liu
@ 2023-03-05 17:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-03-05 17:00 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev, dsahern, stephen, liangwen12year

Hello:

This patch was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber.org>:

On Tue, 28 Feb 2023 15:31:46 +0800 you wrote:
> Previously, the code returned directly within the switch statement in
> the functions print_{ipv4, ipv6}. While this approach was functional,
> after the commit 721435dc, we can no longer return directly because we
> need to close the match object. To resolve this issue, replace the return
> statement with break.
> 
> Fixes: 721435dcfd92 ("tc: u32: add json support in `print_raw`, `print_ipv4`, `print_ipv6`")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> 
> [...]

Here is the summary with links:
  - [iproute2] tc: f_u32: fix json object leak
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=6637a6d512a9

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

end of thread, other threads:[~2023-03-05 17:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-28  7:31 [PATCH iproute2] tc: f_u32: fix json object leak Hangbin Liu
2023-03-05 17:00 ` patchwork-bot+netdevbpf

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