29
29
30
30
#include "sockmap_helpers.h"
31
31
32
+ #define NO_FLAGS 0
33
+
32
34
static void test_insert_invalid (struct test_sockmap_listen * skel __always_unused ,
33
35
int family , int sotype , int mapfd )
34
36
{
@@ -1376,7 +1378,8 @@ static void test_redir(struct test_sockmap_listen *skel, struct bpf_map *map,
1376
1378
1377
1379
static void pairs_redir_to_connected (int cli0 , int peer0 , int cli1 , int peer1 ,
1378
1380
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 )
1380
1383
{
1381
1384
const char * log_prefix = redir_mode_str (mode );
1382
1385
unsigned int pass ;
@@ -1396,11 +1399,9 @@ static void pairs_redir_to_connected(int cli0, int peer0, int cli1, int peer1,
1396
1399
return ;
1397
1400
}
1398
1401
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 );
1402
1403
if (n == 0 )
1403
- FAIL ("%s: incomplete write " , log_prefix );
1404
+ FAIL ("%s: incomplete send " , log_prefix );
1404
1405
if (n < 1 )
1405
1406
return ;
1406
1407
@@ -1432,7 +1433,8 @@ static void unix_redir_to_connected(int sotype, int sock_mapfd,
1432
1433
goto close0 ;
1433
1434
c1 = sfd [0 ], p1 = sfd [1 ];
1434
1435
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 );
1436
1438
1437
1439
xclose (c1 );
1438
1440
xclose (p1 );
@@ -1722,7 +1724,8 @@ static void udp_redir_to_connected(int family, int sock_mapfd, int verd_mapfd,
1722
1724
if (err )
1723
1725
goto close_cli0 ;
1724
1726
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 );
1726
1729
1727
1730
xclose (c1 );
1728
1731
xclose (p1 );
@@ -1780,7 +1783,8 @@ static void inet_unix_redir_to_connected(int family, int type, int sock_mapfd,
1780
1783
if (err )
1781
1784
goto close ;
1782
1785
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 );
1784
1788
1785
1789
xclose (c1 );
1786
1790
xclose (p1 );
@@ -1815,10 +1819,9 @@ static void inet_unix_skb_redir_to_connected(struct test_sockmap_listen *skel,
1815
1819
xbpf_prog_detach2 (verdict , sock_map , BPF_SK_SKB_VERDICT );
1816
1820
}
1817
1821
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 )
1822
1825
{
1823
1826
int c0 , c1 , p0 , p1 ;
1824
1827
int sfd [2 ];
@@ -1832,8 +1835,8 @@ static void unix_inet_redir_to_connected(int family, int type,
1832
1835
goto close_cli0 ;
1833
1836
c1 = sfd [0 ], p1 = sfd [1 ];
1834
1837
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 );
1837
1840
1838
1841
xclose (c1 );
1839
1842
xclose (p1 );
@@ -1858,31 +1861,32 @@ static void unix_inet_skb_redir_to_connected(struct test_sockmap_listen *skel,
1858
1861
skel -> bss -> test_ingress = false;
1859
1862
unix_inet_redir_to_connected (family , SOCK_DGRAM ,
1860
1863
sock_map , -1 , verdict_map ,
1861
- REDIR_EGRESS );
1864
+ REDIR_EGRESS , NO_FLAGS );
1862
1865
unix_inet_redir_to_connected (family , SOCK_DGRAM ,
1863
1866
sock_map , -1 , verdict_map ,
1864
- REDIR_EGRESS );
1867
+ REDIR_EGRESS , NO_FLAGS );
1865
1868
1866
1869
unix_inet_redir_to_connected (family , SOCK_DGRAM ,
1867
1870
sock_map , nop_map , verdict_map ,
1868
- REDIR_EGRESS );
1871
+ REDIR_EGRESS , NO_FLAGS );
1869
1872
unix_inet_redir_to_connected (family , SOCK_STREAM ,
1870
1873
sock_map , nop_map , verdict_map ,
1871
- REDIR_EGRESS );
1874
+ REDIR_EGRESS , NO_FLAGS );
1875
+
1872
1876
skel -> bss -> test_ingress = true;
1873
1877
unix_inet_redir_to_connected (family , SOCK_DGRAM ,
1874
1878
sock_map , -1 , verdict_map ,
1875
- REDIR_INGRESS );
1879
+ REDIR_INGRESS , NO_FLAGS );
1876
1880
unix_inet_redir_to_connected (family , SOCK_STREAM ,
1877
1881
sock_map , -1 , verdict_map ,
1878
- REDIR_INGRESS );
1882
+ REDIR_INGRESS , NO_FLAGS );
1879
1883
1880
1884
unix_inet_redir_to_connected (family , SOCK_DGRAM ,
1881
1885
sock_map , nop_map , verdict_map ,
1882
- REDIR_INGRESS );
1886
+ REDIR_INGRESS , NO_FLAGS );
1883
1887
unix_inet_redir_to_connected (family , SOCK_STREAM ,
1884
1888
sock_map , nop_map , verdict_map ,
1885
- REDIR_INGRESS );
1889
+ REDIR_INGRESS , NO_FLAGS );
1886
1890
1887
1891
xbpf_prog_detach2 (verdict , sock_map , BPF_SK_SKB_VERDICT );
1888
1892
}
0 commit comments