{"action":"created","comment":{"url":"https://api.github.com/repos/cilium/cilium/pulls/comments/182383583","pull_request_review_id":113164287,"id":182383583,"diff_hunk":"@@ -3354,7 +3354,376 @@ the toolchain section under the respective tools.\n tc (traffic control)\n --------------------\n \n-TODO\n+Aside from other program types such as XDP, BPF can also be used out of the\n+kernel's tc (traffic control) layer in the networking data path. On a high-level\n+there are three major differences when comparing BPF XDP programs to tc BPF\n+ones:\n+\n+* The BPF input context is a ``sk_buff`` not a ``xdp_buff``. When the kernel's\n+  networking stack receives a packet, after the XDP layer, it allocates a buffer\n+  and parses the packet to store metadata about the packet. This representation\n+  is known as the ``sk_buff``. This structure is then exposed in the BPF input\n+  context so that BPF programs from the tc ingress layer can use the metadata that\n+  the stack extracts from the packet. This can be useful, but comes with an\n+  associated cost of the stack performing this allocation and metadata extraction,\n+  and handling the packet until it hits the tc hook. By definition, the ``xdp_buff``\n+  doesn't have access to this metadata because the XDP hook is called before\n+  this work is done. This is a significant contributor to the performance\n+  difference between the XDP and tc hooks.\n+\n+  Therefore, BPF programs attached to the tc BPF hook can, for instance, read or\n+  write the skb's ``mark``, ``pkt_type``, ``protocol``, ``priority``,\n+  ``queue_mapping``, ``napi_id``, ``cb[]`` array, ``hash``, ``tc_classid`` or\n+  ``tc_index``, vlan metadata, the XDP transferred custom metadata and various\n+  other information. All members of the ``struct __sk_buff`` BPF context used\n+  in tc BPF are defined in the ``linux/bpf.h`` system header.\n+\n+  Generally, the ``sk_buff`` is of a completely different nature than\n+  ``xdp_buff`` where both come with advantages and disadvantages. For example,\n+  the ``sk_buff`` case has the advantage that it is rather straight forward to\n+  mangle its associated metadata, however, it also contains a lot of protocol\n+  specific information (e.g. GSO related state) which makes it difficult to\n+  simply switch protocols by solely rewriting the packet data. This is due to\n+  the stack processing the packet based on the metadata rather than having the\n+  cost of accessing the packet contents each time. Thus, additional conversion\n+  is required from BPF helper functions taking care that ``sk_buff`` internals\n+  are properly converted as well. The ``xdp_buff`` case however does not\n+  face such issues since it comes at such an early stage where the kernel\n+  has not even allocated an ``sk_buff`` yet, thus packet rewrites of any\n+  kind can be realized trivially. However, the ``xdp_buff`` case has the\n+  disadvantage that ``sk_buff`` metadata is not available for mangling\n+  at this time. The latter is overcome by passing custom metadata from\n+  XDP BPF to tc BPF, though. In this way, the limitations of each program\n+  type can be overcome by operating complementary programs of both types\n+  as the use case requires.\n+\n+..\n+\n+* Compared to XDP, tc BPF programs can be triggered out of ingress and also\n+  egress points in the networking data path as opposed to ingress only in case\n+  of XDP.\n+\n+  The two hook points ``sch_handle_ingress()`` and ``sch_handle_egress()`` in\n+  the kernel are triggered out of ``__netif_receive_skb_core()`` and\n+  ``__dev_queue_xmit()``, respectively. The latter two are the main receive\n+  and transmit functions in the data path that, taking XDP aside, are triggered","path":"Documentation/bpf.rst","position":119,"original_position":119,"commit_id":"31ca4eca2ef92448dce80a2629f201a1795c6ef0","original_commit_id":"31ca4eca2ef92448dce80a2629f201a1795c6ef0","user":{"login":"raybejjani","id":744312,"avatar_url":"https://avatars0.githubusercontent.com/u/744312?v=4","gravatar_id":"","url":"https://api.github.com/users/raybejjani","html_url":"https://github.com/raybejjani","followers_url":"https://api.github.com/users/raybejjani/followers","following_url":"https://api.github.com/users/raybejjani/following{/other_user}","gists_url":"https://api.github.com/users/raybejjani/gists{/gist_id}","starred_url":"https://api.github.com/users/raybejjani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raybejjani/subscriptions","organizations_url":"https://api.github.com/users/raybejjani/orgs","repos_url":"https://api.github.com/users/raybejjani/repos","events_url":"https://api.github.com/users/raybejjani/events{/privacy}","received_events_url":"https://api.github.com/users/raybejjani/received_events","type":"User","site_admin":false},"body":"\"functions in the data path that, along with XDP, are triggered\" although it's clear what your saying anyway.","created_at":"2018-04-18T10:42:15Z","updated_at":"2018-04-18T10:51:57Z","html_url":"https://github.com/cilium/cilium/pull/3780#discussion_r182383583","pull_request_url":"https://api.github.com/repos/cilium/cilium/pulls/3780","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/cilium/cilium/pulls/comments/182383583"},"html":{"href":"https://github.com/cilium/cilium/pull/3780#discussion_r182383583"},"pull_request":{"href":"https://api.github.com/repos/cilium/cilium/pulls/3780"}}},"pull_request":{"url":"https://api.github.com/repos/cilium/cilium/pulls/3780","id":182297434,"html_url":"https://github.com/cilium/cilium/pull/3780","diff_url":"https://github.com/cilium/cilium/pull/3780.diff","patch_url":"https://github.com/cilium/cilium/pull/3780.patch","issue_url":"https://api.github.com/repos/cilium/cilium/issues/3780","number":3780,"state":"closed","locked":false,"title":"bpf documentation updates, part 5","user":{"login":"borkmann","id":677393,"avatar_url":"https://avatars1.githubusercontent.com/u/677393?v=4","gravatar_id":"","url":"https://api.github.com/users/borkmann","html_url":"https://github.com/borkmann","followers_url":"https://api.github.com/users/borkmann/followers","following_url":"https://api.github.com/users/borkmann/following{/other_user}","gists_url":"https://api.github.com/users/borkmann/gists{/gist_id}","starred_url":"https://api.github.com/users/borkmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/borkmann/subscriptions","organizations_url":"https://api.github.com/users/borkmann/orgs","repos_url":"https://api.github.com/users/borkmann/repos","events_url":"https://api.github.com/users/borkmann/events{/privacy}","received_events_url":"https://api.github.com/users/borkmann/received_events","type":"User","site_admin":false},"body":"This concludes the initial version of the BPF / XDP ref guide writeup.\r\n\r\nFixes: #713","created_at":"2018-04-17T21:00:48Z","updated_at":"2018-04-18T10:51:57Z","closed_at":"2018-04-18T10:29:38Z","merged_at":"2018-04-18T10:29:37Z","merge_commit_sha":"f8bf6ef3c0ef578e91c68eb6dd55d3b767e51bd3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":893250993,"url":"https://api.github.com/repos/cilium/cilium/labels/1.0-doc-work","name":"1.0-doc-work","color":"1d76db","default":false},{"id":665378286,"url":"https://api.github.com/repos/cilium/cilium/labels/area/documentation","name":"area/documentation","color":"1d76db","default":false},{"id":403149902,"url":"https://api.github.com/repos/cilium/cilium/labels/pending-review","name":"pending-review","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/cilium/cilium/pulls/3780/commits","review_comments_url":"https://api.github.com/repos/cilium/cilium/pulls/3780/comments","review_comment_url":"https://api.github.com/repos/cilium/cilium/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cilium/cilium/issues/3780/comments","statuses_url":"https://api.github.com/repos/cilium/cilium/statuses/31ca4eca2ef92448dce80a2629f201a1795c6ef0","head":{"label":"cilium:doc-updates","ref":"doc-updates","sha":"31ca4eca2ef92448dce80a2629f201a1795c6ef0","user":{"login":"cilium","id":21054566,"avatar_url":"https://avatars0.githubusercontent.com/u/21054566?v=4","gravatar_id":"","url":"https://api.github.com/users/cilium","html_url":"https://github.com/cilium","followers_url":"https://api.github.com/users/cilium/followers","following_url":"https://api.github.com/users/cilium/following{/other_user}","gists_url":"https://api.github.com/users/cilium/gists{/gist_id}","starred_url":"https://api.github.com/users/cilium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cilium/subscriptions","organizations_url":"https://api.github.com/users/cilium/orgs","repos_url":"https://api.github.com/users/cilium/repos","events_url":"https://api.github.com/users/cilium/events{/privacy}","received_events_url":"https://api.github.com/users/cilium/received_events","type":"Organization","site_admin":false},"repo":{"id":48109239,"name":"cilium","full_name":"cilium/cilium","owner":{"login":"cilium","id":21054566,"avatar_url":"https://avatars0.githubusercontent.com/u/21054566?v=4","gravatar_id":"","url":"https://api.github.com/users/cilium","html_url":"https://github.com/cilium","followers_url":"https://api.github.com/users/cilium/followers","following_url":"https://api.github.com/users/cilium/following{/other_user}","gists_url":"https://api.github.com/users/cilium/gists{/gist_id}","starred_url":"https://api.github.com/users/cilium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cilium/subscriptions","organizations_url":"https://api.github.com/users/cilium/orgs","repos_url":"https://api.github.com/users/cilium/repos","events_url":"https://api.github.com/users/cilium/events{/privacy}","received_events_url":"https://api.github.com/users/cilium/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cilium/cilium","description":"HTTP, gRPC, and Kafka Aware Security and Networking for Containers with BPF and XDP","fork":false,"url":"https://api.github.com/repos/cilium/cilium","forks_url":"https://api.github.com/repos/cilium/cilium/forks","keys_url":"https://api.github.com/repos/cilium/cilium/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cilium/cilium/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cilium/cilium/teams","hooks_url":"https://api.github.com/repos/cilium/cilium/hooks","issue_events_url":"https://api.github.com/repos/cilium/cilium/issues/events{/number}","events_url":"https://api.github.com/repos/cilium/cilium/events","assignees_url":"https://api.github.com/repos/cilium/cilium/assignees{/user}","branches_url":"https://api.github.com/repos/cilium/cilium/branches{/branch}","tags_url":"https://api.github.com/repos/cilium/cilium/tags","blobs_url":"https://api.github.com/repos/cilium/cilium/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cilium/cilium/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cilium/cilium/git/refs{/sha}","trees_url":"https://api.github.com/repos/cilium/cilium/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cilium/cilium/statuses/{sha}","languages_url":"https://api.github.com/repos/cilium/cilium/languages","stargazers_url":"https://api.github.com/repos/cilium/cilium/stargazers","contributors_url":"https://api.github.com/repos/cilium/cilium/contributors","subscribers_url":"https://api.github.com/repos/cilium/cilium/subscribers","subscription_url":"https://api.github.com/repos/cilium/cilium/subscription","commits_url":"https://api.github.com/repos/cilium/cilium/commits{/sha}","git_commits_url":"https://api.github.com/repos/cilium/cilium/git/commits{/sha}","comments_url":"https://api.github.com/repos/cilium/cilium/comments{/number}","issue_comment_url":"https://api.github.com/repos/cilium/cilium/issues/comments{/number}","contents_url":"https://api.github.com/repos/cilium/cilium/contents/{+path}","compare_url":"https://api.github.com/repos/cilium/cilium/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cilium/cilium/merges","archive_url":"https://api.github.com/repos/cilium/cilium/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cilium/cilium/downloads","issues_url":"https://api.github.com/repos/cilium/cilium/issues{/number}","pulls_url":"https://api.github.com/repos/cilium/cilium/pulls{/number}","milestones_url":"https://api.github.com/repos/cilium/cilium/milestones{/number}","notifications_url":"https://api.github.com/repos/cilium/cilium/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cilium/cilium/labels{/name}","releases_url":"https://api.github.com/repos/cilium/cilium/releases{/id}","deployments_url":"https://api.github.com/repos/cilium/cilium/deployments","created_at":"2015-12-16T12:33:31Z","updated_at":"2018-04-18T10:29:47Z","pushed_at":"2018-04-18T10:41:55Z","git_url":"git://github.com/cilium/cilium.git","ssh_url":"git@github.com:cilium/cilium.git","clone_url":"https://github.com/cilium/cilium.git","svn_url":"https://github.com/cilium/cilium","homepage":"","size":45076,"stargazers_count":1768,"watchers_count":1768,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":169,"mirror_url":null,"archived":false,"open_issues_count":501,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":169,"open_issues":501,"watchers":1768,"default_branch":"master"}},"base":{"label":"cilium:master","ref":"master","sha":"a1e7a25405a8a65285af4a1dd00b8c93d478ec17","user":{"login":"cilium","id":21054566,"avatar_url":"https://avatars0.githubusercontent.com/u/21054566?v=4","gravatar_id":"","url":"https://api.github.com/users/cilium","html_url":"https://github.com/cilium","followers_url":"https://api.github.com/users/cilium/followers","following_url":"https://api.github.com/users/cilium/following{/other_user}","gists_url":"https://api.github.com/users/cilium/gists{/gist_id}","starred_url":"https://api.github.com/users/cilium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cilium/subscriptions","organizations_url":"https://api.github.com/users/cilium/orgs","repos_url":"https://api.github.com/users/cilium/repos","events_url":"https://api.github.com/users/cilium/events{/privacy}","received_events_url":"https://api.github.com/users/cilium/received_events","type":"Organization","site_admin":false},"repo":{"id":48109239,"name":"cilium","full_name":"cilium/cilium","owner":{"login":"cilium","id":21054566,"avatar_url":"https://avatars0.githubusercontent.com/u/21054566?v=4","gravatar_id":"","url":"https://api.github.com/users/cilium","html_url":"https://github.com/cilium","followers_url":"https://api.github.com/users/cilium/followers","following_url":"https://api.github.com/users/cilium/following{/other_user}","gists_url":"https://api.github.com/users/cilium/gists{/gist_id}","starred_url":"https://api.github.com/users/cilium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cilium/subscriptions","organizations_url":"https://api.github.com/users/cilium/orgs","repos_url":"https://api.github.com/users/cilium/repos","events_url":"https://api.github.com/users/cilium/events{/privacy}","received_events_url":"https://api.github.com/users/cilium/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cilium/cilium","description":"HTTP, gRPC, and Kafka Aware Security and Networking for Containers with BPF and XDP","fork":false,"url":"https://api.github.com/repos/cilium/cilium","forks_url":"https://api.github.com/repos/cilium/cilium/forks","keys_url":"https://api.github.com/repos/cilium/cilium/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cilium/cilium/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cilium/cilium/teams","hooks_url":"https://api.github.com/repos/cilium/cilium/hooks","issue_events_url":"https://api.github.com/repos/cilium/cilium/issues/events{/number}","events_url":"https://api.github.com/repos/cilium/cilium/events","assignees_url":"https://api.github.com/repos/cilium/cilium/assignees{/user}","branches_url":"https://api.github.com/repos/cilium/cilium/branches{/branch}","tags_url":"https://api.github.com/repos/cilium/cilium/tags","blobs_url":"https://api.github.com/repos/cilium/cilium/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cilium/cilium/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cilium/cilium/git/refs{/sha}","trees_url":"https://api.github.com/repos/cilium/cilium/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cilium/cilium/statuses/{sha}","languages_url":"https://api.github.com/repos/cilium/cilium/languages","stargazers_url":"https://api.github.com/repos/cilium/cilium/stargazers","contributors_url":"https://api.github.com/repos/cilium/cilium/contributors","subscribers_url":"https://api.github.com/repos/cilium/cilium/subscribers","subscription_url":"https://api.github.com/repos/cilium/cilium/subscription","commits_url":"https://api.github.com/repos/cilium/cilium/commits{/sha}","git_commits_url":"https://api.github.com/repos/cilium/cilium/git/commits{/sha}","comments_url":"https://api.github.com/repos/cilium/cilium/comments{/number}","issue_comment_url":"https://api.github.com/repos/cilium/cilium/issues/comments{/number}","contents_url":"https://api.github.com/repos/cilium/cilium/contents/{+path}","compare_url":"https://api.github.com/repos/cilium/cilium/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cilium/cilium/merges","archive_url":"https://api.github.com/repos/cilium/cilium/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cilium/cilium/downloads","issues_url":"https://api.github.com/repos/cilium/cilium/issues{/number}","pulls_url":"https://api.github.com/repos/cilium/cilium/pulls{/number}","milestones_url":"https://api.github.com/repos/cilium/cilium/milestones{/number}","notifications_url":"https://api.github.com/repos/cilium/cilium/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cilium/cilium/labels{/name}","releases_url":"https://api.github.com/repos/cilium/cilium/releases{/id}","deployments_url":"https://api.github.com/repos/cilium/cilium/deployments","created_at":"2015-12-16T12:33:31Z","updated_at":"2018-04-18T10:29:47Z","pushed_at":"2018-04-18T10:41:55Z","git_url":"git://github.com/cilium/cilium.git","ssh_url":"git@github.com:cilium/cilium.git","clone_url":"https://github.com/cilium/cilium.git","svn_url":"https://github.com/cilium/cilium","homepage":"","size":45076,"stargazers_count":1768,"watchers_count":1768,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":169,"mirror_url":null,"archived":false,"open_issues_count":501,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":169,"open_issues":501,"watchers":1768,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cilium/cilium/pulls/3780"},"html":{"href":"https://github.com/cilium/cilium/pull/3780"},"issue":{"href":"https://api.github.com/repos/cilium/cilium/issues/3780"},"comments":{"href":"https://api.github.com/repos/cilium/cilium/issues/3780/comments"},"review_comments":{"href":"https://api.github.com/repos/cilium/cilium/pulls/3780/comments"},"review_comment":{"href":"https://api.github.com/repos/cilium/cilium/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cilium/cilium/pulls/3780/commits"},"statuses":{"href":"https://api.github.com/repos/cilium/cilium/statuses/31ca4eca2ef92448dce80a2629f201a1795c6ef0"}},"author_association":"OWNER"}}
{"actor":{"display_login":"raybejjani"}}