From owner-svn-src-user@FreeBSD.ORG Fri Jan 8 22:31:43 2010 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 F2EC01065672; Fri, 8 Jan 2010 22:31:42 +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 E271F8FC1B; Fri, 8 Jan 2010 22:31:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o08MVgVE011387; Fri, 8 Jan 2010 22:31:42 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o08MVgvg011385; Fri, 8 Jan 2010 22:31:42 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201001082231.o08MVgvg011385@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 8 Jan 2010 22:31:42 +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: r201842 - user/luigi/ipfw3-head/sbin/ipfw 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, 08 Jan 2010 22:31:43 -0000 Author: luigi Date: Fri Jan 8 22:31:42 2010 New Revision: 201842 URL: http://svn.freebsd.org/changeset/base/201842 Log: pass parameters for profile Modified: user/luigi/ipfw3-head/sbin/ipfw/dummynet.c Modified: user/luigi/ipfw3-head/sbin/ipfw/dummynet.c ============================================================================== --- user/luigi/ipfw3-head/sbin/ipfw/dummynet.c Fri Jan 8 22:28:54 2010 (r201841) +++ user/luigi/ipfw3-head/sbin/ipfw/dummynet.c Fri Jan 8 22:31:42 2010 (r201842) @@ -570,10 +570,8 @@ compare_points(const void *vp1, const vo #define ED_EFMT(s) EX_DATAERR,"error in %s at line %d: "#s,filename,lineno -void -load_extra_delays(const char *filename, struct dn_pipe *p); -void -load_extra_delays(const char *filename, struct dn_pipe *p) +static void +load_extra_delays(const char *filename, struct new_profile *p) { char line[ED_MAX_LINE_LEN]; FILE *f; @@ -628,7 +626,8 @@ load_extra_delays(const char *filename, ED_MAX_SAMPLES_NO); do_points = 0; } else if (!strcasecmp(name, ED_TOK_BW)) { - read_bandwidth(arg, &p->bandwidth, p->if_name, sizeof(p->if_name)); + char buf[IFNAMSIZ]; + read_bandwidth(arg, &p->bandwidth, buf, sizeof(buf)); } else if (!strcasecmp(name, ED_TOK_LOSS)) { if (loss != -1.0) errx(ED_EFMT("duplicated token: %s"), name); @@ -734,13 +733,12 @@ ipfw_config_pipe(int ac, char **av) struct new_pipe *p = NULL; struct new_fs *fs = NULL; struct new_profile *pf = NULL; + struct new_cmd *cmd = NULL; struct ipfw_flow_id *mask = NULL; - int lmax = sizeof(*sch) + sizeof(*p) + sizeof(*fs) + sizeof(*pf); + int lmax = sizeof(*cmd); /* always present */ - base = buf = calloc(1, lmax); - if (buf == NULL) { - errx(1, "no memory for pipe buffer"); - } + /* worst case: 2 schedulers, 1 profile, 1 pipe, 1 flowset */ + lmax += 2*sizeof(*sch) + sizeof(*p) + sizeof(*fs) + sizeof(*pf); av++; ac--; /* Pipe number */ @@ -749,12 +747,19 @@ ipfw_config_pipe(int ac, char **av) } if (i <= 0) errx(EX_USAGE, "need a pipe/flowset/sched number"); + base = buf = calloc(1, lmax); + if (buf == NULL) { + errx(1, "no memory for pipe buffer"); + } + cmd = o_next(&buf, sizeof(*cmd), DN_CMD_CONFIGURE); + cmd->entries = 0; /* no explicit arguments */ + switch (co.do_pipe) { case 1: sch = o_next(&buf, sizeof(*sch), DN_SCH); p = o_next(&buf, sizeof(*p), DN_PIPE); fs = o_next(&buf, sizeof(*fs), DN_FS); - mask = &sch->sched_mask; // XXX or both ? + mask = &sch->sched_mask; sch->pipe_nr = p->pipe_nr = i; fs->fs_nr = i + DN_PIPEOFFSET; fs->sched_nr = sch->sched_nr = i + DN_PIPEOFFSET; @@ -769,7 +774,7 @@ ipfw_config_pipe(int ac, char **av) case 3: /* scheduler */ sch = o_next(&buf, sizeof(*sch), DN_SCH); sch->sched_nr = i; - mask = &sch->sched_mask; // XXX or both ? + mask = &sch->sched_mask; break; } @@ -1001,22 +1006,17 @@ end_mask: ac--; av++; break; -#if 0 case TOK_PIPE_PROFILE: NEED((!pf), "profile already set"); NEED(p, "profile"); { - pf = o_next(&buf, sizeof(*pf)); - int samples[ED_MAX_SAMPLES_NO]; - if (co.do_pipe != 1) - errx(EX_DATAERR, "extra delay only valid for pipes"); + pf = o_next(&buf, sizeof(*pf), DN_PROFILE); NEED1("extra delay needs the file name\n"); - p.samples = &samples[0]; - load_extra_delays(av[0], &p); + load_extra_delays(av[0], pf); --ac; ++av; } break; -#endif + case TOK_BURST: NEED(p, "burst"); NEED1("burst needs argument\n");