Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-9612

Mongos not parsing correctly IPV6 address

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.4.3
    • Component/s: Networking
    • Labels:
    • ALL
    • Hide

      ./mongos --ipv6 --configdb 2001:0db8:0000:85a3:0000:0000:ac1f:8001:5000

      Show
      ./mongos --ipv6 --configdb 2001:0db8:0000:85a3:0000:0000:ac1f:8001:5000
    • Platforms 14 (05/13/16)

      When you start the mongos instance and specify the adresse of a config server, and this address is an IPV6, mongos can't resolve it because it parse it as a normal IP or hostname.

      https://github.com/mongodb/mongo/blob/master/src/mongo/s/config.cpp#L984
      to resolve this issue we can remplace:

       if ( name.find( ":" ) != string::npos ) {
                  if ( withPort )
                      return name;
                  return name.substr( 0 , name.find( ":" ) );
              }
      

      by:

       if ( name.find( ":" ) != string::npos ) {
                  if ( withPort )
                      return name;
                  return name.substr( 0 , name.find_last_of( ":" ) );
              }
      


      Example:

      2001:0db8:0000:85a3:0000:0000:ac1f:8001:port

      mongos will try to resolve "2001" as the host part of the adresse intead of 2001:0db8:0000:85a3:0000:0000:ac1f:8001

            Assignee:
            waley.chen Waley Chen
            Reporter:
            lawcen Lahoucine BENLAHMR
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: