aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/pf
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2011-12-20 13:53:31 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2011-12-20 13:53:31 +0000
commitf08535f8727db100757115023ae19d0bc1eac194 (patch)
tree5763c925081c47070f96599b2dbbbeee072455c2 /sys/contrib/pf
parent73889c808a4d1867f75a87d7e8d78e66120356e8 (diff)
Notes
Diffstat (limited to 'sys/contrib/pf')
-rw-r--r--sys/contrib/pf/net/if_pfsync.c66
1 files changed, 27 insertions, 39 deletions
diff --git a/sys/contrib/pf/net/if_pfsync.c b/sys/contrib/pf/net/if_pfsync.c
index a8e5fa98ee642..8614c0048f6ca 100644
--- a/sys/contrib/pf/net/if_pfsync.c
+++ b/sys/contrib/pf/net/if_pfsync.c
@@ -62,12 +62,6 @@ __FBSDID("$FreeBSD$");
#else
#define NPFSYNC 0
#endif
-
-#ifdef DEV_CARP
-#define NCARP DEV_CARP
-#else
-#define NCARP 0
-#endif
#endif /* __FreeBSD__ */
#include <sys/param.h>
@@ -127,12 +121,14 @@ __FBSDID("$FreeBSD$");
#include <netinet6/nd6.h>
#endif /* INET6 */
-#ifndef __FreeBSD__
+#ifdef __FreeBSD__
+#include <netinet/ip_carp.h>
+#else
#include "carp.h"
-#endif
#if NCARP > 0
#include <netinet/ip_carp.h>
#endif
+#endif
#include <net/pfvar.h>
#include <net/if_pfsync.h>
@@ -308,11 +304,15 @@ static VNET_DEFINE(struct pfsync_softc *, pfsyncif) = NULL;
static VNET_DEFINE(struct pfsyncstats, pfsyncstats);
#define V_pfsyncstats VNET(pfsyncstats)
+static VNET_DEFINE(int, pfsync_carp_adj) = CARP_MAXSKEW;
+#define V_pfsync_carp_adj VNET(pfsync_carp_adj)
SYSCTL_NODE(_net, OID_AUTO, pfsync, CTLFLAG_RW, 0, "PFSYNC");
SYSCTL_VNET_STRUCT(_net_pfsync, OID_AUTO, stats, CTLFLAG_RW,
&VNET_NAME(pfsyncstats), pfsyncstats,
"PFSYNC statistics (struct pfsyncstats, net/if_pfsync.h)");
+SYSCTL_INT(_net_pfsync, OID_AUTO, carp_demotion_factor, CTLFLAG_RW,
+ &VNET_NAME(pfsync_carp_adj), 0, "pfsync's CARP demotion factor adjustment");
#else
struct pfsync_softc *pfsyncif = NULL;
struct pfsyncstats pfsyncstats;
@@ -505,11 +505,11 @@ pfsync_clone_create(struct if_clone *ifc, int unit)
if_attach(ifp);
#ifndef __FreeBSD__
if_alloc_sadl(ifp);
-#endif
#if NCARP > 0
if_addgroup(ifp, "carp");
#endif
+#endif
#if NBPFILTER > 0
#ifdef __FreeBSD__
@@ -545,14 +545,11 @@ pfsync_clone_destroy(struct ifnet *ifp)
timeout_del(&sc->sc_tmo);
#ifdef __FreeBSD__
PF_UNLOCK();
-#endif
-#if NCARP > 0
-#ifdef notyet
-#ifdef __FreeBSD__
- if (!sc->pfsync_sync_ok)
+ if (!sc->pfsync_sync_ok && carp_demote_adj_p)
+ (*carp_demote_adj_p)(-V_pfsync_carp_adj, "pfsync destroy");
#else
+#if NCARP > 0
if (!pfsync_sync_ok)
-#endif
carp_group_demote_adj(&sc->sc_if, -1);
#endif
#endif
@@ -1636,19 +1633,16 @@ pfsync_in_bus(struct pfsync_pkt *pkt, struct mbuf *m, int offset, int count)
sc->sc_ureq_sent = 0;
sc->sc_bulk_tries = 0;
timeout_del(&sc->sc_bulkfail_tmo);
-#if NCARP > 0
-#ifdef notyet
#ifdef __FreeBSD__
- if (!sc->pfsync_sync_ok)
+ if (!sc->pfsync_sync_ok && carp_demote_adj_p)
+ (*carp_demote_adj_p)(-V_pfsync_carp_adj,
+ "pfsync bulk done");
+ sc->pfsync_sync_ok = 1;
#else
+#if NCARP > 0
if (!pfsync_sync_ok)
-#endif
carp_group_demote_adj(&sc->sc_if, -1);
#endif
-#endif
-#ifdef __FreeBSD__
- sc->pfsync_sync_ok = 1;
-#else
pfsync_sync_ok = 1;
#endif
#ifdef __FreeBSD__
@@ -1988,19 +1982,16 @@ pfsyncioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
if (sc->sc_sync_if) {
/* Request a full state table update. */
sc->sc_ureq_sent = time_uptime;
-#if NCARP > 0
-#ifdef notyet
#ifdef __FreeBSD__
- if (sc->pfsync_sync_ok)
+ if (sc->pfsync_sync_ok && carp_demote_adj_p)
+ (*carp_demote_adj_p)(V_pfsync_carp_adj,
+ "pfsync bulk start");
+ sc->pfsync_sync_ok = 0;
#else
+#if NCARP > 0
if (pfsync_sync_ok)
-#endif
carp_group_demote_adj(&sc->sc_if, 1);
#endif
-#endif
-#ifdef __FreeBSD__
- sc->pfsync_sync_ok = 0;
-#else
pfsync_sync_ok = 0;
#endif
#ifdef __FreeBSD__
@@ -3159,19 +3150,16 @@ pfsync_bulk_fail(void *arg)
/* Pretend like the transfer was ok */
sc->sc_ureq_sent = 0;
sc->sc_bulk_tries = 0;
-#if NCARP > 0
-#ifdef notyet
#ifdef __FreeBSD__
- if (!sc->pfsync_sync_ok)
+ if (!sc->pfsync_sync_ok && carp_demote_adj_p)
+ (*carp_demote_adj_p)(-V_pfsync_carp_adj,
+ "pfsync bulk fail");
+ sc->pfsync_sync_ok = 1;
#else
+#if NCARP > 0
if (!pfsync_sync_ok)
-#endif
carp_group_demote_adj(&sc->sc_if, -1);
#endif
-#endif
-#ifdef __FreeBSD__
- sc->pfsync_sync_ok = 1;
-#else
pfsync_sync_ok = 1;
#endif
#ifdef __FreeBSD__