From owner-svn-src-user@FreeBSD.ORG Thu Oct 15 11:12: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 08BF51065672; Thu, 15 Oct 2009 11:12:54 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EBC568FC1D; Thu, 15 Oct 2009 11:12:53 +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 n9FBCraH071786; Thu, 15 Oct 2009 11:12:53 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9FBCrwv071781; Thu, 15 Oct 2009 11:12:53 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910151112.n9FBCrwv071781@svn.freebsd.org> From: Ermal Luçi Date: Thu, 15 Oct 2009 11:12: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: r198124 - user/eri/pf45/head/sys/contrib/pf/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: Thu, 15 Oct 2009 11:12:54 -0000 Author: eri Date: Thu Oct 15 11:12:53 2009 New Revision: 198124 URL: http://svn.freebsd.org/changeset/base/198124 Log: More V_ foo. NOTE: With this commit a GENERIC VIMAGE kernel builds. Modified: user/eri/pf45/head/sys/contrib/pf/net/pf.c user/eri/pf45/head/sys/contrib/pf/net/pf_if.c user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c user/eri/pf45/head/sys/contrib/pf/net/pf_ruleset.c Modified: user/eri/pf45/head/sys/contrib/pf/net/pf.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf.c Thu Oct 15 10:49:24 2009 (r198123) +++ user/eri/pf45/head/sys/contrib/pf/net/pf.c Thu Oct 15 11:12:53 2009 (r198124) @@ -3204,7 +3204,11 @@ pf_calc_mss(struct pf_addr *addr, sa_fam if (rt && rt->rt_ifp) { mss = rt->rt_ifp->if_mtu - hlen - sizeof(struct tcphdr); +#ifdef __FreeBSD__ + mss = max(V_tcp_mssdflt, mss); +#else mss = max(tcp_mssdflt, mss); +#endif RTFREE(rt); } mss = min(mss, offer); Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_if.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf_if.c Thu Oct 15 10:49:24 2009 (r198123) +++ user/eri/pf45/head/sys/contrib/pf/net/pf_if.c Thu Oct 15 11:12:53 2009 (r198124) @@ -149,7 +149,7 @@ pfi_initialize(void) #endif #ifdef __FreeBSD__ V_pfi_buffer_max = 64; - V_pfi_buffer = malloc(V_pfi_buffer_max * sizeof(*pfi_buffer), + V_pfi_buffer = malloc(V_pfi_buffer_max * sizeof(*V_pfi_buffer), PFI_MTYPE, M_WAITOK); if ((V_pfi_all = pfi_kif_get(IFG_ALL)) == NULL) @@ -745,7 +745,7 @@ pfi_address_add(struct sockaddr *sa, int #endif return; } - p = malloc(new_max * sizeof(*pfi_buffer), PFI_MTYPE, + p = malloc(new_max * sizeof(*V_pfi_buffer), PFI_MTYPE, #ifdef __FreeBSD__ M_NOWAIT); #else @@ -761,7 +761,7 @@ pfi_address_add(struct sockaddr *sa, int return; } #ifdef __FreeBSD__ - memcpy(V_pfi_buffer, p, V_pfi_buffer_cnt * sizeof(*pfi_buffer)); + memcpy(V_pfi_buffer, p, V_pfi_buffer_cnt * sizeof(*V_pfi_buffer)); /* no need to zero buffer */ free(V_pfi_buffer, PFI_MTYPE); V_pfi_buffer = p; Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Thu Oct 15 10:49:24 2009 (r198123) +++ user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Thu Oct 15 11:12:53 2009 (r198124) @@ -39,6 +39,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_global.h" #include "opt_inet.h" #include "opt_inet6.h" #include "opt_bpf.h" @@ -178,21 +179,30 @@ void pf_addr_copyout(struct pf_addr_w #ifdef __FreeBSD__ VNET_DEFINE(struct pf_rule, pf_default_rule); VNET_DEFINE(struct sx, pf_consistency_lock); +#ifndef VIMAGE SX_SYSINIT(pf_consistency_lock, &V_pf_consistency_lock, "pf_statetbl_lock"); +#endif #ifdef ALTQ -static VNET_DEFINE(int, pf_altq_running); -#define pf_altq_running VNET(pf_altq_running) +static VNET_DEFINE(int, pf_altq_running); +#define V_pf_altq_running VNET(pf_altq_running) #endif TAILQ_HEAD(pf_tags, pf_tagname); +#ifdef VIMAGE +#define V_pf_tags VNET(pf_tags) +VNET_DEFINE(struct pf_tags, pf_tags); +#define V_pf_qids VNET(pf_qids) +VNET_DEFINE(struct pf_tags, pf_qids); +#else #define V_pf_tags VNET(pf_tags) VNET_DEFINE(struct pf_tags, pf_tags) = TAILQ_HEAD_INITIALIZER(V_pf_tags); +#define V_pf_qids VNET(pf_qids) VNET_DEFINE(struct pf_tags, pf_qids) = - TAILQ_HEAD_INITIALIZER(pf_qids); -#define pf_qids VNET(pf_qids) + TAILQ_HEAD_INITIALIZER(V_pf_qids); +#endif #else /* !__FreeBSD__ */ struct pf_rule pf_default_rule; @@ -223,7 +233,7 @@ void pf_rtlabel_copyout(struct pf_add #endif #ifdef __FreeBSD__ -static VNET_DEFINE(struct cdev, *pf_dev); +static struct cdev *pf_dev; /* * XXX - These are new and need to be checked when moveing to a new version @@ -283,7 +293,7 @@ pflog_packet_t *pflog_packet_ptr = NUL VNET_DEFINE(int, debug_pfugidhack); SYSCTL_VNET_INT(_debug, OID_AUTO, pfugidhack, CTLFLAG_RW, - &V_debug_pfugidhack, 0, + &VNET_NAME(debug_pfugidhack), 0, "Enable/disable pf user/group rules mpsafe hack"); void @@ -419,7 +429,7 @@ pfattach(void) pf_normalize_init(); - bzero(&V_pf_status, sizeof(pf_status)); + bzero(&V_pf_status, sizeof(V_pf_status)); V_pf_status.debug = PF_DEBUG_URGENT; V_pf_pfil_hooked = 0; @@ -833,19 +843,31 @@ pf_rtlabel_copyout(struct pf_addr_wrap * u_int32_t pf_qname2qid(char *qname) { +#ifdef __FreeBSD__ + return ((u_int32_t)tagname2tag(&V_pf_qids, qname)); +#else return ((u_int32_t)tagname2tag(&pf_qids, qname)); +#endif } void pf_qid2qname(u_int32_t qid, char *p) { +#ifdef __FreeBSD__ + tag2tagname(&V_pf_qids, (u_int16_t)qid, p); +#else tag2tagname(&pf_qids, (u_int16_t)qid, p); +#endif } void pf_qid_unref(u_int32_t qid) { +#ifdef __FreeBSD__ + tag_unref(&V_pf_qids, (u_int16_t)qid); +#else tag_unref(&pf_qids, (u_int16_t)qid); +#endif } int @@ -962,7 +984,11 @@ pf_commit_altq(u_int32_t ticket) #endif /* attach the discipline */ error = altq_pfattach(altq); +#ifdef __FreeBSD__ + if (error == 0 && V_pf_altq_running) +#else if (error == 0 && pf_altq_running) +#endif error = pf_enable_altq(altq); if (error != 0) { splx(s); @@ -983,7 +1009,11 @@ pf_commit_altq(u_int32_t ticket) if (altq->qname[0] == 0) { #endif /* detach and destroy the discipline */ +#ifdef __FreeBSD__ + if (V_pf_altq_running) +#else if (pf_altq_running) +#endif error = pf_disable_altq(altq); err = altq_pfdetach(altq); if (err != 0 && error == 0) @@ -2611,7 +2641,11 @@ pfioctl(dev_t dev, u_long cmd, caddr_t a } } if (error == 0) +#ifdef __FreeBSD__ + V_pf_altq_running = 1; +#else pf_altq_running = 1; +#endif DPFPRINTF(PF_DEBUG_MISC, ("altq: started\n")); break; } @@ -2634,7 +2668,11 @@ pfioctl(dev_t dev, u_long cmd, caddr_t a } } if (error == 0) +#ifdef __FreeBSD__ + V_pf_altq_running = 0; +#else pf_altq_running = 0; +#endif DPFPRINTF(PF_DEBUG_MISC, ("altq: stopped\n")); break; } @@ -3098,7 +3136,11 @@ pfioctl(dev_t dev, u_long cmd, caddr_t a pr->nr = 0; if (ruleset->anchor == NULL) { /* XXX kludge for pf_main_ruleset */ +#ifdef __FreeBSD__ + RB_FOREACH(anchor, pf_anchor_global, &V_pf_anchors) +#else RB_FOREACH(anchor, pf_anchor_global, &pf_anchors) +#endif if (anchor->parent == NULL) pr->nr++; } else { @@ -3123,7 +3165,11 @@ pfioctl(dev_t dev, u_long cmd, caddr_t a pr->name[0] = 0; if (ruleset->anchor == NULL) { /* XXX kludge for pf_main_ruleset */ +#ifdef __FreeBSD__ + RB_FOREACH(anchor, pf_anchor_global, &V_pf_anchors) +#else RB_FOREACH(anchor, pf_anchor_global, &pf_anchors) +#endif if (anchor->parent == NULL && nr++ == pr->nr) { strlcpy(pr->name, anchor->name, sizeof(pr->name)); @@ -4261,6 +4307,9 @@ vnet_pf_init(const void *unused) V_debug_pfugidhack = 0; + TAILQ_INIT(&V_pf_tags); + TAILQ_INIT(&V_pf_qids); + return (0); } @@ -4293,6 +4342,9 @@ static int pf_load(void) { init_zone_var(); +#ifdef VIMAGE + sx_init(&V_pf_consistency_lock, "pf_statetbl_lock"); +#endif init_pf_mutex(); pf_dev = make_dev(&pf_cdevsw, 0, 0, 0, 0600, PF_NAME); if (pfattach() < 0) { @@ -4335,6 +4387,9 @@ pf_unload(void) PF_UNLOCK(); destroy_dev(pf_dev); destroy_pf_mutex(); +#ifdef VIMAGE + sx_destroy(&V_pf_consistency_lock); +#endif return error; } Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_ruleset.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf_ruleset.c Thu Oct 15 10:49:24 2009 (r198123) +++ user/eri/pf45/head/sys/contrib/pf/net/pf_ruleset.c Thu Oct 15 11:12:53 2009 (r198124) @@ -171,7 +171,11 @@ pf_find_anchor(const char *path) if (key == NULL) return (NULL); strlcpy(key->path, path, sizeof(key->path)); +#ifdef __FreeBSD__ + found = RB_FIND(pf_anchor_global, &V_pf_anchors, key); +#else found = RB_FIND(pf_anchor_global, &pf_anchors, key); +#endif rs_free(key); return (found); } @@ -252,7 +256,11 @@ pf_find_or_create_ruleset(const char *pa strlcat(anchor->path, "/", sizeof(anchor->path)); } strlcat(anchor->path, anchor->name, sizeof(anchor->path)); +#ifdef __FreeBSD__ + if ((dup = RB_INSERT(pf_anchor_global, &V_pf_anchors, anchor)) != +#else if ((dup = RB_INSERT(pf_anchor_global, &pf_anchors, anchor)) != +#endif NULL) { printf("pf_find_or_create_ruleset: RB_INSERT1 " "'%s' '%s' collides with '%s' '%s'\n", @@ -269,7 +277,11 @@ pf_find_or_create_ruleset(const char *pa "RB_INSERT2 '%s' '%s' collides with " "'%s' '%s'\n", anchor->path, anchor->name, dup->path, dup->name); +#ifdef __FreeBSD__ + RB_REMOVE(pf_anchor_global, &V_pf_anchors, +#else RB_REMOVE(pf_anchor_global, &pf_anchors, +#endif anchor); rs_free(anchor); rs_free(p); @@ -305,7 +317,11 @@ pf_remove_if_empty_ruleset(struct pf_rul !TAILQ_EMPTY(ruleset->rules[i].inactive.ptr) || ruleset->rules[i].inactive.open) return; +#ifdef __FreeBSD__ + RB_REMOVE(pf_anchor_global, &V_pf_anchors, ruleset->anchor); +#else RB_REMOVE(pf_anchor_global, &pf_anchors, ruleset->anchor); +#endif if ((parent = ruleset->anchor->parent) != NULL) RB_REMOVE(pf_anchor_node, &parent->children, ruleset->anchor);