From: Amitay Isaacs Date: Thu, 3 Mar 2016 03:17:40 +0000 (+1100) Subject: ctdb-common: For AF_PACKET socket types, protocol is in network order X-Git-Tag: samba-4.3.12~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e60d1455886aab95b872f2716d4bf5af6fcae466;p=thirdparty%2Fsamba.git ctdb-common: For AF_PACKET socket types, protocol is in network order BUG: https://bugzilla.samba.org/show_bug.cgi?id=11770 From man page of packet(7): protocol is the IEEE 802.3 protocol number in network byte order. See the include file for a list of allowed protocols. When protocol is set to htons(ETH_P_ALL), then all protocols are received. Protocol argument was changed from network order to host order wrongly in commit 9f8395cb7d49b63a82f75bf504f5f83920102b29. Specifying "protocol" field to socket(AF_PACKET, ...) call only affects the packets that are recevied. So use protocol = 0 when sending raw packets. Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke Autobuild-User(master): Martin Schwenke Autobuild-Date(master): Fri Mar 4 12:58:50 CET 2016 on sn-devel-144 (cherry picked from commit f5b6a5b13406c245ab9cc8c1699483af9eb21f88) --- diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c index 2e58853c24c..9872070af5a 100644 --- a/ctdb/common/system_linux.c +++ b/ctdb/common/system_linux.c @@ -93,7 +93,7 @@ int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface) switch (addr->ip.sin_family) { case AF_INET: - s = socket(AF_PACKET, SOCK_RAW, ETHERTYPE_ARP); + s = socket(AF_PACKET, SOCK_RAW, 0); if (s == -1){ DEBUG(DEBUG_CRIT,(__location__ " failed to open raw socket\n")); return -1; @@ -187,7 +187,7 @@ int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface) close(s); break; case AF_INET6: - s = socket(AF_PACKET, SOCK_RAW, ETHERTYPE_ARP); + s = socket(AF_PACKET, SOCK_RAW, 0); if (s == -1){ DEBUG(DEBUG_CRIT,(__location__ " failed to open raw socket\n")); return -1; @@ -447,7 +447,7 @@ int ctdb_sys_open_capture_socket(const char *iface, void **private_data) int s; /* Open a socket to capture all traffic */ - s = socket(AF_PACKET, SOCK_RAW, ETH_P_ALL); + s = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (s == -1) { DEBUG(DEBUG_CRIT,(__location__ " failed to open raw socket\n")); return -1;