Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peer address not available through srt_getpeername() upon epoll TX_READY event #2485

Closed
jeandube opened this issue Oct 11, 2022 · 8 comments · Fixed by #2526
Closed

Peer address not available through srt_getpeername() upon epoll TX_READY event #2485

jeandube opened this issue Oct 11, 2022 · 8 comments · Fixed by #2526
Labels
[core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@jeandube
Copy link
Collaborator

calling socket is connected and not broken and srt_getpeername does not set name.
One can argues that peer address is known by app for a caller but this is probably a regression in 1.5.1 as this used to work.

Here a gdb session:

srt::CUDTUnited::getpeername (this=0x5d4648 <srt::CUDT::uglobal()::instance>, u=958115029, pw_name=0x606038, pw_namelen=0x7ff70cdacc)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:2110
2110        if (!pw_name || !pw_namelen)
(gdb) p *pw_namelen
$33 = 128
(gdb) n
2113        if (getStatus(u) != SRTS_CONNECTED)
(gdb) 
2116        CUDTSocket* s = locateSocket(u);
(gdb) 
2118        if (!s)
(gdb) p s
$34 = (srt::CUDTSocket *) 0x7fe0000a10
(gdb) n
2121        if (!s->core().m_bConnected || s->core().m_bBroken)
(gdb) p s->core().m_bConnected
$35 = {value_ = {_M_base = {static _S_alignment = 1, _M_i = true}}}
(gdb) p s->core().m_bBroken
$36 = {value_ = {_M_base = {static _S_alignment = 1, _M_i = false}}}
(gdb) n
2124        const int len = s->m_PeerAddr.size();
(gdb) 
2125        if (*pw_namelen < len)
(gdb) p len
$37 = 0
(gdb) p s->m_PeerAddr
$38 = {{sin = {sin_family = 0, sin_port = 0, sin_addr = {s_addr = 0}, sin_zero = "\000\000\000\000\000\000\000"}, sin6 = {sin6_family = 0, sin6_port = 0, 
      sin6_flowinfo = 0, sin6_addr = {__in6_u = {__u6_addr8 = '\000' <repeats 15 times>, __u6_addr16 = {0, 0, 0, 0, 0, 0, 0, 0}, __u6_addr32 = {0, 0, 0, 
            0}}}, sin6_scope_id = 0}, sa = {sa_family = 0, sa_data = '\000' <repeats 13 times>}}, len = 28}
(gdb) bt
#0  srt::CUDTUnited::getpeername (this=0x5d4648 <srt::CUDT::uglobal()::instance>, u=958115029, pw_name=0x606038, pw_namelen=0x7ff70cdacc)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:2125
#1  0x00000000004a4244 in srt::CUDT::getpeername (u=958115029, name=0x606038, namelen=0x7ff70cdacc)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:3555
#2  0x0000000000495304 in srt_getpeername (u=958115029, name=0x606038, namelen=0x7ff70cdacc)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/srt_c_api.cpp:160
#3  0x00000000004427f4 in srtconn_LogPeerInfo (srtc=0x6053b0) at ../../libraries/ravo/mxpmod_lib/srtc_mod.c:1689
#4  0x00000000004773e0 in srtconn_StateChange (srtc=0x6053b0, newstate=5) at ../../libraries/ravo/mxpmod_lib/srtc_mod.c:8380
#5  0x000000000047d390 in SrtConn_EventCB (ref=0x6053b0, event=4, data=0x0, datasz=0) at ../../libraries/ravo/mxpmod_lib/srtc_mod.c:8801
#6  0x000000000047ee78 in uepoll_Event (sock=958115029, evt=4, flags=1, lrp=0x5d3f68 <lr_unktxu>) at ../../libraries/ravo/mxpmod_lib/mxpc_uepoll.c:280
#7  0x000000000047f6b4 in uepoll_Loop (ctlfd=5) at ../../libraries/ravo/mxpmod_lib/mxpc_uepoll.c:418
#8  0x000000000047f790 in uepoll_Thread (s=0x5d3de0 <_uepollCtl+16>) at ../../libraries/ravo/mxpmod_lib/mxpc_uepoll.c:441
#9  0x0000007ff7b13fd8 in ?? () from /lib/libpthread.so.0
#10 0x0000007ffffff4a8 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)```
@jeandube jeandube added the Type: Bug Indicates an unexpected problem or unintended behavior label Oct 11, 2022
@jeandube
Copy link
Collaborator Author

Full socket content:

$39 = (srt::CUDTSocket *) 0x7fe0000a10
(gdb) p *s
$40 = {m_Status = {value_ = {static _S_min_alignment = 4, static _S_alignment = 4, _M_i = SRTS_CONNECTED}}, m_tsClosureTimeStamp = {m_timestamp = 0}, 
  m_SelfAddr = {{sin = {sin_family = 2, sin_port = 32038, sin_addr = {s_addr = 3859431690}, sin_zero = "\000\000\000\000\000\000\000"}, sin6 = {
        sin6_family = 2, sin6_port = 32038, sin6_flowinfo = 3859431690, sin6_addr = {__in6_u = {__u6_addr8 = '\000' <repeats 15 times>, __u6_addr16 = {0, 0, 
              0, 0, 0, 0, 0, 0}, __u6_addr32 = {0, 0, 0, 0}}}, sin6_scope_id = 0}, sa = {sa_family = 2, 
        sa_data = "&}\nA\n\346\000\000\000\000\000\000\000"}}, len = 16}, m_PeerAddr = {{sin = {sin_family = 0, sin_port = 0, sin_addr = {s_addr = 0}, 
        sin_zero = "\000\000\000\000\000\000\000"}, sin6 = {sin6_family = 0, sin6_port = 0, sin6_flowinfo = 0, sin6_addr = {__in6_u = {
            __u6_addr8 = '\000' <repeats 15 times>, __u6_addr16 = {0, 0, 0, 0, 0, 0, 0, 0}, __u6_addr32 = {0, 0, 0, 0}}}, sin6_scope_id = 0}, sa = {
        sa_family = 0, sa_data = '\000' <repeats 13 times>}}, len = 28}, m_SocketID = 958115029, m_ListenSocket = 0, m_PeerID = 0, m_GroupMemberData = 0x0, 
  m_GroupOf = 0x0, m_iISN = 0, m_UDT = {static INVALID_SOCK = -1, static ERROR = -1, static HS_VERSION_UDT4 = 4, static HS_VERSION_SRT1 = 5, 
    static COMM_RESPONSE_MAX_EXP = 16, static SRT_TLPKTDROP_MINTHRESHOLD_MS = 1000, static COMM_KEEPALIVE_PERIOD_US = 1000000, 
    static COMM_SYN_INTERVAL_US = 10000, static COMM_CLOSE_BROKEN_LISTENER_TIMEOUT_MS = 3000, static MAX_WEIGHT = 32767, static ACK_WND_SIZE = 1024, 
    static INITIAL_RTT = 100000, static INITIAL_RTTVAR = 50000, m_config = {<srt::CSrtMuxerConfig> = {static DEF_UDP_BUFFER_SIZE = 65536, iIpTTL = 24, 
        iIpToS = 184, iIpV6Only = 0, bReuseAddr = true, sBindToDevice = {static npos = 18446744073709551615, 
          _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7fe0000aa8 ""}, 
          _M_string_length = 0, {_M_local_buf = "\000\000\000\000\270\000\000\000\000\000\000\000\001\000\000", _M_allocated_capacity = 790273982464}}, 
        iUDPSndBufSize = 1024000, iUDPRcvBufSize = 1024000}, static DEF_MSS = 1500, static DEF_FLIGHT_SIZE = 25600, static DEF_BUFFER_SIZE = 8192, 
      static DEF_LINGER_S = 180, static DEF_CONNTIMEO_S = 3, static COMM_RESPONSE_TIMEOUT_MS = 5000, static COMM_DEF_MIN_STABILITY_TIMEOUT_MS = 60, 
      static DEF_MIN_FLIGHT_PKT = 32, static MAX_SID_LENGTH = 512, static MAX_PFILTER_LENGTH = 64, static MAX_CONG_LENGTH = 16, iMSS = 1496, 
      zExpPayloadSize = 1316, bSynSending = false, bSynRecving = false, iFlightFlagSize = 25600, iSndBufSize = 6956, iRcvBufSize = 6956, Linger = {
        l_onoff = 0, l_linger = 0}, bRendezvous = false, tdConnTimeOut = {m_duration = 8000000}, bDriftTracer = true, iSndTimeOut = -1, iRcvTimeOut = -1, 
      llMaxBW = -1, CryptoSecret = {typ = 2, len = 12, str = "passphrase53", '\000' <repeats 67 times>}, iSndCryptoKeyLen = 16, bDataSender = false, 
      bMessageAPI = true, bTSBPD = true, iRcvLatency = 20, iPeerLatency = 20, bTLPktDrop = true, iSndDropDelay = 0, bEnforcedEnc = false, iGroupConnect = 0, 
      iPeerIdleTimeout_ms = 5000, uMinStabilityTimeout_ms = 60, iRetransmitAlgo = 1, llInputBW = 0, llMinInputBW = 0, iOverheadBW = 25, bRcvNakReport = true, 
      iMaxReorderTolerance = 0, uKmRefreshRatePkt = 0, uKmPreAnnouncePkt = 0, uSrtVersion = 66817, uMinimumPeerSrtVersion = 65536, sCongestion = {
        stor = "live", '\000' <repeats 12 times>, len = 4}, sPacketFilterConfig = {stor = '\000' <repeats 64 times>, len = 0}, sStreamName = {
        stor = '\000' <repeats 512 times>, len = 0}}, m_cbPacketArrival = {opaque = 0x0, fn = 0x0}, m_parent = 0x7fe0000a10, m_SocketID = 958115029, 
    m_PeerID = 749168100, m_tsSndHsLastTime = {m_timestamp = 0}, m_iSndHsRetryCnt = 0, m_HSGroupType = SRT_GTYPE_UNDEFINED, m_iMaxSRTPayloadSize = 1452, 
    m_iTsbPdDelay_ms = 250, m_iPeerTsbPdDelay_ms = 250, m_bTLPktDrop = true, m_pCryptoControl = {
      _M_t = {<std::_Tuple_impl<0ul, srt::CCryptoControl*, std::default_delete<srt::CCryptoControl> >> = {<std::_Tuple_impl<1ul, std::default_delete<srt::CCryptoControl> >> = {<std::_Head_base<1ul, std::default_delete<srt::CCryptoControl>, true>> = {<std::default_delete<srt::CCryptoControl>> = {<No data fields>}, <No data fields>}, <No data fields>}, <std::_Head_base<0ul, srt::CCryptoControl*, false>> = {
            _M_head_impl = 0x7fd8003b20}, <No data fields>}, <No data fields>}}, m_pCache = 0x5ed920, m_Slots = {
      {<std::_Vector_base<srt::EventSlot, std::allocator<srt::EventSlot> >> = {
          _M_impl = {<std::allocator<srt::EventSlot>> = {<__gnu_cxx::new_allocator<srt::EventSlot>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, 
            _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, {<std::_Vector_base<srt::EventSlot, std::allocator<srt::EventSlot> >> = {
          _M_impl = {<std::allocator<srt::EventSlot>> = {<__gnu_cxx::new_allocator<srt::EventSlot>> = {<No data fields>}, <No data fields>}, 
            _M_start = 0x7fd80e5970, _M_finish = 0x7fd80e5978, _M_end_of_storage = 0x7fd80e5978}}, <No data fields>}, 
      {<std::_Vector_base<srt::EventSlot, std::allocator<srt::EventSlot> >> = {
          _M_impl = {<std::allocator<srt::EventSlot>> = {<__gnu_cxx::new_allocator<srt::EventSlot>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, 
            _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, {<std::_Vector_base<srt::EventSlot, std::allocator<srt::EventSlot> >> = {
          _M_impl = {<std::allocator<srt::EventSlot>> = {<__gnu_cxx::new_allocator<srt::EventSlot>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, 
            _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, {<std::_Vector_base<srt::EventSlot, std::allocator<srt::EventSlot> >> = {
          _M_impl = {<std::allocator<srt::EventSlot>> = {<__gnu_cxx::new_allocator<srt::EventSlot>> = {<No data fields>}, <No data fields>}, 
            _M_start = 0x7fd8006f30, _M_finish = 0x7fd8006f38, _M_end_of_storage = 0x7fd8006f38}}, <No data fields>}, 
      {<std::_Vector_base<srt::EventSlot, std::allocator<srt::EventSlot> >> = {
          _M_impl = {<std::allocator<srt::EventSlot>> = {<__gnu_cxx::new_allocator<srt::EventSlot>> = {<No data fields>}, <No data fields>}, 
---Type <return> to continue, or q <return> to quit---
            _M_start = 0x7fd8003910, _M_finish = 0x7fd8003918, _M_end_of_storage = 0x7fd8003918}}, <No data fields>}, 
      {<std::_Vector_base<srt::EventSlot, std::allocator<srt::EventSlot> >> = {
          _M_impl = {<std::allocator<srt::EventSlot>> = {<__gnu_cxx::new_allocator<srt::EventSlot>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, 
            _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, {<std::_Vector_base<srt::EventSlot, std::allocator<srt::EventSlot> >> = {
          _M_impl = {<std::allocator<srt::EventSlot>> = {<__gnu_cxx::new_allocator<srt::EventSlot>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, 
            _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, {<std::_Vector_base<srt::EventSlot, std::allocator<srt::EventSlot> >> = {
          _M_impl = {<std::allocator<srt::EventSlot>> = {<__gnu_cxx::new_allocator<srt::EventSlot>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, 
            _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}}, m_CongCtl = {static N_CONTROLLERS = 2, static congctls = {{
          first = 0x571000 "live", second = 0x5201e4 <srt::Creator<srt::LiveCC>::Create(srt::CUDT*)>}, {first = 0x571008 "file", 
          second = 0x520238 <srt::Creator<srt::FileCC>::Create(srt::CUDT*)>}}, congctl = 0x7fd802e010, selector = 0}, m_PacketFilter = {
      static builtin_filters = <optimized out>, static filters = <optimized out>, m_filter = 0x0, m_parent = 0x0, m_sndctlpkt = {hdr = {0, 0, 0, 0}, 
        buffer = '\000' <repeats 1455 times>, length = 0}, m_unitq = 0x0, 
      m_provided = {<std::_Vector_base<srt::SrtPacket, std::allocator<srt::SrtPacket> >> = {
          _M_impl = {<std::allocator<srt::SrtPacket>> = {<__gnu_cxx::new_allocator<srt::SrtPacket>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, 
            _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}}, m_PktFilterRexmitLevel = srt::SRT_ARQ_ALWAYS, m_sPeerPktFilterConfigString = {
      static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, 
        _M_p = 0x7fe0001570 ""}, _M_string_length = 0, {_M_local_buf = "\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000", 
        _M_allocated_capacity = 0}}, m_bListening = {value_ = {_M_base = {static _S_alignment = 1, _M_i = false}}}, m_bConnecting = {value_ = {_M_base = {
          static _S_alignment = 1, _M_i = false}}}, m_bConnected = {value_ = {_M_base = {static _S_alignment = 1, _M_i = true}}}, m_bClosing = {value_ = {
        _M_base = {static _S_alignment = 1, _M_i = false}}}, m_bShutdown = {value_ = {_M_base = {static _S_alignment = 1, _M_i = false}}}, m_bBroken = {
      value_ = {_M_base = {static _S_alignment = 1, _M_i = false}}}, m_bBreakAsUnstable = {value_ = {_M_base = {static _S_alignment = 1, _M_i = false}}}, 
    m_bPeerHealth = {value_ = {_M_base = {static _S_alignment = 1, _M_i = true}}}, m_RejectReason = {value_ = {<std::__atomic_base<int>> = {
          static _S_alignment = 4, _M_i = 0}, <No data fields>}}, m_bOpened = true, m_iBrokenCounter = {value_ = {<std::__atomic_base<int>> = {
          static _S_alignment = 4, _M_i = 0}, <No data fields>}}, m_iEXPCount = 1, m_iBandwidth = {value_ = {<std::__atomic_base<int>> = {
          static _S_alignment = 4, _M_i = 1}, <No data fields>}}, m_iSRTT = {value_ = {<std::__atomic_base<int>> = {static _S_alignment = 4, 
          _M_i = 100000}, <No data fields>}}, m_iRTTVar = {value_ = {<std::__atomic_base<int>> = {static _S_alignment = 4, _M_i = 50000}, <No data fields>}}, 
    m_bIsFirstRTTReceived = {value_ = {_M_base = {static _S_alignment = 1, _M_i = false}}}, m_iDeliveryRate = {value_ = {<std::__atomic_base<int>> = {
          static _S_alignment = 4, _M_i = 16}, <No data fields>}}, m_iByteDeliveryRate = {value_ = {<std::__atomic_base<int>> = {static _S_alignment = 4, 
          _M_i = 23296}, <No data fields>}}, m_ConnReq = {static m_iContentSize = 48, static HS_EXT_HSREQ = 1, static HS_EXT_KMREQ = 2, 
      static HS_EXT_CONFIG = 4, m_iVersion = 5, m_iType = 131075, m_iISN = 1040087316, m_iMSS = 1500, m_iFlightFlagSize = 6956, 
      m_iReqType = srt::URQ_CONCLUSION, m_iID = 958115029, m_iCookie = -224796138, m_piPeerIP = {3926540554, 0, 0, 0}, m_extension = true}, m_ConnRes = {
      static m_iContentSize = 48, static HS_EXT_HSREQ = 1, static HS_EXT_KMREQ = 2, static HS_EXT_CONFIG = 4, m_iVersion = 5, m_iType = 131075, 
      m_iISN = 1040087316, m_iMSS = 1496, m_iFlightFlagSize = 6975, m_iReqType = srt::URQ_CONCLUSION, m_iID = 749168100, m_iCookie = -224796138, 
      m_piPeerIP = {0, 0, 4294901760, 3859431690}, m_extension = false}, m_RdvState = srt::CHandShake::RDV_INVALID, m_SrtHsSide = srt::HSD_INITIATOR, 
    m_pSndBuffer = 0x7fd8031860, m_pSndLossList = 0x7fd802ded0, m_SndTimeWindow = {<srt::CPktTimeWindowTools> = {<No data fields>}, m_aPktWindow = {
        1000000 <repeats 16 times>}, m_aBytesWindow = {1456 <repeats 16 times>}, m_iPktWindowPtr = 0, m_lockPktWindow = {m_mutex = {__data = {__lock = 0, 
            __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, 
          __align = 0}}, m_aProbeWindow = {1000 <repeats 16 times>}, m_iProbeWindowPtr = 0, m_lockProbeWindow = {m_mutex = {__data = {__lock = 0, 
            __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, 
          __align = 0}}, m_iLastSentTime = 0, m_iMinPktSndInt = 1000000, m_tsLastArrTime = {m_timestamp = 425730821110}, m_tsCurrArrTime = {m_timestamp = 0}, 
      m_tsProbeTime = {m_timestamp = 0}, m_Probe1Sequence = -1}, m_tdSendInterval = {dur = {value_ = {<std::__atomic_base<long>> = {static _S_alignment = 8, 
            _M_i = 10}, <No data fields>}}}, m_tdSendTimeDiff = {dur = {value_ = {<std::__atomic_base<long>> = {static _S_alignment = 8, 
            _M_i = 0}, <No data fields>}}}, m_iFlowWindowSize = {value_ = {<std::__atomic_base<int>> = {static _S_alignment = 4, 
          _M_i = 6975}, <No data fields>}}, m_dCongestionWindow = 6975, m_tsNextACKTime = {dur = {value_ = {<std::__atomic_base<unsigned long>> = {
            static _S_alignment = 8, _M_i = 425883909346}, <No data fields>}}}, m_tsNextNAKTime = {dur = {value_ = {<std::__atomic_base<unsigned long>> = {
            static _S_alignment = 8, _M_i = 425884202568}, <No data fields>}}}, m_tdACKInterval = {m_duration = 10000}, m_tdNAKInterval = {
---Type <return> to continue, or q <return> to quit---
      m_duration = 300000}, m_tsLastRspTime = {dur = {value_ = {<std::__atomic_base<unsigned long>> = {static _S_alignment = 8, 
            _M_i = 425883902584}, <No data fields>}}}, m_tsLastRspAckTime = {m_timestamp = 425730870083}, m_tsLastSndTime = {dur = {
        value_ = {<std::__atomic_base<unsigned long>> = {static _S_alignment = 8, _M_i = 425883899483}, <No data fields>}}}, m_tsLastWarningTime = {
      m_timestamp = 0}, m_tsLastReqTime = {dur = {value_ = {<std::__atomic_base<unsigned long>> = {static _S_alignment = 8, _M_i = 0}, <No data fields>}}}, 
    m_tsRcvPeerStartTime = {m_timestamp = 425730847761}, m_tsLingerExpiration = {m_timestamp = 0}, m_tsLastAckTime = {m_timestamp = 425883899383}, 
    m_tdMinNakInterval = {m_duration = 20000}, m_tdMinExpInterval = {m_duration = 300000}, m_iPktCount = 54, m_iLightACKCount = 1, m_tsNextSendTime = {
      m_timestamp = 0}, m_iSndLastFullAck = {value_ = {<std::__atomic_base<int>> = {static _S_alignment = 4, _M_i = 1040087316}, <No data fields>}}, 
    m_iSndLastAck = {value_ = {<std::__atomic_base<int>> = {static _S_alignment = 4, _M_i = 1040087316}, <No data fields>}}, m_iSndLastDataAck = {
      value_ = {<std::__atomic_base<int>> = {static _S_alignment = 4, _M_i = 1040087316}, <No data fields>}}, m_iSndCurrSeqNo = {
      value_ = {<std::__atomic_base<int>> = {static _S_alignment = 4, _M_i = 1040087315}, <No data fields>}}, m_iSndNextSeqNo = {
      value_ = {<std::__atomic_base<int>> = {static _S_alignment = 4, _M_i = 1040087316}, <No data fields>}}, m_iSndLastAck2 = 1040087316, 
    m_SndLastAck2Time = {m_timestamp = 425730821698}, m_iISN = 1040087316, m_bPeerTsbPd = true, m_bPeerTLPktDrop = true, m_bPeerNakReport = true, 
    m_bPeerRexmitFlag = true, m_iReXmitCount = 1, m_pRcvBuffer = 0x7fd8012ae0, m_pRcvLossList = 0x7fd8003a80, 
    m_FreshLoss = {<std::_Deque_base<srt::CRcvFreshLoss, std::allocator<srt::CRcvFreshLoss> >> = {
        _M_impl = {<std::allocator<srt::CRcvFreshLoss>> = {<__gnu_cxx::new_allocator<srt::CRcvFreshLoss>> = {<No data fields>}, <No data fields>}, 
          _M_map = 0x7fe0013960, _M_map_size = 8, _M_start = {_M_cur = 0x7fe00134e0, _M_first = 0x7fe00134e0, _M_last = 0x7fe00136d8, 
            _M_node = 0x7fe0013978}, _M_finish = {_M_cur = 0x7fe00134e0, _M_first = 0x7fe00134e0, _M_last = 0x7fe00136d8, 
            _M_node = 0x7fe0013978}}}, <No data fields>}, m_iReorderTolerance = 0, m_iConsecEarlyDelivery = 0, m_iConsecOrderedDelivery = 1, m_ACKWindow = {
      m_aSeq = {{iACKSeqNo = 1, iACK = 1040087317, tsTimeStamp = {m_timestamp = 425752002684}}, {iACKSeqNo = 2, iACK = 1040087375, tsTimeStamp = {
            m_timestamp = 425753748090}}, {iACKSeqNo = 3, iACK = 1040087529, tsTimeStamp = {m_timestamp = 425753758199}}, {iACKSeqNo = 4, iACK = 1040087571, 
          tsTimeStamp = {m_timestamp = 425754851885}}, {iACKSeqNo = 5, iACK = 1040087604, tsTimeStamp = {m_timestamp = 425756396369}}, {iACKSeqNo = 6, 
          iACK = 1040087657, tsTimeStamp = {m_timestamp = 425830723782}}, {iACKSeqNo = 7, iACK = 1040087698, tsTimeStamp = {m_timestamp = 425834860178}}, {
          iACKSeqNo = 8, iACK = 1040087768, tsTimeStamp = {m_timestamp = 425844779759}}, {iACKSeqNo = 9, iACK = 1040087816, tsTimeStamp = {
            m_timestamp = 425849451182}}, {iACKSeqNo = 10, iACK = 1040087847, tsTimeStamp = {m_timestamp = 425861219625}}, {iACKSeqNo = 11, 
          iACK = 1040087864, tsTimeStamp = {m_timestamp = 425871847349}}, {iACKSeqNo = 12, iACK = 1040087874, tsTimeStamp = {m_timestamp = 425877147603}}, {
          iACKSeqNo = 13, iACK = 1040088009, tsTimeStamp = {m_timestamp = 425877158072}}, {iACKSeqNo = 14, iACK = 1040088014, tsTimeStamp = {
            m_timestamp = 425883899477}}, {iACKSeqNo = 0, iACK = 0, tsTimeStamp = {m_timestamp = 0}} <repeats 1010 times>}, m_iHead = 14, m_iTail = 0}, 
    m_RcvTimeWindow = {<srt::CPktTimeWindowTools> = {<No data fields>}, m_aPktWindow = {61, 61, 35, 36, 61, 61, 61, 60, 61, 59, 38, 42, 61, 60, 59, 38}, 
      m_aBytesWindow = {1316, 376, 376, 1316, 1316, 1316, 1316, 1316, 1316, 376, 564, 1316, 1316, 1316, 376, 1316}, m_iPktWindowPtr = 0, m_lockPktWindow = {
        m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, 
          __size = '\000' <repeats 47 times>, __align = 0}}, m_aProbeWindow = {74, 565, 139, 68, 92, 809, 39, 73, 71, 66, 46, 134, 90, 73, 94, 495, 94, 158, 
        172, 46, 74, 78, 68, 100, 69, 165, 60, 209, 71, 66, 631, 201, 50, 39, 90, 389, 151, 77, 66, 67, 45, 55, 66, 78, 197, 135, 66, 
        1000 <repeats 17 times>}, m_iProbeWindowPtr = 47, m_lockProbeWindow = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, 
            __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, m_iLastSentTime = 0, 
      m_iMinPktSndInt = 1000000, m_tsLastArrTime = {m_timestamp = 425883902585}, m_tsCurrArrTime = {m_timestamp = 425883902585}, m_tsProbeTime = {
        m_timestamp = 425883902428}, m_Probe1Sequence = -1}, m_iRcvLastAck = 1040088014, m_iDebugPrevLastAck = 1040087316, m_iRcvLastSkipAck = 1040088014, 
    m_iRcvLastAckAck = 1040087316, m_iAckSeqNo = 14, m_iRcvCurrSeqNo = {value_ = {<std::__atomic_base<int>> = {static _S_alignment = 4, 
          _M_i = 1040088066}, <No data fields>}}, m_iRcvCurrPhySeqNo = 1040088067, m_iPeerISN = 1040087316, m_uPeerSrtVersion = 66564, m_uPeerSrtFlags = 191, 
    m_bTsbPd = true, m_bGroupTsbPd = false, m_RcvTsbPdThread = {m_thread = 549562954208}, m_RcvTsbPdCond = {m_cv = {__data = {__lock = 0, __futex = 51, 
          __total_seq = 26, __wakeup_seq = 25, __woken_seq = 25, __mutex = 0x7fe0005cc8, __nwaiters = 3, __broadcast_seq = 0}, 
        __size = "\000\000\000\000\063\000\000\000\032\000\000\000\000\000\000\000\031\000\000\000\000\000\000\000\031\000\000\000\000\000\000\000\310\\\000\340\177\000\000\000\003\000\000\000\000\000\000", __align = 219043332096}}, m_bTsbPdAckWakeup = true, m_RcvTsbPdStartupLock = {m_mutex = {__data = {__lock = 0, 
          __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, 
        __align = 0}}, m_cbAcceptHook = {opaque = 0x0, fn = 0x0}, m_cbConnectHook = {opaque = 0x6053b0, fn = 0x447e6c <SrtConn_ConnectCB>}, 
    m_ConnectionLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, 
            __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, m_SendBlockCond = {m_cv = {__data = {__lock = 0, __futex = 0, __total_seq = 0, 
---Type <return> to continue, or q <return> to quit---
          __wakeup_seq = 0, __woken_seq = 0, __mutex = 0x0, __nwaiters = 1, __broadcast_seq = 0}, 
        __size = '\000' <repeats 40 times>, "\001\000\000\000\000\000\000", __align = 0}}, m_SendBlockLock = {m_mutex = {__data = {__lock = 0, __count = 0, 
          __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, 
    m_RcvBufferLock = {m_mutex = {__data = {__lock = 1, __count = 0, __owner = 26570, __nusers = 1, __kind = 0, __spins = 0, __list = {__prev = 0x0, 
            __next = 0x0}}, __size = "\001\000\000\000\000\000\000\000\312g\000\000\001", '\000' <repeats 34 times>, __align = 1}}, m_RecvAckLock = {
      m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, 
        __size = '\000' <repeats 47 times>, __align = 0}}, m_RecvDataCond = {m_cv = {__data = {__lock = 0, __futex = 0, __total_seq = 0, __wakeup_seq = 0, 
          __woken_seq = 0, __mutex = 0x0, __nwaiters = 1, __broadcast_seq = 0}, __size = '\000' <repeats 40 times>, "\001\000\000\000\000\000\000", 
        __align = 0}}, m_RecvLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 1, __kind = 0, __spins = 0, __list = {
            __prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 12 times>, "\001", '\000' <repeats 34 times>, __align = 0}}, m_SendLock = {m_mutex = {
        __data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, 
        __size = '\000' <repeats 47 times>, __align = 0}}, m_RcvLossLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, 
          __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, m_StatsLock = {m_mutex = {
        __data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, 
        __size = '\000' <repeats 47 times>, __align = 0}}, m_stats = {tsStartTime = {m_timestamp = 425730821631}, sndr = {sent = {trace = {m_bytes = 0, 
            m_packets = 0}, total = {m_bytes = 0, m_packets = 0}}, sentUnique = {trace = {m_bytes = 0, m_packets = 0}, total = {m_bytes = 0, m_packets = 0}}, 
        sentRetrans = {trace = {m_bytes = 0, m_packets = 0}, total = {m_bytes = 0, m_packets = 0}}, lost = {trace = {m_count = 0}, total = {m_count = 0}}, 
        dropped = {trace = {m_bytes = 0, m_packets = 0}, total = {m_bytes = 0, m_packets = 0}}, sentFilterExtra = {trace = {m_count = 0}, total = {
            m_count = 0}}, recvdAck = {trace = {m_count = 0}, total = {m_count = 0}}, recvdNak = {trace = {m_count = 0}, total = {m_count = 0}}}, rcvr = {
        recvd = {trace = {m_bytes = 767980, m_packets = 752}, total = {m_bytes = 767980, m_packets = 752}}, recvdUnique = {trace = {m_bytes = 766664, 
            m_packets = 751}, total = {m_bytes = 766664, m_packets = 751}}, recvdRetrans = {trace = {m_bytes = 0, m_packets = 0}, total = {m_bytes = 0, 
            m_packets = 0}}, lost = {trace = {m_bytes = 0, m_packets = 0}, total = {m_bytes = 0, m_packets = 0}}, dropped = {trace = {m_bytes = 0, 
            m_packets = 0}, total = {m_bytes = 0, m_packets = 0}}, recvdBelated = {trace = {m_bytes = 0, m_packets = 0}, total = {m_bytes = 0, 
            m_packets = 0}}, undecrypted = {trace = {m_bytes = 0, m_packets = 0}, total = {m_bytes = 0, m_packets = 0}}, recvdFilterExtra = {trace = {
            m_count = 0}, total = {m_count = 0}}, suppliedByFilter = {trace = {m_count = 0}, total = {m_count = 0}}, lossFilter = {trace = {m_count = 0}, 
          total = {m_count = 0}}, sentAck = {trace = {m_count = 14}, total = {m_count = 14}}, sentNak = {trace = {m_count = 0}, total = {m_count = 0}}}, 
      m_sndDurationTotal = 0, tsLastSampleTime = {m_timestamp = 425730821633}, traceReorderDistance = 0, traceBelatedTime = 0, sndDuration = 0, 
      sndDurationCounter = {m_timestamp = 0}}, static SELF_CLOCK_INTERVAL = 64, static SEND_LITE_ACK = 4, static PACKETPAIR_MASK = 15, m_tsFreshActivation = {
      m_timestamp = 0}, m_tsUnstableSince = {m_timestamp = 0}, m_tsWarySince = {m_timestamp = 0}, static BECAUSE_NO_REASON = 0, static BECAUSE_ACK = 1, 
    static BECAUSE_LITEACK = 2, static BECAUSE_NAKREPORT = 4, static LAST_BECAUSE_BIT = 3, m_pSndQueue = 0x7fe0006520, m_pRcvQueue = 0x7fe00077a0, 
    m_PeerAddr = {{sin = {sin_family = 2, sin_port = 57638, sin_addr = {s_addr = 3926540554}, sin_zero = "\000\000\000\000\000\000\000"}, sin6 = {
          sin6_family = 2, sin6_port = 57638, sin6_flowinfo = 3926540554, sin6_addr = {__in6_u = {
              __u6_addr8 = "\000\000\000\000\000\000\000\000\254=J\000\000\000\000", __u6_addr16 = {0, 0, 0, 0, 15788, 74, 0, 0}, __u6_addr32 = {0, 0, 
                4865452, 0}}}, sin6_scope_id = 5644104}, sa = {sa_family = 2, sa_data = "&\341\nA\n\352\000\000\000\000\000\000\000"}}, len = 16}, 
    m_piSelfIP = {0, 0, 4294901760, 3859431690}, m_pSNode = 0x7fe00215e0, m_pRNode = 0x7fe00063c0, m_sPollID = {_M_t = {
        _M_impl = {<std::allocator<std::_Rb_tree_node<int> >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<int> >> = {<No data fields>}, <No data fields>}, _M_key_compare = {<std::binary_function<int, int, bool>> = {<No data fields>}, <No data fields>}, _M_header = {_M_color = std::_S_red, 
            _M_parent = 0x7fe0013240, _M_left = 0x7fe0013240, _M_right = 0x7fe0013240}, _M_node_count = 1}}}}, m_QueuedSockets = {_M_t = {
      _M_impl = {<std::allocator<std::_Rb_tree_node<int> >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<int> >> = {<No data fields>}, <No data fields>}, 
        _M_key_compare = {<std::binary_function<int, int, bool>> = {<No data fields>}, <No data fields>}, _M_header = {_M_color = std::_S_red, 
          _M_parent = 0x0, _M_left = 0x7fe0006008, _M_right = 0x7fe0006008}, _M_node_count = 0}}}, m_AcceptCond = {m_cv = {__data = {__lock = 0, __futex = 0, 
        __total_seq = 0, __wakeup_seq = 0, __woken_seq = 0, __mutex = 0x0, __nwaiters = 1, __broadcast_seq = 0}, 
      __size = '\000' <repeats 40 times>, "\001\000\000\000\000\000\000", __align = 0}}, m_AcceptLock = {m_mutex = {__data = {__lock = 0, __count = 0, 
        __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, 
  m_uiBackLog = 0, m_iMuxID = 958115035, m_ControlLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, 
        __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}}
(gdb)```

@maxsharabayko maxsharabayko added this to the v1.6.0 milestone Oct 11, 2022
@maxsharabayko maxsharabayko added the [core] Area: Changes in SRT library core label Oct 11, 2022
@jeandube
Copy link
Collaborator Author

srt_getpeername returns zeroed sockaddr even when called later, once caller is connected and steaming.

@maxsharabayko
Copy link
Collaborator

@jeandube Could you also share what is the expected remote IP? Is it IPv6 or IPv4? Local or remote host?

@ethouris
Copy link
Collaborator

ethouris commented Nov 2, 2022

It looks like there's some confusion lagging since even UDT times here.

Just to cut off confusion I have temporarily changed the name of m_PeerAddr in CUDT and CRendezvousQueue::CRL so that only the one remaining in CUDTSocket can be found. This field is being set exclusively in one place: inside the CUDTUnited::newConnection function, called from processConnectRequest being called in response to handshake on the listener side.

This means that this value will be properly set in a socket extracted from a listener - and nowhere else.

The CUDT class has its own m_PeerAddr. This one is being set in CUDT::startConnect to the declared remote address before the connecting process even starts, as well as in CUDT::acceptAndRespond, which is called later inside CUDTUnited::newConnection and with the same peer value as the one used to set CUDTSocket::m_PeerAddr.

The CUDTSocket::m_PeerAddr is used in the following places:

  • in getpeername
  • in accept to fill in the returned address
  • in locatePeer called from newConnection to find out if there already is a socket pending for connection with that peer (before it creates the socket anew and assigns this address there).

All this means that getpeername simply works only for listener-accepted sockets. And that's not even the matter of "clearing" it because this isn't ever done. If m_PeerAddr contains "null data", it simply has never been set since creation as empty.

Not sure if that is how it's supposed to work, but this is how it works, and I doubt it has ever changed.

I agree that it doesn't exactly make sense because a connected socket is a connected socket, no matter if created manually and connected, or extracted from srt_accept, and a connected socket should have a record of its peer.

So, the easiest way to fix it would be to make getpeername read CUDT::m_PeerAddr rather than CUDTSocket::m_PeerAddr. But I'm not sure if this is the right solution.

@leio
Copy link
Contributor

leio commented Nov 2, 2022

This was a regression in 1.5.x in my case, it worked fine in 1.4.4 as well.

My case is calling srt_peername on a caller socket rather early on, right after srt_connect returns. In 1.4.4 and earlier, this returned the sockaddr that I just connected to, but 1.5.1 gives a zeroed out struct. So returns a sockaddr with protocol that I'd call AF_NOPE, not AF_INET or AF_INET6, NOT a SRT_ERROR or anything, just a bad sockaddr info.

My workaround was easy, as I could just use the information I just passed to srt_connect to what I needed it for, but the OP seems to have something more subtle.

@ethouris
Copy link
Collaborator

ethouris commented Nov 2, 2022

Damn, you are perfectly right! Excerpt from CUDTUnited::connectIn:

  /* 
   * In blocking mode, connect can block for up to 30 seconds for
   * rendez-vous mode. Holding the s->m_ControlLock prevent close
   * from cancelling the connect
   */
   try
   {
       // record peer address
       s->m_PeerAddr = target_addr;    //<--------------
       s->core().startConnect(target_addr, forced_isn);
   }
   catch (CUDTException& e) // Interceptor, just to change the state.
   {
      s->m_Status = SRTS_OPENED;
      throw e;
   }

State in master:

    /*
     * In blocking mode, connect can block for up to 30 seconds for
     * rendez-vous mode. Holding the s->m_ControlLock prevent close
     * from cancelling the connect
     */
    try
    {
        s->core().startConnect(target_addr, forced_isn);
    }
    catch (const CUDTException&) // Interceptor, just to change the state.
    {
        s->m_Status = SRTS_OPENED;
        throw;
    }

@maxsharabayko
Copy link
Collaborator

Hmm, I did this change in #2087 because CUDT::startConnect(..) sets the m_PeerAddr anyway.
But I didn't notice there are two m_PeerAddr variables: one in CUDTSocket, and another one in CUDT.
I would say SRT does not need two. Data race protection has to be checked though.

Thus SRT v1.5.0 and v1.5.1 are affected.

@ethouris
Copy link
Collaborator

ethouris commented Nov 2, 2022

A refax request could be a good idea to resolve this duality in time, but this isn't a simple removal of a field and shifting the functions to use the other one. Indeed, they are in two different objects and also under two different mutexes.

Although it could be a good idea to give them prefixes. For example for CUDT I was using m_CorePeerAddress and for CRL - m_RecPeerAddress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants