9
9
10
10
static const int nr_soreuse = 4 ;
11
11
12
+ struct iter_out {
13
+ int idx ;
14
+ __u64 cookie ;
15
+ } __packed ;
16
+
12
17
static void do_test (int sock_type , bool onebyone )
13
18
{
14
19
int err , i , nread , to_read , total_read , iter_fd = -1 ;
15
- int first_idx , second_idx , indices [nr_soreuse ];
20
+ struct iter_out outputs [nr_soreuse ];
16
21
struct bpf_link * link = NULL ;
17
22
struct sock_iter_batch * skel ;
23
+ int first_idx , second_idx ;
18
24
int * fds [2 ] = {};
19
25
20
26
skel = sock_iter_batch__open ();
@@ -34,6 +40,7 @@ static void do_test(int sock_type, bool onebyone)
34
40
goto done ;
35
41
skel -> rodata -> ports [i ] = ntohs (local_port );
36
42
}
43
+ skel -> rodata -> sf = AF_INET6 ;
37
44
38
45
err = sock_iter_batch__load (skel );
39
46
if (!ASSERT_OK (err , "sock_iter_batch__load" ))
@@ -55,38 +62,38 @@ static void do_test(int sock_type, bool onebyone)
55
62
* from a bucket and leave one socket out from
56
63
* that bucket on purpose.
57
64
*/
58
- to_read = (nr_soreuse - 1 ) * sizeof (* indices );
65
+ to_read = (nr_soreuse - 1 ) * sizeof (* outputs );
59
66
total_read = 0 ;
60
67
first_idx = -1 ;
61
68
do {
62
- nread = read (iter_fd , indices , onebyone ? sizeof (* indices ) : to_read );
63
- if (nread <= 0 || nread % sizeof (* indices ))
69
+ nread = read (iter_fd , outputs , onebyone ? sizeof (* outputs ) : to_read );
70
+ if (nread <= 0 || nread % sizeof (* outputs ))
64
71
break ;
65
72
total_read += nread ;
66
73
67
74
if (first_idx == -1 )
68
- first_idx = indices [0 ];
69
- for (i = 0 ; i < nread / sizeof (* indices ); i ++ )
70
- ASSERT_EQ (indices [i ], first_idx , "first_idx" );
75
+ first_idx = outputs [0 ]. idx ;
76
+ for (i = 0 ; i < nread / sizeof (* outputs ); i ++ )
77
+ ASSERT_EQ (outputs [i ]. idx , first_idx , "first_idx" );
71
78
} while (total_read < to_read );
72
- ASSERT_EQ (nread , onebyone ? sizeof (* indices ) : to_read , "nread" );
79
+ ASSERT_EQ (nread , onebyone ? sizeof (* outputs ) : to_read , "nread" );
73
80
ASSERT_EQ (total_read , to_read , "total_read" );
74
81
75
82
free_fds (fds [first_idx ], nr_soreuse );
76
83
fds [first_idx ] = NULL ;
77
84
78
85
/* Read the "whole" second bucket */
79
- to_read = nr_soreuse * sizeof (* indices );
86
+ to_read = nr_soreuse * sizeof (* outputs );
80
87
total_read = 0 ;
81
88
second_idx = !first_idx ;
82
89
do {
83
- nread = read (iter_fd , indices , onebyone ? sizeof (* indices ) : to_read );
84
- if (nread <= 0 || nread % sizeof (* indices ))
90
+ nread = read (iter_fd , outputs , onebyone ? sizeof (* outputs ) : to_read );
91
+ if (nread <= 0 || nread % sizeof (* outputs ))
85
92
break ;
86
93
total_read += nread ;
87
94
88
- for (i = 0 ; i < nread / sizeof (* indices ); i ++ )
89
- ASSERT_EQ (indices [i ], second_idx , "second_idx" );
95
+ for (i = 0 ; i < nread / sizeof (* outputs ); i ++ )
96
+ ASSERT_EQ (outputs [i ]. idx , second_idx , "second_idx" );
90
97
} while (total_read <= to_read );
91
98
ASSERT_EQ (nread , 0 , "nread" );
92
99
/* Both so_reuseport ports should be in different buckets, so
0 commit comments