{"action":"created","comment":{"url":"https://api.github.com/repos/AltraMayor/gatekeeper/pulls/comments/88525833","pull_request_review_id":9095309,"id":88525833,"diff_hunk":"@@ -0,0 +1,138 @@\n+/*\n+ * Gatekeeper - DoS protection system.\n+ * Copyright (C) 2016 Digirati LTDA.\n+ *\n+ * This program is free software: you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation, either version 3 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+ */\n+\n+#include <rte_ip.h>\n+#include <rte_mbuf.h>\n+#include <rte_memcpy.h>\n+#include <rte_byteorder.h>\n+\n+#include \"gatekeeper_ipip.h\"\n+\n+#define IP_VERSION              (0x40)\n+/* Default IP header length == five 32-bits words. */\n+#define IP_HDRLEN               (0x05)\n+/* From RFC 1340. */\n+#define IP_DEFTTL               (64)\n+#define IP_VHL_DEF              (IP_VERSION | IP_HDRLEN)\n+#define IP_DN_FRAGMENT_FLAG     (0x0040)\n+\n+#define IPv6_DEFAULT_VTC_FLOW   (0x60000000)\n+#define IPv6_DEFAULT_HOP_LIMITS (0xFF)\n+\n+int\n+encapsulate(struct rte_mbuf *pkt, uint8_t priority,\n+\tstruct ipip_tunnel_info *info)\n+{\n+\tstruct ether_hdr *new_eth;\n+\tstruct ipv4_hdr *outer_ip4hdr;\n+\tstruct ipv6_hdr *outer_ip6hdr;\n+\n+\tif (info->flow.proto == ETHER_TYPE_IPv4) {\n+\t\t/* Allocate space for outer IPv4 header. */\n+\t\tnew_eth = (struct ether_hdr *)rte_pktmbuf_prepend(pkt,\n+\t\t\tsizeof(struct ipv4_hdr));\n+\t\tif (new_eth == NULL) {\n+\t\t\tRTE_LOG(ERR, MBUF,\n+\t\t\t\t\"Not enough headroom space in the first segment!\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\touter_ip4hdr = (struct ipv4_hdr *)&new_eth[1];\n+\n+\t\t/* Fill up the new Ethernet header. */\n+\t\trte_memcpy(&new_eth->s_addr, &info->source_mac,\n+\t\t\tsizeof(new_eth->s_addr));\n+\t\t/* Fill up the destination MAC address via Gateway MAC. */\n+\t\trte_memcpy(&new_eth->d_addr, &info->nexthop_mac,\n+\t\t\tsizeof(new_eth->d_addr));\n+\n+\t\tnew_eth->ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);\n+\n+\t\t/* Fill up the outer IP header. */\n+\t\touter_ip4hdr->version_ihl = IP_VHL_DEF;\n+\t\touter_ip4hdr->type_of_service = (priority << 2);\n+\t\touter_ip4hdr->packet_id = 0;\n+\t\touter_ip4hdr->fragment_offset = IP_DN_FRAGMENT_FLAG;\n+\t\touter_ip4hdr->time_to_live = IP_DEFTTL;\n+\t\touter_ip4hdr->next_proto_id = IPPROTO_IPIP;\n+\t\t/* The source address is the Gatekeeper server IP address. */\n+\t\touter_ip4hdr->src_addr = info->flow.f.v4.src;\n+\t\t/* The destination address is the Grantor server IP address. */\n+\t\touter_ip4hdr->dst_addr = info->flow.f.v4.dst;\n+\n+\t\touter_ip4hdr->total_length = rte_cpu_to_be_16(pkt->data_len\n+\t\t\t- sizeof(struct ether_hdr));\n+\n+\t\t/*\n+\t\t * The IP header checksum filed must be set to 0\n+\t\t * in order to offload the checksum calculation.\n+\t\t */\n+\t\touter_ip4hdr->hdr_checksum = 0;\n+\n+\t\tpkt->outer_l2_len = sizeof(struct ether_hdr);\n+\t\tpkt->outer_l3_len = sizeof(struct ipv4_hdr);\n+\t\t/*\n+\t\t * XXX Change the ol_flags as needed.\n+\t\t * Configure TX offload on a ip-in-ip-encapsulated packet:\n+\t\t * out_eth/out_ip/in_ip/in_tcp or in_udp/payload\n+\t\t * For now, only calculate outer IP checksum.\n+\t\t */","path":"lib/ipip.c","position":94,"original_position":94,"commit_id":"6b6b9b9fc3f3371f3405fd07ea461e48fcc3ad5c","original_commit_id":"2aa0955a8c9a13262e7411fc0a7a5ef6fbf882a0","user":{"login":"AltraMayor","id":727014,"avatar_url":"https://avatars.githubusercontent.com/u/727014?v=3","gravatar_id":"","url":"https://api.github.com/users/AltraMayor","html_url":"https://github.com/AltraMayor","followers_url":"https://api.github.com/users/AltraMayor/followers","following_url":"https://api.github.com/users/AltraMayor/following{/other_user}","gists_url":"https://api.github.com/users/AltraMayor/gists{/gist_id}","starred_url":"https://api.github.com/users/AltraMayor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AltraMayor/subscriptions","organizations_url":"https://api.github.com/users/AltraMayor/orgs","repos_url":"https://api.github.com/users/AltraMayor/repos","events_url":"https://api.github.com/users/AltraMayor/events{/privacy}","received_events_url":"https://api.github.com/users/AltraMayor/received_events","type":"User","site_admin":false},"body":"Would you mind replacing this comment with the one below? The current comment isn't add much.\r\n\r\n`/* Offload checksum computation for the outer IPv4 header. */`","created_at":"2016-11-17T19:20:23Z","updated_at":"2016-11-17T19:28:13Z","html_url":"https://github.com/AltraMayor/gatekeeper/pull/9#discussion_r88525833","pull_request_url":"https://api.github.com/repos/AltraMayor/gatekeeper/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/AltraMayor/gatekeeper/pulls/comments/88525833"},"html":{"href":"https://github.com/AltraMayor/gatekeeper/pull/9#discussion_r88525833"},"pull_request":{"href":"https://api.github.com/repos/AltraMayor/gatekeeper/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/AltraMayor/gatekeeper/pulls/9","id":93281143,"html_url":"https://github.com/AltraMayor/gatekeeper/pull/9","diff_url":"https://github.com/AltraMayor/gatekeeper/pull/9.diff","patch_url":"https://github.com/AltraMayor/gatekeeper/pull/9.patch","issue_url":"https://api.github.com/repos/AltraMayor/gatekeeper/issues/9","number":9,"state":"open","locked":false,"title":"Add IPIP encapsulation for GK, and a simple GK-GT Unit","user":{"login":"mengxiang0811","id":4590679,"avatar_url":"https://avatars.githubusercontent.com/u/4590679?v=3","gravatar_id":"","url":"https://api.github.com/users/mengxiang0811","html_url":"https://github.com/mengxiang0811","followers_url":"https://api.github.com/users/mengxiang0811/followers","following_url":"https://api.github.com/users/mengxiang0811/following{/other_user}","gists_url":"https://api.github.com/users/mengxiang0811/gists{/gist_id}","starred_url":"https://api.github.com/users/mengxiang0811/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mengxiang0811/subscriptions","organizations_url":"https://api.github.com/users/mengxiang0811/orgs","repos_url":"https://api.github.com/users/mengxiang0811/repos","events_url":"https://api.github.com/users/mengxiang0811/events{/privacy}","received_events_url":"https://api.github.com/users/mengxiang0811/received_events","type":"User","site_admin":false},"body":"The first patch adds support for IP over IP encapsulation for GK block, it supports both IPv4 and IPv6 addresses.  In this patch, the ``struct ip_flow`` is reorganized, since it will be shared by several blocks, so I chose to make it as a library.\r\n\r\nThe second patch adds a simple GK-GT Unit. The policies will be batched in a packet, for each policy decision, it first calculates the RSS hash value for that IP flow, then the last 7 bits will be used to index the Redirection table entries, where it stores the queue id. With the queue id, we may need to find an efficient way to lookup the corresponding GK block, who is responsible for that IP flow. For now, it simply iterates all the GK instances to find the matched one. With this patch, both RSS and ntuple filters support IPv6 as expected.","created_at":"2016-11-11T05:24:16Z","updated_at":"2016-11-17T19:28:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5a0122ea24f6b0b72b3570677ecd95eda7cdb452","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/AltraMayor/gatekeeper/pulls/9/commits","review_comments_url":"https://api.github.com/repos/AltraMayor/gatekeeper/pulls/9/comments","review_comment_url":"https://api.github.com/repos/AltraMayor/gatekeeper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AltraMayor/gatekeeper/issues/9/comments","statuses_url":"https://api.github.com/repos/AltraMayor/gatekeeper/statuses/6b6b9b9fc3f3371f3405fd07ea461e48fcc3ad5c","head":{"label":"mengxiang0811:ipip-ggu","ref":"ipip-ggu","sha":"6b6b9b9fc3f3371f3405fd07ea461e48fcc3ad5c","user":{"login":"mengxiang0811","id":4590679,"avatar_url":"https://avatars.githubusercontent.com/u/4590679?v=3","gravatar_id":"","url":"https://api.github.com/users/mengxiang0811","html_url":"https://github.com/mengxiang0811","followers_url":"https://api.github.com/users/mengxiang0811/followers","following_url":"https://api.github.com/users/mengxiang0811/following{/other_user}","gists_url":"https://api.github.com/users/mengxiang0811/gists{/gist_id}","starred_url":"https://api.github.com/users/mengxiang0811/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mengxiang0811/subscriptions","organizations_url":"https://api.github.com/users/mengxiang0811/orgs","repos_url":"https://api.github.com/users/mengxiang0811/repos","events_url":"https://api.github.com/users/mengxiang0811/events{/privacy}","received_events_url":"https://api.github.com/users/mengxiang0811/received_events","type":"User","site_admin":false},"repo":{"id":67135759,"name":"gatekeeper","full_name":"mengxiang0811/gatekeeper","owner":{"login":"mengxiang0811","id":4590679,"avatar_url":"https://avatars.githubusercontent.com/u/4590679?v=3","gravatar_id":"","url":"https://api.github.com/users/mengxiang0811","html_url":"https://github.com/mengxiang0811","followers_url":"https://api.github.com/users/mengxiang0811/followers","following_url":"https://api.github.com/users/mengxiang0811/following{/other_user}","gists_url":"https://api.github.com/users/mengxiang0811/gists{/gist_id}","starred_url":"https://api.github.com/users/mengxiang0811/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mengxiang0811/subscriptions","organizations_url":"https://api.github.com/users/mengxiang0811/orgs","repos_url":"https://api.github.com/users/mengxiang0811/repos","events_url":"https://api.github.com/users/mengxiang0811/events{/privacy}","received_events_url":"https://api.github.com/users/mengxiang0811/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mengxiang0811/gatekeeper","description":"First open source DoS protection system","fork":true,"url":"https://api.github.com/repos/mengxiang0811/gatekeeper","forks_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/forks","keys_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/teams","hooks_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/hooks","issue_events_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/issues/events{/number}","events_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/events","assignees_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/assignees{/user}","branches_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/branches{/branch}","tags_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/tags","blobs_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/git/refs{/sha}","trees_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/statuses/{sha}","languages_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/languages","stargazers_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/stargazers","contributors_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/contributors","subscribers_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/subscribers","subscription_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/subscription","commits_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/commits{/sha}","git_commits_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/git/commits{/sha}","comments_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/comments{/number}","issue_comment_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/issues/comments{/number}","contents_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/contents/{+path}","compare_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/merges","archive_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/downloads","issues_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/issues{/number}","pulls_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/pulls{/number}","milestones_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/milestones{/number}","notifications_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/labels{/name}","releases_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/releases{/id}","deployments_url":"https://api.github.com/repos/mengxiang0811/gatekeeper/deployments","created_at":"2016-09-01T13:55:13Z","updated_at":"2016-10-28T15:53:34Z","pushed_at":"2016-11-17T04:12:30Z","git_url":"git://github.com/mengxiang0811/gatekeeper.git","ssh_url":"git@github.com:mengxiang0811/gatekeeper.git","clone_url":"https://github.com/mengxiang0811/gatekeeper.git","svn_url":"https://github.com/mengxiang0811/gatekeeper","homepage":"","size":156,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"AltraMayor:master","ref":"master","sha":"60a0ed21d38668c8c9103ae499e6244436f21768","user":{"login":"AltraMayor","id":727014,"avatar_url":"https://avatars.githubusercontent.com/u/727014?v=3","gravatar_id":"","url":"https://api.github.com/users/AltraMayor","html_url":"https://github.com/AltraMayor","followers_url":"https://api.github.com/users/AltraMayor/followers","following_url":"https://api.github.com/users/AltraMayor/following{/other_user}","gists_url":"https://api.github.com/users/AltraMayor/gists{/gist_id}","starred_url":"https://api.github.com/users/AltraMayor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AltraMayor/subscriptions","organizations_url":"https://api.github.com/users/AltraMayor/orgs","repos_url":"https://api.github.com/users/AltraMayor/repos","events_url":"https://api.github.com/users/AltraMayor/events{/privacy}","received_events_url":"https://api.github.com/users/AltraMayor/received_events","type":"User","site_admin":false},"repo":{"id":62745741,"name":"gatekeeper","full_name":"AltraMayor/gatekeeper","owner":{"login":"AltraMayor","id":727014,"avatar_url":"https://avatars.githubusercontent.com/u/727014?v=3","gravatar_id":"","url":"https://api.github.com/users/AltraMayor","html_url":"https://github.com/AltraMayor","followers_url":"https://api.github.com/users/AltraMayor/followers","following_url":"https://api.github.com/users/AltraMayor/following{/other_user}","gists_url":"https://api.github.com/users/AltraMayor/gists{/gist_id}","starred_url":"https://api.github.com/users/AltraMayor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AltraMayor/subscriptions","organizations_url":"https://api.github.com/users/AltraMayor/orgs","repos_url":"https://api.github.com/users/AltraMayor/repos","events_url":"https://api.github.com/users/AltraMayor/events{/privacy}","received_events_url":"https://api.github.com/users/AltraMayor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AltraMayor/gatekeeper","description":"First open source DDoS protection system","fork":false,"url":"https://api.github.com/repos/AltraMayor/gatekeeper","forks_url":"https://api.github.com/repos/AltraMayor/gatekeeper/forks","keys_url":"https://api.github.com/repos/AltraMayor/gatekeeper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AltraMayor/gatekeeper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AltraMayor/gatekeeper/teams","hooks_url":"https://api.github.com/repos/AltraMayor/gatekeeper/hooks","issue_events_url":"https://api.github.com/repos/AltraMayor/gatekeeper/issues/events{/number}","events_url":"https://api.github.com/repos/AltraMayor/gatekeeper/events","assignees_url":"https://api.github.com/repos/AltraMayor/gatekeeper/assignees{/user}","branches_url":"https://api.github.com/repos/AltraMayor/gatekeeper/branches{/branch}","tags_url":"https://api.github.com/repos/AltraMayor/gatekeeper/tags","blobs_url":"https://api.github.com/repos/AltraMayor/gatekeeper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AltraMayor/gatekeeper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AltraMayor/gatekeeper/git/refs{/sha}","trees_url":"https://api.github.com/repos/AltraMayor/gatekeeper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AltraMayor/gatekeeper/statuses/{sha}","languages_url":"https://api.github.com/repos/AltraMayor/gatekeeper/languages","stargazers_url":"https://api.github.com/repos/AltraMayor/gatekeeper/stargazers","contributors_url":"https://api.github.com/repos/AltraMayor/gatekeeper/contributors","subscribers_url":"https://api.github.com/repos/AltraMayor/gatekeeper/subscribers","subscription_url":"https://api.github.com/repos/AltraMayor/gatekeeper/subscription","commits_url":"https://api.github.com/repos/AltraMayor/gatekeeper/commits{/sha}","git_commits_url":"https://api.github.com/repos/AltraMayor/gatekeeper/git/commits{/sha}","comments_url":"https://api.github.com/repos/AltraMayor/gatekeeper/comments{/number}","issue_comment_url":"https://api.github.com/repos/AltraMayor/gatekeeper/issues/comments{/number}","contents_url":"https://api.github.com/repos/AltraMayor/gatekeeper/contents/{+path}","compare_url":"https://api.github.com/repos/AltraMayor/gatekeeper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AltraMayor/gatekeeper/merges","archive_url":"https://api.github.com/repos/AltraMayor/gatekeeper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AltraMayor/gatekeeper/downloads","issues_url":"https://api.github.com/repos/AltraMayor/gatekeeper/issues{/number}","pulls_url":"https://api.github.com/repos/AltraMayor/gatekeeper/pulls{/number}","milestones_url":"https://api.github.com/repos/AltraMayor/gatekeeper/milestones{/number}","notifications_url":"https://api.github.com/repos/AltraMayor/gatekeeper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AltraMayor/gatekeeper/labels{/name}","releases_url":"https://api.github.com/repos/AltraMayor/gatekeeper/releases{/id}","deployments_url":"https://api.github.com/repos/AltraMayor/gatekeeper/deployments","created_at":"2016-07-06T18:53:45Z","updated_at":"2016-11-04T13:44:41Z","pushed_at":"2016-11-17T04:12:31Z","git_url":"git://github.com/AltraMayor/gatekeeper.git","ssh_url":"git@github.com:AltraMayor/gatekeeper.git","clone_url":"https://github.com/AltraMayor/gatekeeper.git","svn_url":"https://github.com/AltraMayor/gatekeeper","homepage":"","size":84,"stargazers_count":3,"watchers_count":3,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AltraMayor/gatekeeper/pulls/9"},"html":{"href":"https://github.com/AltraMayor/gatekeeper/pull/9"},"issue":{"href":"https://api.github.com/repos/AltraMayor/gatekeeper/issues/9"},"comments":{"href":"https://api.github.com/repos/AltraMayor/gatekeeper/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/AltraMayor/gatekeeper/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/AltraMayor/gatekeeper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AltraMayor/gatekeeper/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/AltraMayor/gatekeeper/statuses/6b6b9b9fc3f3371f3405fd07ea461e48fcc3ad5c"}}}}
{"actor":{"display_login":"AltraMayor"}}