related to error cases, what would happen if you e.g. set in the IPv6 case 0x21 the dst_ip->af = AF_INET6, but later one run unto an error in the parsing. Then you would return an error to the callee, and would go to the read_ip_info path. Here the AF_INET6 would be still be set, or I am wrong?

I believe you might be misreading the code here. I've added a comment to clarify things.

There is only a single error case after the 0x21 case, and that's the inability to read from the socket. In this case, we return -1, which in the calling function would result in a goto error;, which terminates the connection. We only set the *_ip->af after we've done most of the v2 parsing. Same thing is true for the v1 parsing: once we get to the TCP{4,6} part of the line, only 0 or -1 are possible outputs for the function.

Your comment did help me discover that I was missing the LOCAL case (line 1075), and mistakenly returned 0 in that case instead of 1, so thanks for that.

You work on a local pointer src_ip and dst_ip in the parsing part, but directly on the c->rcv.src_port/c->rcv.dst_port - is there a particular reasons for it?

Convenience. There is only one pointer access for c->rcv.src_port and c->rcv.dst_port, whereas there's two pointer accesses in c->rcv.src_ip->..., and multiple fields are accessed in {src,dst}_ip (af, len, u, etc). I'm happy to use a local pointer if requested.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.