From owner-svn-src-user@FreeBSD.ORG Sun Jan 4 07:33:10 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B83A3106564A; Sun, 4 Jan 2009 07:33:10 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A88708FC19; Sun, 4 Jan 2009 07:33:10 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n047XAfU049378; Sun, 4 Jan 2009 07:33:10 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n047XAGS049377; Sun, 4 Jan 2009 07:33:10 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901040733.n047XAGS049377@svn.freebsd.org> From: Kip Macy Date: Sun, 4 Jan 2009 07:33:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186734 - user/kmacy/HEAD_fast_net/sys/amd64/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Jan 2009 07:33:11 -0000 Author: kmacy Date: Sun Jan 4 07:33:10 2009 New Revision: 186734 URL: http://svn.freebsd.org/changeset/base/186734 Log: remove USB from kernel Modified: user/kmacy/HEAD_fast_net/sys/amd64/conf/PERFTEST Modified: user/kmacy/HEAD_fast_net/sys/amd64/conf/PERFTEST ============================================================================== --- user/kmacy/HEAD_fast_net/sys/amd64/conf/PERFTEST Sun Jan 4 07:32:06 2009 (r186733) +++ user/kmacy/HEAD_fast_net/sys/amd64/conf/PERFTEST Sun Jan 4 07:33:10 2009 (r186734) @@ -275,41 +275,6 @@ device firmware # firmware assist modul # Note that 'bpf' is required for DHCP. device bpf # Berkeley packet filter -# USB support -device uhci # UHCI PCI->USB interface -device ohci # OHCI PCI->USB interface -device ehci # EHCI PCI->USB interface (USB 2.0) -device usb # USB Bus (required) -#device udbp # USB Double Bulk Pipe devices -device ugen # Generic -device uhid # "Human Interface Devices" -device ukbd # Keyboard -device ulpt # Printer -device umass # Disks/Mass storage - Requires scbus and da -device ums # Mouse -device ural # Ralink Technology RT2500USB wireless NICs -device rum # Ralink Technology RT2501USB wireless NICs -device urio # Diamond Rio 500 MP3 player -device uscanner # Scanners -# USB Serial devices -device ucom # Generic com ttys -device uark # Technologies ARK3116 based serial adapters -device ubsa # Belkin F5U103 and compatible serial adapters -device uftdi # For FTDI usb serial adapters -device uipaq # Some WinCE based devices -device uplcom # Prolific PL-2303 serial adapters -device uslcom # SI Labs CP2101/CP2102 serial adapters -device uvisor # Visor and Palm devices -device uvscom # USB serial support for DDI pocket's PHS -# USB Ethernet, requires miibus -device aue # ADMtek USB Ethernet -device axe # ASIX Electronics USB Ethernet -device cdce # Generic USB over Ethernet -device cue # CATC USB Ethernet -device kue # Kawasaki LSI USB Ethernet -device rue # RealTek RTL8150 USB Ethernet -device udav # Davicom DM9601E USB - # FireWire support device firewire # FireWire bus code device sbp # SCSI over FireWire (Requires scbus and da) From owner-svn-src-user@FreeBSD.ORG Sun Jan 4 17:27:12 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 61464106566B; Sun, 4 Jan 2009 17:27:12 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4EF0C8FC1C; Sun, 4 Jan 2009 17:27:12 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n04HRCm5063871; Sun, 4 Jan 2009 17:27:12 GMT (envelope-from piso@svn.freebsd.org) Received: (from piso@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n04HRCTW063867; Sun, 4 Jan 2009 17:27:12 GMT (envelope-from piso@svn.freebsd.org) Message-Id: <200901041727.n04HRCTW063867@svn.freebsd.org> From: Paolo Pisati Date: Sun, 4 Jan 2009 17:27:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186742 - user/piso/sys/netinet/libalias X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Jan 2009 17:27:12 -0000 Author: piso Date: Sun Jan 4 17:27:11 2009 New Revision: 186742 URL: http://svn.freebsd.org/changeset/base/186742 Log: -protect kernel code only with _KERNEL -move FindSctpRedirectAddress to alias_local.h together with all the others Find* functions -style Modified: user/piso/sys/netinet/libalias/alias.h user/piso/sys/netinet/libalias/alias_db.c user/piso/sys/netinet/libalias/alias_local.h user/piso/sys/netinet/libalias/alias_sctp.c Modified: user/piso/sys/netinet/libalias/alias.h ============================================================================== --- user/piso/sys/netinet/libalias/alias.h Sun Jan 4 17:26:59 2009 (r186741) +++ user/piso/sys/netinet/libalias/alias.h Sun Jan 4 17:27:11 2009 (r186742) @@ -36,13 +36,6 @@ * distribution. */ -/** - * Modifications to add sctp functionality by David A. Hayes - * $Id: alias.h 122 2008-06-25 06:50:47Z dhayes $ - * All are inclosed in #ifdef _ALIAS_SCTP - * - */ - #ifndef _ALIAS_H_ #define _ALIAS_H_ @@ -52,11 +45,6 @@ #define LIBALIAS_BUF_SIZE 128 #ifdef _KERNEL - -#ifndef _ALIAS_SCTP -#define _ALIAS_SCTP //if ALIAS_SCTP code is to be included -#endif - /* * The kernel version of libalias does not support these features. */ Modified: user/piso/sys/netinet/libalias/alias_db.c ============================================================================== --- user/piso/sys/netinet/libalias/alias_db.c Sun Jan 4 17:26:59 2009 (r186741) +++ user/piso/sys/netinet/libalias/alias_db.c Sun Jan 4 17:27:11 2009 (r186742) @@ -141,12 +141,6 @@ __FBSDID("$FreeBSD$"); See HISTORY file for additional revisions. */ -/** - * Modifications to add sctp functionality by David A. Hayes - * $Id: alias_db.c 177 2008-07-14 04:33:47Z dhayes $ - * All are inclosed in #ifdef _ALIAS_SCTP - * - */ #ifdef _KERNEL @@ -173,9 +167,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef _ALIAS_SCTP -#include -#endif #include #else #include "alias.h" @@ -383,7 +374,6 @@ static moduledata_t alias_mod = { }; DECLARE_MODULE(alias, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND); - #endif /* Internal utility routines (used only in alias_db.c) @@ -421,10 +411,6 @@ static void ClearFWHole(struct alias_lin static void ShowAliasStats(struct libalias *); static int InitPacketAliasLog(struct libalias *); static void UninitPacketAliasLog(struct libalias *); -#ifdef _ALIAS_SCTP -struct in_addr FindSctpRedirectAddress(struct libalias *la, struct sctp_nat_msg *sm); -void SctpShowAliasStats(struct libalias *la); -#endif static u_int StartPointIn(struct in_addr alias_addr, @@ -504,25 +490,17 @@ ShowAliasStats(struct libalias *la) /* Used for debugging */ if (la->logDesc) { int tot = la->icmpLinkCount + la->udpLinkCount + -#ifdef _ALIAS_SCTP (la->sctpLinkCount>>1) + /* sctp counts half associations */ -#endif la->tcpLinkCount + la->pptpLinkCount + la->protoLinkCount + la->fragmentIdLinkCount + la->fragmentPtrLinkCount; AliasLog(la->logDesc, -#ifdef _ALIAS_SCTP "icmp=%u, udp=%u, tcp=%u, sctp=%u, pptp=%u, proto=%u, frag_id=%u frag_ptr=%u / tot=%u", -#else - "icmp=%u, udp=%u, tcp=%u, pptp=%u, proto=%u, frag_id=%u frag_ptr=%u / tot=%u", -#endif la->icmpLinkCount, la->udpLinkCount, la->tcpLinkCount, -#ifdef _ALIAS_SCTP la->sctpLinkCount>>1, /* sctp counts half associations */ -#endif la->pptpLinkCount, la->protoLinkCount, la->fragmentIdLinkCount, @@ -533,13 +511,6 @@ ShowAliasStats(struct libalias *la) } } -#ifdef _ALIAS_SCTP -void SctpShowAliasStats(struct libalias *la) -{ - ShowAliasStats(la); -} -#endif - /* Internal routines for finding, deleting and adding links Port Allocation: @@ -1003,10 +974,6 @@ AddLink(struct libalias *la, struct in_a case LINK_TCP: lnk->expire_time = TCP_EXPIRE_INITIAL; break; -#ifdef _ALIAS_SCTP - case LINK_SCTP: /* treat like LINK_ADDR */ - break; -#endif case LINK_PPTP: lnk->flags |= LINK_PERMANENT; /* no timeout. */ break; @@ -1067,10 +1034,6 @@ AddLink(struct libalias *la, struct in_a return (NULL); } break; -#ifdef _ALIAS_SCTP - case LINK_SCTP: /* treat like LINK_ADDR */ - break; -#endif case LINK_PPTP: la->pptpLinkCount++; break; @@ -1317,17 +1280,17 @@ _FindLinkIn(struct libalias *la, struct src_addr = lnk->src_addr; src_port = lnk->src_port; } -#ifdef _ALIAS_SCTP - if(link_type == LINK_SCTP) { +#ifdef _KERNEL + if (link_type == LINK_SCTP) { lnk->src_addr = src_addr; lnk->src_port = src_port; return(lnk); } #endif - lnk = ReLink(lnk, - src_addr, dst_addr, alias_addr, - src_port, dst_port, alias_port, - link_type); + lnk = ReLink(lnk, + src_addr, dst_addr, alias_addr, + src_port, dst_port, alias_port, + link_type); } return (lnk); } @@ -2323,7 +2286,7 @@ LibAliasRedirectPort(struct libalias *la case IPPROTO_TCP: link_type = LINK_TCP; break; -#ifdef _ALIAS_SCTP +#ifdef _KERNEL case IPPROTO_SCTP: link_type = LINK_SCTP; break; @@ -2547,8 +2510,8 @@ LibAliasInit(struct libalias *la) LIST_INIT(&la->linkTableOut[i]); for (i = 0; i < LINK_TABLE_IN_SIZE; i++) LIST_INIT(&la->linkTableIn[i]); -#ifdef _ALIAS_SCTP - AliasSctpInit(la);//*** +#ifdef _KERNEL + AliasSctpInit(la); #endif LIBALIAS_LOCK_INIT(la); LIBALIAS_LOCK(la); @@ -2557,7 +2520,7 @@ LibAliasInit(struct libalias *la) la->deleteAllLinks = 1; CleanupAliasData(la); la->deleteAllLinks = 0; -#ifdef _ALIAS_SCTP +#ifdef _KERNEL AliasSctpTerm(la); AliasSctpInit(la); #endif @@ -2569,9 +2532,7 @@ LibAliasInit(struct libalias *la) la->icmpLinkCount = 0; la->udpLinkCount = 0; la->tcpLinkCount = 0; -#ifdef _ALIAS_SCTP la->sctpLinkCount = 0; -#endif la->pptpLinkCount = 0; la->protoLinkCount = 0; la->fragmentIdLinkCount = 0; @@ -2600,7 +2561,7 @@ LibAliasUninit(struct libalias *la) { LIBALIAS_LOCK(la); -#ifdef _ALIAS_SCTP +#ifdef _KERNEL AliasSctpTerm(la); #endif la->deleteAllLinks = 1; @@ -2943,7 +2904,7 @@ LibAliasSetSkinnyPort(struct libalias *l la->skinnyPort = port; LIBALIAS_UNLOCK(la); } -#ifdef _ALIAS_SCTP + /** * @brief Find the address to redirect incoming packets * @@ -2978,4 +2939,3 @@ FindSctpRedirectAddress(struct libalias return(redir); /* address redirect */ } } -#endif Modified: user/piso/sys/netinet/libalias/alias_local.h ============================================================================== --- user/piso/sys/netinet/libalias/alias_local.h Sun Jan 4 17:26:59 2009 (r186741) +++ user/piso/sys/netinet/libalias/alias_local.h Sun Jan 4 17:27:11 2009 (r186742) @@ -42,12 +42,6 @@ * * */ -/** - * Modifications to add sctp functionality by David A. Hayes - * $Id: alias_local.h 122 2008-06-25 06:50:47Z dhayes $ - * All are inclosed in #ifdef _ALIAS_SCTP - * - */ #ifndef _ALIAS_LOCAL_H_ #define _ALIAS_LOCAL_H_ @@ -56,16 +50,6 @@ #include #ifdef _KERNEL -/* if alias_sctp is not required, #define _ALIAS_SCTP should be commented out */ -#ifndef _ALIAS_SCTP -#define _ALIAS_SCTP -#endif -#ifdef _ALIAS_SCTP -#include -#endif -#endif - -#ifdef _KERNEL #include #include #include @@ -73,6 +57,10 @@ /* XXX: LibAliasSetTarget() uses this constant. */ #define INADDR_NONE 0xffffffff + +#include +#else +#include "alias_sctp.h" #endif /* Sizes of input and output link tables */ @@ -163,33 +151,29 @@ struct libalias { struct in_addr true_addr; /* in network byte order. */ u_short true_port; /* in host byte order. */ - /* - * - *alias_sctp code - */ -#ifdef _ALIAS_SCTP - /*counts associations that have progressed to UP and not yet removed */ - int sctpLinkCount; - /*Timing queue for keeping track of association timeouts */ - struct sctp_nat_timer sctpNatTimer; - - /* Size of hash table used in this instance*/ - u_int sctpNatTableSize; -/** - * @brief Local look up table - * - * lookup table of sctp_nat_assoc sorted by l_vtag/l_port - */ - LIST_HEAD(sctpNatTableL, sctp_nat_assoc) *sctpTableLocal; -/** - * @brief Global look up table - * - * lookup table of sctp_nat_assoc sorted by g_vtag/g_port - */ - LIST_HEAD(sctpNatTableG, sctp_nat_assoc) *sctpTableGlobal; -#endif + /* + * sctp code support + */ + + /* counts associations that have progressed to UP and not yet removed */ + int sctpLinkCount; #ifdef _KERNEL + /* timing queue for keeping track of association timeouts */ + struct sctp_nat_timer sctpNatTimer; + + /* size of hash table used in this instance */ + u_int sctpNatTableSize; + +/* + * local look up table sorted by l_vtag/l_port + */ + LIST_HEAD(sctpNatTableL, sctp_nat_assoc) *sctpTableLocal; +/* + * global look up table sorted by g_vtag/g_port + */ + LIST_HEAD(sctpNatTableG, sctp_nat_assoc) *sctpTableGlobal; + /* * avoid races in libalias: every public function has to use it. */ @@ -240,21 +224,13 @@ struct libalias { /* Prototypes */ - /* - * - *alias_sctp code - */ -#ifdef _ALIAS_SCTP /* * SctpFunction prototypes * */ void AliasSctpInit(struct libalias *la); void AliasSctpTerm(struct libalias *la); - int SctpAlias(struct libalias *la, struct ip *ip, int direction); -//int SctpAliasOut(struct libalias *la, struct ip *ip); -#endif /* * We do not calculate TCP checksums when libalias is a kernel @@ -322,6 +298,8 @@ struct in_addr FindOriginalAddress(struct libalias *la, struct in_addr _alias_addr); struct in_addr FindAliasAddress(struct libalias *la, struct in_addr _original_addr); +struct in_addr +FindSctpRedirectAddress(struct libalias *la, struct sctp_nat_msg *sm); /* External data access/modification */ int Modified: user/piso/sys/netinet/libalias/alias_sctp.c ============================================================================== --- user/piso/sys/netinet/libalias/alias_sctp.c Sun Jan 4 17:26:59 2009 (r186741) +++ user/piso/sys/netinet/libalias/alias_sctp.c Sun Jan 4 17:27:11 2009 (r186742) @@ -189,22 +189,6 @@ static void SctpAliasLog(const char *for */ void SctpShowAliasStats(struct libalias *la); -/** @ingroup external - * @brief Find the address to redirect incoming packets - * - * This function is defined in alias_db.c, since it calls static functions in - * this file - * - * Given a destination port for incoming packets to the NAT, discover what - * (if any) internal IP address this packet should be re-directed to - * - * @param la Pointer to the libalias instance - * @param sm Pointer to the incoming message - * - * @return Address to redirect an incoming INIT to - */ -struct in_addr FindSctpRedirectAddress(struct libalias *la, struct sctp_nat_msg *sm); - #ifdef _KERNEL MALLOC_DEFINE(M_SCTPNAT, "sctpnat", "sctp nat dbs"); From owner-svn-src-user@FreeBSD.ORG Mon Jan 5 10:40:20 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 833AD106566C; Mon, 5 Jan 2009 10:40:20 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 724428FC13; Mon, 5 Jan 2009 10:40:20 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n05AeKVZ093659; Mon, 5 Jan 2009 10:40:20 GMT (envelope-from dfr@svn.freebsd.org) Received: (from dfr@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n05AeKmv093658; Mon, 5 Jan 2009 10:40:20 GMT (envelope-from dfr@svn.freebsd.org) Message-Id: <200901051040.n05AeKmv093658@svn.freebsd.org> From: Doug Rabson Date: Mon, 5 Jan 2009 10:40:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186765 - user/dfr/xenhvm/6/sys/dev/xen/blkfront X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2009 10:40:20 -0000 Author: dfr Date: Mon Jan 5 10:40:19 2009 New Revision: 186765 URL: http://svn.freebsd.org/changeset/base/186765 Log: Don't crash on resume if there is a blkfront instance which failed to initialise before the suspend. This happens in HVM mode for DVD devices which are handled by the emulator, not blkfront. Modified: user/dfr/xenhvm/6/sys/dev/xen/blkfront/blkfront.c Modified: user/dfr/xenhvm/6/sys/dev/xen/blkfront/blkfront.c ============================================================================== --- user/dfr/xenhvm/6/sys/dev/xen/blkfront/blkfront.c Mon Jan 5 08:56:45 2009 (r186764) +++ user/dfr/xenhvm/6/sys/dev/xen/blkfront/blkfront.c Mon Jan 5 10:40:19 2009 (r186765) @@ -1031,6 +1031,9 @@ blkif_recover(struct blkfront_info *info blkif_request_t *req; struct blk_shadow *copy; + if (!info->sc) + return; + /* Stage 1: Make a safe copy of the shadow state. */ copy = (struct blk_shadow *)malloc(sizeof(info->shadow), M_DEVBUF, M_NOWAIT|M_ZERO); memcpy(copy, info->shadow, sizeof(info->shadow)); From owner-svn-src-user@FreeBSD.ORG Mon Jan 5 10:41:55 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F15B106564A; Mon, 5 Jan 2009 10:41:55 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0DDD78FC1E; Mon, 5 Jan 2009 10:41:55 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n05AfsmN093722; Mon, 5 Jan 2009 10:41:54 GMT (envelope-from dfr@svn.freebsd.org) Received: (from dfr@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n05Afsup093721; Mon, 5 Jan 2009 10:41:54 GMT (envelope-from dfr@svn.freebsd.org) Message-Id: <200901051041.n05Afsup093721@svn.freebsd.org> From: Doug Rabson Date: Mon, 5 Jan 2009 10:41:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186766 - user/dfr/xenhvm/6/sys/dev/xen/xenpci X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2009 10:41:55 -0000 Author: dfr Date: Mon Jan 5 10:41:54 2009 New Revision: 186766 URL: http://svn.freebsd.org/changeset/base/186766 Log: Tidy this up and remove all the #if 0 dead code. Add a suitable copyright. Modified: user/dfr/xenhvm/6/sys/dev/xen/xenpci/machine_reboot.c Modified: user/dfr/xenhvm/6/sys/dev/xen/xenpci/machine_reboot.c ============================================================================== --- user/dfr/xenhvm/6/sys/dev/xen/xenpci/machine_reboot.c Mon Jan 5 10:40:19 2009 (r186765) +++ user/dfr/xenhvm/6/sys/dev/xen/xenpci/machine_reboot.c Mon Jan 5 10:41:54 2009 (r186766) @@ -1,125 +1,79 @@ +/*- + * Copyright (c) 2008 Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #include __FBSDID("$FreeBSD$"); #include -#include #include -#include #include -#include -#include -#include #include -#include #include -#include #include #include -#include -#include #include -struct ap_suspend_info { - int do_spin; - atomic_t nr_spinning; -}; - -#ifdef CONFIG_SMP - -/* - * Spinning prevents, for example, APs touching grant table entries while - * the shared grant table is not mapped into the address space imemdiately - * after resume. - */ -static void ap_suspend(void *_info) -{ - struct ap_suspend_info *info = _info; - - BUG_ON(!irqs_disabled()); - - atomic_inc(&info->nr_spinning); - mb(); - - while (info->do_spin) - cpu_relax(); - - mb(); - atomic_dec(&info->nr_spinning); -} - -#define initiate_ap_suspend(i) smp_call_function(ap_suspend, i, 0, 0) - -#else /* !defined(CONFIG_SMP) */ - -#define initiate_ap_suspend(i) 0 - -#endif - -static int bp_suspend(void) -{ - int suspend_cancelled; - - suspend_cancelled = HYPERVISOR_suspend(0); - if (!suspend_cancelled) - xenpci_resume(); - - return suspend_cancelled; -} - void xen_suspend() { int suspend_cancelled; - //struct ap_suspend_info info; if (DEVICE_SUSPEND(root_bus)) { printf("xen_suspend: device_suspend failed\n"); return; } + /* + * Make sure we don't change cpus or switch to some other + * thread. for the duration. + */ critical_enter(); - /* Prevent any races with evtchn_interrupt() handler. */ + /* + * Prevent any races with evtchn_interrupt() handler. + */ irq_suspend(); - -#if 0 - info.do_spin = 1; - atomic_set(&info.nr_spinning, 0); - smp_mb(); - - nr_cpus = num_online_cpus() - 1; - - err = initiate_ap_suspend(&info); - if (err < 0) { - critical_exit(); - //xenbus_suspend_cancel(); - return err; - } - - while (atomic_read(&info.nr_spinning) != nr_cpus) - cpu_relax(); -#endif - disable_intr(); - suspend_cancelled = bp_suspend(); - //resume_notifier(suspend_cancelled); - enable_intr(); -#if 0 - smp_mb(); - info.do_spin = 0; - while (atomic_read(&info.nr_spinning) != 0) - cpu_relax(); -#endif + suspend_cancelled = HYPERVISOR_suspend(0); + if (!suspend_cancelled) + xenpci_resume(); + /* + * Re-enable interrupts and put the scheduler back to normal. + */ + enable_intr(); critical_exit(); + /* + * FreeBSD really needs to add DEVICE_SUSPEND_CANCEL or + * similar. + */ if (!suspend_cancelled) DEVICE_RESUME(root_bus); -#if 0 - else - xenbus_suspend_cancel(); -#endif } From owner-svn-src-user@FreeBSD.ORG Mon Jan 5 10:43:49 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C055106564A; Mon, 5 Jan 2009 10:43:49 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2A5468FC08; Mon, 5 Jan 2009 10:43:49 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n05AhnW1093791; Mon, 5 Jan 2009 10:43:49 GMT (envelope-from dfr@svn.freebsd.org) Received: (from dfr@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n05Ahnij093789; Mon, 5 Jan 2009 10:43:49 GMT (envelope-from dfr@svn.freebsd.org) Message-Id: <200901051043.n05Ahnij093789@svn.freebsd.org> From: Doug Rabson Date: Mon, 5 Jan 2009 10:43:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186767 - user/dfr/xenhvm/6/sys/dev/xen/xenpci X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2009 10:43:49 -0000 Author: dfr Date: Mon Jan 5 10:43:48 2009 New Revision: 186767 URL: http://svn.freebsd.org/changeset/base/186767 Log: Tidy this up a lot and improve the comments somewhat. Modified: user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpci.c user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpcivar.h Modified: user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpci.c ============================================================================== --- user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpci.c Mon Jan 5 10:41:54 2009 (r186766) +++ user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpci.c Mon Jan 5 10:43:48 2009 (r186767) @@ -1,5 +1,5 @@ /* - * Copyright (c) [year] [your name] + * Copyright (c) 2008 Citrix Systems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,101 +68,12 @@ shared_info_t *HYPERVISOR_shared_info; static vm_paddr_t shared_info_pa; /* - * The softc is automatically allocated by the parent bus using the - * size specified in the driver_t declaration below. + * This is used to find our platform device instance. */ -#define DEVICE2SOFTC(dev) ((struct xenpci_softc *) device_get_softc(dev)) - -/* Function prototypes (these should all be static). */ -static int xenpci_deallocate_resources(device_t device); -static int xenpci_allocate_resources(device_t device); -static int xenpci_attach(device_t device, struct xenpci_softc *scp); -static int xenpci_detach(device_t device, struct xenpci_softc *scp); - -static int xenpci_alloc_space_int(struct xenpci_softc *scp, size_t sz, - u_long *pa); - static devclass_t xenpci_devclass; -static int xenpci_pci_probe(device_t); -static int xenpci_pci_attach(device_t); -static int xenpci_pci_detach(device_t); -static int xenpci_pci_resume(device_t); - -static device_method_t xenpci_pci_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, xenpci_pci_probe), - DEVMETHOD(device_attach, xenpci_pci_attach), - DEVMETHOD(device_detach, xenpci_pci_detach), - DEVMETHOD(device_resume, xenpci_pci_resume), - - /* Bus interface */ - DEVMETHOD(bus_add_child, bus_generic_add_child), - - { 0, 0 } -}; - -static driver_t xenpci_pci_driver = { - "xenpci", - xenpci_pci_methods, - sizeof(struct xenpci_softc), -}; - -DRIVER_MODULE(xenpci, pci, xenpci_pci_driver, xenpci_devclass, 0, 0); - -static struct _pcsid -{ - u_int32_t type; - const char *desc; -} pci_ids[] = { - { 0x00015853, "Xen Platform Device" }, - { 0x00000000, NULL } -}; - -static int -xenpci_pci_probe (device_t device) -{ - u_int32_t type = pci_get_devid(device); - struct _pcsid *ep = pci_ids; - - while (ep->type && ep->type != type) - ++ep; - if (ep->desc) { - device_set_desc(device, ep->desc); - return (bus_generic_probe(device)); - } else - return (ENXIO); -} - -static int -xenpci_pci_attach(device_t device) -{ - int error; - struct xenpci_softc *scp = DEVICE2SOFTC(device); - - error = xenpci_attach(device, scp); - if (error) - xenpci_pci_detach(device); - return (error); -} - -static int -xenpci_pci_detach (device_t device) -{ - struct xenpci_softc *scp = DEVICE2SOFTC(device); - - return (xenpci_detach(device, scp)); -} - -static int -xenpci_pci_resume(device_t device) -{ - - return (bus_generic_resume(device)); -} - /* - * Common Attachment sub-functions + * Return the CPUID base address for Xen functions. */ static uint32_t xenpci_cpuid_base(void) @@ -178,21 +89,24 @@ xenpci_cpuid_base(void) return (0); } +/* + * Allocate and fill in the hypcall page. + */ static int -xenpci_init_hypercall_stubs(device_t device, struct xenpci_softc * scp) +xenpci_init_hypercall_stubs(device_t dev, struct xenpci_softc * scp) { uint32_t base, regs[4]; int i; base = xenpci_cpuid_base(); if (!base) { - device_printf(device, "Xen platform device but not Xen VMM\n"); + device_printf(dev, "Xen platform device but not Xen VMM\n"); return (EINVAL); } if (bootverbose) { do_cpuid(base + 1, regs); - device_printf(device, "Xen version %d.%d.\n", + device_printf(dev, "Xen version %d.%d.\n", regs[0] >> 16, regs[0] & 0xffff); } @@ -210,8 +124,11 @@ xenpci_init_hypercall_stubs(device_t dev return (0); } +/* + * After a resume, re-initialise the hypercall page. + */ static void -xenpci_resume_hypercall_stubs(device_t device, struct xenpci_softc * scp) +xenpci_resume_hypercall_stubs(device_t dev, struct xenpci_softc * scp) { uint32_t base, regs[4]; int i; @@ -224,19 +141,22 @@ xenpci_resume_hypercall_stubs(device_t d } } +/* + * Tell the hypervisor how to contact us for event channel callbacks. + */ static void -xenpci_set_callback(device_t device) +xenpci_set_callback(device_t dev) { int irq; uint64_t callback; struct xen_hvm_param xhp; - irq = pci_get_irq(device); + irq = pci_get_irq(dev); if (irq < 16) { callback = irq; } else { - callback = (pci_get_intpin(device) - 1) & 3; - callback |= pci_get_slot(device) << 11; + callback = (pci_get_intpin(dev) - 1) & 3; + callback |= pci_get_slot(dev) << 11; callback |= 1ull << 56; } @@ -247,135 +167,62 @@ xenpci_set_callback(device_t device) panic("Can't set evtchn callback"); } -static int -xenpci_attach(device_t device, struct xenpci_softc * scp) -{ - struct xen_add_to_physmap xatp; - vm_offset_t shared_va; - - if (xenpci_allocate_resources(device)) - goto errexit; - - scp->phys_next = rman_get_start(scp->res_memory); - - if (xenpci_init_hypercall_stubs(device, scp)) - goto errexit; - - setup_xen_features(); - - xenpci_alloc_space_int(scp, PAGE_SIZE, &shared_info_pa); - - xatp.domid = DOMID_SELF; - xatp.idx = 0; - xatp.space = XENMAPSPACE_shared_info; - xatp.gpfn = shared_info_pa >> PAGE_SHIFT; - if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp)) - panic("HYPERVISOR_memory_op failed"); - - shared_va = kmem_alloc_nofault(kernel_map, PAGE_SIZE); - pmap_kenter(shared_va, shared_info_pa); - HYPERVISOR_shared_info = (void *) shared_va; - - /* - * Hook the irq up to evtchn - */ - xenpci_irq_init(device, scp); - xenpci_set_callback(device); - - return (bus_generic_attach(device)); - -errexit: - /* - * Undo anything we may have done. - */ - xenpci_detach(device, scp); - return (ENXIO); -} +/* + * Deallocate anything allocated by xenpci_allocate_resources. + */ static int -xenpci_detach(device_t device, struct xenpci_softc *scp) +xenpci_deallocate_resources(device_t dev) { - device_t parent = device_get_parent(device); + struct xenpci_softc *scp = device_get_softc(dev); - /* - * Take our interrupt handler out of the list of handlers - * that can handle this irq. - */ - if (scp->intr_cookie != NULL) { - if (BUS_TEARDOWN_INTR(parent, device, - scp->res_irq, scp->intr_cookie) != 0) - printf("intr teardown failed.. continuing\n"); - scp->intr_cookie = NULL; + if (scp->res_irq != 0) { + bus_deactivate_resource(dev, SYS_RES_IRQ, + scp->rid_irq, scp->res_irq); + bus_release_resource(dev, SYS_RES_IRQ, + scp->rid_irq, scp->res_irq); + scp->res_irq = 0; + } + if (scp->res_memory != 0) { + bus_deactivate_resource(dev, SYS_RES_MEMORY, + scp->rid_memory, scp->res_memory); + bus_release_resource(dev, SYS_RES_MEMORY, + scp->rid_memory, scp->res_memory); + scp->res_memory = 0; } - /* - * Deallocate any system resources we may have - * allocated on behalf of this driver. - */ - return xenpci_deallocate_resources(device); + return (0); } +/* + * Allocate irq and memory resources. + */ static int -xenpci_allocate_resources(device_t device) +xenpci_allocate_resources(device_t dev) { - int error; - struct xenpci_softc *scp = DEVICE2SOFTC(device); + struct xenpci_softc *scp = device_get_softc(dev); - scp->res_irq = bus_alloc_resource_any(device, SYS_RES_IRQ, + scp->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &scp->rid_irq, RF_SHAREABLE|RF_ACTIVE); if (scp->res_irq == NULL) goto errexit; - scp->rid_ioport = PCIR_BAR(0); - scp->res_ioport = bus_alloc_resource_any(device, SYS_RES_IOPORT, - &scp->rid_ioport, RF_ACTIVE); - if (scp->res_ioport == NULL) - goto errexit; - scp->rid_memory = PCIR_BAR(1); - scp->res_memory = bus_alloc_resource_any(device, SYS_RES_MEMORY, + scp->res_memory = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &scp->rid_memory, RF_ACTIVE); if (scp->res_memory == NULL) goto errexit; return (0); errexit: - error = ENXIO; /* Cleanup anything we may have assigned. */ - xenpci_deallocate_resources(device); + xenpci_deallocate_resources(dev); return (ENXIO); /* For want of a better idea. */ } -static int -xenpci_deallocate_resources(device_t device) -{ - struct xenpci_softc *scp = DEVICE2SOFTC(device); - - if (scp->res_irq != 0) { - bus_deactivate_resource(device, SYS_RES_IRQ, - scp->rid_irq, scp->res_irq); - bus_release_resource(device, SYS_RES_IRQ, - scp->rid_irq, scp->res_irq); - scp->res_irq = 0; - } - if (scp->res_ioport != 0) { - bus_deactivate_resource(device, SYS_RES_IOPORT, - scp->rid_ioport, scp->res_ioport); - bus_release_resource(device, SYS_RES_IOPORT, - scp->rid_ioport, scp->res_ioport); - scp->res_ioport = 0; - } - if (scp->res_memory != 0) { - bus_deactivate_resource(device, SYS_RES_MEMORY, - scp->rid_memory, scp->res_memory); - bus_release_resource(device, SYS_RES_MEMORY, - scp->rid_memory, scp->res_memory); - scp->res_memory = 0; - } - - return (0); -} - +/* + * Allocate a physical address range from our mmio region. + */ static int xenpci_alloc_space_int(struct xenpci_softc *scp, size_t sz, vm_paddr_t *pa) @@ -391,27 +238,35 @@ xenpci_alloc_space_int(struct xenpci_sof return (0); } +/* + * Allocate a physical address range from our mmio region. + */ int xenpci_alloc_space(size_t sz, vm_paddr_t *pa) { - device_t device = devclass_get_device(xenpci_devclass, 0); + device_t dev = devclass_get_device(xenpci_devclass, 0); - if (device) { - return (xenpci_alloc_space_int(DEVICE2SOFTC(device), + if (dev) { + return (xenpci_alloc_space_int(device_get_softc(dev), sz, pa)); } else { return (ENOMEM); } } +/* + * Called very early in the resume sequence - reinitialise the various + * bits of Xen machinery including the hypercall page and the shared + * info page. + */ void xenpci_resume() { - device_t device = devclass_get_device(xenpci_devclass, 0); - struct xenpci_softc *scp = DEVICE2SOFTC(device); + device_t dev = devclass_get_device(xenpci_devclass, 0); + struct xenpci_softc *scp = device_get_softc(dev); struct xen_add_to_physmap xatp; - xenpci_resume_hypercall_stubs(device, scp); + xenpci_resume_hypercall_stubs(dev, scp); xatp.domid = DOMID_SELF; xatp.idx = 0; @@ -422,9 +277,123 @@ xenpci_resume() pmap_kenter((vm_offset_t) HYPERVISOR_shared_info, shared_info_pa); - xenpci_set_callback(device); + xenpci_set_callback(dev); gnttab_resume(); irq_resume(); } +/* + * Probe - just check device ID. + */ +static int +xenpci_probe(device_t dev) +{ + + if (pci_get_devid(dev) != 0x00015853) + return (ENXIO); + + device_set_desc(dev, "Xen Platform Device"); + return (bus_generic_probe(dev)); +} + +/* + * Attach - find resources and talk to Xen. + */ +static int +xenpci_attach(device_t dev) +{ + int error; + struct xenpci_softc *scp = device_get_softc(dev); + struct xen_add_to_physmap xatp; + vm_offset_t shared_va; + + error = xenpci_allocate_resources(dev); + if (error) + goto errexit; + + scp->phys_next = rman_get_start(scp->res_memory); + + error = xenpci_init_hypercall_stubs(dev, scp); + if (error) + goto errexit; + + setup_xen_features(); + + xenpci_alloc_space_int(scp, PAGE_SIZE, &shared_info_pa); + + xatp.domid = DOMID_SELF; + xatp.idx = 0; + xatp.space = XENMAPSPACE_shared_info; + xatp.gpfn = shared_info_pa >> PAGE_SHIFT; + if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp)) + panic("HYPERVISOR_memory_op failed"); + + shared_va = kmem_alloc_nofault(kernel_map, PAGE_SIZE); + pmap_kenter(shared_va, shared_info_pa); + HYPERVISOR_shared_info = (void *) shared_va; + + /* + * Hook the irq up to evtchn + */ + xenpci_irq_init(dev, scp); + xenpci_set_callback(dev); + + return (bus_generic_attach(dev)); + +errexit: + /* + * Undo anything we may have done. + */ + xenpci_deallocate_resources(dev); + return (error); +} + +/* + * Detach - reverse anything done by attach. + */ +static int +xenpci_detach(device_t dev) +{ + struct xenpci_softc *scp = device_get_softc(dev); + device_t parent = device_get_parent(dev); + + /* + * Take our interrupt handler out of the list of handlers + * that can handle this irq. + */ + if (scp->intr_cookie != NULL) { + if (BUS_TEARDOWN_INTR(parent, dev, + scp->res_irq, scp->intr_cookie) != 0) + printf("intr teardown failed.. continuing\n"); + scp->intr_cookie = NULL; + } + + /* + * Deallocate any system resources we may have + * allocated on behalf of this driver. + */ + return (xenpci_deallocate_resources(dev)); +} + +static device_method_t xenpci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, xenpci_probe), + DEVMETHOD(device_attach, xenpci_attach), + DEVMETHOD(device_detach, xenpci_detach), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, bus_generic_add_child), + + { 0, 0 } +}; + +static driver_t xenpci_driver = { + "xenpci", + xenpci_methods, + sizeof(struct xenpci_softc), +}; + +DRIVER_MODULE(xenpci, pci, xenpci_driver, xenpci_devclass, 0, 0); Modified: user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpcivar.h ============================================================================== --- user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpcivar.h Mon Jan 5 10:41:54 2009 (r186766) +++ user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpcivar.h Mon Jan 5 10:43:48 2009 (r186767) @@ -1,5 +1,5 @@ /* - * Copyright (c) [year] [your name] + * Copyright (c) 2008 Citrix Systems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,6 @@ struct xenpci_softc { int rid_ioport; int rid_memory; int rid_irq; - struct resource* res_ioport; /* Resource for port range. */ struct resource* res_memory; /* Resource for mem range. */ struct resource* res_irq; /* Resource for irq range. */ void *intr_cookie; From owner-svn-src-user@FreeBSD.ORG Mon Jan 5 12:39:11 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FF9B106564A; Mon, 5 Jan 2009 12:39:11 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2F4848FC21; Mon, 5 Jan 2009 12:39:11 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n05CdB5w096256; Mon, 5 Jan 2009 12:39:11 GMT (envelope-from piso@svn.freebsd.org) Received: (from piso@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n05CdBjS096255; Mon, 5 Jan 2009 12:39:11 GMT (envelope-from piso@svn.freebsd.org) Message-Id: <200901051239.n05CdBjS096255@svn.freebsd.org> From: Paolo Pisati Date: Mon, 5 Jan 2009 12:39:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186770 - user/piso/sys/netinet/libalias X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2009 12:39:12 -0000 Author: piso Date: Mon Jan 5 12:39:10 2009 New Revision: 186770 URL: http://svn.freebsd.org/changeset/base/186770 Log: link_type == LINK_SCTP is true only if we get called from findSctpRedirect, and findSctpRedirect is called from alias_sctp.c that is compiled out in userland, thus it's safe to undef link_type == LINK_SCTP code. Modified: user/piso/sys/netinet/libalias/alias_db.c Modified: user/piso/sys/netinet/libalias/alias_db.c ============================================================================== --- user/piso/sys/netinet/libalias/alias_db.c Mon Jan 5 12:18:46 2009 (r186769) +++ user/piso/sys/netinet/libalias/alias_db.c Mon Jan 5 12:39:10 2009 (r186770) @@ -1280,13 +1280,11 @@ _FindLinkIn(struct libalias *la, struct src_addr = lnk->src_addr; src_port = lnk->src_port; } -#ifdef _KERNEL if (link_type == LINK_SCTP) { lnk->src_addr = src_addr; lnk->src_port = src_port; return(lnk); } -#endif lnk = ReLink(lnk, src_addr, dst_addr, alias_addr, src_port, dst_port, alias_port, @@ -2286,11 +2284,9 @@ LibAliasRedirectPort(struct libalias *la case IPPROTO_TCP: link_type = LINK_TCP; break; -#ifdef _KERNEL case IPPROTO_SCTP: link_type = LINK_SCTP; break; -#endif default: #ifdef LIBALIAS_DEBUG fprintf(stderr, "PacketAliasRedirectPort(): "); From owner-svn-src-user@FreeBSD.ORG Mon Jan 5 12:58:46 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2FD511065672; Mon, 5 Jan 2009 12:58:44 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1DB9A8FC23; Mon, 5 Jan 2009 12:58:44 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n05Cwi5d096735; Mon, 5 Jan 2009 12:58:44 GMT (envelope-from piso@svn.freebsd.org) Received: (from piso@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n05Cwic4096734; Mon, 5 Jan 2009 12:58:44 GMT (envelope-from piso@svn.freebsd.org) Message-Id: <200901051258.n05Cwic4096734@svn.freebsd.org> From: Paolo Pisati Date: Mon, 5 Jan 2009 12:58:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186771 - user/piso/sys/netinet/libalias X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2009 12:58:48 -0000 Author: piso Date: Mon Jan 5 12:58:43 2009 New Revision: 186771 URL: http://svn.freebsd.org/changeset/base/186771 Log: get rid of the doxygen bits and reformat FindSctpRedirectAddress. Modified: user/piso/sys/netinet/libalias/alias_db.c Modified: user/piso/sys/netinet/libalias/alias_db.c ============================================================================== --- user/piso/sys/netinet/libalias/alias_db.c Mon Jan 5 12:39:10 2009 (r186770) +++ user/piso/sys/netinet/libalias/alias_db.c Mon Jan 5 12:58:43 2009 (r186771) @@ -2901,37 +2901,29 @@ LibAliasSetSkinnyPort(struct libalias *l LIBALIAS_UNLOCK(la); } -/** - * @brief Find the address to redirect incoming packets - * - * The function is located in alias_db.c due to calls to static functions - * - * - * @param la pointer to the libalias instance - * @param sm pointer to the incoming message - * - * @return address to redirect an incoming INIT to +/* + * Find the address to redirect incoming packets */ struct in_addr FindSctpRedirectAddress(struct libalias *la, struct sctp_nat_msg *sm) { - struct alias_link *lnk; - struct in_addr redir; + struct alias_link *lnk; + struct in_addr redir; - LIBALIAS_LOCK_ASSERT(la); - lnk = FindLinkIn(la, sm->ip_hdr->ip_src, sm->ip_hdr->ip_dst, - sm->sctp_hdr->dest_port,sm->sctp_hdr->dest_port, LINK_SCTP, 1); - if (lnk != NULL) { - return(lnk->src_addr); /* port redirect */ - } else { - redir = FindOriginalAddress(la,sm->ip_hdr->ip_dst); - if (redir.s_addr == la->aliasAddress.s_addr || - redir.s_addr == la->targetAddress.s_addr) { /* No address found */ - lnk = FindLinkIn(la, sm->ip_hdr->ip_src, sm->ip_hdr->ip_dst, - NO_DEST_PORT, 0, LINK_SCTP, 1); - if (lnk != NULL) - return(lnk->src_addr); /* redirect proto */ - } - return(redir); /* address redirect */ - } + LIBALIAS_LOCK_ASSERT(la); + lnk = FindLinkIn(la, sm->ip_hdr->ip_src, sm->ip_hdr->ip_dst, + sm->sctp_hdr->dest_port,sm->sctp_hdr->dest_port, LINK_SCTP, 1); + if (lnk != NULL) { + return(lnk->src_addr); /* port redirect */ + } else { + redir = FindOriginalAddress(la,sm->ip_hdr->ip_dst); + if (redir.s_addr == la->aliasAddress.s_addr || + redir.s_addr == la->targetAddress.s_addr) { /* No address found */ + lnk = FindLinkIn(la, sm->ip_hdr->ip_src, sm->ip_hdr->ip_dst, + NO_DEST_PORT, 0, LINK_SCTP, 1); + if (lnk != NULL) + return(lnk->src_addr); /* redirect proto */ + } + return(redir); /* address redirect */ + } } From owner-svn-src-user@FreeBSD.ORG Mon Jan 5 13:18:39 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 98CD2106570C; Mon, 5 Jan 2009 13:18:39 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 878A28FC2B; Mon, 5 Jan 2009 13:18:39 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n05DIdcX097256; Mon, 5 Jan 2009 13:18:39 GMT (envelope-from piso@svn.freebsd.org) Received: (from piso@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n05DIdDo097255; Mon, 5 Jan 2009 13:18:39 GMT (envelope-from piso@svn.freebsd.org) Message-Id: <200901051318.n05DIdDo097255@svn.freebsd.org> From: Paolo Pisati Date: Mon, 5 Jan 2009 13:18:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186774 - user/piso/sys/netinet/libalias X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2009 13:18:40 -0000 Author: piso Date: Mon Jan 5 13:18:39 2009 New Revision: 186774 URL: http://svn.freebsd.org/changeset/base/186774 Log: white space fix. Modified: user/piso/sys/netinet/libalias/alias_db.c Modified: user/piso/sys/netinet/libalias/alias_db.c ============================================================================== --- user/piso/sys/netinet/libalias/alias_db.c Mon Jan 5 13:10:06 2009 (r186773) +++ user/piso/sys/netinet/libalias/alias_db.c Mon Jan 5 13:18:39 2009 (r186774) @@ -142,7 +142,6 @@ __FBSDID("$FreeBSD$"); See HISTORY file for additional revisions. */ - #ifdef _KERNEL #include #include @@ -1280,6 +1279,7 @@ _FindLinkIn(struct libalias *la, struct src_addr = lnk->src_addr; src_port = lnk->src_port; } + if (link_type == LINK_SCTP) { lnk->src_addr = src_addr; lnk->src_port = src_port; From owner-svn-src-user@FreeBSD.ORG Mon Jan 5 14:27:05 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4C347106566B; Mon, 5 Jan 2009 14:27:05 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 377E08FC16; Mon, 5 Jan 2009 14:27:05 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n05ER5U9098645; Mon, 5 Jan 2009 14:27:05 GMT (envelope-from piso@svn.freebsd.org) Received: (from piso@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n05ER5AW098644; Mon, 5 Jan 2009 14:27:05 GMT (envelope-from piso@svn.freebsd.org) Message-Id: <200901051427.n05ER5AW098644@svn.freebsd.org> From: Paolo Pisati Date: Mon, 5 Jan 2009 14:27:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186777 - user/piso/sys/netinet/libalias X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2009 14:27:05 -0000 Author: piso Date: Mon Jan 5 14:27:04 2009 New Revision: 186777 URL: http://svn.freebsd.org/changeset/base/186777 Log: protect code not ready yet for userland with _KERNEL. Modified: user/piso/sys/netinet/libalias/alias.c Modified: user/piso/sys/netinet/libalias/alias.c ============================================================================== --- user/piso/sys/netinet/libalias/alias.c Mon Jan 5 14:21:49 2009 (r186776) +++ user/piso/sys/netinet/libalias/alias.c Mon Jan 5 14:27:04 2009 (r186777) @@ -111,13 +111,6 @@ __FBSDID("$FreeBSD$"); See HISTORY file for additional revisions. */ -/** - * Modifications to add sctp functionality by David A. Hayes - * $Id: alias.c 122 2008-06-25 06:50:47Z dhayes $ - * All are inclosed in #ifdef _ALIAS_SCTP - * - */ - #ifdef _KERNEL #include #include @@ -144,17 +137,11 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef _ALIAS_SCTP -#include -#endif #else #include #include "alias.h" #include "alias_local.h" #include "alias_mod.h" -#ifdef _ALIAS_SCTP -#include "alias_sctp.h" -#endif #endif /* @@ -1360,7 +1347,7 @@ LibAliasInLocked(struct libalias *la, ch case IPPROTO_TCP: iresult = TcpAliasIn(la, pip); break; -#ifdef _ALIAS_SCTP +#ifdef _KERNEL case IPPROTO_SCTP: iresult = SctpAlias(la, pip, SN_TO_LOCAL); break; @@ -1510,7 +1497,7 @@ LibAliasOutLocked(struct libalias *la, c case IPPROTO_TCP: iresult = TcpAliasOut(la, pip, maxpacketsize, create); break; - #ifdef _ALIAS_SCTP +#ifdef _KERNEL case IPPROTO_SCTP: iresult = SctpAlias(la, pip, SN_TO_GLOBAL); break; From owner-svn-src-user@FreeBSD.ORG Mon Jan 5 14:46:47 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C82F8106566C; Mon, 5 Jan 2009 14:46:46 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A5F5A8FC35; Mon, 5 Jan 2009 14:46:46 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n05Ekk66099114; Mon, 5 Jan 2009 14:46:46 GMT (envelope-from piso@svn.freebsd.org) Received: (from piso@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n05EkkJg099112; Mon, 5 Jan 2009 14:46:46 GMT (envelope-from piso@svn.freebsd.org) Message-Id: <200901051446.n05EkkJg099112@svn.freebsd.org> From: Paolo Pisati Date: Mon, 5 Jan 2009 14:46:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186778 - user/piso/sys/netinet/libalias X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2009 14:47:09 -0000 Author: piso Date: Mon Jan 5 14:46:46 2009 New Revision: 186778 URL: http://svn.freebsd.org/changeset/base/186778 Log: shuffle the copyright/license at the beginning of file, to match FreeBSD standards. Modified: user/piso/sys/netinet/libalias/alias_sctp.c user/piso/sys/netinet/libalias/alias_sctp.h Modified: user/piso/sys/netinet/libalias/alias_sctp.c ============================================================================== --- user/piso/sys/netinet/libalias/alias_sctp.c Mon Jan 5 14:27:04 2009 (r186777) +++ user/piso/sys/netinet/libalias/alias_sctp.c Mon Jan 5 14:46:46 2009 (r186778) @@ -1,34 +1,9 @@ -//* $Id$ */ -//#ifndef lint -//static char vcid[] = "$Id$"; -//#endif /* lint */ /** * @file alias_sctp.c * Copyright (c) 2008, Centre for Advanced Internet Architectures * Swinburne University of Technology, Melbourne, Australia * (CRICOS number 00111D). * - * Alias_sctp forms part of the libalias kernel module to handle - * Network Address Translation (NAT) for the SCTP protocol. - * - * This software was developed by David A. Hayes and Jason But - * - * The design is outlined in CAIA technical report number 080618A - * (D. Hayes and J. But, "Alias_sctp Version 0.1: SCTP NAT implementation in IPFW") - * - * Development is part of the CAIA SONATA project, - * proposed by Jason But and Grenville Armitage: - * http://caia.swin.edu.au/urp/sonata/ - * - * - * This project has been made possible in part by a grant from - * the Cisco University Research Program Fund at Community - * Foundation Silicon Valley. - * - * - * - * All rights reserved. - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -54,6 +29,23 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * Alias_sctp forms part of the libalias kernel module to handle + * Network Address Translation (NAT) for the SCTP protocol. + * + * This software was developed by David A. Hayes and Jason But + * + * The design is outlined in CAIA technical report number 080618A + * (D. Hayes and J. But, "Alias_sctp Version 0.1: SCTP NAT implementation in IPFW") + * + * Development is part of the CAIA SONATA project, + * proposed by Jason But and Grenville Armitage: + * http://caia.swin.edu.au/urp/sonata/ + * + * + * This project has been made possible in part by a grant from + * the Cisco University Research Program Fund at Community + * Foundation Silicon Valley. + * */ /** @mainpage * Alias_sctp is part of the SONATA (http://caia.swin.edu.au/urp/sonata) project Modified: user/piso/sys/netinet/libalias/alias_sctp.h ============================================================================== --- user/piso/sys/netinet/libalias/alias_sctp.h Mon Jan 5 14:27:04 2009 (r186777) +++ user/piso/sys/netinet/libalias/alias_sctp.h Mon Jan 5 14:46:46 2009 (r186778) @@ -1,34 +1,9 @@ -/*/* $Id$ */ -//#ifndef lint -//static char vcid[] = "$Id$"; -//#endif /* lint */ /** * @file alias_sctp.h * Copyright (c) 2008, Centre for Advanced Internet Architectures * Swinburne University of Technology, Melbourne, Australia * (CRICOS number 00111D). * - * Alias_sctp forms part of the libalias kernel module to handle - * Network Address Translation (NAT) for the SCTP protocol. - * - * This software was developed by David A. Hayes - * with leadership and advice from Jason But - * - * The design is outlined in CAIA technical report number 080618A - * (D. Hayes and J. But, "Alias_sctp Version 0.1: SCTP NAT implementation in IPFW") - * - * Development is part of the CAIA SONATA project, - * proposed by Jason But and Grenville Armitage: - * http://caia.swin.edu.au/urp/sonata/ - * - * - * This project has been made possible in part by a grant from - * the Cisco University Research Program Fund at Community - * Foundation Silicon Valley. - * - * - * All rights reserved. - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -54,6 +29,24 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * Alias_sctp forms part of the libalias kernel module to handle + * Network Address Translation (NAT) for the SCTP protocol. + * + * This software was developed by David A. Hayes + * with leadership and advice from Jason But + * + * The design is outlined in CAIA technical report number 080618A + * (D. Hayes and J. But, "Alias_sctp Version 0.1: SCTP NAT implementation in IPFW") + * + * Development is part of the CAIA SONATA project, + * proposed by Jason But and Grenville Armitage: + * http://caia.swin.edu.au/urp/sonata/ + * + * + * This project has been made possible in part by a grant from + * the Cisco University Research Program Fund at Community + * Foundation Silicon Valley. + * */ #ifndef _ALIAS_SCTP_H_ #define _ALIAS_SCTP_H_ From owner-svn-src-user@FreeBSD.ORG Mon Jan 5 14:48:43 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A9B441065674; Mon, 5 Jan 2009 14:48:43 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 973068FC29; Mon, 5 Jan 2009 14:48:43 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n05Emhhn099185; Mon, 5 Jan 2009 14:48:43 GMT (envelope-from piso@svn.freebsd.org) Received: (from piso@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n05EmhMn099183; Mon, 5 Jan 2009 14:48:43 GMT (envelope-from piso@svn.freebsd.org) Message-Id: <200901051448.n05EmhMn099183@svn.freebsd.org> From: Paolo Pisati Date: Mon, 5 Jan 2009 14:48:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186779 - user/piso/sys/netinet/libalias X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2009 14:48:43 -0000 Author: piso Date: Mon Jan 5 14:48:43 2009 New Revision: 186779 URL: http://svn.freebsd.org/changeset/base/186779 Log: BSD indent a bit the code. Modified: user/piso/sys/netinet/libalias/alias_sctp.c user/piso/sys/netinet/libalias/alias_sctp.h Modified: user/piso/sys/netinet/libalias/alias_sctp.c ============================================================================== --- user/piso/sys/netinet/libalias/alias_sctp.c Mon Jan 5 14:46:46 2009 (r186778) +++ user/piso/sys/netinet/libalias/alias_sctp.c Mon Jan 5 14:48:43 2009 (r186779) @@ -99,9 +99,9 @@ */ /* Packet Parsing Functions */ static int sctp_PktParser(struct libalias *la, int direction, struct ip *pip, - struct sctp_nat_msg *sm, struct sctp_nat_assoc **passoc); + struct sctp_nat_msg *sm, struct sctp_nat_assoc **passoc); static int GetAsconfVtags(struct libalias *la, struct sctp_nat_msg *sm, - uint32_t *l_vtag, uint32_t *g_vtag, int direction); + uint32_t *l_vtag, uint32_t *g_vtag, int direction); static int IsASCONFack(struct libalias *la, struct sctp_nat_msg *sm, int direction); static void AddGlobalIPAddresses(struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc, int direction); @@ -111,20 +111,20 @@ static int IsADDorDEL(struct libalias *l /* State Machine Functions */ static int ProcessSctpMsg(struct libalias *la, int direction, \ - struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc); + struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc); static int ID_process(struct libalias *la, int direction,\ - struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); static int INi_process(struct libalias *la, int direction,\ - struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); static int INa_process(struct libalias *la, int direction,\ - struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); static int UP_process(struct libalias *la, int direction,\ - struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); static int CL_process(struct libalias *la, int direction,\ - struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); static void TxAbortErrorM(struct libalias *la, struct sctp_nat_msg *sm,\ - struct sctp_nat_assoc *assoc, int sndrply, int direction); + struct sctp_nat_assoc *assoc, int sndrply, int direction); /* Hash Table Functions */ static struct sctp_nat_assoc* @@ -340,9 +340,9 @@ static u_int sysctl_holddown_timer = 0; static u_int sysctl_hashtable_size = SN_DEFAULT_HASH_SIZE; /**< Sets the hash table size for any NEW NAT instances (existing instances retain their existing Hash Table */ /** @brief net.inet.ip.alias.sctp.error_on_ootb */ static u_int sysctl_error_on_ootb = 1; /**< NAT response to receipt of OOTB packet - (0 - No response, 1 - NAT will send ErrorM only to local side, - 2 - NAT will send local ErrorM and global ErrorM if there was a partial association match - 3 - NAT will send ErrorM to both local and global) */ + (0 - No response, 1 - NAT will send ErrorM only to local side, + 2 - NAT will send local ErrorM and global ErrorM if there was a partial association match + 3 - NAT will send ErrorM to both local and global) */ /** @brief net.inet.ip.alias.sctp.accept_global_ootb_addip */ static u_int sysctl_accept_global_ootb_addip = 0; /** 0 - enables tracking but limits the number of global IP addresses to this value) - If set to >=1 the NAT will track that many global IP addresses. This may reduce look up table conflicts, but increases processing */ + If set to >=1 the NAT will track that many global IP addresses. This may reduce look up table conflicts, but increases processing */ #define SN_NO_ERROR_ON_OOTB 0 /**< Send no errorM on out of the blue packets */ #define SN_LOCAL_ERROR_ON_OOTB 1 /**< Send only local errorM on out of the blue packets */ @@ -369,41 +369,41 @@ SYSCTL_DECL(_net_inet_ip_alias); SYSCTL_NODE(_net_inet_ip_alias, OID_AUTO, sctp, CTLFLAG_RW, NULL, "SCTP NAT"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, log_level, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_log_level, 0, sysctl_chg_loglevel, "IU", - "Level of detail (0 - default, 1 - event, 2 - info, 3 - detail, 4 - debug, 5 - max debug)"); + &sysctl_log_level, 0, sysctl_chg_loglevel, "IU", + "Level of detail (0 - default, 1 - event, 2 - info, 3 - detail, 4 - debug, 5 - max debug)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, init_timer, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_init_timer, 0, sysctl_chg_timer, "IU", - "Timeout value (s) while waiting for (INIT-ACK|AddIP-ACK)"); + &sysctl_init_timer, 0, sysctl_chg_timer, "IU", + "Timeout value (s) while waiting for (INIT-ACK|AddIP-ACK)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, up_timer, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_up_timer, 0, sysctl_chg_timer, "IU", - "Timeout value (s) to keep an association up with no traffic"); + &sysctl_up_timer, 0, sysctl_chg_timer, "IU", + "Timeout value (s) to keep an association up with no traffic"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, shutdown_timer, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_shutdown_timer, 0, sysctl_chg_timer, "IU", - "Timeout value (s) while waiting for SHUTDOWN-COMPLETE"); + &sysctl_shutdown_timer, 0, sysctl_chg_timer, "IU", + "Timeout value (s) while waiting for SHUTDOWN-COMPLETE"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, holddown_timer, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_holddown_timer, 0, sysctl_chg_timer, "IU", - "Hold association in table for this many seconds after receiving a SHUTDOWN-COMPLETE"); + &sysctl_holddown_timer, 0, sysctl_chg_timer, "IU", + "Hold association in table for this many seconds after receiving a SHUTDOWN-COMPLETE"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, hashtable_size, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_hashtable_size, 0, sysctl_chg_hashtable_size, "IU", - "Size of hash tables used for NAT lookups (100 < prime_number > 1000001)"); + &sysctl_hashtable_size, 0, sysctl_chg_hashtable_size, "IU", + "Size of hash tables used for NAT lookups (100 < prime_number > 1000001)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, error_on_ootb, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_error_on_ootb, 0, sysctl_chg_error_on_ootb, "IU", - "ErrorM sent on receipt of ootb packet:\n\t0 - none,\n\t1 - to local only,\n\t2 - to local and global if a partial association match,\n\t3 - to local and global (DoS risk)"); + &sysctl_error_on_ootb, 0, sysctl_chg_error_on_ootb, "IU", + "ErrorM sent on receipt of ootb packet:\n\t0 - none,\n\t1 - to local only,\n\t2 - to local and global if a partial association match,\n\t3 - to local and global (DoS risk)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, accept_global_ootb_addip, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_accept_global_ootb_addip, 0, sysctl_chg_accept_global_ootb_addip, "IU", - "NAT response to receipt of global OOTB AddIP:\n\t0 - No response,\n\t1 - NAT will accept OOTB global AddIP messages for processing (Security risk)"); + &sysctl_accept_global_ootb_addip, 0, sysctl_chg_accept_global_ootb_addip, "IU", + "NAT response to receipt of global OOTB AddIP:\n\t0 - No response,\n\t1 - NAT will accept OOTB global AddIP messages for processing (Security risk)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, initialising_chunk_proc_limit, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_initialising_chunk_proc_limit, 0, sysctl_chg_initialising_chunk_proc_limit, "IU", - "Number of chunks that should be processed if there is no current association found:\n\t > 0 (A high value is a DoS risk)"); + &sysctl_initialising_chunk_proc_limit, 0, sysctl_chg_initialising_chunk_proc_limit, "IU", + "Number of chunks that should be processed if there is no current association found:\n\t > 0 (A high value is a DoS risk)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, chunk_proc_limit, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_chunk_proc_limit, 0, sysctl_chg_chunk_proc_limit, "IU", - "Number of chunks that should be processed to find key chunk:\n\t>= initialising_chunk_proc_limit (A high value is a DoS risk)"); + &sysctl_chunk_proc_limit, 0, sysctl_chg_chunk_proc_limit, "IU", + "Number of chunks that should be processed to find key chunk:\n\t>= initialising_chunk_proc_limit (A high value is a DoS risk)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, param_proc_limit, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_param_proc_limit, 0, sysctl_chg_param_proc_limit, "IU", - "Number of parameters (in a chunk) that should be processed to find key parameters:\n\t> 1 (A high value is a DoS risk)"); + &sysctl_param_proc_limit, 0, sysctl_chg_param_proc_limit, "IU", + "Number of parameters (in a chunk) that should be processed to find key parameters:\n\t> 1 (A high value is a DoS risk)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, track_global_addresses, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_track_global_addresses, 0, sysctl_chg_track_global_addresses, "IU", - "Configures the global address tracking option within the NAT:\n\t0 - Global tracking is disabled,\n\t> 0 - enables tracking but limits the number of global IP addresses to this value"); + &sysctl_track_global_addresses, 0, sysctl_chg_track_global_addresses, "IU", + "Configures the global address tracking option within the NAT:\n\t0 - Global tracking is disabled,\n\t> 0 - enables tracking but limits the number of global IP addresses to this value"); #endif /* SYSCTL_NODE */ @@ -416,16 +416,16 @@ SYSCTL_PROC(_net_inet_ip_alias_sctp, OID */ int sysctl_chg_loglevel(SYSCTL_HANDLER_ARGS) { - u_int level = *(u_int *)arg1; - int error; + u_int level = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &level, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &level, 0, req); + if (error) return (error); - sysctl_log_level = (level > SN_LOG_DEBUG_MAX)?(SN_LOG_DEBUG_MAX):(level); - sysctl_log_level = (level < SN_LOG_LOW)?(SN_LOG_LOW):(level); + sysctl_log_level = (level > SN_LOG_DEBUG_MAX)?(SN_LOG_DEBUG_MAX):(level); + sysctl_log_level = (level < SN_LOG_LOW)?(SN_LOG_LOW):(level); - return (0); + return (0); } /** @ingroup sysctl @@ -437,22 +437,22 @@ int sysctl_chg_loglevel(SYSCTL_HANDLER_A */ int sysctl_chg_timer(SYSCTL_HANDLER_ARGS) { - u_int timer = *(u_int *)arg1; - int error; + u_int timer = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &timer, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &timer, 0, req); + if (error) return (error); - timer = (timer > SN_MAX_TIMER)?(SN_MAX_TIMER):(timer); + timer = (timer > SN_MAX_TIMER)?(SN_MAX_TIMER):(timer); - if (((u_int *)arg1) != &sysctl_holddown_timer) - { - timer = (timer < SN_MIN_TIMER)?(SN_MIN_TIMER):(timer); - } + if (((u_int *)arg1) != &sysctl_holddown_timer) + { + timer = (timer < SN_MIN_TIMER)?(SN_MIN_TIMER):(timer); + } - *(u_int *)arg1 = timer; + *(u_int *)arg1 = timer; - return (0); + return (0); } /** @ingroup sysctl @@ -466,20 +466,20 @@ int sysctl_chg_timer(SYSCTL_HANDLER_ARGS */ int sysctl_chg_hashtable_size(SYSCTL_HANDLER_ARGS) { - u_int size = *(u_int *)arg1; - int error; + u_int size = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &size, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &size, 0, req); + if (error) return (error); - size = (size < SN_MIN_HASH_SIZE)?(SN_MIN_HASH_SIZE):((size > SN_MAX_HASH_SIZE)?(SN_MAX_HASH_SIZE):(size)); + size = (size < SN_MIN_HASH_SIZE)?(SN_MIN_HASH_SIZE):((size > SN_MAX_HASH_SIZE)?(SN_MAX_HASH_SIZE):(size)); - size |= 0x00000001; /* make odd */ + size |= 0x00000001; /* make odd */ - for(;(((size % 3) == 0) || ((size % 5) == 0) || ((size % 7) == 0) || ((size % 11) == 0)); size+=2); - sysctl_hashtable_size = size; + for(;(((size % 3) == 0) || ((size % 5) == 0) || ((size % 7) == 0) || ((size % 11) == 0)); size+=2); + sysctl_hashtable_size = size; - return (0); + return (0); } /** @ingroup sysctl @@ -494,15 +494,15 @@ int sysctl_chg_hashtable_size(SYSCTL_HAN */ int sysctl_chg_error_on_ootb(SYSCTL_HANDLER_ARGS) { - u_int flag = *(u_int *)arg1; - int error; + u_int flag = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &flag, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &flag, 0, req); + if (error) return (error); - sysctl_error_on_ootb = (flag > SN_ERROR_ON_OOTB) ? SN_ERROR_ON_OOTB: flag; + sysctl_error_on_ootb = (flag > SN_ERROR_ON_OOTB) ? SN_ERROR_ON_OOTB: flag; - return (0); + return (0); } /** @ingroup sysctl @@ -513,15 +513,15 @@ int sysctl_chg_error_on_ootb(SYSCTL_HAND */ int sysctl_chg_accept_global_ootb_addip(SYSCTL_HANDLER_ARGS) { - u_int flag = *(u_int *)arg1; - int error; + u_int flag = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &flag, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &flag, 0, req); + if (error) return (error); - sysctl_accept_global_ootb_addip = (flag == 1) ? 1: 0; + sysctl_accept_global_ootb_addip = (flag == 1) ? 1: 0; - return (0); + return (0); } /** @ingroup sysctl @@ -533,17 +533,17 @@ int sysctl_chg_accept_global_ootb_addip( */ int sysctl_chg_initialising_chunk_proc_limit(SYSCTL_HANDLER_ARGS) { - u_int proclimit = *(u_int *)arg1; - int error; + u_int proclimit = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &proclimit, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &proclimit, 0, req); + if (error) return (error); - sysctl_initialising_chunk_proc_limit = (proclimit < 1) ? 1: proclimit; - sysctl_chunk_proc_limit = - (sysctl_chunk_proc_limit < sysctl_initialising_chunk_proc_limit) ? sysctl_initialising_chunk_proc_limit : sysctl_chunk_proc_limit; + sysctl_initialising_chunk_proc_limit = (proclimit < 1) ? 1: proclimit; + sysctl_chunk_proc_limit = + (sysctl_chunk_proc_limit < sysctl_initialising_chunk_proc_limit) ? sysctl_initialising_chunk_proc_limit : sysctl_chunk_proc_limit; - return (0); + return (0); } /** @ingroup sysctl @@ -555,16 +555,16 @@ int sysctl_chg_initialising_chunk_proc_l */ int sysctl_chg_chunk_proc_limit(SYSCTL_HANDLER_ARGS) { - u_int proclimit = *(u_int *)arg1; - int error; + u_int proclimit = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &proclimit, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &proclimit, 0, req); + if (error) return (error); - sysctl_chunk_proc_limit = - (proclimit < sysctl_initialising_chunk_proc_limit) ? sysctl_initialising_chunk_proc_limit : proclimit; + sysctl_chunk_proc_limit = + (proclimit < sysctl_initialising_chunk_proc_limit) ? sysctl_initialising_chunk_proc_limit : proclimit; - return (0); + return (0); } @@ -577,16 +577,16 @@ int sysctl_chg_chunk_proc_limit(SYSCTL_H */ int sysctl_chg_param_proc_limit(SYSCTL_HANDLER_ARGS) { - u_int proclimit = *(u_int *)arg1; - int error; + u_int proclimit = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &proclimit, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &proclimit, 0, req); + if (error) return (error); - sysctl_param_proc_limit = - (proclimit < 2) ? 2 : proclimit; + sysctl_param_proc_limit = + (proclimit < 2) ? 2 : proclimit; - return (0); + return (0); } /** @ingroup sysctl @@ -598,15 +598,15 @@ int sysctl_chg_param_proc_limit(SYSCTL_H */ int sysctl_chg_track_global_addresses(SYSCTL_HANDLER_ARGS) { - u_int num_to_track = *(u_int *)arg1; - int error; + u_int num_to_track = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &num_to_track, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &num_to_track, 0, req); + if (error) return (error); - sysctl_track_global_addresses = (num_to_track > SN_MAX_GLOBAL_ADDRESSES) ? SN_MAX_GLOBAL_ADDRESSES : num_to_track; + sysctl_track_global_addresses = (num_to_track > SN_MAX_GLOBAL_ADDRESSES) ? SN_MAX_GLOBAL_ADDRESSES : num_to_track; - return (0); + return (0); } @@ -624,30 +624,30 @@ int sysctl_chg_track_global_addresses(SY */ void AliasSctpInit(struct libalias *la) { - /* Initialise association tables*/ - int i; - la->sctpNatTableSize = sysctl_hashtable_size; - SN_LOG(SN_LOG_EVENT, - SctpAliasLog("Initialising SCTP NAT Instance (hash_table_size:%d)\n", la->sctpNatTableSize)); - la->sctpTableLocal = sn_calloc(la->sctpNatTableSize, sizeof(struct sctpNatTableL)); - la->sctpTableGlobal = sn_calloc(la->sctpNatTableSize, sizeof(struct sctpNatTableG)); - la->sctpNatTimer.TimerQ = sn_calloc(SN_TIMER_QUEUE_SIZE, sizeof(struct sctpTimerQ)); - /* Initialise hash table */ - for (i = 0; i < la->sctpNatTableSize; i++) { - LIST_INIT(&la->sctpTableLocal[i]); - LIST_INIT(&la->sctpTableGlobal[i]); - } - - /* Initialise circular timer Q*/ - for (i = 0; i < SN_TIMER_QUEUE_SIZE; i++) - LIST_INIT(&la->sctpNatTimer.TimerQ[i]); + /* Initialise association tables*/ + int i; + la->sctpNatTableSize = sysctl_hashtable_size; + SN_LOG(SN_LOG_EVENT, + SctpAliasLog("Initialising SCTP NAT Instance (hash_table_size:%d)\n", la->sctpNatTableSize)); + la->sctpTableLocal = sn_calloc(la->sctpNatTableSize, sizeof(struct sctpNatTableL)); + la->sctpTableGlobal = sn_calloc(la->sctpNatTableSize, sizeof(struct sctpNatTableG)); + la->sctpNatTimer.TimerQ = sn_calloc(SN_TIMER_QUEUE_SIZE, sizeof(struct sctpTimerQ)); + /* Initialise hash table */ + for (i = 0; i < la->sctpNatTableSize; i++) { + LIST_INIT(&la->sctpTableLocal[i]); + LIST_INIT(&la->sctpTableGlobal[i]); + } + + /* Initialise circular timer Q*/ + for (i = 0; i < SN_TIMER_QUEUE_SIZE; i++) + LIST_INIT(&la->sctpNatTimer.TimerQ[i]); #ifdef _KERNEL - la->sctpNatTimer.loc_time=time_uptime; /* la->timeStamp is not set yet */ + la->sctpNatTimer.loc_time=time_uptime; /* la->timeStamp is not set yet */ #else - la->sctpNatTimer.loc_time=la->timeStamp; + la->sctpNatTimer.loc_time=la->timeStamp; #endif - la->sctpNatTimer.cur_loc = 0; - la->sctpLinkCount = 0; + la->sctpNatTimer.cur_loc = 0; + la->sctpLinkCount = 0; } /** @@ -664,25 +664,25 @@ void AliasSctpInit(struct libalias *la) */ void AliasSctpTerm(struct libalias *la) { - struct sctp_nat_assoc *assoc1, *assoc2; - int i; + struct sctp_nat_assoc *assoc1, *assoc2; + int i; + + LIBALIAS_LOCK_ASSERT(la); + SN_LOG(SN_LOG_EVENT, + SctpAliasLog("Removing SCTP NAT Instance\n")); + for (i = 0; i < SN_TIMER_QUEUE_SIZE; i++) { + assoc1 = LIST_FIRST(&la->sctpNatTimer.TimerQ[i]); + while (assoc1 != NULL) { + freeGlobalAddressList(assoc1); + assoc2 = LIST_NEXT(assoc1, timer_Q); + sn_free(assoc1); + assoc1 = assoc2; + } + } - LIBALIAS_LOCK_ASSERT(la); - SN_LOG(SN_LOG_EVENT, - SctpAliasLog("Removing SCTP NAT Instance\n")); - for (i = 0; i < SN_TIMER_QUEUE_SIZE; i++) { - assoc1 = LIST_FIRST(&la->sctpNatTimer.TimerQ[i]); - while (assoc1 != NULL) { - freeGlobalAddressList(assoc1); - assoc2 = LIST_NEXT(assoc1, timer_Q); - sn_free(assoc1); - assoc1 = assoc2; - } - } - - sn_free(la->sctpTableLocal); - sn_free(la->sctpTableGlobal); - sn_free(la->sctpNatTimer.TimerQ); + sn_free(la->sctpTableLocal); + sn_free(la->sctpTableGlobal); + sn_free(la->sctpNatTimer.TimerQ); } /** @@ -711,122 +711,122 @@ void AliasSctpTerm(struct libalias *la) int SctpAlias(struct libalias *la, struct ip *pip, int direction) { - int rtnval; - struct sctp_nat_msg msg; - struct sctp_nat_assoc *assoc = NULL; - - if ((direction != SN_TO_LOCAL) && (direction != SN_TO_GLOBAL)) { - SctpAliasLog("ERROR: Invalid direction\n"); - return(PKT_ALIAS_ERROR); - } - - sctp_CheckTimers(la); /* Check timers */ - - /* Parse the packet */ - rtnval = sctp_PktParser(la, direction, pip, &msg, &assoc); //using *char (change to mbuf when get code from paolo) - switch (rtnval) { - case SN_PARSE_OK: - break; - case SN_PARSE_ERROR_CHHL: - /* Not an error if there is a chunk length parsing error and this is a fragmented packet */ - if (ntohs(pip->ip_off) & IP_MF) { - rtnval = SN_PARSE_OK; - break; - } - SN_LOG(SN_LOG_EVENT, - logsctperror("SN_PARSE_ERROR", msg.sctp_hdr->v_tag, rtnval, direction)); - return(PKT_ALIAS_ERROR); - case SN_PARSE_ERROR_PARTIALLOOKUP: - if (sysctl_error_on_ootb > SN_LOCALandPARTIAL_ERROR_ON_OOTB) { - SN_LOG(SN_LOG_EVENT, - logsctperror("SN_PARSE_ERROR", msg.sctp_hdr->v_tag, rtnval, direction)); - return(PKT_ALIAS_ERROR); - } - case SN_PARSE_ERROR_LOOKUP: - if (sysctl_error_on_ootb == SN_ERROR_ON_OOTB || - (sysctl_error_on_ootb == SN_LOCALandPARTIAL_ERROR_ON_OOTB && direction == SN_TO_LOCAL) || - (sysctl_error_on_ootb == SN_LOCAL_ERROR_ON_OOTB && direction == SN_TO_GLOBAL)) { - TxAbortErrorM(la, &msg, assoc, SN_REFLECT_ERROR, direction); /*NB assoc=NULL */ - return(PKT_ALIAS_RESPOND); - } - default: - SN_LOG(SN_LOG_EVENT, - logsctperror("SN_PARSE_ERROR", msg.sctp_hdr->v_tag, rtnval, direction)); - return(PKT_ALIAS_ERROR); - } - - SN_LOG(SN_LOG_DETAIL, - logsctpassoc(assoc, "*"); - logsctpparse(direction, &msg); - ); - - /* Process the SCTP message */ - rtnval = ProcessSctpMsg(la, direction, &msg, assoc); - - SN_LOG(SN_LOG_DEBUG_MAX, - logsctpassoc(assoc, "-"); - logSctpLocal(la); - logSctpGlobal(la); - ); - SN_LOG(SN_LOG_DEBUG, logTimerQ(la)); - - switch(rtnval){ - case SN_NAT_PKT: - switch(direction) { - case SN_TO_LOCAL: - DifferentialChecksum(&(msg.ip_hdr->ip_sum), - &(assoc->l_addr), &(msg.ip_hdr->ip_dst), 2); - msg.ip_hdr->ip_dst = assoc->l_addr; /* change dst address to local address*/ - break; - case SN_TO_GLOBAL: - DifferentialChecksum(&(msg.ip_hdr->ip_sum), - &(assoc->a_addr), &(msg.ip_hdr->ip_src), 2); - msg.ip_hdr->ip_src = assoc->a_addr; /* change src to alias addr*/ - break; - default: - rtnval = SN_DROP_PKT; /* shouldn't get here, but if it does drop packet */ - SN_LOG(SN_LOG_LOW, logsctperror("ERROR: Invalid direction", msg.sctp_hdr->v_tag, rtnval, direction)); - break; - } - break; - case SN_DROP_PKT: - SN_LOG(SN_LOG_DETAIL, logsctperror("SN_DROP_PKT", msg.sctp_hdr->v_tag, rtnval, direction)); - break; - case SN_REPLY_ABORT: - case SN_REPLY_ERROR: - case SN_SEND_ABORT: - TxAbortErrorM(la, &msg, assoc, rtnval, direction); - break; - default: - // big error, remove association and go to idle and write log messages - SN_LOG(SN_LOG_LOW, logsctperror("SN_PROCESSING_ERROR", msg.sctp_hdr->v_tag, rtnval, direction)); - assoc->state=SN_RM;/* Mark for removal*/ - break; - } - - /* Remove association if tagged for removal */ - if (assoc->state == SN_RM) { - if (assoc->TableRegister) { - sctp_RmTimeOut(la, assoc); - RmSctpAssoc(la, assoc); - } - LIBALIAS_LOCK_ASSERT(la); - freeGlobalAddressList(assoc); - sn_free(assoc); - } - switch(rtnval) { - case SN_NAT_PKT: - return(PKT_ALIAS_OK); - case SN_SEND_ABORT: - return(PKT_ALIAS_OK); - case SN_REPLY_ABORT: - case SN_REPLY_ERROR: - case SN_REFLECT_ERROR: - return(PKT_ALIAS_RESPOND); - case SN_DROP_PKT: - default: - return(PKT_ALIAS_ERROR); - } + int rtnval; + struct sctp_nat_msg msg; + struct sctp_nat_assoc *assoc = NULL; + + if ((direction != SN_TO_LOCAL) && (direction != SN_TO_GLOBAL)) { + SctpAliasLog("ERROR: Invalid direction\n"); + return(PKT_ALIAS_ERROR); + } + + sctp_CheckTimers(la); /* Check timers */ + + /* Parse the packet */ + rtnval = sctp_PktParser(la, direction, pip, &msg, &assoc); //using *char (change to mbuf when get code from paolo) + switch (rtnval) { + case SN_PARSE_OK: + break; + case SN_PARSE_ERROR_CHHL: + /* Not an error if there is a chunk length parsing error and this is a fragmented packet */ + if (ntohs(pip->ip_off) & IP_MF) { + rtnval = SN_PARSE_OK; + break; + } + SN_LOG(SN_LOG_EVENT, + logsctperror("SN_PARSE_ERROR", msg.sctp_hdr->v_tag, rtnval, direction)); + return(PKT_ALIAS_ERROR); + case SN_PARSE_ERROR_PARTIALLOOKUP: + if (sysctl_error_on_ootb > SN_LOCALandPARTIAL_ERROR_ON_OOTB) { + SN_LOG(SN_LOG_EVENT, + logsctperror("SN_PARSE_ERROR", msg.sctp_hdr->v_tag, rtnval, direction)); + return(PKT_ALIAS_ERROR); + } + case SN_PARSE_ERROR_LOOKUP: + if (sysctl_error_on_ootb == SN_ERROR_ON_OOTB || + (sysctl_error_on_ootb == SN_LOCALandPARTIAL_ERROR_ON_OOTB && direction == SN_TO_LOCAL) || + (sysctl_error_on_ootb == SN_LOCAL_ERROR_ON_OOTB && direction == SN_TO_GLOBAL)) { + TxAbortErrorM(la, &msg, assoc, SN_REFLECT_ERROR, direction); /*NB assoc=NULL */ + return(PKT_ALIAS_RESPOND); + } + default: + SN_LOG(SN_LOG_EVENT, + logsctperror("SN_PARSE_ERROR", msg.sctp_hdr->v_tag, rtnval, direction)); + return(PKT_ALIAS_ERROR); + } + + SN_LOG(SN_LOG_DETAIL, + logsctpassoc(assoc, "*"); + logsctpparse(direction, &msg); + ); + + /* Process the SCTP message */ + rtnval = ProcessSctpMsg(la, direction, &msg, assoc); + + SN_LOG(SN_LOG_DEBUG_MAX, + logsctpassoc(assoc, "-"); + logSctpLocal(la); + logSctpGlobal(la); + ); + SN_LOG(SN_LOG_DEBUG, logTimerQ(la)); + + switch(rtnval){ + case SN_NAT_PKT: + switch(direction) { + case SN_TO_LOCAL: + DifferentialChecksum(&(msg.ip_hdr->ip_sum), + &(assoc->l_addr), &(msg.ip_hdr->ip_dst), 2); + msg.ip_hdr->ip_dst = assoc->l_addr; /* change dst address to local address*/ + break; + case SN_TO_GLOBAL: + DifferentialChecksum(&(msg.ip_hdr->ip_sum), + &(assoc->a_addr), &(msg.ip_hdr->ip_src), 2); + msg.ip_hdr->ip_src = assoc->a_addr; /* change src to alias addr*/ + break; + default: + rtnval = SN_DROP_PKT; /* shouldn't get here, but if it does drop packet */ + SN_LOG(SN_LOG_LOW, logsctperror("ERROR: Invalid direction", msg.sctp_hdr->v_tag, rtnval, direction)); + break; + } + break; + case SN_DROP_PKT: + SN_LOG(SN_LOG_DETAIL, logsctperror("SN_DROP_PKT", msg.sctp_hdr->v_tag, rtnval, direction)); + break; + case SN_REPLY_ABORT: + case SN_REPLY_ERROR: + case SN_SEND_ABORT: + TxAbortErrorM(la, &msg, assoc, rtnval, direction); + break; + default: + // big error, remove association and go to idle and write log messages + SN_LOG(SN_LOG_LOW, logsctperror("SN_PROCESSING_ERROR", msg.sctp_hdr->v_tag, rtnval, direction)); + assoc->state=SN_RM;/* Mark for removal*/ + break; + } + + /* Remove association if tagged for removal */ + if (assoc->state == SN_RM) { + if (assoc->TableRegister) { + sctp_RmTimeOut(la, assoc); + RmSctpAssoc(la, assoc); + } + LIBALIAS_LOCK_ASSERT(la); + freeGlobalAddressList(assoc); + sn_free(assoc); + } + switch(rtnval) { + case SN_NAT_PKT: + return(PKT_ALIAS_OK); + case SN_SEND_ABORT: + return(PKT_ALIAS_OK); + case SN_REPLY_ABORT: + case SN_REPLY_ERROR: + case SN_REFLECT_ERROR: + return(PKT_ALIAS_RESPOND); + case SN_DROP_PKT: + default: + return(PKT_ALIAS_ERROR); + } } /** @@ -865,92 +865,92 @@ SctpAlias(struct libalias *la, struct ip static void TxAbortErrorM(struct libalias *la, struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc, int sndrply, int direction) { - int sctp_size = sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_error_cause); - int ip_size = sizeof(struct ip) + sctp_size; - int include_error_cause = 1; - char tmp_ip[ip_size]; - - if (ntohs(sm->ip_hdr->ip_len) < ip_size) { /* short packet, cannot send error cause */ - include_error_cause = 0; - ip_size = ip_size - sizeof(struct sctp_error_cause); - sctp_size = sctp_size - sizeof(struct sctp_error_cause); - } - /* Assign header pointers packet */ - struct ip* ip = (struct ip *) tmp_ip; - struct sctphdr* sctp_hdr = (struct sctphdr *) ((char *) ip + sizeof(*ip)); - struct sctp_chunkhdr* chunk_hdr = (struct sctp_chunkhdr *) ((char *) sctp_hdr + sizeof(*sctp_hdr)); - struct sctp_error_cause* error_cause = (struct sctp_error_cause *) ((char *) chunk_hdr + sizeof(*chunk_hdr)); - - /* construct ip header */ - ip->ip_v = sm->ip_hdr->ip_v; - ip->ip_hl = 5; /* 5*32 bit words */ - ip->ip_tos = 0; - ip->ip_len = htons(ip_size); - ip->ip_id = sm->ip_hdr->ip_id; - ip->ip_off = 0; - ip->ip_ttl = 255; - ip->ip_p = IPPROTO_SCTP; - /* - The definitions below should be removed when they make it into the SCTP stack - */ + int sctp_size = sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_error_cause); + int ip_size = sizeof(struct ip) + sctp_size; + int include_error_cause = 1; + char tmp_ip[ip_size]; + + if (ntohs(sm->ip_hdr->ip_len) < ip_size) { /* short packet, cannot send error cause */ + include_error_cause = 0; + ip_size = ip_size - sizeof(struct sctp_error_cause); + sctp_size = sctp_size - sizeof(struct sctp_error_cause); + } + /* Assign header pointers packet */ + struct ip* ip = (struct ip *) tmp_ip; + struct sctphdr* sctp_hdr = (struct sctphdr *) ((char *) ip + sizeof(*ip)); + struct sctp_chunkhdr* chunk_hdr = (struct sctp_chunkhdr *) ((char *) sctp_hdr + sizeof(*sctp_hdr)); + struct sctp_error_cause* error_cause = (struct sctp_error_cause *) ((char *) chunk_hdr + sizeof(*chunk_hdr)); + + /* construct ip header */ + ip->ip_v = sm->ip_hdr->ip_v; + ip->ip_hl = 5; /* 5*32 bit words */ + ip->ip_tos = 0; + ip->ip_len = htons(ip_size); + ip->ip_id = sm->ip_hdr->ip_id; + ip->ip_off = 0; + ip->ip_ttl = 255; + ip->ip_p = IPPROTO_SCTP; + /* + The definitions below should be removed when they make it into the SCTP stack + */ #define SCTP_MIDDLEBOX_FLAG 0x02 #define SCTP_NAT_TABLE_COLLISION 0x00b0 #define SCTP_MISSING_NAT 0x00b1 - chunk_hdr->chunk_type = (sndrply & SN_TX_ABORT) ? SCTP_ABORT_ASSOCIATION : SCTP_OPERATION_ERROR; - chunk_hdr->chunk_flags = SCTP_MIDDLEBOX_FLAG; - if (include_error_cause) { - error_cause->code = htons((sndrply & SN_REFLECT_ERROR) ? SCTP_MISSING_NAT : SCTP_NAT_TABLE_COLLISION); - error_cause->length = htons(sizeof(struct sctp_error_cause)); - chunk_hdr->chunk_length = htons(sizeof(*chunk_hdr) + sizeof(struct sctp_error_cause)); - } else { - chunk_hdr->chunk_length = htons(sizeof(*chunk_hdr)); - } - - /* set specific values */ - switch(sndrply) { - case SN_REFLECT_ERROR: - chunk_hdr->chunk_flags |= SCTP_HAD_NO_TCB; /* set Tbit */ - sctp_hdr->v_tag = sm->sctp_hdr->v_tag; - break; - case SN_REPLY_ERROR: - sctp_hdr->v_tag = (direction == SN_TO_LOCAL) ? assoc->g_vtag : assoc->l_vtag ; - break; - case SN_SEND_ABORT: - sctp_hdr->v_tag = sm->sctp_hdr->v_tag; - break; - case SN_REPLY_ABORT: - sctp_hdr->v_tag = sm->sctpchnk.Init->initiate_tag; - break; - } + chunk_hdr->chunk_type = (sndrply & SN_TX_ABORT) ? SCTP_ABORT_ASSOCIATION : SCTP_OPERATION_ERROR; + chunk_hdr->chunk_flags = SCTP_MIDDLEBOX_FLAG; + if (include_error_cause) { + error_cause->code = htons((sndrply & SN_REFLECT_ERROR) ? SCTP_MISSING_NAT : SCTP_NAT_TABLE_COLLISION); + error_cause->length = htons(sizeof(struct sctp_error_cause)); + chunk_hdr->chunk_length = htons(sizeof(*chunk_hdr) + sizeof(struct sctp_error_cause)); + } else { + chunk_hdr->chunk_length = htons(sizeof(*chunk_hdr)); + } + + /* set specific values */ + switch(sndrply) { + case SN_REFLECT_ERROR: + chunk_hdr->chunk_flags |= SCTP_HAD_NO_TCB; /* set Tbit */ + sctp_hdr->v_tag = sm->sctp_hdr->v_tag; + break; + case SN_REPLY_ERROR: + sctp_hdr->v_tag = (direction == SN_TO_LOCAL) ? assoc->g_vtag : assoc->l_vtag ; + break; + case SN_SEND_ABORT: + sctp_hdr->v_tag = sm->sctp_hdr->v_tag; + break; + case SN_REPLY_ABORT: + sctp_hdr->v_tag = sm->sctpchnk.Init->initiate_tag; + break; + } - /* Set send/reply values */ - if (sndrply == SN_SEND_ABORT) { /*pass through NAT */ - ip->ip_src = (direction == SN_TO_LOCAL) ? sm->ip_hdr->ip_src : assoc->a_addr; - ip->ip_dst = (direction == SN_TO_LOCAL) ? assoc->l_addr : sm->ip_hdr->ip_dst; - sctp_hdr->src_port = sm->sctp_hdr->src_port; - sctp_hdr->dest_port = sm->sctp_hdr->dest_port; - } else { /* reply and reflect */ - ip->ip_src = sm->ip_hdr->ip_dst; - ip->ip_dst = sm->ip_hdr->ip_src; - sctp_hdr->src_port = sm->sctp_hdr->dest_port; - sctp_hdr->dest_port = sm->sctp_hdr->src_port; - } + /* Set send/reply values */ + if (sndrply == SN_SEND_ABORT) { /*pass through NAT */ + ip->ip_src = (direction == SN_TO_LOCAL) ? sm->ip_hdr->ip_src : assoc->a_addr; + ip->ip_dst = (direction == SN_TO_LOCAL) ? assoc->l_addr : sm->ip_hdr->ip_dst; + sctp_hdr->src_port = sm->sctp_hdr->src_port; + sctp_hdr->dest_port = sm->sctp_hdr->dest_port; + } else { /* reply and reflect */ + ip->ip_src = sm->ip_hdr->ip_dst; + ip->ip_dst = sm->ip_hdr->ip_src; + sctp_hdr->src_port = sm->sctp_hdr->dest_port; + sctp_hdr->dest_port = sm->sctp_hdr->src_port; + } - /* Calculate IP header checksum */ - ip->ip_sum = in_cksum_hdr(ip); + /* Calculate IP header checksum */ + ip->ip_sum = in_cksum_hdr(ip); - /* calculate SCTP header CRC32 */ - sctp_hdr->checksum = 0; - sctp_hdr->checksum = sctp_csum_finalize(update_crc32(0xffffffff, (unsigned char *) sctp_hdr, sctp_size)); - - memcpy(sm->ip_hdr, ip, ip_size); - - SN_LOG(SN_LOG_EVENT,SctpAliasLog("%s %s 0x%x (->%s:%u vtag=0x%x crc=0x%x)\n", - ((sndrply == SN_SEND_ABORT) ? "Sending" : "Replying"), - ((sndrply & SN_TX_ERROR) ? "ErrorM" : "AbortM"), - (include_error_cause ? ntohs(error_cause->code) : 0), - inet_ntoa(ip->ip_dst),ntohs(sctp_hdr->dest_port), - ntohl(sctp_hdr->v_tag), ntohl(sctp_hdr->checksum))); + /* calculate SCTP header CRC32 */ + sctp_hdr->checksum = 0; + sctp_hdr->checksum = sctp_csum_finalize(update_crc32(0xffffffff, (unsigned char *) sctp_hdr, sctp_size)); + + memcpy(sm->ip_hdr, ip, ip_size); + + SN_LOG(SN_LOG_EVENT,SctpAliasLog("%s %s 0x%x (->%s:%u vtag=0x%x crc=0x%x)\n", + ((sndrply == SN_SEND_ABORT) ? "Sending" : "Replying"), + ((sndrply & SN_TX_ERROR) ? "ErrorM" : "AbortM"), + (include_error_cause ? ntohs(error_cause->code) : 0), + inet_ntoa(ip->ip_dst),ntohs(sctp_hdr->dest_port), + ntohl(sctp_hdr->v_tag), ntohl(sctp_hdr->checksum))); } /* ---------------------------------------------------------------------- @@ -980,209 +980,209 @@ TxAbortErrorM(struct libalias *la, struc */ static int sctp_PktParser(struct libalias *la, int direction, struct ip *pip, - struct sctp_nat_msg *sm, struct sctp_nat_assoc **passoc) + struct sctp_nat_msg *sm, struct sctp_nat_assoc **passoc) //sctp_PktParser(int direction, struct mbuf *ipak, int ip_hdr_len,struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc) { - struct sctphdr *sctp_hdr; - struct sctp_chunkhdr *chunk_hdr; - struct sctp_paramhdr *param_hdr; - struct in_addr ipv4addr; - int bytes_left; /* bytes left in ip packet */ - int chunk_length; - int chunk_count; - int partial_match = 0; - // mbuf *mp; - // int mlen; - - // mlen = SCTP_HEADER_LEN(i_pak); - // mp = SCTP_HEADER_TO_CHAIN(i_pak); /* does nothing in bsd since header and chain not separate */ - - /* - * Note, that if the VTag is zero, it must be an INIT - * Also, I am only interested in the content of INIT and ADDIP chunks - */ - - // no mbuf stuff from Paolo yet so ... - sm->ip_hdr = pip; - /* remove ip header length from the bytes_left */ - bytes_left = ntohs(pip->ip_len) - (pip->ip_hl << 2); - - /* Check SCTP header length and move to first chunk */ - if (bytes_left < sizeof(struct sctphdr)) { - sm->sctp_hdr = NULL; - return(SN_PARSE_ERROR_IPSHL); /* packet not long enough*/ - } + struct sctphdr *sctp_hdr; + struct sctp_chunkhdr *chunk_hdr; + struct sctp_paramhdr *param_hdr; + struct in_addr ipv4addr; + int bytes_left; /* bytes left in ip packet */ + int chunk_length; + int chunk_count; + int partial_match = 0; + // mbuf *mp; + // int mlen; + + // mlen = SCTP_HEADER_LEN(i_pak); + // mp = SCTP_HEADER_TO_CHAIN(i_pak); /* does nothing in bsd since header and chain not separate */ + + /* + * Note, that if the VTag is zero, it must be an INIT + * Also, I am only interested in the content of INIT and ADDIP chunks + */ + + // no mbuf stuff from Paolo yet so ... + sm->ip_hdr = pip; + /* remove ip header length from the bytes_left */ + bytes_left = ntohs(pip->ip_len) - (pip->ip_hl << 2); + + /* Check SCTP header length and move to first chunk */ + if (bytes_left < sizeof(struct sctphdr)) { + sm->sctp_hdr = NULL; + return(SN_PARSE_ERROR_IPSHL); /* packet not long enough*/ + } - sm->sctp_hdr = sctp_hdr = (struct sctphdr *) ip_next(pip); - bytes_left -= sizeof(struct sctphdr); + sm->sctp_hdr = sctp_hdr = (struct sctphdr *) ip_next(pip); + bytes_left -= sizeof(struct sctphdr); - /* Check for valid ports (zero valued ports would find partially initialised associations */ - if (sctp_hdr->src_port == 0 || sctp_hdr->dest_port == 0) - return(SN_PARSE_ERROR_PORT); - - /* Check length of first chunk */ - if (bytes_left < SN_MIN_CHUNK_SIZE) /* malformed chunk - could cause endless loop*/ - return(SN_PARSE_ERROR_CHHL); /* packet not long enough for this chunk */ + /* Check for valid ports (zero valued ports would find partially initialised associations */ + if (sctp_hdr->src_port == 0 || sctp_hdr->dest_port == 0) + return(SN_PARSE_ERROR_PORT); + + /* Check length of first chunk */ + if (bytes_left < SN_MIN_CHUNK_SIZE) /* malformed chunk - could cause endless loop*/ + return(SN_PARSE_ERROR_CHHL); /* packet not long enough for this chunk */ - /* First chunk */ - chunk_hdr = SN_SCTP_FIRSTCHUNK(sctp_hdr); + /* First chunk */ + chunk_hdr = SN_SCTP_FIRSTCHUNK(sctp_hdr); - chunk_length = SCTP_SIZE32(ntohs(chunk_hdr->chunk_length)); - if ((chunk_length < SN_MIN_CHUNK_SIZE) || (chunk_length > bytes_left)) /* malformed chunk - could cause endless loop*/ - return(SN_PARSE_ERROR_CHHL); - - if ((chunk_hdr->chunk_flags & SCTP_HAD_NO_TCB) && - ((chunk_hdr->chunk_type == SCTP_ABORT_ASSOCIATION) || - (chunk_hdr->chunk_type == SCTP_SHUTDOWN_COMPLETE))) { - /* T-Bit set */ - if (direction == SN_TO_LOCAL) - *passoc = FindSctpGlobalT(la, pip->ip_src, sctp_hdr->v_tag, sctp_hdr->dest_port, sctp_hdr->src_port); - else - *passoc = FindSctpLocalT(la, pip->ip_dst, sctp_hdr->v_tag, sctp_hdr->dest_port, sctp_hdr->src_port); - } else { - /* Proper v_tag settings */ - if (direction == SN_TO_LOCAL) - *passoc = FindSctpGlobal(la, pip->ip_src, sctp_hdr->v_tag, sctp_hdr->src_port, sctp_hdr->dest_port, &partial_match); - else - *passoc = FindSctpLocal(la, pip->ip_src, pip->ip_dst, sctp_hdr->v_tag, sctp_hdr->src_port, sctp_hdr->dest_port); - } - - chunk_count = 1; - /* Real packet parsing occurs below */ - sm->msg = SN_SCTP_OTHER;/* Initialise to largest value*/ - sm->chunk_length = 0; /* only care about length for key chunks */ - while (IS_SCTP_CONTROL(chunk_hdr)) { - switch(chunk_hdr->chunk_type) { - case SCTP_INITIATION: - if (chunk_length < sizeof(struct sctp_init_chunk)) /* malformed chunk*/ - return(SN_PARSE_ERROR_CHHL); - sm->msg = SN_SCTP_INIT; - sm->sctpchnk.Init = (struct sctp_init *) ((char *) chunk_hdr + sizeof(struct sctp_chunkhdr)); - sm->chunk_length = chunk_length; - /* if no existing association, create a new one */ - if (*passoc == NULL) { - if (sctp_hdr->v_tag == 0){ //Init requires vtag=0 - *passoc = (struct sctp_nat_assoc *) sn_malloc(sizeof(struct sctp_nat_assoc)); - if (*passoc == NULL) {/* out of resources */ - return(SN_PARSE_ERROR_AS_MALLOC); - } - /* Initialise association - malloc initialises memory to zeros */ - (*passoc)->state = SN_ID; - LIST_INIT(&((*passoc)->Gaddr)); /* always initialise to avoid memory problems */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Mon Jan 5 15:02:07 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E6735106566C; Mon, 5 Jan 2009 15:02:06 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D1BA28FC17; Mon, 5 Jan 2009 15:02:06 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n05F26RK099542; Mon, 5 Jan 2009 15:02:06 GMT (envelope-from dfr@svn.freebsd.org) Received: (from dfr@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n05F25dQ099518; Mon, 5 Jan 2009 15:02:05 GMT (envelope-from dfr@svn.freebsd.org) Message-Id: <200901051502.n05F25dQ099518@svn.freebsd.org> From: Doug Rabson Date: Mon, 5 Jan 2009 15:02:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186780 - in user/dfr/xenhvm/6: . bin/cp contrib/bind9 contrib/ntp contrib/openpam contrib/sendmail contrib/tcsh contrib/telnet etc games/fortune/fortune include lib/libarchive lib/libb... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2009 15:02:07 -0000 Author: dfr Date: Mon Jan 5 15:02:05 2009 New Revision: 186780 URL: http://svn.freebsd.org/changeset/base/186780 Log: Merge r185180:186767 from projects/releng_6_xen Modified: user/dfr/xenhvm/6/ (props changed) user/dfr/xenhvm/6/Makefile.inc1 (props changed) user/dfr/xenhvm/6/bin/cp/ (props changed) user/dfr/xenhvm/6/contrib/bind9/ (props changed) user/dfr/xenhvm/6/contrib/ntp/ (props changed) user/dfr/xenhvm/6/contrib/openpam/ (props changed) user/dfr/xenhvm/6/contrib/sendmail/ (props changed) user/dfr/xenhvm/6/contrib/tcsh/ (props changed) user/dfr/xenhvm/6/contrib/telnet/ (props changed) user/dfr/xenhvm/6/etc/ (props changed) user/dfr/xenhvm/6/games/fortune/fortune/ (props changed) user/dfr/xenhvm/6/include/ (props changed) user/dfr/xenhvm/6/lib/libarchive/ (props changed) user/dfr/xenhvm/6/lib/libbluetooth/ (props changed) user/dfr/xenhvm/6/lib/libc/ (props changed) user/dfr/xenhvm/6/lib/libc/sys/ (props changed) user/dfr/xenhvm/6/lib/libexpat/ (props changed) user/dfr/xenhvm/6/lib/libfetch/ (props changed) user/dfr/xenhvm/6/lib/libftpio/ (props changed) user/dfr/xenhvm/6/lib/libgeom/ (props changed) user/dfr/xenhvm/6/lib/libpam/ (props changed) user/dfr/xenhvm/6/lib/libutil/ (props changed) user/dfr/xenhvm/6/libexec/rpc.rstatd/ (props changed) user/dfr/xenhvm/6/sbin/devfs/ (props changed) user/dfr/xenhvm/6/sbin/fdisk/ (props changed) user/dfr/xenhvm/6/sbin/ping6/ (props changed) user/dfr/xenhvm/6/sbin/routed/main.c (props changed) user/dfr/xenhvm/6/share/colldef/ (props changed) user/dfr/xenhvm/6/share/man/man4/ (props changed) user/dfr/xenhvm/6/share/man/man4/xl.4 (props changed) user/dfr/xenhvm/6/share/man/man5/ (props changed) user/dfr/xenhvm/6/share/man/man7/ports.7 (props changed) user/dfr/xenhvm/6/share/man/man9/ (props changed) user/dfr/xenhvm/6/share/mk/ (props changed) user/dfr/xenhvm/6/share/sendmail/ (props changed) user/dfr/xenhvm/6/share/syscons/keymaps/ (props changed) user/dfr/xenhvm/6/share/timedef/ (props changed) user/dfr/xenhvm/6/share/zoneinfo/ (props changed) user/dfr/xenhvm/6/sys/ (props changed) user/dfr/xenhvm/6/sys/conf/kern.pre.mk user/dfr/xenhvm/6/sys/dev/xen/blkfront/blkfront.c user/dfr/xenhvm/6/sys/dev/xen/console/console.c user/dfr/xenhvm/6/sys/dev/xen/console/xencons_ring.c user/dfr/xenhvm/6/sys/dev/xen/evtchn/evtchn_dev.c user/dfr/xenhvm/6/sys/dev/xen/netfront/netfront.c user/dfr/xenhvm/6/sys/i386/conf/XEN user/dfr/xenhvm/6/sys/i386/include/xen/xenfunc.h user/dfr/xenhvm/6/sys/i386/isa/npx.c user/dfr/xenhvm/6/sys/i386/xen/clock.c user/dfr/xenhvm/6/sys/i386/xen/mp_machdep.c user/dfr/xenhvm/6/sys/i386/xen/pmap.c user/dfr/xenhvm/6/sys/i386/xen/xen_machdep.c user/dfr/xenhvm/6/sys/kern/kern_condvar.c user/dfr/xenhvm/6/sys/kern/kern_lock.c user/dfr/xenhvm/6/sys/kern/kern_mutex.c user/dfr/xenhvm/6/sys/kern/kern_rwlock.c user/dfr/xenhvm/6/sys/kern/kern_sx.c user/dfr/xenhvm/6/sys/kern/kern_synch.c user/dfr/xenhvm/6/sys/kern/kern_timeout.c user/dfr/xenhvm/6/sys/sys/lock.h user/dfr/xenhvm/6/sys/sys/mutex.h user/dfr/xenhvm/6/sys/sys/sleepqueue.h user/dfr/xenhvm/6/sys/sys/sx.h user/dfr/xenhvm/6/sys/sys/systm.h user/dfr/xenhvm/6/sys/xen/evtchn.h user/dfr/xenhvm/6/sys/xen/evtchn/evtchn.c user/dfr/xenhvm/6/sys/xen/evtchn/evtchn_dev.c user/dfr/xenhvm/6/sys/xen/gnttab.c user/dfr/xenhvm/6/sys/xen/gnttab.h user/dfr/xenhvm/6/sys/xen/hypervisor.h user/dfr/xenhvm/6/sys/xen/interface/arch-x86/xen.h user/dfr/xenhvm/6/sys/xen/xen_intr.h user/dfr/xenhvm/6/sys/xen/xenbus/xenbus_comms.c user/dfr/xenhvm/6/sys/xen/xenbus/xenbus_comms.h user/dfr/xenhvm/6/sys/xen/xenbus/xenbus_if.m user/dfr/xenhvm/6/sys/xen/xenbus/xenbus_xs.c user/dfr/xenhvm/6/sys/xen/xenbus/xenbusvar.h user/dfr/xenhvm/6/tools/regression/usr.bin/ (props changed) user/dfr/xenhvm/6/tools/regression/usr.bin/calendar/ (props changed) user/dfr/xenhvm/6/usr.bin/calendar/ (props changed) user/dfr/xenhvm/6/usr.bin/cksum/ (props changed) user/dfr/xenhvm/6/usr.bin/fetch/ (props changed) user/dfr/xenhvm/6/usr.bin/gzip/ (props changed) user/dfr/xenhvm/6/usr.bin/ipcrm/ (props changed) user/dfr/xenhvm/6/usr.bin/ipcs/ (props changed) user/dfr/xenhvm/6/usr.bin/ldd/ (props changed) user/dfr/xenhvm/6/usr.bin/lockf/ (props changed) user/dfr/xenhvm/6/usr.bin/make/ (props changed) user/dfr/xenhvm/6/usr.bin/netstat/ (props changed) user/dfr/xenhvm/6/usr.bin/shar/ (props changed) user/dfr/xenhvm/6/usr.bin/su/ (props changed) user/dfr/xenhvm/6/usr.bin/tar/ (props changed) user/dfr/xenhvm/6/usr.bin/truncate/ (props changed) user/dfr/xenhvm/6/usr.bin/units/ (props changed) user/dfr/xenhvm/6/usr.bin/whereis/ (props changed) user/dfr/xenhvm/6/usr.bin/window/ (props changed) user/dfr/xenhvm/6/usr.sbin/adduser/ (props changed) user/dfr/xenhvm/6/usr.sbin/cdcontrol/ (props changed) user/dfr/xenhvm/6/usr.sbin/config/ (props changed) user/dfr/xenhvm/6/usr.sbin/cron/ (props changed) user/dfr/xenhvm/6/usr.sbin/freebsd-update/ (props changed) user/dfr/xenhvm/6/usr.sbin/mountd/ (props changed) user/dfr/xenhvm/6/usr.sbin/newsyslog/newsyslog.conf.5 (props changed) user/dfr/xenhvm/6/usr.sbin/ntp/ (props changed) user/dfr/xenhvm/6/usr.sbin/ntp/doc/ (props changed) user/dfr/xenhvm/6/usr.sbin/pkg_install/ (props changed) user/dfr/xenhvm/6/usr.sbin/portsnap/ (props changed) user/dfr/xenhvm/6/usr.sbin/pw/ (props changed) user/dfr/xenhvm/6/usr.sbin/rpc.lockd/ (props changed) user/dfr/xenhvm/6/usr.sbin/sysinstall/ (props changed) user/dfr/xenhvm/6/usr.sbin/syslogd/ (props changed) user/dfr/xenhvm/6/usr.sbin/tzsetup/ (props changed) Modified: user/dfr/xenhvm/6/sys/conf/kern.pre.mk ============================================================================== --- user/dfr/xenhvm/6/sys/conf/kern.pre.mk Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/conf/kern.pre.mk Mon Jan 5 15:02:05 2009 (r186780) @@ -20,12 +20,12 @@ SIZE?= size COPTFLAGS?= -O .else . if defined(DEBUG) -_MINUS_O= -O +_MINUS_O= -O -fno-optimize-sibling-calls . else _MINUS_O= -O2 . endif . if ${MACHINE_ARCH} == "amd64" -COPTFLAGS?=-O2 -frename-registers -pipe +COPTFLAGS?=${_MINUS_O} -frename-registers -pipe . else COPTFLAGS?=${_MINUS_O} -pipe . endif @@ -70,7 +70,7 @@ INCLUDES+= -I$S/dev/twa # .. and the same for em INCLUDES+= -I$S/dev/em -INCLUDES+= -I$S/xen/interface -I$S/xen/interface/io +INCLUDES+= -I$S/xen/interface -I$S/xen/interface/io -I$S/xen/interface/hvm CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} Modified: user/dfr/xenhvm/6/sys/dev/xen/blkfront/blkfront.c ============================================================================== --- user/dfr/xenhvm/6/sys/dev/xen/blkfront/blkfront.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/dev/xen/blkfront/blkfront.c Mon Jan 5 15:02:05 2009 (r186780) @@ -41,9 +41,8 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include - +#include #include #include #include @@ -1010,7 +1009,7 @@ blkif_free(struct blkfront_info *info, i info->ring.sring = NULL; } if (info->irq) - unbind_from_irqhandler(info->irq); + unbind_from_irqhandler(info->irq); info->irq = 0; } Modified: user/dfr/xenhvm/6/sys/dev/xen/console/console.c ============================================================================== --- user/dfr/xenhvm/6/sys/dev/xen/console/console.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/dev/xen/console/console.c Mon Jan 5 15:02:05 2009 (r186780) @@ -77,17 +77,17 @@ static unsigned int wc, wp; /* write_con #define XCUNIT(x) (minor(x)) #define ISTTYOPEN(tp) ((tp) && ((tp)->t_state & TS_ISOPEN)) #define CN_LOCK_INIT(x, _name) \ - mtx_init(&x, _name, NULL, MTX_SPIN|MTX_RECURSE) + mtx_init(&x, _name, NULL, MTX_DEF|MTX_RECURSE) #define CN_LOCK(l) \ do { \ if (panicstr == NULL) \ - mtx_lock_spin(&(l)); \ + mtx_lock(&(l)); \ } while (0) #define CN_UNLOCK(l) \ do { \ if (panicstr == NULL) \ - mtx_unlock_spin(&(l)); \ + mtx_unlock(&(l)); \ } while (0) #define CN_LOCK_ASSERT(x) mtx_assert(&x, MA_OWNED) #define CN_LOCK_DESTROY(x) mtx_destroy(&x) @@ -241,6 +241,7 @@ xc_probe(device_t dev) static int xc_attach(device_t dev) { + int error; struct xc_softc *sc = (struct xc_softc *)device_get_softc(dev); int error; @@ -267,9 +268,14 @@ xc_attach(device_t dev) callout_reset(&xc_callout, XC_POLLTIME, xc_timeout, xccons); if (xen_start_info->flags & SIF_INITDOMAIN) { - error = bind_virq_to_irqhandler(VIRQ_CONSOLE, 0, "console", - xencons_priv_interrupt, INTR_TYPE_TTY, NULL); - KASSERT(error >= 0, ("can't register console interrupt")); + error = bind_virq_to_irqhandler( + VIRQ_CONSOLE, + 0, + "console", + xencons_priv_interrupt, + INTR_TYPE_TTY, NULL); + + KASSERT(error >= 0, ("can't register console interrupt")); } /* register handler to flush console on shutdown */ Modified: user/dfr/xenhvm/6/sys/dev/xen/console/xencons_ring.c ============================================================================== --- user/dfr/xenhvm/6/sys/dev/xen/console/xencons_ring.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/dev/xen/console/xencons_ring.c Mon Jan 5 15:02:05 2009 (r186780) @@ -18,17 +18,22 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include #include +#include +#include #define console_evtchn console.domU.evtchn static unsigned int console_irq; extern char *console_page; - +extern struct mtx cn_mtx; + static inline struct xencons_interface * xencons_interface(void) { @@ -84,6 +89,7 @@ xencons_handle_input(void *unused) struct xencons_interface *intf; XENCONS_RING_IDX cons, prod; + mtx_lock(&cn_mtx); intf = xencons_interface(); cons = intf->in_cons; @@ -101,6 +107,7 @@ xencons_handle_input(void *unused) notify_remote_via_evtchn(xen_start_info->console_evtchn); xencons_tx(); + mtx_unlock(&cn_mtx); } void Modified: user/dfr/xenhvm/6/sys/dev/xen/evtchn/evtchn_dev.c ============================================================================== --- user/dfr/xenhvm/6/sys/dev/xen/evtchn/evtchn_dev.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/dev/xen/evtchn/evtchn_dev.c Mon Jan 5 15:02:05 2009 (r186780) @@ -26,13 +26,13 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include #include -#include +#include typedef struct evtchn_sotfc { Modified: user/dfr/xenhvm/6/sys/dev/xen/netfront/netfront.c ============================================================================== --- user/dfr/xenhvm/6/sys/dev/xen/netfront/netfront.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/dev/xen/netfront/netfront.c Mon Jan 5 15:02:05 2009 (r186780) @@ -63,10 +63,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include -#include -#include - #include #include #include @@ -357,7 +355,7 @@ makembuf (struct mbuf *buf) m_copydata(buf, 0, buf->m_pkthdr.len, mtod(m,caddr_t) ); m->m_ext.ext_args = (caddr_t *)(uintptr_t)(vtophys(mtod(m,caddr_t)) >> PAGE_SHIFT); - + return m; } @@ -575,14 +573,14 @@ setup_device(device_t dev, struct netfro goto fail; error = bind_listening_port_to_irqhandler(xenbus_get_otherend_id(dev), - "xn", xn_intr, info, INTR_TYPE_NET | INTR_MPSAFE, &info->irq); + "xn", xn_intr, info, INTR_TYPE_NET | INTR_MPSAFE, &info->irq); if (error) { xenbus_dev_fatal(dev, error, "bind_evtchn_to_irqhandler failed"); goto fail; } - + show_device(info); return (0); @@ -1450,9 +1448,9 @@ xn_ioctl(struct ifnet *ifp, u_long cmd, if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) xn_ifinit_locked(sc); arp_ifinit(ifp, ifa); - XN_UNLOCK(sc); + XN_UNLOCK(sc); } else { - XN_UNLOCK(sc); + XN_UNLOCK(sc); error = ether_ioctl(ifp, cmd, data); } break; @@ -1779,8 +1777,6 @@ static void netif_free(struct netfront_i #endif } - - static void netif_disconnect_backend(struct netfront_info *info) { XN_RX_LOCK(info); @@ -1798,6 +1794,7 @@ static void netif_disconnect_backend(str if (info->irq) unbind_from_irqhandler(info->irq); + info->irq = 0; } Modified: user/dfr/xenhvm/6/sys/i386/conf/XEN ============================================================================== --- user/dfr/xenhvm/6/sys/i386/conf/XEN Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/i386/conf/XEN Mon Jan 5 15:02:05 2009 (r186780) @@ -67,8 +67,8 @@ options GDB # Support remote GDB. #options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed # To make an SMP kernel, the next two lines are needed -options SMP # Symmetric MultiProcessor Kernel -device apic # I/O APIC +#options SMP # Symmetric MultiProcessor Kernel +#device apic # I/O APIC options PAE @@ -153,3 +153,4 @@ options KTR_COMPILE=(KTR_PMAP) options KTR_CPUMASK=0xff options KTR_ENTRIES=65536 options KTR_MASK=(KTR_PMAP) +options KVA_PAGES=1600 Modified: user/dfr/xenhvm/6/sys/i386/include/xen/xenfunc.h ============================================================================== --- user/dfr/xenhvm/6/sys/i386/include/xen/xenfunc.h Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/i386/include/xen/xenfunc.h Mon Jan 5 15:02:05 2009 (r186780) @@ -30,6 +30,11 @@ #ifndef _XEN_XENFUNC_H_ #define _XEN_XENFUNC_H_ +#include +#include +#include +#include +#include #define BKPT __asm__("int3"); #define XPQ_CALL_DEPTH 5 #define XPQ_CALL_COUNT 2 Modified: user/dfr/xenhvm/6/sys/i386/isa/npx.c ============================================================================== --- user/dfr/xenhvm/6/sys/i386/isa/npx.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/i386/isa/npx.c Mon Jan 5 15:02:05 2009 (r186780) @@ -69,8 +69,8 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef XEN #include +#ifdef XEN #include #endif #ifdef DEV_ISA Modified: user/dfr/xenhvm/6/sys/i386/xen/clock.c ============================================================================== --- user/dfr/xenhvm/6/sys/i386/xen/clock.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/i386/xen/clock.c Mon Jan 5 15:02:05 2009 (r186780) @@ -295,11 +295,12 @@ static struct timecounter xen_timecounte }; static void -clkintr(struct clockframe *frame) +clkintr(void *arg) { int64_t delta_cpu, delta; struct shadow_time_info *shadow = PCPU_PTR(shadow_time); - + struct clockframe *frame = (struct clockframe *)arg; + do { __get_time_values_from_xen(); @@ -839,7 +840,8 @@ static struct vcpu_set_periodic_timer xe void cpu_initclocks(void) { - + int error; + xen_set_periodic_tick.period_ns = NS_PER_TICK; HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, 0, @@ -849,11 +851,11 @@ cpu_initclocks(void) unbind_from_irqhandler(time_irq); time_irq = 0; - if (bind_virq_to_irqhandler(VIRQ_TIMER, 0, "clk", - (driver_intr_t *)clkintr, INTR_TYPE_CLK | INTR_FAST, - &time_irq)) { + error = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "clk", + clkintr, + INTR_TYPE_CLK | INTR_FAST, &time_irq); + if (error) panic("failed to register clock interrupt\n"); - } /* should fast clock be enabled ? */ } @@ -861,23 +863,23 @@ cpu_initclocks(void) int ap_cpu_initclocks(int cpu) { - int time_irq; + unsigned int time_irq; + int error; xen_set_periodic_tick.period_ns = NS_PER_TICK; HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, cpu, &xen_set_periodic_tick); - - if ((time_irq = bind_virq_to_irqhandler(VIRQ_TIMER, cpu, "clk", - (driver_intr_t *)clkintr, - INTR_TYPE_CLK | INTR_FAST, NULL)) < 0) { + error = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "clk", + clkintr, + INTR_TYPE_CLK | INTR_FAST, &time_irq); + if (error) panic("failed to register clock interrupt\n"); - } + return (0); } - void cpu_startprofclock(void) { Modified: user/dfr/xenhvm/6/sys/i386/xen/mp_machdep.c ============================================================================== --- user/dfr/xenhvm/6/sys/i386/xen/mp_machdep.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/i386/xen/mp_machdep.c Mon Jan 5 15:02:05 2009 (r186780) @@ -83,9 +83,10 @@ __FBSDID("$FreeBSD$"); #include #include - #include #include +#include +#include #include #define WARMBOOT_TARGET 0 @@ -557,25 +558,31 @@ static int xen_smp_intr_init(unsigned int cpu) { int rc; - struct pcpu *pc = pcpu_find(cpu); - + unsigned int irq; + pc->pc_resched_irq = pc->pc_callfunc_irq = ~0; sprintf(resched_name[cpu], "resched%u", cpu); - rc = bind_ipi_to_irqhandler(RESCHEDULE_VECTOR, cpu, - resched_name[cpu], smp_reschedule_interrupt, - INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE, &pc->pc_resched_irq); + rc = bind_ipi_to_irqhandler(RESCHEDULE_VECTOR, + cpu, + resched_name[cpu], + smp_reschedule_interrupt, + INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE, &irq); printf("cpu=%d irq=%d vector=%d\n", cpu, pc->pc_resched_irq, RESCHEDULE_VECTOR); + per_cpu(resched_irq, cpu) = irq; + sprintf(callfunc_name[cpu], "callfunc%u", cpu); - rc = bind_ipi_to_irqhandler(CALL_FUNCTION_VECTOR, cpu, - callfunc_name[cpu], - smp_call_function_interrupt, - INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE, &pc->pc_callfunc_irq); + rc = bind_ipi_to_irqhandler(CALL_FUNCTION_VECTOR, + cpu, + callfunc_name[cpu], + smp_call_function_interrupt, + INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE, &irq); if (rc < 0) goto fail; + per_cpu(callfunc_irq, cpu) = irq; printf("cpu=%d irq=%d vector=%d\n", cpu, pc->pc_callfunc_irq, CALL_FUNCTION_VECTOR); @@ -586,10 +593,10 @@ xen_smp_intr_init(unsigned int cpu) return 0; fail: - if (pc->pc_resched_irq != ~0) - unbind_from_irqhandler(pc->pc_resched_irq); - if (pc->pc_callfunc_irq != ~0) - unbind_from_irqhandler(pc->pc_callfunc_irq); + if (per_cpu(resched_irq, cpu) >= 0) + unbind_from_irqhandler(per_cpu(resched_irq, cpu)); + if (per_cpu(callfunc_irq, cpu) >= 0) + unbind_from_irqhandler(per_cpu(callfunc_irq, cpu)); return rc; } Modified: user/dfr/xenhvm/6/sys/i386/xen/pmap.c ============================================================================== --- user/dfr/xenhvm/6/sys/i386/xen/pmap.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/i386/xen/pmap.c Mon Jan 5 15:02:05 2009 (r186780) @@ -159,6 +159,16 @@ __FBSDID("$FreeBSD$"); #include #endif +#ifdef XBOX +#include +#endif + +#include +#include +#include +#include +#include + #if !defined(CPU_DISABLE_SSE) && defined(I686_CPU) #define CPU_ENABLE_SSE #endif Modified: user/dfr/xenhvm/6/sys/i386/xen/xen_machdep.c ============================================================================== --- user/dfr/xenhvm/6/sys/i386/xen/xen_machdep.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/i386/xen/xen_machdep.c Mon Jan 5 15:02:05 2009 (r186780) @@ -413,10 +413,11 @@ void _xen_queue_pt_update(vm_paddr_t ptr, vm_paddr_t val, char *file, int line) { SET_VCPU(); - +#if 0 if (__predict_true(gdtset)) mtx_assert(&vm_page_queue_mtx, MA_OWNED); - +#endif + KASSERT((ptr & 7) == 0, ("misaligned update")); if (__predict_true(gdtset)) @@ -925,6 +926,39 @@ initvalues(start_info_t *startinfo) xen_start_info = startinfo; xen_phys_machine = (xen_pfn_t *)startinfo->mfn_list; + IdlePTD = (pd_entry_t *)((uint8_t *)startinfo->pt_base + PAGE_SIZE); + l1_pages = 0; + +#ifdef PAE + l3_pages = 1; + l2_pages = 0; + IdlePDPT = (pd_entry_t *)startinfo->pt_base; + IdlePDPTma = xpmap_ptom(VTOP(startinfo->pt_base)); + for (i = (KERNBASE >> 30); + (i < 4) && (IdlePDPT[i] != 0); i++) + l2_pages++; + /* + * Note that only one page directory has been allocated at this point. + * Thus, if KERNBASE + */ +#if 0 + for (i = 0; i < l2_pages; i++) + IdlePTDma[i] = xpmap_ptom(VTOP(IdlePTD + i*PAGE_SIZE)); +#endif + + l2_pages = (l2_pages == 0) ? 1 : l2_pages; +#else + l3_pages = 0; + l2_pages = 1; +#endif + for (i = (((KERNBASE>>18) & PAGE_MASK)>>PAGE_SHIFT); + (i>PDRSHIFT)); i++) { + + if (IdlePTD[i] == 0) + break; + l1_pages++; + } + /* number of pages allocated after the pts + 1*/; cur_space = xen_start_info->pt_base + ((xen_start_info->nr_pt_frames) + 3 )*PAGE_SIZE; Modified: user/dfr/xenhvm/6/sys/kern/kern_condvar.c ============================================================================== --- user/dfr/xenhvm/6/sys/kern/kern_condvar.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/kern/kern_condvar.c Mon Jan 5 15:02:05 2009 (r186780) @@ -124,8 +124,7 @@ cv_wait(struct cv *cvp, struct mtx *mp) DROP_GIANT(); mtx_unlock(mp); - sleepq_add(cvp, &mp->mtx_object, cvp->cv_description, SLEEPQ_CONDVAR, - 0); + sleepq_add(cvp, &mp->mtx_object, cvp->cv_description, SLEEPQ_CONDVAR, 0); sleepq_wait(cvp); #ifdef KTRACE @@ -232,8 +231,7 @@ cv_timedwait(struct cv *cvp, struct mtx DROP_GIANT(); mtx_unlock(mp); - sleepq_add(cvp, &mp->mtx_object, cvp->cv_description, SLEEPQ_CONDVAR, - 0); + sleepq_add(cvp, &mp->mtx_object, cvp->cv_description, SLEEPQ_CONDVAR, 0); sleepq_set_timeout(cvp, timo); rval = sleepq_timedwait(cvp); Modified: user/dfr/xenhvm/6/sys/kern/kern_lock.c ============================================================================== --- user/dfr/xenhvm/6/sys/kern/kern_lock.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/kern/kern_lock.c Mon Jan 5 15:02:05 2009 (r186780) @@ -62,6 +62,43 @@ __FBSDID("$FreeBSD$"); #include #endif + +#ifdef DDB +#include +static void db_show_lockmgr(struct lock_object *lock); +#endif +static void lock_lockmgr(struct lock_object *lock, int how); +static int unlock_lockmgr(struct lock_object *lock); + +struct lock_class lock_class_lockmgr = { + .lc_name = "lockmgr", + .lc_flags = LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE | LC_UPGRADABLE, +#ifdef DDB + .lc_ddb_show = db_show_lockmgr, +#endif + .lc_lock = lock_lockmgr, + .lc_unlock = unlock_lockmgr, +}; + +/* + * Locking primitives implementation. + * Locks provide shared/exclusive sychronization. + */ + +void +lock_lockmgr(struct lock_object *lock, int how) +{ + + panic("lockmgr locks do not support sleep interlocking"); +} + +int +unlock_lockmgr(struct lock_object *lock) +{ + + panic("lockmgr locks do not support sleep interlocking"); +} + /* * Locking primitives implementation. * Locks provide shared/exclusive sychronization. @@ -639,14 +676,13 @@ ok: return (1); } -DB_SHOW_COMMAND(lockmgr, db_show_lockmgr) +void +db_show_lockmgr(struct lock_object *lock) { struct thread *td; struct lock *lkp; - if (!have_addr) - return; - lkp = (struct lock *)addr; + lkp = (struct lock *)lock; db_printf("lock type: %s\n", lkp->lk_wmesg); db_printf("state: "); Modified: user/dfr/xenhvm/6/sys/kern/kern_mutex.c ============================================================================== --- user/dfr/xenhvm/6/sys/kern/kern_mutex.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/kern/kern_mutex.c Mon Jan 5 15:02:05 2009 (r186780) @@ -92,25 +92,66 @@ __FBSDID("$FreeBSD$"); #ifdef DDB static void db_show_mtx(struct lock_object *lock); #endif +static void lock_mtx(struct lock_object *lock, int how); +static void lock_spin(struct lock_object *lock, int how); +static int unlock_mtx(struct lock_object *lock); +static int unlock_spin(struct lock_object *lock); + /* * Lock classes for sleep and spin mutexes. */ struct lock_class lock_class_mtx_sleep = { - "sleep mutex", - LC_SLEEPLOCK | LC_RECURSABLE, + .lc_name = "sleep mutex", + .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE, #ifdef DDB - db_show_mtx + .lc_ddb_show = db_show_mtx, #endif + .lc_lock = lock_mtx, + .lc_unlock = unlock_mtx, }; struct lock_class lock_class_mtx_spin = { - "spin mutex", - LC_SPINLOCK | LC_RECURSABLE, + .lc_name = "spin mutex", + .lc_flags = LC_SPINLOCK | LC_RECURSABLE, #ifdef DDB - db_show_mtx + .lc_ddb_show = db_show_mtx, #endif + .lc_lock = lock_spin, + .lc_unlock = unlock_spin, }; +void +lock_mtx(struct lock_object *lock, int how) +{ + + mtx_lock((struct mtx *)lock); +} + +void +lock_spin(struct lock_object *lock, int how) +{ + + panic("spin locks can only use msleep_spin"); +} + +int +unlock_mtx(struct lock_object *lock) +{ + struct mtx *m; + + m = (struct mtx *)lock; + mtx_assert(m, MA_OWNED | MA_NOTRECURSED); + mtx_unlock(m); + return (0); +} + +int +unlock_spin(struct lock_object *lock) +{ + + panic("spin locks can only use msleep_spin"); +} + /* * System-wide mutexes */ Modified: user/dfr/xenhvm/6/sys/kern/kern_rwlock.c ============================================================================== --- user/dfr/xenhvm/6/sys/kern/kern_rwlock.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/kern/kern_rwlock.c Mon Jan 5 15:02:05 2009 (r186780) @@ -60,13 +60,19 @@ CTASSERT((RW_RECURSE & LO_CLASSFLAGS) == static void db_show_rwlock(struct lock_object *lock); #endif +static void lock_rw(struct lock_object *lock, int how); +static int unlock_rw(struct lock_object *lock); + struct lock_class lock_class_rw = { .lc_name = "rw", .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE | LC_UPGRADABLE, #ifdef DDB .lc_ddb_show = db_show_rwlock, #endif + .lc_lock = lock_rw, + .lc_unlock = unlock_rw }; + /* * Return a pointer to the owning thread if the lock is write-locked or @@ -99,6 +105,34 @@ struct lock_class lock_class_rw = { #endif void +lock_rw(struct lock_object *lock, int how) +{ + struct rwlock *rw; + + rw = (struct rwlock *)lock; + if (how) + rw_wlock(rw); + else + rw_rlock(rw); +} + +int +unlock_rw(struct lock_object *lock) +{ + struct rwlock *rw; + + rw = (struct rwlock *)lock; + rw_assert(rw, RA_LOCKED | LA_NOTRECURSED); + if (rw->rw_lock & RW_LOCK_READ) { + rw_runlock(rw); + return (0); + } else { + rw_wunlock(rw); + return (1); + } +} + +void rw_init_flags(struct rwlock *rw, const char *name, int opts) { int flags; Modified: user/dfr/xenhvm/6/sys/kern/kern_sx.c ============================================================================== --- user/dfr/xenhvm/6/sys/kern/kern_sx.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/kern/kern_sx.c Mon Jan 5 15:02:05 2009 (r186780) @@ -108,12 +108,17 @@ CTASSERT(((SX_ADAPTIVESPIN | SX_RECURSE) static void db_show_sx(struct lock_object *lock); #endif +static void lock_sx(struct lock_object *lock, int how); +static int unlock_sx(struct lock_object *lock); + struct lock_class lock_class_sx = { .lc_name = "sx", .lc_flags = LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE | LC_UPGRADABLE, #ifdef DDB .lc_ddb_show = db_show_sx, #endif + .lc_lock = lock_sx, + .lc_unlock = unlock_sx, }; #ifndef INVARIANTS @@ -121,6 +126,34 @@ struct lock_class lock_class_sx = { #endif void +lock_sx(struct lock_object *lock, int how) +{ + struct sx *sx; + + sx = (struct sx *)lock; + if (how) + sx_xlock(sx); + else + sx_slock(sx); +} + +int +unlock_sx(struct lock_object *lock) +{ + struct sx *sx; + + sx = (struct sx *)lock; + sx_assert(sx, SA_LOCKED | SA_NOTRECURSED); + if (sx_xlocked(sx)) { + sx_xunlock(sx); + return (1); + } else { + sx_sunlock(sx); + return (0); + } +} + +void sx_sysinit(void *arg) { struct sx_args *sargs = arg; @@ -845,6 +878,7 @@ _sx_sunlock_hard(struct sx *sx, const ch } } +#if 0 /* * Atomically drop an sx lock while going to sleep. This is just a hack * for 6.x. In 7.0 and later this is done more cleanly. @@ -961,6 +995,7 @@ sx_sleep(void *ident, struct sx *sx, int } return (rval); } +#endif #ifdef INVARIANT_SUPPORT #ifndef INVARIANTS Modified: user/dfr/xenhvm/6/sys/kern/kern_synch.c ============================================================================== --- user/dfr/xenhvm/6/sys/kern/kern_synch.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/kern/kern_synch.c Mon Jan 5 15:02:05 2009 (r186780) @@ -75,6 +75,7 @@ SYSINIT(synch_setup, SI_SUB_KICK_SCHEDUL int hogticks; int lbolt; +static int pause_wchan; static struct callout loadav_callout; static struct callout lbolt_callout; @@ -106,6 +107,143 @@ sleepinit(void) init_sleepqueues(); } + +/* + * General sleep call. Suspends the current thread until a wakeup is + * performed on the specified identifier. The thread will then be made + * runnable with the specified priority. Sleeps at most timo/hz seconds + * (0 means no timeout). If pri includes PCATCH flag, signals are checked + * before and after sleeping, else signals are not checked. Returns 0 if + * awakened, EWOULDBLOCK if the timeout expires. If PCATCH is set and a + * signal needs to be delivered, ERESTART is returned if the current system + * call should be restarted if possible, and EINTR is returned if the system + * call should be interrupted by the signal (return EINTR). + * + * The lock argument is unlocked before the caller is suspended, and + * re-locked before _sleep() returns. If priority includes the PDROP + * flag the lock is not re-locked before returning. + */ +int +_sleep(void *ident, struct lock_object *lock, int priority, + const char *wmesg, int timo) +{ + struct thread *td; + struct proc *p; + struct lock_class *class; + int catch, flags, lock_state, pri, rval; + WITNESS_SAVE_DECL(lock_witness); + + td = curthread; + p = td->td_proc; +#ifdef KTRACE + if (KTRPOINT(td, KTR_CSW)) + ktrcsw(1, 0); +#endif + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock, + "Sleeping on \"%s\"", wmesg); + KASSERT(timo != 0 || mtx_owned(&Giant) || lock != NULL || + ident == &lbolt, ("sleeping without a lock")); + KASSERT(p != NULL, ("msleep1")); + KASSERT(ident != NULL && TD_IS_RUNNING(td), ("msleep")); + if (lock != NULL) + class = LOCK_CLASS(lock); + else + class = NULL; + + if (cold) { + /* + * During autoconfiguration, just return; + * don't run any other threads or panic below, + * in case this is the idle thread and already asleep. + * XXX: this used to do "s = splhigh(); splx(safepri); + * splx(s);" to give interrupts a chance, but there is + * no way to give interrupts a chance now. + */ + if (lock != NULL && priority & PDROP) + class->lc_unlock(lock); + return (0); + } + catch = priority & PCATCH; + rval = 0; + + /* + * If we are already on a sleep queue, then remove us from that + * sleep queue first. We have to do this to handle recursive + * sleeps. + */ + if (TD_ON_SLEEPQ(td)) + sleepq_remove(td, td->td_wchan); + + if (ident == &pause_wchan) + flags = SLEEPQ_PAUSE; + else + flags = SLEEPQ_SLEEP; + if (catch) + flags |= SLEEPQ_INTERRUPTIBLE; + + sleepq_lock(ident); + CTR5(KTR_PROC, "sleep: thread %ld (pid %ld, %s) on %s (%p)", + td->td_tid, p->p_pid, p->p_comm, wmesg, ident); + + DROP_GIANT(); + if (lock != NULL && !(class->lc_flags & LC_SLEEPABLE)) { + WITNESS_SAVE(lock, lock_witness); + lock_state = class->lc_unlock(lock); + } else + /* GCC needs to follow the Yellow Brick Road */ + lock_state = -1; + + /* + * We put ourselves on the sleep queue and start our timeout + * before calling thread_suspend_check, as we could stop there, + * and a wakeup or a SIGCONT (or both) could occur while we were + * stopped without resuming us. Thus, we must be ready for sleep + * when cursig() is called. If the wakeup happens while we're + * stopped, then td will no longer be on a sleep queue upon + * return from cursig(). + */ + sleepq_add(ident, ident == &lbolt ? NULL : lock, wmesg, flags, 0); + if (timo) + sleepq_set_timeout(ident, timo); + if (lock != NULL && class->lc_flags & LC_SLEEPABLE) { + sleepq_release(ident); + WITNESS_SAVE(lock, lock_witness); + lock_state = class->lc_unlock(lock); + sleepq_lock(ident); + } + + /* + * Adjust this thread's priority, if necessary. + */ + pri = priority & PRIMASK; + if (pri != 0 && pri != td->td_priority) { + mtx_lock_spin(&sched_lock); + sched_prio(td, pri); + mtx_unlock_spin(&sched_lock); + } + + if (timo && catch) + rval = sleepq_timedwait_sig(ident); + else if (timo) + rval = sleepq_timedwait(ident); + else if (catch) + rval = sleepq_wait_sig(ident); + else { + sleepq_wait(ident); + rval = 0; + } +#ifdef KTRACE + if (KTRPOINT(td, KTR_CSW)) + ktrcsw(0, 0); +#endif + PICKUP_GIANT(); + if (lock != NULL && !(priority & PDROP)) { + class->lc_lock(lock, lock_state); + WITNESS_RESTORE(lock, lock_witness); + } + return (rval); +} + /* * General sleep call. Suspends the current process until a wakeup is * performed on the specified identifier. The process will then be made @@ -170,7 +308,7 @@ msleep(ident, mtx, priority, wmesg, timo if (TD_ON_SLEEPQ(td)) sleepq_remove(td, td->td_wchan); - flags = SLEEPQ_MSLEEP; + flags = SLEEPQ_SLEEP; if (catch) flags |= SLEEPQ_INTERRUPTIBLE; @@ -271,7 +409,7 @@ msleep_spin(ident, mtx, wmesg, timo) /* * We put ourselves on the sleep queue and start our timeout. */ - sleepq_add(ident, &mtx->mtx_object, wmesg, SLEEPQ_MSLEEP, 0); + sleepq_add(ident, &mtx->mtx_object, wmesg, SLEEPQ_SLEEP, 0); if (timo) sleepq_set_timeout(ident, timo); @@ -320,7 +458,7 @@ wakeup(ident) { sleepq_lock(ident); - sleepq_broadcast(ident, SLEEPQ_MSLEEP, -1, 0); + sleepq_broadcast(ident, SLEEPQ_SLEEP, -1, 0); } /* @@ -334,7 +472,7 @@ wakeup_one(ident) { sleepq_lock(ident); - sleepq_signal(ident, SLEEPQ_MSLEEP, -1, 0); + sleepq_signal(ident, SLEEPQ_SLEEP, -1, 0); } /* Modified: user/dfr/xenhvm/6/sys/kern/kern_timeout.c ============================================================================== --- user/dfr/xenhvm/6/sys/kern/kern_timeout.c Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/kern/kern_timeout.c Mon Jan 5 15:02:05 2009 (r186780) @@ -557,7 +557,7 @@ again: mtx_unlock_spin(&callout_lock); sleepq_add(&callout_wait, &callout_lock.mtx_object, "codrain", - SLEEPQ_MSLEEP, 0); + SLEEPQ_SLEEP, 0); sleepq_wait(&callout_wait); sq_locked = 0; Modified: user/dfr/xenhvm/6/sys/sys/lock.h ============================================================================== --- user/dfr/xenhvm/6/sys/sys/lock.h Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/sys/lock.h Mon Jan 5 15:02:05 2009 (r186780) @@ -51,6 +51,8 @@ struct lock_class { const char *lc_name; u_int lc_flags; void (*lc_ddb_show)(struct lock_object *lock); + void (*lc_lock)(struct lock_object *lock, int how); + int (*lc_unlock)(struct lock_object *lock); }; #define LC_SLEEPLOCK 0x00000001 /* Sleep lock. */ Modified: user/dfr/xenhvm/6/sys/sys/mutex.h ============================================================================== --- user/dfr/xenhvm/6/sys/sys/mutex.h Mon Jan 5 14:48:43 2009 (r186779) +++ user/dfr/xenhvm/6/sys/sys/mutex.h Mon Jan 5 15:02:05 2009 (r186780) @@ -325,6 +325,9 @@ extern struct mtx_pool *mtxpool_sleep; #define mtx_trylock_flags(m, opts) \ _mtx_trylock((m), (opts), LOCK_FILE, LOCK_LINE) +#define mtx_sleep(chan, mtx, pri, wmesg, timo) \ + _sleep((chan), &(mtx)->mtx_object, (pri), (wmesg), (timo)) + #define mtx_initialized(m) lock_initalized(&(m)->mtx_object) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Tue Jan 6 12:17:44 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 129101065674; Tue, 6 Jan 2009 12:17:44 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 011768FC14; Tue, 6 Jan 2009 12:17:44 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n06CHhWR030454; Tue, 6 Jan 2009 12:17:43 GMT (envelope-from dfr@svn.freebsd.org) Received: (from dfr@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n06CHh9I030453; Tue, 6 Jan 2009 12:17:43 GMT (envelope-from dfr@svn.freebsd.org) Message-Id: <200901061217.n06CHh9I030453@svn.freebsd.org> From: Doug Rabson Date: Tue, 6 Jan 2009 12:17:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186814 - user/dfr/xenhvm/6/sys/amd64/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Jan 2009 12:17:44 -0000 Author: dfr Date: Tue Jan 6 12:17:43 2009 New Revision: 186814 URL: http://svn.freebsd.org/changeset/base/186814 Log: Add a config file for a kernel suitable for a Xen HVM guest. Added: user/dfr/xenhvm/6/sys/amd64/conf/XENHVM Added: user/dfr/xenhvm/6/sys/amd64/conf/XENHVM ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/dfr/xenhvm/6/sys/amd64/conf/XENHVM Tue Jan 6 12:17:43 2009 (r186814) @@ -0,0 +1,140 @@ +# +# GENERIC -- Generic kernel configuration file for FreeBSD/amd64 +# +# For more information on this file, please read the handbook section on +# Kernel Configuration Files: +# +# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# +# The handbook is also available locally in /usr/share/doc/handbook +# if you've installed the doc distribution, otherwise always see the +# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the +# latest information. +# +# An exhaustive list of options and more detailed explanations of the +# device lines is also present in the ../../conf/NOTES and NOTES files. +# If you are in doubt as to the purpose or necessity of a line, check first +# in NOTES. +# +# $FreeBSD$ + +machine amd64 +cpu HAMMER +ident XENHVM + +# To statically compile in device wiring instead of /boot/device.hints +#hints "GENERIC.hints" # Default places to look for devices. + +makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols +makeoptions MODULES_OVERRIDE="" + +options SCHED_4BSD # 4BSD scheduler +options PREEMPTION # Enable kernel thread preemption +options INET # InterNETworking +options INET6 # IPv6 communications protocols +options FFS # Berkeley Fast Filesystem +options SOFTUPDATES # Enable FFS soft updates support +options UFS_ACL # Support for access control lists +options UFS_DIRHASH # Improve performance on big directories +options MD_ROOT # MD is a potential root device +options NFSCLIENT # Network Filesystem Client +options NFSSERVER # Network Filesystem Server +options NFSLOCKD # Network Lock Manager +options NFS_ROOT # NFS usable as /, requires NFSCLIENT +options NTFS # NT File System +options MSDOSFS # MSDOS Filesystem +options CD9660 # ISO 9660 Filesystem +options PROCFS # Process filesystem (requires PSEUDOFS) +options PSEUDOFS # Pseudo-filesystem framework +options GEOM_GPT # GUID Partition Tables. +options COMPAT_43 # Needed by COMPAT_LINUX32 +options COMPAT_IA32 # Compatible with i386 binaries +options COMPAT_FREEBSD4 # Compatible with FreeBSD4 +options COMPAT_FREEBSD5 # Compatible with FreeBSD5 +options COMPAT_LINUX32 # Compatible with i386 linux binaries +options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI +options KTRACE # ktrace(1) support +options SYSVSHM # SYSV-style shared memory +options SYSVMSG # SYSV-style message queues +options SYSVSEM # SYSV-style semaphores +options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions +options KBD_INSTALL_CDEV # install a CDEV entry in /dev +options ADAPTIVE_GIANT # Giant mutex is adaptive. + +options KDB +options DDB + +# Workarounds for some known-to-be-broken chipsets (nVidia nForce3-Pro150) +device atpic # 8259A compatability + +# Linux 32-bit ABI support +options LINPROCFS # Cannot be a module yet. + +# Bus support. +device acpi +device pci + +# Floppy drives +#device fdc + +# Xen HVM support +options XENHVM +device xenpci + +# ATA and ATAPI devices +device ata +device atadisk # ATA disk drives +device ataraid # ATA RAID drives +device atapicd # ATAPI CDROM drives +device atapifd # ATAPI floppy drives +device atapist # ATAPI tape drives +options ATA_STATIC_ID # Static device numbering + + +# SCSI peripherals +device scbus # SCSI bus (required for SCSI) +device da # Direct Access (disks) +device sa # Sequential Access (tape etc) +device cd # CD +device pass # Passthrough device (direct SCSI access) + +# atkbdc0 controls both the keyboard and the PS/2 mouse +device atkbdc # AT keyboard controller +device atkbd # AT keyboard +device psm # PS/2 mouse + +device kbdmux # keyboard multiplexer + +device vga # VGA video card driver + +device splash # Splash screen and screen saver support + +# syscons is the default console driver, resembling an SCO console +device sc + +device agp # support several AGP chipsets + +# Serial (COM) ports +device sio # 8250, 16[45]50 based serial ports + +# PCI Ethernet NICs that use the common MII bus controller code. +# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! +device miibus # MII bus support +device re # RealTek 8139C+/8169/8169S/8110S + +# Pseudo devices. +device loop # Network loopback +device random # Entropy device +device ether # Ethernet support +device sl # Kernel SLIP +device ppp # Kernel PPP +device tun # Packet tunnel. +device pty # Pseudo-ttys (telnet etc) +device md # Memory "disks" +device gif # IPv6 and IPv4 tunneling +device faith # IPv6-to-IPv4 relaying (translation) + +# The `bpf' device enables the Berkeley Packet Filter. +# Be aware of the administrative consequences of enabling this! +# Note that 'bpf' is required for DHCP. +device bpf # Berkeley packet filter From owner-svn-src-user@FreeBSD.ORG Wed Jan 7 09:17:26 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D36A106564A; Wed, 7 Jan 2009 09:17:26 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7307E8FC0C; Wed, 7 Jan 2009 09:17:26 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n079HQX4057278; Wed, 7 Jan 2009 09:17:26 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n079HQmM057277; Wed, 7 Jan 2009 09:17:26 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901070917.n079HQmM057277@svn.freebsd.org> From: Luigi Rizzo Date: Wed, 7 Jan 2009 09:17:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186852 - in user/luigi: . geom_sched X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jan 2009 09:17:26 -0000 Author: luigi Date: Wed Jan 7 09:17:25 2009 New Revision: 186852 URL: http://svn.freebsd.org/changeset/base/186852 Log: experiments with geom disk schedulers Added: user/luigi/ user/luigi/geom_sched/ - copied from r186851, stable/7/ From owner-svn-src-user@FreeBSD.ORG Thu Jan 8 00:08:35 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DACF7106567A; Thu, 8 Jan 2009 00:08:35 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C69928FC19; Thu, 8 Jan 2009 00:08:35 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0808ZYT003496; Thu, 8 Jan 2009 00:08:35 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0808Zkf003479; Thu, 8 Jan 2009 00:08:35 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200901080008.n0808Zkf003479@svn.freebsd.org> From: Sam Leffler Date: Thu, 8 Jan 2009 00:08:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186880 - in user/sam/wifi: . bin/test contrib/csup contrib/file contrib/file/Magdir contrib/file/tests contrib/lukemftpd/src crypto/openssl/apps crypto/openssl/ssl etc/defaults lib/lib... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2009 00:08:36 -0000 Author: sam Date: Thu Jan 8 00:08:34 2009 New Revision: 186880 URL: http://svn.freebsd.org/changeset/base/186880 Log: sync w/ head Added: user/sam/wifi/contrib/csup/lex.rcs.c - copied unchanged from r186879, head/contrib/csup/lex.rcs.c user/sam/wifi/contrib/csup/rcsfile.c - copied unchanged from r186879, head/contrib/csup/rcsfile.c user/sam/wifi/contrib/csup/rcsfile.h - copied unchanged from r186879, head/contrib/csup/rcsfile.h user/sam/wifi/contrib/csup/rcsparse.c - copied unchanged from r186879, head/contrib/csup/rcsparse.c user/sam/wifi/contrib/csup/rcsparse.h - copied unchanged from r186879, head/contrib/csup/rcsparse.h user/sam/wifi/contrib/csup/rcstokenizer.h - copied unchanged from r186879, head/contrib/csup/rcstokenizer.h user/sam/wifi/contrib/csup/rcstokenizer.l - copied unchanged from r186879, head/contrib/csup/rcstokenizer.l user/sam/wifi/contrib/csup/rsyncfile.c - copied unchanged from r186879, head/contrib/csup/rsyncfile.c user/sam/wifi/contrib/csup/rsyncfile.h - copied unchanged from r186879, head/contrib/csup/rsyncfile.h user/sam/wifi/contrib/file/AUTHORS - copied unchanged from r186879, head/contrib/file/AUTHORS user/sam/wifi/contrib/file/COPYING - copied unchanged from r186879, head/contrib/file/COPYING user/sam/wifi/contrib/file/INSTALL - copied unchanged from r186879, head/contrib/file/INSTALL user/sam/wifi/contrib/file/Magdir/clarion - copied unchanged from r186879, head/contrib/file/Magdir/clarion user/sam/wifi/contrib/file/Magdir/erlang - copied unchanged from r186879, head/contrib/file/Magdir/erlang user/sam/wifi/contrib/file/Magdir/gnome-keyring - copied unchanged from r186879, head/contrib/file/Magdir/gnome-keyring user/sam/wifi/contrib/file/Magdir/gnumeric - copied unchanged from r186879, head/contrib/file/Magdir/gnumeric user/sam/wifi/contrib/file/Magdir/graphviz - copied unchanged from r186879, head/contrib/file/Magdir/graphviz user/sam/wifi/contrib/file/Magdir/inform - copied unchanged from r186879, head/contrib/file/Magdir/inform user/sam/wifi/contrib/file/Magdir/kde - copied unchanged from r186879, head/contrib/file/Magdir/kde user/sam/wifi/contrib/file/Magdir/llvm - copied unchanged from r186879, head/contrib/file/Magdir/llvm user/sam/wifi/contrib/file/Magdir/lua - copied unchanged from r186879, head/contrib/file/Magdir/lua user/sam/wifi/contrib/file/Magdir/luks - copied unchanged from r186879, head/contrib/file/Magdir/luks user/sam/wifi/contrib/file/Magdir/mathcad - copied unchanged from r186879, head/contrib/file/Magdir/mathcad user/sam/wifi/contrib/file/Magdir/mercurial - copied unchanged from r186879, head/contrib/file/Magdir/mercurial user/sam/wifi/contrib/file/Magdir/mozilla - copied unchanged from r186879, head/contrib/file/Magdir/mozilla user/sam/wifi/contrib/file/Magdir/netware - copied unchanged from r186879, head/contrib/file/Magdir/netware user/sam/wifi/contrib/file/Magdir/ole2compounddocs - copied unchanged from r186879, head/contrib/file/Magdir/ole2compounddocs user/sam/wifi/contrib/file/Magdir/ruby - copied unchanged from r186879, head/contrib/file/Magdir/ruby user/sam/wifi/contrib/file/Magdir/securitycerts - copied unchanged from r186879, head/contrib/file/Magdir/securitycerts user/sam/wifi/contrib/file/Magdir/warc - copied unchanged from r186879, head/contrib/file/Magdir/warc user/sam/wifi/contrib/file/Magdir/weak - copied unchanged from r186879, head/contrib/file/Magdir/weak user/sam/wifi/contrib/file/Magdir/windows - copied unchanged from r186879, head/contrib/file/Magdir/windows user/sam/wifi/contrib/file/Magdir/xilinx - copied unchanged from r186879, head/contrib/file/Magdir/xilinx user/sam/wifi/contrib/file/NEWS - copied unchanged from r186879, head/contrib/file/NEWS user/sam/wifi/contrib/file/TODO - copied unchanged from r186879, head/contrib/file/TODO user/sam/wifi/contrib/file/asprintf.c - copied unchanged from r186879, head/contrib/file/asprintf.c user/sam/wifi/contrib/file/compile - copied unchanged from r186879, head/contrib/file/compile user/sam/wifi/contrib/file/config.guess - copied unchanged from r186879, head/contrib/file/config.guess user/sam/wifi/contrib/file/config.sub - copied unchanged from r186879, head/contrib/file/config.sub user/sam/wifi/contrib/file/configure.ac - copied unchanged from r186879, head/contrib/file/configure.ac user/sam/wifi/contrib/file/elfclass.h - copied unchanged from r186879, head/contrib/file/elfclass.h user/sam/wifi/contrib/file/getopt_long.c - copied unchanged from r186879, head/contrib/file/getopt_long.c user/sam/wifi/contrib/file/mygetopt.h - copied unchanged from r186879, head/contrib/file/mygetopt.h user/sam/wifi/contrib/file/tests/ - copied from r186879, head/contrib/file/tests/ user/sam/wifi/contrib/file/vasprintf.c - copied unchanged from r186879, head/contrib/file/vasprintf.c user/sam/wifi/lib/libelf/README - copied unchanged from r186879, head/lib/libelf/README user/sam/wifi/sys/modules/usb2/serial_3g/ - copied from r186879, head/sys/modules/usb2/serial_3g/ Replaced: user/sam/wifi/contrib/file/FREEBSD-upgrade - copied unchanged from r186879, head/contrib/file/FREEBSD-upgrade user/sam/wifi/contrib/file/magic2mime - copied unchanged from r186879, head/contrib/file/magic2mime Deleted: user/sam/wifi/contrib/file/LEGAL.NOTICE user/sam/wifi/contrib/file/Makefile.std user/sam/wifi/contrib/file/PORTING user/sam/wifi/contrib/file/configure.in user/sam/wifi/contrib/file/magic.mime user/sam/wifi/contrib/file/mkinstalldirs user/sam/wifi/contrib/file/test.c user/sam/wifi/sys/dev/sound/pci/au88x0.c user/sam/wifi/sys/dev/sound/pci/au88x0.h user/sam/wifi/sys/modules/sound/driver/au88x0/ Modified: user/sam/wifi/ (props changed) user/sam/wifi/ObsoleteFiles.inc user/sam/wifi/bin/test/test.1 user/sam/wifi/contrib/csup/ (props changed) user/sam/wifi/contrib/csup/GNUmakefile user/sam/wifi/contrib/csup/Makefile user/sam/wifi/contrib/csup/TODO user/sam/wifi/contrib/csup/config.c user/sam/wifi/contrib/csup/csup.1 user/sam/wifi/contrib/csup/detailer.c user/sam/wifi/contrib/csup/diff.c user/sam/wifi/contrib/csup/diff.h user/sam/wifi/contrib/csup/fattr.c user/sam/wifi/contrib/csup/fattr.h user/sam/wifi/contrib/csup/keyword.c user/sam/wifi/contrib/csup/keyword.h user/sam/wifi/contrib/csup/lister.c user/sam/wifi/contrib/csup/misc.c user/sam/wifi/contrib/csup/misc.h user/sam/wifi/contrib/csup/mux.c user/sam/wifi/contrib/csup/proto.c user/sam/wifi/contrib/csup/proto.h user/sam/wifi/contrib/csup/status.c user/sam/wifi/contrib/csup/stream.c user/sam/wifi/contrib/csup/stream.h user/sam/wifi/contrib/csup/updater.c user/sam/wifi/contrib/file/ (props changed) user/sam/wifi/contrib/file/ChangeLog user/sam/wifi/contrib/file/MAINT user/sam/wifi/contrib/file/Magdir/adventure user/sam/wifi/contrib/file/Magdir/animation user/sam/wifi/contrib/file/Magdir/apple user/sam/wifi/contrib/file/Magdir/archive user/sam/wifi/contrib/file/Magdir/audio user/sam/wifi/contrib/file/Magdir/c-lang user/sam/wifi/contrib/file/Magdir/c64 user/sam/wifi/contrib/file/Magdir/cafebabe user/sam/wifi/contrib/file/Magdir/cddb user/sam/wifi/contrib/file/Magdir/commands user/sam/wifi/contrib/file/Magdir/compress user/sam/wifi/contrib/file/Magdir/console user/sam/wifi/contrib/file/Magdir/cracklib user/sam/wifi/contrib/file/Magdir/ctags user/sam/wifi/contrib/file/Magdir/database user/sam/wifi/contrib/file/Magdir/diff user/sam/wifi/contrib/file/Magdir/dump user/sam/wifi/contrib/file/Magdir/elf user/sam/wifi/contrib/file/Magdir/filesystems user/sam/wifi/contrib/file/Magdir/flash user/sam/wifi/contrib/file/Magdir/fonts user/sam/wifi/contrib/file/Magdir/fortran user/sam/wifi/contrib/file/Magdir/frame user/sam/wifi/contrib/file/Magdir/freebsd user/sam/wifi/contrib/file/Magdir/fsav user/sam/wifi/contrib/file/Magdir/games user/sam/wifi/contrib/file/Magdir/gimp user/sam/wifi/contrib/file/Magdir/gnu user/sam/wifi/contrib/file/Magdir/hp user/sam/wifi/contrib/file/Magdir/iff user/sam/wifi/contrib/file/Magdir/images user/sam/wifi/contrib/file/Magdir/java user/sam/wifi/contrib/file/Magdir/jpeg user/sam/wifi/contrib/file/Magdir/lex user/sam/wifi/contrib/file/Magdir/linux user/sam/wifi/contrib/file/Magdir/lisp user/sam/wifi/contrib/file/Magdir/macintosh user/sam/wifi/contrib/file/Magdir/mail.news user/sam/wifi/contrib/file/Magdir/mathematica user/sam/wifi/contrib/file/Magdir/misctools user/sam/wifi/contrib/file/Magdir/msdos user/sam/wifi/contrib/file/Magdir/mup user/sam/wifi/contrib/file/Magdir/os2 user/sam/wifi/contrib/file/Magdir/palm user/sam/wifi/contrib/file/Magdir/pdf user/sam/wifi/contrib/file/Magdir/perl user/sam/wifi/contrib/file/Magdir/pgp user/sam/wifi/contrib/file/Magdir/pkgadd user/sam/wifi/contrib/file/Magdir/printer user/sam/wifi/contrib/file/Magdir/psion user/sam/wifi/contrib/file/Magdir/revision user/sam/wifi/contrib/file/Magdir/riff user/sam/wifi/contrib/file/Magdir/rpm user/sam/wifi/contrib/file/Magdir/rtf user/sam/wifi/contrib/file/Magdir/sc user/sam/wifi/contrib/file/Magdir/scientific user/sam/wifi/contrib/file/Magdir/sgi user/sam/wifi/contrib/file/Magdir/sgml user/sam/wifi/contrib/file/Magdir/sharc user/sam/wifi/contrib/file/Magdir/sketch user/sam/wifi/contrib/file/Magdir/softquad user/sam/wifi/contrib/file/Magdir/spectrum user/sam/wifi/contrib/file/Magdir/tex user/sam/wifi/contrib/file/Magdir/troff user/sam/wifi/contrib/file/Magdir/unicode user/sam/wifi/contrib/file/Magdir/uuencode user/sam/wifi/contrib/file/Magdir/varied.script user/sam/wifi/contrib/file/Magdir/vorbis user/sam/wifi/contrib/file/Magdir/wordprocessors user/sam/wifi/contrib/file/Makefile.am user/sam/wifi/contrib/file/Makefile.in user/sam/wifi/contrib/file/README user/sam/wifi/contrib/file/acinclude.m4 user/sam/wifi/contrib/file/aclocal.m4 user/sam/wifi/contrib/file/apprentice.c user/sam/wifi/contrib/file/ascmagic.c user/sam/wifi/contrib/file/compress.c user/sam/wifi/contrib/file/config.h.in user/sam/wifi/contrib/file/configure user/sam/wifi/contrib/file/file.c user/sam/wifi/contrib/file/file.h user/sam/wifi/contrib/file/file.man user/sam/wifi/contrib/file/fsmagic.c user/sam/wifi/contrib/file/funcs.c user/sam/wifi/contrib/file/is_tar.c user/sam/wifi/contrib/file/libmagic.man user/sam/wifi/contrib/file/magic.c user/sam/wifi/contrib/file/magic.h user/sam/wifi/contrib/file/magic.man user/sam/wifi/contrib/file/names.h user/sam/wifi/contrib/file/patchlevel.h user/sam/wifi/contrib/file/print.c user/sam/wifi/contrib/file/readelf.c user/sam/wifi/contrib/file/readelf.h user/sam/wifi/contrib/file/softmagic.c user/sam/wifi/contrib/file/tar.h user/sam/wifi/contrib/lukemftpd/src/extern.h user/sam/wifi/contrib/lukemftpd/src/ftpcmd.y user/sam/wifi/contrib/lukemftpd/src/ftpd.c user/sam/wifi/crypto/openssl/apps/speed.c user/sam/wifi/crypto/openssl/apps/spkac.c user/sam/wifi/crypto/openssl/apps/verify.c user/sam/wifi/crypto/openssl/apps/x509.c user/sam/wifi/crypto/openssl/ssl/s2_clnt.c user/sam/wifi/crypto/openssl/ssl/s2_srvr.c user/sam/wifi/crypto/openssl/ssl/s3_clnt.c user/sam/wifi/crypto/openssl/ssl/s3_srvr.c user/sam/wifi/crypto/openssl/ssl/ssltest.c user/sam/wifi/etc/defaults/rc.conf user/sam/wifi/lib/libc/net/getaddrinfo.3 user/sam/wifi/lib/libc/sys/jail.2 user/sam/wifi/lib/libc/sys/socket.2 user/sam/wifi/lib/libmagic/Makefile user/sam/wifi/lib/libstand/bootp.c user/sam/wifi/lib/libusb20/libusb20_desc.c user/sam/wifi/sbin/geom/class/virstor/gvirstor.8 user/sam/wifi/sbin/md5/md5.1 user/sam/wifi/sbin/mount_msdosfs/mount_msdosfs.8 user/sam/wifi/sbin/ping/ping.8 user/sam/wifi/share/man/man4/Makefile user/sam/wifi/share/man/man4/ae.4 user/sam/wifi/share/man/man4/cpuctl.4 user/sam/wifi/share/man/man4/snd_hda.4 user/sam/wifi/share/man/man4/snd_ich.4 user/sam/wifi/share/man/man7/build.7 user/sam/wifi/share/man/man9/dev_clone.9 user/sam/wifi/share/man/man9/domain.9 user/sam/wifi/share/misc/bsd-family-tree user/sam/wifi/sys/amd64/amd64/identcpu.c user/sam/wifi/sys/amd64/conf/GENERIC user/sam/wifi/sys/amd64/include/cputypes.h user/sam/wifi/sys/amd64/include/specialreg.h user/sam/wifi/sys/boot/forth/loader.4th user/sam/wifi/sys/boot/forth/pnp.4th user/sam/wifi/sys/boot/forth/support.4th user/sam/wifi/sys/conf/NOTES user/sam/wifi/sys/conf/files user/sam/wifi/sys/conf/kern.post.mk user/sam/wifi/sys/dev/ath/ath_rate/amrr/amrr.c user/sam/wifi/sys/dev/ath/ath_rate/onoe/onoe.c user/sam/wifi/sys/dev/ath/ath_rate/sample/sample.c user/sam/wifi/sys/dev/ath/if_ath_pci.c user/sam/wifi/sys/dev/dcons/dcons_crom.c user/sam/wifi/sys/dev/dcons/dcons_os.c user/sam/wifi/sys/dev/exca/exca.c user/sam/wifi/sys/dev/iicbus/ad7418.c user/sam/wifi/sys/dev/iicbus/ds1672.c user/sam/wifi/sys/dev/iicbus/icee.c user/sam/wifi/sys/dev/iicbus/if_ic.c user/sam/wifi/sys/dev/iicbus/iic.c user/sam/wifi/sys/dev/iicbus/iicbus.c user/sam/wifi/sys/dev/iicbus/iicsmb.c user/sam/wifi/sys/dev/mpt/mpt.c user/sam/wifi/sys/dev/mpt/mpt.h user/sam/wifi/sys/dev/mpt/mpt_cam.c user/sam/wifi/sys/dev/mpt/mpt_raid.c user/sam/wifi/sys/dev/mpt/mpt_user.c user/sam/wifi/sys/dev/ofw/ofw_bus_subr.c user/sam/wifi/sys/dev/ofw/openfirm.c user/sam/wifi/sys/dev/ofw/openfirm.h user/sam/wifi/sys/dev/pccard/pccardvar.h user/sam/wifi/sys/dev/pcn/if_pcn.c user/sam/wifi/sys/dev/sound/pcm/sound.c user/sam/wifi/sys/dev/syscons/teken/teken.c user/sam/wifi/sys/dev/syscons/teken/teken.h user/sam/wifi/sys/dev/syscons/teken/teken_demo.c user/sam/wifi/sys/dev/syscons/teken/teken_subr.h user/sam/wifi/sys/dev/usb/ehci_pci.c user/sam/wifi/sys/dev/usb/uhci_pci.c user/sam/wifi/sys/dev/usb2/controller/at91dci.c user/sam/wifi/sys/dev/usb2/controller/ehci2.c user/sam/wifi/sys/dev/usb2/controller/ehci2.h user/sam/wifi/sys/dev/usb2/controller/musb2_otg.c user/sam/wifi/sys/dev/usb2/controller/ohci2.c user/sam/wifi/sys/dev/usb2/controller/ohci2_pci.c user/sam/wifi/sys/dev/usb2/controller/uhci2.c user/sam/wifi/sys/dev/usb2/controller/uhci2.h user/sam/wifi/sys/dev/usb2/controller/usb2_bus.h user/sam/wifi/sys/dev/usb2/controller/usb2_controller.c user/sam/wifi/sys/dev/usb2/controller/usb2_controller.h user/sam/wifi/sys/dev/usb2/controller/uss820dci.c user/sam/wifi/sys/dev/usb2/core/usb2_busdma.c user/sam/wifi/sys/dev/usb2/core/usb2_core.h user/sam/wifi/sys/dev/usb2/core/usb2_device.c user/sam/wifi/sys/dev/usb2/core/usb2_device.h user/sam/wifi/sys/dev/usb2/core/usb2_dynamic.c user/sam/wifi/sys/dev/usb2/core/usb2_dynamic.h user/sam/wifi/sys/dev/usb2/core/usb2_generic.c user/sam/wifi/sys/dev/usb2/core/usb2_handle_request.c user/sam/wifi/sys/dev/usb2/core/usb2_hub.c user/sam/wifi/sys/dev/usb2/core/usb2_hub.h user/sam/wifi/sys/dev/usb2/core/usb2_msctest.c user/sam/wifi/sys/dev/usb2/core/usb2_msctest.h user/sam/wifi/sys/dev/usb2/core/usb2_request.c user/sam/wifi/sys/dev/usb2/core/usb2_request.h user/sam/wifi/sys/dev/usb2/core/usb2_transfer.c user/sam/wifi/sys/dev/usb2/core/usb2_transfer.h user/sam/wifi/sys/dev/usb2/ethernet/if_axe2.c user/sam/wifi/sys/dev/usb2/ethernet/if_axe2_reg.h user/sam/wifi/sys/dev/usb2/image/uscanner2.c user/sam/wifi/sys/dev/usb2/include/usb2_devid.h user/sam/wifi/sys/dev/usb2/include/usb2_devtable.h user/sam/wifi/sys/dev/usb2/include/usb2_ioctl.h user/sam/wifi/sys/dev/usb2/include/usb2_standard.h user/sam/wifi/sys/dev/usb2/serial/u3g2.c user/sam/wifi/sys/dev/usb2/serial/uchcom2.c user/sam/wifi/sys/dev/usb2/serial/uftdi2.c user/sam/wifi/sys/dev/usb2/serial/uplcom2.c user/sam/wifi/sys/dev/usb2/serial/uvscom2.c user/sam/wifi/sys/dev/usb2/sound/uaudio2.c user/sam/wifi/sys/dev/usb2/storage/umass2.c user/sam/wifi/sys/dev/usb2/storage/ustorage2_fs.c user/sam/wifi/sys/dev/usb2/wlan/if_ural2.c user/sam/wifi/sys/dev/usb2/wlan/if_zyd2.c user/sam/wifi/sys/dev/usb2/wlan/if_zyd2_reg.h user/sam/wifi/sys/geom/part/g_part.c user/sam/wifi/sys/geom/part/g_part_pc98.c user/sam/wifi/sys/geom/part/g_part_vtoc8.c user/sam/wifi/sys/gnu/fs/ext2fs/ext2_bitops.h user/sam/wifi/sys/i386/conf/GENERIC user/sam/wifi/sys/i386/cpufreq/est.c user/sam/wifi/sys/kern/kern_jail.c user/sam/wifi/sys/kern/tty.c user/sam/wifi/sys/kern/uipc_cow.c user/sam/wifi/sys/kern/uipc_debug.c user/sam/wifi/sys/kern/uipc_domain.c user/sam/wifi/sys/modules/usb2/Makefile user/sam/wifi/sys/net/route.c user/sam/wifi/sys/net80211/ieee80211_node.c user/sam/wifi/sys/netinet/in.c user/sam/wifi/sys/netinet/ip_output.c user/sam/wifi/sys/netinet/udp_usrreq.c user/sam/wifi/sys/netinet/udp_var.h user/sam/wifi/sys/netinet6/in6.c user/sam/wifi/sys/netinet6/in6_gif.c user/sam/wifi/sys/netinet6/ip6protosw.h user/sam/wifi/sys/netinet6/udp6_usrreq.c user/sam/wifi/sys/netipsec/xform_ipip.c user/sam/wifi/sys/powerpc/powermac/grackle.c user/sam/wifi/sys/powerpc/powermac/gracklevar.h user/sam/wifi/sys/powerpc/powermac/macio.c user/sam/wifi/sys/powerpc/powermac/uninorth.c user/sam/wifi/sys/powerpc/powermac/uninorthvar.h user/sam/wifi/sys/security/audit/audit.h user/sam/wifi/sys/security/audit/audit_pipe.c user/sam/wifi/sys/sys/elf_common.h user/sam/wifi/sys/sys/mbuf.h user/sam/wifi/sys/sys/protosw.h user/sam/wifi/sys/sys/soundcard.h user/sam/wifi/sys/vm/vm_page.c user/sam/wifi/sys/vm/vm_page.h user/sam/wifi/usr.bin/csup/ (props changed) user/sam/wifi/usr.bin/csup/Makefile user/sam/wifi/usr.bin/make/globals.h user/sam/wifi/usr.bin/make/job.c user/sam/wifi/usr.bin/make/main.c user/sam/wifi/usr.bin/make/make.1 user/sam/wifi/usr.bin/make/var.c user/sam/wifi/usr.sbin/burncd/burncd.c user/sam/wifi/usr.sbin/cpucontrol/cpucontrol.8 user/sam/wifi/usr.sbin/fwcontrol/fwcontrol.c user/sam/wifi/usr.sbin/kldxref/ef_i386.c user/sam/wifi/usr.sbin/kldxref/ef_obj.c user/sam/wifi/usr.sbin/kldxref/fileformat user/sam/wifi/usr.sbin/kldxref/kldxref.c user/sam/wifi/usr.sbin/makefs/ffs/ffs_bswap.c (props changed) user/sam/wifi/usr.sbin/makefs/ffs/ffs_subr.c (props changed) user/sam/wifi/usr.sbin/makefs/ffs/ufs_bswap.h (props changed) user/sam/wifi/usr.sbin/makefs/getid.c (props changed) user/sam/wifi/usr.sbin/mergemaster/mergemaster.8 user/sam/wifi/usr.sbin/mergemaster/mergemaster.sh user/sam/wifi/usr.sbin/mld6query/mld6query.8 user/sam/wifi/usr.sbin/pkg_install/add/pkg_add.1 user/sam/wifi/usr.sbin/pkg_install/lib/lib.h user/sam/wifi/usr.sbin/pkg_install/lib/plist.c user/sam/wifi/usr.sbin/rrenumd/rrenumd.8 user/sam/wifi/usr.sbin/rtadvd/rtadvd.8 user/sam/wifi/usr.sbin/rtsold/rtsold.8 user/sam/wifi/usr.sbin/traceroute6/traceroute6.8 Modified: user/sam/wifi/ObsoleteFiles.inc ============================================================================== --- user/sam/wifi/ObsoleteFiles.inc Wed Jan 7 23:30:26 2009 (r186879) +++ user/sam/wifi/ObsoleteFiles.inc Thu Jan 8 00:08:34 2009 (r186880) @@ -14,6 +14,8 @@ # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last. # +# 20081223: bind 9.4.3 import, nsupdate.8 moved to nsupdate.1 +OLD_FILES+=usr/share/man/man8/nsupdate.8.gz # 20081223: ipprotosw.h removed OLD_FILES+=usr/include/netinet/ipprotosw.h # 20081123: vfs_mountedon.9 removed Modified: user/sam/wifi/bin/test/test.1 ============================================================================== --- user/sam/wifi/bin/test/test.1 Wed Jan 7 23:30:26 2009 (r186879) +++ user/sam/wifi/bin/test/test.1 Thu Jan 8 00:08:34 2009 (r186880) @@ -310,7 +310,7 @@ are evaluated consistently according to standards document. All other cases are subject to the ambiguity in the command semantics. -.Sh RETURN VALUES +.Sh EXIT STATUS The .Nm utility exits with one of the following values: Modified: user/sam/wifi/contrib/csup/GNUmakefile ============================================================================== --- user/sam/wifi/contrib/csup/GNUmakefile Wed Jan 7 23:30:26 2009 (r186879) +++ user/sam/wifi/contrib/csup/GNUmakefile Thu Jan 8 00:08:34 2009 (r186880) @@ -12,8 +12,9 @@ GROUP?= 0 UNAME= $(shell uname -s) SRCS= attrstack.c config.c detailer.c diff.c fattr.c fixups.c fnmatch.c \ - globtree.c idcache.c keyword.c lister.c main.c misc.c mux.c pathcomp.c \ - parse.c proto.c status.c stream.c threads.c token.c updater.c + globtree.c idcache.c keyword.c lex.rcs.c lister.c main.c misc.c mux.c \ + pathcomp.c parse.c proto.c rcsfile.c rcsparse.c rsyncfile.c status.c \ + stream.c threads.c token.c updater.c OBJS= $(SRCS:.c=.o) WARNS= -Wall -W -Wno-unused-parameter -Wmissing-prototypes -Wpointer-arith \ Modified: user/sam/wifi/contrib/csup/Makefile ============================================================================== --- user/sam/wifi/contrib/csup/Makefile Wed Jan 7 23:30:26 2009 (r186879) +++ user/sam/wifi/contrib/csup/Makefile Thu Jan 8 00:08:34 2009 (r186880) @@ -9,10 +9,11 @@ UNAME!= /usr/bin/uname -s PROG= csup SRCS= attrstack.c config.c detailer.c diff.c fattr.c fixups.c fnmatch.c \ globtree.c idcache.c keyword.c lister.c main.c misc.c mux.c parse.y \ - pathcomp.c proto.c status.c stream.c threads.c token.l updater.c + pathcomp.c proto.c status.c stream.c threads.c token.l updater.c \ + rcsfile.c rcsparse.c lex.rcs.c rsyncfile.c CFLAGS+= -I. -I${.CURDIR} -g -pthread -DHAVE_FFLAGS -DNDEBUG -WARNS?= 6 +WARNS?= 1 # A bit of tweaking is needed to get this Makefile working # with the bsd.prog.mk of all the *BSD OSes... Modified: user/sam/wifi/contrib/csup/TODO ============================================================================== --- user/sam/wifi/contrib/csup/TODO Wed Jan 7 23:30:26 2009 (r186879) +++ user/sam/wifi/contrib/csup/TODO Thu Jan 8 00:08:34 2009 (r186880) @@ -28,4 +28,3 @@ MISSING FEATURES: checkout files (files in CVS/ subdirectores), a command line override to only update a specific collection and a third verbosity level to display commit log messages. -- Add support for CVS mode (maybe?). Modified: user/sam/wifi/contrib/csup/config.c ============================================================================== --- user/sam/wifi/contrib/csup/config.c Wed Jan 7 23:30:26 2009 (r186879) +++ user/sam/wifi/contrib/csup/config.c Thu Jan 8 00:08:34 2009 (r186880) @@ -133,7 +133,6 @@ config_init(const char *file, struct col coll->co_options &= ~CO_CHECKRCS; /* In recent versions, we always try to set the file modes. */ coll->co_options |= CO_SETMODE; - /* XXX We don't support the rsync updating algorithm yet. */ coll->co_options |= CO_NORSYNC; error = config_parse_refusefiles(coll); if (error) @@ -444,10 +443,6 @@ coll_add(char *name) "\"%s\"\n", cur_coll->co_name); exit(1); } - if (!(cur_coll->co_options & CO_CHECKOUTMODE)) { - lprintf(-1, "Client only supports checkout mode\n"); - exit(1); - } if (!STAILQ_EMPTY(&colls)) { coll = STAILQ_LAST(&colls, coll, co_next); if (strcmp(coll->co_host, cur_coll->co_host) != 0) { Modified: user/sam/wifi/contrib/csup/csup.1 ============================================================================== --- user/sam/wifi/contrib/csup/csup.1 Wed Jan 7 23:30:26 2009 (r186879) +++ user/sam/wifi/contrib/csup/csup.1 Thu Jan 8 00:08:34 2009 (r186880) @@ -442,8 +442,6 @@ They are called mode and .Em checkout mode. -.Nm -only supports the checkout mode for now. .Pp In CVS mode, the client receives copies of the actual RCS files making up the master CVS repository. CVS mode is the default mode of operation. Modified: user/sam/wifi/contrib/csup/detailer.c ============================================================================== --- user/sam/wifi/contrib/csup/detailer.c Wed Jan 7 23:30:26 2009 (r186879) +++ user/sam/wifi/contrib/csup/detailer.c Thu Jan 8 00:08:34 2009 (r186880) @@ -30,13 +30,21 @@ #include #include #include +#include + +#include +#include +#include #include "config.h" #include "detailer.h" #include "fixups.h" +#include "globtree.h" #include "misc.h" #include "mux.h" #include "proto.h" +#include "rcsfile.h" +#include "rsyncfile.h" #include "status.h" #include "stream.h" @@ -56,8 +64,16 @@ struct detailer { static int detailer_batch(struct detailer *); static int detailer_coll(struct detailer *, struct coll *, struct status *); -static int detailer_dofile(struct detailer *, struct coll *, +static int detailer_dofile_co(struct detailer *, struct coll *, struct status *, char *); +static int detailer_dofile_rcs(struct detailer *, struct coll *, + char *, char *); +static int detailer_dofile_regular(struct detailer *, char *, char *); +static int detailer_dofile_rsync(struct detailer *, char *, char *); +static int detailer_checkrcsattr(struct detailer *, struct coll *, char *, + struct fattr *, int); +int detailer_send_details(struct detailer *, struct coll *, char *, + char *, struct fattr *); void * detailer(void *arg) @@ -186,8 +202,13 @@ detailer_batch(struct detailer *d) } if (fixup->f_coll != coll) break; - error = proto_printf(wr, "Y %s %s %s\n", fixup->f_name, - coll->co_tag, coll->co_date); + if (coll->co_options & CO_CHECKOUTMODE) + error = proto_printf(wr, "Y %s %s %s\n", + fixup->f_name, coll->co_tag, coll->co_date); + else { + error = proto_printf(wr, "A %s\n", + fixup->f_name); + } if (error) return (DETAILER_ERR_WRITE); fixup = NULL; @@ -208,12 +229,14 @@ detailer_batch(struct detailer *d) static int detailer_coll(struct detailer *d, struct coll *coll, struct status *st) { + struct fattr *rcsattr; struct stream *rd, *wr; - char *cmd, *file, *line, *msg; - int error; + char *attr, *cmd, *file, *line, *msg, *path, *target; + int error, attic; rd = d->rd; wr = d->wr; + attic = 0; line = stream_getln(rd, NULL); if (line == NULL) return (DETAILER_ERR_READ); @@ -226,17 +249,84 @@ detailer_coll(struct detailer *d, struct /* Delete file. */ file = proto_get_ascii(&line); if (file == NULL || line != NULL) - return (DETAILER_ERR_PROTO); + return (DETAILER_ERR_PROTO); error = proto_printf(wr, "D %s\n", file); if (error) return (DETAILER_ERR_WRITE); break; + case 'I': + case 'i': + case 'j': + /* Directory operations. */ + file = proto_get_ascii(&line); + if (file == NULL || line != NULL) + return (DETAILER_ERR_PROTO); + error = proto_printf(wr, "%s %s\n", cmd, file); + if (error) + return (DETAILER_ERR_WRITE); + break; + case 'J': + /* Set directory attributes. */ + file = proto_get_ascii(&line); + attr = proto_get_ascii(&line); + if (file == NULL || line != NULL || attr == NULL) + return (DETAILER_ERR_PROTO); + error = proto_printf(wr, "%s %s %s\n", cmd, file, attr); + if (error) + return (DETAILER_ERR_WRITE); + break; + case 'H': + case 'h': + /* Create a hard link. */ + file = proto_get_ascii(&line); + target = proto_get_ascii(&line); + if (file == NULL || target == NULL) + return (DETAILER_ERR_PROTO); + error = proto_printf(wr, "%s %s %s\n", cmd, file, + target); + break; + case 't': + file = proto_get_ascii(&line); + attr = proto_get_ascii(&line); + if (file == NULL || attr == NULL || line != NULL) { + return (DETAILER_ERR_PROTO); + } + rcsattr = fattr_decode(attr); + if (rcsattr == NULL) { + return (DETAILER_ERR_PROTO); + } + error = detailer_checkrcsattr(d, coll, file, rcsattr, + 1); + break; + + case 'T': + file = proto_get_ascii(&line); + attr = proto_get_ascii(&line); + if (file == NULL || attr == NULL || line != NULL) + return (DETAILER_ERR_PROTO); + rcsattr = fattr_decode(attr); + if (rcsattr == NULL) + return (DETAILER_ERR_PROTO); + error = detailer_checkrcsattr(d, coll, file, rcsattr, + 0); + break; + case 'U': /* Add or update file. */ file = proto_get_ascii(&line); if (file == NULL || line != NULL) return (DETAILER_ERR_PROTO); - error = detailer_dofile(d, coll, st, file); + if (coll->co_options & CO_CHECKOUTMODE) { + error = detailer_dofile_co(d, coll, st, file); + } else { + path = cvspath(coll->co_prefix, file, 0); + rcsattr = fattr_frompath(path, FATTR_NOFOLLOW); + error = detailer_send_details(d, coll, file, + path, rcsattr); + if (rcsattr != NULL) + fattr_free(rcsattr); + free(path); + } if (error) return (error); break; @@ -261,14 +351,110 @@ detailer_coll(struct detailer *d, struct return (0); } +/* + * Tell the server to update a regular file. + */ static int -detailer_dofile(struct detailer *d, struct coll *coll, struct status *st, - char *file) +detailer_dofile_regular(struct detailer *d, char *name, char *path) { + struct stream *wr; + struct stat st; char md5[MD5_DIGEST_SIZE]; + int error; + + wr = d->wr; + error = stat(path, &st); + /* If we don't have it or it's unaccessible, we want it again. */ + if (error) { + proto_printf(wr, "A %s\n", name); + return (0); + } + + /* If not, we want the file to be updated. */ + error = MD5_File(path, md5); + if (error) { + lprintf(-1, "Error reading \"%s\"\n", name); + return (error); + } + error = proto_printf(wr, "R %s %O %s\n", name, st.st_size, md5); + if (error) + return (DETAILER_ERR_WRITE); + return (0); +} + +/* + * Tell the server to update a file with the rsync algorithm. + */ +static int +detailer_dofile_rsync(struct detailer *d, char *name, char *path) +{ + struct stream *wr; + struct rsyncfile *rf; + + wr = d->wr; + rf = rsync_open(path, 0, 1); + if (rf == NULL) { + /* Fallback if we fail in opening it. */ + proto_printf(wr, "A %s\n", name); + return (0); + } + proto_printf(wr, "r %s %z %z\n", name, rsync_filesize(rf), + rsync_blocksize(rf)); + /* Detail the blocks. */ + while (rsync_nextblock(rf) != 0) + proto_printf(wr, "%s %s\n", rsync_rsum(rf), rsync_blockmd5(rf)); + proto_printf(wr, ".\n"); + rsync_close(rf); + return (0); +} + +/* + * Tell the server to update an RCS file that we have, or send it if we don't. + */ +static int +detailer_dofile_rcs(struct detailer *d, struct coll *coll, char *name, + char *path) +{ + struct stream *wr; + struct fattr *fa; + struct rcsfile *rf; + int error; + + wr = d->wr; + path = atticpath(coll->co_prefix, name); + fa = fattr_frompath(path, FATTR_NOFOLLOW); + if (fa == NULL) { + /* We don't have it, so send request to get it. */ + error = proto_printf(wr, "A %s\n", name); + if (error) + return (DETAILER_ERR_WRITE); + free(path); + return (0); + } + + rf = rcsfile_frompath(path, name, coll->co_cvsroot, coll->co_tag, 1); + free(path); + if (rf == NULL) { + error = proto_printf(wr, "A %s\n", name); + if (error) + return (DETAILER_ERR_WRITE); + return (0); + } + /* Tell to update the RCS file. The client version details follow. */ + rcsfile_send_details(rf, wr); + rcsfile_free(rf); + fattr_free(fa); + return (0); +} + +static int +detailer_dofile_co(struct detailer *d, struct coll *coll, struct status *st, + char *file) +{ struct stream *wr; struct fattr *fa; struct statusrec *sr; + char md5[MD5_DIGEST_SIZE]; char *path; int error, ret; @@ -337,3 +523,81 @@ detailer_dofile(struct detailer *d, stru return (DETAILER_ERR_WRITE); return (0); } + +int +detailer_checkrcsattr(struct detailer *d, struct coll *coll, char *name, + struct fattr *server_attr, int attic) +{ + struct fattr *client_attr; + char *attr, *path; + int error; + + /* + * I don't think we can use the status file, since it only records file + * attributes in cvsmode. + */ + client_attr = NULL; + path = cvspath(coll->co_prefix, name, attic); + if (path == NULL) { + return (DETAILER_ERR_PROTO); + } + + if (access(path, F_OK) == 0 && + ((client_attr = fattr_frompath(path, FATTR_NOFOLLOW)) != NULL) && + fattr_equal(client_attr, server_attr)) { + attr = fattr_encode(client_attr, NULL, 0); + if (attic) { + error = proto_printf(d->wr, "l %s %s\n", name, attr); + } else { + error = proto_printf(d->wr, "L %s %s\n", name, attr); + } + free(attr); + free(path); + fattr_free(client_attr); + if (error) + return (DETAILER_ERR_WRITE); + return (0); + } + /* We don't have it, so tell the server to send it. */ + error = detailer_send_details(d, coll, name, path, client_attr); + fattr_free(client_attr); + free(path); + return (error); +} + +int +detailer_send_details(struct detailer *d, struct coll *coll, char *name, + char *path, struct fattr *fa) +{ + int error; + size_t len; + + /* + * Try to check if the file exists either live or dead to see if we can + * edit it and put it live or dead, rather than receiving the entire + * file. + */ + if (fa == NULL) { + path = atticpath(coll->co_prefix, name); + fa = fattr_frompath(path, FATTR_NOFOLLOW); + } + if (fa == NULL) { + error = proto_printf(d->wr, "A %s\n", name); + if (error) + return (DETAILER_ERR_WRITE); + } else if (fattr_type(fa) == FT_FILE) { + if (isrcs(name, &len) && !(coll->co_options & CO_NORCS)) { + detailer_dofile_rcs(d, coll, name, path); + } else if (!(coll->co_options & CO_NORSYNC) && + !globtree_test(coll->co_norsync, name)) { + detailer_dofile_rsync(d, name, path); + } else { + detailer_dofile_regular(d, name, path); + } + } else { + error = proto_printf(d->wr, "N %s\n", name); + if (error) + return (DETAILER_ERR_WRITE); + } + return (0); +} Modified: user/sam/wifi/contrib/csup/diff.c ============================================================================== --- user/sam/wifi/contrib/csup/diff.c Wed Jan 7 23:30:26 2009 (r186879) +++ user/sam/wifi/contrib/csup/diff.c Thu Jan 8 00:08:34 2009 (r186880) @@ -26,9 +26,12 @@ * $FreeBSD$ */ +#include + #include #include #include +#include #include #include @@ -36,15 +39,20 @@ #include "keyword.h" #include "misc.h" #include "stream.h" +#include "queue.h" typedef long lineno_t; #define EC_ADD 0 #define EC_DEL 1 +#define MAXKEY LONG_MAX /* Editing command and state. */ struct editcmd { int cmd; + long key; + int havetext; + int offset; lineno_t where; lineno_t count; lineno_t lasta; @@ -55,20 +63,28 @@ struct editcmd { struct diffinfo *di; struct stream *orig; struct stream *dest; + LIST_ENTRY(editcmd) next; +}; + +struct diffstart { + LIST_HEAD(, editcmd) dhead; }; static int diff_geteditcmd(struct editcmd *, char *); static int diff_copyln(struct editcmd *, lineno_t); +static int diff_ignoreln(struct editcmd *, lineno_t); static void diff_write(struct editcmd *, void *, size_t); +static int diff_insert_edit(struct diffstart *, struct editcmd *); +static void diff_free(struct diffstart *); int diff_apply(struct stream *rd, struct stream *orig, struct stream *dest, - struct keyword *keyword, struct diffinfo *di) + struct keyword *keyword, struct diffinfo *di, int comode) { struct editcmd ec; lineno_t i; - char *line; size_t size; + char *line; int empty, error, noeol; memset(&ec, 0, sizeof(ec)); @@ -104,7 +120,7 @@ diff_apply(struct stream *rd, struct str line = stream_getln(rd, &size); if (line == NULL) return (-1); - if (line[0] == '.') { + if (comode && line[0] == '.') { line++; size--; } @@ -124,10 +140,10 @@ diff_apply(struct stream *rd, struct str } line = stream_getln(rd, NULL); } - if (line == NULL) + if (comode && line == NULL) return (-1); /* If we got ".+", there's no ending newline. */ - if (strcmp(line, ".+") == 0 && !empty) + if (comode && strcmp(line, ".+") == 0 && !empty) noeol = 1; ec.where = 0; while ((line = stream_getln(orig, &size)) != NULL) @@ -143,6 +159,198 @@ diff_apply(struct stream *rd, struct str return (0); } +/* + * Reverse a diff using the same algorithm as in cvsup. + */ +static int +diff_write_reverse(struct stream *dest, struct diffstart *ds) +{ + struct editcmd *ec, *nextec; + long editline, endline, firstoutputlinedeleted; + long num_added, num_deleted, startline; + int num; + + nextec = LIST_FIRST(&ds->dhead); + editline = 0; + num = 0; + while (nextec != NULL) { + ec = nextec; + nextec = LIST_NEXT(nextec, next); + if (nextec == NULL) + break; + num++; + num_deleted = 0; + if (ec->havetext) + num_deleted = ec->count; + num_added = num_deleted + nextec->offset - ec->offset; + if (num_deleted > 0) { + firstoutputlinedeleted = ec->key - num_deleted + 1; + stream_printf(dest, "d%ld %ld\n", firstoutputlinedeleted, + num_deleted); + if (num_added <= 0) + continue; + } + if (num_added > 0) { + stream_printf(dest, "a%ld %ld\n", ec->key, num_added); + startline = ec->key - num_deleted + 1 + ec->offset; + endline = startline + num_added - 1; + + /* Copy lines from original file. First ignore some. */ + ec->editline = editline; + diff_ignoreln(ec, startline - 1); + diff_copyln(ec, endline); + editline = ec->editline; + } + } + return (0); +} + +/* + * Insert a diff into the list sorted on key. Should perhaps use quicker + * algorithms than insertion sort, but do this for now. + */ +static int +diff_insert_edit(struct diffstart *ds, struct editcmd *ec) +{ + struct editcmd *curec; + + if (ec == NULL) + return (0); + + if (LIST_EMPTY(&ds->dhead)) { + LIST_INSERT_HEAD(&ds->dhead, ec, next); + return (0); + } + + /* Insertion sort based on key. */ + LIST_FOREACH(curec, &ds->dhead, next) { + if (ec->key < curec->key) { + LIST_INSERT_BEFORE(curec, ec, next); + return (0); + } + if (LIST_NEXT(curec, next) == NULL) + break; + } + /* Just insert it after. */ + LIST_INSERT_AFTER(curec, ec, next); + return (0); +} + +static void +diff_free(struct diffstart *ds) +{ + struct editcmd *ec; + + while(!LIST_EMPTY(&ds->dhead)) { + ec = LIST_FIRST(&ds->dhead); + LIST_REMOVE(ec, next); + free(ec); + } +} + +/* + * Write the reverse diff from the diff in rd, and original file into + * destination. This algorithm is the same as used in cvsup. + */ +int +diff_reverse(struct stream *rd, struct stream *orig, struct stream *dest, + struct keyword *keyword, struct diffinfo *di) +{ + struct diffstart ds; + struct editcmd ec, *addec, *delec; + lineno_t i; + char *line; + int error, offset; + + memset(&ec, 0, sizeof(ec)); + ec.orig = orig; + ec.dest = dest; + ec.keyword = keyword; + ec.di = di; + addec = NULL; + delec = NULL; + ec.havetext = 0; + offset = 0; + LIST_INIT(&ds.dhead); + + /* Start with next since we need it. */ + line = stream_getln(rd, NULL); + /* First we build up the list of diffs from input. */ + while (line != NULL) { + error = diff_geteditcmd(&ec, line); + if (error) + break; + if (ec.cmd == EC_ADD) { + addec = xmalloc(sizeof(struct editcmd)); + *addec = ec; + addec->havetext = 1; + /* Ignore the lines we was supposed to add. */ + for (i = 0; i < ec.count; i++) { + line = stream_getln(rd, NULL); + if (line == NULL) + return (-1); + } + + /* Get the next diff command if we have one. */ + addec->key = addec->where + addec->count - offset; + if (delec != NULL && + delec->key == addec->key - addec->count) { + delec->key = addec->key; + delec->havetext = addec->havetext; + delec->count = addec->count; + diff_insert_edit(&ds, delec); + free(addec); + delec = NULL; + addec = NULL; + } else { + if (delec != NULL) { + diff_insert_edit(&ds, delec); + } + delec = NULL; + addec->offset = offset; + diff_insert_edit(&ds, addec); + addec = NULL; + } + offset -= ec.count; + } else if (ec.cmd == EC_DEL) { + if (delec != NULL) { + /* Update offset to our next. */ + diff_insert_edit(&ds, delec); + delec = NULL; + } + delec = xmalloc(sizeof(struct editcmd)); + *delec = ec; + delec->key = delec->where - 1 - offset; + delec->offset = offset; + delec->count = 0; + delec->havetext = 0; + /* Important to use the count we had before reset.*/ + offset += ec.count; + } + line = stream_getln(rd, NULL); + } + + while (line != NULL) + line = stream_getln(rd, NULL); + if (delec != NULL) { + diff_insert_edit(&ds, delec); + delec = NULL; + } + + addec = xmalloc(sizeof(struct editcmd)); + /* Should be filesize, but we set it to max value. */ + addec->key = MAXKEY; + addec->offset = offset; + addec->havetext = 0; + addec->count = 0; + diff_insert_edit(&ds, addec); + addec = NULL; + diff_write_reverse(dest, &ds); + diff_free(&ds); + stream_flush(dest); + return (0); +} + /* Get an editing command from the diff. */ static int diff_geteditcmd(struct editcmd *ec, char *line) @@ -181,8 +389,8 @@ diff_geteditcmd(struct editcmd *ec, char static int diff_copyln(struct editcmd *ec, lineno_t to) { - char *line; size_t size; + char *line; while (ec->editline < to) { line = stream_getln(ec->orig, &size); @@ -194,12 +402,28 @@ diff_copyln(struct editcmd *ec, lineno_t return (0); } +/* Ignore lines from the original version of the file up to line "to". */ +static int +diff_ignoreln(struct editcmd *ec, lineno_t to) +{ + size_t size; + char *line; + + while (ec->editline < to) { + line = stream_getln(ec->orig, &size); + if (line == NULL) + return (-1); + ec->editline++; + } + return (0); +} + /* Write a new line to the file, expanding RCS keywords appropriately. */ static void diff_write(struct editcmd *ec, void *buf, size_t size) { - char *line, *newline; size_t newsize; + char *line, *newline; int ret; line = buf; Modified: user/sam/wifi/contrib/csup/diff.h ============================================================================== --- user/sam/wifi/contrib/csup/diff.h Wed Jan 7 23:30:26 2009 (r186879) +++ user/sam/wifi/contrib/csup/diff.h Thu Jan 8 00:08:34 2009 (r186880) @@ -45,6 +45,8 @@ struct diffinfo { }; int diff_apply(struct stream *, struct stream *, struct stream *, - struct keyword *, struct diffinfo *); + struct keyword *, struct diffinfo *, int); +int diff_reverse(struct stream *, struct stream *, + struct stream *, struct keyword *, struct diffinfo *); #endif /* !_DIFF_H_ */ Modified: user/sam/wifi/contrib/csup/fattr.c ============================================================================== --- user/sam/wifi/contrib/csup/fattr.c Wed Jan 7 23:30:26 2009 (r186879) +++ user/sam/wifi/contrib/csup/fattr.c Thu Jan 8 00:08:34 2009 (r186880) @@ -44,7 +44,7 @@ /* * Include the appropriate definition for the file attributes we support. * There are two different files: fattr_bsd.h for BSD-like systems that - * support the extended file flags à la chflags() and fattr_posix.h for + * support the extended file flags a la chflags() and fattr_posix.h for * bare POSIX systems that don't. */ #ifdef HAVE_FFLAGS @@ -449,7 +449,7 @@ fattr_encode(const struct fattr *fa, fat piece++; } if (mask & FA_DEV) { - vallen = snprintf(piece->val, sizeof(piece->val), "%lld", + vallen = snprintf(piece->val, sizeof(piece->val), "%llx", (long long)fa->dev); len += snprintf(piece->len, sizeof(piece->len), "%lld", (long long)vallen) + vallen + 1; @@ -534,6 +534,13 @@ fattr_getlinkcount(const struct fattr *f return (fa->linkcount); } +char * +fattr_getlinktarget(const struct fattr *fa) +{ + + return (fa->linktarget); +} + /* * Eat the specified attribute and put it in the file attribute * structure. Returns NULL on error, or a pointer to the next @@ -732,18 +739,28 @@ fattr_makenode(const struct fattr *fa, c mode_t modemask, mode; int error; + error = 0; + if (fa->mask & FA_OWNER && fa->mask & FA_GROUP) modemask = FA_SETIDMASK | FA_PERMMASK; else modemask = FA_PERMMASK; /* We only implement fattr_makenode() for dirs for now. */ - assert(fa->type == FT_DIRECTORY); if (fa->mask & FA_MODE) mode = fa->mode & modemask; else mode = 0700; - error = mkdir(path, mode); + + if (fa->type == FT_DIRECTORY) + error = mkdir(path, mode); + else if (fa->type == FT_SYMLINK) { + error = symlink(fa->linktarget, path); + } else if (fa->type == FT_CDEV) { + lprintf(-1, "Character devices not supported!\n"); + } else if (fa->type == FT_BDEV) { + lprintf(-1, "Block devices not supported!\n"); + } return (error); } @@ -823,6 +840,19 @@ fattr_install(struct fattr *fa, const ch } #endif + /* + * If it is changed from a file to a symlink, remove the file + * and create the symlink. + */ + if (inplace && (fa->type == FT_SYMLINK) && + (old->type == FT_FILE)) { + error = unlink(topath); + if (error) + goto bad; + error = symlink(fa->linktarget, topath); + if (error) + goto bad; + } /* Determine whether we need to remove the target first. */ if (!inplace && (fa->type == FT_DIRECTORY) != (old->type == FT_DIRECTORY)) { @@ -853,8 +883,9 @@ fattr_install(struct fattr *fa, const ch if (mask & FA_GROUP) gid = fa->gid; error = chown(frompath, uid, gid); - if (error) + if (error) { goto bad; + } } if (mask & FA_MODE) { newmode = fa->mode & modemask; @@ -901,6 +932,9 @@ fattr_equal(const struct fattr *fa1, con mask = fa1->mask & fa2->mask; if (fa1->type == FT_UNKNOWN || fa2->type == FT_UNKNOWN) return (0); + if (mask & FA_FILETYPE) + if (fa1->type != fa2->type) + return (0); if (mask & FA_MODTIME) if (fa1->modtime != fa2->modtime) return (0); @@ -936,3 +970,12 @@ fattr_equal(const struct fattr *fa1, con return (0); return (1); } + +/* + * Must have to get the correct filesize sendt by the server. + */ +off_t +fattr_filesize(const struct fattr *fa) +{ + return (fa->size); +} Modified: user/sam/wifi/contrib/csup/fattr.h ============================================================================== --- user/sam/wifi/contrib/csup/fattr.h Wed Jan 7 23:30:26 2009 (r186879) +++ user/sam/wifi/contrib/csup/fattr.h Thu Jan 8 00:08:34 2009 (r186880) @@ -101,6 +101,7 @@ int fattr_type(const struct fattr *); void fattr_maskout(struct fattr *, int); int fattr_getmask(const struct fattr *); nlink_t fattr_getlinkcount(const struct fattr *); +char *fattr_getlinktarget(const struct fattr *); void fattr_umask(struct fattr *, mode_t); void fattr_merge(struct fattr *, const struct fattr *); void fattr_mergedefault(struct fattr *); @@ -111,5 +112,7 @@ int fattr_install(struct fattr *, cons int fattr_equal(const struct fattr *, const struct fattr *); void fattr_free(struct fattr *); int fattr_supported(int); +off_t fattr_filesize(const struct fattr *); + #endif /* !_FATTR_H_ */ Modified: user/sam/wifi/contrib/csup/keyword.c ============================================================================== --- user/sam/wifi/contrib/csup/keyword.c Wed Jan 7 23:30:26 2009 (r186879) +++ user/sam/wifi/contrib/csup/keyword.c Thu Jan 8 00:08:34 2009 (r186880) @@ -152,6 +152,29 @@ keyword_decode_expand(const char *expand return (-1); } +const char * +keyword_encode_expand(int expand) +{ + + switch (expand) { + case EXPAND_DEFAULT: + return ("."); + case EXPAND_KEYVALUE: + return ("kv"); + case EXPAND_KEYVALUELOCKER: + return ("kvl"); + case EXPAND_KEY: + return ("k"); + case EXPAND_OLD: + return ("o"); + case EXPAND_BINARY: + return ("b"); + case EXPAND_VALUE: + return ("v"); + } + return (NULL); +} + void keyword_free(struct keyword *keyword) { Modified: user/sam/wifi/contrib/csup/keyword.h ============================================================================== --- user/sam/wifi/contrib/csup/keyword.h Wed Jan 7 23:30:26 2009 (r186879) +++ user/sam/wifi/contrib/csup/keyword.h Thu Jan 8 00:08:34 2009 (r186880) @@ -42,6 +42,7 @@ struct keyword; struct keyword *keyword_new(void); int keyword_decode_expand(const char *); +const char *keyword_encode_expand(int); int keyword_alias(struct keyword *, const char *, const char *); int keyword_enable(struct keyword *, const char *); int keyword_disable(struct keyword *, const char *); Copied: user/sam/wifi/contrib/csup/lex.rcs.c (from r186879, head/contrib/csup/lex.rcs.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/sam/wifi/contrib/csup/lex.rcs.c Thu Jan 8 00:08:34 2009 (r186880, copy of r186879, head/contrib/csup/lex.rcs.c) @@ -0,0 +1,2094 @@ + +#line 3 "lex.rcs.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Jan 8 00:31:49 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 46433106566C; Thu, 8 Jan 2009 00:31:49 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 363188FC13; Thu, 8 Jan 2009 00:31:49 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n080Vmtw003946; Thu, 8 Jan 2009 00:31:48 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n080Vm6R003945; Thu, 8 Jan 2009 00:31:48 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901080031.n080Vm6R003945@svn.freebsd.org> From: Kip Macy Date: Thu, 8 Jan 2009 00:31:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186881 - user/kmacy/HEAD_fast_net/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2009 00:31:49 -0000 Author: kmacy Date: Thu Jan 8 00:31:48 2009 New Revision: 186881 URL: http://svn.freebsd.org/changeset/base/186881 Log: track new vnode creation Modified: user/kmacy/HEAD_fast_net/sys/kern/vfs_subr.c Modified: user/kmacy/HEAD_fast_net/sys/kern/vfs_subr.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/kern/vfs_subr.c Thu Jan 8 00:08:34 2009 (r186880) +++ user/kmacy/HEAD_fast_net/sys/kern/vfs_subr.c Thu Jan 8 00:31:48 2009 (r186881) @@ -169,6 +169,9 @@ SYSCTL_LONG(_vfs, OID_AUTO, freevnodes, static int reassignbufcalls; SYSCTL_INT(_vfs, OID_AUTO, reassignbufcalls, CTLFLAG_RW, &reassignbufcalls, 0, ""); +static int newvnodes; +SYSCTL_INT(_vfs, OID_AUTO, newvnodes, CTLFLAG_RD, &newvnodes, 0, ""); + /* * Cache for the mount type id assigned to NFS. This is used for * special checks in nfs/nfs_nqlease.c and vm/vnode_pager.c. @@ -922,6 +925,8 @@ getnewvnode(const char *tag, struct moun struct bufobj *bo; mtx_lock(&vnode_free_list_mtx); + newvnodes++; + /* * Lend our context to reclaim vnodes if they've exceeded the max. */ From owner-svn-src-user@FreeBSD.ORG Thu Jan 8 09:24:19 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28D561065769; Thu, 8 Jan 2009 09:24:19 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1348A8FC35; Thu, 8 Jan 2009 09:24:19 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n089OJHc014235; Thu, 8 Jan 2009 09:24:19 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n089OIeF014222; Thu, 8 Jan 2009 09:24:18 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901080924.n089OIeF014222@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 8 Jan 2009 09:24:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186888 - in user/luigi/geom_sched/sys: conf dev/ata geom geom/sched modules/geom modules/geom/geom_sched modules/geom/geom_sched/geom_sched modules/geom/geom_sched/gs_as modules/geom/g... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2009 09:24:20 -0000 Author: luigi Date: Thu Jan 8 09:24:18 2009 New Revision: 186888 URL: http://svn.freebsd.org/changeset/base/186888 Log: initial snapshot of geom disk schedulers by Fabio Checconi. Added: user/luigi/geom_sched/sys/geom/sched/ user/luigi/geom_sched/sys/geom/sched/g_as.c user/luigi/geom_sched/sys/geom/sched/g_gsched.h user/luigi/geom_sched/sys/geom/sched/g_rr.c user/luigi/geom_sched/sys/geom/sched/g_sched.c user/luigi/geom_sched/sys/geom/sched/g_sched.h user/luigi/geom_sched/sys/geom/sched/gs_as.c user/luigi/geom_sched/sys/geom/sched/gs_rr.c user/luigi/geom_sched/sys/modules/geom/geom_sched/ user/luigi/geom_sched/sys/modules/geom/geom_sched/Makefile user/luigi/geom_sched/sys/modules/geom/geom_sched/geom_sched/ user/luigi/geom_sched/sys/modules/geom/geom_sched/geom_sched/Makefile user/luigi/geom_sched/sys/modules/geom/geom_sched/gs_as/ user/luigi/geom_sched/sys/modules/geom/geom_sched/gs_as/Makefile user/luigi/geom_sched/sys/modules/geom/geom_sched/gs_rr/ user/luigi/geom_sched/sys/modules/geom/geom_sched/gs_rr/Makefile user/luigi/geom_sched/sys/modules/geom/geom_sched/gsched_as/ user/luigi/geom_sched/sys/modules/geom/geom_sched/gsched_as/Makefile user/luigi/geom_sched/sys/modules/geom/geom_sched/gsched_rr/ user/luigi/geom_sched/sys/modules/geom/geom_sched/gsched_rr/Makefile Modified: user/luigi/geom_sched/sys/conf/NOTES user/luigi/geom_sched/sys/conf/files user/luigi/geom_sched/sys/conf/options user/luigi/geom_sched/sys/dev/ata/ata-all.h user/luigi/geom_sched/sys/dev/ata/ata-disk.c user/luigi/geom_sched/sys/dev/ata/ata-queue.c user/luigi/geom_sched/sys/geom/geom_disk.c user/luigi/geom_sched/sys/geom/geom_disk.h user/luigi/geom_sched/sys/geom/geom_io.c user/luigi/geom_sched/sys/modules/geom/Makefile user/luigi/geom_sched/sys/sys/bio.h Modified: user/luigi/geom_sched/sys/conf/NOTES ============================================================================== --- user/luigi/geom_sched/sys/conf/NOTES Thu Jan 8 06:38:06 2009 (r186887) +++ user/luigi/geom_sched/sys/conf/NOTES Thu Jan 8 09:24:18 2009 (r186888) @@ -153,6 +153,10 @@ options GEOM_PART_MBR # MBR partitioni options GEOM_PART_VTOC8 # SMI VTOC8 disk label options GEOM_PC98 # NEC PC9800 partitioning options GEOM_RAID3 # RAID3 functionality. +options GEOM_SCHED # Disk scheduling in GEOM. +options GEOM_GSCHED_AS # Geom-based anticipatory. +options GEOM_GS_AS # Driver-based anticipatory. +options GEOM_GS_RR # Driver-based round-robin. options GEOM_SHSEC # Shared secret. options GEOM_STRIPE # Disk striping. options GEOM_SUNLABEL # Sun/Solaris partitioning Modified: user/luigi/geom_sched/sys/conf/files ============================================================================== --- user/luigi/geom_sched/sys/conf/files Thu Jan 8 06:38:06 2009 (r186887) +++ user/luigi/geom_sched/sys/conf/files Thu Jan 8 09:24:18 2009 (r186888) @@ -1283,6 +1283,7 @@ geom/geom_mbr_enc.c optional geom_mbr geom/geom_pc98.c optional geom_pc98 geom/geom_pc98_enc.c optional geom_pc98 geom/geom_slice.c standard +geom/geom_sched.c standard geom/geom_subr.c standard geom/geom_sunlabel.c optional geom_sunlabel geom/geom_sunlabel_enc.c optional geom_sunlabel @@ -1312,6 +1313,11 @@ geom/part/g_part_vtoc8.c optional geom_p geom/raid3/g_raid3.c optional geom_raid3 geom/raid3/g_raid3_ctl.c optional geom_raid3 geom/shsec/g_shsec.c optional geom_shsec +geom/sched/g_sched.c optional geom_sched +geom/sched/g_as.c optional geom_gsched_as +geom/sched/g_rr.c optional geom_gsched_rr +geom/sched/gs_as.c optional geom_gs_as +geom/sched/gs_rr.c optional geom_gs_rr geom/stripe/g_stripe.c optional geom_stripe geom/uzip/g_uzip.c optional geom_uzip geom/virstor/binstream.c optional geom_virstor Modified: user/luigi/geom_sched/sys/conf/options ============================================================================== --- user/luigi/geom_sched/sys/conf/options Thu Jan 8 06:38:06 2009 (r186887) +++ user/luigi/geom_sched/sys/conf/options Thu Jan 8 09:24:18 2009 (r186888) @@ -98,6 +98,10 @@ GEOM_PART_MBR opt_geom.h GEOM_PART_VTOC8 opt_geom.h GEOM_PC98 opt_geom.h GEOM_RAID3 opt_geom.h +GEOM_SCHED opt_geom.h +GEOM_GSCHED_AS opt_geom.h +GEOM_GS_AS opt_geom.h +GEOM_GS_RR opt_geom.h GEOM_SHSEC opt_geom.h GEOM_STRIPE opt_geom.h GEOM_SUNLABEL opt_geom.h Modified: user/luigi/geom_sched/sys/dev/ata/ata-all.h ============================================================================== --- user/luigi/geom_sched/sys/dev/ata/ata-all.h Thu Jan 8 06:38:06 2009 (r186887) +++ user/luigi/geom_sched/sys/dev/ata/ata-all.h Thu Jan 8 09:24:18 2009 (r186888) @@ -510,6 +510,7 @@ struct ata_channel { TAILQ_HEAD(, ata_request) ata_queue; /* head of ATA queue */ struct ata_request *freezepoint; /* composite freezepoint */ struct ata_request *running; /* currently running request */ + struct disk *disks[2]; /* disks, if any */ }; /* disk bay/enclosure related */ @@ -546,6 +547,9 @@ int ata_wmode(struct ata_params *ap); int ata_umode(struct ata_params *ap); int ata_limit_mode(device_t dev, int mode, int maxmode); +/* ata-disk.c */ +struct ata_request *ata_create_request(struct bio *bp, int full); + /* ata-queue.c: */ int ata_controlcmd(device_t dev, u_int8_t command, u_int16_t feature, u_int64_t lba, u_int16_t count); int ata_atapicmd(device_t dev, u_int8_t *ccb, caddr_t data, int count, int flags, int timeout); Modified: user/luigi/geom_sched/sys/dev/ata/ata-disk.c ============================================================================== --- user/luigi/geom_sched/sys/dev/ata/ata-disk.c Thu Jan 8 06:38:06 2009 (r186887) +++ user/luigi/geom_sched/sys/dev/ata/ata-disk.c Thu Jan 8 09:24:18 2009 (r186888) @@ -60,6 +60,7 @@ static void ad_describe(device_t dev); static int ad_version(u_int16_t); static disk_strategy_t ad_strategy; static disk_ioctl_t ad_ioctl; +static disk_kick_t ad_kick; static dumper_t ad_dump; /* @@ -148,6 +149,7 @@ ad_attach(device_t dev) adp->disk = disk_alloc(); adp->disk->d_strategy = ad_strategy; adp->disk->d_ioctl = ad_ioctl; + adp->disk->d_kick = ad_kick; adp->disk->d_dump = ad_dump; adp->disk->d_name = "ad"; adp->disk->d_drv1 = dev; @@ -168,6 +170,7 @@ ad_attach(device_t dev) snprintf(adp->disk->d_ident, sizeof(adp->disk->d_ident), "ad:%s", atadev->param.serial); disk_create(adp->disk, DISK_VERSION); + ch->disks[atadev->unit == ATA_SLAVE] = adp->disk; device_add_child(dev, "subdisk", device_get_unit(dev)); ad_firmware_geom_adjust(dev, adp->disk); bus_generic_attach(dev); @@ -179,6 +182,7 @@ ad_attach(device_t dev) static int ad_detach(device_t dev) { + struct ata_channel *ch = device_get_softc(device_get_parent(dev)); struct ad_softc *adp = device_get_ivars(dev); struct ata_device *atadev = device_get_softc(dev); device_t *children; @@ -199,6 +203,8 @@ ad_detach(device_t dev) free(children, M_TEMP); } + ch->disks[atadev->unit == ATA_SLAVE] = NULL; + /* detroy disk from the system so we dont get any further requests */ disk_destroy(adp->disk); @@ -266,13 +272,13 @@ ad_spindown(void *priv) ata_queue_request(request); } - -static void -ad_strategy(struct bio *bp) +struct ata_request * +ata_create_request(struct bio *bp, int full) { - device_t dev = bp->bio_disk->d_drv1; + device_t dev = bp->bio_disk->d_drv1; struct ata_device *atadev = device_get_softc(dev); struct ata_request *request; + struct ata_channel *ch; if (atadev->spindown != 0) callout_reset(&atadev->spindown_timer, hz * atadev->spindown, @@ -281,7 +287,7 @@ ad_strategy(struct bio *bp) if (!(request = ata_alloc_request())) { device_printf(dev, "FAILURE - out of memory in start\n"); biofinish(bp, NULL, ENOMEM); - return; + return NULL; } /* setup request */ @@ -344,10 +350,32 @@ ad_strategy(struct bio *bp) device_printf(dev, "FAILURE - unknown BIO operation\n"); ata_free_request(request); biofinish(bp, NULL, EIO); - return; + return NULL; } request->flags |= ATA_R_ORDERED; - ata_queue_request(request); + + if (full != 0) { + if ((request->parent = device_get_parent(dev)) == NULL) { + ata_free_request(request); + biofinish(bp, NULL, ENXIO); + return NULL; + } + + ch = device_get_softc(request->parent); + callout_init_mtx(&request->callout, &ch->state_mtx, + CALLOUT_RETURNUNLOCKED); + } + + return request; +} + +static void +ad_strategy(struct bio *bp) +{ + struct ata_request *request; + + if ((request = ata_create_request(bp, 0)) != NULL) + ata_queue_request(request); } static void @@ -369,6 +397,18 @@ ad_ioctl(struct disk *disk, u_long cmd, return ata_device_ioctl(disk->d_drv1, cmd, data); } +static void +ad_kick(struct disk *disk) +{ + device_t dev; + struct ata_channel *ch; + + dev = disk->d_drv1; + ch = device_get_softc(device_get_parent(dev)); + if (ch != NULL) + ata_start(ch->dev); +} + static int ad_dump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t length) Modified: user/luigi/geom_sched/sys/dev/ata/ata-queue.c ============================================================================== --- user/luigi/geom_sched/sys/dev/ata/ata-queue.c Thu Jan 8 06:38:06 2009 (r186887) +++ user/luigi/geom_sched/sys/dev/ata/ata-queue.c Thu Jan 8 09:24:18 2009 (r186888) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include /* prototypes */ static void ata_completed(void *, int); @@ -171,10 +172,25 @@ ata_start(device_t dev) struct ata_channel *ch = device_get_softc(dev); struct ata_request *request; struct ata_composite *cptr; - int dependencies = 0; + struct disk *dp; + struct bio *bp; + int dependencies = 0, i; - /* if we have a request on the queue try to get it running */ mtx_lock(&ch->queue_mtx); + if (TAILQ_FIRST(&ch->ata_queue) == NULL) { + for (i = 0; i < 2; i++) { + dp = ch->disks[i]; + while (dp != NULL && (bp = g_sched_next(dp)) != NULL) { + request = ata_create_request(bp, 1); + if (request != NULL) { + ata_sort_queue(ch, request); + break; + } + } + } + } + + /* if we have a request on the queue try to get it running */ if ((request = TAILQ_FIRST(&ch->ata_queue))) { /* we need the locking function to get the lock for this channel */ Modified: user/luigi/geom_sched/sys/geom/geom_disk.c ============================================================================== --- user/luigi/geom_sched/sys/geom/geom_disk.c Thu Jan 8 06:38:06 2009 (r186887) +++ user/luigi/geom_sched/sys/geom/geom_disk.c Thu Jan 8 09:24:18 2009 (r186888) @@ -55,9 +55,11 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include static struct mtx g_disk_done_mtx; +static g_ctl_req_t g_disk_ctlreq; static g_access_t g_disk_access; static g_init_t g_disk_init; static g_fini_t g_disk_fini; @@ -68,6 +70,7 @@ static g_dumpconf_t g_disk_dumpconf; static struct g_class g_disk_class = { .name = "DISK", .version = G_VERSION, + .ctlreq = g_disk_ctlreq, .init = g_disk_init, .fini = g_disk_fini, .start = g_disk_start, @@ -81,16 +84,19 @@ g_disk_init(struct g_class *mp __unused) { mtx_init(&g_disk_done_mtx, "g_disk_done", NULL, MTX_DEF); + g_sched_init(); } static void g_disk_fini(struct g_class *mp __unused) { + g_sched_fini(); mtx_destroy(&g_disk_done_mtx); } DECLARE_GEOM_CLASS(g_disk_class, g_disk); +MODULE_VERSION(g_disk, 0); static void __inline g_disk_lock_giant(struct disk *dp) @@ -106,6 +112,83 @@ g_disk_unlock_giant(struct disk *dp) mtx_unlock(&Giant); } +static void +g_disk_configure(struct gctl_req *req, struct g_class *mp) +{ + struct disk *dp; + struct g_provider *pp; + const char *sched, *name; + char param[16]; + int i, *nargs; + + g_topology_assert(); + + nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs)); + if (nargs == NULL) { + gctl_error(req, "No '%s' argument.", "nargs"); + return; + } + + if (*nargs <= 0) { + gctl_error(req, "Missing devices."); + return; + } + + sched = gctl_get_asciiparam(req, "iosched"); + if (sched == NULL) { + gctl_error(req, "No '%s' argument.", "iosched"); + return; + } + + for (i = 0; i < *nargs; i++) { + snprintf(param, sizeof(param), "arg%d", i); + name = gctl_get_asciiparam(req, param); + if (name == NULL) { + gctl_error(req, "No '%s' argument.", param); + return; + } + + if (strncmp(name, "/dev/", strlen("/dev/")) == 0) + name += strlen("/dev/"); + + pp = g_provider_by_name(name); + if (pp == NULL || pp->geom->class != mp) { + gctl_error(req, "Provider %s is invalid.", name); + return; + } + + dp = pp->geom->softc; + if (g_sched_configure(dp, sched) != 0) { + gctl_error(req, "Could not set scheduler %s.", sched); + return; + } + } +} + +static void +g_disk_ctlreq(struct gctl_req *req, struct g_class *mp, const char *verb) +{ + uint32_t *version; + + g_topology_assert(); + + version = gctl_get_paraml(req, "version", sizeof(*version)); + if (version == NULL) { + gctl_error(req, "No '%s' argument.", "version"); + return; + } + + if (*version != G_VERSION) { + gctl_error(req, "Userland and kernel parts are out of sync."); + return; + } + + if (strcmp(verb, "configure") == 0) + g_disk_configure(req, mp); + else + gctl_error(req, "Unknown verb."); +} + static int g_disk_access(struct g_provider *pp, int r, int w, int e) { @@ -198,6 +281,8 @@ g_disk_done(struct bio *bp) mtx_lock(&g_disk_done_mtx); bp->bio_completed = bp->bio_length - bp->bio_resid; + g_sched_done(bp); + bp2 = bp->bio_parent; if (bp2->bio_error == 0) bp2->bio_error = bp->bio_error; @@ -288,7 +373,7 @@ g_disk_start(struct bio *bp) bp2->bio_disk = dp; devstat_start_transaction_bio(dp->d_devstat, bp2); g_disk_lock_giant(dp); - dp->d_strategy(bp2); + g_sched_start(dp, bp2); g_disk_unlock_giant(dp); bp2 = bp3; bp3 = NULL; @@ -466,6 +551,7 @@ disk_create(struct disk *dp, int version dp->d_sectorsize, DEVSTAT_ALL_SUPPORTED, DEVSTAT_TYPE_DIRECT, DEVSTAT_PRIORITY_MAX); dp->d_geom = NULL; + g_sched_disk_init(dp); g_disk_ident_adjust(dp->d_ident, sizeof(dp->d_ident)); g_post_event(g_disk_create, dp, M_WAITOK, dp, NULL); } @@ -476,6 +562,7 @@ disk_destroy(struct disk *dp) g_cancel_event(dp); dp->d_destroyed = 1; + g_sched_disk_fini(dp); if (dp->d_devstat != NULL) devstat_remove_entry(dp->d_devstat); g_post_event(g_disk_destroy, dp, M_WAITOK, NULL); @@ -487,6 +574,8 @@ disk_gone(struct disk *dp) struct g_geom *gp; struct g_provider *pp; + g_sched_disk_gone(dp); + gp = dp->d_geom; if (gp != NULL) LIST_FOREACH(pp, &gp->provider, provider) Modified: user/luigi/geom_sched/sys/geom/geom_disk.h ============================================================================== --- user/luigi/geom_sched/sys/geom/geom_disk.h Thu Jan 8 06:38:06 2009 (r186887) +++ user/luigi/geom_sched/sys/geom/geom_disk.h Thu Jan 8 09:24:18 2009 (r186888) @@ -53,7 +53,10 @@ typedef int disk_ioctl_t(struct disk *, int fflag, struct thread *td); /* NB: disk_ioctl_t SHALL be cast'able to d_ioctl_t */ +typedef void disk_kick_t(struct disk *); + struct g_geom; +struct g_sched; struct devstat; struct disk { @@ -74,6 +77,7 @@ struct disk { disk_close_t *d_close; disk_strategy_t *d_strategy; disk_ioctl_t *d_ioctl; + disk_kick_t *d_kick; dumper_t *d_dump; /* Info fields from driver to geom_disk.c. Valid when open */ @@ -86,6 +90,13 @@ struct disk { u_int d_stripesize; char d_ident[DISK_IDENT_SIZE]; + /* Scheduler fields */ + struct mtx d_sched_lock; + u_int d_sched_flags; + u_int d_nr_sorted; + struct g_sched *d_sched; + void *d_sched_data; + /* Fields private to the driver */ void *d_drv1; }; Modified: user/luigi/geom_sched/sys/geom/geom_io.c ============================================================================== --- user/luigi/geom_sched/sys/geom/geom_io.c Thu Jan 8 06:38:06 2009 (r186887) +++ user/luigi/geom_sched/sys/geom/geom_io.c Thu Jan 8 09:24:18 2009 (r186888) @@ -172,6 +172,7 @@ g_clone_bio(struct bio *bp) bp2->bio_offset = bp->bio_offset; bp2->bio_data = bp->bio_data; bp2->bio_attribute = bp->bio_attribute; + bp2->bio_thread = bp->bio_thread; bp->bio_children++; } #ifdef KTR @@ -369,6 +370,10 @@ g_io_request(struct bio *bp, struct g_co bp->bio_error = 0; bp->bio_completed = 0; + /* Pass down the thread that issued the bio. */ + if (bp->bio_thread == NULL) + bp->bio_thread = curthread; + KASSERT(!(bp->bio_flags & BIO_ONQUEUE), ("Bio already on queue bp=%p", bp)); bp->bio_flags |= BIO_ONQUEUE; Added: user/luigi/geom_sched/sys/geom/sched/g_as.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/luigi/geom_sched/sys/geom/sched/g_as.c Thu Jan 8 09:24:18 2009 (r186888) @@ -0,0 +1,204 @@ +/*- + * Copyright (c) 2007 Fabio Checconi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/* + * Status values for AS. + */ +#define G_AS_NOWAIT 0 /* Not wating at all. */ +#define G_AS_WAITREQ 1 /* Waiting a request to complete. */ +#define G_AS_WAITING 2 /* Waiting a new request. */ + +struct g_as_softc { + struct g_geom *sc_geom; + struct thread *sc_curthread; + int sc_status; + long sc_batch; + + struct callout sc_wait; + struct bio_queue_head sc_bioq; +}; + +#define G_AS_WAIT_EXPIRE (hz/200 > 0 ? hz/200 : 2) +#define G_AS_MAX_BATCH 0x00800000 + +/* + * Dispatch the first queued request. Here we also update the status + * according to the dispatched request. + */ +static void +g_as_dispatch(struct g_as_softc *sc) +{ + struct bio *bio; + + /* + * Batching means just don't serve too many requests waiting + * for sequential ones, it is not really coupled with the + * threads being served. Its only purpose is to let not the + * scheduler starve other threads while an aggressive one + * is making continuously new requests. + */ + sc->sc_curthread = NULL; + + bio = bioq_takefirst(&sc->sc_bioq); + if (bio != NULL) { + sc->sc_batch += bio->bio_length; + if (sc->sc_batch > G_AS_MAX_BATCH) { + /* + * Too many requests served here, don't wait + * for the next. + */ + sc->sc_batch = 0; + sc->sc_status = G_AS_NOWAIT; + } else { + /* + * When this request will be served we'll wait + * for a new one from the same thread. + * Of course we are anticipating everything + * here, even writes or asynchronous requests, + * but this is only a prototype. + */ + sc->sc_status = G_AS_WAITREQ; + } + g_io_request(bio, LIST_FIRST(&sc->sc_geom->consumer)); + } else + sc->sc_status = G_AS_NOWAIT; +} + +static void +g_as_wait_timeout(void *data) +{ + struct g_as_softc *sc = data; + + g_sched_lock(sc->sc_geom); + /* + * We were waiting for a new request for curthread, it did + * not come, just dispatch the next one. + */ + if (sc->sc_status == G_AS_WAITING) + g_as_dispatch(sc); + g_sched_unlock(sc->sc_geom); +} + +static void +g_as_start(void *data, struct bio *bio) +{ + struct g_as_softc *sc = data; + + bioq_disksort(&sc->sc_bioq, bio); + + /* + * If the request being submitted is the one we were waiting for + * stop the timer and dispatch it, otherwise do nothing. + */ + if (sc->sc_status == G_AS_NOWAIT || + bio->bio_thread == sc->sc_curthread) { + callout_stop(&sc->sc_wait); + g_as_dispatch(sc); + } +} + +static void +g_as_done(void *data, struct bio *bio) +{ + struct g_as_softc *sc = data; + struct bio *bp2; + + bp2 = bio->bio_parent; + + /* Don't wait when fragments are completed. */ + if (bp2->bio_children != bp2->bio_inbed + 1) + return; + + if (sc->sc_status == G_AS_WAITREQ) { + /* + * Start waiting for a new request from curthread. + */ + sc->sc_curthread = bio->bio_thread; + sc->sc_status = G_AS_WAITING; + callout_reset(&sc->sc_wait, G_AS_WAIT_EXPIRE, + g_as_wait_timeout, sc); + } else { + /* + * Since we don't have to wait anything just dispatch + * the next request. + */ + g_as_dispatch(sc); + } +} + +static void * +g_as_init(struct g_geom *geom) +{ + struct g_as_softc *sc; + + sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO); + sc->sc_geom = geom; + sc->sc_curthread = NULL; + sc->sc_status = G_AS_NOWAIT; + + callout_init(&sc->sc_wait, CALLOUT_MPSAFE); + bioq_init(&sc->sc_bioq); + + return sc; +} + +static void +g_as_fini(void *data) +{ + struct g_as_softc *sc = data; + + KASSERT(bioq_first(&sc->sc_bioq) == NULL, + ("Still requests pending.")); + callout_drain(&sc->sc_wait); + + g_free(sc); +} + +static struct g_gsched g_as = { + .gs_name = "as", + .gs_init = g_as_init, + .gs_fini = g_as_fini, + .gs_start = g_as_start, + .gs_done = g_as_done, +}; + +DECLARE_GSCHED_MODULE(as, &g_as); Added: user/luigi/geom_sched/sys/geom/sched/g_gsched.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/luigi/geom_sched/sys/geom/sched/g_gsched.h Thu Jan 8 09:24:18 2009 (r186888) @@ -0,0 +1,88 @@ +/*- + * Copyright (c) 2008 Fabio Checconi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _G_GSCHED_H_ +#define _G_GSCHED_H_ + +#ifdef _KERNEL +#include +#include +#include +#include +#include + +/* + * This is the interface exported to scheduling modules. + */ +/* + * Geom I/O scheduler descriptor. + */ +struct g_geom; + +typedef void *gs_init_t (struct g_geom *geom); +typedef void gs_fini_t (void *data); +typedef void gs_start_t (void *data, struct bio *bio); +typedef void gs_done_t (void *data, struct bio *bio); + +struct g_gsched { + const char *gs_name; + int gs_refs; + + gs_init_t *gs_init; + gs_fini_t *gs_fini; + gs_start_t *gs_start; + gs_done_t *gs_done; + + LIST_ENTRY(g_gsched) glist; +}; + +/* + * Locking interface. When each operation registered with the + * scheduler is invoked, a per-instance lock is taken to protect + * the data associated with it. If the scheduler needs something + * else to access the same data (e.g., a callout) it must use + * these functions. + */ +void g_sched_lock(struct g_geom *gp); +void g_sched_unlock(struct g_geom *gp); + +/* + * Declaration of a scheduler module. + */ +int g_gsched_modevent(module_t mod, int cmd, void *arg); + +#define DECLARE_GSCHED_MODULE(name, gsched) \ + static moduledata_t name##_mod = { \ + #name, \ + g_gsched_modevent, \ + gsched, \ + }; \ + DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_ANY); \ + MODULE_DEPEND(name, g_sched, 0, 0, 0); + +#endif /* _KERNEL */ + +#endif /* _G_GSCHED_H_ */ Added: user/luigi/geom_sched/sys/geom/sched/g_rr.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/luigi/geom_sched/sys/geom/sched/g_rr.c Thu Jan 8 09:24:18 2009 (r186888) @@ -0,0 +1,355 @@ +/*- + * Copyright (c) 2008 Fabio Checconi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Trivial round robin disk scheduler, with per-thread queues, always + * anticipating requests from the last served thread. + */ + +/* Timeout for anticipation. */ +#define G_RR_WAIT_EXPIRE (hz/200 > 0 ? hz/200 : 2) + +#define G_QUEUE_NOWAIT 0 /* Ready to dispatch. */ +#define G_QUEUE_WAITREQ 1 /* Waiting for a completion. */ +#define G_QUEUE_WAITING 2 /* Waiting for a new request. */ + +/* + * Per process (thread) queue structure. Each process (thread) in the + * system that accesses the disk managed by an instance of this scheduler + * has an associated queue. + */ +struct g_rr_queue { + int q_refs; + int q_status; + u_long q_key; + struct proc *q_proc; + + struct bio_queue_head q_bioq; + unsigned int q_service; + unsigned int q_budget; + + LIST_ENTRY(g_rr_queue) q_hash; + TAILQ_ENTRY(g_rr_queue) q_tailq; +}; + +/* List types. */ +TAILQ_HEAD(g_rr_tailq, g_rr_queue); +LIST_HEAD(g_hash, g_rr_queue); + +/* Size of the per-device hash table storing threads. */ +#define G_RR_HASH_SIZE 32 + +/* Default slice for RR between queues. */ +#define G_RR_DEFAULT_BUDGET 0x00800000 + +/* + * Per device descriptor. It holds the RR list of queues accessing + * the disk. + */ +struct g_rr_softc { + struct g_geom *sc_geom; + + struct g_rr_queue *sc_active; + struct g_rr_tailq sc_rr_tailq; + + struct g_hash *sc_hash; + u_long sc_hash_mask; + + struct callout sc_wait; +}; + +static inline u_long +g_rr_key(struct thread *tp) +{ + + return (tp != NULL ? tp->td_tid : 0); +} + +/* Return the hash chain for the given key. */ +static inline struct g_hash * +g_rr_hash(struct g_rr_softc *sc, u_long key) +{ + + return (&sc->sc_hash[key & sc->sc_hash_mask]); +} + +/* + * Get a reference to the queue that holds requests for tp, allocating + * it if necessary. + */ +static struct g_rr_queue * +g_rr_queue_get(struct g_rr_softc *sc, struct thread *tp) +{ + struct g_hash *bucket; + struct g_rr_queue *qp; + u_long key; + + key = g_rr_key(tp); + bucket = g_rr_hash(sc, key); + LIST_FOREACH(qp, bucket, q_hash) { + if (qp->q_key == key) { + qp->q_refs++; + return (qp); + } + } + + qp = g_malloc(sizeof *qp, M_NOWAIT | M_ZERO); + + if (qp != NULL) { + /* One for the hash table, one for the caller. */ + qp->q_refs = 2; + + qp->q_key = key; + qp->q_proc = tp->td_proc; + bioq_init(&qp->q_bioq); + qp->q_budget = G_RR_DEFAULT_BUDGET; + LIST_INSERT_HEAD(bucket, qp, q_hash); + } + + return (qp); +} + +/* + * Release a reference to the queue. + */ +static void +g_rr_queue_put(struct g_rr_queue *qp) +{ + + if (--qp->q_refs > 0) + return; + + LIST_REMOVE(qp, q_hash); + KASSERT(bioq_first(&qp->q_bioq) == NULL, ("released nonempty queue")); + + g_free(qp); +} + +static void * +g_rr_init(struct g_geom *geom) +{ + struct g_rr_softc *sc; + + sc = g_malloc(sizeof *sc, M_WAITOK | M_ZERO); + sc->sc_geom = geom; + TAILQ_INIT(&sc->sc_rr_tailq); + sc->sc_hash = hashinit(G_RR_HASH_SIZE, M_GEOM, &sc->sc_hash_mask); + callout_init(&sc->sc_wait, CALLOUT_MPSAFE); + + return (sc); +} + +static void +g_rr_fini(void *data) +{ + struct g_rr_softc *sc; + struct g_rr_queue *qp, *qp2; + int i; + + sc = data; + callout_drain(&sc->sc_wait); + KASSERT(sc->sc_active == NULL, ("still a queue under service")); + KASSERT(TAILQ_EMPTY(&sc->sc_rr_tailq), ("still scheduled queues")); + for (i = 0; i < G_RR_HASH_SIZE; i++) { + LIST_FOREACH_SAFE(qp, &sc->sc_hash[i], q_hash, qp2) { + LIST_REMOVE(qp, q_hash); + g_rr_queue_put(qp); + } + } + hashdestroy(sc->sc_hash, M_GEOM, sc->sc_hash_mask); + g_free(sc); +} + +/* + * Activate a queue, inserting it into the RR list and preparing it + * to be served. + */ +static inline void +g_rr_activate(struct g_rr_softc *sc, struct g_rr_queue *qp) +{ + + qp->q_service = 0; + TAILQ_INSERT_TAIL(&sc->sc_rr_tailq, qp, q_tailq); +} + +static void +g_rr_dispatch(struct g_rr_softc *sc) +{ + struct g_rr_queue *qp; + struct bio *bp, *next; + + /* Try with the queue under service first. */ + qp = sc->sc_active; + if (qp == NULL) { + /* No queue under service, look for the first in RR order. */ + qp = TAILQ_FIRST(&sc->sc_rr_tailq); + if (qp == NULL) { + /* No queue at all, just return. */ + return; + } + /* Select the new queue for service. */ + TAILQ_REMOVE(&sc->sc_rr_tailq, qp, q_tailq); + sc->sc_active = qp; + } else if (qp->q_status != G_QUEUE_NOWAIT) { + /* Queue is anticipating, stop dispatching. */ + return; + } + + bp = bioq_takefirst(&qp->q_bioq); + qp->q_service += bp->bio_length; + next = bioq_first(&qp->q_bioq); + if (qp->q_service > qp->q_budget) { + /* Queue exhausted its budget. */ + sc->sc_active = NULL; + if (next != NULL) { + /* If it has more requests requeue it. */ + qp->q_status = G_QUEUE_NOWAIT; + g_rr_activate(sc, qp); + } else { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Jan 8 09:38:19 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 29A62106564A; Thu, 8 Jan 2009 09:38:19 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1554F8FC1B; Thu, 8 Jan 2009 09:38:19 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n089cI5D014503; Thu, 8 Jan 2009 09:38:18 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n089cIGJ014502; Thu, 8 Jan 2009 09:38:18 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901080938.n089cIGJ014502@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 8 Jan 2009 09:38:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186889 - user/luigi/geom_sched/sys/geom X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2009 09:38:20 -0000 Author: luigi Date: Thu Jan 8 09:38:18 2009 New Revision: 186889 URL: http://svn.freebsd.org/changeset/base/186889 Log: add forgotten file Added: user/luigi/geom_sched/sys/geom/geom_sched.c Added: user/luigi/geom_sched/sys/geom/geom_sched.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/luigi/geom_sched/sys/geom/geom_sched.c Thu Jan 8 09:38:18 2009 (r186889) @@ -0,0 +1,509 @@ +/*- + * Copyright (c) 2008 Fabio Checconi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define G_SCHED_FLUSHING 1 /* Disk flush in progress. */ +#define G_SCHED_SWITCHING 2 /* Switching schedulers (debug.) */ + +/* Debug sysctl stuff. */ +SYSCTL_DECL(_kern_geom); +SYSCTL_NODE(_kern_geom, OID_AUTO, sched, CTLFLAG_RW, 0, "I/O scheduler stuff"); +u_int g_sched_debug; +SYSCTL_UINT(_kern_geom_sched, OID_AUTO, debug, CTLFLAG_RW, &g_sched_debug, 0, + "Debug level"); + +/* + * Global mutex, protecting the registered schedulers' list and their + * gs_refs field. + */ +static struct mtx g_sched_mtx; + +/* Global list of registered schedulers. */ +LIST_HEAD(g_sched_list, g_sched); +static struct g_sched_list g_sched_list; + +/* Initialization flag. */ +static int g_sched_initialized; + +void +g_sched_init(void) +{ + + if (g_sched_initialized != 0) + return; + + g_sched_initialized = 1; + + mtx_init(&g_sched_mtx, "I/O scheduler", NULL, MTX_DEF); + LIST_INIT(&g_sched_list); +} + +void +g_sched_fini(void) +{ + + /* + * This function is called when the g_disk module is unloaded, + * since all the scheduler modules depend on it, they must have + * been unregistered. + */ + KASSERT(LIST_EMPTY(&g_sched_list), ("still registered schedulers")); + mtx_destroy(&g_sched_mtx); +} + +void +g_sched_disk_init(struct disk *dp) +{ + + mtx_init(&dp->d_sched_lock, "disk I/O scheduler", NULL, MTX_DEF); + dp->d_sched_flags = 0; + dp->d_nr_sorted = 0; + dp->d_sched = NULL; + dp->d_sched_data = NULL; +} + +/* + * Flush the scheduler, assuming that the disk d_sched_lock mutex is + * held. This function tries to dispatch all the requests queued in + * the target scheduler and to wait until they're completed. Flushing + * is implemented avoiding queueing for all the requests arriving while + * the flush is in progres. + */ +static void +g_sched_flush_locked(struct disk *dp) +{ + struct g_sched *gsp; + + gsp = dp->d_sched; + if (gsp == NULL) + return; + + dp->d_sched_flags |= G_SCHED_FLUSHING; + G_SCHED_DEBUG(2, "geom_sched: flushing"); + while (dp->d_nr_sorted > 0) { + mtx_unlock(&dp->d_sched_lock); + dp->d_kick(dp); + G_SCHED_DEBUG(2, "geom_sched: %d to flush", dp->d_nr_sorted); + tsleep(&dp->d_sched, 0, "I/O sched flush", hz); + mtx_lock(&dp->d_sched_lock); + } + dp->d_sched_flags &= ~G_SCHED_FLUSHING; +} + +void +g_sched_disk_gone(struct disk *dp) +{ + struct g_sched *gsp; + struct bio *bp; + + mtx_lock(&dp->d_sched_lock); + gsp = dp->d_sched; + if (gsp != NULL) { + while ((bp = gsp->gs_next(dp->d_sched_data, 1)) != NULL) { + mtx_unlock(&dp->d_sched_lock); + /* + * Discard all the requests in the scheduler with + * an appropriate error. Need to release the disk + * lock since completion callbacks may reenter the + * scheduler. + */ + biofinish(bp, NULL, ENXIO); + mtx_lock(&dp->d_sched_lock); + } + } + mtx_unlock(&dp->d_sched_lock); +} + +void +g_sched_disk_fini(struct disk *dp) +{ + + g_sched_disk_gone(dp); + /* + * Here we assume that no new requests reach the scheduler, since + * the disk is almost already destroyed. + */ + g_sched_configure(dp, "none"); + mtx_destroy(&dp->d_sched_lock); +} + +void +g_sched_start(struct disk *dp, struct bio *bp) +{ + struct g_sched *gsp; + + mtx_lock(&dp->d_sched_lock); + gsp = dp->d_sched; + + /* + * Don't try to queue a request if we have no scheduler for + * this disk, or if the request is not one of the type we care + * about (i.e., it is not a read or write). + */ + if (gsp == NULL || (bp->bio_cmd & (BIO_READ | BIO_WRITE)) == 0) + goto nosched; + + /* + * When flushing is in progress we don't want the scheduler + * queue to grow, so we dispatch new requests directly to the + * driver. + */ + if ((dp->d_sched_flags & G_SCHED_FLUSHING) != 0) + goto nosched; + + dp->d_nr_sorted++; + gsp->gs_start(dp->d_sched_data, bp); + mtx_unlock(&dp->d_sched_lock); + + /* + * Try to immediately start the queue. It is up to the scheduler + * to freeze it if needed (returning NULL on the next invocation + * of gs_next()). The scheduler will also be responsible of + * restarting the dispatches to the driver, invoking d_kick() + * directly. + */ + dp->d_kick(dp); + return; + +nosched: + mtx_unlock(&dp->d_sched_lock); + + /* + * Mark the request as not sorted by the scheduler. Schedulers + * are supposed to store a non-NULL value in the bio_caller1 field + * (they will need it anyway, unless they're really really simple.) + */ + bp->bio_caller1 = NULL; + dp->d_strategy(bp); +} + +struct bio * +g_sched_next(struct disk *dp) +{ + struct g_sched *gsp; + struct bio *bp; + + bp = NULL; + + mtx_lock(&dp->d_sched_lock); + gsp = dp->d_sched; + + /* If the disk is not using a scheduler, just always return NULL. */ + if (gsp == NULL) + goto out; + + /* Get the next request from the scheduler. */ + bp = gsp->gs_next(dp->d_sched_data, + (dp->d_sched_flags & G_SCHED_FLUSHING) != 0); + + KASSERT(bp == NULL || bp->bio_caller1 != NULL, + ("bio_caller1 == NULL")); + +out: + mtx_unlock(&dp->d_sched_lock); + + return (bp); +} + +void +g_sched_done(struct bio *bp) +{ + struct disk *dp; + struct g_sched *gsp; + int kick; + + dp = bp->bio_disk; + + mtx_lock(&dp->d_sched_lock); + + kick = !!dp->d_nr_sorted; + + gsp = dp->d_sched; + /* + * Don't call the completion callback if we have no scheduler + * or if the request that completed was not one we sorted. + */ + if (gsp == NULL || bp->bio_caller1 == NULL) + goto out; + + kick = gsp->gs_done(dp->d_sched_data, bp); + + /* + * If flush is in progress and we have no more requests queued, + * wake up the flushing process. + */ + if (--dp->d_nr_sorted == 0 && + (dp->d_sched_flags & G_SCHED_FLUSHING) != 0) { + G_SCHED_DEBUG(2, "geom_sched: flush complete"); + wakeup(&dp->d_sched); + } + +out: + mtx_unlock(&dp->d_sched_lock); + + if (kick) + dp->d_kick(dp); +} + +/* + * Try to register a new scheduler. May fail if a scheduler with the + * same name is already registered. + */ +static int +g_sched_register(struct g_sched *gsp) +{ + struct g_sched *tmp; + int error; + + error = 0; + + mtx_lock(&g_sched_mtx); + LIST_FOREACH(tmp, &g_sched_list, gs_list) + if (strcmp(tmp->gs_name, gsp->gs_name) == 0) { + G_SCHED_DEBUG(1, "geom_sched: %s already registered", + gsp->gs_name); + error = EEXIST; + goto out; + } + + LIST_INSERT_HEAD(&g_sched_list, gsp, gs_list); + gsp->gs_refs = 1; + +out: + mtx_unlock(&g_sched_mtx); + + return (error); +} + +/* + * Try to unregister a scheduler. May fail if the scheduler is not + * registered or if it still in use. + */ +static int +g_sched_unregister(struct g_sched *gsp) +{ + struct g_sched *tmp; + int error; + + error = 0; + + mtx_lock(&g_sched_mtx); + LIST_FOREACH(tmp, &g_sched_list, gs_list) { + if (tmp == gsp) { + if (gsp->gs_refs != 1) { + G_SCHED_DEBUG(1, "geom_sched: %s still in use", + gsp->gs_name); + error = EBUSY; + } else if (gsp->gs_refs == 1) + /* + * The list reference is the last one + * that can be removed, so it is safe to + * just decrement the counter elsewhere. + */ + LIST_REMOVE(gsp, gs_list); + goto out; + } + } + + G_SCHED_DEBUG(1, "geom_sched: %s not registered", gsp->gs_name); + +out: + mtx_unlock(&g_sched_mtx); + + return (error); +} + +/* + * Search a scheduler by name, and return it, adding a reference to it. + * Return NULL if no scheduler with the given name exists. + */ +static struct g_sched * +g_sched_find(const char *name) +{ + struct g_sched *gsp; + + mtx_lock(&g_sched_mtx); + LIST_FOREACH(gsp, &g_sched_list, gs_list) { + if (strcmp(name, gsp->gs_name) == 0) { + gsp->gs_refs++; + goto out; + } + } + + gsp = NULL; + +out: + mtx_unlock(&g_sched_mtx); + + return (gsp); +} + +int +g_sched_configure(struct disk *dp, const char *name) +{ + struct g_sched *gsp, *old_gsp; + void *data, *old_data; + int error; + + error = 0; + old_data = NULL; + + G_SCHED_DEBUG(2, "geom_sched: switching to %s", name); + + /* + * A driver that does not provide a d_kick() method cannot + * use the scheduler subsystem. Just ignore the configuration + * request. + */ + if (dp->d_kick == NULL) { + printf("d_kick = %p\n", dp->d_kick); + return (EOPNOTSUPP); + } + + gsp = g_sched_find(name); + /* + * Admit a NULL gsp to indicate that we are switching to the + * default system behavior (no scheduler at all), iff the + * provided name is "none." + */ + if (gsp == NULL && strcmp("none", name) != 0) { + printf("scheduler not found\n"); + return (EINVAL); + } + + mtx_lock(&dp->d_sched_lock); + old_gsp = dp->d_sched; + if (old_gsp == gsp) { + /* Not really a switch, same scheduler, just return. */ + printf("same scheduler\n"); + goto out; + } + + /* + * Reconfiguration events are serialized in the same thread, + * so we should not see more than one reconfiguration at time. + */ + KASSERT((dp->d_sched_flags & G_SCHED_SWITCHING) == 0, + ("multiple reconfiguration requests")); + + dp->d_sched_flags |= G_SCHED_SWITCHING; + + if (old_gsp != NULL) { + /* We had a previous scheduler, flush it. */ + g_sched_flush_locked(dp); + } + + if (gsp != NULL) { + mtx_unlock(&dp->d_sched_lock); + /* Try to allocate the new private data. */ + data = gsp->gs_init(dp); + if (data == NULL) { + error = ENOMEM; + goto unref; + } + mtx_lock(&dp->d_sched_lock); + /* + * Allocation went OK, prepare to release old data and + * store the new ones in d_sched_data. + */ + old_data = dp->d_sched_data; + dp->d_sched_data = data; + } + + /* Commit the switch. */ + dp->d_sched = gsp; + dp->d_sched_flags &= ~G_SCHED_SWITCHING; + + /* Remember to release the reference to the old scheduler. */ + gsp = old_gsp; +out: + mtx_unlock(&dp->d_sched_lock); + +unref: + if (gsp != NULL) { + if (old_data != NULL) + gsp->gs_fini(old_data); + mtx_lock(&g_sched_mtx); + /* + * gs_refs > 2 here, as the g_sched_list holds a reference + * to it. The ugly lock/unlock sequence around the decrement + * does not increase the number of atomic ops WRT using the + * atomic_* functions. (The ref got in g_sched_find() would + * balance the atomic op removed here.) + */ + gsp->gs_refs--; + mtx_unlock(&g_sched_mtx); + } + + G_SCHED_DEBUG(2, "geom_sched: switch done (%d)", error); + + return (error); +} + +/* + * Helper to load/unload scheduler modules. Each module should + * DECLARE_SCHED_MODULE() to declare itself, providing a struct + * g_sched descriptor. This function is used from + * DECLARE_SCHED_MODULE() to register/unregister the scheduler. + */ +int +g_sched_modevent(module_t mod, int cmd, void *arg) +{ + struct g_sched *gsp; + int error; + + gsp = arg; + error = EOPNOTSUPP; + + g_sched_init(); + + switch (cmd) { + case MOD_LOAD: + error = g_sched_register(gsp); + break; + case MOD_UNLOAD: + error = g_sched_unregister(gsp); + break; + } + + return (error); +} From owner-svn-src-user@FreeBSD.ORG Thu Jan 8 12:10:12 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35BE710656E2; Thu, 8 Jan 2009 12:10:12 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 227348FC0A; Thu, 8 Jan 2009 12:10:12 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n08CACjN021915; Thu, 8 Jan 2009 12:10:12 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n08CABiJ021906; Thu, 8 Jan 2009 12:10:11 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901081210.n08CABiJ021906@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 8 Jan 2009 12:10:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186893 - in user/luigi/geom_sched/sys: geom geom/sched i386/conf sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2009 12:10:12 -0000 Author: luigi Date: Thu Jan 8 12:10:11 2009 New Revision: 186893 URL: http://svn.freebsd.org/changeset/base/186893 Log: 1. restore original structure for struct bio -- now the classification info is stored by g_io_request() in the bio_caller1 field in the first bio of the geom chain. 2. create a DISKLESS configuration for tests Added: user/luigi/geom_sched/sys/i386/conf/DISKLESS user/luigi/geom_sched/sys/i386/conf/DISKLESS.env Modified: user/luigi/geom_sched/sys/geom/geom_io.c user/luigi/geom_sched/sys/geom/sched/g_as.c user/luigi/geom_sched/sys/geom/sched/g_gsched.h user/luigi/geom_sched/sys/geom/sched/g_rr.c user/luigi/geom_sched/sys/geom/sched/gs_as.c user/luigi/geom_sched/sys/geom/sched/gs_rr.c user/luigi/geom_sched/sys/sys/bio.h Modified: user/luigi/geom_sched/sys/geom/geom_io.c ============================================================================== --- user/luigi/geom_sched/sys/geom/geom_io.c Thu Jan 8 11:09:27 2009 (r186892) +++ user/luigi/geom_sched/sys/geom/geom_io.c Thu Jan 8 12:10:11 2009 (r186893) @@ -172,7 +172,6 @@ g_clone_bio(struct bio *bp) bp2->bio_offset = bp->bio_offset; bp2->bio_data = bp->bio_data; bp2->bio_attribute = bp->bio_attribute; - bp2->bio_thread = bp->bio_thread; bp->bio_children++; } #ifdef KTR @@ -370,9 +369,19 @@ g_io_request(struct bio *bp, struct g_co bp->bio_error = 0; bp->bio_completed = 0; - /* Pass down the thread that issued the bio. */ - if (bp->bio_thread == NULL) - bp->bio_thread = curthread; + /* + * Scheduler support: if this is the first element in the geom + * chain (we know from bp->bio_parent == NULL), store + * the thread that originated the request in bp->bio_caller1, + * which should be unused in this particular entry (at least + * with the code in 7.1/8.0). + */ + if (bp->bio_parent == NULL) { + if (bp->bio_caller1 != NULL) + printf("unexpected bio_caller1 %p\n", bp->bio_caller1); + else + bp->bio_caller1 = (void *)curthread->td_tid; + } KASSERT(!(bp->bio_flags & BIO_ONQUEUE), ("Bio already on queue bp=%p", bp)); Modified: user/luigi/geom_sched/sys/geom/sched/g_as.c ============================================================================== --- user/luigi/geom_sched/sys/geom/sched/g_as.c Thu Jan 8 11:09:27 2009 (r186892) +++ user/luigi/geom_sched/sys/geom/sched/g_as.c Thu Jan 8 12:10:11 2009 (r186893) @@ -49,7 +49,7 @@ struct g_as_softc { struct g_geom *sc_geom; - struct thread *sc_curthread; + u_long sc_curkey; int sc_status; long sc_batch; @@ -76,7 +76,7 @@ g_as_dispatch(struct g_as_softc *sc) * scheduler starve other threads while an aggressive one * is making continuously new requests. */ - sc->sc_curthread = NULL; + sc->sc_curkey = 0; bio = bioq_takefirst(&sc->sc_bioq); if (bio != NULL) { @@ -130,7 +130,7 @@ g_as_start(void *data, struct bio *bio) * stop the timer and dispatch it, otherwise do nothing. */ if (sc->sc_status == G_AS_NOWAIT || - bio->bio_thread == sc->sc_curthread) { + g_sched_classify(bio) == sc->sc_curkey) { callout_stop(&sc->sc_wait); g_as_dispatch(sc); } @@ -152,7 +152,7 @@ g_as_done(void *data, struct bio *bio) /* * Start waiting for a new request from curthread. */ - sc->sc_curthread = bio->bio_thread; + sc->sc_curkey = g_sched_classify(bio); sc->sc_status = G_AS_WAITING; callout_reset(&sc->sc_wait, G_AS_WAIT_EXPIRE, g_as_wait_timeout, sc); @@ -172,7 +172,7 @@ g_as_init(struct g_geom *geom) sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO); sc->sc_geom = geom; - sc->sc_curthread = NULL; + sc->sc_curkey = 0; sc->sc_status = G_AS_NOWAIT; callout_init(&sc->sc_wait, CALLOUT_MPSAFE); Modified: user/luigi/geom_sched/sys/geom/sched/g_gsched.h ============================================================================== --- user/luigi/geom_sched/sys/geom/sched/g_gsched.h Thu Jan 8 11:09:27 2009 (r186892) +++ user/luigi/geom_sched/sys/geom/sched/g_gsched.h Thu Jan 8 12:10:11 2009 (r186893) @@ -70,6 +70,27 @@ void g_sched_lock(struct g_geom *gp); void g_sched_unlock(struct g_geom *gp); /* + * Lookup the identity of the issuer of the original request. + * In the current implementation we use the curthread of the + * issuer, but different mechanisms may be implemented later + * so we do not make assumptions on the return value which for + * us is just an opaque identifier. + * For the time being we make this inline. + */ +static inline +u_long g_sched_classify(struct bio *bp) +{ + + if (bp == NULL) { + printf("g_sched_classify: NULL bio\n"); + return (0); /* as good as anything */ + } + while (bp->bio_parent != NULL) + bp = bp->bio_parent; + return ((u_long)(bp->bio_caller1)); +} + +/* * Declaration of a scheduler module. */ int g_gsched_modevent(module_t mod, int cmd, void *arg); Modified: user/luigi/geom_sched/sys/geom/sched/g_rr.c ============================================================================== --- user/luigi/geom_sched/sys/geom/sched/g_rr.c Thu Jan 8 11:09:27 2009 (r186892) +++ user/luigi/geom_sched/sys/geom/sched/g_rr.c Thu Jan 8 12:10:11 2009 (r186893) @@ -58,7 +58,6 @@ struct g_rr_queue { int q_refs; int q_status; u_long q_key; - struct proc *q_proc; struct bio_queue_head q_bioq; unsigned int q_service; @@ -94,13 +93,6 @@ struct g_rr_softc { struct callout sc_wait; }; -static inline u_long -g_rr_key(struct thread *tp) -{ - - return (tp != NULL ? tp->td_tid : 0); -} - /* Return the hash chain for the given key. */ static inline struct g_hash * g_rr_hash(struct g_rr_softc *sc, u_long key) @@ -114,13 +106,11 @@ g_rr_hash(struct g_rr_softc *sc, u_long * it if necessary. */ static struct g_rr_queue * -g_rr_queue_get(struct g_rr_softc *sc, struct thread *tp) +g_rr_queue_get(struct g_rr_softc *sc, u_long key) { struct g_hash *bucket; struct g_rr_queue *qp; - u_long key; - key = g_rr_key(tp); bucket = g_rr_hash(sc, key); LIST_FOREACH(qp, bucket, q_hash) { if (qp->q_key == key) { @@ -136,7 +126,6 @@ g_rr_queue_get(struct g_rr_softc *sc, st qp->q_refs = 2; qp->q_key = key; - qp->q_proc = tp->td_proc; bioq_init(&qp->q_bioq); qp->q_budget = G_RR_DEFAULT_BUDGET; LIST_INSERT_HEAD(bucket, qp, q_hash); @@ -265,7 +254,7 @@ g_rr_start(void *data, struct bio *bp) sc = data; /* Get the queue for the thread that issued the request. */ - qp = g_rr_queue_get(sc, bp->bio_thread); + qp = g_rr_queue_get(sc, g_sched_classify(bp)); if (qp == NULL) { g_io_request(bp, LIST_FIRST(&sc->sc_geom->consumer)); return; Modified: user/luigi/geom_sched/sys/geom/sched/gs_as.c ============================================================================== --- user/luigi/geom_sched/sys/geom/sched/gs_as.c Thu Jan 8 11:09:27 2009 (r186892) +++ user/luigi/geom_sched/sys/geom/sched/gs_as.c Thu Jan 8 12:10:11 2009 (r186893) @@ -50,7 +50,7 @@ struct gs_as_softc { struct disk *sc_disk; - struct thread *sc_curthread; + u_long sc_curkey; int sc_status; long sc_batch; @@ -83,7 +83,7 @@ gs_as_next(void *data, int force) * scheduler starve other threads while an aggressive one * is making continuously new requests. */ - sc->sc_curthread = NULL; + sc->sc_curkey = NULL; bio = bioq_takefirst(&sc->sc_bioq); if (bio != NULL) { @@ -123,7 +123,7 @@ gs_as_wait_timeout(void *data) mtx_lock(&dp->d_sched_lock); /* - * We were waiting for a new request for curthread, it did + * We were waiting for a new request for curkey, it did * not come, just dispatch the next one. */ if (sc->sc_status == G_AS_WAITING) @@ -148,7 +148,7 @@ gs_as_start(void *data, struct bio *bio) * stop the timer and dispatch it, otherwise do nothing. */ if (sc->sc_status == G_AS_NOWAIT || - bio->bio_thread == sc->sc_curthread) { + g_sched_classify(bio) == sc->sc_curkey) { callout_stop(&sc->sc_wait); sc->sc_status = G_AS_NOWAIT; } @@ -164,7 +164,8 @@ gs_as_done(void *data, struct bio *bio) if (sc->sc_status == G_AS_WAITREQ) { next = bioq_first(&sc->sc_bioq); - if (next != NULL && next->bio_thread == bio->bio_thread) { + if (next != NULL && + g_sched_classify(next) == g_sched_classify(bio)) { /* * Don't wait if the current thread already * has pending requests. This is not complete, @@ -177,11 +178,11 @@ gs_as_done(void *data, struct bio *bio) } /* Start waiting for a new request from curthread. */ - sc->sc_curthread = bio->bio_thread; + sc->sc_curkey = g_sched_classify(bio); sc->sc_status = G_AS_WAITING; callout_reset(&sc->sc_wait, G_AS_WAIT_EXPIRE, gs_as_wait_timeout, sc); - G_SCHED_DEBUG(2, "gs_as: waiting for %p", sc->sc_curthread); + G_SCHED_DEBUG(2, "gs_as: waiting for %lu", sc->sc_curkey); return (0); } @@ -196,7 +197,7 @@ gs_as_init(struct disk *dp) sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO); sc->sc_disk = dp; - sc->sc_curthread = NULL; + sc->sc_curkey = 0; sc->sc_status = G_AS_NOWAIT; callout_init(&sc->sc_wait, CALLOUT_MPSAFE); Modified: user/luigi/geom_sched/sys/geom/sched/gs_rr.c ============================================================================== --- user/luigi/geom_sched/sys/geom/sched/gs_rr.c Thu Jan 8 11:09:27 2009 (r186892) +++ user/luigi/geom_sched/sys/geom/sched/gs_rr.c Thu Jan 8 12:10:11 2009 (r186893) @@ -61,7 +61,6 @@ struct gs_rr_queue { int q_refs; int q_status; u_long q_key; - struct proc *q_proc; struct bio_queue_head q_bioq; unsigned int q_service; @@ -99,13 +98,6 @@ struct gs_rr_softc { struct callout sc_wait; }; -static inline u_long -gs_rr_key(struct thread *tp) -{ - - return (tp != NULL ? tp->td_tid : 0); -} - /* Return the hash chain for the given key. */ static inline struct gs_hash * gs_rr_hash(struct gs_rr_softc *sc, u_long key) @@ -119,13 +111,11 @@ gs_rr_hash(struct gs_rr_softc *sc, u_lon * it if necessary. */ static struct gs_rr_queue * -gs_rr_queue_get(struct gs_rr_softc *sc, struct thread *tp) +gs_rr_queue_get(struct gs_rr_softc *sc, u_long key) { struct gs_hash *bucket; struct gs_rr_queue *qp, *new_qp; - u_long key; - key = gs_rr_key(tp); new_qp = NULL; bucket = gs_rr_hash(sc, key); retry: @@ -159,7 +149,6 @@ retry: new_qp->q_refs = 2; new_qp->q_key = key; - new_qp->q_proc = tp->td_proc; bioq_init(&new_qp->q_bioq); new_qp->q_budget = G_RR_DEFAULT_BUDGET; LIST_INSERT_HEAD(bucket, new_qp, q_hash); @@ -238,7 +227,7 @@ gs_rr_start(void *data, struct bio *bp) sc = data; /* Get the queue for the thread that issued the request. */ - qp = gs_rr_queue_get(sc, bp->bio_thread); + qp = gs_rr_queue_get(sc, g_sched_classify(bp)); if (bioq_first(&qp->q_bioq) == NULL) { /* We're inserting into an empty queue... */ if (qp == sc->sc_active) { Added: user/luigi/geom_sched/sys/i386/conf/DISKLESS ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/luigi/geom_sched/sys/i386/conf/DISKLESS Thu Jan 8 12:10:11 2009 (r186893) @@ -0,0 +1,25 @@ +# +# $FreeBSD: src/sys/i386/conf/DISKLESS,v 1.474.2.14 2008/08/29 18:54:35 jhb Exp $ + +include "GENERIC" +ident DISKLESS + +# Make some environment vars available +env "DISKLESS.env" + +# To statically compile in device wiring instead of /boot/device.hints +hints "GENERIC.hints" # Default places to look for devices. + +# make sure we start with an open firewall +options IPFIREWALL +options IPFIREWALL_DEFAULT_TO_ACCEPT +options IPDIVERT +options DUMMYNET + +# added against GENERIC +options BOOTP +options BOOTP_NFSROOT +options BOOTP_COMPAT +options INCLUDE_CONFIG_FILE # Include this file in kernel +options KDB +options DDB Added: user/luigi/geom_sched/sys/i386/conf/DISKLESS.env ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/luigi/geom_sched/sys/i386/conf/DISKLESS.env Thu Jan 8 12:10:11 2009 (r186893) @@ -0,0 +1,2 @@ +# you can put here env/kenv variables +# machdep.bios.pnp=disable Modified: user/luigi/geom_sched/sys/sys/bio.h ============================================================================== --- user/luigi/geom_sched/sys/sys/bio.h Thu Jan 8 11:09:27 2009 (r186892) +++ user/luigi/geom_sched/sys/sys/bio.h Thu Jan 8 12:10:11 2009 (r186893) @@ -42,7 +42,6 @@ struct disk; struct bio; -struct thread; typedef void bio_task_t(void *); @@ -79,9 +78,6 @@ struct bio { bio_task_t *bio_task; /* Task_queue handler */ void *bio_task_arg; /* Argument to above */ - - struct thread *bio_thread; /* Thread that issued the request */ - #ifdef DIAGNOSTIC void *_bio_caller1; void *_bio_caller2; From owner-svn-src-user@FreeBSD.ORG Thu Jan 8 12:39:41 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7563B106564A; Thu, 8 Jan 2009 12:39:41 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4938F8FC1B; Thu, 8 Jan 2009 12:39:41 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n08CdfuL022488; Thu, 8 Jan 2009 12:39:41 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n08CdeXx022482; Thu, 8 Jan 2009 12:39:40 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901081239.n08CdeXx022482@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 8 Jan 2009 12:39:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186895 - in user/luigi/geom_sched/sbin/geom/class: . disk sched X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2009 12:39:41 -0000 Author: luigi Date: Thu Jan 8 12:39:40 2009 New Revision: 186895 URL: http://svn.freebsd.org/changeset/base/186895 Log: add control libraries for the two new classes Added: user/luigi/geom_sched/sbin/geom/class/disk/ user/luigi/geom_sched/sbin/geom/class/disk/Makefile user/luigi/geom_sched/sbin/geom/class/disk/geom_disk.c user/luigi/geom_sched/sbin/geom/class/sched/ user/luigi/geom_sched/sbin/geom/class/sched/Makefile user/luigi/geom_sched/sbin/geom/class/sched/geom_sched.c user/luigi/geom_sched/sbin/geom/class/sched/gsched.8 Modified: user/luigi/geom_sched/sbin/geom/class/Makefile Modified: user/luigi/geom_sched/sbin/geom/class/Makefile ============================================================================== --- user/luigi/geom_sched/sbin/geom/class/Makefile Thu Jan 8 12:22:37 2009 (r186894) +++ user/luigi/geom_sched/sbin/geom/class/Makefile Thu Jan 8 12:39:40 2009 (r186895) @@ -4,6 +4,7 @@ SUBDIR= cache SUBDIR+=concat +SUBDIR+=disk .if ${MK_OPENSSL} != "no" SUBDIR+=eli .endif @@ -14,6 +15,7 @@ SUBDIR+=multipath SUBDIR+=nop SUBDIR+=part SUBDIR+=raid3 +SUBDIR+=sched SUBDIR+=shsec SUBDIR+=stripe SUBDIR+=virstor Added: user/luigi/geom_sched/sbin/geom/class/disk/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/luigi/geom_sched/sbin/geom/class/disk/Makefile Thu Jan 8 12:39:40 2009 (r186895) @@ -0,0 +1,12 @@ +# GEOM_LIBRARY_PATH + +.PATH: ${.CURDIR}/../../misc + +#SHLIB_NAME?=geom_${CLASS}.so +#LINKS= ${BINDIR}/geom ${BINDIR}/g${CLASS} +#SRCS+= geom_${CLASS}.c subr.c +#CFLAGS+= -I/usr/src/sbin/geom/ + +CLASS=disk + +.include Added: user/luigi/geom_sched/sbin/geom/class/disk/geom_disk.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/luigi/geom_sched/sbin/geom/class/disk/geom_disk.c Thu Jan 8 12:39:40 2009 (r186895) @@ -0,0 +1,50 @@ +/*- + * Copyright (c) 2008 Fabio Checconi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#include +#include +#include + +#include +#include "core/geom.h" + +uint32_t lib_version = G_LIB_VERSION; +uint32_t version = G_VERSION; + +static char iosched[] = "gs_as"; + +struct g_command class_commands[] = { + { "configure", G_FLAG_VERBOSE, NULL, + { + { 's', "iosched", iosched, G_TYPE_STRING }, + G_OPT_SENTINEL + }, + NULL, "[-v] [-s iosched] prov ..." + }, + G_CMD_SENTINEL +}; Added: user/luigi/geom_sched/sbin/geom/class/sched/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/luigi/geom_sched/sbin/geom/class/sched/Makefile Thu Jan 8 12:39:40 2009 (r186895) @@ -0,0 +1,7 @@ +# GEOM_LIBRARY_PATH + +.PATH: ${.CURDIR}/../../misc + +CLASS=sched + +.include Added: user/luigi/geom_sched/sbin/geom/class/sched/geom_sched.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/luigi/geom_sched/sbin/geom/class/sched/geom_sched.c Thu Jan 8 12:39:40 2009 (r186895) @@ -0,0 +1,67 @@ +/*- + * Copyright (c) 2007 Fabio Checconi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#include +#include +#include + +#include "core/geom.h" + +#define G_SCHED_VERSION 0 + +uint32_t lib_version = G_LIB_VERSION; +uint32_t version = G_SCHED_VERSION; + +static char sched[] = "as"; + +struct g_command class_commands[] = { + { "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL, + { + { 's', "sched", sched, G_TYPE_STRING }, + G_OPT_SENTINEL + }, + NULL, "[-v] [-s sched] dev ..." + }, + { "configure", G_FLAG_VERBOSE, NULL, + { + G_OPT_SENTINEL + }, + NULL, "[-v] prov ..." + }, + { "destroy", G_FLAG_VERBOSE, NULL, + { + { 'f', "force", NULL, G_TYPE_BOOL }, + G_OPT_SENTINEL + }, + NULL, "[-fv] prov ..." + }, + { "reset", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL, + "[-v] prov ..." + }, + G_CMD_SENTINEL +}; Added: user/luigi/geom_sched/sbin/geom/class/sched/gsched.8 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/luigi/geom_sched/sbin/geom/class/sched/gsched.8 Thu Jan 8 12:39:40 2009 (r186895) @@ -0,0 +1,137 @@ +.\" Copyright (c) 2007 Fabio Checconi +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd September 20, 2007 +.Dt GSCHED 8 +.Os +.Sh NAME +.Nm gsched +.Nd "control utility for SCHED GEOM class" +.Sh SYNOPSIS +.Nm +.Cm create +.Op Fl v +.Ar dev ... +.Nm +.Cm configure +.Op Fl v +.Ar prov ... +.Nm +.Cm destroy +.Op Fl fv +.Ar prov ... +.Nm +.Cm reset +.Op Fl v +.Ar prov ... +.Nm +.Cm list +.Nm +.Cm status +.Nm +.Cm load +.Nm +.Cm unload +.Sh DESCRIPTION +The +.Nm +utility changes the scheduling policy of the requests going to its providers. +By now it just uses a C-LOOK policy with a little anticipation. +.Pp +The first argument to +.Nm +indicates an action to be performed: +.Bl -tag -width ".Cm configure" +.It Cm create +Set up a scheduling provider on the given devices. +If the operation succeeds, the new provider should appear with name +.Pa /dev/ Ns Ao Ar dev Ac Ns Pa .sched . +The kernel module +.Pa geom_sched.ko +will be loaded if it is not loaded already. +.It Cm configure +Configure existing scheduling provider. +At the moment it is not used at all. +.It Cm destroy +Turn off the given scheduling providers. +.It Cm reset +Do nothing. +.It Cm list +See +.Xr geom 8 . +.It Cm status +See +.Xr geom 8 . +.It Cm load +See +.Xr geom 8 . +.It Cm unload +See +.Xr geom 8 . +.El +.Pp +Additional options: +.Bl -tag -width ".Fl f" +.It Fl f +Force the removal of the specified provider. +.It Fl v +Be more verbose. +.El +.Sh SYSCTL VARIABLES +The following +.Xr sysctl 8 +variables can be used to control the behavior of the +.Nm SCHED +GEOM class. +The default value is shown next to each variable. +.Bl -tag -width indent +.It Va kern.geom.sched.debug : No 0 +Debug level of the +.Nm NOP +GEOM class. +This can be set to a number between 0 and 2 inclusive. +If set to 0 minimal debug information is printed, and if set to 2 the +maximum amount of debug information is printed. +.El +.Sh EXIT STATUS +Exit status is 0 on success, and 1 if the command fails. +.Sh EXAMPLES +The following example shows how to create a scheduling provider for disk +.Pa /dev/da0 +, and how to destroy it. +.Bd -literal -offset indent +gnop create -v da0 +gnop destroy -v da0.nop +.Ed +.Pp +.Ed +.Sh SEE ALSO +.Xr geom 4 , +.Xr geom 8 +.Sh HISTORY +The +.Nm +utility still has to appear, and hopefully it will never do. +.Sh AUTHORS +.An Fabio Checconi Aq fabio@FreeBSD.org From owner-svn-src-user@FreeBSD.ORG Thu Jan 8 18:24:05 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F2BF01065687; Thu, 8 Jan 2009 18:24:04 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E18268FC0C; Thu, 8 Jan 2009 18:24:04 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n08IO4hQ030197; Thu, 8 Jan 2009 18:24:04 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n08IO4Em030195; Thu, 8 Jan 2009 18:24:04 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901081824.n08IO4Em030195@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 8 Jan 2009 18:24:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186908 - in user/luigi/geom_sched/sys/geom: . sched X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2009 18:24:05 -0000 Author: luigi Date: Thu Jan 8 18:24:04 2009 New Revision: 186908 URL: http://svn.freebsd.org/changeset/base/186908 Log: make it work with a stock kernel Modified: user/luigi/geom_sched/sys/geom/geom_io.c user/luigi/geom_sched/sys/geom/sched/g_sched.c Modified: user/luigi/geom_sched/sys/geom/geom_io.c ============================================================================== --- user/luigi/geom_sched/sys/geom/geom_io.c Thu Jan 8 17:51:15 2009 (r186907) +++ user/luigi/geom_sched/sys/geom/geom_io.c Thu Jan 8 18:24:04 2009 (r186908) @@ -369,6 +369,7 @@ g_io_request(struct bio *bp, struct g_co bp->bio_error = 0; bp->bio_completed = 0; +#if 0 /* * Scheduler support: if this is the first element in the geom * chain (we know from bp->bio_parent == NULL), store @@ -382,6 +383,7 @@ g_io_request(struct bio *bp, struct g_co else bp->bio_caller1 = (void *)curthread->td_tid; } +#endif KASSERT(!(bp->bio_flags & BIO_ONQUEUE), ("Bio already on queue bp=%p", bp)); Modified: user/luigi/geom_sched/sys/geom/sched/g_sched.c ============================================================================== --- user/luigi/geom_sched/sys/geom/sched/g_sched.c Thu Jan 8 17:51:15 2009 (r186907) +++ user/luigi/geom_sched/sys/geom/sched/g_sched.c Thu Jan 8 18:24:04 2009 (r186908) @@ -35,6 +35,7 @@ #include #include #include +#include /* we access curthread */ #include #include "g_gsched.h" #include "g_sched.h" @@ -396,18 +397,103 @@ g_sched_destroy_geom(struct gctl_req *re return (g_sched_destroy(gp, 0)); } +/* + * The code below patches g_io_request() to call g_new_io_request() first. + * We must be careful with the compiler, as it may clobber the + * parameters on the stack so they are not preserved for the + * continuation of the original function. + * Ideally we should write everything in assembler: + + mov 0x8(%esp), %edx // load bp + mov 0x64(%edx),%eax // load bp->bio_parent + test %eax,%eax + jne 1f + mov 0x30(%edx),%eax // load bp->bio_caller1 + test %eax,%eax + jne 1f + mov %fs:0x0,%eax // pcpu pointer + mov 0x34(%eax),%eax // curthread + mov %eax,0x30(%edx) // store in bp->bio_caller1 + 1: // old function + push %ebp + mov %esp, %ebp + push %edi + push %esi + jmp x+5 + + */ + +static unsigned char +g_io_trampoline[] = { + 0xe8, 0x00, 0x00, 0x00, 0x00, /* call foo */ + 0x55, /* push %ebp */ + 0x89, 0xe5, /* mov %esp,%ebp */ + 0x57, /* push %edi */ + 0x56, /* push %esi */ + 0xe9, 0x00, 0x00, 0x00, 0x00, /* jmp x+5 */ +}; + +static void +g_new_io_request(const char *ret, struct bio *bp, struct g_consumer *cp) +{ + + /* + * Scheduler support: if this is the first element in the geom + * chain (we know from bp->bio_parent == NULL), store + * the thread that originated the request in bp->bio_caller1, + * which should be unused in this particular entry (at least + * with the code in 7.1/8.0). + */ + if (bp->bio_parent == NULL && bp->bio_caller1 == NULL) + bp->bio_caller1 = (void *)curthread->td_tid; +} + +static int g_io_patched = 0; +static int +g_io_patch(void *f, void *p, void *new_f) +{ + int found = bcmp(f, (const char *)p + 5, 5); + printf("match result %d\n", found); + if (found == 0) { + int ofs; + + printf("patching function\n"); + /* link the trampoline to the new function */ + ofs = (int)new_f - ((int)p + 5); + bcopy(&ofs, (char *)p + 1, 4); + /* jump back to the original + 5 */ + ofs = ((int)f + 5) - ((int)p + 15); + bcopy(&ofs, (char *)p + 11, 4); + /* patch the original address with a jump to the trampoline */ + *(unsigned char *)f = 0xe9; /* jump opcode */ + ofs = (int)p - ((int)f + 5); + bcopy(&ofs, (char *)f + 1, 4); + g_io_patched = 1; + } + return 0; +} + static void g_sched_init(struct g_class *mp) { mtx_init(&g_gsched_mtx, "gsched", NULL, MTX_DEF); LIST_INIT(&gsched_list); + + printf("%s loading...\n", __FUNCTION__); + /* patch g_io_request to set the thread */ + g_io_patch(g_io_request, g_io_trampoline, g_new_io_request); } static void g_sched_fini(struct g_class *mp) { + if (g_io_patched) { + /* restore the original g_io_request */ + bcopy(g_io_trampoline + 5, (char *)g_io_request, 5); + } + printf("%s unloading...\n", __FUNCTION__); KASSERT(LIST_EMPTY(&gsched_list), ("still registered schedulers")); mtx_destroy(&g_gsched_mtx); } From owner-svn-src-user@FreeBSD.ORG Fri Jan 9 07:23:02 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 95AB71065687; Fri, 9 Jan 2009 07:23:02 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 843018FC16; Fri, 9 Jan 2009 07:23:02 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n097N2NO045906; Fri, 9 Jan 2009 07:23:02 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n097N2OI045902; Fri, 9 Jan 2009 07:23:02 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901090723.n097N2OI045902@svn.freebsd.org> From: Kip Macy Date: Fri, 9 Jan 2009 07:23:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186923 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2009 07:23:02 -0000 Author: kmacy Date: Fri Jan 9 07:23:02 2009 New Revision: 186923 URL: http://svn.freebsd.org/changeset/base/186923 Log: Add kernel support for weighting routes Modified: user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c user/kmacy/HEAD_fast_net/sys/net/route.c user/kmacy/HEAD_fast_net/sys/net/route.h user/kmacy/HEAD_fast_net/sys/net/rtsock.c Modified: user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c Fri Jan 9 04:38:22 2009 (r186922) +++ user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c Fri Jan 9 07:23:02 2009 (r186923) @@ -80,14 +80,14 @@ rn_mpath_next(struct radix_node *rn) u_int32_t rn_mpath_count(struct radix_node *rn) { - u_int32_t i; + uint32_t i = 0; struct rtentry *rt; i = 1; while ((rn = rn_mpath_next(rn)) != NULL) { rt = (struct rtentry *)rn; if ((rt->rt_flags & RTF_SHUTDOWN) == 0) - i++; + i += rt->rt_rmx.rmx_weight; } return (i); } @@ -260,11 +260,12 @@ different: } void -rtalloc_mpath_fib(struct route *ro, u_int32_t hash, u_int fibnum) +rtalloc_mpath_fib(struct route *ro, uint32_t hash, u_int fibnum) { struct radix_node *rn0, *rn; u_int32_t n; struct rtentry *rt; + uint64_t total_weight = 0; /* * XXX we don't attempt to lookup cached route again; what should @@ -289,12 +290,15 @@ rtalloc_mpath_fib(struct route *ro, u_in /* gw selection by Modulo-N Hash (RFC2991) XXX need improvement? */ hash += hashjitter; hash %= n; - while (hash-- > 0 && rn) { + while (rn) { rt = (struct rtentry *)rn; - if (rt->rt_flags & RTF_SHUTDOWN) { - hash++; + if (rt->rt_flags & RTF_SHUTDOWN) continue; - } + + total_weight += rt->rt_rmx.rmx_weight; + if (total_weight >= hash) + break; + /* stay within the multipath routes */ if (rn->rn_dupedkey && rn->rn_mask != rn->rn_dupedkey->rn_mask) break; Modified: user/kmacy/HEAD_fast_net/sys/net/route.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/route.c Fri Jan 9 04:38:22 2009 (r186922) +++ user/kmacy/HEAD_fast_net/sys/net/route.c Fri Jan 9 07:23:02 2009 (r186923) @@ -805,7 +805,7 @@ bad: #ifdef RADIX_MPATH static int -rn_mpath_delete(int req, struct rt_addrinfo *info, +rn_mpath_update(int req, struct rt_addrinfo *info, struct radix_node_head *rnh, struct rtentry **ret_nrt) { /* @@ -855,6 +855,9 @@ rn_mpath_delete(int req, struct rt_addri * use the normal delete code to remove * the first entry */ + if (req != RTM_DELETE) + goto nondelete; + error = ENOENT; goto done; } @@ -875,9 +878,12 @@ rn_mpath_delete(int req, struct rt_addri */ V_rttrash++; - } else if (req == RTM_SHUTDOWN) + } + +nondelete: + if (req == RTM_SHUTDOWN) rt->rt_flags |= RTF_SHUTDOWN; - else + else if (req != RTM_DELETE) panic("unrecognized request %d", req); @@ -934,9 +940,9 @@ rtrequest1_fib(int req, struct rt_addrin switch (req) { case RTM_DELETE: #ifdef RADIX_MPATH - case RTM_SHUTDOWN: + case RTM_SHUTDOWN: if (rn_mpath_capable(rnh)) { - error = rn_mpath_delete(req, info, rnh, ret_nrt); + error = rn_mpath_update(req, info, rnh, ret_nrt); /* * "bad" holds true for the success case * as well @@ -992,11 +998,13 @@ rtrequest1_fib(int req, struct rt_addrin case RTM_ADD: if ((flags & RTF_GATEWAY) && !gateway) senderr(EINVAL); - if (dst && gateway && (dst->sa_family != gateway->sa_family) && - (gateway->sa_family != AF_UNSPEC) && (gateway->sa_family != AF_LINK)) + if (dst && gateway && (dst->sa_family != gateway->sa_family) + && (gateway->sa_family != AF_UNSPEC) + && (gateway->sa_family != AF_LINK)) senderr(EINVAL); - if (info->rti_ifa == NULL && (error = rt_getifa_fib(info, fibnum))) + if (info->rti_ifa == NULL && + (error = rt_getifa_fib(info, fibnum))) senderr(error); ifa = info->rti_ifa; rt = uma_zalloc(rtzone, M_NOWAIT | M_ZERO); @@ -1037,6 +1045,7 @@ rtrequest1_fib(int req, struct rt_addrin IFAREF(ifa); rt->rt_ifa = ifa; rt->rt_ifp = ifa->ifa_ifp; + rt->rt_rmx.rmx_weight = 1; #ifdef RADIX_MPATH /* do not permit exactly the same dst/mask/gw pair */ Modified: user/kmacy/HEAD_fast_net/sys/net/route.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/route.h Fri Jan 9 04:38:22 2009 (r186922) +++ user/kmacy/HEAD_fast_net/sys/net/route.h Fri Jan 9 07:23:02 2009 (r186923) @@ -60,6 +60,7 @@ struct rt_metrics_lite { u_long rmx_mtu; /* MTU for this path */ u_long rmx_expire; /* lifetime for route, e.g. redirect */ u_long rmx_pksent; /* packets sent using this route */ + u_long rmx_weight; /* absolute weight */ }; struct rt_metrics { @@ -73,7 +74,8 @@ struct rt_metrics { u_long rmx_rtt; /* estimated round trip time */ u_long rmx_rttvar; /* estimated rtt variance */ u_long rmx_pksent; /* packets sent using this route */ - u_long rmx_filler[4]; /* will be used for T/TCP later */ + u_long rmx_weight; /* route weight */ + u_long rmx_filler[3]; /* will be used for T/TCP later */ }; /* @@ -232,7 +234,7 @@ struct rt_msghdr { struct rt_metrics rtm_rmx; /* metrics themselves */ }; -#define RTM_VERSION 5 /* Up the ante and ignore older versions */ +#define RTM_VERSION 6 /* Up the ante and ignore older versions */ /* * Message types. @@ -268,6 +270,7 @@ struct rt_msghdr { #define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */ #define RTV_RTT 0x40 /* init or lock _rtt */ #define RTV_RTTVAR 0x80 /* init or lock _rttvar */ +#define RTV_WEIGHT 0x100 /* init or lock _rttvar */ /* * Bitmask values for rtm_addrs. @@ -275,7 +278,7 @@ struct rt_msghdr { #define RTA_DST 0x1 /* destination sockaddr present */ #define RTA_GATEWAY 0x2 /* gateway sockaddr present */ #define RTA_NETMASK 0x4 /* netmask sockaddr present */ -#define RTA_GENMASK 0x8 /* cloning mask sockaddr present */ +#define RTA_SPARE 0x8 /* unused */ #define RTA_IFP 0x10 /* interface name sockaddr present */ #define RTA_IFA 0x20 /* interface addr sockaddr present */ #define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */ @@ -287,7 +290,7 @@ struct rt_msghdr { #define RTAX_DST 0 /* destination sockaddr present */ #define RTAX_GATEWAY 1 /* gateway sockaddr present */ #define RTAX_NETMASK 2 /* netmask sockaddr present */ -#define RTAX_GENMASK 3 /* cloning mask sockaddr present */ +#define RTAX_SPARE 3 /* spare field */ #define RTAX_IFP 4 /* interface name sockaddr present */ #define RTAX_IFA 5 /* interface addr sockaddr present */ #define RTAX_AUTHOR 6 /* sockaddr for author of redirect */ @@ -295,11 +298,11 @@ struct rt_msghdr { #define RTAX_MAX 8 /* size of array to allocate */ struct rt_addrinfo { - int rti_addrs; - struct sockaddr *rti_info[RTAX_MAX]; - int rti_flags; - struct ifaddr *rti_ifa; - struct ifnet *rti_ifp; + int rti_addrs; + struct sockaddr *rti_info[RTAX_MAX]; + int rti_flags; + struct ifaddr *rti_ifa; + struct ifnet *rti_ifp; }; /* Modified: user/kmacy/HEAD_fast_net/sys/net/rtsock.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/rtsock.c Fri Jan 9 04:38:22 2009 (r186922) +++ user/kmacy/HEAD_fast_net/sys/net/rtsock.c Fri Jan 9 07:23:02 2009 (r186923) @@ -614,7 +614,6 @@ route_output(struct mbuf *m, struct sock info.rti_info[RTAX_DST] = rt_key(rt); info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; info.rti_info[RTAX_NETMASK] = rt_mask(rt); - info.rti_info[RTAX_GENMASK] = 0; if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) { ifp = rt->rt_ifp; if (ifp) { @@ -792,6 +791,7 @@ rt_setmetrics(u_long which, const struct * of tcp hostcache. The rest is ignored. */ metric(RTV_MTU, rmx_mtu); + metric(RTV_WEIGHT, rmx_weight); /* Userland -> kernel timebase conversion. */ if (which & RTV_EXPIRE) out->rmx_expire = in->rmx_expire ? @@ -1260,7 +1260,6 @@ sysctl_dumpentry(struct radix_node *rn, info.rti_info[RTAX_DST] = rt_key(rt); info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; info.rti_info[RTAX_NETMASK] = rt_mask(rt); - info.rti_info[RTAX_GENMASK] = 0; if (rt->rt_ifp) { info.rti_info[RTAX_IFP] = rt->rt_ifp->if_addr->ifa_addr; info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; From owner-svn-src-user@FreeBSD.ORG Fri Jan 9 07:23:27 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 405AD1065680; Fri, 9 Jan 2009 07:23:27 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2F8AE8FC1E; Fri, 9 Jan 2009 07:23:27 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n097NRfc045952; Fri, 9 Jan 2009 07:23:27 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n097NRu2045951; Fri, 9 Jan 2009 07:23:27 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901090723.n097NRu2045951@svn.freebsd.org> From: Kip Macy Date: Fri, 9 Jan 2009 07:23:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186924 - user/kmacy/HEAD_fast_net/usr.sbin/route6d X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2009 07:23:27 -0000 Author: kmacy Date: Fri Jan 9 07:23:26 2009 New Revision: 186924 URL: http://svn.freebsd.org/changeset/base/186924 Log: remove RTA_GENMASK Modified: user/kmacy/HEAD_fast_net/usr.sbin/route6d/route6d.c Modified: user/kmacy/HEAD_fast_net/usr.sbin/route6d/route6d.c ============================================================================== --- user/kmacy/HEAD_fast_net/usr.sbin/route6d/route6d.c Fri Jan 9 07:23:02 2009 (r186923) +++ user/kmacy/HEAD_fast_net/usr.sbin/route6d/route6d.c Fri Jan 9 07:23:26 2009 (r186924) @@ -2661,10 +2661,6 @@ rt_entry(rtm, again) sin6_mask = (struct sockaddr_in6 *)rtmp; rtmp += ROUNDUP(sin6_mask->sin6_len); } - if (rtm->rtm_addrs & RTA_GENMASK) { - sin6_genmask = (struct sockaddr_in6 *)rtmp; - rtmp += ROUNDUP(sin6_genmask->sin6_len); - } if (rtm->rtm_addrs & RTA_IFP) { sin6_ifp = (struct sockaddr_in6 *)rtmp; rtmp += ROUNDUP(sin6_ifp->sin6_len); From owner-svn-src-user@FreeBSD.ORG Fri Jan 9 07:27:09 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28225106566B; Fri, 9 Jan 2009 07:27:09 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 172CC8FC1B; Fri, 9 Jan 2009 07:27:09 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n097R8vH046053; Fri, 9 Jan 2009 07:27:08 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n097R8mO046051; Fri, 9 Jan 2009 07:27:08 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901090727.n097R8mO046051@svn.freebsd.org> From: Kip Macy Date: Fri, 9 Jan 2009 07:27:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186925 - user/kmacy/HEAD_fast_net/sbin/route X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2009 07:27:09 -0000 Author: kmacy Date: Fri Jan 9 07:27:08 2009 New Revision: 186925 URL: http://svn.freebsd.org/changeset/base/186925 Log: - remove genmask - add -weight option for adding / changing route weight Modified: user/kmacy/HEAD_fast_net/sbin/route/keywords user/kmacy/HEAD_fast_net/sbin/route/route.c Modified: user/kmacy/HEAD_fast_net/sbin/route/keywords ============================================================================== --- user/kmacy/HEAD_fast_net/sbin/route/keywords Fri Jan 9 07:23:26 2009 (r186924) +++ user/kmacy/HEAD_fast_net/sbin/route/keywords Fri Jan 9 07:27:08 2009 (r186925) @@ -47,6 +47,7 @@ sendpipe shutdown ssthresh static +weight x25 xns xresolve Modified: user/kmacy/HEAD_fast_net/sbin/route/route.c ============================================================================== --- user/kmacy/HEAD_fast_net/sbin/route/route.c Fri Jan 9 07:23:26 2009 (r186924) +++ user/kmacy/HEAD_fast_net/sbin/route/route.c Fri Jan 9 07:27:08 2009 (r186925) @@ -549,6 +549,7 @@ set_metric(value, key) caseof(K_SSTHRESH, RTV_SSTHRESH, rmx_ssthresh); caseof(K_RTT, RTV_RTT, rmx_rtt); caseof(K_RTTVAR, RTV_RTTVAR, rmx_rttvar); + caseof(K_WEIGHT, RTV_WEIGHT, rmx_weight); } rtm_inits |= flag; if (lockrest || locking) @@ -574,6 +575,7 @@ newroute(argc, argv) cmd = argv[0]; if (*cmd != 'g') shutdown(s, SHUT_RD); /* Don't want to read back our messages */ + while (--argc > 0) { if (**(++argv)== '-') { switch (key = keyword(1 + *argv)) { @@ -646,11 +648,6 @@ newroute(argc, argv) usage((char *)NULL); (void) getaddr(RTA_IFP, *++argv, 0); break; - case K_GENMASK: - if (!--argc) - usage((char *)NULL); - (void) getaddr(RTA_GENMASK, *++argv, 0); - break; case K_GATEWAY: if (!--argc) usage((char *)NULL); @@ -689,6 +686,7 @@ newroute(argc, argv) case K_SSTHRESH: case K_RTT: case K_RTTVAR: + case K_WEIGHT: if (!--argc) usage((char *)NULL); set_metric(*++argv, key); @@ -925,9 +923,6 @@ getaddr(which, s, hpp) case RTA_NETMASK: su = &so_mask; break; - case RTA_GENMASK: - su = &so_genmask; - break; case RTA_IFP: su = &so_ifp; afamily = AF_LINK; @@ -1191,6 +1186,8 @@ rtmsg(cmd, flags) cmd = RTM_ADD; else if (cmd == 'c') cmd = RTM_CHANGE; + else if (cmd == 's') + cmd = RTM_SHUTDOWN; else if (cmd == 'g') { cmd = RTM_GET; if (so_ifp.sa.sa_family == 0) { @@ -1198,9 +1195,7 @@ rtmsg(cmd, flags) so_ifp.sa.sa_len = sizeof(struct sockaddr_dl); rtm_addrs |= RTA_IFP; } - } else if (cmd == 's') - cmd = RTM_SHUTDOWN; - else + } else cmd = RTM_DELETE; #define rtm m_rtmsg.m_rtm rtm.rtm_type = cmd; @@ -1210,13 +1205,11 @@ rtmsg(cmd, flags) rtm.rtm_addrs = rtm_addrs; rtm.rtm_rmx = rt_metrics; rtm.rtm_inits = rtm_inits; - if (rtm_addrs & RTA_NETMASK) mask_addr(); NEXTADDR(RTA_DST, so_dst); NEXTADDR(RTA_GATEWAY, so_gate); NEXTADDR(RTA_NETMASK, so_mask); - NEXTADDR(RTA_GENMASK, so_genmask); NEXTADDR(RTA_IFP, so_ifp); NEXTADDR(RTA_IFA, so_ifa); rtm.rtm_msglen = l = cp - (char *)&m_rtmsg; @@ -1466,7 +1459,7 @@ print_getmsg(rtm, msglen) #define msec(u) (((u) + 500) / 1000) /* usec to msec */ (void) printf("\n%s\n", "\ - recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire"); + recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu weight expire"); printf("%8ld%c ", rtm->rtm_rmx.rmx_recvpipe, lock(RPIPE)); printf("%8ld%c ", rtm->rtm_rmx.rmx_sendpipe, lock(SPIPE)); printf("%8ld%c ", rtm->rtm_rmx.rmx_ssthresh, lock(SSTHRESH)); @@ -1474,6 +1467,7 @@ print_getmsg(rtm, msglen) printf("%8ld%c ", msec(rtm->rtm_rmx.rmx_rttvar), lock(RTTVAR)); printf("%8ld%c ", rtm->rtm_rmx.rmx_hopcount, lock(HOPCOUNT)); printf("%8ld%c ", rtm->rtm_rmx.rmx_mtu, lock(MTU)); + printf("%8ld%c ", rtm->rtm_rmx.rmx_weight, lock(WEIGHT)); if (rtm->rtm_rmx.rmx_expire) rtm->rtm_rmx.rmx_expire -= time(0); printf("%8ld%c\n", rtm->rtm_rmx.rmx_expire, lock(EXPIRE)); From owner-svn-src-user@FreeBSD.ORG Fri Jan 9 11:44:22 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 656CA10656CF; Fri, 9 Jan 2009 11:44:22 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4A38C8FC14; Fri, 9 Jan 2009 11:44:22 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n09BiMaj055671; Fri, 9 Jan 2009 11:44:22 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n09BiMU4055670; Fri, 9 Jan 2009 11:44:22 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901091144.n09BiMU4055670@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 9 Jan 2009 11:44:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186940 - user/luigi/geom_sched/sys/geom/sched X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2009 11:44:22 -0000 Author: luigi Date: Fri Jan 9 11:44:22 2009 New Revision: 186940 URL: http://svn.freebsd.org/changeset/base/186940 Log: explain what is this file for Modified: user/luigi/geom_sched/sys/geom/sched/g_gsched.h Modified: user/luigi/geom_sched/sys/geom/sched/g_gsched.h ============================================================================== --- user/luigi/geom_sched/sys/geom/sched/g_gsched.h Fri Jan 9 11:36:30 2009 (r186939) +++ user/luigi/geom_sched/sys/geom/sched/g_gsched.h Fri Jan 9 11:44:22 2009 (r186940) @@ -24,6 +24,10 @@ * SUCH DAMAGE. */ +/* + * Prototypes for GEOM-based disk schedulers. + */ + #ifndef _G_GSCHED_H_ #define _G_GSCHED_H_ From owner-svn-src-user@FreeBSD.ORG Fri Jan 9 11:46:23 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 833CA10656CF; Fri, 9 Jan 2009 11:46:23 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 71FFE8FC18; Fri, 9 Jan 2009 11:46:23 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n09BkNcM055828; Fri, 9 Jan 2009 11:46:23 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n09BkNnk055826; Fri, 9 Jan 2009 11:46:23 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901091146.n09BkNnk055826@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 9 Jan 2009 11:46:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186943 - in user/luigi/geom_sched/sys/geom: . sched X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2009 11:46:24 -0000 Author: luigi Date: Fri Jan 9 11:46:23 2009 New Revision: 186943 URL: http://svn.freebsd.org/changeset/base/186943 Log: for the time being, avoid patching the kernel and do the marking in g_io_request Modified: user/luigi/geom_sched/sys/geom/geom_io.c user/luigi/geom_sched/sys/geom/sched/g_sched.c Modified: user/luigi/geom_sched/sys/geom/geom_io.c ============================================================================== --- user/luigi/geom_sched/sys/geom/geom_io.c Fri Jan 9 11:45:45 2009 (r186942) +++ user/luigi/geom_sched/sys/geom/geom_io.c Fri Jan 9 11:46:23 2009 (r186943) @@ -369,7 +369,7 @@ g_io_request(struct bio *bp, struct g_co bp->bio_error = 0; bp->bio_completed = 0; -#if 0 +#if 1 /* * Scheduler support: if this is the first element in the geom * chain (we know from bp->bio_parent == NULL), store @@ -377,12 +377,25 @@ g_io_request(struct bio *bp, struct g_co * which should be unused in this particular entry (at least * with the code in 7.1/8.0). */ - if (bp->bio_parent == NULL) { - if (bp->bio_caller1 != NULL) - printf("unexpected bio_caller1 %p\n", bp->bio_caller1); - else - bp->bio_caller1 = (void *)curthread->td_tid; +{ + struct bio *top = bp; + static int good = 0, req = 0; + static int last = 0; + + while (top->bio_parent) + top = top->bio_parent; + req++; + if (top->bio_caller1 == NULL) { + top->bio_caller1 = (void *)curthread->td_tid; + if (0) printf("new label %p (thr %p) size %d\n", + top->bio_caller1, curthread, (int)top->bio_length); + good++; + } + if (ticks > last) { + last = last + hz; + printf("at %d total %d good %d\n", ticks, req, good); } +} #endif KASSERT(!(bp->bio_flags & BIO_ONQUEUE), Modified: user/luigi/geom_sched/sys/geom/sched/g_sched.c ============================================================================== --- user/luigi/geom_sched/sys/geom/sched/g_sched.c Fri Jan 9 11:45:45 2009 (r186942) +++ user/luigi/geom_sched/sys/geom/sched/g_sched.c Fri Jan 9 11:46:23 2009 (r186943) @@ -452,6 +452,7 @@ static int g_io_patched = 0; static int g_io_patch(void *f, void *p, void *new_f) { + return 0; int found = bcmp(f, (const char *)p + 5, 5); printf("match result %d\n", found); if (found == 0) { From owner-svn-src-user@FreeBSD.ORG Fri Jan 9 11:47:14 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D1DBF106566B; Fri, 9 Jan 2009 11:47:14 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C09D58FC1B; Fri, 9 Jan 2009 11:47:14 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n09BlEci055892; Fri, 9 Jan 2009 11:47:14 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n09BlEwQ055891; Fri, 9 Jan 2009 11:47:14 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901091147.n09BlEwQ055891@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 9 Jan 2009 11:47:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186944 - user/luigi/geom_sched/sys/geom/sched X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2009 11:47:15 -0000 Author: luigi Date: Fri Jan 9 11:47:14 2009 New Revision: 186944 URL: http://svn.freebsd.org/changeset/base/186944 Log: document and small reorganization of variables Modified: user/luigi/geom_sched/sys/geom/sched/g_as.c Modified: user/luigi/geom_sched/sys/geom/sched/g_as.c ============================================================================== --- user/luigi/geom_sched/sys/geom/sched/g_as.c Fri Jan 9 11:46:23 2009 (r186943) +++ user/luigi/geom_sched/sys/geom/sched/g_as.c Fri Jan 9 11:47:14 2009 (r186944) @@ -24,6 +24,13 @@ * SUCH DAMAGE. */ +/* + * This code implements a GEOM-based anticipatory disk scheduler. + * This version does not track process state or behaviour and it is + * just a proof of concept to show how non work-conserving policies + * can be implemented within this framework. + */ + #include #include @@ -52,17 +59,18 @@ struct g_as_softc { u_long sc_curkey; int sc_status; long sc_batch; + int sc_wait_ticks; + int sc_max_batch; struct callout sc_wait; struct bio_queue_head sc_bioq; }; -#define G_AS_WAIT_EXPIRE (hz/200 > 0 ? hz/200 : 2) -#define G_AS_MAX_BATCH 0x00800000 - /* - * Dispatch the first queued request. Here we also update the status + * Dispatch the first queued request, and update the status * according to the dispatched request. + * This is called as a result of a start, on a timeout, or on + * a completion event. */ static void g_as_dispatch(struct g_as_softc *sc) @@ -70,37 +78,43 @@ g_as_dispatch(struct g_as_softc *sc) struct bio *bio; /* - * Batching means just don't serve too many requests waiting - * for sequential ones, it is not really coupled with the - * threads being served. Its only purpose is to let not the - * scheduler starve other threads while an aggressive one - * is making continuously new requests. + * Serve the requests at the head of the queue, if any, + * and decide whether or not to do anticipatory scheduling + * for the next round. We anticipate if this request is from + * a new client or the current client has not yet exhausted + * its budget. Otherwise, we will serve the next request + * immediately. */ - sc->sc_curkey = 0; bio = bioq_takefirst(&sc->sc_bioq); - if (bio != NULL) { - sc->sc_batch += bio->bio_length; - if (sc->sc_batch > G_AS_MAX_BATCH) { - /* - * Too many requests served here, don't wait - * for the next. - */ + if (bio == NULL) { + /* stray call or timeout */ + sc->sc_curkey = 0; + sc->sc_batch = 0; + sc->sc_status = G_AS_NOWAIT; + } else { + u_long head_key = g_sched_classify(bio); + + /* pass down the current request */ + g_io_request(bio, LIST_FIRST(&sc->sc_geom->consumer)); + + /* + * Now decide what to do next: + * reset budget if client has changed, + * store the identity of the current client, + * and anticipate if and only if the current + * client is below its allowed budget. + */ + if (head_key != sc->sc_curkey) sc->sc_batch = 0; + sc->sc_curkey = head_key; + if (sc->sc_batch > sc->sc_max_batch) { sc->sc_status = G_AS_NOWAIT; } else { - /* - * When this request will be served we'll wait - * for a new one from the same thread. - * Of course we are anticipating everything - * here, even writes or asynchronous requests, - * but this is only a prototype. - */ + sc->sc_batch += bio->bio_length; sc->sc_status = G_AS_WAITREQ; } - g_io_request(bio, LIST_FIRST(&sc->sc_geom->consumer)); - } else - sc->sc_status = G_AS_NOWAIT; + } } static void @@ -118,17 +132,31 @@ g_as_wait_timeout(void *data) g_sched_unlock(sc->sc_geom); } +/* + * This function is called when I have a real disk I/O request coming + * from a client (only for schedulable requests). + * Queue the request and possibly dispatch it. If not dispatched now, + * surely there a timeout or a completion event that will keep things + * running. + */ static void g_as_start(void *data, struct bio *bio) { struct g_as_softc *sc = data; - bioq_disksort(&sc->sc_bioq, bio); - /* - * If the request being submitted is the one we were waiting for - * stop the timer and dispatch it, otherwise do nothing. + * This is an approximated implementation: we do an immediate + * dispatch if the current request is coming from the same client + * who was served last (who was the "privileged" one in terms + * of the scheduling policy). However, the dispatch may actually + * serve a different request if the incoming request is not + * sequential (hence it would cause a seek anyways). + * For this reason, we do an unconditional disksort, and + * then decide to dispatch or wait using the identity + * of the client issuing the request. */ + bioq_disksort(&sc->sc_bioq, bio); + if (sc->sc_status == G_AS_NOWAIT || g_sched_classify(bio) == sc->sc_curkey) { callout_stop(&sc->sc_wait); @@ -136,25 +164,17 @@ g_as_start(void *data, struct bio *bio) } } +/* + * callback when a request is complete. + */ static void g_as_done(void *data, struct bio *bio) { struct g_as_softc *sc = data; - struct bio *bp2; - - bp2 = bio->bio_parent; - - /* Don't wait when fragments are completed. */ - if (bp2->bio_children != bp2->bio_inbed + 1) - return; if (sc->sc_status == G_AS_WAITREQ) { - /* - * Start waiting for a new request from curthread. - */ - sc->sc_curkey = g_sched_classify(bio); - sc->sc_status = G_AS_WAITING; - callout_reset(&sc->sc_wait, G_AS_WAIT_EXPIRE, + sc->sc_status = G_AS_WAITING; /* have pending timer */ + callout_reset(&sc->sc_wait, sc->sc_wait_ticks, g_as_wait_timeout, sc); } else { /* @@ -165,6 +185,11 @@ g_as_done(void *data, struct bio *bio) } } +/* + * Geom glue. When a new geom is attached, allocate and init a + * descriptor. We use a callout queue for timeouts, and a bioq + * to store pending requests. + */ static void * g_as_init(struct g_geom *geom) { @@ -174,6 +199,8 @@ g_as_init(struct g_geom *geom) sc->sc_geom = geom; sc->sc_curkey = 0; sc->sc_status = G_AS_NOWAIT; + sc->sc_wait_ticks = (hz >= 400) ? hz/200 : 2; + sc->sc_max_batch = 0x00800000; /* 8 MB */ callout_init(&sc->sc_wait, CALLOUT_MPSAFE); bioq_init(&sc->sc_bioq); @@ -186,6 +213,11 @@ g_as_fini(void *data) { struct g_as_softc *sc = data; + /* + * geom should guarantee that _fini is only called when there + * are no more bio's active (GEOM does not know about the queue, + * but it can count existing bio's associated to the geom). + */ KASSERT(bioq_first(&sc->sc_bioq) == NULL, ("Still requests pending.")); callout_drain(&sc->sc_wait); From owner-svn-src-user@FreeBSD.ORG Fri Jan 9 11:48:53 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DF6E41065821; Fri, 9 Jan 2009 11:48:53 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CC4888FC08; Fri, 9 Jan 2009 11:48:53 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n09BmriV055973; Fri, 9 Jan 2009 11:48:53 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n09BmrlE055970; Fri, 9 Jan 2009 11:48:53 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901091148.n09BmrlE055970@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 9 Jan 2009 11:48:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186945 - in user/luigi/geom_sched: sbin/geom/class/sched sys/geom sys/geom/sched X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2009 11:48:54 -0000 Author: luigi Date: Fri Jan 9 11:48:53 2009 New Revision: 186945 URL: http://svn.freebsd.org/changeset/base/186945 Log: documentation and small reorganization of the code Modified: user/luigi/geom_sched/sbin/geom/class/sched/gsched.8 user/luigi/geom_sched/sys/geom/geom_sched.c user/luigi/geom_sched/sys/geom/sched/g_rr.c Modified: user/luigi/geom_sched/sbin/geom/class/sched/gsched.8 ============================================================================== --- user/luigi/geom_sched/sbin/geom/class/sched/gsched.8 Fri Jan 9 11:47:14 2009 (r186944) +++ user/luigi/geom_sched/sbin/geom/class/sched/gsched.8 Fri Jan 9 11:48:53 2009 (r186945) @@ -27,7 +27,7 @@ .Os .Sh NAME .Nm gsched -.Nd "control utility for SCHED GEOM class" +.Nd "control utility for disk scheduler GEOM class" .Sh SYNOPSIS .Nm .Cm create @@ -46,13 +46,7 @@ .Op Fl v .Ar prov ... .Nm -.Cm list -.Nm -.Cm status -.Nm -.Cm load -.Nm -.Cm unload +.Cm { list | status | load | unload } .Sh DESCRIPTION The .Nm @@ -121,8 +115,8 @@ The following example shows how to creat .Pa /dev/da0 , and how to destroy it. .Bd -literal -offset indent -gnop create -v da0 -gnop destroy -v da0.nop +gsched create -v da0 +gsched destroy -v da0.nop .Ed .Pp .Ed Modified: user/luigi/geom_sched/sys/geom/geom_sched.c ============================================================================== --- user/luigi/geom_sched/sys/geom/geom_sched.c Fri Jan 9 11:47:14 2009 (r186944) +++ user/luigi/geom_sched/sys/geom/geom_sched.c Fri Jan 9 11:48:53 2009 (r186945) @@ -24,6 +24,14 @@ * SUCH DAMAGE. */ +/* + * This file implements the glue for device-level pluggable disk schedulers. + * The actual scheduling policy is implemented by external modules which + * register with this one, e.g. gs_as or gs_rr ... + * Functions defined here are exported to geom_disk and to individual + * device drivers. XXX to be completed + */ + #include #include @@ -46,12 +54,17 @@ /* Debug sysctl stuff. */ SYSCTL_DECL(_kern_geom); -SYSCTL_NODE(_kern_geom, OID_AUTO, sched, CTLFLAG_RW, 0, "I/O scheduler stuff"); -u_int g_sched_debug; +SYSCTL_NODE(_kern_geom, OID_AUTO, sched, CTLFLAG_RW, 0, + "Disk I/O scheduler"); +u_int g_sched_debug; /* also used by children modules */ SYSCTL_UINT(_kern_geom_sched, OID_AUTO, debug, CTLFLAG_RW, &g_sched_debug, 0, "Debug level"); /* + * The variables below store the list of schedulers registered + * with this class. A scheduler registers through the DECLARE_GSCHED_MODULE + * macro which in eventually causes the invocation of g_sched_register(). + * * Global mutex, protecting the registered schedulers' list and their * gs_refs field. */ @@ -102,9 +115,9 @@ g_sched_disk_init(struct disk *dp) } /* - * Flush the scheduler, assuming that the disk d_sched_lock mutex is - * held. This function tries to dispatch all the requests queued in - * the target scheduler and to wait until they're completed. Flushing + * Flush the scheduler. Called with the disk d_sched_lock mutex held. + * This function tries to dispatch all the requests queued in + * the target scheduler and to wait until they are completed. Flushing * is implemented avoiding queueing for all the requests arriving while * the flush is in progres. */ @@ -129,6 +142,11 @@ g_sched_flush_locked(struct disk *dp) dp->d_sched_flags &= ~G_SCHED_FLUSHING; } +/* + * This function is called by geom_disk when a disk has been detached. + * We may have requests still queued, and need to dispose them because + * there is no underlying device anymore. + */ void g_sched_disk_gone(struct disk *dp) { @@ -145,6 +163,7 @@ g_sched_disk_gone(struct disk *dp) * an appropriate error. Need to release the disk * lock since completion callbacks may reenter the * scheduler. + * gsp should remain unchanged across the loop. */ biofinish(bp, NULL, ENXIO); mtx_lock(&dp->d_sched_lock); @@ -159,8 +178,9 @@ g_sched_disk_fini(struct disk *dp) g_sched_disk_gone(dp); /* - * Here we assume that no new requests reach the scheduler, since - * the disk is almost already destroyed. + * No new requests can reach the scheduler, as the disk + * is almost already destroyed (almost meaning that no more + * requests should arrive and the queue is empty). */ g_sched_configure(dp, "none"); mtx_destroy(&dp->d_sched_lock); @@ -175,45 +195,36 @@ g_sched_start(struct disk *dp, struct bi gsp = dp->d_sched; /* - * Don't try to queue a request if we have no scheduler for - * this disk, or if the request is not one of the type we care - * about (i.e., it is not a read or write). - */ - if (gsp == NULL || (bp->bio_cmd & (BIO_READ | BIO_WRITE)) == 0) - goto nosched; - - /* - * When flushing is in progress we don't want the scheduler - * queue to grow, so we dispatch new requests directly to the - * driver. - */ - if ((dp->d_sched_flags & G_SCHED_FLUSHING) != 0) - goto nosched; - - dp->d_nr_sorted++; - gsp->gs_start(dp->d_sched_data, bp); - mtx_unlock(&dp->d_sched_lock); - - /* - * Try to immediately start the queue. It is up to the scheduler - * to freeze it if needed (returning NULL on the next invocation - * of gs_next()). The scheduler will also be responsible of - * restarting the dispatches to the driver, invoking d_kick() - * directly. - */ - dp->d_kick(dp); - return; + * Only queue a request if + * 1. we have a scheduler (gsp != NULL); + * 2. this is a read or write request; + * 3. we are not flushing the scheduler. + * In all other cases, dispatch directly to the driver. + */ + if (gsp != NULL && (bp->bio_cmd & (BIO_READ | BIO_WRITE)) != 0 && + (dp->d_sched_flags & G_SCHED_FLUSHING) == 0) { + dp->d_nr_sorted++; + gsp->gs_start(dp->d_sched_data, bp); + mtx_unlock(&dp->d_sched_lock); -nosched: - mtx_unlock(&dp->d_sched_lock); + /* + * Try to immediately start the queue. It is up to + * the scheduler to freeze it if needed (returning NULL + * on the next invocation of gs_next()). In this case + * the scheduler will also be in charge of restarting + * the dispatches to the driver, invoking d_kick() + * directly. + */ + dp->d_kick(dp); + } else { + mtx_unlock(&dp->d_sched_lock); - /* - * Mark the request as not sorted by the scheduler. Schedulers - * are supposed to store a non-NULL value in the bio_caller1 field - * (they will need it anyway, unless they're really really simple.) - */ - bp->bio_caller1 = NULL; - dp->d_strategy(bp); + /* + * Mark the request as not sorted by the scheduler. + */ + bp->bio_caller1 = NULL; + dp->d_strategy(bp); + } } struct bio * @@ -227,18 +238,14 @@ g_sched_next(struct disk *dp) mtx_lock(&dp->d_sched_lock); gsp = dp->d_sched; - /* If the disk is not using a scheduler, just always return NULL. */ - if (gsp == NULL) - goto out; - - /* Get the next request from the scheduler. */ - bp = gsp->gs_next(dp->d_sched_data, - (dp->d_sched_flags & G_SCHED_FLUSHING) != 0); + if (gsp != NULL) { /* make sure we have a scheduler */ + /* Get the next request from the scheduler. */ + bp = gsp->gs_next(dp->d_sched_data, + (dp->d_sched_flags & G_SCHED_FLUSHING) != 0); - KASSERT(bp == NULL || bp->bio_caller1 != NULL, - ("bio_caller1 == NULL")); - -out: + KASSERT(bp == NULL || bp->bio_caller1 != NULL, + ("bio_caller1 == NULL")); + } mtx_unlock(&dp->d_sched_lock); return (bp); @@ -262,22 +269,19 @@ g_sched_done(struct bio *bp) * Don't call the completion callback if we have no scheduler * or if the request that completed was not one we sorted. */ - if (gsp == NULL || bp->bio_caller1 == NULL) - goto out; - - kick = gsp->gs_done(dp->d_sched_data, bp); + if (gsp != NULL && bp->bio_caller1 != NULL) { + kick = gsp->gs_done(dp->d_sched_data, bp); - /* - * If flush is in progress and we have no more requests queued, - * wake up the flushing process. - */ - if (--dp->d_nr_sorted == 0 && - (dp->d_sched_flags & G_SCHED_FLUSHING) != 0) { - G_SCHED_DEBUG(2, "geom_sched: flush complete"); - wakeup(&dp->d_sched); + /* + * If flush is in progress and we have no more requests queued, + * wake up the flushing process. + */ + if (--dp->d_nr_sorted == 0 && + (dp->d_sched_flags & G_SCHED_FLUSHING) != 0) { + G_SCHED_DEBUG(2, "geom_sched: flush complete"); + wakeup(&dp->d_sched); + } } - -out: mtx_unlock(&dp->d_sched_lock); if (kick) @@ -333,13 +337,14 @@ g_sched_unregister(struct g_sched *gsp) G_SCHED_DEBUG(1, "geom_sched: %s still in use", gsp->gs_name); error = EBUSY; - } else if (gsp->gs_refs == 1) + } else if (gsp->gs_refs == 1) { /* * The list reference is the last one * that can be removed, so it is safe to * just decrement the counter elsewhere. */ LIST_REMOVE(gsp, gs_list); + } goto out; } } Modified: user/luigi/geom_sched/sys/geom/sched/g_rr.c ============================================================================== --- user/luigi/geom_sched/sys/geom/sched/g_rr.c Fri Jan 9 11:47:14 2009 (r186944) +++ user/luigi/geom_sched/sys/geom/sched/g_rr.c Fri Jan 9 11:48:53 2009 (r186945) @@ -24,6 +24,10 @@ * SUCH DAMAGE. */ +/* + * GEOM-based round robin disk scheduler. + */ + #include #include #include @@ -43,7 +47,7 @@ */ /* Timeout for anticipation. */ -#define G_RR_WAIT_EXPIRE (hz/200 > 0 ? hz/200 : 2) +#define G_RR_WAIT_EXPIRE (hz/400 > 0 ? hz/200 : 2) #define G_QUEUE_NOWAIT 0 /* Ready to dispatch. */ #define G_QUEUE_WAITREQ 1 /* Waiting for a completion. */ @@ -129,6 +133,7 @@ g_rr_queue_get(struct g_rr_softc *sc, u_ bioq_init(&qp->q_bioq); qp->q_budget = G_RR_DEFAULT_BUDGET; LIST_INSERT_HEAD(bucket, qp, q_hash); + printf("new queue for key %lu\n", key); } return (qp); @@ -177,7 +182,6 @@ g_rr_fini(void *data) KASSERT(TAILQ_EMPTY(&sc->sc_rr_tailq), ("still scheduled queues")); for (i = 0; i < G_RR_HASH_SIZE; i++) { LIST_FOREACH_SAFE(qp, &sc->sc_hash[i], q_hash, qp2) { - LIST_REMOVE(qp, q_hash); g_rr_queue_put(qp); } } @@ -246,6 +250,9 @@ g_rr_dispatch(struct g_rr_softc *sc) g_io_request(bp, LIST_FIRST(&sc->sc_geom->consumer)); } +/* + * Called when a real request for disk I/O arrives. + */ static void g_rr_start(void *data, struct bio *bp) { From owner-svn-src-user@FreeBSD.ORG Fri Jan 9 12:17:38 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0F57C1065676; Fri, 9 Jan 2009 12:17:38 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F26228FC14; Fri, 9 Jan 2009 12:17:37 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n09CHbhU056540; Fri, 9 Jan 2009 12:17:37 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n09CHbY7056539; Fri, 9 Jan 2009 12:17:37 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901091217.n09CHbY7056539@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 9 Jan 2009 12:17:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186946 - user/luigi/geom_sched/sys/geom X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2009 12:17:39 -0000 Author: luigi Date: Fri Jan 9 12:17:37 2009 New Revision: 186946 URL: http://svn.freebsd.org/changeset/base/186946 Log: simplify the tagging Modified: user/luigi/geom_sched/sys/geom/geom_io.c Modified: user/luigi/geom_sched/sys/geom/geom_io.c ============================================================================== --- user/luigi/geom_sched/sys/geom/geom_io.c Fri Jan 9 11:48:53 2009 (r186945) +++ user/luigi/geom_sched/sys/geom/geom_io.c Fri Jan 9 12:17:37 2009 (r186946) @@ -377,13 +377,19 @@ g_io_request(struct bio *bp, struct g_co * which should be unused in this particular entry (at least * with the code in 7.1/8.0). */ + { + struct bio *top = bp; + while (top->bio_parent) + top = top->bio_parent; + if (top->bio_caller1 == NULL) + top->bio_caller1 = (void *)curthread->td_tid; + } +#if 0 { struct bio *top = bp; static int good = 0, req = 0; static int last = 0; - while (top->bio_parent) - top = top->bio_parent; req++; if (top->bio_caller1 == NULL) { top->bio_caller1 = (void *)curthread->td_tid; @@ -397,6 +403,7 @@ g_io_request(struct bio *bp, struct g_co } } #endif +#endif KASSERT(!(bp->bio_flags & BIO_ONQUEUE), ("Bio already on queue bp=%p", bp)); From owner-svn-src-user@FreeBSD.ORG Fri Jan 9 13:18:13 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5BCDA106566B; Fri, 9 Jan 2009 13:18:13 +0000 (UTC) (envelope-from netchild@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 48B058FC1C; Fri, 9 Jan 2009 13:18:13 +0000 (UTC) (envelope-from netchild@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n09DIDFv057787; Fri, 9 Jan 2009 13:18:13 GMT (envelope-from netchild@svn.freebsd.org) Received: (from netchild@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n09DIDHa057784; Fri, 9 Jan 2009 13:18:13 GMT (envelope-from netchild@svn.freebsd.org) Message-Id: <200901091318.n09DIDHa057784@svn.freebsd.org> From: Alexander Leidinger Date: Fri, 9 Jan 2009 13:18:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186949 - user/netchild/linuxulator-dtrace/src/sys/compat/linux X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2009 13:18:13 -0000 Author: netchild Date: Fri Jan 9 13:18:13 2009 New Revision: 186949 URL: http://svn.freebsd.org/changeset/base/186949 Log: - Add more dtrace probes. - Add corresponding *_error probes to the dtrace script. - Remove 'register': This is there since cvs rev 1.1. This is not speed critical code, so remove this and let the compiler do his job. In other similar places this was removed already. - Staticize functions which are not used somewhere else, move the corresponding prototypes from the header to the code file. - Add a comment to the debug part which is not dtrace-ified about the constraints which prevent the removal ATM (remove this code when ldebug() is not used anywhere anymore, AKA when the dtrace-ification is finished). Modified: user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_error.d user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_mib.c user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_mib.h Modified: user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_error.d ============================================================================== --- user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_error.d Fri Jan 9 13:06:56 2009 (r186948) +++ user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_error.d Fri Jan 9 13:18:13 2009 (r186949) @@ -56,7 +56,10 @@ linuxulator*:time:linux_clock_nanosleep: linuxulator*:time:linux_clock_nanosleep:copyout_error, linuxulator*:time:linux_clock_nanosleep:nanosleep_error, linuxulator*:sysctl:handle_string:copyout_error, -linuxulator*:sysctl:linux_sysctl:copyin_error +linuxulator*:sysctl:linux_sysctl:copyin_error, +linuxulator*:mib:linux_sysctl_osname:sysctl_string_error, +linuxulator*:mib:linux_sysctl_osversion:sysctl_string_error, +linuxulator*:mib:linux_sysctl_oss_version:sysctl_string_error { printf("ERROR: %s in %s:%s:%s\n", probename, probeprov, probemod, probefunc); stack(); Modified: user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_mib.c ============================================================================== --- user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_mib.c Fri Jan 9 13:06:56 2009 (r186948) +++ user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_mib.c Fri Jan 9 13:18:13 2009 (r186949) @@ -29,8 +29,12 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_compat.h" +#include "opt_kdtrace.h" + #include #include +#include #include #include #include @@ -46,7 +50,85 @@ __FBSDID("$FreeBSD$"); #else #include #endif + #include +#include + +LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE); +LIN_SDT_PROBE_DEFINE(mib, linux_sysctl_osname, entry); +LIN_SDT_PROBE_DEFINE(mib, linux_sysctl_osname, sysctl_string_error); +LIN_SDT_PROBE_ARGTYPE(mib, linux_sysctl_osname, sysctl_string_error, 0, "int"); +LIN_SDT_PROBE_DEFINE(mib, linux_sysctl_osname, return); +LIN_SDT_PROBE_ARGTYPE(mib, linux_sysctl_osname, return, 0, + "int"); +LIN_SDT_PROBE_DEFINE(mib, linux_sysctl_osrelease, entry); +LIN_SDT_PROBE_DEFINE(mib, linux_sysctl_osrelease, sysctl_string_error); +LIN_SDT_PROBE_ARGTYPE(mib, linux_sysctl_osrelease, sysctl_string_error, 0, + "int"); +LIN_SDT_PROBE_DEFINE(mib, linux_sysctl_osrelease, return); +LIN_SDT_PROBE_ARGTYPE(mib, linux_sysctl_osrelease, return, 0, + "int"); +LIN_SDT_PROBE_DEFINE(mib, linux_sysctl_oss_version, entry); +LIN_SDT_PROBE_DEFINE(mib, linux_sysctl_oss_version, sysctl_string_error); +LIN_SDT_PROBE_ARGTYPE(mib, linux_sysctl_oss_version, sysctl_string_error, 0, + "int"); +LIN_SDT_PROBE_DEFINE(mib, linux_sysctl_oss_version, return); +LIN_SDT_PROBE_ARGTYPE(mib, linux_sysctl_oss_version, return, 0, + "int"); +LIN_SDT_PROBE_DEFINE(mib, linux_get_prison, entry); +LIN_SDT_PROBE_ARGTYPE(mib, linux_get_prison, entry, 0, + "struct thread *"); +LIN_SDT_PROBE_DEFINE(mib, linux_get_prison, return); +LIN_SDT_PROBE_ARGTYPE(mib, linux_get_prison, return, 0, + "static struct prison *"); +LIN_SDT_PROBE_DEFINE(mib, linux_get_osname, entry); +LIN_SDT_PROBE_ARGTYPE(mib, linux_get_osname, entry, 0, + "struct thread *"); +LIN_SDT_PROBE_ARGTYPE(mib, linux_get_osname, entry, 1, + "char *"); +LIN_SDT_PROBE_DEFINE(mib, linux_get_osname, return); +LIN_SDT_PROBE_DEFINE(mib, linux_set_osname, entry); +LIN_SDT_PROBE_ARGTYPE(mib, linux_set_osname, entry, 0, + "struct thread *"); +LIN_SDT_PROBE_ARGTYPE(mib, linux_set_osname, entry, 1, + "char *"); +LIN_SDT_PROBE_DEFINE(mib, linux_set_osname, return); +LIN_SDT_PROBE_ARGTYPE(mib, linux_set_osname, return, 0, + "int"); +LIN_SDT_PROBE_DEFINE(mib, linux_get_osrelease, entry); +LIN_SDT_PROBE_ARGTYPE(mib, linux_get_osrelease, entry, 0, + "struct thread *"); +LIN_SDT_PROBE_ARGTYPE(mib, linux_get_osrelease, entry, 1, + "char *"); +LIN_SDT_PROBE_DEFINE(mib, linux_get_osrelease, return); +LIN_SDT_PROBE_DEFINE(mib, linux_use26, entry); +LIN_SDT_PROBE_ARGTYPE(mib, linux_use26, entry, 0, + "struct thread *"); +LIN_SDT_PROBE_DEFINE(mib, linux_use26, return); +LIN_SDT_PROBE_ARGTYPE(mib, linux_use26, return, 0, + "int"); +LIN_SDT_PROBE_DEFINE(mib, linux_set_osrelease, entry); +LIN_SDT_PROBE_ARGTYPE(mib, linux_set_osrelease, entry, 0, + "struct thread *"); +LIN_SDT_PROBE_ARGTYPE(mib, linux_set_osrelease, entry, 1, + "char *"); +LIN_SDT_PROBE_DEFINE(mib, linux_set_osrelease, return); +LIN_SDT_PROBE_ARGTYPE(mib, linux_set_osrelease, return, 0, + "int"); +LIN_SDT_PROBE_DEFINE(mib, linux_get_oss_version, entry); +LIN_SDT_PROBE_ARGTYPE(mib, linux_get_oss_version, entry, 0, + "struct thread *"); +LIN_SDT_PROBE_DEFINE(mib, linux_get_oss_version, return); +LIN_SDT_PROBE_ARGTYPE(mib, linux_get_oss_version, return, 0, + "int"); +LIN_SDT_PROBE_DEFINE(mib, linux_set_oss_version, entry); +LIN_SDT_PROBE_ARGTYPE(mib, linux_set_oss_version, entry, 0, + "struct thread *"); +LIN_SDT_PROBE_ARGTYPE(mib, linux_set_oss_version, entry, 1, + "int"); +LIN_SDT_PROBE_DEFINE(mib, linux_set_oss_version, return); +LIN_SDT_PROBE_ARGTYPE(mib, linux_set_oss_version, return, 0, + "int"); struct linux_prison { char pr_osname[LINUX_MAX_UTSNAME]; @@ -63,17 +145,30 @@ MTX_SYSINIT(linux_osname, &osname_lock, static char linux_osname[LINUX_MAX_UTSNAME] = "Linux"; +static int linux_set_osname(struct thread *td, char *osname); +static int linux_set_osrelease(struct thread *td, char *osrelease); +static int linux_set_oss_version(struct thread *td, int oss_version); + static int linux_sysctl_osname(SYSCTL_HANDLER_ARGS) { char osname[LINUX_MAX_UTSNAME]; int error; + LIN_SDT_PROBE(mib, linux_sysctl_osname, entry, 0, 0, 0, 0, 0); + linux_get_osname(req->td, osname); error = sysctl_handle_string(oidp, osname, LINUX_MAX_UTSNAME, req); - if (error || req->newptr == NULL) + if (error || req->newptr == NULL) { + LIN_SDT_PROBE(mib, linux_sysctl_osname, sysctl_string_error, + error, 0, 0, 0, 0); + LIN_SDT_PROBE(mib, linux_sysctl_osname, return, error, 0, 0, + 0, 0); return (error); + } error = linux_set_osname(req->td, osname); + + LIN_SDT_PROBE(mib, linux_sysctl_osname, return, error, 0, 0, 0, 0); return (error); } @@ -91,11 +186,20 @@ linux_sysctl_osrelease(SYSCTL_HANDLER_AR char osrelease[LINUX_MAX_UTSNAME]; int error; + LIN_SDT_PROBE(mib, linux_sysctl_osrelease, entry, 0, 0, 0, 0, 0); + linux_get_osrelease(req->td, osrelease); error = sysctl_handle_string(oidp, osrelease, LINUX_MAX_UTSNAME, req); - if (error || req->newptr == NULL) + if (error || req->newptr == NULL) { + LIN_SDT_PROBE(mib, linux_sysctl_osrelease, sysctl_string_error, + error, 0, 0, 0, 0); + LIN_SDT_PROBE(mib, linux_sysctl_osrelease, return, error, 0, 0, + 0, 0); return (error); + } error = linux_set_osrelease(req->td, osrelease); + + LIN_SDT_PROBE(mib, linux_sysctl_osrelease, return, error, 0, 0, 0, 0); return (error); } @@ -112,11 +216,20 @@ linux_sysctl_oss_version(SYSCTL_HANDLER_ int oss_version; int error; + LIN_SDT_PROBE(mib, linux_sysctl_oss_version, entry, 0, 0, 0, 0, 0); + oss_version = linux_get_oss_version(req->td); error = sysctl_handle_int(oidp, &oss_version, 0, req); - if (error || req->newptr == NULL) + if (error || req->newptr == NULL) { + LIN_SDT_PROBE(mib, linux_sysctl_oss_version, + sysctl_string_error, error, 0, 0, 0, 0); + LIN_SDT_PROBE(mib, linux_sysctl_oss_version, return, error, 0, + 0, 0, 0); return (error); + } error = linux_set_oss_version(req->td, oss_version); + + LIN_SDT_PROBE(mib, linux_sysctl_oss_version, return, error, 0, 0, 0, 0); return (error); } @@ -131,12 +244,16 @@ SYSCTL_PROC(_compat_linux, OID_AUTO, oss static struct prison * linux_get_prison(struct thread *td) { - register struct prison *pr; - register struct linux_prison *lpr; + struct prison *pr; + struct linux_prison *lpr; + + LIN_SDT_PROBE(mib, linux_get_prison, entry, td, 0, 0, 0, 0); KASSERT(td == curthread, ("linux_get_prison() called on !curthread")); - if (!jailed(td->td_ucred)) + if (!jailed(td->td_ucred)) { + LIN_SDT_PROBE(mib, linux_get_prison, return, NULL, 0, 0, 0, 0); return (NULL); + } pr = td->td_ucred->cr_prison; mtx_lock(&pr->pr_mtx); if (pr->pr_linux == NULL) { @@ -154,14 +271,18 @@ linux_get_prison(struct thread *td) else free(lpr, M_PRISON); } + + LIN_SDT_PROBE(mib, linux_get_prison, return, pr, 0, 0, 0, 0); return (pr); } void linux_get_osname(struct thread *td, char *dst) { - register struct prison *pr; - register struct linux_prison *lpr; + struct prison *pr; + struct linux_prison *lpr; + + LIN_SDT_PROBE(mib, linux_get_osname, entry, td, dst, 0, 0, 0); pr = td->td_ucred->cr_prison; if (pr != NULL) { @@ -171,6 +292,8 @@ linux_get_osname(struct thread *td, char if (lpr->pr_osname[0]) { bcopy(lpr->pr_osname, dst, LINUX_MAX_UTSNAME); mtx_unlock(&pr->pr_mtx); + LIN_SDT_PROBE(mib, linux_get_osname, return, 0, + 0, 0, 0, 0); return; } } @@ -180,14 +303,18 @@ linux_get_osname(struct thread *td, char mtx_lock(&osname_lock); bcopy(linux_osname, dst, LINUX_MAX_UTSNAME); mtx_unlock(&osname_lock); + + LIN_SDT_PROBE(mib, linux_get_osname, return, 0, 0, 0, 0, 0); } -int +static int linux_set_osname(struct thread *td, char *osname) { struct prison *pr; struct linux_prison *lpr; + LIN_SDT_PROBE(mib, linux_set_osname, entry, td, osname, 0, 0, 0); + pr = linux_get_prison(td); if (pr != NULL) { lpr = (struct linux_prison *)pr->pr_linux; @@ -199,15 +326,18 @@ linux_set_osname(struct thread *td, char mtx_unlock(&osname_lock); } + LIN_SDT_PROBE(mib, linux_set_osname, return, 0, 0, 0, 0, 0); return (0); } void linux_get_osrelease(struct thread *td, char *dst) { - register struct prison *pr; + struct prison *pr; struct linux_prison *lpr; + LIN_SDT_PROBE(mib, linux_get_osrelease, entry, td, dst, 0, 0, 0); + pr = td->td_ucred->cr_prison; if (pr != NULL) { mtx_lock(&pr->pr_mtx); @@ -217,6 +347,8 @@ linux_get_osrelease(struct thread *td, c bcopy(lpr->pr_osrelease, dst, LINUX_MAX_UTSNAME); mtx_unlock(&pr->pr_mtx); + LIN_SDT_PROBE(mib, linux_get_osrelease, return, + 0, 0, 0, 0, 0); return; } } @@ -226,6 +358,8 @@ linux_get_osrelease(struct thread *td, c mtx_lock(&osname_lock); bcopy(linux_osrelease, dst, LINUX_MAX_UTSNAME); mtx_unlock(&osname_lock); + + LIN_SDT_PROBE(mib, linux_get_osrelease, return, 0, 0, 0, 0, 0); } int @@ -235,6 +369,8 @@ linux_use26(struct thread *td) struct linux_prison *lpr; int use26 = linux_use_linux26; + LIN_SDT_PROBE(mib, linux_use26, entry, td, 0, 0, 0, 0); + pr = td->td_ucred->cr_prison; if (pr != NULL) { if (pr->pr_linux != NULL) { @@ -242,17 +378,20 @@ linux_use26(struct thread *td) use26 = lpr->pr_use_linux26; } } - + + LIN_SDT_PROBE(mib, linux_use26, return, use26, 0, 0, 0, 0); return (use26); } -int +static int linux_set_osrelease(struct thread *td, char *osrelease) { struct prison *pr; struct linux_prison *lpr; int use26; + LIN_SDT_PROBE(mib, linux_set_osrelease, entry, td, osrelease, 0, 0, 0); + use26 = (strlen(osrelease) >= 3 && osrelease[2] == '6'); pr = linux_get_prison(td); @@ -268,16 +407,19 @@ linux_set_osrelease(struct thread *td, c mtx_unlock(&osname_lock); } + LIN_SDT_PROBE(mib, linux_set_osrelease, return, 0, 0, 0, 0, 0); return (0); } int linux_get_oss_version(struct thread *td) { - register struct prison *pr; - register struct linux_prison *lpr; + struct prison *pr; + struct linux_prison *lpr; int version; + LIN_SDT_PROBE(mib, linux_get_oss_version, entry, td, 0, 0, 0, 0); + pr = td->td_ucred->cr_prison; if (pr != NULL) { mtx_lock(&pr->pr_mtx); @@ -286,6 +428,8 @@ linux_get_oss_version(struct thread *td) if (lpr->pr_oss_version) { version = lpr->pr_oss_version; mtx_unlock(&pr->pr_mtx); + LIN_SDT_PROBE(mib, linux_get_oss_version, + return, version, 0, 0, 0, 0); return (version); } } @@ -295,15 +439,19 @@ linux_get_oss_version(struct thread *td) mtx_lock(&osname_lock); version = linux_oss_version; mtx_unlock(&osname_lock); + + LIN_SDT_PROBE(mib, linux_get_oss_version, return, version, 0, 0, 0, 0); return (version); } -int +static int linux_set_oss_version(struct thread *td, int oss_version) { struct prison *pr; struct linux_prison *lpr; + LIN_SDT_PROBE(mib, linux_set_oss_version, entry, td, oss_version, 0, 0, + 0); pr = linux_get_prison(td); if (pr != NULL) { lpr = (struct linux_prison *)pr->pr_linux; @@ -315,10 +463,12 @@ linux_set_oss_version(struct thread *td, mtx_unlock(&osname_lock); } + LIN_SDT_PROBE(mib, linux_set_oss_version, return, 0, 0, 0, 0, 0); return (0); } #ifdef DEBUG +/* XXX: can be removed when every ldebug(...) is removed. */ u_char linux_debug_map[howmany(LINUX_SYS_MAXSYSCALL, sizeof(u_char))]; Modified: user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_mib.h ============================================================================== --- user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_mib.h Fri Jan 9 13:06:56 2009 (r186948) +++ user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_mib.h Fri Jan 9 13:18:13 2009 (r186949) @@ -32,14 +32,8 @@ #define _LINUX_MIB_H_ void linux_get_osname(struct thread *td, char *dst); -int linux_set_osname(struct thread *td, char *osname); - void linux_get_osrelease(struct thread *td, char *dst); -int linux_set_osrelease(struct thread *td, char *osrelease); - int linux_get_oss_version(struct thread *td); -int linux_set_oss_version(struct thread *td, int oss_version); - int linux_use26(struct thread *td); #endif /* _LINUX_MIB_H_ */ From owner-svn-src-user@FreeBSD.ORG Fri Jan 9 14:35:33 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0AEBF10656C3; Fri, 9 Jan 2009 14:35:33 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ED25D8FC0C; Fri, 9 Jan 2009 14:35:32 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n09EZWs4059431; Fri, 9 Jan 2009 14:35:32 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n09EZWMW059430; Fri, 9 Jan 2009 14:35:32 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901091435.n09EZWMW059430@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 9 Jan 2009 14:35:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186951 - user/luigi/geom_sched/sys/geom X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2009 14:35:33 -0000 Author: luigi Date: Fri Jan 9 14:35:32 2009 New Revision: 186951 URL: http://svn.freebsd.org/changeset/base/186951 Log: add missing file Added: user/luigi/geom_sched/sys/geom/geom_sched.h Added: user/luigi/geom_sched/sys/geom/geom_sched.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/luigi/geom_sched/sys/geom/geom_sched.h Fri Jan 9 14:35:32 2009 (r186951) @@ -0,0 +1,196 @@ +/*- + * Copyright (c) 2008 Fabio Checconi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _GEOM_GEOM_SCHED_H_ +#define _GEOM_GEOM_SCHED_H_ + +#ifdef _KERNEL +#include +#include +#include +#include +#include + +extern u_int g_sched_debug; + +#define G_SCHED_DEBUG(lvl, ...) do { \ + if (g_sched_debug >= (lvl)) { \ + printf("GEOM_SCHED"); \ + if (g_sched_debug > 0) \ + printf("[%u]", (lvl)); \ + printf(": "); \ + printf(__VA_ARGS__); \ + printf("\n"); \ + } \ +} while (0) + +/* + * Types for the callbacks defined by each I/O scheduler. + * + * When a scheduler is assigned to a disk its gs_init method is called. + * It takes the target disk as input and returns the private data the + * scheduler will use for it. It can fail and return NULL, thus making + * the scheduler switch fail. It is not called under disk d_sched_lock + * nor under g_sched_mtx. + */ +typedef void *gs_init_t (struct disk *dp); + +/* + * Disk shutdown method, called when the scheduler is detached from a + * disk. It is not synchronized WRT other scheduler methods, but it is + * guaranteed to be executed when no more requests will reach the + * scheduler. + */ +typedef void gs_fini_t (void *data); + +/* + * Insert a new request into the scheduler. This method is called only + * for requests that can be reordered by the scheduler, and is supposed + * to queue the request. It is called under the disk d_sched_lock mutex. + */ +typedef void gs_start_t (void *data, struct bio *bp); + +/* + * Get the next request from the scheduler. This method is called with + * the disk d_sched_lock mutex held, from the drivers code. When force + * is not zero it is assumed to not return NULL unless the scheduler has + * no more queued requests. + */ +typedef struct bio *gs_next_t (void *data, int force); + +/* + * Completion callback for a previously issued request. It gets called + * under the disk d_sched_lock mutex. It has no specific task, as + * request completion is handled by the generic code, but can be used + * by the scheduler to implement anticipation mechanisms. A nonzero + * return value means that dispatching has to be restarted. + */ +typedef int gs_done_t (void *data, struct bio *bp); + +/* + * I/O scheduler descriptor. Each scheduler has to register itself + * providing a struct g_sched object. (Must not be const, as the + * framework needs to modify gs_refs and gs_list.) + */ +struct g_sched { + const char *gs_name; + + int gs_refs; + + gs_init_t *gs_init; + gs_fini_t *gs_fini; + gs_start_t *gs_start; + gs_next_t *gs_next; + gs_done_t *gs_done; + + LIST_ENTRY(g_sched) gs_list; +}; + +/* + * Lookup the identity of the issuer of the original request. + * In the current implementation we use the curthread of the + * issuer, but different mechanisms may be implemented later + * so we do not make assumptions on the return value which for + * us is just an opaque identifier. + * For the time being we make this inline. + */ +static inline +u_long g_sched_classify(struct bio *bp) +{ + + if (bp == NULL) { + printf("g_sched_classify: NULL bio\n"); + return (0); /* as good as anything */ + } + while (bp->bio_parent != NULL) + bp = bp->bio_parent; + return ((u_long)(bp->bio_caller1)); +} + +/* + * Initialize/cleanup the I/O scheduling subsystem. Interface towards + * geom_disk.c, for class init/fini methods. + */ +void g_sched_init(void); +void g_sched_fini(void); + +/* + * Initialize/cleanup the I/O scheduling fields of the given disk. Interface + * towards geom_disk.c, used to signal to the scheduler subsystem the main + * events of the disk lifecycle. + */ +void g_sched_disk_init(struct disk *dp); +void g_sched_disk_fini(struct disk *dp); +void g_sched_disk_gone(struct disk *dp); + +/* + * Try to enqueue a bio into the scheduler of the given disk. If the + * request can be reordered (we reorder only READ and WRITE requests), + * the bio is passed to the scheduler, otherwise it is passed directly + * to the driver using its d_strategy. + */ +void g_sched_start(struct disk *dp, struct bio *bp); + +/* + * Pick the next request from the scheduler of the given disk. This + * function has to be called from the drivers when they want to refill + * their internal queue (if any) or if they need a new request. + * If force == 0 the scheduler is allowed to return NULL even if it + * has requests enqueued, to allow non work-conserving schedulers to + * be implemented (the kick mechanism will restart the I/O on the + * device). + */ +struct bio *g_sched_next(struct disk *dp); + +/* + * Notify to the scheduler the completion of a request. + */ +void g_sched_done(struct bio *bp); + +/* + * Try to configure dp to use the scheduler identified by name. Used + * by the disk class to handle reconfigurations. It may sleep waiting + * for pending requests to complete. + */ +int g_sched_configure(struct disk *dp, const char *name); + +/* + * Register a scheduling module. Used by the schedulers to register + * themselves to the system. + */ +int g_sched_modevent(module_t mod, int cmd, void *arg); + +#define DECLARE_GSCHED_MODULE(name, gsched) \ + static moduledata_t name##_mod = { \ + #name, \ + g_sched_modevent, \ + gsched, \ + }; \ + DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_ANY); \ + MODULE_DEPEND(name, g_disk, 0, 0, 0); + +#endif /* _KERNEL */ +#endif /* _GEOM_GEOM_SCHED_H_ */ From owner-svn-src-user@FreeBSD.ORG Fri Jan 9 14:35:56 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D31410656C0; Fri, 9 Jan 2009 14:35:56 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0C5038FC18; Fri, 9 Jan 2009 14:35:56 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n09EZt5U059473; Fri, 9 Jan 2009 14:35:55 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n09EZt3F059471; Fri, 9 Jan 2009 14:35:55 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901091435.n09EZt3F059471@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 9 Jan 2009 14:35:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186952 - in user/luigi/geom_sched/sys/geom: . sched X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2009 14:35:56 -0000 Author: luigi Date: Fri Jan 9 14:35:55 2009 New Revision: 186952 URL: http://svn.freebsd.org/changeset/base/186952 Log: do the patching of g_io_request Modified: user/luigi/geom_sched/sys/geom/geom_io.c user/luigi/geom_sched/sys/geom/sched/g_sched.c Modified: user/luigi/geom_sched/sys/geom/geom_io.c ============================================================================== --- user/luigi/geom_sched/sys/geom/geom_io.c Fri Jan 9 14:35:32 2009 (r186951) +++ user/luigi/geom_sched/sys/geom/geom_io.c Fri Jan 9 14:35:55 2009 (r186952) @@ -369,7 +369,7 @@ g_io_request(struct bio *bp, struct g_co bp->bio_error = 0; bp->bio_completed = 0; -#if 1 +#if 0 /* * Scheduler support: if this is the first element in the geom * chain (we know from bp->bio_parent == NULL), store Modified: user/luigi/geom_sched/sys/geom/sched/g_sched.c ============================================================================== --- user/luigi/geom_sched/sys/geom/sched/g_sched.c Fri Jan 9 14:35:32 2009 (r186951) +++ user/luigi/geom_sched/sys/geom/sched/g_sched.c Fri Jan 9 14:35:55 2009 (r186952) @@ -433,7 +433,7 @@ g_io_trampoline[] = { 0xe9, 0x00, 0x00, 0x00, 0x00, /* jmp x+5 */ }; -static void +static int g_new_io_request(const char *ret, struct bio *bp, struct g_consumer *cp) { @@ -444,15 +444,20 @@ g_new_io_request(const char *ret, struct * which should be unused in this particular entry (at least * with the code in 7.1/8.0). */ - if (bp->bio_parent == NULL && bp->bio_caller1 == NULL) - bp->bio_caller1 = (void *)curthread->td_tid; + struct bio *top = bp; + if (top) { + while (top->bio_parent) + top = top->bio_parent; + if (top->bio_caller1 == NULL) + top->bio_caller1 = (void *)curthread->td_tid; + } + return (bp != top); /* prevent compiler from clobbering bp */ } static int g_io_patched = 0; static int g_io_patch(void *f, void *p, void *new_f) { - return 0; int found = bcmp(f, (const char *)p + 5, 5); printf("match result %d\n", found); if (found == 0) { From owner-svn-src-user@FreeBSD.ORG Sat Jan 10 02:32:56 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 938EE106566B; Sat, 10 Jan 2009 02:32:56 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 81EDC8FC17; Sat, 10 Jan 2009 02:32:56 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0A2WuUO076918; Sat, 10 Jan 2009 02:32:56 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0A2WuUX076916; Sat, 10 Jan 2009 02:32:56 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901100232.n0A2WuUX076916@svn.freebsd.org> From: Kip Macy Date: Sat, 10 Jan 2009 02:32:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186994 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 02:32:57 -0000 Author: kmacy Date: Sat Jan 10 02:32:56 2009 New Revision: 186994 URL: http://svn.freebsd.org/changeset/base/186994 Log: - add kernel support for "sticky" routes - all connections from a given source ip will be routed to the same dst ip Modified: user/kmacy/HEAD_fast_net/sys/net/flowtable.c user/kmacy/HEAD_fast_net/sys/net/route.h Modified: user/kmacy/HEAD_fast_net/sys/net/flowtable.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/flowtable.c Sat Jan 10 01:47:15 2009 (r186993) +++ user/kmacy/HEAD_fast_net/sys/net/flowtable.c Sat Jan 10 02:32:56 2009 (r186994) @@ -330,13 +330,14 @@ flowtable_pcpu_unlock(struct flowtable * static uint32_t ipv4_flow_lookup_hash_internal(struct mbuf *m, struct route *ro, - uint32_t *key, uint16_t *flags, uint8_t *protop) + uint32_t *key, uint16_t *flags, uint8_t *protop, uint32_t *hash, + uint32_t *hash_noports) { uint16_t sport = 0, dport = 0; struct ip *ip; uint8_t proto = 0; int iphlen; - uint32_t hash; + uint32_t rh; struct sockaddr_in *sin; struct tcphdr *th; struct udphdr *uh; @@ -352,14 +353,16 @@ ipv4_flow_lookup_hash_internal(struct mb key[1] = 0; key[2] = sin->sin_addr.s_addr; - if (m == NULL || (*flags & FL_HASH_PORTS) == 0) + if (m == NULL) goto skipports; - ip = mtod(m, struct ip *); proto = ip->ip_p; iphlen = ip->ip_hl << 2; /* XXX options? */ key[1] = ip->ip_src.s_addr; - + + if ((*flags & FL_HASH_PORTS) == 0) + goto skipports; + switch (proto) { case IPPROTO_TCP: th = (struct tcphdr *)((caddr_t)ip + iphlen); @@ -386,30 +389,27 @@ ipv4_flow_lookup_hash_internal(struct mb break;; } - *protop = proto; - - /* - * If this is a transmit route cache then - * hash all flows to a given destination to - * the same bucket - */ - if ((*flags & FL_HASH_PORTS) == 0) - proto = sport = dport = 0; - - ((uint16_t *)key)[0] = sport; - ((uint16_t *)key)[1] = dport; skipports: - hash = hashword(key, 3, hashjitter + proto); + rh = hashword(key, 3, hashjitter + proto); + *hash_noports = rh; + *hash = 0; + if ((*flags & FL_HASH_PORTS) && sport) { + ((uint16_t *)key)[0] = sport; + ((uint16_t *)key)[1] = dport; + rh = hashword(key, 3, hashjitter + proto); + *hash = rh; + } if (m != NULL && (m->m_flags & M_FLOWID) == 0) - m->m_pkthdr.flowid = hash; - - CTR5(KTR_SPARE3, "proto=%d hash=%x key[0]=%x sport=%d dport=%d\n", proto, hash, key[0], sport, dport); - - return (hash); + m->m_pkthdr.flowid = rh; + + CTR5(KTR_SPARE3, "proto=%d hash=%x key[0]=%x sport=%d dport=%d\n", + proto, *hash, key[0], sport, dport); + + return (0); noop: *protop = proto; - return (0); + return (ENOENT); } static bitstr_t * @@ -566,7 +566,7 @@ flowtable_key_equal(struct flentry *fle, int flowtable_lookup(struct flowtable *ft, struct mbuf *m, struct route *ro) { - uint32_t key[9], hash; + uint32_t key[9], hash, hash_noports; struct flentry *fle; uint16_t flags; uint8_t proto = 0; @@ -577,13 +577,14 @@ flowtable_lookup(struct flowtable *ft, s flags = ft ? ft->ft_flags : 0; ro->ro_rt = NULL; ro->ro_lle = NULL; - + hash = hash_noports = 0; + /* * The internal hash lookup is the only IPv4 specific bit * remaining */ - hash = ipv4_flow_lookup_hash_internal(m, ro, key, - &flags, &proto); + error = ipv4_flow_lookup_hash_internal(m, ro, key, + &flags, &proto, &hash, &hash_noports); /* * Ports are zero and this isn't a transmit cache @@ -591,10 +592,13 @@ flowtable_lookup(struct flowtable *ft, s * statex * FL_HASH_PORTS => key[0] != 0 for TCP || UDP || SCTP */ - if (hash == 0 || (key[0] == 0 && (ft->ft_flags & FL_HASH_PORTS))) { + if (error == ENOENT || (key[0] == 0 && (ft->ft_flags & FL_HASH_PORTS))) { cache = 0; goto uncached; } + if ((ft->ft_flags & FL_HASH_PORTS) == 0) + goto skipports; + FL_ENTRY_LOCK(ft, hash); fle = FL_ENTRY(ft, hash); rt = __DEVOLATILE(struct rtentry *, fle->f_rt); @@ -614,6 +618,27 @@ flowtable_lookup(struct flowtable *ft, s } FL_ENTRY_UNLOCK(ft, hash); +skipports: + key[0] = 0; + FL_ENTRY_LOCK(ft, hash_noports); + fle = FL_ENTRY(ft, hash_noports); + rt = __DEVOLATILE(struct rtentry *, fle->f_rt); + lle = __DEVOLATILE(struct llentry *, fle->f_lle); + if ((rt != NULL) + && fle->f_fhash == hash_noports + && flowtable_key_equal(fle, key, flags) + && (proto == fle->f_proto) + && (rt->rt_flags & RTF_UP) + && (rt->rt_ifp != NULL)) { + fle->f_uptime = time_uptime; + fle->f_flags |= flags; + ro->ro_rt = rt; + ro->ro_lle = lle; + FL_ENTRY_UNLOCK(ft, hash_noports); + return (0); + } + FL_ENTRY_UNLOCK(ft, hash_noports); + uncached: /* * This bit of code ends up locking the @@ -639,6 +664,18 @@ uncached: struct rtentry *rt = ro->ro_rt; struct ifnet *ifp = rt->rt_ifp; + if (rt->rt_flags & RTF_STICKY) { + RTFREE(rt); + hash = hash_noports; + ft->ft_rtalloc(ro, hash, fib); + if (ro->ro_rt == NULL) { + error = ENETUNREACH; + goto done; + } + rt = ro->ro_rt; + ifp = rt->rt_ifp; + } + if (rt->rt_flags & RTF_GATEWAY) l3addr = rt->rt_gateway; else @@ -670,7 +707,7 @@ uncached: } error = 0; } - +done: return (error); } @@ -719,7 +756,7 @@ flowtable_alloc(int nentry, int flags) ft->ft_masks[i] = bit_alloc(nentry); } } else { - ft->ft_lock_count = 2*(powerof2(mp_ncpus) ? mp_ncpus : + ft->ft_lock_count = 8*(powerof2(mp_ncpus) ? mp_ncpus : (fls(mp_ncpus) << 1)); ft->ft_lock = flowtable_global_lock; Modified: user/kmacy/HEAD_fast_net/sys/net/route.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/route.h Sat Jan 10 01:47:15 2009 (r186993) +++ user/kmacy/HEAD_fast_net/sys/net/route.h Sat Jan 10 02:32:56 2009 (r186994) @@ -196,9 +196,10 @@ struct ortentry { #define RTF_LOCAL 0x200000 /* route represents a local address */ #define RTF_BROADCAST 0x400000 /* route represents a bcast address */ #define RTF_MULTICAST 0x800000 /* route represents a mcast address */ - /* 0x1000000 and up unassigned */ + /* 0x8000000 and up unassigned */ +#define RTF_STICKY 0x10000000 /* always route dst->src */ #define RTF_SHUTDOWN 0x20000000 /* no new connections */ -#define RTF_RNH_LOCKED 0x40000000 +#define RTF_RNH_LOCKED 0x40000000 /* Mask of RTF flags that are allowed to be modified by RTM_CHANGE. */ #define RTF_FMASK \ From owner-svn-src-user@FreeBSD.ORG Sat Jan 10 02:33:31 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B6AC7106566C; Sat, 10 Jan 2009 02:33:31 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A60278FC08; Sat, 10 Jan 2009 02:33:31 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0A2XV1o076984; Sat, 10 Jan 2009 02:33:31 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0A2XVYx076982; Sat, 10 Jan 2009 02:33:31 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901100233.n0A2XVYx076982@svn.freebsd.org> From: Kip Macy Date: Sat, 10 Jan 2009 02:33:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186995 - user/kmacy/HEAD_fast_net/sbin/route X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 02:33:32 -0000 Author: kmacy Date: Sat Jan 10 02:33:31 2009 New Revision: 186995 URL: http://svn.freebsd.org/changeset/base/186995 Log: - add support to the route command for making routes sticky Modified: user/kmacy/HEAD_fast_net/sbin/route/keywords user/kmacy/HEAD_fast_net/sbin/route/route.c Modified: user/kmacy/HEAD_fast_net/sbin/route/keywords ============================================================================== --- user/kmacy/HEAD_fast_net/sbin/route/keywords Sat Jan 10 02:32:56 2009 (r186994) +++ user/kmacy/HEAD_fast_net/sbin/route/keywords Sat Jan 10 02:33:31 2009 (r186995) @@ -33,6 +33,7 @@ mtu net netmask nostatic +nostick osi prefixlen proto1 @@ -47,6 +48,7 @@ sendpipe shutdown ssthresh static +sticky weight x25 xns Modified: user/kmacy/HEAD_fast_net/sbin/route/route.c ============================================================================== --- user/kmacy/HEAD_fast_net/sbin/route/route.c Sat Jan 10 02:32:56 2009 (r186994) +++ user/kmacy/HEAD_fast_net/sbin/route/route.c Sat Jan 10 02:33:31 2009 (r186995) @@ -638,6 +638,12 @@ newroute(argc, argv) case K_STATIC: flags |= RTF_STATIC; break; + case K_STICKY: + flags |= RTF_STICKY; + break; + case K_NOSTICK: + flags &= ~RTF_STICKY; + break; case K_IFA: if (!--argc) usage((char *)NULL); From owner-svn-src-user@FreeBSD.ORG Sat Jan 10 04:35:35 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C5A861065670; Sat, 10 Jan 2009 04:35:35 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B449A8FC1B; Sat, 10 Jan 2009 04:35:35 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0A4ZZBM079822; Sat, 10 Jan 2009 04:35:35 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0A4ZZMf079821; Sat, 10 Jan 2009 04:35:35 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901100435.n0A4ZZMf079821@svn.freebsd.org> From: Kip Macy Date: Sat, 10 Jan 2009 04:35:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187003 - user/kmacy/HEAD_fast_net/sbin/route X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 04:35:36 -0000 Author: kmacy Date: Sat Jan 10 04:35:35 2009 New Revision: 187003 URL: http://svn.freebsd.org/changeset/base/187003 Log: - add new flags to route output - remove hopcount Modified: user/kmacy/HEAD_fast_net/sbin/route/route.c Modified: user/kmacy/HEAD_fast_net/sbin/route/route.c ============================================================================== --- user/kmacy/HEAD_fast_net/sbin/route/route.c Sat Jan 10 04:35:12 2009 (r187002) +++ user/kmacy/HEAD_fast_net/sbin/route/route.c Sat Jan 10 04:35:35 2009 (r187003) @@ -1299,10 +1299,10 @@ char metricnames[] = "\011pksent\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire\2hopcount" "\1mtu"; char routeflags[] = -"\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010MASK_PRESENT" -"\011CLONING\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016b016" -"\017PROTO2\020PROTO1\021PRCLONING\022WASCLONED\023PROTO3\024CHAINDELETE" -"\025PINNED\026LOCAL\027BROADCAST\030MULTICAST"; +"\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE" +"\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016b016" +"\017PROTO2\020PROTO1\021PRCLONING\022WASCLONED\023PROTO3" +"\025PINNED\026LOCAL\027BROADCAST\030MULTICAST\035STICK\036SHUTDOWN"; char ifnetflags[] = "\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6b6\7RUNNING\010NOARP" "\011PPROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1" @@ -1465,7 +1465,7 @@ print_getmsg(rtm, msglen) #define msec(u) (((u) + 500) / 1000) /* usec to msec */ (void) printf("\n%s\n", "\ - recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu weight expire"); + recvpipe sendpipe ssthresh rtt,msec rttvar mtu weight expire"); printf("%8ld%c ", rtm->rtm_rmx.rmx_recvpipe, lock(RPIPE)); printf("%8ld%c ", rtm->rtm_rmx.rmx_sendpipe, lock(SPIPE)); printf("%8ld%c ", rtm->rtm_rmx.rmx_ssthresh, lock(SSTHRESH)); From owner-svn-src-user@FreeBSD.ORG Sat Jan 10 04:42:54 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4772F106566B; Sat, 10 Jan 2009 04:42:54 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2726D8FC13; Sat, 10 Jan 2009 04:42:54 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0A4gsUS079974; Sat, 10 Jan 2009 04:42:54 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0A4gsFJ079973; Sat, 10 Jan 2009 04:42:54 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901100442.n0A4gsFJ079973@svn.freebsd.org> From: Kip Macy Date: Sat, 10 Jan 2009 04:42:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187004 - user/kmacy/HEAD_fast_net/sbin/route X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 04:42:54 -0000 Author: kmacy Date: Sat Jan 10 04:42:53 2009 New Revision: 187004 URL: http://svn.freebsd.org/changeset/base/187004 Log: update route flags and metricnames Modified: user/kmacy/HEAD_fast_net/sbin/route/route.c Modified: user/kmacy/HEAD_fast_net/sbin/route/route.c ============================================================================== --- user/kmacy/HEAD_fast_net/sbin/route/route.c Sat Jan 10 04:35:35 2009 (r187003) +++ user/kmacy/HEAD_fast_net/sbin/route/route.c Sat Jan 10 04:42:53 2009 (r187004) @@ -1296,13 +1296,13 @@ char *msgtypes[] = { }; char metricnames[] = -"\011pksent\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire\2hopcount" +"\011weight\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire" "\1mtu"; char routeflags[] = "\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE" "\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016b016" "\017PROTO2\020PROTO1\021PRCLONING\022WASCLONED\023PROTO3" -"\025PINNED\026LOCAL\027BROADCAST\030MULTICAST\035STICK\036SHUTDOWN"; +"\025PINNED\026LOCAL\027BROADCAST\030MULTICAST\035STICKY\036SHUTDOWN"; char ifnetflags[] = "\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6b6\7RUNNING\010NOARP" "\011PPROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1" @@ -1471,7 +1471,6 @@ print_getmsg(rtm, msglen) printf("%8ld%c ", rtm->rtm_rmx.rmx_ssthresh, lock(SSTHRESH)); printf("%8ld%c ", msec(rtm->rtm_rmx.rmx_rtt), lock(RTT)); printf("%8ld%c ", msec(rtm->rtm_rmx.rmx_rttvar), lock(RTTVAR)); - printf("%8ld%c ", rtm->rtm_rmx.rmx_hopcount, lock(HOPCOUNT)); printf("%8ld%c ", rtm->rtm_rmx.rmx_mtu, lock(MTU)); printf("%8ld%c ", rtm->rtm_rmx.rmx_weight, lock(WEIGHT)); if (rtm->rtm_rmx.rmx_expire) From owner-svn-src-user@FreeBSD.ORG Sat Jan 10 04:49:55 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 74AC01065670; Sat, 10 Jan 2009 04:49:55 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 63C5A8FC1E; Sat, 10 Jan 2009 04:49:55 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0A4ntAF080147; Sat, 10 Jan 2009 04:49:55 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0A4ntxJ080145; Sat, 10 Jan 2009 04:49:55 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901100449.n0A4ntxJ080145@svn.freebsd.org> From: Kip Macy Date: Sat, 10 Jan 2009 04:49:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187005 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 04:49:55 -0000 Author: kmacy Date: Sat Jan 10 04:49:55 2009 New Revision: 187005 URL: http://svn.freebsd.org/changeset/base/187005 Log: fetch weight when getting metrics Modified: user/kmacy/HEAD_fast_net/sys/net/route.h user/kmacy/HEAD_fast_net/sys/net/rtsock.c Modified: user/kmacy/HEAD_fast_net/sys/net/route.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/route.h Sat Jan 10 04:42:53 2009 (r187004) +++ user/kmacy/HEAD_fast_net/sys/net/route.h Sat Jan 10 04:49:55 2009 (r187005) @@ -204,7 +204,7 @@ struct ortentry { /* Mask of RTF flags that are allowed to be modified by RTM_CHANGE. */ #define RTF_FMASK \ (RTF_PROTO1 | RTF_PROTO2 | RTF_PROTO3 | RTF_BLACKHOLE | \ - RTF_REJECT | RTF_STATIC) + RTF_REJECT | RTF_STATIC | RTF_SHUTDOWN | RTF_STICKY) /* * Routing statistics. @@ -271,7 +271,7 @@ struct rt_msghdr { #define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */ #define RTV_RTT 0x40 /* init or lock _rtt */ #define RTV_RTTVAR 0x80 /* init or lock _rttvar */ -#define RTV_WEIGHT 0x100 /* init or lock _rttvar */ +#define RTV_WEIGHT 0x100 /* init or lock _weight */ /* * Bitmask values for rtm_addrs. Modified: user/kmacy/HEAD_fast_net/sys/net/rtsock.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/rtsock.c Sat Jan 10 04:42:53 2009 (r187004) +++ user/kmacy/HEAD_fast_net/sys/net/rtsock.c Sat Jan 10 04:49:55 2009 (r187005) @@ -785,7 +785,8 @@ static void rt_setmetrics(u_long which, const struct rt_metrics *in, struct rt_metrics_lite *out) { -#define metric(f, e) if (which & (f)) out->e = in->e; +#define metric(f, e) if (which & (f)) { printf("setting 0x%x", f); out->e = in->e; } + /* * Only these are stored in the routing entry since introduction * of tcp hostcache. The rest is ignored. @@ -805,6 +806,7 @@ rt_getmetrics(const struct rt_metrics_li #define metric(e) out->e = in->e; bzero(out, sizeof(*out)); metric(rmx_mtu); + metric(rmx_weight); /* Kernel -> userland timebase conversion. */ out->rmx_expire = in->rmx_expire ? in->rmx_expire - time_uptime + time_second : 0; From owner-svn-src-user@FreeBSD.ORG Sat Jan 10 04:59:30 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E5136106566C; Sat, 10 Jan 2009 04:59:30 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D43388FC1D; Sat, 10 Jan 2009 04:59:30 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0A4xUVq080408; Sat, 10 Jan 2009 04:59:30 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0A4xUYa080407; Sat, 10 Jan 2009 04:59:30 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901100459.n0A4xUYa080407@svn.freebsd.org> From: Kip Macy Date: Sat, 10 Jan 2009 04:59:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187006 - user/kmacy/HEAD_fast_net/sbin/route X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 04:59:31 -0000 Author: kmacy Date: Sat Jan 10 04:59:30 2009 New Revision: 187006 URL: http://svn.freebsd.org/changeset/base/187006 Log: try to improve formatting slightly Modified: user/kmacy/HEAD_fast_net/sbin/route/route.c Modified: user/kmacy/HEAD_fast_net/sbin/route/route.c ============================================================================== --- user/kmacy/HEAD_fast_net/sbin/route/route.c Sat Jan 10 04:49:55 2009 (r187005) +++ user/kmacy/HEAD_fast_net/sbin/route/route.c Sat Jan 10 04:59:30 2009 (r187006) @@ -1465,12 +1465,11 @@ print_getmsg(rtm, msglen) #define msec(u) (((u) + 500) / 1000) /* usec to msec */ (void) printf("\n%s\n", "\ - recvpipe sendpipe ssthresh rtt,msec rttvar mtu weight expire"); + recvpipe sendpipe ssthresh rtt,msec mtu weight expire"); printf("%8ld%c ", rtm->rtm_rmx.rmx_recvpipe, lock(RPIPE)); printf("%8ld%c ", rtm->rtm_rmx.rmx_sendpipe, lock(SPIPE)); printf("%8ld%c ", rtm->rtm_rmx.rmx_ssthresh, lock(SSTHRESH)); printf("%8ld%c ", msec(rtm->rtm_rmx.rmx_rtt), lock(RTT)); - printf("%8ld%c ", msec(rtm->rtm_rmx.rmx_rttvar), lock(RTTVAR)); printf("%8ld%c ", rtm->rtm_rmx.rmx_mtu, lock(MTU)); printf("%8ld%c ", rtm->rtm_rmx.rmx_weight, lock(WEIGHT)); if (rtm->rtm_rmx.rmx_expire) From owner-svn-src-user@FreeBSD.ORG Sat Jan 10 05:04:16 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8C8371065672; Sat, 10 Jan 2009 05:04:16 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7B4DD8FC0A; Sat, 10 Jan 2009 05:04:16 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0A54Gql080545; Sat, 10 Jan 2009 05:04:16 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0A54GPQ080543; Sat, 10 Jan 2009 05:04:16 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901100504.n0A54GPQ080543@svn.freebsd.org> From: Kip Macy Date: Sat, 10 Jan 2009 05:04:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187007 - user/kmacy/HEAD_fast_net/sbin/route X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 05:04:17 -0000 Author: kmacy Date: Sat Jan 10 05:04:16 2009 New Revision: 187007 URL: http://svn.freebsd.org/changeset/base/187007 Log: - more output futzing - add show as alias for get Modified: user/kmacy/HEAD_fast_net/sbin/route/keywords user/kmacy/HEAD_fast_net/sbin/route/route.c Modified: user/kmacy/HEAD_fast_net/sbin/route/keywords ============================================================================== --- user/kmacy/HEAD_fast_net/sbin/route/keywords Sat Jan 10 04:59:30 2009 (r187006) +++ user/kmacy/HEAD_fast_net/sbin/route/keywords Sat Jan 10 05:04:16 2009 (r187007) @@ -45,6 +45,7 @@ rtt rttvar sa sendpipe +show shutdown ssthresh static Modified: user/kmacy/HEAD_fast_net/sbin/route/route.c ============================================================================== --- user/kmacy/HEAD_fast_net/sbin/route/route.c Sat Jan 10 04:59:30 2009 (r187006) +++ user/kmacy/HEAD_fast_net/sbin/route/route.c Sat Jan 10 05:04:16 2009 (r187007) @@ -169,6 +169,7 @@ main(argc, argv) if (*argv) switch (keyword(*argv)) { case K_GET: + case K_SHOW: uid = 0; /* FALLTHROUGH */ @@ -1465,7 +1466,7 @@ print_getmsg(rtm, msglen) #define msec(u) (((u) + 500) / 1000) /* usec to msec */ (void) printf("\n%s\n", "\ - recvpipe sendpipe ssthresh rtt,msec mtu weight expire"); + recvpipe sendpipe ssthresh rtt,msec mtu weight expire"); printf("%8ld%c ", rtm->rtm_rmx.rmx_recvpipe, lock(RPIPE)); printf("%8ld%c ", rtm->rtm_rmx.rmx_sendpipe, lock(SPIPE)); printf("%8ld%c ", rtm->rtm_rmx.rmx_ssthresh, lock(SSTHRESH)); From owner-svn-src-user@FreeBSD.ORG Sat Jan 10 05:15:41 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 42DB11065672; Sat, 10 Jan 2009 05:15:41 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 318D98FC1B; Sat, 10 Jan 2009 05:15:41 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0A5FfDZ080785; Sat, 10 Jan 2009 05:15:41 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0A5Ff3m080784; Sat, 10 Jan 2009 05:15:41 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901100515.n0A5Ff3m080784@svn.freebsd.org> From: Kip Macy Date: Sat, 10 Jan 2009 05:15:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187008 - user/kmacy/HEAD_fast_net/sbin/route X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 05:15:41 -0000 Author: kmacy Date: Sat Jan 10 05:15:40 2009 New Revision: 187008 URL: http://svn.freebsd.org/changeset/base/187008 Log: update show handling Modified: user/kmacy/HEAD_fast_net/sbin/route/route.c Modified: user/kmacy/HEAD_fast_net/sbin/route/route.c ============================================================================== --- user/kmacy/HEAD_fast_net/sbin/route/route.c Sat Jan 10 05:04:16 2009 (r187007) +++ user/kmacy/HEAD_fast_net/sbin/route/route.c Sat Jan 10 05:15:40 2009 (r187008) @@ -574,7 +574,7 @@ newroute(argc, argv) errx(EX_NOPERM, "must be root to alter routing table"); } cmd = argv[0]; - if (*cmd != 'g') + if (*cmd != 'g' && cmd != 's') shutdown(s, SHUT_RD); /* Don't want to read back our messages */ while (--argc > 0) { @@ -747,7 +747,7 @@ newroute(argc, argv) } else break; } - if (*cmd == 'g') + if (*cmd == 'g' || *cmd == 's') exit(ret != 0); if (!qflag) { oerrno = errno; @@ -1193,9 +1193,7 @@ rtmsg(cmd, flags) cmd = RTM_ADD; else if (cmd == 'c') cmd = RTM_CHANGE; - else if (cmd == 's') - cmd = RTM_SHUTDOWN; - else if (cmd == 'g') { + else if (cmd == 'g' || cmd == 's') { cmd = RTM_GET; if (so_ifp.sa.sa_family == 0) { so_ifp.sa.sa_family = AF_LINK; From owner-svn-src-user@FreeBSD.ORG Sat Jan 10 05:24:48 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D108106566C; Sat, 10 Jan 2009 05:24:48 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0C2678FC16; Sat, 10 Jan 2009 05:24:48 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0A5OlkQ080982; Sat, 10 Jan 2009 05:24:47 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0A5Ol1K080980; Sat, 10 Jan 2009 05:24:47 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901100524.n0A5Ol1K080980@svn.freebsd.org> From: Kip Macy Date: Sat, 10 Jan 2009 05:24:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187009 - user/kmacy/HEAD_fast_net/sbin/route X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 05:24:48 -0000 Author: kmacy Date: Sat Jan 10 05:24:47 2009 New Revision: 187009 URL: http://svn.freebsd.org/changeset/base/187009 Log: - remove shutdown - update route flags Modified: user/kmacy/HEAD_fast_net/sbin/route/keywords user/kmacy/HEAD_fast_net/sbin/route/route.c Modified: user/kmacy/HEAD_fast_net/sbin/route/keywords ============================================================================== --- user/kmacy/HEAD_fast_net/sbin/route/keywords Sat Jan 10 05:15:40 2009 (r187008) +++ user/kmacy/HEAD_fast_net/sbin/route/keywords Sat Jan 10 05:24:47 2009 (r187009) @@ -46,7 +46,6 @@ rttvar sa sendpipe show -shutdown ssthresh static sticky Modified: user/kmacy/HEAD_fast_net/sbin/route/route.c ============================================================================== --- user/kmacy/HEAD_fast_net/sbin/route/route.c Sat Jan 10 05:15:40 2009 (r187008) +++ user/kmacy/HEAD_fast_net/sbin/route/route.c Sat Jan 10 05:24:47 2009 (r187009) @@ -177,7 +177,6 @@ main(argc, argv) case K_ADD: case K_DEL: case K_DELETE: - case K_SHUTDOWN: newroute(argc, argv); /* NOTREACHED */ @@ -574,7 +573,7 @@ newroute(argc, argv) errx(EX_NOPERM, "must be root to alter routing table"); } cmd = argv[0]; - if (*cmd != 'g' && cmd != 's') + if (*cmd != 'g' && *cmd != 's') shutdown(s, SHUT_RD); /* Don't want to read back our messages */ while (--argc > 0) { @@ -1299,9 +1298,9 @@ char metricnames[] = "\1mtu"; char routeflags[] = "\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE" -"\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016b016" +"\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE" "\017PROTO2\020PROTO1\021PRCLONING\022WASCLONED\023PROTO3" -"\025PINNED\026LOCAL\027BROADCAST\030MULTICAST\035STICKY\036SHUTDOWN"; +"\025PINNED\026LOCAL\027BROADCAST\030MULTICAST\035STICKY"; char ifnetflags[] = "\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6b6\7RUNNING\010NOARP" "\011PPROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1" From owner-svn-src-user@FreeBSD.ORG Sat Jan 10 05:42:53 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BD9B5106566C; Sat, 10 Jan 2009 05:42:53 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 935408FC1A; Sat, 10 Jan 2009 05:42:53 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0A5grKb081345; Sat, 10 Jan 2009 05:42:53 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0A5grKk081343; Sat, 10 Jan 2009 05:42:53 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901100542.n0A5grKk081343@svn.freebsd.org> From: Kip Macy Date: Sat, 10 Jan 2009 05:42:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187010 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 05:42:54 -0000 Author: kmacy Date: Sat Jan 10 05:42:53 2009 New Revision: 187010 URL: http://svn.freebsd.org/changeset/base/187010 Log: fix flag setting in RTM_CHANGE Modified: user/kmacy/HEAD_fast_net/sys/net/route.h user/kmacy/HEAD_fast_net/sys/net/rtsock.c Modified: user/kmacy/HEAD_fast_net/sys/net/route.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/route.h Sat Jan 10 05:24:47 2009 (r187009) +++ user/kmacy/HEAD_fast_net/sys/net/route.h Sat Jan 10 05:42:53 2009 (r187010) @@ -230,7 +230,6 @@ struct rt_msghdr { int rtm_seq; /* for sender to identify action */ int rtm_errno; /* why failed */ int rtm_fmask; /* bitmask used in RTM_CHANGE message */ -#define rtm_use rtm_fmask /* deprecated, use rtm_rmx->rmx_pksent */ u_long rtm_inits; /* which metrics we are initializing */ struct rt_metrics rtm_rmx; /* metrics themselves */ }; Modified: user/kmacy/HEAD_fast_net/sys/net/rtsock.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/rtsock.c Sat Jan 10 05:24:47 2009 (r187009) +++ user/kmacy/HEAD_fast_net/sys/net/rtsock.c Sat Jan 10 05:42:53 2009 (r187010) @@ -655,7 +655,6 @@ route_output(struct mbuf *m, struct sock } (void)rt_msg2(rtm->rtm_type, &info, (caddr_t)rtm, NULL); rtm->rtm_flags = rt->rt_flags; - rtm->rtm_use = 0; rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx); rtm->rtm_addrs = info.rti_addrs; break; @@ -709,10 +708,8 @@ route_output(struct mbuf *m, struct sock rt->rt_ifp = info.rti_ifp; } /* Allow some flags to be toggled on change. */ - if (rtm->rtm_fmask & RTF_FMASK) - rt->rt_flags = (rt->rt_flags & - ~rtm->rtm_fmask) | - (rtm->rtm_flags & rtm->rtm_fmask); + rt->rt_flags = (rt->rt_flags & ~RTF_FMASK) | + (rtm->rtm_flags & RTF_FMASK); rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx, &rt->rt_rmx); rtm->rtm_index = rt->rt_ifp->if_index; @@ -1273,7 +1270,10 @@ sysctl_dumpentry(struct radix_node *rn, struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem; rtm->rtm_flags = rt->rt_flags; - rtm->rtm_use = rt->rt_rmx.rmx_pksent; + /* + * let's be honest about this being a retarded hack + */ + rtm->rtm_fmask = rt->rt_rmx.rmx_pksent; rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx); rtm->rtm_index = rt->rt_ifp->if_index; rtm->rtm_errno = rtm->rtm_pid = rtm->rtm_seq = 0; From owner-svn-src-user@FreeBSD.ORG Sat Jan 10 06:18:27 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38AA6106564A; Sat, 10 Jan 2009 06:18:27 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2806A8FC0C; Sat, 10 Jan 2009 06:18:27 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0A6IRs6082042; Sat, 10 Jan 2009 06:18:27 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0A6IR4L082041; Sat, 10 Jan 2009 06:18:27 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901100618.n0A6IR4L082041@svn.freebsd.org> From: Kip Macy Date: Sat, 10 Jan 2009 06:18:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187011 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 06:18:27 -0000 Author: kmacy Date: Sat Jan 10 06:18:26 2009 New Revision: 187011 URL: http://svn.freebsd.org/changeset/base/187011 Log: add debug cruft to route selection Modified: user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c Modified: user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c Sat Jan 10 05:42:53 2009 (r187010) +++ user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c Sat Jan 10 06:18:26 2009 (r187011) @@ -83,7 +83,6 @@ rn_mpath_count(struct radix_node *rn) uint32_t i = 0; struct rtentry *rt; - i = 1; while ((rn = rn_mpath_next(rn)) != NULL) { rt = (struct rtentry *)rn; if ((rt->rt_flags & RTF_SHUTDOWN) == 0) @@ -259,6 +258,9 @@ different: return 0; } +static int n_prev; +static int lookup_count; + void rtalloc_mpath_fib(struct route *ro, uint32_t hash, u_int fibnum) { @@ -287,15 +289,26 @@ rtalloc_mpath_fib(struct route *ro, uint rn0 = rn = (struct radix_node *)ro->ro_rt; n = rn_mpath_count(rn0); + if (n != n_prev) { + printf("rn_mpath_count=%d\n", n); + n_prev = n; + } + + /* gw selection by Modulo-N Hash (RFC2991) XXX need improvement? */ hash += hashjitter; hash %= n; + if ((lookup_count % 500) == 0) + printf("hash=%d ", hash); while (rn) { rt = (struct rtentry *)rn; if (rt->rt_flags & RTF_SHUTDOWN) continue; total_weight += rt->rt_rmx.rmx_weight; + if ((lookup_count % 500) == 0) + printf("rmx_weight=%ld ", rt->rt_rmx.rmx_weight); + if (total_weight >= hash) break; @@ -304,7 +317,10 @@ rtalloc_mpath_fib(struct route *ro, uint break; rn = rn->rn_dupedkey; } - + if ((lookup_count % 500) == 0) + printf("\n"); + lookup_count++; + /* XXX try filling rt_gwroute and avoid unreachable gw */ /* if gw selection fails, use the first match (default) */ From owner-svn-src-user@FreeBSD.ORG Sat Jan 10 06:36:28 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B9E8106564A; Sat, 10 Jan 2009 06:36:28 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6ACE18FC12; Sat, 10 Jan 2009 06:36:28 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0A6aS8R082452; Sat, 10 Jan 2009 06:36:28 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0A6aS2w082451; Sat, 10 Jan 2009 06:36:28 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901100636.n0A6aS2w082451@svn.freebsd.org> From: Kip Macy Date: Sat, 10 Jan 2009 06:36:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187012 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 06:36:28 -0000 Author: kmacy Date: Sat Jan 10 06:36:28 2009 New Revision: 187012 URL: http://svn.freebsd.org/changeset/base/187012 Log: fix rn_mpath_count and reduce frequency of printing Modified: user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c Modified: user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c Sat Jan 10 06:18:26 2009 (r187011) +++ user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c Sat Jan 10 06:36:28 2009 (r187012) @@ -83,10 +83,12 @@ rn_mpath_count(struct radix_node *rn) uint32_t i = 0; struct rtentry *rt; - while ((rn = rn_mpath_next(rn)) != NULL) { + while (rn != NULL) { + rt = (struct rtentry *)rn; if ((rt->rt_flags & RTF_SHUTDOWN) == 0) i += rt->rt_rmx.rmx_weight; + rn = rn_mpath_next(rn); } return (i); } @@ -298,7 +300,7 @@ rtalloc_mpath_fib(struct route *ro, uint /* gw selection by Modulo-N Hash (RFC2991) XXX need improvement? */ hash += hashjitter; hash %= n; - if ((lookup_count % 500) == 0) + if ((lookup_count % 50000) == 0) printf("hash=%d ", hash); while (rn) { rt = (struct rtentry *)rn; @@ -306,7 +308,7 @@ rtalloc_mpath_fib(struct route *ro, uint continue; total_weight += rt->rt_rmx.rmx_weight; - if ((lookup_count % 500) == 0) + if ((lookup_count % 50000) == 0) printf("rmx_weight=%ld ", rt->rt_rmx.rmx_weight); if (total_weight >= hash) @@ -317,7 +319,7 @@ rtalloc_mpath_fib(struct route *ro, uint break; rn = rn->rn_dupedkey; } - if ((lookup_count % 500) == 0) + if ((lookup_count % 50000) == 0) printf("\n"); lookup_count++; From owner-svn-src-user@FreeBSD.ORG Sat Jan 10 06:55:37 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC532106566B; Sat, 10 Jan 2009 06:55:37 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AAF2C8FC16; Sat, 10 Jan 2009 06:55:37 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0A6tbb6082823; Sat, 10 Jan 2009 06:55:37 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0A6tbqp082822; Sat, 10 Jan 2009 06:55:37 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200901100655.n0A6tbqp082822@svn.freebsd.org> From: Kip Macy Date: Sat, 10 Jan 2009 06:55:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187013 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 06:55:38 -0000 Author: kmacy Date: Sat Jan 10 06:55:37 2009 New Revision: 187013 URL: http://svn.freebsd.org/changeset/base/187013 Log: update loop condition print hash earlier Modified: user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c Modified: user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c Sat Jan 10 06:36:28 2009 (r187012) +++ user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c Sat Jan 10 06:55:37 2009 (r187013) @@ -299,21 +299,19 @@ rtalloc_mpath_fib(struct route *ro, uint /* gw selection by Modulo-N Hash (RFC2991) XXX need improvement? */ hash += hashjitter; - hash %= n; if ((lookup_count % 50000) == 0) - printf("hash=%d ", hash); - while (rn) { + printf("hash=%u n=%d ", hash, n); + hash %= n; + while (total_weight < hash && rn) { rt = (struct rtentry *)rn; if (rt->rt_flags & RTF_SHUTDOWN) continue; total_weight += rt->rt_rmx.rmx_weight; if ((lookup_count % 50000) == 0) - printf("rmx_weight=%ld ", rt->rt_rmx.rmx_weight); + printf("rmx_weight=%ld ", + rt->rt_rmx.rmx_weight); - if (total_weight >= hash) - break; - /* stay within the multipath routes */ if (rn->rn_dupedkey && rn->rn_mask != rn->rn_dupedkey->rn_mask) break;