File tree Expand file tree Collapse file tree
tools/testing/selftests/bpf Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -448,6 +448,7 @@ BPF_SKEL_FUNCS(sendmsg6_prog, sendmsg_v6_prog);
448448BPF_SKEL_FUNCS (sendmsg6_prog , sendmsg_v6_deny_prog );
449449BPF_SKEL_FUNCS (sendmsg6_prog , sendmsg_v6_preserve_dst_prog );
450450BPF_SKEL_FUNCS (sendmsg6_prog , sendmsg_v6_v4mapped_prog );
451+ BPF_SKEL_FUNCS (sendmsg6_prog , sendmsg_v6_wildcard_prog );
451452BPF_SKEL_FUNCS (sendmsg_unix_prog , sendmsg_unix_prog );
452453BPF_SKEL_FUNCS (recvmsg4_prog , recvmsg4_prog );
453454BPF_SKEL_FUNCS (recvmsg6_prog , recvmsg6_prog );
@@ -849,6 +850,22 @@ static struct sock_addr_test tests[] = {
849850 SRC6_REWRITE_IP ,
850851 SYSCALL_ENOTSUPP ,
851852 },
853+ {
854+ SOCK_ADDR_TEST_SENDMSG ,
855+ "sendmsg6: sendmsg dst IP = [::] (BSD'ism) (dgram)" ,
856+ sendmsg_v6_wildcard_prog_load ,
857+ sendmsg_v6_wildcard_prog_destroy ,
858+ BPF_CGROUP_UDP6_SENDMSG ,
859+ & user_ops ,
860+ AF_INET6 ,
861+ SOCK_DGRAM ,
862+ SERV6_IP ,
863+ SERV6_PORT ,
864+ SERV6_REWRITE_IP ,
865+ SERV6_REWRITE_PORT ,
866+ SRC6_REWRITE_IP ,
867+ SUCCESS ,
868+ },
852869 {
853870 SOCK_ADDR_TEST_SENDMSG ,
854871 "sendmsg_unix: sendmsg (dgram)" ,
Original file line number Diff line number Diff line change @@ -84,6 +84,26 @@ int sendmsg_v6_v4mapped_prog(struct bpf_sock_addr *ctx)
8484 return 1 ;
8585}
8686
87+ SEC ("cgroup/sendmsg6" )
88+ int sendmsg_v6_wildcard_prog (struct bpf_sock_addr * ctx )
89+ {
90+ /* Rewrite source. */
91+ ctx -> msg_src_ip6 [0 ] = bpf_htonl (SRC_REWRITE_IP6_0 );
92+ ctx -> msg_src_ip6 [1 ] = bpf_htonl (SRC_REWRITE_IP6_1 );
93+ ctx -> msg_src_ip6 [2 ] = bpf_htonl (SRC_REWRITE_IP6_2 );
94+ ctx -> msg_src_ip6 [3 ] = bpf_htonl (SRC_REWRITE_IP6_3 );
95+
96+ /* Rewrite destination. */
97+ ctx -> user_ip6 [0 ] = bpf_htonl (0 );
98+ ctx -> user_ip6 [1 ] = bpf_htonl (0 );
99+ ctx -> user_ip6 [2 ] = bpf_htonl (0 );
100+ ctx -> user_ip6 [3 ] = bpf_htonl (0 );
101+
102+ ctx -> user_port = bpf_htons (DST_REWRITE_PORT6 );
103+
104+ return 1 ;
105+ }
106+
87107SEC ("cgroup/sendmsg6" )
88108int sendmsg_v6_preserve_dst_prog (struct bpf_sock_addr * ctx )
89109{
Original file line number Diff line number Diff line change @@ -94,7 +94,6 @@ static int connect4_prog_load(const struct sock_addr_test *test);
9494static int connect6_prog_load (const struct sock_addr_test * test );
9595static int sendmsg4_rw_asm_prog_load (const struct sock_addr_test * test );
9696static int sendmsg6_rw_asm_prog_load (const struct sock_addr_test * test );
97- static int sendmsg6_rw_wildcard_prog_load (const struct sock_addr_test * test );
9897
9998static struct sock_addr_test tests [] = {
10099 /* bind */
@@ -298,20 +297,6 @@ static struct sock_addr_test tests[] = {
298297 SRC6_REWRITE_IP ,
299298 SUCCESS ,
300299 },
301- {
302- "sendmsg6: set dst IP = [::] (BSD'ism)" ,
303- sendmsg6_rw_wildcard_prog_load ,
304- BPF_CGROUP_UDP6_SENDMSG ,
305- BPF_CGROUP_UDP6_SENDMSG ,
306- AF_INET6 ,
307- SOCK_DGRAM ,
308- SERV6_IP ,
309- SERV6_PORT ,
310- SERV6_REWRITE_IP ,
311- SERV6_REWRITE_PORT ,
312- SRC6_REWRITE_IP ,
313- SUCCESS ,
314- },
315300};
316301
317302static int load_insns (const struct sock_addr_test * test ,
@@ -497,11 +482,6 @@ static int sendmsg6_rw_asm_prog_load(const struct sock_addr_test *test)
497482 return sendmsg6_rw_dst_asm_prog_load (test , SERV6_REWRITE_IP );
498483}
499484
500- static int sendmsg6_rw_wildcard_prog_load (const struct sock_addr_test * test )
501- {
502- return sendmsg6_rw_dst_asm_prog_load (test , WILDCARD6_IP );
503- }
504-
505485static int cmp_addr (const struct sockaddr_storage * addr1 ,
506486 const struct sockaddr_storage * addr2 , int cmp_port )
507487{
You can’t perform that action at this time.
0 commit comments