<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.openanolis.cn/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.openanolis.cn/"
          
          maintainer="service@openanolis.org"
>

    <bug>
          <bug_id>4510</bug_id>
          
          <creation_ts>2023-03-14 14:42:48 +0000</creation_ts>
          <short_desc>[Anck 5.10 nightly][ANCK-5.10-14][Anolis8][x86_64]kernel-selftests：执行net目录下reuseaddr_ports_exhausted.sh用例fail，not ok 3 global.reuseaddr_ports_exhausted_reusable_different_euid</short_desc>
          <delta_ts>2023-07-25 15:12:20 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Infrastructures</classification>
          <product>Antest</product>
          <component>测试用例</component>
          <version>unspecified</version>
          <rep_platform>x86_64</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3-Medium</priority>
          <bug_severity>S3-normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="shanxifanshi">wb-lyf900195</reporter>
          <assigned_to name="宁畅">hengqi.hq</assigned_to>
          <cc>maqiao.mq</cc>
    
    
    <cc>meiyou.hr</cc>
    
    
    <cc>mqaio</cc>
    
    
    <cc>qingming.su</cc>
    
    
    <cc>sonice1755</cc>
    
    
    <cc>wb-wpp899309</cc>
    
    
    <cc>wxm01174540</cc>
    
    
    <cc>zgy01497303</cc>
    
    
    <cc>zx01468051</cc>
          
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>15089</commentid>
    <comment_count>0</comment_count>
    <who name="shanxifanshi">wb-lyf900195</who>
    <bug_when>2023-03-14 14:42:48 +0000</bug_when>
    <thetext>[缺陷描述]：
kernel-selftests：执行net目录下reuseaddr_ports_exhausted.sh用例fail，not ok 3 global.reuseaddr_ports_exhausted_reusable_different_euid

测试日志：
# ./reuseaddr_ports_exhausted.sh
TAP version 13
1..3
# Starting 3 tests from 1 test cases.
#  RUN           global.reuseaddr_ports_exhausted_unreusable ...
#            OK  global.reuseaddr_ports_exhausted_unreusable
ok 1 global.reuseaddr_ports_exhausted_unreusable
#  RUN           global.reuseaddr_ports_exhausted_reusable_same_euid ...
#            OK  global.reuseaddr_ports_exhausted_reusable_same_euid
ok 2 global.reuseaddr_ports_exhausted_reusable_same_euid
#  RUN           global.reuseaddr_ports_exhausted_reusable_different_euid ...
# reuseaddr_ports_exhausted.c:153:reuseaddr_ports_exhausted_reusable_different_euid:Expected -1 (-1) == ret (0)
# reuseaddr_ports_exhausted.c:153:reuseaddr_ports_exhausted_reusable_different_euid:should fail to listen because only one uid reserves the port in TCP_LISTEN.
# reuseaddr_ports_exhausted.c:153:reuseaddr_ports_exhausted_reusable_different_euid:Expected -1 (-1) == ret (0)
# reuseaddr_ports_exhausted.c:153:reuseaddr_ports_exhausted_reusable_different_euid:should fail to listen because only one uid reserves the port in TCP_LISTEN.
# reuseaddr_ports_exhausted.c:153:reuseaddr_ports_exhausted_reusable_different_euid:Expected -1 (-1) == ret (0)
# reuseaddr_ports_exhausted.c:153:reuseaddr_ports_exhausted_reusable_different_euid:should fail to listen because only one uid reserves the port in TCP_LISTEN.
# reuseaddr_ports_exhausted.c:153:reuseaddr_ports_exhausted_reusable_different_euid:Expected -1 (-1) == ret (0)
# reuseaddr_ports_exhausted.c:153:reuseaddr_ports_exhausted_reusable_different_euid:should fail to listen because only one uid reserves the port in TCP_LISTEN.
# reuseaddr_ports_exhausted_reusable_different_euid: Test failed at step #13
#          FAIL  global.reuseaddr_ports_exhausted_reusable_different_euid
not ok 3 global.reuseaddr_ports_exhausted_reusable_different_euid
# FAILED: 2 / 3 tests passed.
# Totals: pass:2 fail:1 xfail:0 xpass:0 skip:0 error:0

[环境信息]：
复现环境：
anck 5.10 x86机器

复现概率：
必现

内核信息：
# uname -r
5.10.134-335.git.b9e0e840126f.an8.x86_64

操作系统信息：
# cat /etc/os-release
NAME=&quot;Anolis OS&quot;
VERSION=&quot;8.8&quot;
ID=&quot;anolis&quot;
ID_LIKE=&quot;rhel fedora centos&quot;
VERSION_ID=&quot;8.8&quot;
PLATFORM_ID=&quot;platform:an8&quot;
PRETTY_NAME=&quot;Anolis OS 8.8&quot;
ANSI_COLOR=&quot;0;31&quot;
HOME_URL=&quot;https://openanolis.cn/&quot;

cpu信息：
# lscpu
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              4
On-line CPU(s) list: 0-3
Thread(s) per core:  2
Core(s) per socket:  2
Socket(s):           1
NUMA node(s):        1
Vendor ID:           GenuineIntel
BIOS Vendor ID:      Alibaba Cloud
CPU family:          6
Model:               106
Model name:          Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
BIOS Model name:     pc-i440fx-2.1
Stepping:            6
CPU MHz:             2699.998
BogoMIPS:            5399.99
Hypervisor vendor:   KVM
Virtualization type: full
L1d cache:           48K
L1i cache:           32K
L2 cache:            1280K
L3 cache:            49152K
NUMA node0 CPU(s):   0-3
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves wbnoinvd arat avx512vbmi pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid fsrm arch_capabilities

内存信息：
# free -h
              total        used        free      shared  buff/cache   available
Mem:           15Gi       319Mi       8.5Gi       1.0Mi       6.3Gi        14Gi
Swap:            0B          0B          0B


[复现步骤]：
下载当前内核对应的kernel源码包
rpm -ivh xxx.src.rpm  默认安装到/root下
yum-builddep -y rpmbuild/SPECS/kernel.spec   自动安装前置依赖包，需要yum-utils
rpmbuild -bp ./rpmbuild/SPECS/kernel.spec   # 这个步骤会打相关的patch， 解压缩tar包，生成BUILD目录
cd rpmbuild/BUILD/kernel-xxx/linux-xxx/  
cd  /tools/testing/selftests/net
make

执行测试用例
./reuseaddr_ports_exhausted.sh

[期望结果]：
用例pass

[实际结果]：
用例fail

[原因分析]：
测试代码路径：
tools/testing/selftests/net/reuseaddr_ports_exhausted.sh
tools/testing/selftests/net/reuseaddr_ports_exhausted.c

fail点的函数如下：
reuseaddr_ports_exhausted.c

TEST(reuseaddr_ports_exhausted_reusable_different_euid)
{
        struct reuse_opts *opts;
        int i, j, ret, fd[2];
        uid_t euid[2] = {10, 20};

        for (i = 0; i &lt; 4; i++) {
                opts = &amp;reusable_opts[i];

                for (j = 0; j &lt; 2; j++) {
                        ret = seteuid(euid[j]);
                        ASSERT_EQ(0, ret) TH_LOG(&quot;failed to seteuid: %d.&quot;, euid[j]);

                        fd[j] = bind_port(_metadata, opts-&gt;reuseaddr[j], opts-&gt;reuseport[j]);

                        ret = seteuid(0);
                        ASSERT_EQ(0, ret) TH_LOG(&quot;failed to seteuid: 0.&quot;);
                }

                ASSERT_NE(-1, fd[0]) TH_LOG(&quot;failed to bind.&quot;);
                EXPECT_NE(-1, fd[1]) TH_LOG(&quot;should succeed to bind because one socket can be bound in each euid.&quot;);

                if (fd[1] != -1) {
                        ret = listen(fd[0], 5);
                        ASSERT_EQ(0, ret) TH_LOG(&quot;failed to listen.&quot;);

                        ret = listen(fd[1], 5);
                        EXPECT_EQ(-1, ret) TH_LOG(&quot;should fail to listen because only one uid reserves the port in TCP_LISTEN.&quot;);  ---用例在此fail
                }

1. 之前一直都是pass的，使用昨晚9:38编译的内核测试开始fail
2. 在2台环境上测试都fail，应该不是环境问题
3. 内核昨天合入了3个commit，可能与此相关，请参考
https://gitee.com/anolis/cloud-kernel/pulls/1444
https://gitee.com/anolis/cloud-kernel/pulls/1440
https://gitee.com/anolis/cloud-kernel/pulls/1402/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15096</commentid>
    <comment_count>1</comment_count>
    <who name="yunhe123">zgy01497303</who>
    <bug_when>2023-03-14 15:20:08 +0000</bug_when>
    <thetext>*** Bug 4512 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15111</commentid>
    <comment_count>2</comment_count>
    <who name="wangpingping">wb-wpp899309</who>
    <bug_when>2023-03-14 17:48:01 +0000</bug_when>
    <thetext>alinux3 x86和aarch64 kernel-selftests下net.reuseaddr_ports_exhausted.sh今日nightly首次出现同样的失败；
内核：5.10.134-862.git.b9e0e840126f.al8.x86_64 
# cat /etc/o
cat: /etc/o: No such file or directory
[root@VM20200706-58 tone]# cat /etc/os-release
NAME=&quot;Alibaba Cloud Linux&quot;
VERSION=&quot;3 (Soaring Falcon)&quot;
ID=&quot;alinux&quot;
ID_LIKE=&quot;rhel fedora centos&quot;
VERSION_ID=&quot;3&quot;
PLATFORM_ID=&quot;platform:al8&quot;
PRETTY_NAME=&quot;Alibaba Cloud Linux 3 (Soaring Falcon)&quot;
ANSI_COLOR=&quot;0;31&quot;
HOME_URL=&quot;https://www.aliyun.com/&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15195</commentid>
    <comment_count>3</comment_count>
    <who name="宁畅">hengqi.hq</who>
    <bug_when>2023-03-15 19:08:26 +0000</bug_when>
    <thetext>PR: https://gitee.com/anolis/cloud-kernel/pulls/1475</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15198</commentid>
    <comment_count>4</comment_count>
    <who name="shanxifanshi">wb-lyf900195</who>
    <bug_when>2023-03-16 09:50:33 +0000</bug_when>
    <thetext>最新nightly验证，用例pass，问题解决，bug关闭

# uname -r
5.10.134-337.git.8f3d075c5f6a.an8.x86_64

# ./reuseaddr_ports_exhausted.sh
TAP version 13
1..3
# Starting 3 tests from 1 test cases.
#  RUN           global.reuseaddr_ports_exhausted_unreusable ...
#            OK  global.reuseaddr_ports_exhausted_unreusable
ok 1 global.reuseaddr_ports_exhausted_unreusable
#  RUN           global.reuseaddr_ports_exhausted_reusable_same_euid ...
#            OK  global.reuseaddr_ports_exhausted_reusable_same_euid
ok 2 global.reuseaddr_ports_exhausted_reusable_same_euid
#  RUN           global.reuseaddr_ports_exhausted_reusable_different_euid ...
#            OK  global.reuseaddr_ports_exhausted_reusable_different_euid
ok 3 global.reuseaddr_ports_exhausted_reusable_different_euid
# PASSED: 3 / 3 tests passed.
# Totals: pass:3 fail:0 xfail:0 xpass:0 skip:0 error:0
tests done</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>