[SERVER-15322] mongosniff erroneously displays the same string for source and destination IP addresses Created: 19/Sep/14  Updated: 06/Feb/15  Resolved: 15/Jan/15

Status: Closed
Project: Core Server
Component/s: Tools
Affects Version/s: 2.6.3
Fix Version/s: 3.0.0-rc6

Type: Bug Priority: Major - P3
Reporter: Juan Berner Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: pull-request
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

As far as I know this happens every time you use it, I cloned from master with:

git clone https://github.com/mongodb/mongo.git and built it with scons

Participants:

 Description   

I had these types of messages from mongosniff:

10.32.152.63:6612  <<--  10.32.152.63:49802   85 bytes  id:10f177a 17766266 - 38764426
        reply n:1 cursorId: 0
        { js: { utf8: true }, oidMachine: 6672235, ok: 1.0 }
10.32.164.94:49383  -->> 10.32.164.94:6612 admin.$cmd  58 bytes id:24f7f8b     38764427
        query: { features: 1 }  ntoreturn: 1 ntoskip: 0

There the source and destination ip are the same due to a bug in the output.

I have proposed this pull request https://github.com/mongodb/mongo/pull/782

Thanks!



 Comments   
Comment by Githook User [ 15/Jan/15 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-15322 fixed mongosniffer log message
Branch: master
https://github.com/mongodb/mongo/commit/ab47afeb030b42097acede562760c3a2ca785086

Comment by Benety Goh [ 22/Sep/14 ]

According to the Linux man page for inet_ntoa,

The inet_ntoa() function converts the Internet host address in, given in network byte order, to a string in IPv4 dotted-decimal notation. The string is returned in a statically allocated buffer, which subsequent calls will overwrite.

The underlying issue is caused by the log output stream referring to the same internal buffer used by inet_ntoa to render both the source and destination IP.

sniffer.cpp:

    out() << inet_ntoa(ip->ip_src) << ":" << ntohs( tcp->th_sport )
          << ( serverPorts.count( ntohs( tcp->th_dport ) ) ? "  -->> " : "  <<--  " )
          << inet_ntoa(ip->ip_dst) << ":" << ntohs( tcp->th_dport )
          << " " << (d.messageShouldHaveNs() ? d.getns() : "")
          << "  " << m.header().getLen() << " bytes "
          << " id:" << hex << m.header().getId() << dec << "\t" << m.header().getId();
 

Comment by Ramon Fernandez Marina [ 22/Sep/14 ]

89berner, in order to evaluate your pull request you need to sign the contributor's aggreement. Also, please check the pull request as we also need an answer to benety.goh's question (i.e.: desired output of this change).

Thanks,
Ramón.

Generated at Thu Feb 08 03:37:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.