Skip to content

Conversation

@gllghr
Copy link
Contributor

@gllghr gllghr commented Oct 3, 2019

The IPv4 addresses in /proc/tcp are not converted to host order before being printed by the kernel, so they have least-significant byte first on little-endian systems (see https://github.com/torvalds/linux/blob/0f1a7b3fac0583083ca19d4de47403511ced3521/net/ipv4/tcp_ipv4.c#L2460). We need to convert them back to network order when parsing them.

Previous output:

   92: S_IFSOCK mode:777 dev:0,9 ino:1093729 uid:0 gid:0 size:0
       O_RDWR
         SOCK_STREAM
         sockname: AF_INET 1.0.0.127  port: 8586

Fixed output:

   92: S_IFSOCK mode:777 dev:0,9 ino:1093729 uid:0 gid:0 size:0
       O_RDWR
         SOCK_STREAM
         sockname: AF_INET 127.0.0.1  port: 8586

I also added a follow-up commit which improves the error handling in the relevant function and adds tests for it.

ab-pre-push: http://selfservice.jenkins.delphix.com/job/devops-gate/job/master/job/appliance-build-orchestrator-pre-push/2263/

Fixes #1

@gllghr
Copy link
Contributor Author

gllghr commented Oct 3, 2019

cc @sebroy

@gllghr gllghr merged commit cc0aa67 into delphix:master Oct 4, 2019
@gllghr gllghr deleted the ipv4Addr branch October 14, 2019 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

pfiles prints IP addresses in the wrong byte order

1 participant