From owner-p4-projects@FreeBSD.ORG Sat Jun 24 07:42:25 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7B2B516A4C2; Sat, 24 Jun 2006 07:42:25 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3D7DF16A4A0 for ; Sat, 24 Jun 2006 07:42:25 +0000 (UTC) (envelope-from als@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id BF74D43D49 for ; Sat, 24 Jun 2006 07:42:24 +0000 (GMT) (envelope-from als@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k5O7gOx9015174 for ; Sat, 24 Jun 2006 07:42:24 GMT (envelope-from als@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5O7gOMp015171 for perforce@freebsd.org; Sat, 24 Jun 2006 07:42:24 GMT (envelope-from als@FreeBSD.org) Date: Sat, 24 Jun 2006 07:42:24 GMT Message-Id: <200606240742.k5O7gOMp015171@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to als@FreeBSD.org using -f From: Alex Lyashkov To: Perforce Change Reviews Cc: Subject: PERFORCE change 99917 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Jun 2006 07:42:25 -0000 http://perforce.freebsd.org/chv.cgi?CH=99917 Change 99917 by als@als_head on 2006/06/24 07:41:46 Update copyright Affected files ... .. //depot/projects/jail2/sys/kern/kern_jail2_network.c#2 edit Differences ... ==== //depot/projects/jail2/sys/kern/kern_jail2_network.c#2 (text+ko) ==== @@ -1,127 +1,5 @@ /* - * Copyright (c) 2004 Alex Lyashkov - * 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 - -#define jprint(a...) -/* printf(a) */ - -static int -jail_addradd_ipv4(struct prison *_jail, void *_udata) -{ - struct jail2_ipv4addr ja; - int error; - - error = copyin(_udata, &ja, sizeof(ja)); - if (error) - return (error); - - mtx_lock(&_jail->pr_mtx); - _jail->pr_network.pr_ip = htonl(ja.addr); - mtx_unlock(&_jail->pr_mtx); - - return (0); -} - -static int -jail_addrdel_ipv4(struct prison *_jail, void *_udata) -{ - struct jail2_ipv4addr ja; - int error; - - error = copyin(_udata, &ja, sizeof(ja)); - if (error) - return (error); - - mtx_lock(&_jail->pr_mtx); - error = _jail->pr_network.pr_ip == ja.addr ? 0 : ESRCH; - if( error == 0 ) - _jail->pr_network.pr_ip = 0; - mtx_unlock(&_jail->pr_mtx); - - return (0); -} - - -int jail2_network(struct thread *td, struct jail_2 *j) -{ - struct prison *pr; - int ret = 0; - - mtx_lock(&allprison_mtx); - pr = prison_find(j->ctx_id); - mtx_unlock(&allprison_mtx); - - jprint("jail2_network %d ctx: %d pr: %p\n", JAIL2_CMD(j->cmd), j->ctx_id, pr ); - if(pr == NULL) { - printf("Prison not found for command %x\n", j->cmd); - return (ESRCH); - } - - switch(JAIL2_CMD(j->cmd)) { - case J_VNETDEV_CREATE: - case J_VNETDEV_REMOVE: - case J_VNETDEV_ATTACH: - case J_VNETDEV_DETACH: - case J_VNETDEV_SET_TXSPEED: - case J_VNETDEV_SET_FLAGS: - case J_VNETDEV_UNSET_FLAGS: - ret = EOPNOTSUPP; - break; - /* IPV4 control */ - case J_ADDMASKIPV4: - ret = jail_addradd_ipv4(pr,j->data); - break; - case J_RMIPV4: - ret = jail_addrdel_ipv4(pr,j->data); - break; - default: - ret = EOPNOTSUPP; - break; - } - - /* remove refs from find/create */ - prison_free(pr); - jprint("jail2_network return %d\n", ret); - return (ret); -} -/* - * Copyright (c) 2004 Alex Lyashkov + * Copyright (c) 2004-2006 Alex Lyashkov * All rights reserved. * * Redistribution and use in source and binary forms, with or without