handle return value in kretprobe handler for tcpv4connect
authorYonghong Song <yhs@plumgrid.com>
Wed, 7 Oct 2015 15:59:42 +0000 (08:59 -0700)
committerYonghong Song <yhs@plumgrid.com>
Wed, 7 Oct 2015 15:59:42 +0000 (08:59 -0700)
Signed-off-by: Yonghong Song <yhs@plumgrid.com>
tools/tcpv4connect

index fdada97..67a2894 100755 (executable)
@@ -61,6 +61,13 @@ int kretprobe__tcp_v4_connect(struct pt_regs *ctx)
                return 0;       // missed entry
        }
 
+       if (ret != 0) {
+               // failed to send SYNC packet, socket __sk_common.{skc_rcv_saddr, ...}
+               // may not be populated properly.
+               currsock.delete(&pid);
+               return 0;
+       }
+
        // pull in details
        struct sock *skp = *skpp;
        u32 saddr = 0, daddr = 0;