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

Listening on IPv6 any ([::]) fails because of SRTO_BINDTODEVICE #1481

Closed
jeandube opened this issue Aug 17, 2020 · 6 comments · Fixed by #1482
Closed

Listening on IPv6 any ([::]) fails because of SRTO_BINDTODEVICE #1481

jeandube opened this issue Aug 17, 2020 · 6 comments · Fixed by #1482
Assignees
Labels
[core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@jeandube
Copy link
Collaborator

listening on IPv6 any ([::]) no longer work with commit 4aa6fbb

11:23:39.842698 mxptool: setUDPSockOpt(channel.cpp:264): /App:Rx*E:SRT.c: SRTO_BINDTODEVICE can only be set with AF_INET connections
Application is not setting SRTO_BINDTODEVICE:
Breakpoint 1, CChannel::setUDPSockOpt (this=0x7fffe8008020) at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/channel.cpp:264 264 LOGC(mglog.Error, log << "SRTO_BINDTODEVICE can only be set with AF_INET connections"); (gdb) bt #0 CChannel::setUDPSockOpt (this=0x7fffe8008020) at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/channel.cpp:264 #1 0x000000000046f7f3 in CChannel::open (this=0x7fffe8008020, addr=...) at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/channel.cpp:128 #2 0x000000000045b9f8 in CUDTUnited::updateMux (this=0x707600, s=0x7fffe8000d90, addr=..., udpsock=<optimized out>) at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:2624 #3 0x000000000045cb09 in CUDTUnited::bind (this=0x707600, s=0x7fffe8000d90, name=...) at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:864 #4 0x000000000045ccbd in CUDT::bind (u=<optimized out>, name=<optimized out>, namelen=<optimized out>) at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:3013 #5 0x00000000004399a9 in srtconn_Open (srtc=0x718cd0, newsa=0x7175a0, newsalen=28, flags=0) at ../../libraries/naga/mxpmod_lib/srtc_mod.c:1842 #6 0x000000000043b2bc in SrtConn_Open (mxpc=0x718cd0, newsa=0x7175a0, newsalen=28, flags=0) at ../../libraries/naga/mxpmod_lib/srtc_mod.c:2093 #7 0x0000000000408772 in srtApp_LoopbackCx (loopcx=0x716870) at mxptool.c:376 #8 0x0000000000408d4c in srtApp_TxData (ref=0x716870, rxmsg=0x7fffe8000990) at mxptool.c:489 #9 0x000000000040953b in srtApp_RxProc (ref=0x715960, rxmsg=0x7fffe8000990) at mxptool.c:683 #10 0x0000000000409ab9 in srtApp_RxLoop (cx=0x715960) at mxptool.c:877 #11 0x000000000040b42b in srtApp_CxLoop (cx=0x715960, ai=0x7166c0, openf=0) at mxptool.c:1536 #12 0x000000000040b84b in srtApp_CxThread (s=0x715960) at mxptool.c:1595 #13 0x00007ffff74e9e9a in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0 #14 0x00007ffff6afd2ed in clone () from /lib/x86_64-linux-gnu/libc.so.6 #15 0x0000000000000000 in ?? ()

@jeandube jeandube added the Type: Bug Indicates an unexpected problem or unintended behavior label Aug 17, 2020
@jeandube
Copy link
Collaborator Author

Revisiting the fix to this problem: one line of this problem description was ignored:
Application is not setting SRTO_BINDTODEVICE

#ifdef SRT_ENABLE_BINDTODEVICE
      if (!m_BindToDevice.empty())
      {
          if (m_BindAddr.family() != AF_INET)
          {

The fix was to add the AF_INET line but m_BindToDevice should be empty. this CChannel member is not initialized..

@jeandube
Copy link
Collaborator Author

Or the default std::string constructor initialized it. Meanwhile my use case should not enter that if{} branch.

@maxsharabayko maxsharabayko reopened this Feb 12, 2021
@maxsharabayko maxsharabayko added this to the v1.4.3 milestone Feb 12, 2021
@maxsharabayko maxsharabayko added the [core] Area: Changes in SRT library core label Feb 12, 2021
@ethouris
Copy link
Collaborator

Excuse me, but I don't understand the problem. Yes, m_BindToDevice should be empty, as default-initialized. This now belongs to a bigger object of CSrtMuxerConfig type, which is as itself put into the multiplexer, and it's also a part of CSrtConfig, which's object is in the socket. This "multiplexer part" of the object is simply assigned from the socket when creating a multiplexer.

Am I getting it right, you have a case when the app didn't set this value but it wasn't an empty string?

@jeandube
Copy link
Collaborator Author

Yes, application is not setting this value. I remember this problem I reported and that it was fixed but I just bumped on the fix while investigating the SRTO_BINDTODEVICE implementation. I will gdb to confirm.

@ethouris
Copy link
Collaborator

What is interesting, especially for the fields that should keep a string there's a type that allows to keep them as a fixed size character array. The m_BindToDevice is an exception.

@jeandube
Copy link
Collaborator Author

I retrieved the original code causing this problem (commit 4aa6fbb) and m_BindAddr.family != AF_INET generated an exception outside the !m_BindToDevice.empty() condition causing any IPv6 address binding to fail. I reopened issue while not understanding the fix. Closing issue.

#ifdef SRT_ENABLE_BINDTODEVICE
      if (m_BindAddr.family() != AF_INET)
      {
          LOGC(mglog.Error, log << "SRTO_BINDTODEVICE can only be set with AF_INET connections");
          throw CUDTException(MJ_NOTSUP, MN_INVAL, 0);
      }

      if (!m_BindToDevice.empty())
      {
          if (0 != ::setsockopt(m_iSocket, SOL_SOCKET, SO_BINDTODEVICE, m_BindToDevice.c_str(), m_BindToDevice.size()))
          {
              char buf[255];
              const char* err = SysStrError(NET_ERROR, buf, 255);
              LOGC(mglog.Error, log << "setsockopt(SRTO_BINDTODEVICE): " << err);
              throw CUDTException(MJ_SETUP, MN_NORES, NET_ERROR);
          }
      }
#endif

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.

3 participants