From owner-freebsd-net@FreeBSD.ORG Mon Jan 17 17:47:48 2005 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3911D16A4EB for ; Mon, 17 Jan 2005 17:47:48 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.192]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5F4DE43D31 for ; Mon, 17 Jan 2005 17:47:46 +0000 (GMT) (envelope-from jsimola@gmail.com) Received: by wproxy.gmail.com with SMTP id 58so105498wri for ; Mon, 17 Jan 2005 09:47:46 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=ZgZtm1R6BfouwT9nHSRzSKZhyq9zNO8CcG3192C3UXc6N3R0RsDBkU9PzNNg0Yk6K2CSu3UhV4N3pCzQRK5XqRnZIIUtGAQwYTZ3oVMaoQVMIk6YdAqJKrqtCG+3KLyEY0suRK0lTcD5I6T/OCOZoa9cnuoJtGUdSVOzV5IxstU= Received: by 10.54.6.43 with SMTP id 43mr262460wrf; Mon, 17 Jan 2005 09:47:45 -0800 (PST) Received: by 10.54.39.34 with HTTP; Mon, 17 Jan 2005 09:47:45 -0800 (PST) Message-ID: <8eea040805011709477418156d@mail.gmail.com> Date: Mon, 17 Jan 2005 09:47:45 -0800 From: Jon Simola To: freebsd-net@freebsd.org In-Reply-To: <8eea040805010512321bf5b953@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <8eea040805010512321bf5b953@mail.gmail.com> Subject: ALTQ patch for if_vlan.c X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: jon@abccomm.com List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Jan 2005 17:47:48 -0000 (CC's to jsimola@gmail.com, I'm not subscribed to the -net list) I whipped up this against 5.3-STABLE #1: Wed Dec 22 17:11:02 PST 2004 I've had this patch in operation for a week on my router that serves 500 DSL customers and I've had no problems with it. On the -stable list it was mentioned that the vlan pseudo-device probably isn't the best place to be doing this, however I haven't been able to figure out any other way to perform traffic shaping on vlan interfaces. --- sys/net/if_vlan.c.orig Wed Jan 5 12:25:19 2005 +++ sys/net/if_vlan.c Wed Jan 5 12:53:45 2005 @@ -379,7 +379,10 @@ ifp->if_init = vlan_ifinit; ifp->if_start = vlan_start; ifp->if_ioctl = vlan_ioctl; - ifp->if_snd.ifq_maxlen = ifqmaxlen; + IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); + ifp->if_snd.ifq_drv_maxlen = 0; + IFQ_SET_READY(&ifp->if_snd); + ether_ifattach(ifp, ifv->ifv_ac.ac_enaddr); /* Now undo some of the damage... */ ifp->if_baudrate = 0; @@ -423,11 +426,15 @@ { int unit; struct ifvlan *ifv = ifp->if_softc; + int s; unit = ifp->if_dunit; VLAN_LOCK(); LIST_REMOVE(ifv, ifv_list); + s = splimp(); + IFQ_PURGE(&ifp->if_snd); + splx(s); vlan_unconfig(ifp); VLAN_UNLOCK(); @@ -458,12 +465,22 @@ struct mbuf *m; int error; + if (ALTQ_IS_ENABLED(&ifp->if_snd)) { + IFQ_LOCK(&ifp->if_snd); + IFQ_POLL_NOLOCK(&ifp->if_snd, m); + if (m == NULL ) { + IFQ_UNLOCK(&ifp->if_snd); + return; + } + IFQ_UNLOCK(&ifp->if_snd); + } + ifv = ifp->if_softc; p = ifv->ifv_p; ifp->if_flags |= IFF_OACTIVE; for (;;) { - IF_DEQUEUE(&ifp->if_snd, m); + IFQ_DEQUEUE(&ifp->if_snd, m); if (m == 0) break; BPF_MTAP(ifp, m); -- Jon Simola