PERFORCE change 142754 for review
Vincenzo Iozzo
snagg at FreeBSD.org
Mon Jun 2 13:23:19 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=142754
Change 142754 by snagg at snagg_macosx on 2008/06/02 13:22:21
IFC
Affected files ...
.. //depot/projects/soc2008/snagg-audit/sys/compat/linux/linux_stats.c#2 integrate
.. //depot/projects/soc2008/snagg-audit/sys/compat/linux/linux_util.c#2 integrate
.. //depot/projects/soc2008/snagg-audit/sys/dev/pccard/pccard_cis.c#2 integrate
.. //depot/projects/soc2008/snagg-audit/sys/netgraph/ng_nat.c#2 integrate
.. //depot/projects/soc2008/snagg-audit/sys/netinet/libalias/alias.c#4 integrate
.. //depot/projects/soc2008/snagg-audit/sys/netinet/libalias/alias_db.c#2 integrate
.. //depot/projects/soc2008/snagg-audit/sys/netinet/libalias/alias_local.h#2 integrate
Differences ...
==== //depot/projects/soc2008/snagg-audit/sys/compat/linux/linux_stats.c#2 (text+ko) ====
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/linux/linux_stats.c,v 1.91 2008/04/08 09:45:47 kib Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/linux/linux_stats.c,v 1.92 2008/06/02 08:40:06 ed Exp $");
#include "opt_compat.h"
#include "opt_mac.h"
@@ -178,19 +178,8 @@
#endif
error = kern_stat(td, path, UIO_SYSSPACE, &buf);
- if (!error) {
- if (strlen(path) > strlen("/dev/pts/") &&
- !strncmp(path, "/dev/pts/", strlen("/dev/pts/")) &&
- path[9] >= '0' && path[9] <= '9') {
- /*
- * Linux checks major and minors of the slave device
- * to make sure it's a pty device, so let's make him
- * believe it is.
- */
- buf.st_rdev = (136 << 8);
- } else
- translate_path_major_minor(td, path, &buf);
- }
+ if (!error)
+ translate_path_major_minor(td, path, &buf);
LFREEPATH(path);
if (error)
return (error);
@@ -528,19 +517,8 @@
#endif
error = kern_stat(td, filename, UIO_SYSSPACE, &buf);
- if (!error) {
- if (strlen(filename) > strlen("/dev/pts/") &&
- !strncmp(filename, "/dev/pts/", strlen("/dev/pts/")) &&
- filename[9] >= '0' && filename[9] <= '9') {
- /*
- * Linux checks major and minors of the slave device
- * to make sure it's a pty deivce, so let's make him
- * believe it is.
- */
- buf.st_rdev = (136 << 8);
- } else
- translate_path_major_minor(td, filename, &buf);
- }
+ if (!error)
+ translate_path_major_minor(td, filename, &buf);
LFREEPATH(filename);
if (error)
return (error);
==== //depot/projects/soc2008/snagg-audit/sys/compat/linux/linux_util.c#2 (text+ko) ====
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/linux/linux_util.c,v 1.34 2008/04/08 09:45:47 kib Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/linux/linux_util.c,v 1.35 2008/06/02 08:40:06 ed Exp $");
#include "opt_compat.h"
@@ -130,6 +130,22 @@
if (node == NULL || major == NULL || minor == NULL)
return 1;
+
+ if (strlen(node) > strlen("pts/") &&
+ strncmp(node, "pts/", strlen("pts/")) == 0) {
+ unsigned long devno;
+
+ /*
+ * Linux checks major and minors of the slave device
+ * to make sure it's a pty device, so let's make him
+ * believe it is.
+ */
+ devno = strtoul(node + strlen("pts/"), NULL, 10);
+ *major = 136 + (devno / 256);
+ *minor = devno % 256;
+ return 0;
+ }
+
TAILQ_FOREACH(de, &devices, list) {
if (strcmp(node, de->entry.bsd_device_name) == 0) {
*major = de->entry.linux_major;
==== //depot/projects/soc2008/snagg-audit/sys/dev/pccard/pccard_cis.c#2 (text+ko) ====
@@ -1,5 +1,5 @@
/* $NetBSD: pcmcia_cis.c,v 1.17 2000/02/10 09:01:52 chopps Exp $ */
-/* $FreeBSD: src/sys/dev/pccard/pccard_cis.c,v 1.40 2007/02/27 17:23:28 jhb Exp $ */
+/* $FreeBSD: src/sys/dev/pccard/pccard_cis.c,v 1.41 2008/06/01 20:55:34 imp Exp $ */
/*-
* Copyright (c) 1997 Marc Horowitz. All rights reserved.
@@ -898,7 +898,7 @@
break;
case CISTPL_CFTABLE_ENTRY:
{
- int idx, i, j;
+ int idx, i;
u_int reg, reg2;
u_int intface, def, num;
u_int power, timing, iospace, irq, memspace, misc;
@@ -906,8 +906,7 @@
idx = 0;
- reg = pccard_tuple_read_1(tuple, idx);
- idx++;
+ reg = pccard_tuple_read_1(tuple, idx++);
intface = reg & PCCARD_TPCE_INDX_INTFACE;
def = reg & PCCARD_TPCE_INDX_DEFAULT;
num = reg & PCCARD_TPCE_INDX_NUM_MASK;
@@ -983,8 +982,7 @@
}
if (intface) {
- reg = pccard_tuple_read_1(tuple, idx);
- idx++;
+ reg = pccard_tuple_read_1(tuple, idx++);
cfe->flags &= ~(PCCARD_CFE_MWAIT_REQUIRED
| PCCARD_CFE_RDYBSY_ACTIVE
| PCCARD_CFE_WP_ACTIVE
@@ -999,8 +997,7 @@
cfe->flags |= PCCARD_CFE_BVD_ACTIVE;
cfe->iftype = reg & PCCARD_TPCE_IF_IFTYPE;
}
- reg = pccard_tuple_read_1(tuple, idx);
- idx++;
+ reg = pccard_tuple_read_1(tuple, idx++);
power = reg & PCCARD_TPCE_FS_POWER_MASK;
timing = reg & PCCARD_TPCE_FS_TIMING;
@@ -1013,30 +1010,26 @@
/* skip over power, don't save */
/* for each parameter selection byte */
for (i = 0; i < power; i++) {
- reg = pccard_tuple_read_1(tuple, idx);
- idx++;
- /* for each bit */
- for (j = 0; j < 7; j++) {
- /* if the bit is set */
- if ((reg >> j) & 0x01) {
- /* skip over bytes */
- do {
- reg2 = pccard_tuple_read_1(tuple, idx);
- idx++;
- /*
- * until
- * non-extensi
- * on byte
- */
- } while (reg2 & 0x80);
- }
+ reg = pccard_tuple_read_1(tuple, idx++);
+ for (; reg; reg >>= 1)
+ {
+ /* set bit -> read */
+ if ((reg & 1) == 0)
+ continue;
+ /* skip over bytes */
+ do {
+ reg2 = pccard_tuple_read_1(tuple, idx++);
+ /*
+ * until non-extension
+ * byte
+ */
+ } while (reg2 & 0x80);
}
}
}
if (timing) {
/* skip over timing, don't save */
- reg = pccard_tuple_read_1(tuple, idx);
- idx++;
+ reg = pccard_tuple_read_1(tuple, idx++);
if ((reg & PCCARD_TPCE_TD_RESERVED_MASK) !=
PCCARD_TPCE_TD_RESERVED_MASK)
@@ -1054,8 +1047,7 @@
goto abort_cfe;
}
- reg = pccard_tuple_read_1(tuple, idx);
- idx++;
+ reg = pccard_tuple_read_1(tuple, idx++);
cfe->flags &=
~(PCCARD_CFE_IO8 | PCCARD_CFE_IO16);
if (reg & PCCARD_TPCE_IO_BUSWIDTH_8BIT)
@@ -1066,9 +1058,7 @@
reg & PCCARD_TPCE_IO_IOADDRLINES_MASK;
if (reg & PCCARD_TPCE_IO_HASRANGE) {
- reg = pccard_tuple_read_1(tuple, idx);
- idx++;
-
+ reg = pccard_tuple_read_1(tuple, idx++);
cfe->num_iospace = 1 + (reg &
PCCARD_TPCE_IO_RANGE_COUNT);
@@ -1085,8 +1075,7 @@
switch (reg & PCCARD_TPCE_IO_RANGE_ADDRSIZE_MASK) {
case PCCARD_TPCE_IO_RANGE_ADDRSIZE_ONE:
cfe->iospace[i].start =
- pccard_tuple_read_1(tuple, idx);
- idx++;
+ pccard_tuple_read_1(tuple, idx++);
break;
case PCCARD_TPCE_IO_RANGE_ADDRSIZE_TWO:
cfe->iospace[i].start =
@@ -1103,8 +1092,7 @@
PCCARD_TPCE_IO_RANGE_LENGTHSIZE_MASK) {
case PCCARD_TPCE_IO_RANGE_LENGTHSIZE_ONE:
cfe->iospace[i].length =
- pccard_tuple_read_1(tuple, idx);
- idx++;
+ pccard_tuple_read_1(tuple, idx++);
break;
case PCCARD_TPCE_IO_RANGE_LENGTHSIZE_TWO:
cfe->iospace[i].length =
@@ -1132,8 +1120,7 @@
goto abort_cfe;
}
- reg = pccard_tuple_read_1(tuple, idx);
- idx++;
+ reg = pccard_tuple_read_1(tuple, idx++);
cfe->flags &= ~(PCCARD_CFE_IRQSHARE
| PCCARD_CFE_IRQPULSE
| PCCARD_CFE_IRQLEVEL);
@@ -1186,12 +1173,9 @@
int cardaddrsize;
int hostaddrsize;
- reg = pccard_tuple_read_1(tuple, idx);
- idx++;
-
+ reg = pccard_tuple_read_1(tuple, idx++);
cfe->num_memspace = (reg &
PCCARD_TPCE_MS_COUNT) + 1;
-
if (cfe->num_memspace >
(sizeof(cfe->memspace) /
sizeof(cfe->memspace[0]))) {
@@ -1255,8 +1239,7 @@
goto abort_cfe;
}
- reg = pccard_tuple_read_1(tuple, idx);
- idx++;
+ reg = pccard_tuple_read_1(tuple, idx++);
cfe->flags &= ~(PCCARD_CFE_POWERDOWN
| PCCARD_CFE_READONLY
| PCCARD_CFE_AUDIO);
@@ -1269,8 +1252,7 @@
cfe->maxtwins = reg & PCCARD_TPCE_MI_MAXTWINS;
while (reg & PCCARD_TPCE_MI_EXT) {
- reg = pccard_tuple_read_1(tuple, idx);
- idx++;
+ reg = pccard_tuple_read_1(tuple, idx++);
}
}
/* skip all the subtuples */
==== //depot/projects/soc2008/snagg-audit/sys/netgraph/ng_nat.c#2 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/netgraph/ng_nat.c,v 1.11 2008/03/01 17:14:02 mav Exp $
+ * $FreeBSD: src/sys/netgraph/ng_nat.c,v 1.12 2008/06/01 15:13:32 mav Exp $
*/
#include <sys/param.h>
@@ -704,14 +704,14 @@
("ng_nat: ip_len != m_pkthdr.len"));
if (hook == priv->in) {
- rval = LibAliasIn(priv->lib, c, MCLBYTES);
+ rval = LibAliasIn(priv->lib, c, m->m_len + M_TRAILINGSPACE(m));
if (rval != PKT_ALIAS_OK &&
rval != PKT_ALIAS_FOUND_HEADER_FRAGMENT) {
NG_FREE_ITEM(item);
return (EINVAL);
}
} else if (hook == priv->out) {
- rval = LibAliasOut(priv->lib, c, MCLBYTES);
+ rval = LibAliasOut(priv->lib, c, m->m_len + M_TRAILINGSPACE(m));
if (rval != PKT_ALIAS_OK) {
NG_FREE_ITEM(item);
return (EINVAL);
==== //depot/projects/soc2008/snagg-audit/sys/netinet/libalias/alias.c#4 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netinet/libalias/alias.c,v 1.62 2008/06/01 11:47:04 mav Exp $");
+__FBSDID("$FreeBSD: src/sys/netinet/libalias/alias.c,v 1.63 2008/06/01 17:52:40 mav Exp $");
/*
Alias.c provides supervisory control for the functions of the
@@ -1656,29 +1656,49 @@
* m_megapullup() - this function is a big hack.
* Thankfully, it's only used in ng_nat and ipfw+nat.
*
- * It allocates an mbuf with cluster and copies the whole chain into cluster,
- * so that it is all contiguous and the whole packet can be accessed via a
- * plain (char *) pointer. This is required, because libalias doesn't know
- * how to handle mbuf chains.
+ * It allocates an mbuf with cluster and copies the specified part of the chain
+ * into cluster, so that it is all contiguous and can be accessed via a plain
+ * (char *) pointer. This is required, because libalias doesn't know how to
+ * handle mbuf chains.
*
- * On success, m_megapullup returns an mbuf with cluster containing the input
- * packet, on failure NULL. In both cases, the input packet is consumed.
+ * On success, m_megapullup returns an mbuf (possibly with cluster) containing
+ * the input packet, on failure NULL. The input packet is always consumed.
*/
struct mbuf *
m_megapullup(struct mbuf *m, int len) {
struct mbuf *mcl;
- caddr_t cp;
- if (len > MCLBYTES)
+ if (len > m->m_pkthdr.len)
goto bad;
- if ((mcl = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR)) == NULL)
+ /* Do not reallocate packet if it is sequentional,
+ * writable and has some extra space for expansion.
+ * XXX: Constant 100bytes is completely empirical. */
+#define RESERVE 100
+ if (m->m_next == NULL && M_WRITABLE(m) && M_TRAILINGSPACE(m) >= RESERVE)
+ return (m);
+
+ if (len <= MCLBYTES - RESERVE) {
+ mcl = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
+ } else if (len < MJUM16BYTES) {
+ int size;
+ if (len <= MJUMPAGESIZE - RESERVE) {
+ size = MJUMPAGESIZE;
+ } else if (len <= MJUM9BYTES - RESERVE) {
+ size = MJUM9BYTES;
+ } else {
+ size = MJUM16BYTES;
+ };
+ mcl = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, size);
+ } else {
+ goto bad;
+ }
+ if (mcl == NULL)
goto bad;
- cp = mtod(mcl, caddr_t);
- m_copydata(m, 0, len, cp);
m_move_pkthdr(mcl, m);
- mcl->m_len = mcl->m_pkthdr.len;
+ m_copydata(m, 0, len, mtod(mcl, caddr_t));
+ mcl->m_len = mcl->m_pkthdr.len = len;
m_freem(m);
return (mcl);
==== //depot/projects/soc2008/snagg-audit/sys/netinet/libalias/alias_db.c#2 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netinet/libalias/alias_db.c,v 1.72 2008/03/06 21:50:40 piso Exp $");
+__FBSDID("$FreeBSD: src/sys/netinet/libalias/alias_db.c,v 1.73 2008/06/01 18:34:58 mav Exp $");
/*
Alias_db.c encapsulates all data structures used for storing
@@ -180,8 +180,9 @@
*/
/* Parameters used for cleanup of expired links */
-#define ALIAS_CLEANUP_INTERVAL_SECS 60
-#define ALIAS_CLEANUP_MAX_SPOKES 30
+/* NOTE: ALIAS_CLEANUP_INTERVAL_SECS must be less then LINK_TABLE_OUT_SIZE */
+#define ALIAS_CLEANUP_INTERVAL_SECS 64
+#define ALIAS_CLEANUP_MAX_SPOKES (LINK_TABLE_OUT_SIZE/5)
/* Timeouts (in seconds) for different link types */
#define ICMP_EXPIRE_TIME 60
@@ -814,20 +815,12 @@
CleanupAliasData(struct libalias *la)
{
struct alias_link *lnk;
- int i, icount;
+ int i;
LIBALIAS_LOCK_ASSERT(la);
- icount = 0;
for (i = 0; i < LINK_TABLE_OUT_SIZE; i++) {
- lnk = LIST_FIRST(&la->linkTableOut[i]);
- while (lnk != NULL) {
- struct alias_link *link_next;
-
- link_next = LIST_NEXT(lnk, list_out);
- icount++;
+ while ((lnk = LIST_FIRST(&la->linkTableOut[i])) != NULL)
DeleteLink(lnk);
- lnk = link_next;
- }
}
la->cleanupIndex = 0;
@@ -837,39 +830,13 @@
static void
IncrementalCleanup(struct libalias *la)
{
- int icount;
- struct alias_link *lnk;
+ struct alias_link *lnk, *lnk_tmp;
LIBALIAS_LOCK_ASSERT(la);
- icount = 0;
- lnk = LIST_FIRST(&la->linkTableOut[la->cleanupIndex++]);
- while (lnk != NULL) {
- int idelta;
- struct alias_link *link_next;
-
- link_next = LIST_NEXT(lnk, list_out);
- idelta = la->timeStamp - lnk->timestamp;
- switch (lnk->link_type) {
- case LINK_TCP:
- if (idelta > lnk->expire_time) {
- struct tcp_dat *tcp_aux;
-
- tcp_aux = lnk->data.tcp;
- if (tcp_aux->state.in != ALIAS_TCP_STATE_CONNECTED
- || tcp_aux->state.out != ALIAS_TCP_STATE_CONNECTED) {
- DeleteLink(lnk);
- icount++;
- }
- }
- break;
- default:
- if (idelta > lnk->expire_time) {
- DeleteLink(lnk);
- icount++;
- }
- break;
- }
- lnk = link_next;
+ LIST_FOREACH_SAFE(lnk, &la->linkTableOut[la->cleanupIndex++],
+ list_out, lnk_tmp) {
+ if (la->timeStamp - lnk->timestamp > lnk->expire_time)
+ DeleteLink(lnk);
}
if (la->cleanupIndex == LINK_TABLE_OUT_SIZE)
@@ -1137,12 +1104,12 @@
LIBALIAS_LOCK_ASSERT(la);
i = StartPointOut(src_addr, dst_addr, src_port, dst_port, link_type);
LIST_FOREACH(lnk, &la->linkTableOut[i], list_out) {
- if (lnk->src_addr.s_addr == src_addr.s_addr
- && lnk->server == NULL
- && lnk->dst_addr.s_addr == dst_addr.s_addr
- && lnk->dst_port == dst_port
- && lnk->src_port == src_port
- && lnk->link_type == link_type) {
+ if (lnk->dst_addr.s_addr == dst_addr.s_addr &&
+ lnk->src_addr.s_addr == src_addr.s_addr &&
+ lnk->src_port == src_port &&
+ lnk->dst_port == dst_port &&
+ lnk->link_type == link_type &&
+ lnk->server == NULL) {
lnk->timestamp = la->timeStamp;
break;
}
@@ -2189,7 +2156,7 @@
void
HouseKeeping(struct libalias *la)
{
- int i, n, n100;
+ int i, n;
#ifndef _KERNEL
struct timeval tv;
struct timezone tz;
@@ -2209,33 +2176,22 @@
#endif
/* Compute number of spokes (output table link chains) to cover */
- n100 = LINK_TABLE_OUT_SIZE * 100 + la->houseKeepingResidual;
- n100 *= la->timeStamp - la->lastCleanupTime;
- n100 /= ALIAS_CLEANUP_INTERVAL_SECS;
+ n = LINK_TABLE_OUT_SIZE * (la->timeStamp - la->lastCleanupTime);
+ n /= ALIAS_CLEANUP_INTERVAL_SECS;
- n = n100 / 100;
-
/* Handle different cases */
- if (n > ALIAS_CLEANUP_MAX_SPOKES) {
- n = ALIAS_CLEANUP_MAX_SPOKES;
+ if (n > 0) {
+ if (n > ALIAS_CLEANUP_MAX_SPOKES)
+ n = ALIAS_CLEANUP_MAX_SPOKES;
la->lastCleanupTime = la->timeStamp;
- la->houseKeepingResidual = 0;
-
for (i = 0; i < n; i++)
IncrementalCleanup(la);
- } else if (n > 0) {
- la->lastCleanupTime = la->timeStamp;
- la->houseKeepingResidual = n100 - 100 * n;
-
- for (i = 0; i < n; i++)
- IncrementalCleanup(la);
} else if (n < 0) {
#ifdef LIBALIAS_DEBUG
fprintf(stderr, "PacketAlias/HouseKeeping(): ");
fprintf(stderr, "something unexpected in time values\n");
#endif
la->lastCleanupTime = la->timeStamp;
- la->houseKeepingResidual = 0;
}
}
@@ -2529,7 +2485,6 @@
la->timeStamp = tv.tv_sec;
la->lastCleanupTime = tv.tv_sec;
#endif
- la->houseKeepingResidual = 0;
for (i = 0; i < LINK_TABLE_OUT_SIZE; i++)
LIST_INIT(&la->linkTableOut[i]);
==== //depot/projects/soc2008/snagg-audit/sys/netinet/libalias/alias_local.h#2 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/netinet/libalias/alias_local.h,v 1.35 2008/03/06 21:50:40 piso Exp $
+ * $FreeBSD: src/sys/netinet/libalias/alias_local.h,v 1.36 2008/06/01 18:34:58 mav Exp $
*/
/*
@@ -60,7 +60,7 @@
#endif
/* Sizes of input and output link tables */
-#define LINK_TABLE_OUT_SIZE 101
+#define LINK_TABLE_OUT_SIZE 4001
#define LINK_TABLE_IN_SIZE 4001
struct proxy_entry;
@@ -110,8 +110,6 @@
* IncrementalCleanup() */
/* was called */
- int houseKeepingResidual; /* used by HouseKeeping() */
-
int deleteAllLinks; /* If equal to zero, DeleteLink() */
/* will not remove permanent links */
More information about the p4-projects
mailing list