2929
3030#include "sockmap_helpers.h"
3131
32+ #define NO_FLAGS 0
33+
3234static void test_insert_invalid (struct test_sockmap_listen * skel __always_unused ,
3335 int family , int sotype , int mapfd )
3436{
@@ -1376,7 +1378,8 @@ static void test_redir(struct test_sockmap_listen *skel, struct bpf_map *map,
13761378
13771379static void pairs_redir_to_connected (int cli0 , int peer0 , int cli1 , int peer1 ,
13781380 int sock_mapfd , int nop_mapfd ,
1379- int verd_mapfd , enum redir_mode mode )
1381+ int verd_mapfd , enum redir_mode mode ,
1382+ int send_flags )
13801383{
13811384 const char * log_prefix = redir_mode_str (mode );
13821385 unsigned int pass ;
@@ -1396,11 +1399,9 @@ static void pairs_redir_to_connected(int cli0, int peer0, int cli1, int peer1,
13961399 return ;
13971400 }
13981401
1399- n = write (cli1 , "a" , 1 );
1400- if (n < 0 )
1401- FAIL_ERRNO ("%s: write" , log_prefix );
1402+ n = xsend (cli1 , "a" , 1 , send_flags );
14021403 if (n == 0 )
1403- FAIL ("%s: incomplete write " , log_prefix );
1404+ FAIL ("%s: incomplete send " , log_prefix );
14041405 if (n < 1 )
14051406 return ;
14061407
@@ -1432,7 +1433,8 @@ static void unix_redir_to_connected(int sotype, int sock_mapfd,
14321433 goto close0 ;
14331434 c1 = sfd [0 ], p1 = sfd [1 ];
14341435
1435- pairs_redir_to_connected (c0 , p0 , c1 , p1 , sock_mapfd , -1 , verd_mapfd , mode );
1436+ pairs_redir_to_connected (c0 , p0 , c1 , p1 , sock_mapfd , -1 , verd_mapfd ,
1437+ mode , NO_FLAGS );
14361438
14371439 xclose (c1 );
14381440 xclose (p1 );
@@ -1722,7 +1724,8 @@ static void udp_redir_to_connected(int family, int sock_mapfd, int verd_mapfd,
17221724 if (err )
17231725 goto close_cli0 ;
17241726
1725- pairs_redir_to_connected (c0 , p0 , c1 , p1 , sock_mapfd , -1 , verd_mapfd , mode );
1727+ pairs_redir_to_connected (c0 , p0 , c1 , p1 , sock_mapfd , -1 , verd_mapfd ,
1728+ mode , NO_FLAGS );
17261729
17271730 xclose (c1 );
17281731 xclose (p1 );
@@ -1780,7 +1783,8 @@ static void inet_unix_redir_to_connected(int family, int type, int sock_mapfd,
17801783 if (err )
17811784 goto close ;
17821785
1783- pairs_redir_to_connected (c0 , p0 , c1 , p1 , sock_mapfd , -1 , verd_mapfd , mode );
1786+ pairs_redir_to_connected (c0 , p0 , c1 , p1 , sock_mapfd , -1 , verd_mapfd ,
1787+ mode , NO_FLAGS );
17841788
17851789 xclose (c1 );
17861790 xclose (p1 );
@@ -1815,10 +1819,9 @@ static void inet_unix_skb_redir_to_connected(struct test_sockmap_listen *skel,
18151819 xbpf_prog_detach2 (verdict , sock_map , BPF_SK_SKB_VERDICT );
18161820}
18171821
1818- static void unix_inet_redir_to_connected (int family , int type ,
1819- int sock_mapfd , int nop_mapfd ,
1820- int verd_mapfd ,
1821- enum redir_mode mode )
1822+ static void unix_inet_redir_to_connected (int family , int type , int sock_mapfd ,
1823+ int nop_mapfd , int verd_mapfd ,
1824+ enum redir_mode mode , int send_flags )
18221825{
18231826 int c0 , c1 , p0 , p1 ;
18241827 int sfd [2 ];
@@ -1832,8 +1835,8 @@ static void unix_inet_redir_to_connected(int family, int type,
18321835 goto close_cli0 ;
18331836 c1 = sfd [0 ], p1 = sfd [1 ];
18341837
1835- pairs_redir_to_connected (c0 , p0 , c1 , p1 ,
1836- sock_mapfd , nop_mapfd , verd_mapfd , mode );
1838+ pairs_redir_to_connected (c0 , p0 , c1 , p1 , sock_mapfd , nop_mapfd ,
1839+ verd_mapfd , mode , send_flags );
18371840
18381841 xclose (c1 );
18391842 xclose (p1 );
@@ -1858,31 +1861,32 @@ static void unix_inet_skb_redir_to_connected(struct test_sockmap_listen *skel,
18581861 skel -> bss -> test_ingress = false;
18591862 unix_inet_redir_to_connected (family , SOCK_DGRAM ,
18601863 sock_map , -1 , verdict_map ,
1861- REDIR_EGRESS );
1864+ REDIR_EGRESS , NO_FLAGS );
18621865 unix_inet_redir_to_connected (family , SOCK_DGRAM ,
18631866 sock_map , -1 , verdict_map ,
1864- REDIR_EGRESS );
1867+ REDIR_EGRESS , NO_FLAGS );
18651868
18661869 unix_inet_redir_to_connected (family , SOCK_DGRAM ,
18671870 sock_map , nop_map , verdict_map ,
1868- REDIR_EGRESS );
1871+ REDIR_EGRESS , NO_FLAGS );
18691872 unix_inet_redir_to_connected (family , SOCK_STREAM ,
18701873 sock_map , nop_map , verdict_map ,
1871- REDIR_EGRESS );
1874+ REDIR_EGRESS , NO_FLAGS );
1875+
18721876 skel -> bss -> test_ingress = true;
18731877 unix_inet_redir_to_connected (family , SOCK_DGRAM ,
18741878 sock_map , -1 , verdict_map ,
1875- REDIR_INGRESS );
1879+ REDIR_INGRESS , NO_FLAGS );
18761880 unix_inet_redir_to_connected (family , SOCK_STREAM ,
18771881 sock_map , -1 , verdict_map ,
1878- REDIR_INGRESS );
1882+ REDIR_INGRESS , NO_FLAGS );
18791883
18801884 unix_inet_redir_to_connected (family , SOCK_DGRAM ,
18811885 sock_map , nop_map , verdict_map ,
1882- REDIR_INGRESS );
1886+ REDIR_INGRESS , NO_FLAGS );
18831887 unix_inet_redir_to_connected (family , SOCK_STREAM ,
18841888 sock_map , nop_map , verdict_map ,
1885- REDIR_INGRESS );
1889+ REDIR_INGRESS , NO_FLAGS );
18861890
18871891 xbpf_prog_detach2 (verdict , sock_map , BPF_SK_SKB_VERDICT );
18881892}
0 commit comments