From owner-svn-src-all@FreeBSD.ORG Sat Sep 29 20:02:26 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A19D5106566B; Sat, 29 Sep 2012 20:02:26 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8B17E8FC0A; Sat, 29 Sep 2012 20:02:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q8TK2Q40085158; Sat, 29 Sep 2012 20:02:26 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q8TK2QE8085156; Sat, 29 Sep 2012 20:02:26 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201209292002.q8TK2QE8085156@svn.freebsd.org> From: Gleb Smirnoff Date: Sat, 29 Sep 2012 20:02:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r241056 - head/sys/netpfil/pf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Sep 2012 20:02:26 -0000 Author: glebius Date: Sat Sep 29 20:02:26 2012 New Revision: 241056 URL: http://svn.freebsd.org/changeset/base/241056 Log: Simplify send out queue code: - Write method of a queue now is void,length of item is taken as queue property. - Write methods don't need to know about mbud, supply just buf to them. - No need for safe queue iterator in pfsync_sendout(). Obtained from: OpenBSD Modified: head/sys/netpfil/pf/if_pfsync.c Modified: head/sys/netpfil/pf/if_pfsync.c ============================================================================== --- head/sys/netpfil/pf/if_pfsync.c Sat Sep 29 19:09:11 2012 (r241055) +++ head/sys/netpfil/pf/if_pfsync.c Sat Sep 29 20:02:26 2012 (r241056) @@ -137,16 +137,16 @@ static int (*pfsync_acts[])(struct pfsyn }; struct pfsync_q { - int (*write)(struct pf_state *, struct mbuf *, int); + void (*write)(struct pf_state *, void *); size_t len; u_int8_t action; }; /* we have one of these for every PFSYNC_S_ */ -static int pfsync_out_state(struct pf_state *, struct mbuf *, int); -static int pfsync_out_iack(struct pf_state *, struct mbuf *, int); -static int pfsync_out_upd_c(struct pf_state *, struct mbuf *, int); -static int pfsync_out_del(struct pf_state *, struct mbuf *, int); +static void pfsync_out_state(struct pf_state *, void *); +static void pfsync_out_iack(struct pf_state *, void *); +static void pfsync_out_upd_c(struct pf_state *, void *); +static void pfsync_out_del(struct pf_state *, void *); static struct pfsync_q pfsync_qs[] = { { pfsync_out_state, sizeof(struct pfsync_state), PFSYNC_ACT_INS }, @@ -1408,32 +1408,27 @@ pfsyncioctl(struct ifnet *ifp, u_long cm return (0); } -static int -pfsync_out_state(struct pf_state *st, struct mbuf *m, int offset) +static void +pfsync_out_state(struct pf_state *st, void *buf) { - struct pfsync_state *sp = (struct pfsync_state *)(m->m_data + offset); + struct pfsync_state *sp = buf; pfsync_state_export(sp, st); - - return (sizeof(*sp)); } -static int -pfsync_out_iack(struct pf_state *st, struct mbuf *m, int offset) +static void +pfsync_out_iack(struct pf_state *st, void *buf) { - struct pfsync_ins_ack *iack = - (struct pfsync_ins_ack *)(m->m_data + offset); + struct pfsync_ins_ack *iack = buf; iack->id = st->id; iack->creatorid = st->creatorid; - - return (sizeof(*iack)); } -static int -pfsync_out_upd_c(struct pf_state *st, struct mbuf *m, int offset) +static void +pfsync_out_upd_c(struct pf_state *st, void *buf) { - struct pfsync_upd_c *up = (struct pfsync_upd_c *)(m->m_data + offset); + struct pfsync_upd_c *up = buf; bzero(up, sizeof(*up)); up->id = st->id; @@ -1441,21 +1436,16 @@ pfsync_out_upd_c(struct pf_state *st, st pf_state_peer_hton(&st->dst, &up->dst); up->creatorid = st->creatorid; up->timeout = st->timeout; - - return (sizeof(*up)); } -static int -pfsync_out_del(struct pf_state *st, struct mbuf *m, int offset) +static void +pfsync_out_del(struct pf_state *st, void *buf) { - struct pfsync_del_c *dp = (struct pfsync_del_c *)(m->m_data + offset); + struct pfsync_del_c *dp = buf; dp->id = st->id; dp->creatorid = st->creatorid; - st->state_flags |= PFSTATE_NOSYNC; - - return (sizeof(*dp)); } static void @@ -1497,7 +1487,7 @@ pfsync_sendout(int schedswi) struct ip *ip; struct pfsync_header *ph; struct pfsync_subheader *subh; - struct pf_state *st, *next; + struct pf_state *st; struct pfsync_upd_req_item *ur; int offset; int q, count = 0; @@ -1547,7 +1537,7 @@ pfsync_sendout(int schedswi) offset += sizeof(*subh); count = 0; - TAILQ_FOREACH_SAFE(st, &sc->sc_qs[q], sync_list, next) { + TAILQ_FOREACH(st, &sc->sc_qs[q], sync_list) { KASSERT(st->sync_state == q, ("%s: st->sync_state == q", __func__)); @@ -1555,7 +1545,8 @@ pfsync_sendout(int schedswi) * XXXGL: some of write methods do unlocked reads * of state data :( */ - offset += pfsync_qs[q].write(st, m, offset); + pfsync_qs[q].write(st, m->m_data + offset); + offset += pfsync_qs[q].len; st->sync_state = PFSYNC_S_NONE; pf_release_state(st); count++;