Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Apr 2012 09:13:36 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r233834 - projects/pf/head/sys/contrib/pf/net
Message-ID:  <201204030913.q339Dafg041431@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Tue Apr  3 09:13:35 2012
New Revision: 233834
URL: http://svn.freebsd.org/changeset/base/233834

Log:
  Anytime I encounter these macros, I look for them
  in the pfvar.h. What's the reason to mask basic
  language syntax?

Modified:
  projects/pf/head/sys/contrib/pf/net/if_pfsync.c
  projects/pf/head/sys/contrib/pf/net/pf.c
  projects/pf/head/sys/contrib/pf/net/pfvar.h

Modified: projects/pf/head/sys/contrib/pf/net/if_pfsync.c
==============================================================================
--- projects/pf/head/sys/contrib/pf/net/if_pfsync.c	Tue Apr  3 09:02:19 2012	(r233833)
+++ projects/pf/head/sys/contrib/pf/net/if_pfsync.c	Tue Apr  3 09:13:35 2012	(r233834)
@@ -538,8 +538,8 @@ pfsync_state_import(struct pfsync_state 
 	r->states_cur++;
 	r->states_tot++;
 
-	if (!ISSET(flags, PFSYNC_SI_IOCTL))
-		SET(st->state_flags, PFSTATE_NOSYNC);
+	if (!(flags & PFSYNC_SI_IOCTL))
+		st->state_flags |= PFSTATE_NOSYNC;
 
 	if ((error = pf_state_insert(kif, skw, sks, st)) != 0) {
 		/* XXX when we have nat_rule/anchors, use STATE_DEC_COUNTERS */
@@ -1469,7 +1469,7 @@ pfsync_out_del(struct pf_state *st, stru
 	dp->id = st->id;
 	dp->creatorid = st->creatorid;
 
-	SET(st->state_flags, PFSTATE_NOSYNC);
+	st->state_flags |= PFSTATE_NOSYNC;
 
 	return (sizeof(*dp));
 }
@@ -1662,13 +1662,13 @@ pfsync_insert_state(struct pf_state *st)
 
 	PF_LOCK_ASSERT();
 
-	if (ISSET(st->rule.ptr->rule_flag, PFRULE_NOSYNC) ||
+	if ((st->rule.ptr->rule_flag & PFRULE_NOSYNC) ||
 	    st->key[PF_SK_WIRE]->proto == IPPROTO_PFSYNC) {
-		SET(st->state_flags, PFSTATE_NOSYNC);
+		st->state_flags |= PFSTATE_NOSYNC;
 		return;
 	}
 
-	if (sc == NULL || ISSET(st->state_flags, PFSTATE_NOSYNC))
+	if (sc == NULL || (st->state_flags & PFSTATE_NOSYNC))
 		return;
 
 	KASSERT(st->sync_state == PFSYNC_S_NONE,
@@ -1705,7 +1705,7 @@ pfsync_defer(struct pf_state *st, struct
 	sc->sc_deferred++;
 
 	m->m_flags |= M_SKIP_FIREWALL;
-	SET(st->state_flags, PFSTATE_ACK);
+	st->state_flags |= PFSTATE_ACK;
 
 	pd->pd_st = st;
 	pd->pd_m = m;
@@ -1729,7 +1729,7 @@ pfsync_undefer(struct pfsync_deferral *p
 	TAILQ_REMOVE(&sc->sc_deferrals, pd, pd_entry);
 	sc->sc_deferred--;
 
-	CLR(pd->pd_st->state_flags, PFSTATE_ACK);
+	pd->pd_st->state_flags &= ~PFSTATE_ACK;
 	pf_release_state(pd->pd_st);
 	callout_stop(&pd->pd_tmo); /* bah */
 	if (drop)
@@ -1788,9 +1788,9 @@ pfsync_update_state(struct pf_state *st)
 	if (sc == NULL)
 		return;
 
-	if (ISSET(st->state_flags, PFSTATE_ACK))
+	if (st->state_flags & PFSTATE_ACK)
 		pfsync_deferred(st, 0);
-	if (ISSET(st->state_flags, PFSTATE_NOSYNC)) {
+	if (st->state_flags & PFSTATE_NOSYNC) {
 		if (st->sync_state != PFSYNC_S_NONE)
 			pfsync_q_del(st);
 		return;
@@ -1879,7 +1879,7 @@ pfsync_update_state_req(struct pf_state 
 
 	KASSERT(sc != NULL, ("%s: nonexistent instance", __func__));
 
-	if (ISSET(st->state_flags, PFSTATE_NOSYNC)) {
+	if (st->state_flags & PFSTATE_NOSYNC) {
 		if (st->sync_state != PFSYNC_S_NONE)
 			pfsync_q_del(st);
 		return;
@@ -1916,9 +1916,9 @@ pfsync_delete_state(struct pf_state *st)
 	if (sc == NULL)
 		return;
 
-	if (ISSET(st->state_flags, PFSTATE_ACK))
+	if (st->state_flags & PFSTATE_ACK)
 		pfsync_deferred(st, 1);
-	if (ISSET(st->state_flags, PFSTATE_NOSYNC)) {
+	if (st->state_flags & PFSTATE_NOSYNC) {
 		if (st->sync_state != PFSYNC_S_NONE)
 			pfsync_q_del(st);
 		return;
@@ -2176,7 +2176,7 @@ pfsync_up(void)
 {
 	struct pfsync_softc *sc = V_pfsyncif;
 
-	if (sc == NULL || !ISSET(sc->sc_ifp->if_flags, IFF_DRV_RUNNING))
+	if (sc == NULL || !(sc->sc_ifp->if_flags & IFF_DRV_RUNNING))
 		return (0);
 
 	return (1);

Modified: projects/pf/head/sys/contrib/pf/net/pf.c
==============================================================================
--- projects/pf/head/sys/contrib/pf/net/pf.c	Tue Apr  3 09:02:19 2012	(r233833)
+++ projects/pf/head/sys/contrib/pf/net/pf.c	Tue Apr  3 09:13:35 2012	(r233834)
@@ -3184,7 +3184,7 @@ pf_test_rule(struct pf_rule **rm, struct
 	if (rewrite)
 		m_copyback(m, off, hdrlen, pd->hdr.any);
 
-	if (*sm != NULL && !ISSET((*sm)->state_flags, PFSTATE_NOSYNC) &&
+	if (*sm != NULL && !((*sm)->state_flags & PFSTATE_NOSYNC) &&
 	    direction == PF_OUT && pfsync_up_ptr != NULL && pfsync_up_ptr()) {
 		/*
 		 * We want the state created, but we dont

Modified: projects/pf/head/sys/contrib/pf/net/pfvar.h
==============================================================================
--- projects/pf/head/sys/contrib/pf/net/pfvar.h	Tue Apr  3 09:02:19 2012	(r233833)
+++ projects/pf/head/sys/contrib/pf/net/pfvar.h	Tue Apr  3 09:13:35 2012	(r233834)
@@ -937,11 +937,6 @@ VNET_DECLARE(int, debug_pfugidhack);
 #define	V_debug_pfugidhack	VNET(debug_pfugidhack)
 
 #define	V_pf_end_threads	VNET(pf_end_threads)
-
-/* Macros to set/clear/test flags. */
-#define	SET(t, f)	((t) |= (f))
-#define	CLR(t, f)	((t) &= ~(f))
-#define	ISSET(t, f)	((t) & (f))
 #endif /* _KERNEL */
 
 #define	PFSYNC_FLAG_SRCNODE	0x04



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204030913.q339Dafg041431>