From owner-svn-src-stable-6@FreeBSD.ORG Mon Oct 19 19:14:04 2009 Return-Path: Delivered-To: svn-src-stable-6@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B69481065676; Mon, 19 Oct 2009 19:14:04 +0000 (UTC) (envelope-from gallatin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A3F3B8FC12; Mon, 19 Oct 2009 19:14:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9JJE4q8010255; Mon, 19 Oct 2009 19:14:04 GMT (envelope-from gallatin@svn.freebsd.org) Received: (from gallatin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9JJE4Cj010251; Mon, 19 Oct 2009 19:14:04 GMT (envelope-from gallatin@svn.freebsd.org) Message-Id: <200910191914.n9JJE4Cj010251@svn.freebsd.org> From: Andrew Gallatin Date: Mon, 19 Oct 2009 19:14:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198245 - in stable/6/sys: . conf contrib/pf dev/cxgb kern sys X-BeenThere: svn-src-stable-6@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 6-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Oct 2009 19:14:04 -0000 Author: gallatin Date: Mon Oct 19 19:14:04 2009 New Revision: 198245 URL: http://svn.freebsd.org/changeset/base/198245 Log: MFC of 178042 to allow safe firmware(9) loading from NIC watchdog handlers. Also MFCed are the related changes 178016, 183614 and 184842. 178042: Do firmare image loading in a context known to have a root directory 183614: Dynamically allocate the task struct in firmware mountroot 184842: Avoid scheduling firmware taskqueues when cold 178016: Add a mountroot event handler. Removal of SI_SUB_MOUNT_ROOT was not merged. 178042 is dependant upon this. This fixes a panic in at least mxge(4) if the NIC has a hardware fault when the firmware image is not resident. Reviewed by: jhb Modified: stable/6/sys/ (props changed) stable/6/sys/conf/ (props changed) stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/cxgb/ (props changed) stable/6/sys/kern/subr_firmware.c stable/6/sys/kern/vfs_mount.c stable/6/sys/sys/eventhandler.h Modified: stable/6/sys/kern/subr_firmware.c ============================================================================== --- stable/6/sys/kern/subr_firmware.c Mon Oct 19 19:11:00 2009 (r198244) +++ stable/6/sys/kern/subr_firmware.c Mon Oct 19 19:14:04 2009 (r198245) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2005, Sam Leffler + * Copyright (c) 2005-2008, Sam Leffler * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,6 +40,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include + +#include +#include /* * Loadable firmware support. See sys/sys/firmware.h and firmware(9) @@ -88,7 +92,7 @@ struct priv_fw { /* * 'file' is private info managed by the autoload/unload code. * Set at the end of firmware_get(), cleared only in the - * firmware_task, so the latter can depend on its value even + * firmware_unload_task, so the latter can depend on its value even * while the lock is not held. */ linker_file_t file; /* module file, if autoloaded */ @@ -120,14 +124,16 @@ struct priv_fw { static struct priv_fw firmware_table[FIRMWARE_MAX]; /* - * module release are handled in a separate task as they might sleep. + * Firmware module operations are handled in a separate task as they + * might sleep and they require directory context to do i/o. */ -struct task firmware_task; +static struct taskqueue *firmware_tq; +static struct task firmware_unload_task; /* * This mutex protects accesses to the firmware table. */ -struct mtx firmware_mtx; +static struct mtx firmware_mtx; MTX_SYSINIT(firmware, &firmware_mtx, "firmware table", MTX_DEF); /* @@ -226,7 +232,7 @@ firmware_unregister(const char *imagenam } else if (fp->refcnt != 0) { /* cannot unregister */ err = EBUSY; } else { - linker_file_t x = fp->file; /* save value */ + linker_file_t x = fp->file; /* save value */ if (fp->parent != NULL) /* release parent reference */ fp->parent->refcnt--; @@ -243,6 +249,47 @@ firmware_unregister(const char *imagenam return err; } +static void +loadimage(void *arg, int npending) +{ + struct thread *td = curthread; + char *imagename = arg; + struct priv_fw *fp; + linker_file_t result; + int error; + + /* synchronize with the thread that dispatched us */ + mtx_lock(&firmware_mtx); + mtx_unlock(&firmware_mtx); + + if (td->td_proc->p_fd->fd_rdir == NULL) { + printf("%s: root not mounted yet, no way to load image\n", + imagename); + goto done; + } + error = linker_reference_module(imagename, NULL, &result); + if (error != 0) { + printf("%s: could not load firmware image, error %d\n", + imagename, error); + goto done; + } + + mtx_lock(&firmware_mtx); + fp = lookup(imagename, NULL); + if (fp == NULL || fp->file != NULL) { + mtx_unlock(&firmware_mtx); + if (fp == NULL) + printf("%s: firmware image loaded, " + "but did not register\n", imagename); + (void) linker_release_module(imagename, NULL, NULL); + goto done; + } + fp->file = result; /* record the module identity */ + mtx_unlock(&firmware_mtx); +done: + wakeup_one(imagename); /* we're done */ +} + /* * Lookup and potentially load the specified firmware image. * If the firmware is not found in the registry, try to load a kernel @@ -253,9 +300,9 @@ firmware_unregister(const char *imagenam const struct firmware * firmware_get(const char *imagename) { + struct task fwload_task; struct thread *td; struct priv_fw *fp; - linker_file_t result; mtx_lock(&firmware_mtx); fp = lookup(imagename, NULL); @@ -264,29 +311,34 @@ firmware_get(const char *imagename) /* * Image not present, try to load the module holding it. */ - mtx_unlock(&firmware_mtx); td = curthread; if (suser(td) != 0 || securelevel_gt(td->td_ucred, 0) != 0) { + mtx_unlock(&firmware_mtx); printf("%s: insufficient privileges to " "load firmware image %s\n", __func__, imagename); return NULL; } - (void) linker_reference_module(imagename, NULL, &result); + /* + * Defer load to a thread with known context. linker_reference_module + * may do filesystem i/o which requires root & current dirs, etc. + * Also we must not hold any mtx's over this call which is problematic. + */ + if (!cold) { + TASK_INIT(&fwload_task, 0, loadimage, __DECONST(void *, + imagename)); + taskqueue_enqueue(firmware_tq, &fwload_task); + msleep(__DECONST(void *, imagename), &firmware_mtx, 0, + "fwload", 0); + } /* - * After loading the module, see if the image is registered now. + * After attempting to load the module, see if the image is registered. */ - mtx_lock(&firmware_mtx); fp = lookup(imagename, NULL); if (fp == NULL) { mtx_unlock(&firmware_mtx); - printf("%s: failed to load firmware image %s\n", - __func__, imagename); - (void) linker_release_module(imagename, NULL, NULL); return NULL; } - fp->file = result; /* record the module identity */ - found: /* common exit point on success */ fp->refcnt++; mtx_unlock(&firmware_mtx); @@ -299,8 +351,8 @@ found: /* common exit point on succes * to release the resource, but the flag is only advisory. * * If this is the last reference to the firmware image, and this is an - * autoloaded module, wake up the firmware_task to figure out what to do - * with the associated module. + * autoloaded module, wake up the firmware_unload_task to figure out + * what to do with the associated module. */ void firmware_put(const struct firmware *p, int flags) @@ -313,12 +365,62 @@ firmware_put(const struct firmware *p, i if (flags & FIRMWARE_UNLOAD) fp->flags |= FW_UNLOAD; if (fp->file) - taskqueue_enqueue(taskqueue_thread, &firmware_task); + taskqueue_enqueue(firmware_tq, &firmware_unload_task); } mtx_unlock(&firmware_mtx); } /* + * Setup directory state for the firmware_tq thread so we can do i/o. + */ +static void +set_rootvnode(void *arg, int npending) +{ + struct thread *td = curthread; + struct proc *p = td->td_proc; + + FILEDESC_LOCK(p->p_fd); + if (p->p_fd->fd_cdir == NULL) { + p->p_fd->fd_cdir = rootvnode; + VREF(rootvnode); + } + if (p->p_fd->fd_rdir == NULL) { + p->p_fd->fd_rdir = rootvnode; + VREF(rootvnode); + } + FILEDESC_UNLOCK(p->p_fd); + + free(arg, M_TEMP); +} + +/* + * Event handler called on mounting of /; bounce a task + * into the task queue thread to setup it's directories. + */ +static void +firmware_mountroot(void *arg) +{ + struct task *setroot_task; + + setroot_task = malloc(sizeof(struct task), M_TEMP, M_NOWAIT); + if (setroot_task != NULL) { + TASK_INIT(setroot_task, 0, set_rootvnode, setroot_task); + taskqueue_enqueue(firmware_tq, setroot_task); + } else + printf("%s: no memory for task!\n", __func__); +} + +static eventhandler_tag mountroot_tag; +static void +mountroot_evh_init(void *ctx) +{ + mountroot_tag = EVENTHANDLER_REGISTER(mountroot, + firmware_mountroot, ctx, 0); +} +SYSINIT(mountroot_evh_init, SI_SUB_CONFIGURE, SI_ORDER_ANY, + mountroot_evh_init, NULL); + +/* * The body of the task in charge of unloading autoloaded modules * that are not needed anymore. * Images can be cross-linked so we may need to make multiple passes, @@ -382,11 +484,23 @@ static int firmware_modevent(module_t mod, int type, void *unused) { struct priv_fw *fp; - int i, err = EINVAL; + int i, err; switch (type) { case MOD_LOAD: - TASK_INIT(&firmware_task, 0, unloadentry, NULL); + TASK_INIT(&firmware_unload_task, 0, unloadentry, NULL); + firmware_tq = taskqueue_create("taskqueue_firmware", M_WAITOK, + taskqueue_thread_enqueue, &firmware_tq, NULL); + /* NB: use our own loop routine that sets up context */ + (void) taskqueue_start_threads(&firmware_tq, 1, PWAIT, + "firmware taskq"); + if (rootvnode != NULL) { + /* + * Root is already mounted so we won't get an event; + * simulate one here. + */ + firmware_mountroot(NULL); + } return 0; case MOD_UNLOAD: @@ -397,8 +511,9 @@ firmware_modevent(module_t mod, int type fp->flags |= FW_UNLOAD;; } mtx_unlock(&firmware_mtx); - taskqueue_enqueue(taskqueue_thread, &firmware_task); - taskqueue_drain(taskqueue_thread, &firmware_task); + taskqueue_enqueue(firmware_tq, &firmware_unload_task); + taskqueue_drain(firmware_tq, &firmware_unload_task); + err = 0; for (i = 0; i < FIRMWARE_MAX; i++) { fp = &firmware_table[i]; if (fp->fw.name != NULL) { @@ -408,6 +523,8 @@ firmware_modevent(module_t mod, int type err = EINVAL; } } + if (err == 0) + taskqueue_free(firmware_tq); return err; } return EINVAL; Modified: stable/6/sys/kern/vfs_mount.c ============================================================================== --- stable/6/sys/kern/vfs_mount.c Mon Oct 19 19:11:00 2009 (r198244) +++ stable/6/sys/kern/vfs_mount.c Mon Oct 19 19:14:04 2009 (r198245) @@ -1360,6 +1360,8 @@ set_rootvnode(struct thread *td) FILEDESC_UNLOCK(p->p_fd); VOP_UNLOCK(rootvnode, 0, td); + + EVENTHANDLER_INVOKE(mountroot); } /* Modified: stable/6/sys/sys/eventhandler.h ============================================================================== --- stable/6/sys/sys/eventhandler.h Mon Oct 19 19:11:00 2009 (r198244) +++ stable/6/sys/sys/eventhandler.h Mon Oct 19 19:14:04 2009 (r198245) @@ -156,6 +156,10 @@ typedef void (*vm_lowmem_handler_t)(void #define LOWMEM_PRI_DEFAULT EVENTHANDLER_PRI_FIRST EVENTHANDLER_DECLARE(vm_lowmem, vm_lowmem_handler_t); +/* Root mounted event */ +typedef void (*mountroot_handler_t)(void *); +EVENTHANDLER_DECLARE(mountroot, mountroot_handler_t); + /* * Process events * process_fork and exit handlers are called without Giant. From owner-svn-src-stable-6@FreeBSD.ORG Tue Oct 20 13:49:34 2009 Return-Path: Delivered-To: svn-src-stable-6@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 63C5D1065670; Tue, 20 Oct 2009 13:49:34 +0000 (UTC) (envelope-from ume@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 525908FC1A; Tue, 20 Oct 2009 13:49:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9KDnY1v068760; Tue, 20 Oct 2009 13:49:34 GMT (envelope-from ume@svn.freebsd.org) Received: (from ume@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9KDnYvC068758; Tue, 20 Oct 2009 13:49:34 GMT (envelope-from ume@svn.freebsd.org) Message-Id: <200910201349.n9KDnYvC068758@svn.freebsd.org> From: Hajimu UMEMOTO Date: Tue, 20 Oct 2009 13:49:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198286 - stable/6/bin/csh X-BeenThere: svn-src-stable-6@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 6-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Oct 2009 13:49:34 -0000 Author: ume Date: Tue Oct 20 13:49:34 2009 New Revision: 198286 URL: http://svn.freebsd.org/changeset/base/198286 Log: MFC r198189: Check error of dlfunc(3). Modified: stable/6/bin/csh/ (props changed) stable/6/bin/csh/iconv_stub.c Modified: stable/6/bin/csh/iconv_stub.c ============================================================================== --- stable/6/bin/csh/iconv_stub.c Tue Oct 20 13:47:05 2009 (r198285) +++ stable/6/bin/csh/iconv_stub.c Tue Oct 20 13:49:34 2009 (r198286) @@ -61,9 +61,20 @@ dl_iconv_open(const char *tocode, const if (iconvlib == NULL) return (iconv_t)-1; iconv_open = (iconv_open_t *)dlfunc(iconvlib, ICONV_OPEN); + if (iconv_open == NULL) + goto dlfunc_err; dl_iconv = (dl_iconv_t *)dlfunc(iconvlib, ICONV_ENGINE); + if (dl_iconv == NULL) + goto dlfunc_err; dl_iconv_close = (dl_iconv_close_t *)dlfunc(iconvlib, ICONV_CLOSE); + if (dl_iconv_close == NULL) + goto dlfunc_err; } return iconv_open(tocode, fromcode); + +dlfunc_err: + dlclose(iconvlib); + iconvlib = NULL; + return (iconv_t)-1; } From owner-svn-src-stable-6@FreeBSD.ORG Thu Oct 22 09:39:32 2009 Return-Path: Delivered-To: svn-src-stable-6@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8AD44106566C; Thu, 22 Oct 2009 09:39:32 +0000 (UTC) (envelope-from brueffer@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 78D518FC18; Thu, 22 Oct 2009 09:39:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9M9dWUM024773; Thu, 22 Oct 2009 09:39:32 GMT (envelope-from brueffer@svn.freebsd.org) Received: (from brueffer@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9M9dW1Z024771; Thu, 22 Oct 2009 09:39:32 GMT (envelope-from brueffer@svn.freebsd.org) Message-Id: <200910220939.n9M9dW1Z024771@svn.freebsd.org> From: Christian Brueffer Date: Thu, 22 Oct 2009 09:39:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198362 - stable/6/share/man/man4 X-BeenThere: svn-src-stable-6@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 6-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Oct 2009 09:39:32 -0000 Author: brueffer Date: Thu Oct 22 09:39:32 2009 New Revision: 198362 URL: http://svn.freebsd.org/changeset/base/198362 Log: MFC: r198232 Powercrypt and NetSec seem to be defunct (webpages point to link farms and a google search yields no alternative). Remove the links but keep the entries around for reference. Modified: stable/6/share/man/man4/ (props changed) stable/6/share/man/man4/hifn.4 Modified: stable/6/share/man/man4/hifn.4 ============================================================================== --- stable/6/share/man/man4/hifn.4 Thu Oct 22 08:38:27 2009 (r198361) +++ stable/6/share/man/man4/hifn.4 Thu Oct 22 09:39:32 2009 (r198362) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 1, 2006 +.Dd October 19, 2009 .Dt HIFN 4 .Os .Sh NAME @@ -87,17 +87,11 @@ Came as 128KB SRAM model, or 2MB DRAM mo .It Hifn 7751 Reference board with 512KB SRAM. .It PowerCrypt -See -.Pa http://www.powercrypt.com/ . Comes with 512KB SRAM. .It XL-Crypt -See -.Pa http://www.powercrypt.com/ . Only board based on 7811 (which is faster than 7751 and has a random number generator). .It NetSec 7751 -See -.Pa http://www.netsec.net/ . Supports the most IPsec sessions, with 1MB SRAM. .It Soekris Engineering vpn1201 and vpn1211 See From owner-svn-src-stable-6@FreeBSD.ORG Fri Oct 23 15:42:23 2009 Return-Path: Delivered-To: svn-src-stable-6@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9762C1065692; Fri, 23 Oct 2009 15:42:23 +0000 (UTC) (envelope-from philip@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 847178FC23; Fri, 23 Oct 2009 15:42:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9NFgN0G065459; Fri, 23 Oct 2009 15:42:23 GMT (envelope-from philip@svn.freebsd.org) Received: (from philip@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9NFgNkK065455; Fri, 23 Oct 2009 15:42:23 GMT (envelope-from philip@svn.freebsd.org) Message-Id: <200910231542.n9NFgNkK065455@svn.freebsd.org> From: Philip Paeps Date: Fri, 23 Oct 2009 15:42:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198412 - stable/6/sbin/dhclient X-BeenThere: svn-src-stable-6@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 6-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Oct 2009 15:42:23 -0000 Author: philip Date: Fri Oct 23 15:42:23 2009 New Revision: 198412 URL: http://svn.freebsd.org/changeset/base/198412 Log: MFC r198352 Make dhclient use bootpc (68) as the source port for unicast DHCPREQUEST packets instead of allowing the protocol stack to pick a random source port. This fixes the behaviour where dhclient would never transition from RENEWING to BOUND without going through REBINDING in networks which are paranoid about DHCP spoofing, such as most mainstream cable-broadband ISP networks. Obtained from: OpenBSD Reviewed by: brooks Approved by: re (kib) Modified: stable/6/sbin/dhclient/ (props changed) stable/6/sbin/dhclient/bpf.c stable/6/sbin/dhclient/dhcpd.h stable/6/sbin/dhclient/packet.c Modified: stable/6/sbin/dhclient/bpf.c ============================================================================== --- stable/6/sbin/dhclient/bpf.c Fri Oct 23 15:14:54 2009 (r198411) +++ stable/6/sbin/dhclient/bpf.c Fri Oct 23 15:42:23 2009 (r198412) @@ -90,11 +90,23 @@ if_register_bpf(struct interface_info *i void if_register_send(struct interface_info *info) { + int sock, on = 1; + /* * If we're using the bpf API for sending and receiving, we * don't need to register this interface twice. */ info->wfdesc = info->rfdesc; + + /* + * Use raw socket for unicast send. + */ + if ((sock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP)) == -1) + error("socket(SOCK_RAW): %m"); + if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, &on, + sizeof(on)) == -1) + error("setsockopt(IP_HDRINCL): %m"); + info->ufdesc = sock; } /* @@ -244,35 +256,32 @@ send_packet(struct interface_info *inter { unsigned char buf[256]; struct iovec iov[2]; + struct msghdr msg; int result, bufp = 0; - int sock; - - if (to->sin_addr.s_addr != INADDR_BROADCAST) { - note("SENDING DIRECT"); - /* We know who the server is, send the packet via - normal socket interface */ - - if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) >= 0) { - result = sendto (sock, (char *)raw, len, 0, - (struct sockaddr *)to, sizeof *to); - close(sock); - if (result > 0) - return result; - } - } /* Assemble the headers... */ - assemble_hw_header(interface, buf, &bufp, hto); + if (to->sin_addr.s_addr == INADDR_BROADCAST) + assemble_hw_header(interface, buf, &bufp, hto); assemble_udp_ip_header(buf, &bufp, from.s_addr, to->sin_addr.s_addr, to->sin_port, (unsigned char *)raw, len); - /* Fire it off */ iov[0].iov_base = (char *)buf; iov[0].iov_len = bufp; iov[1].iov_base = (char *)raw; iov[1].iov_len = len; - result = writev(interface->wfdesc, iov, 2); + /* Fire it off */ + if (to->sin_addr.s_addr == INADDR_BROADCAST) + result = writev(interface->wfdesc, iov, 2); + else { + memset(&msg, 0, sizeof(msg)); + msg.msg_name = (struct sockaddr *)to; + msg.msg_namelen = sizeof(*to); + msg.msg_iov = iov; + msg.msg_iovlen = 2; + result = sendmsg(interface->ufdesc, &msg, 0); + } + if (result < 0) warning("send_packet: %m"); return (result); Modified: stable/6/sbin/dhclient/dhcpd.h ============================================================================== --- stable/6/sbin/dhclient/dhcpd.h Fri Oct 23 15:14:54 2009 (r198411) +++ stable/6/sbin/dhclient/dhcpd.h Fri Oct 23 15:42:23 2009 (r198412) @@ -37,6 +37,8 @@ * Enterprises. To learn more about the Internet Software Consortium, * see ``http://www.vix.com/isc''. To learn more about Vixie * Enterprises, see ``http://www.vix.com''. + * + * $FreeBSD$ */ #include @@ -194,6 +196,7 @@ struct interface_info { char name[IFNAMSIZ]; int rfdesc; int wfdesc; + int ufdesc; unsigned char *rbuf; size_t rbuf_max; size_t rbuf_offset; Modified: stable/6/sbin/dhclient/packet.c ============================================================================== --- stable/6/sbin/dhclient/packet.c Fri Oct 23 15:14:54 2009 (r198411) +++ stable/6/sbin/dhclient/packet.c Fri Oct 23 15:42:23 2009 (r198412) @@ -135,6 +135,17 @@ assemble_udp_ip_header(unsigned char *bu ip.ip_dst.s_addr = to; ip.ip_sum = wrapsum(checksum((unsigned char *)&ip, sizeof(ip), 0)); + + /* + * While the BPF -- used for broadcasts -- expects a "true" IP header + * with all the bytes in network byte order, the raw socket interface + * which is used for unicasts expects the ip_len field to be in host + * byte order. In both cases, the checksum has to be correct, so this + * is as good a place as any to turn the bytes around again. + */ + if (to != INADDR_BROADCAST) + ip.ip_len = ntohs(ip.ip_len); + memcpy(&buf[*bufix], &ip, sizeof(ip)); *bufix += sizeof(ip); From owner-svn-src-stable-6@FreeBSD.ORG Sat Oct 24 18:38:25 2009 Return-Path: Delivered-To: svn-src-stable-6@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 05A0610656B8; Sat, 24 Oct 2009 18:38:25 +0000 (UTC) (envelope-from gallatin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E85D28FC15; Sat, 24 Oct 2009 18:38:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9OIcOpJ004610; Sat, 24 Oct 2009 18:38:24 GMT (envelope-from gallatin@svn.freebsd.org) Received: (from gallatin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9OIcO6X004608; Sat, 24 Oct 2009 18:38:24 GMT (envelope-from gallatin@svn.freebsd.org) Message-Id: <200910241838.n9OIcO6X004608@svn.freebsd.org> From: Andrew Gallatin Date: Sat, 24 Oct 2009 18:38:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198447 - stable/6/sys/modules/firmware X-BeenThere: svn-src-stable-6@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 6-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Oct 2009 18:38:25 -0000 Author: gallatin Date: Sat Oct 24 18:38:24 2009 New Revision: 198447 URL: http://svn.freebsd.org/changeset/base/198447 Log: Fix firmware module build when it is not built with the kernel (eg, make world when MODULES_WITH_WORLD is defined) Submitted by: Andre Albsmeier at siemens dot com Pointy hat to: gallatin Modified: stable/6/sys/modules/firmware/Makefile Modified: stable/6/sys/modules/firmware/Makefile ============================================================================== --- stable/6/sys/modules/firmware/Makefile Sat Oct 24 18:38:13 2009 (r198446) +++ stable/6/sys/modules/firmware/Makefile Sat Oct 24 18:38:24 2009 (r198447) @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../kern KMOD= firmware -SRCS= subr_firmware.c +SRCS= subr_firmware.c vnode_if.h .include