Re: [PATCH bpf-next 2/2] selftests/bpf: Add pair_redir_to_connected helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/28/23 11:20 AM, Geliang Tang wrote:
Extract duplicate code from these four functions

  unix_redir_to_connected()
  udp_redir_to_connected()
  inet_unix_redir_to_connected()
  unix_inet_redir_to_connected()

to create a new helper pair_redir_to_connected(). Create the different
socketpair in these four functions, then pass the socketpair infos to
the new common helper to do the connections.

Signed-off-by: Geliang Tang <geliang.tang@xxxxxxxx>
---
  .../selftests/bpf/prog_tests/sockmap_listen.c | 149 ++++--------------
  1 file changed, 30 insertions(+), 119 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
index 8df8cbb447f1..fbdf7eb23c1b 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
@@ -1336,27 +1336,17 @@ static void test_redir(struct test_sockmap_listen *skel, struct bpf_map *map,
  	}
  }
-static void unix_redir_to_connected(int sotype, int sock_mapfd,
-			       int verd_mapfd, enum redir_mode mode)
+static void pair_redir_to_connected(int c0, int p0, int c1, int p1,
+		int sock_mapfd, int verd_mapfd, enum redir_mode mode)

just nit: indent, and could we find sth more descriptive than {c,p}0 and {c,p}1?

otherwise, lgtm.

  {
  	const char *log_prefix = redir_mode_str(mode);
-	int c0, c1, p0, p1;
  	unsigned int pass;
  	int err, n;
-	int sfd[2];
  	u32 key;
  	char b;
zero_verdict_count(verd_mapfd);




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux