{"action":"created","comment":{"url":"https://api.github.com/repos/libpnet/libpnet/pulls/comments/188352351","pull_request_review_id":120313302,"id":188352351,"diff_hunk":"@@ -119,23 +122,71 @@ pub fn channel(network_interface: &NetworkInterface,\n \n     // Enable promiscuous capture\n     if unsafe {\n-        libc::setsockopt(socket,\n-                         linux::SOL_PACKET,\n-                         linux::PACKET_ADD_MEMBERSHIP,\n-                         (&pmr as *const linux::packet_mreq) as *const libc::c_void,\n-                         mem::size_of::<linux::packet_mreq>() as u32)\n-    } == -1 {\n+        libc::setsockopt(\n+            socket,\n+            linux::SOL_PACKET,\n+            linux::PACKET_ADD_MEMBERSHIP,\n+            (&pmr as *const linux::packet_mreq) as *const libc::c_void,\n+            mem::size_of::<linux::packet_mreq>() as u32,\n+        )\n+    } == -1\n+    {\n         let err = io::Error::last_os_error();\n         unsafe {\n             pnet_sys::close(socket);\n         }\n         return Err(err);\n     }\n \n+    // Enable packet fanout\n+    if let Some(fanout) = config.fanout {\n+        use super::FanoutType;\n+        let mut typ = match fanout.fanout_type {\n+            FanoutType::HASH => linux::PACKET_FANOUT_HASH,\n+            FanoutType::LB => linux::PACKET_FANOUT_LB,\n+            FanoutType::CPU => linux::PACKET_FANOUT_CPU,\n+            FanoutType::ROLLOVER => linux::PACKET_FANOUT_ROLLOVER,\n+            FanoutType::RND => linux::PACKET_FANOUT_RND,\n+            FanoutType::QM => linux::PACKET_FANOUT_QM,\n+            FanoutType::CBPF => linux::PACKET_FANOUT_CBPF,\n+            FanoutType::EBPF => linux::PACKET_FANOUT_EBPF,\n+        } as u32;\n+        // set defrag flag\n+        if fanout.defrag {\n+            typ = typ | linux::PACKET_FANOUT_FLAG_DEFRAG;\n+        }\n+        // set rollover flag\n+        if fanout.rollover {\n+            typ = typ | linux::PACKET_FANOUT_FLAG_ROLLOVER;\n+        }\n+        // set uniqueid flag -- probably not needed atm..\n+        // PACKET_FANOUT_FLAG_UNIQUEID -- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4a69a864209e9ab436d4a58e8028ac96cc873d15","path":"pnet_datalink/src/linux.rs","position":101,"original_position":101,"commit_id":"e3ed08ceaac45c60ce33787ddc50064e93f6ab29","original_commit_id":"e3ed08ceaac45c60ce33787ddc50064e93f6ab29","user":{"login":"berkus","id":80306,"avatar_url":"https://avatars3.githubusercontent.com/u/80306?v=4","gravatar_id":"","url":"https://api.github.com/users/berkus","html_url":"https://github.com/berkus","followers_url":"https://api.github.com/users/berkus/followers","following_url":"https://api.github.com/users/berkus/following{/other_user}","gists_url":"https://api.github.com/users/berkus/gists{/gist_id}","starred_url":"https://api.github.com/users/berkus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/berkus/subscriptions","organizations_url":"https://api.github.com/users/berkus/orgs","repos_url":"https://api.github.com/users/berkus/repos","events_url":"https://api.github.com/users/berkus/events{/privacy}","received_events_url":"https://api.github.com/users/berkus/received_events","type":"User","site_admin":false},"body":"There's no way to request socket's group_id, and uniqueid sets it to some unused value. We then have to reuse that value for opening other sockets. And we can't.\r\n\r\nAt the moment I decided against exporting get_group_id() API - mostly because I don't know how it could be exposed nicely.","created_at":"2018-05-15T16:26:17Z","updated_at":"2018-05-15T16:26:17Z","html_url":"https://github.com/libpnet/libpnet/pull/328#discussion_r188352351","pull_request_url":"https://api.github.com/repos/libpnet/libpnet/pulls/328","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/libpnet/libpnet/pulls/comments/188352351"},"html":{"href":"https://github.com/libpnet/libpnet/pull/328#discussion_r188352351"},"pull_request":{"href":"https://api.github.com/repos/libpnet/libpnet/pulls/328"}},"in_reply_to_id":188346485},"pull_request":{"url":"https://api.github.com/repos/libpnet/libpnet/pulls/328","id":188138823,"html_url":"https://github.com/libpnet/libpnet/pull/328","diff_url":"https://github.com/libpnet/libpnet/pull/328.diff","patch_url":"https://github.com/libpnet/libpnet/pull/328.patch","issue_url":"https://api.github.com/repos/libpnet/libpnet/issues/328","number":328,"state":"open","locked":false,"title":"Add PACKET_FANOUT support for Linux","user":{"login":"berkus","id":80306,"avatar_url":"https://avatars3.githubusercontent.com/u/80306?v=4","gravatar_id":"","url":"https://api.github.com/users/berkus","html_url":"https://github.com/berkus","followers_url":"https://api.github.com/users/berkus/followers","following_url":"https://api.github.com/users/berkus/following{/other_user}","gists_url":"https://api.github.com/users/berkus/gists{/gist_id}","starred_url":"https://api.github.com/users/berkus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/berkus/subscriptions","organizations_url":"https://api.github.com/users/berkus/orgs","repos_url":"https://api.github.com/users/berkus/repos","events_url":"https://api.github.com/users/berkus/events{/privacy}","received_events_url":"https://api.github.com/users/berkus/received_events","type":"User","site_admin":false},"body":"Adds an example app.\r\nAlso rustfmt using RFC-based rustfmt-preview.","created_at":"2018-05-15T14:01:20Z","updated_at":"2018-05-15T16:26:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b99cb8034ab0cda047b871ce01b27495cce87ce1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/libpnet/libpnet/pulls/328/commits","review_comments_url":"https://api.github.com/repos/libpnet/libpnet/pulls/328/comments","review_comment_url":"https://api.github.com/repos/libpnet/libpnet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libpnet/libpnet/issues/328/comments","statuses_url":"https://api.github.com/repos/libpnet/libpnet/statuses/e3ed08ceaac45c60ce33787ddc50064e93f6ab29","head":{"label":"berkus:add-packet-fanout","ref":"add-packet-fanout","sha":"e3ed08ceaac45c60ce33787ddc50064e93f6ab29","user":{"login":"berkus","id":80306,"avatar_url":"https://avatars3.githubusercontent.com/u/80306?v=4","gravatar_id":"","url":"https://api.github.com/users/berkus","html_url":"https://github.com/berkus","followers_url":"https://api.github.com/users/berkus/followers","following_url":"https://api.github.com/users/berkus/following{/other_user}","gists_url":"https://api.github.com/users/berkus/gists{/gist_id}","starred_url":"https://api.github.com/users/berkus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/berkus/subscriptions","organizations_url":"https://api.github.com/users/berkus/orgs","repos_url":"https://api.github.com/users/berkus/repos","events_url":"https://api.github.com/users/berkus/events{/privacy}","received_events_url":"https://api.github.com/users/berkus/received_events","type":"User","site_admin":false},"repo":{"id":129652419,"name":"libpnet","full_name":"berkus/libpnet","owner":{"login":"berkus","id":80306,"avatar_url":"https://avatars3.githubusercontent.com/u/80306?v=4","gravatar_id":"","url":"https://api.github.com/users/berkus","html_url":"https://github.com/berkus","followers_url":"https://api.github.com/users/berkus/followers","following_url":"https://api.github.com/users/berkus/following{/other_user}","gists_url":"https://api.github.com/users/berkus/gists{/gist_id}","starred_url":"https://api.github.com/users/berkus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/berkus/subscriptions","organizations_url":"https://api.github.com/users/berkus/orgs","repos_url":"https://api.github.com/users/berkus/repos","events_url":"https://api.github.com/users/berkus/events{/privacy}","received_events_url":"https://api.github.com/users/berkus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/berkus/libpnet","description":"Cross-platform, low level networking using the Rust programming language.","fork":true,"url":"https://api.github.com/repos/berkus/libpnet","forks_url":"https://api.github.com/repos/berkus/libpnet/forks","keys_url":"https://api.github.com/repos/berkus/libpnet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/berkus/libpnet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/berkus/libpnet/teams","hooks_url":"https://api.github.com/repos/berkus/libpnet/hooks","issue_events_url":"https://api.github.com/repos/berkus/libpnet/issues/events{/number}","events_url":"https://api.github.com/repos/berkus/libpnet/events","assignees_url":"https://api.github.com/repos/berkus/libpnet/assignees{/user}","branches_url":"https://api.github.com/repos/berkus/libpnet/branches{/branch}","tags_url":"https://api.github.com/repos/berkus/libpnet/tags","blobs_url":"https://api.github.com/repos/berkus/libpnet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/berkus/libpnet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/berkus/libpnet/git/refs{/sha}","trees_url":"https://api.github.com/repos/berkus/libpnet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/berkus/libpnet/statuses/{sha}","languages_url":"https://api.github.com/repos/berkus/libpnet/languages","stargazers_url":"https://api.github.com/repos/berkus/libpnet/stargazers","contributors_url":"https://api.github.com/repos/berkus/libpnet/contributors","subscribers_url":"https://api.github.com/repos/berkus/libpnet/subscribers","subscription_url":"https://api.github.com/repos/berkus/libpnet/subscription","commits_url":"https://api.github.com/repos/berkus/libpnet/commits{/sha}","git_commits_url":"https://api.github.com/repos/berkus/libpnet/git/commits{/sha}","comments_url":"https://api.github.com/repos/berkus/libpnet/comments{/number}","issue_comment_url":"https://api.github.com/repos/berkus/libpnet/issues/comments{/number}","contents_url":"https://api.github.com/repos/berkus/libpnet/contents/{+path}","compare_url":"https://api.github.com/repos/berkus/libpnet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/berkus/libpnet/merges","archive_url":"https://api.github.com/repos/berkus/libpnet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/berkus/libpnet/downloads","issues_url":"https://api.github.com/repos/berkus/libpnet/issues{/number}","pulls_url":"https://api.github.com/repos/berkus/libpnet/pulls{/number}","milestones_url":"https://api.github.com/repos/berkus/libpnet/milestones{/number}","notifications_url":"https://api.github.com/repos/berkus/libpnet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/berkus/libpnet/labels{/name}","releases_url":"https://api.github.com/repos/berkus/libpnet/releases{/id}","deployments_url":"https://api.github.com/repos/berkus/libpnet/deployments","created_at":"2018-04-15T21:28:14Z","updated_at":"2018-05-15T14:03:11Z","pushed_at":"2018-05-15T14:03:09Z","git_url":"git://github.com/berkus/libpnet.git","ssh_url":"git@github.com:berkus/libpnet.git","clone_url":"https://github.com/berkus/libpnet.git","svn_url":"https://github.com/berkus/libpnet","homepage":"","size":1065,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"libpnet:master","ref":"master","sha":"89b7f5f916f109fe8588e02eea0bfcc6fdb84b90","user":{"login":"libpnet","id":8604237,"avatar_url":"https://avatars0.githubusercontent.com/u/8604237?v=4","gravatar_id":"","url":"https://api.github.com/users/libpnet","html_url":"https://github.com/libpnet","followers_url":"https://api.github.com/users/libpnet/followers","following_url":"https://api.github.com/users/libpnet/following{/other_user}","gists_url":"https://api.github.com/users/libpnet/gists{/gist_id}","starred_url":"https://api.github.com/users/libpnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libpnet/subscriptions","organizations_url":"https://api.github.com/users/libpnet/orgs","repos_url":"https://api.github.com/users/libpnet/repos","events_url":"https://api.github.com/users/libpnet/events{/privacy}","received_events_url":"https://api.github.com/users/libpnet/received_events","type":"Organization","site_admin":false},"repo":{"id":23515627,"name":"libpnet","full_name":"libpnet/libpnet","owner":{"login":"libpnet","id":8604237,"avatar_url":"https://avatars0.githubusercontent.com/u/8604237?v=4","gravatar_id":"","url":"https://api.github.com/users/libpnet","html_url":"https://github.com/libpnet","followers_url":"https://api.github.com/users/libpnet/followers","following_url":"https://api.github.com/users/libpnet/following{/other_user}","gists_url":"https://api.github.com/users/libpnet/gists{/gist_id}","starred_url":"https://api.github.com/users/libpnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libpnet/subscriptions","organizations_url":"https://api.github.com/users/libpnet/orgs","repos_url":"https://api.github.com/users/libpnet/repos","events_url":"https://api.github.com/users/libpnet/events{/privacy}","received_events_url":"https://api.github.com/users/libpnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/libpnet/libpnet","description":"Cross-platform, low level networking using the Rust programming language.","fork":false,"url":"https://api.github.com/repos/libpnet/libpnet","forks_url":"https://api.github.com/repos/libpnet/libpnet/forks","keys_url":"https://api.github.com/repos/libpnet/libpnet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libpnet/libpnet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libpnet/libpnet/teams","hooks_url":"https://api.github.com/repos/libpnet/libpnet/hooks","issue_events_url":"https://api.github.com/repos/libpnet/libpnet/issues/events{/number}","events_url":"https://api.github.com/repos/libpnet/libpnet/events","assignees_url":"https://api.github.com/repos/libpnet/libpnet/assignees{/user}","branches_url":"https://api.github.com/repos/libpnet/libpnet/branches{/branch}","tags_url":"https://api.github.com/repos/libpnet/libpnet/tags","blobs_url":"https://api.github.com/repos/libpnet/libpnet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libpnet/libpnet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libpnet/libpnet/git/refs{/sha}","trees_url":"https://api.github.com/repos/libpnet/libpnet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libpnet/libpnet/statuses/{sha}","languages_url":"https://api.github.com/repos/libpnet/libpnet/languages","stargazers_url":"https://api.github.com/repos/libpnet/libpnet/stargazers","contributors_url":"https://api.github.com/repos/libpnet/libpnet/contributors","subscribers_url":"https://api.github.com/repos/libpnet/libpnet/subscribers","subscription_url":"https://api.github.com/repos/libpnet/libpnet/subscription","commits_url":"https://api.github.com/repos/libpnet/libpnet/commits{/sha}","git_commits_url":"https://api.github.com/repos/libpnet/libpnet/git/commits{/sha}","comments_url":"https://api.github.com/repos/libpnet/libpnet/comments{/number}","issue_comment_url":"https://api.github.com/repos/libpnet/libpnet/issues/comments{/number}","contents_url":"https://api.github.com/repos/libpnet/libpnet/contents/{+path}","compare_url":"https://api.github.com/repos/libpnet/libpnet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libpnet/libpnet/merges","archive_url":"https://api.github.com/repos/libpnet/libpnet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libpnet/libpnet/downloads","issues_url":"https://api.github.com/repos/libpnet/libpnet/issues{/number}","pulls_url":"https://api.github.com/repos/libpnet/libpnet/pulls{/number}","milestones_url":"https://api.github.com/repos/libpnet/libpnet/milestones{/number}","notifications_url":"https://api.github.com/repos/libpnet/libpnet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libpnet/libpnet/labels{/name}","releases_url":"https://api.github.com/repos/libpnet/libpnet/releases{/id}","deployments_url":"https://api.github.com/repos/libpnet/libpnet/deployments","created_at":"2014-08-31T14:44:47Z","updated_at":"2018-05-14T23:56:10Z","pushed_at":"2018-05-15T14:01:21Z","git_url":"git://github.com/libpnet/libpnet.git","ssh_url":"git@github.com:libpnet/libpnet.git","clone_url":"https://github.com/libpnet/libpnet.git","svn_url":"https://github.com/libpnet/libpnet","homepage":"","size":1059,"stargazers_count":634,"watchers_count":634,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":115,"mirror_url":null,"archived":false,"open_issues_count":58,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":115,"open_issues":58,"watchers":634,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/libpnet/libpnet/pulls/328"},"html":{"href":"https://github.com/libpnet/libpnet/pull/328"},"issue":{"href":"https://api.github.com/repos/libpnet/libpnet/issues/328"},"comments":{"href":"https://api.github.com/repos/libpnet/libpnet/issues/328/comments"},"review_comments":{"href":"https://api.github.com/repos/libpnet/libpnet/pulls/328/comments"},"review_comment":{"href":"https://api.github.com/repos/libpnet/libpnet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libpnet/libpnet/pulls/328/commits"},"statuses":{"href":"https://api.github.com/repos/libpnet/libpnet/statuses/e3ed08ceaac45c60ce33787ddc50064e93f6ab29"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"berkus"}}