lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 17 Jan 2012 16:14:47 +0000
From:	<abirvalg@...abit.com>
To:	netdev@...r.kernel.org
Subject: Re: /proc/net/tcp6 inconsistent line length

On Tue, 17 Jan 2012 13:33:01 -0000
"David Laight" <David.Laight@...LAB.COM> wrote:

>  
> > My application parses /proc/net/tcp6 at least 4 times per 
> > second, so the overhead of figuring out the length of each 
> > line and subtracting the offset is quite expensive.
> 
> I'd be surprised if you can detect the cost of calling
> strchr(buf, '\n') on each line at the frequency.
> 
> It is probably far less than the other processing you
> do on the line.
> 
> 	David
> 
> 

Thank you, David. I first fread() the whole file to membuf and then process it thusly trying to find a line that matches my source port (porthex) :

while(1){
    memcpy(buffer,&tcp6_membuf[184+170*i],4);
    if ( !memcmp ( porthex, buffer, 4 ) ){ //match!
        goto endloop;
    }
     i++;
     continue;

N.B. 184 is the offset of source port on line 2 from the beginning of file (line 1 is used for column headings)

my /proc/net/tcp6 file contains 300 - 500 lines and I parse it at least from 4 to 10 times per sec. So the maximum is 5000 iterations per sec. It would be very costly CPU wise to do strchr(buf, '\n')
 
I'm not skillful enough to understand the code in kernel sources.
My concern boils down to this:

Was /proc/net/tcp* meant to have an equal length of each line?
If yes, then I discovered a bug.
If no, then would it be possible to patch the kernel to enable an equal length on each line? 


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ