{"action":"created","comment":{"url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/pulls/comments/91745792","pull_request_review_id":12257511,"id":91745792,"diff_hunk":"@@ -234,15 +262,134 @@ int kretprobe__tcp_v6_connect(struct pt_regs *ctx)\n \t\t.netns = net_ns_inum,\n \t};\n \n-\tbpf_get_current_comm(&evt.comm, sizeof(evt.comm));\n \n-\t// do not send event if IP address is :: or port is 0\n-\tif ((evt.saddr_h || evt.saddr_l) && (evt.daddr_h || evt.daddr_l) && evt.sport != 0 && evt.dport != 0) {\n-\t\tbpf_perf_event_output(ctx, &tcp_event_v6, BPF_F_CURRENT_CPU, &evt, sizeof(evt));\n-\t}\n+\tstruct pid_comm p = { .pid = pid };\n+\tbpf_get_current_comm(&p.comm, sizeof(p.comm));\n+\tbpf_map_update_elem(&tuplepid_ipv6, &t, &p, BPF_ANY);\n \n-\tbpf_map_delete_elem(&connectsock_v6, &pid);\n+\treturn 0;\n+}\n+\n+SEC(\"kprobe/tcp_set_state\")\n+int kprobe__tcp_set_state(struct pt_regs *ctx)\n+{\n+\tu64 pid = bpf_get_current_pid_tgid();\n+\t/* TODO: remove printks */\n+\tchar called_msg[] = \"kretprobe/tcp_set_state called\\n\";\n+\tbpf_trace_printk(called_msg, sizeof(called_msg));\n \n+\t/* FILTER_PID */\n+\tstruct sock *skp;\n+\tint state;\n+\tskp =  (struct sock *) PT_REGS_PARM1(ctx);\n+\tstate = (int) PT_REGS_PARM2(ctx);\n+\tstruct ns_common *ns;\n+\tu32 net_ns_inum = 0;\n+\tu16 sport = 0, dport = 0, family = 0;\n+\tu8 ipver = 0;\n+\t// Get network namespace id, if kernel supports it\n+#ifdef CONFIG_NET_NS\n+\tpossible_net_t skc_net;\n+\tbpf_probe_read(&skc_net, sizeof(skc_net), &skp->__sk_common.skc_net);\n+\tbpf_probe_read(&net_ns_inum, sizeof(net_ns_inum), &skc_net.net->ns.inum);\n+#else\n+\tnet_ns_inum = 0;","path":"tcptracer-bpf.c","position":274,"original_position":274,"commit_id":"246db4dad87a0f7bcd55b8ddf0e6e304c2827123","original_commit_id":"246db4dad87a0f7bcd55b8ddf0e6e304c2827123","user":{"login":"alban","id":27575,"avatar_url":"https://avatars.githubusercontent.com/u/27575?v=3","gravatar_id":"","url":"https://api.github.com/users/alban","html_url":"https://github.com/alban","followers_url":"https://api.github.com/users/alban/followers","following_url":"https://api.github.com/users/alban/following{/other_user}","gists_url":"https://api.github.com/users/alban/gists{/gist_id}","starred_url":"https://api.github.com/users/alban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alban/subscriptions","organizations_url":"https://api.github.com/users/alban/orgs","repos_url":"https://api.github.com/users/alban/repos","events_url":"https://api.github.com/users/alban/events{/privacy}","received_events_url":"https://api.github.com/users/alban/received_events","type":"User","site_admin":false},"body":"it is already initialized line 287","created_at":"2016-12-09T16:17:51Z","updated_at":"2016-12-09T16:17:51Z","html_url":"https://github.com/kinvolk/tcptracer-bpf/pull/13#discussion_r91745792","pull_request_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/kinvolk/tcptracer-bpf/pulls/comments/91745792"},"html":{"href":"https://github.com/kinvolk/tcptracer-bpf/pull/13#discussion_r91745792"},"pull_request":{"href":"https://api.github.com/repos/kinvolk/tcptracer-bpf/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/pulls/13","id":97286366,"html_url":"https://github.com/kinvolk/tcptracer-bpf/pull/13","diff_url":"https://github.com/kinvolk/tcptracer-bpf/pull/13.diff","patch_url":"https://github.com/kinvolk/tcptracer-bpf/pull/13.patch","issue_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/issues/13","number":13,"state":"open","locked":false,"title":"connect events come from tcp_set_state","user":{"login":"alepuccetti","id":6577391,"avatar_url":"https://avatars.githubusercontent.com/u/6577391?v=3","gravatar_id":"","url":"https://api.github.com/users/alepuccetti","html_url":"https://github.com/alepuccetti","followers_url":"https://api.github.com/users/alepuccetti/followers","following_url":"https://api.github.com/users/alepuccetti/following{/other_user}","gists_url":"https://api.github.com/users/alepuccetti/gists{/gist_id}","starred_url":"https://api.github.com/users/alepuccetti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alepuccetti/subscriptions","organizations_url":"https://api.github.com/users/alepuccetti/orgs","repos_url":"https://api.github.com/users/alepuccetti/repos","events_url":"https://api.github.com/users/alepuccetti/events{/privacy}","received_events_url":"https://api.github.com/users/alepuccetti/received_events","type":"User","site_admin":false},"body":"`tcp_set_state` does not run in the context of the process that calls connect().\r\nWe store the addresses/ports associated with `tcp_v{4,6}_connect` and do\r\na map `addr/ports -> PID` and then send the event only when the\r\nconnection is set to `TCP_ESTABLISHED` with the right `PID`.\r\nBased on https://github.com/kinvolk/bcc/ commits: 2671799e...4ba916a\r\n\r\nAlso a quick fix for removing docker images only when running in CIs. Related to https://github.com/kinvolk/tcptracer-bpf/issues/11\r\n\r\nThis PR needs to be merged at the same time with https://github.com/kinvolk/gobpf-elf-loader/pull/7","created_at":"2016-12-09T10:39:57Z","updated_at":"2016-12-09T16:17:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"344a1f00bac7a7d6f034c2ac2e0a0badcb8123ab","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/pulls/13/commits","review_comments_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/pulls/13/comments","review_comment_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/issues/13/comments","statuses_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/statuses/246db4dad87a0f7bcd55b8ddf0e6e304c2827123","head":{"label":"kinvolk:alessandro/tcp-state","ref":"alessandro/tcp-state","sha":"246db4dad87a0f7bcd55b8ddf0e6e304c2827123","user":{"login":"kinvolk","id":14073052,"avatar_url":"https://avatars.githubusercontent.com/u/14073052?v=3","gravatar_id":"","url":"https://api.github.com/users/kinvolk","html_url":"https://github.com/kinvolk","followers_url":"https://api.github.com/users/kinvolk/followers","following_url":"https://api.github.com/users/kinvolk/following{/other_user}","gists_url":"https://api.github.com/users/kinvolk/gists{/gist_id}","starred_url":"https://api.github.com/users/kinvolk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinvolk/subscriptions","organizations_url":"https://api.github.com/users/kinvolk/orgs","repos_url":"https://api.github.com/users/kinvolk/repos","events_url":"https://api.github.com/users/kinvolk/events{/privacy}","received_events_url":"https://api.github.com/users/kinvolk/received_events","type":"Organization","site_admin":false},"repo":{"id":74774923,"name":"tcptracer-bpf","full_name":"kinvolk/tcptracer-bpf","owner":{"login":"kinvolk","id":14073052,"avatar_url":"https://avatars.githubusercontent.com/u/14073052?v=3","gravatar_id":"","url":"https://api.github.com/users/kinvolk","html_url":"https://github.com/kinvolk","followers_url":"https://api.github.com/users/kinvolk/followers","following_url":"https://api.github.com/users/kinvolk/following{/other_user}","gists_url":"https://api.github.com/users/kinvolk/gists{/gist_id}","starred_url":"https://api.github.com/users/kinvolk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinvolk/subscriptions","organizations_url":"https://api.github.com/users/kinvolk/orgs","repos_url":"https://api.github.com/users/kinvolk/repos","events_url":"https://api.github.com/users/kinvolk/events{/privacy}","received_events_url":"https://api.github.com/users/kinvolk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kinvolk/tcptracer-bpf","description":null,"fork":false,"url":"https://api.github.com/repos/kinvolk/tcptracer-bpf","forks_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/forks","keys_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/teams","hooks_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/hooks","issue_events_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/issues/events{/number}","events_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/events","assignees_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/assignees{/user}","branches_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/branches{/branch}","tags_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/tags","blobs_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/git/refs{/sha}","trees_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/statuses/{sha}","languages_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/languages","stargazers_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/stargazers","contributors_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/contributors","subscribers_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/subscribers","subscription_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/subscription","commits_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/commits{/sha}","git_commits_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/git/commits{/sha}","comments_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/comments{/number}","issue_comment_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/issues/comments{/number}","contents_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/contents/{+path}","compare_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/merges","archive_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/downloads","issues_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/issues{/number}","pulls_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/pulls{/number}","milestones_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/milestones{/number}","notifications_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/labels{/name}","releases_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/releases{/id}","deployments_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/deployments","created_at":"2016-11-25T16:53:49Z","updated_at":"2016-12-05T12:55:12Z","pushed_at":"2016-12-09T14:54:32Z","git_url":"git://github.com/kinvolk/tcptracer-bpf.git","ssh_url":"git@github.com:kinvolk/tcptracer-bpf.git","clone_url":"https://github.com/kinvolk/tcptracer-bpf.git","svn_url":"https://github.com/kinvolk/tcptracer-bpf","homepage":null,"size":61,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"kinvolk:master","ref":"master","sha":"60814947125228b557c939e2a1e10b30ab61acd5","user":{"login":"kinvolk","id":14073052,"avatar_url":"https://avatars.githubusercontent.com/u/14073052?v=3","gravatar_id":"","url":"https://api.github.com/users/kinvolk","html_url":"https://github.com/kinvolk","followers_url":"https://api.github.com/users/kinvolk/followers","following_url":"https://api.github.com/users/kinvolk/following{/other_user}","gists_url":"https://api.github.com/users/kinvolk/gists{/gist_id}","starred_url":"https://api.github.com/users/kinvolk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinvolk/subscriptions","organizations_url":"https://api.github.com/users/kinvolk/orgs","repos_url":"https://api.github.com/users/kinvolk/repos","events_url":"https://api.github.com/users/kinvolk/events{/privacy}","received_events_url":"https://api.github.com/users/kinvolk/received_events","type":"Organization","site_admin":false},"repo":{"id":74774923,"name":"tcptracer-bpf","full_name":"kinvolk/tcptracer-bpf","owner":{"login":"kinvolk","id":14073052,"avatar_url":"https://avatars.githubusercontent.com/u/14073052?v=3","gravatar_id":"","url":"https://api.github.com/users/kinvolk","html_url":"https://github.com/kinvolk","followers_url":"https://api.github.com/users/kinvolk/followers","following_url":"https://api.github.com/users/kinvolk/following{/other_user}","gists_url":"https://api.github.com/users/kinvolk/gists{/gist_id}","starred_url":"https://api.github.com/users/kinvolk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinvolk/subscriptions","organizations_url":"https://api.github.com/users/kinvolk/orgs","repos_url":"https://api.github.com/users/kinvolk/repos","events_url":"https://api.github.com/users/kinvolk/events{/privacy}","received_events_url":"https://api.github.com/users/kinvolk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kinvolk/tcptracer-bpf","description":null,"fork":false,"url":"https://api.github.com/repos/kinvolk/tcptracer-bpf","forks_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/forks","keys_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/teams","hooks_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/hooks","issue_events_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/issues/events{/number}","events_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/events","assignees_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/assignees{/user}","branches_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/branches{/branch}","tags_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/tags","blobs_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/git/refs{/sha}","trees_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/statuses/{sha}","languages_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/languages","stargazers_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/stargazers","contributors_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/contributors","subscribers_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/subscribers","subscription_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/subscription","commits_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/commits{/sha}","git_commits_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/git/commits{/sha}","comments_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/comments{/number}","issue_comment_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/issues/comments{/number}","contents_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/contents/{+path}","compare_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/merges","archive_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/downloads","issues_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/issues{/number}","pulls_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/pulls{/number}","milestones_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/milestones{/number}","notifications_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/labels{/name}","releases_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/releases{/id}","deployments_url":"https://api.github.com/repos/kinvolk/tcptracer-bpf/deployments","created_at":"2016-11-25T16:53:49Z","updated_at":"2016-12-05T12:55:12Z","pushed_at":"2016-12-09T14:54:32Z","git_url":"git://github.com/kinvolk/tcptracer-bpf.git","ssh_url":"git@github.com:kinvolk/tcptracer-bpf.git","clone_url":"https://github.com/kinvolk/tcptracer-bpf.git","svn_url":"https://github.com/kinvolk/tcptracer-bpf","homepage":null,"size":61,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kinvolk/tcptracer-bpf/pulls/13"},"html":{"href":"https://github.com/kinvolk/tcptracer-bpf/pull/13"},"issue":{"href":"https://api.github.com/repos/kinvolk/tcptracer-bpf/issues/13"},"comments":{"href":"https://api.github.com/repos/kinvolk/tcptracer-bpf/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/kinvolk/tcptracer-bpf/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/kinvolk/tcptracer-bpf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kinvolk/tcptracer-bpf/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/kinvolk/tcptracer-bpf/statuses/246db4dad87a0f7bcd55b8ddf0e6e304c2827123"}}}}
{"actor":{"display_login":"alban"}}