summaryrefslogtreecommitdiff
path: root/usr/src/lib/libinetutil/common
diff options
context:
space:
mode:
authorSangeeta Misra <Sangeeta.Misra@Sun.COM>2009-11-03 23:15:19 -0800
committerSangeeta Misra <Sangeeta.Misra@Sun.COM>2009-11-03 23:15:19 -0800
commitdbed73cbda2229fd1aa6dc5743993cae7f0a7ee9 (patch)
tree74a198c6a7ce750aaff09b4d682a53564ca13b58 /usr/src/lib/libinetutil/common
parentdfe73b3d6f9191b75fe71a92c8854f83c6d16a63 (diff)
downloadillumos-joyent-dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9.tar.gz
PSARC 2008/575 ILB: Integrated L3/L4 Load balancer
6882718 in-kernel simple L3/L4 load balancing service should be provided in Solaris 6884202 ipobs_hook() in ip_input() invalidates DB_REF assumption
Diffstat (limited to 'usr/src/lib/libinetutil/common')
-rw-r--r--usr/src/lib/libinetutil/common/libinetutil.h2
-rw-r--r--usr/src/lib/libinetutil/common/ofmt.c31
-rw-r--r--usr/src/lib/libinetutil/common/ofmt.h9
-rw-r--r--usr/src/lib/libinetutil/common/tq.c18
4 files changed, 47 insertions, 13 deletions
diff --git a/usr/src/lib/libinetutil/common/libinetutil.h b/usr/src/lib/libinetutil/common/libinetutil.h
index bacf64938a..a285103af6 100644
--- a/usr/src/lib/libinetutil/common/libinetutil.h
+++ b/usr/src/lib/libinetutil/common/libinetutil.h
@@ -158,7 +158,7 @@ typedef struct iu_timer_queue iu_tq_t;
typedef int iu_timer_id_t;
-#define IU_TIMER_ID_MAX 1024 /* max number of concurrent timers */
+#define IU_TIMER_ID_MAX 4096 /* max number of concurrent timers */
/*
* a iu_tq_callback_t is a function that is called back in response to a
diff --git a/usr/src/lib/libinetutil/common/ofmt.c b/usr/src/lib/libinetutil/common/ofmt.c
index 2bfc4aafa4..c0fce1839e 100644
--- a/usr/src/lib/libinetutil/common/ofmt.c
+++ b/usr/src/lib/libinetutil/common/ofmt.c
@@ -66,6 +66,8 @@ typedef struct ofmt_state_s {
boolean_t os_wrap;
int os_nbad;
char **os_badfields;
+ boolean_t os_multiline;
+ int os_maxnamelen; /* longest name (f. multiline) */
} ofmt_state_t;
/*
* A B_TRUE return value from the callback function will print out the contents
@@ -187,9 +189,12 @@ ofmt_open(const char *str, const ofmt_field_t *template, uint_t flags,
ofmt_status_t err = OFMT_SUCCESS;
boolean_t parsable = ((flags & OFMT_PARSABLE) != 0);
boolean_t wrap = ((flags & OFMT_WRAP) != 0);
+ boolean_t multiline = (flags & OFMT_MULTILINE);
*ofmt = NULL;
if (parsable) {
+ if (multiline)
+ return (OFMT_EPARSEMULTI);
/*
* For parsable output mode, the caller always needs
* to specify precisely which fields are to be selected,
@@ -229,6 +234,7 @@ ofmt_open(const char *str, const ofmt_field_t *template, uint_t flags,
os->os_parsable = parsable;
os->os_wrap = wrap;
+ os->os_multiline = multiline;
of = os->os_fields;
of_index = 0;
/*
@@ -260,6 +266,11 @@ ofmt_open(const char *str, const ofmt_field_t *template, uint_t flags,
of[of_index].of_name = strdup(template[j].of_name);
if (of[of_index].of_name == NULL)
goto nomem;
+ if (multiline) {
+ int n = strlen(of[of_index].of_name);
+
+ os->os_maxnamelen = MAX(n, os->os_maxnamelen);
+ }
of[of_index].of_width = template[j].of_width;
of[of_index].of_id = template[j].of_id;
of[of_index].of_cb = template[j].of_cb;
@@ -310,14 +321,13 @@ ofmt_print_field(ofmt_state_t *os, ofmt_field_t *ofp, const char *value,
uint_t width = ofp->of_width;
uint_t valwidth;
uint_t compress;
- boolean_t parsable = os->os_parsable;
char c;
/*
* Parsable fields are separated by ':'. If such a field contains
* a ':' or '\', this character is prefixed by a '\'.
*/
- if (parsable) {
+ if (os->os_parsable) {
if (os->os_nfields == 1) {
(void) printf("%s", value);
return;
@@ -329,7 +339,13 @@ ofmt_print_field(ofmt_state_t *os, ofmt_field_t *ofp, const char *value,
}
if (!os->os_lastfield)
(void) putchar(':');
- return;
+ } else if (os->os_multiline) {
+ if (value[0] == '\0')
+ value = OFMT_VAL_UNDEF;
+ (void) printf("%*.*s: %s", os->os_maxnamelen,
+ os->os_maxnamelen, ofp->of_name, value);
+ if (!os->os_lastfield)
+ (void) putchar('\n');
} else {
if (os->os_lastfield) {
(void) printf("%s", value);
@@ -408,11 +424,15 @@ ofmt_print(ofmt_handle_t ofmt, void *arg)
return;
}
- if ((os->os_nrow++ % os->os_winsize.ws_row) == 0 && !os->os_parsable) {
+ if ((os->os_nrow++ % os->os_winsize.ws_row) == 0 && !os->os_parsable &&
+ !os->os_multiline) {
ofmt_print_header(os);
os->os_nrow++;
}
+ if (os->os_multiline && os->os_nrow > 1)
+ (void) putchar('\n');
+
of = os->os_fields;
escsep = (os->os_nfields > 1);
more_rows = B_FALSE;
@@ -549,6 +569,9 @@ ofmt_strerror(ofmt_handle_t ofmt, ofmt_status_t err, char *buf, uint_t bufsize)
case OFMT_ENOFIELDS:
s = "no valid output fields";
break;
+ case OFMT_EPARSEMULTI:
+ s = "multiline mode incompatible with parsable mode";
+ break;
case OFMT_EPARSEALL:
s = "output field `all' invalid in parsable mode";
break;
diff --git a/usr/src/lib/libinetutil/common/ofmt.h b/usr/src/lib/libinetutil/common/ofmt.h
index d3e4142578..81693ae325 100644
--- a/usr/src/lib/libinetutil/common/ofmt.h
+++ b/usr/src/lib/libinetutil/common/ofmt.h
@@ -35,6 +35,8 @@
* are separated by ':', with the ':' character itself escaped by a \
* (e.g., IPv6 addresses may be printed as "fe80\:\:1"); single field output
* is printed as-is.
+ * In multiline mode, every [field,value] pair is printed in a line of
+ * its own, thus: "field: value".
*
* The caller must open a handle for each set of fields to be printed by
* invoking ofmt_open(). The invocation to ofmt_open must provide the list of
@@ -57,6 +59,9 @@
* (non machine-parsable) mode, a NULL fields_str, or a value of "all" for
* fields_str, is treated as a request to print all allowable fields that fit
* other applicable constraints.
+ * To achieve multiline mode, OFMT_MULTILINE needs to be specified in oflags.
+ * Specifying both OFMT_MULTILINE and OFMT_PARSABLE will result in
+ * OFMT_EPARSEMULTI.
*
* Thus a typical invocation to open the ofmt_handle would be:
*
@@ -135,7 +140,8 @@ typedef enum {
OFMT_EPARSEALL, /* 'all' invalid in parsable mode */
OFMT_EPARSENONE, /* output fields missing in parsable mode */
OFMT_EPARSEWRAP, /* parsable mode incompatible with wrap mode */
- OFMT_ENOTEMPLATE /* no template provided for fields */
+ OFMT_ENOTEMPLATE, /* no template provided for fields */
+ OFMT_EPARSEMULTI /* parsable and multiline don't mix */
} ofmt_status_t;
/*
@@ -171,6 +177,7 @@ extern ofmt_status_t ofmt_open(const char *, const ofmt_field_t *, uint_t,
#define OFMT_PARSABLE 0x00000001 /* machine parsable mode */
#define OFMT_WRAP 0x00000002 /* wrap output if field width is exceeded */
+#define OFMT_MULTILINE 0x00000004 /* "long" output: "name: value" lines */
/*
* ofmt_close() must be called to free resources associated
diff --git a/usr/src/lib/libinetutil/common/tq.c b/usr/src/lib/libinetutil/common/tq.c
index 78505462bd..e809b3289d 100644
--- a/usr/src/lib/libinetutil/common/tq.c
+++ b/usr/src/lib/libinetutil/common/tq.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <stdlib.h>
#include <limits.h>
#include <sys/time.h>
@@ -342,7 +339,14 @@ iu_expire_timers(iu_tq_t *tq)
for (node = tq->iutq_head; node != NULL;
node = node->iutn_expire_next) {
- if (node->iutn_abs_timeout > current_time)
+ /*
+ * If the timeout is within 1 millisec of current time,
+ * consider it as expired already. We do this because
+ * iu_earliest_timer() only has millisec granularity.
+ * So we should also use millisec grandularity in
+ * comparing timeout values.
+ */
+ if (node->iutn_abs_timeout - current_time > 1000000)
break;
/*