From owner-freebsd-bugs@FreeBSD.ORG Tue Sep 18 13:30:11 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E3E061065674 for ; Tue, 18 Sep 2012 13:30:10 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id BCC6D8FC25 for ; Tue, 18 Sep 2012 13:30:10 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q8IDUACm026842 for ; Tue, 18 Sep 2012 13:30:10 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q8IDUAkf026839; Tue, 18 Sep 2012 13:30:10 GMT (envelope-from gnats) Resent-Date: Tue, 18 Sep 2012 13:30:10 GMT Resent-Message-Id: <201209181330.q8IDUAkf026839@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Stephen Workman Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C92FF106566C for ; Tue, 18 Sep 2012 13:28:50 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 9B97D8FC0A for ; Tue, 18 Sep 2012 13:28:50 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q8IDSoGj048867 for ; Tue, 18 Sep 2012 13:28:50 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id q8IDSow0048866; Tue, 18 Sep 2012 13:28:50 GMT (envelope-from nobody) Message-Id: <201209181328.q8IDSow0048866@red.freebsd.org> Date: Tue, 18 Sep 2012 13:28:50 GMT From: Stephen Workman To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/171744: [PATCH] Fix wake command not sending proper WOL packet X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Sep 2012 13:30:11 -0000 >Number: 171744 >Category: misc >Synopsis: [PATCH] Fix wake command not sending proper WOL packet >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Sep 18 13:30:10 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Stephen Workman >Release: FreeBSD 9.0-RELEASE-p3 >Organization: >Environment: FreeBSD DarkTower 9.0-RELEASE-p3 FreeBSD 9.0-RELEASE-p3 #0: Tue Jun 12 02:52:29 UTC 2012 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64 >Description: The current version of the wake command (/usr/sbin/wake) sends an improperly formatted WOL packet. It is "improper" due to the fact that it sends to the broadcast address of ff:ff:ff:ff:ff:ff instead of the address(es) specified on the command line. Because of this, the packet never makes it to the target host and thus, does not wake up the "sleeping" target. I believe, in my case, the packet isn't even leaving the FreeBSD host. >How-To-Repeat: Run tcpdump on the target host: (tcpdump -i -nne not tcp and not udp and not icmp) - or use Wireshark on a Windows host. Use "wake" to send a WOL packet to the target's MAC address (e.g.: wake xl0 00:11:22:33:44:55) The packet will not be received on the target. >Fix: Send the packet to the target MAC address instead of the broadcast MAC. The patch I have attached makes this change. I have tested it, and it works as expected. Additionally, I have modified the ether_type value to use 0x0842 as this is recognized by tools such as Wireshark and is also used by some other WOL utilities. Also, emits a message to the screen when it sends a packet. Patch attached with submission follows: --- /usr/src/usr.sbin/wake/wake.c 2012-01-02 22:25:54.000000000 -0500 +++ wake.c 2012-09-18 08:23:32.000000000 -0400 @@ -160,8 +160,18 @@ ssize_t len; int i; - (void)memset(pkt.hdr.ether_dhost, 0xff, sizeof(pkt.hdr.ether_dhost)); - pkt.hdr.ether_type = htons(0); + /* Be useful */ + printf("Sending magic packet to "); + for(i = 0; i < ETHER_ADDR_LEN - 1; i++) + printf("%.2X:", addr->octet[i]); + printf("%.2X\n", addr->octet[ETHER_ADDR_LEN-1]); + + /* The packet MUST be sent to the target MAC address */ + memcpy(pkt.hdr.ether_dhost, addr, ETHER_ADDR_LEN); + + /* EtherType 0x0842 is at least semi-recognizable for WOL */ + pkt.hdr.ether_type = htons(0x0842); + (void)memset(pkt.data, 0xff, SYNC_LEN); for (p = pkt.data + SYNC_LEN, i = 0; i < DESTADDR_COUNT; p += ETHER_ADDR_LEN, i++) >Release-Note: >Audit-Trail: >Unformatted: