From 096b043a8581ad43f030323a69b4e6c6e78530fa Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Tue, 5 May 2015 23:06:56 +0300 Subject: sock: Fix capturing extra packets from other dev Create PF_PACKET socket with proto=0 which does not setup packet handler and will not capture packets until bind() will be invoked. Also replaced pf_tx_socket by pf_socket as these funcs became the same, as proto arg is set to 0. Suggested-by: Daniel Borkmann Signed-off-by: Vadim Kochan Acked-by: Daniel Borkmann Signed-off-by: Tobias Klauser --- sock.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'sock.c') diff --git a/sock.c b/sock.c index fbf50d8..7cfa4a0 100644 --- a/sock.c +++ b/sock.c @@ -25,19 +25,10 @@ int af_socket(int af) } int pf_socket(void) -{ - int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); - if (unlikely(sock < 0)) - panic("Creation of PF socket failed: %s\n", strerror(errno)); - - return sock; -} - -int pf_tx_socket(void) { int sock = socket(PF_PACKET, SOCK_RAW, 0); if (unlikely(sock < 0)) - panic("Creation of PF TX socket failed: %s\n", strerror(errno)); + panic("Creation of PF socket failed: %s\n", strerror(errno)); return sock; } -- cgit v1.2.3-54-g00ecf