Index: /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_cache.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_cache.c	(revision 40197)
+++ /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_cache.c	(working copy)
@@ -239,7 +239,6 @@
 	http2_nv *nv;
 	uint32_t offset = 1;
 	cache_metadata_t *meta_data;
-	cookie_node_t *node_p;
 
 	meta_data = proxy_p->cache_metadata_p;
 	meta_data->cache_filter_cache_flag = CF_ACTION_DEFAULT;
@@ -276,7 +275,7 @@
 		}
 	}
 	
-	if (!SLIST_EMPTY(&(proxy_p->h2_cookie_list))) {
+	if (!TAILQ_EMPTY(&(proxy_p->h2_cookie_list))) {
 		HTTP_FLAG_SET(meta_data->flags, HTTP_CMETA_REQ_COOKIE);
 	}
 
@@ -496,7 +495,7 @@
 	}
 	
 	/* Cookie header */
-	if (!SLIST_EMPTY(&(proxy_p->cookie_list))) {
+	if (!TAILQ_EMPTY(&(proxy_p->cookie_list))) {
 		bzero(&cookie_nv, sizeof(cookie_nv));
 		if (h2_cookie_assemble(slb_vs_p, proxy_p, &cookie_nv) != H2_FUNC_SUCCESS) {
 			return H2_FUNC_FAIL;
Index: /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_hpack.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_hpack.c	(revision 40197)
+++ /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_hpack.c	(working copy)
@@ -162,7 +162,7 @@
 {
 	h2log("Enter func [%s]", __func__);
 	int cookie_len = 0, offset = 0;
-	cookie_node_t *node_p;
+	cookie_tailq_node_t *node_p;
 	
 	/* cookie is security related header, we should never add it to dynamic HPACK table,
 	 * so set flag as HTTP2_NV_FLAG_NO_INDEX
@@ -171,10 +171,12 @@
 	nv->name = (uint8_t *)H2_HDR_COOKIE;
 	nv->namelen = sizeof(H2_HDR_COOKIE)-1;
 	
-	SLIST_FOREACH(node_p, &proxy_p->h2_cookie_list, next_p) {
+	TAILQ_FOREACH(node_p, &proxy_p->h2_cookie_list, next_p) {
 		h2_debug_print_cookie_node(__func__, node_p);
 		cookie_len += node_p->name_len + node_p->value_len + 4; /*additional space for "=" ";" and " " '\0'*/
 		h2log("cookie_len [%d]", cookie_len);
+		ulog_error_no_conn(AMP_ULOG_HTTP2, "cookie hdr %p name-len %d, name %s, value-len %d, value %s",
+				   node_p->header_p, node_p->name_len, node_p->name_p, node_p->value_p, node_p->value_p );
 	}
 
 	nv->value = STRING_ALLOC(cookie_len);
@@ -185,7 +187,7 @@
 	h2log("Func [%s], alloc memory %p", __func__, nv->value);
 	bzero(nv->value, cookie_len);
 	
-	SLIST_FOREACH(node_p, &proxy_p->h2_cookie_list, next_p) {
+	TAILQ_FOREACH(node_p, &proxy_p->h2_cookie_list, next_p) {
 		h2log("nv->value [%s]", nv->value);
 		bcopy(node_p->name_p, nv->value + offset, node_p->name_len);
 		offset += node_p->name_len;
@@ -198,7 +200,7 @@
 			offset += node_p->value_len;
 		}
 		
-		if (SLIST_NEXT(node_p, next_p) != NULL) {
+		if (TAILQ_NEXT(node_p, next_p) != NULL) {
 			*(nv->value + offset) = ';';
 			offset++;
 			*(nv->value + offset) = ' ';
@@ -2422,7 +2424,7 @@
 	}
 
 	/* Request cookies */
-	if (!SLIST_EMPTY(&proxy_p->h2_cookie_list)) {
+	if (!TAILQ_EMPTY(&proxy_p->h2_cookie_list)) {
 		bzero(&nv_in, sizeof(http2_nv));
 		if (h2_cookie_assemble(vs_p, proxy_p, &nv_in) != H2_FUNC_SUCCESS) {
 			goto func_fail;
Index: /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_server_states.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_server_states.c	(revision 40197)
+++ /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_server_states.c	(working copy)
@@ -607,7 +607,7 @@
 	uint32_t header_len = 0; /* useless */
 	BOOL end_of_frames = FALSE;	/* useless */
 	BOOL cookie_node_malloced = FALSE;
-	cookie_node_t *node_p;
+	cookie_tailq_node_t *node_p;
 	
 	bzero(&read_write, sizeof(struct read_write_info));
 	
@@ -640,7 +640,7 @@
 	}
 	
 	/* The first is newest cookie node */
-	node_p = SLIST_FIRST(&(proxy_p->cookie_list));	
+	node_p = TAILQ_FIRST(&(proxy_p->cookie_list));	
 	/* So that parser frame can be free */
 	node_p->header_frame_malloc = TRUE;
 	
Index: /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_stream.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_stream.c	(revision 40197)
+++ /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_stream.c	(working copy)
@@ -400,7 +400,7 @@
 	struct frame *frame_p = NULL;
 	struct read_write_info read_write;
 	BOOL cookie_node_malloced = FALSE;
-	cookie_node_t *node_p;
+	cookie_tailq_node_t *node_p;
 	
 	bzero(&read_write, sizeof(struct read_write_info));
 	
@@ -429,7 +429,7 @@
 	}
 	
 	/* The first is newest cookie node */
-	node_p = SLIST_FIRST(&(proxy_p->cookie_list));	
+	node_p = TAILQ_FIRST(&(proxy_p->cookie_list));	
 	/* So that parser frame can be free */
 	node_p->header_frame_malloc = TRUE;
 	
Index: /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_trans_utils.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_trans_utils.c	(revision 40197)
+++ /branches/rel_apv_10_7/usr/click/lib/libhttp2/h2_trans_utils.c	(working copy)
@@ -320,22 +320,22 @@
 			slb_http_set_source_ip_flags(&ippcb->cp_extflags);
 			ippcb->tcp_opt_custom_kind = slb_group_table[slb_membership->gid].custom_kind;
 			ippcb->tcp_opt_source_port = slb_group_table[slb_membership->gid].insert_sport;
-		}
-	}
-
-	if (FLAG_ISSET(slb_group_table[slb_membership->gid].flags, SLB_GRP_PROXY_PROTOCOL_V1)) {
-		if(ippcb = pcb_clipcb(pcb)) {
-			slb_proxy_protocol_v1_flags(&ippcb->cp_extflags);
-		}
-	} else if (FLAG_ISSET(slb_group_table[slb_membership->gid].flags, SLB_GRP_PROXY_PROTOCOL_V2)) {
-		if(ippcb = pcb_clipcb(pcb)) {
-			slb_proxy_protocol_v2_flags(&ippcb->cp_extflags);
-		}
-	}
-
-	if (!SLB_IS_HTTP2_RS(slb_membership)) {
-		/* HTTP/2 to HTTP/1.x mode */
-		h2log("2 to 1 mode, reuse %d", conn_reuse);
+		}
+	}
+
+	if (FLAG_ISSET(slb_group_table[slb_membership->gid].flags, SLB_GRP_PROXY_PROTOCOL_V1)) {
+		if(ippcb = pcb_clipcb(pcb)) {
+			slb_proxy_protocol_v1_flags(&ippcb->cp_extflags);
+		}
+	} else if (FLAG_ISSET(slb_group_table[slb_membership->gid].flags, SLB_GRP_PROXY_PROTOCOL_V2)) {
+		if(ippcb = pcb_clipcb(pcb)) {
+			slb_proxy_protocol_v2_flags(&ippcb->cp_extflags);
+		}
+	}
+
+	if (!SLB_IS_HTTP2_RS(slb_membership)) {
+		/* HTTP/2 to HTTP/1.x mode */
+		h2log("2 to 1 mode, reuse %d", conn_reuse);
         /* process 2-1 server connection reuse */
         isempty = TAILQ_EMPTY(&(http_conn_pools[slb_rs_p->rs_id].idle_conn_q));
 		if (conn_reuse && (!isempty)) {
@@ -2242,7 +2242,7 @@
 	}
 
 	/*
-	 * check if additional buffers were allocated and free them 
+	 * check if additional buffers were allocated and free them
 	 */
 	switch (node_p->fl_malloc) {
 		case COOKIE_NAME_MALLOC:
@@ -2258,62 +2258,142 @@
 		default:
 			break;	/* COOKIE_NO_MALLOC */
 	}
-		
+
 	COOKIE_NODE_FREE(node_p);
 }
 
+/* request cookies are in the queues these functions are only for them */
+cookie_node_t *h2_cookie_tailq_node_ctor(char *stamp)
+{
+	cookie_tailq_node_t *node_p = NULL;
+
+	node_p = cookie_tailq_node_alloc_init();
+	if (node_p == NULL) {
+		goto func_fail;
+	}
+
+	node_p->name_frame_p = parser_frame_alloc();
+	if (node_p->name_frame_p == NULL) {
+		goto func_fail;
+	}
+
+	mpool_stamp(node_p->name_frame_p);
+	node_p->header_frame_malloc = TRUE;
+
+	node_p->value_frame_p = parser_frame_alloc();
+	if (node_p->value_frame_p == NULL) {
+		goto func_fail;
+	}
+	mpool_stamp(node_p->value_frame_p);
+	node_p->value_frame_malloc = TRUE;
+	node_p->fl_grp_opt_secure = GROUP_OPT_IC_SECURE_INIT;
+	node_p->fl_grp_opt_samesite = FALSE;
+
+	node_p->name_p = node_p->name_frame_p->f_data;
+	node_p->value_p = node_p->value_frame_p->f_data;
+
+	return node_p;
+
+func_fail:
+	if (node_p != NULL) {
+		if (node_p->name_frame_p != NULL) {
+			parser_frame_chain_free(node_p->name_frame_p);
+		}
+
+		if (node_p->value_frame_p != NULL) {
+			parser_frame_chain_free(node_p->value_frame_p);
+		}
+
+		COOKIE_TAILQ_NODE_FREE(node_p);
+	}
+
+	return NULL;
+}
+
+
+void h2_cookie_tailq_node_dtor(cookie_tailq_node_t *node_p)
+{
+	if (node_p->header_frame_malloc) {
+		parser_frame_chain_free(node_p->name_frame_p);
+	}
+
+	if (node_p->value_frame_malloc) {
+		parser_frame_chain_free(node_p->value_frame_p);
+	}
+
+	/*
+	 * check if additional buffers were allocated and free them
+	 */
+	switch (node_p->fl_malloc) {
+		case COOKIE_NAME_MALLOC:
+			STRING_FREE(node_p->name_p);
+			break;
+		case COOKIE_VALUE_MALLOC:
+			STRING_FREE(node_p->value_p);
+			break;
+		case COOKIE_NAME_VALUE_MALLOC:
+			STRING_FREE(node_p->name_p);
+			STRING_FREE(node_p->value_p);
+			break;
+		default:
+			break;	/* COOKIE_NO_MALLOC */
+	}
+
+	COOKIE_TAILQ_NODE_FREE(node_p);
+}
+
 /* ok */
 int h2_insert_cookie_node(struct uproxy_type *proxy_p, char *name, char *value)
 {
 	uint8_t *wr_name_p, *wr_value_p;
-	cookie_node_t *node_p = NULL;
+	cookie_tailq_node_t *node_p = NULL;
 	int namelen, valuelen;
 	struct frame *name_frame_p, *value_frame_p;
 
 	namelen = strlen(name);
 	valuelen = strlen(value);
 
-	node_p = h2_cookie_node_ctor(HTTP2_STAMP);
+	node_p = h2_cookie_tailq_node_ctor(HTTP2_STAMP);
 	if (node_p == NULL) {
 		return H2_FUNC_FAIL;
 	}
-	
+
 	node_p->fl_malloc = COOKIE_NO_MALLOC;
-	
+
 	name_frame_p = node_p->name_frame_p;
 	value_frame_p = node_p->value_frame_p;
-	
+
 	mpool_stamp(node_p->name_frame_p);
 	mpool_stamp(node_p->value_frame_p);
-	
+
 	wr_name_p = name_frame_p->f_data;
 	wr_value_p = value_frame_p->f_data;
-	
+
 	if (h2_write_data(name, &wr_name_p, namelen, &name_frame_p) == HTTP_FAIL) {
 		goto func_fail;
 	}
-	
+
 	if (h2_write_data(value, &wr_value_p, valuelen, &value_frame_p) == HTTP_FAIL) {
 		goto func_fail;
 	}
-	
+
 	node_p->name_len = namelen;
 	node_p->value_len = valuelen;
- 					
+
 	h2_debug_print_cookie_node(__func__, node_p);
-	SLIST_INSERT_HEAD(&proxy_p->h2_cookie_list, node_p, next_p);
+	TAILQ_INSERT_TAIL(&proxy_p->h2_cookie_list, node_p, next_p);
 
 	return H2_FUNC_SUCCESS;
-	
+
 func_fail:
 	if (node_p != NULL) {
 		parser_frame_chain_free(node_p->name_frame_p);
 		parser_frame_chain_free(node_p->value_frame_p);
 		COOKIE_NODE_FREE(node_p);
 	}
-	
+
 	AMP_EXCP_HTTP_INC(LEVEL_WARN, h2_insert_cookie_node_failed);
-	
+
 	return H2_FUNC_FAIL;
 }
 
@@ -2720,6 +2800,13 @@
 			node->name_len, node->value_len, node->value_p, node->value_len);
 }
 
+void h2_debug_print_cookie_tailq_node(const char *func, cookie_tailq_node_t *node)
+{
+	h2log("Func: [%s]: Cookie node: name [%.*s] len %d, value [%.*s] len %d", func,
+			node->name_len, node->name_p,
+			node->name_len, node->value_len, node->value_p, node->value_len);
+}
+
 void h2log_helper(char *fmt, ...)
 {
 	va_list	ap;
Index: /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/http_log.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/http_log.c	(revision 40197)
+++ /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/http_log.c	(working copy)
@@ -3633,7 +3633,7 @@
 			 * %k: session cookie / session ID
 			 * modified : mpatil
 			 */
-			if (!SLIST_EMPTY(&proxy_p->h2_cookie_list)){
+			if (!TAILQ_EMPTY(&proxy_p->h2_cookie_list)){
 				h2_cookie_assemble(slb_vs_p, proxy_p, &nv_in);
 				if (nv_in.valuelen) {
 					/* 
Index: /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/http_proxy.h
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/http_proxy.h	(revision 40197)
+++ /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/http_proxy.h	(working copy)
@@ -159,9 +159,9 @@
 	uint16_t http_ver;	/* http ver in request e.g. 10, 11 */
 	uint16_t http_ver_resp; /*http ver in response:HTTP_VER10 HTTP_VER11*/
 	uint16_t cookie_count; /* count of cookies in cookie_list*/
-	struct cookie_list_head cookie_list;/* names values of the cookies */
+	struct cookie_tailq_head cookie_list;/* names values of the cookies */
 	struct cookie_list_head custom_header_list;/* header name and content*/
-	
+
 	/* filled in by client request given to slb after selective copy */
 	header_info_t accept_info;      /* accept hdr for server driven negotiation */
 	header_info_t accept_char_info; /* accept-charset header information */
@@ -266,6 +266,7 @@
 typedef struct {
 	uint32_t str_alloc_cnt;
 	uint32_t cookie_node_alloc_cnt;
+	uint32_t cookie_tailq_node_alloc_cnt;
 	uint32_t range_node_alloc_cnt;
 	uint32_t event_accept_alloc_cnt;
 } alloc_counters_t;
@@ -351,6 +352,17 @@
 	return ptr;
 }
 
+inline void * COOKIE_TAILQ_NODE_ALLOC(void)
+{
+	void *ptr;
+	ptr = DEFAULT_ALLOC(cookie_tailq_node_t, alloc_cntrs.cookie_tailq_node_alloc_cnt);
+	if (ptr == NULL) {
+		AMP_EXCP_MEMORY_INC(LEVEL_WARN, mem_cookie_node_alloc_failed);
+	}
+
+	return ptr;
+}
+
 __attribute__((always_inline)) inline void * STRING_ALLOC(int len)
 {
 	void *ptr;
@@ -375,6 +387,7 @@
 
 #define STRING_FREE(var)                DEFAULT_FREE(var, alloc_cntrs.str_alloc_cnt)
 #define COOKIE_NODE_FREE(var)		DEFAULT_FREE(var, alloc_cntrs.cookie_node_alloc_cnt)
+#define COOKIE_TAILQ_NODE_FREE(var)		DEFAULT_FREE(var, alloc_cntrs.cookie_tailq_node_alloc_cnt)
 #define RANGE_NODE_FREE(var)		DEFAULT_FREE(var, alloc_cntrs.range_node_alloc_cnt)
 
 #define IS_RESPONSE_ENDED(proxy_p, server_conn_data) \
Index: /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/misc.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/misc.c	(revision 40197)
+++ /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/misc.c	(working copy)
@@ -141,6 +141,8 @@
 
 static int selective_copy_list_of_cookie_nodes(struct cookie_list_head *cookie_list_p);
 static void destroy_list_of_cookie_nodes(struct cookie_list_head *cookie_list_p);
+static int selective_copy_tailq_of_cookie_nodes(struct cookie_tailq_head *cookie_list_p);
+static void destroy_tailq_of_cookie_nodes(struct cookie_tailq_head *cookie_list_p);
 static void destroy_cookie_list(uproxy_t *proxy_p);
 
 static void insert_slb_cookie(struct uproxy_conn_data *server_conn_data,
@@ -496,9 +498,103 @@
 }
 
 int
+selective_copy_tailq_of_cookie_nodes(struct cookie_tailq_head *cookie_list_p)
+{
+	uint32_t remain_len = 0;
+	cookie_tailq_node_t *node_p = NULL;
+	uint8_t *str_p = NULL;
+
+	TAILQ_FOREACH(node_p, cookie_list_p, next_p) {
+		if (node_p->name_frame_p != NULL && node_p->name_p != NULL) {
+			/*
+			 * remain_len = number of bytes from the beginning of the
+			 * cookie name to the end of the frame
+			 */
+			remain_len = node_p->name_frame_p->f_datalen -
+			    (node_p->name_p - node_p->name_frame_p->f_data);
+
+			if (remain_len < node_p->name_len) {
+				/* name spans over several frames malloc a buffer */
+				str_p = STRING_ALLOC(node_p->name_len);
+				if (!str_p) {
+					AMP_PRX_APP_ERR_STAT_INC(err_str_alloc_fail);
+					PRX_ERROR_SET(GSU_STRING_ALLOC_FAIL);
+					hp_error("faled allocate cookie name string");
+					return HTTP_FAIL;
+				} else {
+					node_p->fl_malloc = COOKIE_NAME_MALLOC;
+					/*
+					 * copy  name  to the new buffer and
+					 * store the original name pointer(for bug 7208)
+					 */
+					parser_frame_chain_copy_to_buff(str_p, node_p->name_p,
+									node_p->name_len,
+									node_p->name_frame_p);
+					node_p->original_name_p = node_p->name_p;
+					node_p->name_p = str_p;
+				}
+			}
+			/* for name if(remain_len < node_p->name_len)  */
+			if (node_p->value_frame_p != NULL
+			    && node_p->value_p != NULL) {
+				/*
+				 * value was present
+				 * remain_len = number of bytes from the beginning of the
+				 * cookie value to the end of the frame
+				 */
+				remain_len = node_p->value_frame_p->f_datalen -
+					(node_p->value_p - node_p->value_frame_p->f_data);
+				if (remain_len < node_p->value_len) {
+					/* value spans over several frames malloc a buffer */
+					str_p = STRING_ALLOC(node_p->value_len);
+
+					if (!str_p) {
+						AMP_PRX_APP_ERR_STAT_INC(err_str_alloc_fail);
+						PRX_ERROR_SET(GSU_STRING_ALLOC_FAIL);
+						hp_error("faled allocate cookie value string");
+						return HTTP_FAIL;
+					} else {
+						if (node_p->fl_malloc == COOKIE_NAME_MALLOC) {
+							node_p->fl_malloc = COOKIE_NAME_VALUE_MALLOC;
+						} else {
+							node_p->fl_malloc = COOKIE_VALUE_MALLOC;
+						}
+						/*
+						 * copy the value to the new buffer and
+						 *  store the original value pointer(for bug 14426)
+						 */
+						parser_frame_chain_copy_to_buff(str_p, node_p->value_p,
+										node_p->value_len,
+										node_p->value_frame_p);
+						node_p->original_value_p = node_p->value_p;
+						node_p->value_p = str_p;
+					}
+				}	/* for value if(remain_len < node_p->name_len) */
+			} else {
+				/*
+				 * value was not present
+				 * we do not create a string and simply set value_len to 0. The
+				 * way of handling this situation in in agreement with slb
+				 */
+				node_p->value_len = 0;
+			}
+		} else {
+			/*
+			 * cookie node contain null frame pointers or null data pointers;
+			 * this should not happen beacaus invalid request gets dropped
+			 */
+			AMP_PRX_APP_ERR_STAT_INC(err_null_in_cookie_list);
+			ulog_error_no_conn(AMP_ULOG_HTTP_PROXY, "null strings in cookie list");
+		}
+	}			/* TAILQ_FOREACH */
+
+	return HTTP_SUCCESS;
+}
+
+int
 selective_copy_proxy_lists_for_slb(uproxy_t *proxy_p)
 {
-	if (selective_copy_list_of_cookie_nodes(&(proxy_p->cookie_list)) != HTTP_SUCCESS) {
+	if (selective_copy_tailq_of_cookie_nodes(&(proxy_p->cookie_list)) != HTTP_SUCCESS) {
 		AMP_PRX_APP_ERR_STAT_INC(err_verify_cookies);
 		hp_error("failed to copy  cookie list");
 		return HTTP_FAIL;
@@ -542,6 +638,43 @@
 		SLIST_REMOVE_HEAD(cookie_list_p, next_p);
 		if (node_p->header_frame_malloc) {
 			parser_frame_chain_free(node_p->name_frame_p);
+		},m
+		if (node_p->value_frame_malloc) {
+			parser_frame_chain_free(node_p->value_frame_p);
+		}
+
+		/*
+		 * check if additional buffers were allocated and free them
+		 */
+		switch (node_p->fl_malloc) {
+		case COOKIE_NAME_MALLOC:
+			STRING_FREE(node_p->name_p);
+			break;
+		case COOKIE_VALUE_MALLOC:
+			STRING_FREE(node_p->value_p);
+			break;
+		case COOKIE_NAME_VALUE_MALLOC:
+			STRING_FREE(node_p->name_p);
+			STRING_FREE(node_p->value_p);
+			break;
+		default:
+			break;	/* COOKIE_NO_MALLOC */
+		}
+		COOKIE_NODE_FREE(node_p);
+	}
+	SLIST_INIT(cookie_list_p);
+}
+
+void
+destroy_tailq_of_cookie_nodes(struct cookie_tailq_head *cookie_list_p)
+{
+	cookie_tailq_node_t *node_p;
+
+	while (!TAILQ_EMPTY(cookie_list_p)) {
+		node_p = TAILQ_FIRST(cookie_list_p);
+		TAILQ_REMOVE(cookie_list_p, node_p, next_p);
+		if (node_p->header_frame_malloc) {
+			parser_frame_chain_free(node_p->name_frame_p);
 		}
 		
 		if (node_p->value_frame_malloc) {
@@ -565,15 +698,15 @@
 		default:
 			break;	/* COOKIE_NO_MALLOC */
 		}
-		COOKIE_NODE_FREE(node_p);
+		COOKIE_TAILQ_NODE_FREE(node_p);
 	}
-	SLIST_INIT(cookie_list_p);
+	TAILQ_INIT(cookie_list_p);
 }
 
 void
 destroy_cookie_list(uproxy_t *proxy_p)
 {
-	destroy_list_of_cookie_nodes(&(proxy_p->cookie_list));
+	destroy_tailq_of_cookie_nodes(&(proxy_p->cookie_list));
 }
 
 void
@@ -700,7 +833,7 @@
 	proxy_p->serverconnip = 0;
 	proxy_p->serverconnip6 = in6addr_any;
 	
-	SLIST_INIT(&proxy_p->cookie_list);
+	TAILQ_INIT(&proxy_p->cookie_list);
 	SLIST_INIT(&proxy_p->custom_header_list);
 	SLIST_INIT(&proxy_p->set_cookie_list);
 	SLIST_INIT(&proxy_p->resp_custom_header_list);
@@ -2973,16 +3106,16 @@
 
 	if (slb_vs_p) {
 		vs_xforwarded_flag = slb_vs_p->enable_xforwarded_flag;
-		vs_xforwarded_name = slb_vs_p->xforwarded_name;
-		vs_xforwarded_chain = FLAG_ISSET(slb_vs_p->flags, SLV_VS_XFORWARDEDFOR_CHAIN) ? TRUE : FALSE;
-		vs_xforwarded_port_support = slb_vs_p->xforwarded_port_support;
-		if (slb_vs_p->insert_sip && prxconfig->enable_xforw_for_insert && vs_xforwarded_flag) {
-			client_ip_str = AMP_FORWARD_IP_STR(PROXY_CONNP(client_conn_data), ipstr, MAX_IP_STR_LEN);
-		} else if (FLAG_ISSET(slb_vs_p->extflags, SLB_VS_SUPPORT_PROXY_PROTOCOL)) {
-			client_ip_str = AMP_PROXY_PROTOCOL_IP_STR(PROXY_CONNP(client_conn_data), ipstr, MAX_IP_STR_LEN);
-		}
-		
-	} else {
+		vs_xforwarded_name = slb_vs_p->xforwarded_name;
+		vs_xforwarded_chain = FLAG_ISSET(slb_vs_p->flags, SLV_VS_XFORWARDEDFOR_CHAIN) ? TRUE : FALSE;
+		vs_xforwarded_port_support = slb_vs_p->xforwarded_port_support;
+		if (slb_vs_p->insert_sip && prxconfig->enable_xforw_for_insert && vs_xforwarded_flag) {
+			client_ip_str = AMP_FORWARD_IP_STR(PROXY_CONNP(client_conn_data), ipstr, MAX_IP_STR_LEN);
+		} else if (FLAG_ISSET(slb_vs_p->extflags, SLB_VS_SUPPORT_PROXY_PROTOCOL)) {
+			client_ip_str = AMP_PROXY_PROTOCOL_IP_STR(PROXY_CONNP(client_conn_data), ipstr, MAX_IP_STR_LEN);
+		}
+		
+	} else {
 		vs_xforwarded_flag = FALSE;
 	}
 	
Index: /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/parser.h
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/parser.h	(revision 40197)
+++ /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/parser.h	(working copy)
@@ -393,6 +393,7 @@
 void init_req_info(req_info_t *req_info_p);
 int permit_http_host(uint8_t *host_p, int host_len);
 cookie_node_t *cookie_node_alloc_init(void);
+cookie_tailq_node_t *cookie_tailq_node_alloc_init(void);
 
 /* public inline functions */
 static __inline void
Index: /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/parser.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/parser.c	(revision 40197)
+++ /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/parser.c	(working copy)
@@ -551,9 +551,9 @@
 	}
 	if (FLAG_ISSET(prxconfig->proxy_logtype, LOG_CUSTOM) ||
 		FLAG_ISSET(prxconfig->proxy_logtype, LOG_APP_VISUAL)) {
-		cookie_node_t *node_p = NULL;			
+		cookie_tailq_node_t *node_p = NULL;
 		/* cookie is only used for custom and app visual log */
-		if ((node_p = SLIST_FIRST(&(proxy_p->cookie_list)))) {
+		if ((node_p = TAILQ_FIRST(&(proxy_p->cookie_list)))) {
 			if (node_p->header_p) {        /* cookie is not NULL */
 				/* 
 				 * Cookies can be very large so 
Index: /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/parser_utils.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/parser_utils.c	(revision 40197)
+++ /branches/rel_apv_10_7/usr/click/lib/libhttp_proxy/parser_utils.c	(working copy)
@@ -1061,6 +1061,25 @@
 	}
 }
 
+cookie_tailq_node_t *
+cookie_tailq_node_alloc_init(void)
+{
+	cookie_tailq_node_t *node_p;
+
+	node_p = COOKIE_TAILQ_NODE_ALLOC();
+
+	if (!node_p) {
+		hp_error("Could not allocate a cookie node");
+		return NULL;
+	} else {
+		bzero(node_p, sizeof(cookie_tailq_node_t));
+
+		node_p->fl_malloc = COOKIE_NO_MALLOC;
+		TAILQ_NEXT(node_p, next_p) = NULL;
+		return node_p;
+	}
+}
+
 void
 destroy_last_setcookie_node(uproxy_t *proxy_p)
 {
@@ -4958,12 +4977,14 @@
 	     BOOL *end_of_frames,
 	     uproxy_t *proxy_p, 
 	     struct read_write_info *rwp,
-	     BOOL *cookie_node_malloced)
+	     BOOL *cookie_node_malloced,
+	     cookie_tailq_node_t **first_name_value_pair_node_pp)
 {
 	uint16_t token;
 	BOOL skip_read = FALSE;
 	uint32_t tab_space_len = 0, quote_start_len = 0;
-	cookie_node_t *cookie_node_p = NULL;
+	cookie_tailq_node_t *cookie_node_p = NULL;
+	BOOL fl_first_name_value_pair = TRUE;
 
 	token = skip_lws(rwp, headers_len, end_of_frames);
 
@@ -4979,16 +5000,27 @@
 
 		switch (token) {
 		case HTTP_COOKIE_NAME_START:
-			cookie_node_p = cookie_node_alloc_init();
+			cookie_node_p = cookie_tailq_node_alloc_init();
 			if (cookie_node_p) {
 				cookie_node_p->name_p = rwp->wr_p;
 				cookie_node_p->name_frame_p =
 					rwp->wr_frame_p;
 				cookie_node_p->name_len = 1;
-				SLIST_INSERT_HEAD(&(proxy_p->cookie_list),
+				TAILQ_INSERT_TAIL(&(proxy_p->cookie_list),
 						  cookie_node_p, next_p);
 				*cookie_node_malloced = TRUE;
 				proxy_p->cookie_count++;
+				if (fl_first_name_value_pair) {
+				  /*
+				   * remember the node containing first name-value pair
+				   * in this cookie so the caller can store overall
+				   * cookie header in this node, this is needed since
+				   * are nodes are added at the end, but we want to save
+				   * the header info in the first node of each cookie header
+				   */
+				  *first_name_value_pair_node_pp = cookie_node_p;
+				  fl_first_name_value_pair = FALSE;
+				}
 			}
 			break;
 		case HTTP_COOKIE_NAME_SKIP:
@@ -5533,6 +5565,7 @@
 	int cookie_hdr_count = 0;
 	uint32_t hdr_value_offset;
 	uint8_t *str_p = NULL;
+	cookie_tailq_node_t *first_node_p; /* node with the first name-value pair of the cookie header */
 
 
 //#ifdef SERVER_CONN_IP_TANYA
@@ -5824,13 +5857,13 @@
 					hdr_value_offset = rwp->new_headers_len;
 
 					retval = parse_cookie(headers_len, &end_of_frames, proxy_p,
-							      rwp, &cookie_node_malloced);
-					/* nodes are added to the head, 1st one is the last one added */
-					node_p = SLIST_FIRST(&(proxy_p->cookie_list));
-					if (node_p) {
-						node_p->header_p = header_start_p;
-						node_p->header_frame_p = header_start_frame_p;
-						node_p->header_len = header_len_calc(retval,
+							      rwp, &cookie_node_malloced, &first_node_p);
+					/* nodes are added to the tail, save the general header info in the node with first
+					   name value pair which is set by the parse function */
+					if (first_node_p) {
+						first_node_p->header_p = header_start_p;
+						first_node_p->header_frame_p = header_start_frame_p;
+						first_node_p->header_len = header_len_calc(retval,
 										     rwp->new_headers_len, 
 										     header_start, rwp);
 						HTTP_FLAG_SET(proxy_p->cache_metadata_p->flags, HTTP_CMETA_REQ_COOKIE);
@@ -5846,12 +5879,14 @@
 						}
 					}
 
-#ifdef COOKIE_DEBUG
-					SLIST_FOREACH(node_p, &(proxy_p->cookie_list), next_p) {
-						ulog_error_no_conn(AMP_ULOG_HTTP_PROXY, "Cookie name: %.*s, value: %.*s\n", node_p->name_len, node_p->name_p,
-							node_p->value_len, node_p->value_p);
+//#ifdef COOKIE_DEBUG
+					TAILQ_FOREACH(first_node_p, &(proxy_p->cookie_list), next_p) {
+						ulog_error_no_conn(AMP_ULOG_HTTP_PROXY,
+								   "hdr frame %p, Cookie name: %.*s, value: %.*s\n",
+								   first_node_p->header_p, first_node_p->name_len, first_node_p->name_p,
+								   first_node_p->value_len, first_node_p->value_p);
 					}
-#endif
+//#endif
 
 					break;
 				case HTTP_REQ_HDRS_DATE:
Index: /branches/rel_apv_10_7/usr/click/lib/libsmanager/sec_sso_post.h
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libsmanager/sec_sso_post.h	(revision 40197)
+++ /branches/rel_apv_10_7/usr/click/lib/libsmanager/sec_sso_post.h	(working copy)
@@ -36,6 +36,7 @@
 struct conn_entry;
 struct url_host;
 struct cookie_list_head;
+struct cookie_tailq_head;
 
 void complete_response_process_sso_post(struct conn_entry *server_conn_p,
                                            struct uproxy_type *proxy_p);
@@ -46,6 +47,6 @@
 int sec_handle_sso_post_response(struct uproxy_conn_data *server_conn_data,
                              struct uproxy_conn_data *client_conn_data,
                              int resp_status_code);
-int sso_post_buffer_set_cookie(struct cookie_list_head *src_cookie_list,
+int sso_post_buffer_set_cookie(struct cookie_tailq_head *src_cookie_list,
         struct cookie_list_head *dst_cookie_list);
 #endif /* _SEC_SSO_POST_H_ */
Index: /branches/rel_apv_10_7/usr/click/lib/libsmanager/sec_sso_post.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libsmanager/sec_sso_post.c	(revision 40197)
+++ /branches/rel_apv_10_7/usr/click/lib/libsmanager/sec_sso_post.c	(working copy)
@@ -864,12 +864,13 @@
  * backend server.
  */
 int
-sso_post_buffer_set_cookie(struct cookie_list_head *src_cookie_list,
+sso_post_buffer_set_cookie(struct cookie_tailq_head *src_cookie_list,
         struct cookie_list_head *dst_cookie_list)
 {
-    cookie_node_t *node_p, *new_node_p;
+    cookie_tailq_node_t *node_p;
+    cookie_node_t *new_node_p;
 
-    SLIST_FOREACH(node_p, src_cookie_list, next_p) {
+    TAILQ_FOREACH(node_p, src_cookie_list, next_p) {
 	    SLIST_FOREACH(new_node_p, dst_cookie_list, next_p) {
 			if (strncmp(new_node_p->name_p, node_p->name_p, new_node_p->name_len) == 0 &&
 				new_node_p->name_len == node_p->name_len) {
@@ -958,22 +959,23 @@
     struct frame *new_frame_p = *n_frame_p;
     uint8_t *write_p = *w_p;
 
-    struct cookie_list_head *cookie_list_p;
+    struct cookie_tailq_head *cookie_list_p;
     struct cookie_list_head *set_cookie_list_p = &proxy_p->sso_post_set_cookie_list;
 
-    cookie_node_t *cookie_node_p, *set_cookie_node_p;
+    cookie_tailq_node_t *cookie_node_p;
+    cookie_node_t *set_cookie_node_p;
     BOOL first_cookie = TRUE;
     char *name = NULL;
     char *value = NULL;
 
     cookie_list_p = &proxy_p->sso_post_cookie_list;
 
-    if (SLIST_EMPTY(cookie_list_p) && SLIST_EMPTY(set_cookie_list_p)) {
+    if (TAILQ_EMPTY(cookie_list_p) && SLIST_EMPTY(set_cookie_list_p)) {
         return TRUE;
     }
 
-    if (!SLIST_EMPTY(cookie_list_p) && !SLIST_EMPTY(set_cookie_list_p)) {
-        SLIST_FOREACH(cookie_node_p, cookie_list_p, next_p) {
+    if (!TAILQ_EMPTY(cookie_list_p) && !SLIST_EMPTY(set_cookie_list_p)) {
+        TAILQ_FOREACH(cookie_node_p, cookie_list_p, next_p) {
             SLIST_FOREACH(set_cookie_node_p, set_cookie_list_p, next_p) {
                 if (strcmp(set_cookie_node_p->name_p, cookie_node_p->name_p) == 0) {
                     /* when find one set-cookie node has the same name with the old
@@ -1023,8 +1025,8 @@
         if (!SLIST_EMPTY(set_cookie_list_p)) {
             goto new_cookie_list;
         }
-    } else if (!SLIST_EMPTY(cookie_list_p)) {
-        SLIST_FOREACH(cookie_node_p, cookie_list_p, next_p) {
+    } else if (!TAILQ_EMPTY(cookie_list_p)) {
+        TAILQ_FOREACH(cookie_node_p, cookie_list_p, next_p) {
             if (first_cookie == TRUE) {
                 /* "Cookie:" */
                 if (write_data(SSO_POST_COOKIE_PREFIX, &write_p,
Index: /branches/rel_apv_10_7/usr/click/lib/libsmanager/smanager_states.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libsmanager/smanager_states.c	(revision 40197)
+++ /branches/rel_apv_10_7/usr/click/lib/libsmanager/smanager_states.c	(working copy)
@@ -674,10 +674,10 @@
 {
 	/* Init smanager data structure */
 	smanager_data_t *sec_data = sm_data_p->smanager_data;
-	cookie_node_t *node_p;
+	cookie_tailq_node_t *node_p;
 
 	/* Todo: refactor this function */
-	SLIST_FOREACH(node_p, &(sec_data->proxy_p->cookie_list), next_p) {
+	TAILQ_FOREACH(node_p, &(sec_data->proxy_p->cookie_list), next_p) {
 		if (SLEN(SEC_AN_BOOKMARK_COOKIE_NAME) == node_p->name_len) {
 			if ((0 == parser_frame_chain_strncmp((uint8_t *)SEC_AN_BOOKMARK_COOKIE_NAME,
 								node_p->name_p, node_p->name_len, node_p->name_frame_p)) &&
@@ -875,7 +875,7 @@
 {
 	uint8_t ret_val = 0;
 	smanager_data_t *sec_data = sm_data_p->smanager_data;
-	cookie_node_t *node_p;
+	cookie_tailq_node_t *node_p;
 	char tmp_name[SEC_COOKIE_SESSION_NAME_PREFIX_LEN + CLICK_ID_LENGTH + 1];
 	char *name_p;
 	char tmp_value[SLB_NAME_MAX_LEN + 1 + SESSION_AUTH_SESSIONID_STR_LEN + 1 + SESSION_AUTH_SIGNATURE_LEN];
@@ -884,7 +884,7 @@
 
 	sec_data->session_id = INVALID_SESSION_ID;
 
-	SLIST_FOREACH(node_p, &(sec_data->proxy_p->cookie_list), next_p) {
+	TAILQ_FOREACH(node_p, &(sec_data->proxy_p->cookie_list), next_p) {
 		if ((sec_cookie_session_name_length == node_p->name_len) &&
 			(0 == parser_frame_chain_strncmp((uint8_t *)sec_cookie_session_name,
 								node_p->name_p, node_p->name_len, node_p->name_frame_p))) {
Index: /branches/rel_apv_10_7/usr/src/sys/click/app/proxy/proxy.h
===================================================================
--- /branches/rel_apv_10_7/usr/src/sys/click/app/proxy/proxy.h	(revision 40197)
+++ /branches/rel_apv_10_7/usr/src/sys/click/app/proxy/proxy.h	(working copy)
@@ -980,6 +980,54 @@
 /* head of the list of cookie nodes */
 SLIST_HEAD(cookie_list_head, cookie_node);
 
+/*
+ * node for_cookie lists, the cookies need to be eximined as they were listed in the header,
+ * so they need be stored in a queue and not in the stack/slist as before,
+ * no change the set-cookie and other header lists
+ */
+typedef struct cookie_tailq_node {
+	struct frame *header_frame_p;	/* frame where header starts */
+	uint8_t *header_p;	/* pointer to the header */
+	uint32_t header_len;	/* header length */
+
+	struct frame *name_frame_p;/* frame where name starts */
+	uint8_t *name_p;	   /* pointer to the name */
+	uint8_t *original_name_p;  /* pointer to the original name if name_p pointer
+				      to the new malloced name */
+	uint32_t name_len;	/* name length */
+
+	struct frame *value_frame_p;	/* frame where value starts */
+	uint8_t *value_p;	/* pointer to the value */
+	uint8_t *original_value_p;  /* pointer to the original value if value_p pointer
+				       to the new malloced name */
+	uint32_t value_len;	/* value length */
+	uint32_t directives_len; /*directives length*/
+
+	TAILQ_ENTRY(cookie_tailq_node) next_p;	/* next pointer */
+	cookieMalloc_e fl_malloc;	/* see cookieMalloc_e */
+	uint8_t	header_frame_malloc;
+	uint8_t value_frame_malloc;
+	/*
+	 * only for nodes in the cookie_list; when we need to erase set-cookie
+	 * header we will erase all of them and so we do not care if we have
+	 * more than one name=value pair in the header
+	 */
+	uint8_t cookie_cnt;	/* cookie number */
+
+	BOOL fl_secure_set_cookie;
+	BOOL fl_secure_set_icookie;
+	BOOL fl_samesite_set_cookie;
+	BOOL fl_samesite_rewrited;
+	int samesite_value_type;
+	uint8_t *modify_location;
+	int fl_grp_opt_samesite;
+	int fl_grp_opt_secure; /* For CLI slb group option ic, the value is GROUP_OPT_IC_SECURE_INIT -1,
+				GROUP_OPT_IC_SECURE_NO 0, GROUP_OPT_IC_SECURE_YES 1 */
+} cookie_tailq_node_t;
+
+/* head of the queue cookie nodes */
+TAILQ_HEAD(cookie_tailq_head, cookie_tailq_node);
+
 /* 
  * compression uagent data structure,
  * which should be keep consistent with those in kernel(proxy_cache.h)
Index: /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_interface.h
===================================================================
--- /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_interface.h	(revision 40197)
+++ /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_interface.h	(working copy)
@@ -27,7 +27,9 @@
 #include <click/netinet/click_utils.h>
 
 struct cookie_list_head;
+struct cookie_tailq_head;
 struct cookie_node;
+struct cookie_tailq_node;
 struct copied_header;
 
 #define IS_CONNREUSE_OFF(slb_rs_p) \
@@ -74,8 +76,8 @@
 slb_rs_t *slb_dnssec_rs_lookup(slb_vs_t *vs_p, slb_l4_args_t *slb_args);
 slb_rs_t *slb_dnssec_rs_lookup6(slb_vs_t *vs_p, slb_l4_args_t *slb_args);
 
-struct cookie_node
-*slb_find_rewrite_cookie(struct cookie_list_head *cookie_list,
+struct cookie_tailq_node
+*slb_find_rewrite_cookie(struct cookie_tailq_head *cookie_list,
                         slb_membership_t *slb_membership);
 
 /* bug 14426, zhangwy, 2006/09/19 */                                           
@@ -99,39 +101,39 @@
                    char *url, uint32_t url_len,
                    char *hostname, uint32_t hostname_len,
                    char *sslsid, uint32_t sslsid_len,
-                   struct cookie_list_head *cookie_list,
+                   struct cookie_tailq_head *cookie_list,
                    struct cookie_list_head *cust_hdr_list,
                    BOOL *request_cacheable,
                    uint32_t source_ip, struct in6_addr *ip6, uint16_t source_port,
                    struct copied_header *standard_headers,
                    uint32_t member_hint, uint32_t hint_id,
                    /* bug 14426, zhangwy, 2006/09/19 */
-                   struct cookie_node ** embeded_cookie_p,
-                   struct cookie_node ** insert_cookie_p,
-                   uint32_t *persistent_rid, 
-                   struct frame *body_first_p,
-                   struct frame *body_last_p, int chunked,
-                   int *error, int *hit_icookie, int is_deny);
-
-/*bug 23075, 2009/07/22*/
-slb_membership_t *
+                   struct cookie_tailq_node ** embeded_cookie_p,
+                   struct cookie_tailq_node ** insert_cookie_p,
+                   uint32_t *persistent_rid, 
+                   struct frame *body_first_p,
+                   struct frame *body_last_p, int chunked,
+                   int *error, int *hit_icookie, int is_deny);
+
+/*bug 23075, 2009/07/22*/
+slb_membership_t *
 slb_policy_nesting_lookup(int depth, slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
                   char *sslsid, uint32_t sslsid_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
                   struct cookie_list_head *cust_hdr_list,
                   BOOL *request_cacheable,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header *standard_headers,
                   int *had_match, slb_membership_t *hint,
                   /* bug 14426, zhangwy, 2006/09/19 */
-		  struct cookie_node ** embeded_cookie_p,
-		  struct cookie_node ** insert_cookie_p,
-		  uint32_t *persistent_rid, struct frame *body_first_p,
-                  struct frame *body_last_p, int chunked, 
-                  int *error, int *hit_icookie, int is_deny);
-/*End of bug 23075*/
-
+		  struct cookie_tailq_node ** embeded_cookie_p,
+		  struct cookie_tailq_node ** insert_cookie_p,
+		  uint32_t *persistent_rid, struct frame *body_first_p,
+                  struct frame *body_last_p, int chunked, 
+                  int *error, int *hit_icookie, int is_deny);
+/*End of bug 23075*/
+
 slb_membership_t* doh_get_membership(slb_vs_t *vs_p, 
 						   				  uint32_t source_ip, 
 						  				  struct in6_addr *source_ip6, 
@@ -154,7 +156,7 @@
 slb_membership_t *
 slb_membership_lookup(uint32_t gpid, char *hostname, uint32_t hostname_len,
                       char *persistence_val, uint32_t persistence_len,
-                      struct cookie_list_head *cookie_list,
+                      struct cookie_tailq_head *cookie_list,
                       struct cookie_list_head *cust_hdr_list,
                       struct copied_header *standard_headers,
                       uint32_t source_ip, struct in6_addr * source_ip6,
Index: /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_rs_group.h
===================================================================
--- /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_rs_group.h	(revision 40197)
+++ /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_rs_group.h	(working copy)
@@ -28,6 +28,7 @@
 #define curr_thread_hits                  thread_misc[slb_idx].hits
 
 struct cookie_list_head;
+struct cookie_tailq_head;
 struct copied_header;
 
 /* bug 16837,2007/09/18 */
@@ -631,7 +632,7 @@
 slb_membership_t *
 slb_rs_persistence_lookup(uint32_t gid, char *hostname, uint32_t hostname_len,
                       char *persistence_val, uint32_t persistence_len,
-                      struct cookie_list_head *cookie_list,
+                      struct cookie_tailq_head *cookie_list,
                       struct cookie_list_head *cust_hdr_list,
                       struct copied_header * standard_headers,
                       uint32_t source_ip, struct in6_addr * source_ip6, 
@@ -649,7 +650,7 @@
 int 
 slb_find_session_in_header(
 			slb_group_persistent_setting_t * persistent_setting_p,
-			struct cookie_list_head *cookie_list,
+			struct cookie_tailq_head *cookie_list,
 			struct cookie_list_head *cust_hdr_list,
                       struct copied_header *standard_headers,
                       char ** persistence_value_p);
Index: /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_rs_group_shared.c
===================================================================
--- /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_rs_group_shared.c	(revision 40197)
+++ /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_rs_group_shared.c	(working copy)
@@ -3457,7 +3457,7 @@
 slb_membership_t *
 slb_membership_lookup(uint32_t gpid, char *hostname, uint32_t hostname_len,
                       char *persistence_val, uint32_t persistence_len,
-                      struct cookie_list_head *cookie_list,
+                      struct cookie_tailq_head *cookie_list,
                       struct cookie_list_head *cust_hdr_list,
                       struct copied_header standard_headers[],
                       uint32_t source_ip, struct in6_addr * source_ip6,
@@ -4245,12 +4245,12 @@
 * SEE ALSO
 * SOURCE
 */
-cookie_node_t *
-slb_find_rewrite_cookie(struct cookie_list_head *cookie_list,
+cookie_tailq_node_t *
+slb_find_rewrite_cookie(struct cookie_tailq_head *cookie_list,
                         slb_membership_t *slb_membership)
 {
-    cookie_node_t *cookie_node;
-    SLIST_FOREACH( cookie_node, cookie_list, next_p ) {
+    cookie_tailq_node_t *cookie_node;
+    TAILQ_FOREACH( cookie_node, cookie_list, next_p ) {
         if (cookie_node->name_len == strlen(slb_group_table[slb_membership->gid].cookie_name) &&	/* bug 18418, 2008/01/18*/
              strncmp( (char *)(cookie_node->name_p),
                      slb_group_table[slb_membership->gid].cookie_name,
@@ -5714,11 +5714,11 @@
 }
 
 static int
-slb_find_session_cookie(struct cookie_list_head *cookie_list,
+slb_find_session_cookie(struct cookie_tailq_head *cookie_list,
                         char * cookie_name, char ** persistence_value)
 {
-    cookie_node_t *cookie_node;
-    SLIST_FOREACH( cookie_node, cookie_list, next_p) {
+    cookie_tailq_node_t *cookie_node;
+    TAILQ_FOREACH( cookie_node, cookie_list, next_p) {
         if (cookie_node->name_len == strlen(cookie_name) &&	
              strncasecmp( (char *)(cookie_node->name_p),
                      cookie_name, cookie_node->name_len) == 0) {
@@ -5990,7 +5990,7 @@
 
 int slb_find_session_in_header(
 			slb_group_persistent_setting_t * persistent_setting_p,
-			struct cookie_list_head *cookie_list,
+			struct cookie_tailq_head *cookie_list,
 			struct cookie_list_head *cust_hdr_list,
                       struct copied_header standard_headers[],
                       char ** persistence_value_p)
@@ -6054,7 +6054,7 @@
 static BOOL 
 slb_get_session_id_in_header(uint32_t gpid, 
 			slb_group_persistent_setting_t * persistent_setting_p,
-			struct cookie_list_head *cookie_list,
+			struct cookie_tailq_head *cookie_list,
 			struct cookie_list_head *cust_hdr_list,
                       struct copied_header standard_headers[],
                       session_key_t * session_key_p)
@@ -6726,7 +6726,7 @@
 slb_membership_t *
 slb_rs_persistence_lookup(uint32_t gpid, char *hostname, uint32_t hostname_len,
                       char *persistence_val, uint32_t persistence_len,
-                      struct cookie_list_head *cookie_list,
+                      struct cookie_tailq_head *cookie_list,
                       struct cookie_list_head *cust_hdr_list,
                       struct copied_header standard_headers[],
                       uint32_t source_ip, struct in6_addr * source_ip6, 
Index: /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_shared.c
===================================================================
--- /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_shared.c	(revision 40197)
+++ /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_shared.c	(working copy)
@@ -148,22 +148,22 @@
 				   char *url, uint32_t url_len,
 				   char *hostname, uint32_t hostname_len,
 				   char *sslsid, uint32_t sslsid_len,
-				   struct cookie_list_head *cookie_list,
+				   struct cookie_tailq_head *cookie_list,
 				   struct cookie_list_head *cust_hdr_list,
 				   BOOL *request_cacheable,
 				   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
 				   struct copied_header standard_headers[],
 				   uint32_t member_hint, uint32_t hint_id,
 				   /* bug 14426, zhangwy, 2006/09/19 */
-				   struct cookie_node ** embeded_cookie_p,
-				   struct cookie_node ** insert_cookie_p,
-				   uint32_t *persistent_rid, 
-				   struct frame *body_first_p,
-				   struct frame *body_last_p, int chunked,
-				   int *error, int *hit_icookie, int is_deny)
-{
-	slb_membership_t *hint;
-	slb_membership_t *mem_p;
+				   struct cookie_tailq_node ** embeded_cookie_p,
+				   struct cookie_tailq_node ** insert_cookie_p,
+				   uint32_t *persistent_rid, 
+				   struct frame *body_first_p,
+				   struct frame *body_last_p, int chunked,
+				   int *error, int *hit_icookie, int is_deny)
+{
+	slb_membership_t *hint;
+	slb_membership_t *mem_p;
 	slb_rs_t *rs_p;
 	int had_match = 0; /* whether any policies were matched */
 	static char temp_url[1024];
@@ -230,13 +230,13 @@
 
     mem_p = slb_policy_nesting_lookup(0, vs_p, url, url_len, hostname, hostname_len, sslsid, sslsid_len,
                           cookie_list, cust_hdr_list, request_cacheable, 
-              		source_ip, source_ip6, source_port, standard_headers, &had_match, hint, 
-                          /* bug 14426, zhangwy, 2006/09/19 */
-			  embeded_cookie_p, insert_cookie_p, persistent_rid, 
-			  body_first_p, body_last_p, chunked, error, hit_icookie, is_deny);
-	if (mem_p!=NULL){
-		/* policy statistics already updated in slb_policy_lookup() */
-		return mem_p->id;
+              		source_ip, source_ip6, source_port, standard_headers, &had_match, hint, 
+                          /* bug 14426, zhangwy, 2006/09/19 */
+			  embeded_cookie_p, insert_cookie_p, persistent_rid, 
+			  body_first_p, body_last_p, chunked, error, hit_icookie, is_deny);
+	if (mem_p!=NULL){
+		/* policy statistics already updated in slb_policy_lookup() */
+		return mem_p->id;
 	}			  
     
 	/* absolutely nothing matched - oh well */
@@ -292,22 +292,22 @@
 				   char *url, uint32_t url_len,
 				   char *hostname, uint32_t hostname_len,
 				   char *sslsid, uint32_t sslsid_len,
-				   struct cookie_list_head *cookie_list,
+				   struct cookie_tailq_head *cookie_list,
 				   struct cookie_list_head *cust_hdr_list,
 				   BOOL *request_cacheable,
 				   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
 				   struct copied_header standard_headers[],
 				   uint32_t member_hint, uint32_t hint_id,
 				   /* bug 14426, zhangwy, 2006/09/19 */
-				   struct cookie_node ** embeded_cookie_p,
-				   struct cookie_node ** insert_cookie_p,
-				   uint32_t *persistent_rid, 
-				   struct frame *body_first_p,
-				   struct frame *body_last_p, int chunked,
-				   int *error, int *hit_icookie, int is_deny)
-{
-	uint32_t memid;
-	slb_membership_t *memp;
+				   struct cookie_tailq_node ** embeded_cookie_p,
+				   struct cookie_tailq_node ** insert_cookie_p,
+				   uint32_t *persistent_rid, 
+				   struct frame *body_first_p,
+				   struct frame *body_last_p, int chunked,
+				   int *error, int *hit_icookie, int is_deny)
+{
+	uint32_t memid;
+	slb_membership_t *memp;
 	
 	if (error != NULL) {
 		*error = SLB_LOOKUP_OK; /* default */
@@ -315,13 +315,13 @@
 
 	memid = slb_client_request_uproxy_core(vs_p,
 		url, url_len, hostname, hostname_len, sslsid, sslsid_len,
-		cookie_list, cust_hdr_list, request_cacheable,
-		source_ip, source_ip6, source_port, standard_headers, member_hint, hint_id,
-		embeded_cookie_p, insert_cookie_p, persistent_rid, 
-		body_first_p, body_last_p, chunked, error, hit_icookie, is_deny);
-
-	if (memid != SLB_INVALID_MEM_ID) {
-		memp = slb_get_membership_by_id(memid);
+		cookie_list, cust_hdr_list, request_cacheable,
+		source_ip, source_ip6, source_port, standard_headers, member_hint, hint_id,
+		embeded_cookie_p, insert_cookie_p, persistent_rid, 
+		body_first_p, body_last_p, chunked, error, hit_icookie, is_deny);
+
+	if (memid != SLB_INVALID_MEM_ID) {
+		memp = slb_get_membership_by_id(memid);
 		if (memp) {
 			if (!SLB_RSVS_COMPAT(&slb_rs_table[memp->rid], vs_p)) {
 				return SLB_INVALID_MEM_ID;
Index: /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_vs_policy_shared.c
===================================================================
--- /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_vs_policy_shared.c	(revision 40197)
+++ /branches/rel_apv_10_7/usr/src/sys/click/app/slb/slb_vs_policy_shared.c	(working copy)
@@ -104,12 +104,12 @@
 void
 slb_policy_qclientport_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -117,12 +117,12 @@
 void
 slb_policy_qnetwork_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -131,12 +131,12 @@
 void
 slb_policy_purl_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -145,12 +145,12 @@
 void           	             	  
 slb_policy_cookie_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -159,12 +159,12 @@
 void
 slb_policy_qcookie_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -173,12 +173,12 @@
 void
 slb_policy_qhost_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -187,12 +187,12 @@
 void
 slb_policy_qurl_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -201,12 +201,12 @@
 void
 slb_policy_qbody_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -214,12 +214,12 @@
 void
 slb_policy_regex_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -228,12 +228,12 @@
 void
 slb_policy_header_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -242,12 +242,12 @@
 void
 slb_policy_hashurl_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked);
@@ -275,12 +275,12 @@
 
 typedef void policy_lookup_func_t(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip,struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked);
@@ -731,12 +731,12 @@
 void
 slb_policy_qclientport_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6,uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -805,12 +805,12 @@
 void
 slb_policy_qnetwork_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked)
@@ -872,12 +872,12 @@
 void
 slb_policy_purl_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree,policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked)
@@ -963,29 +963,29 @@
 void
 slb_policy_qcookie_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree, policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked)
 {
 	slb_policy_t * policy_p;
 	patricia_node_t *pat_node;
-	cookie_node_t *cookie_p;
+	cookie_tailq_node_t *cookie_p;
 	regex_node_t *best_match_in_list;
 	regex_node_t *curr_node;
 	struct regex_result_list *matched_list;
 	slb_policy_t * policy_invert_p;
-	cookie_node_t *policy_invert_cookie_match;
+	cookie_tailq_node_t *policy_invert_cookie_match;
 	uint32_t precedence = DEFAULT_PRECEDENCE;
 	/* NOTE: k == POLICY_QOS_COOKIE at this point, because if the */
 	/* cookie for() loop above did not finish, then it must have  */
 	/* already returned, so we don't get here anyway.             */
-	SLIST_FOREACH(cookie_p, cookie_list, next_p) {
+	TAILQ_FOREACH(cookie_p, cookie_list, next_p) {
 			static char qos_cookie[SLB_COOKIE_MAX_LEN*2 + 2] = {0};
 			uint32_t qos_cookie_len;
 			/*
@@ -1107,12 +1107,12 @@
 void
 slb_policy_qhost_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree,policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked)
@@ -1228,19 +1228,19 @@
  * that we can check for simultaneously using the patricia tree
  * Output:
  * 	slb_policy_t *match[], 
- * 	cookie_node_t *cookie_match[],
+ *	cookie_tailq_node_t *cookie_match[],
  *	char * persistence_val, 
  *	int * persistence_len
  */
 void
 slb_policy_cookie_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree,policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -1248,11 +1248,11 @@
 {
 	slb_policy_t * policy_p;
 	patricia_node_t *pat_node;
-	cookie_node_t * cookie_p;
+	cookie_tailq_node_t * cookie_p;
 	int k;
 	
 	/* search for cookie matches */
-	SLIST_FOREACH(cookie_p, cookie_list, next_p) {
+	TAILQ_FOREACH(cookie_p, cookie_list, next_p) {
 		pat_node = patricia_insearch(pat_tree,
 		                             (char *)(cookie_p->name_p),
 		                             (int32_t)(cookie_p->name_len), 0);
@@ -1282,12 +1282,12 @@
 void
 slb_policy_qurl_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree,policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -1404,12 +1404,12 @@
 void
 slb_policy_qbody_lookup(slb_vs_t *vs_p,	char *url, uint32_t url_len,
 		char *hostname, uint32_t hostname_len,
-		struct cookie_list_head *cookie_list,
+		struct cookie_tailq_head *cookie_list,
 		struct cookie_list_head *cust_hdr_list,
 		uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
 		struct copied_header standard_headers[],
 		patricia_tree_t *pat_tree, policy_type_e type,
-		slb_policy_t *match[], cookie_node_t *cookie_match[],
+		slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
 		char ** persistence_val, int * persistence_len,
 		struct frame *body_first_p, struct frame *body_last_p,
 		int chunked
@@ -1439,12 +1439,12 @@
 void
 slb_policy_regex_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree,policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -1613,12 +1613,12 @@
 void
 slb_policy_header_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree,policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -1906,12 +1906,12 @@
 void
 slb_policy_hashurl_lookup(slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
 		  struct cookie_list_head *cust_hdr_list,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   patricia_tree_t *pat_tree,policy_type_e type,
-                  slb_policy_t *match[], cookie_node_t *cookie_match[],
+                  slb_policy_t *match[], cookie_tailq_node_t *cookie_match[],
                   char ** persistence_val, int * persistence_len,
                   struct frame *body_first_p, struct frame *body_last_p,
                   int chunked
@@ -2019,24 +2019,24 @@
 slb_policy_nesting_lookup(int depth, slb_vs_t *vs_p, char *url, uint32_t url_len,
                   char *hostname, uint32_t hostname_len,
                   char *sslsid, uint32_t sslsid_len,
-                  struct cookie_list_head *cookie_list,
+                  struct cookie_tailq_head *cookie_list,
                   struct cookie_list_head *cust_hdr_list,
                   BOOL *request_cacheable,
                   uint32_t source_ip, struct in6_addr *source_ip6, uint16_t source_port,
                   struct copied_header standard_headers[],
                   int *had_match, slb_membership_t *hint,
                   /* bug 14426, zhangwy, 2006/09/19 */
-		  struct cookie_node ** embeded_cookie_p,
-		  struct cookie_node ** insert_cookie_p,
-		  uint32_t *persistent_rid, 
-		  struct frame *body_first_p,
-		  struct frame *body_last_p, int chunked,
-		  int *error, int *hit_icookie, int is_deny)
-{
-	int type;
-	slb_policy_t *match[POLICY_COUNT];
+		  struct cookie_tailq_node ** embeded_cookie_p,
+		  struct cookie_tailq_node ** insert_cookie_p,
+		  uint32_t *persistent_rid, 
+		  struct frame *body_first_p,
+		  struct frame *body_last_p, int chunked,
+		  int *error, int *hit_icookie, int is_deny)
+{
+	int type;
+	slb_policy_t *match[POLICY_COUNT];
 	patricia_tree_t *pat_tree;
-	cookie_node_t *cookie_match[POLICY_COUNT];
+	cookie_tailq_node_t *cookie_match[POLICY_COUNT];
 	slb_membership_t *mem_p = NULL;
 	char real_gname[SLB_NAME_MAX_LEN+1] = {0};
 	
@@ -2139,13 +2139,13 @@
 					/*Do recursion policy lookup on the vlink*/	
 					mem_p = slb_policy_nesting_lookup(depth+1,
 					                   next_vlink, url, url_len,hostname, hostname_len, sslsid, sslsid_len,
-		                                           cookie_list, cust_hdr_list,request_cacheable,
-		                                           source_ip, source_ip6, source_port, standard_headers, had_match, hint,
-		                                           embeded_cookie_p, insert_cookie_p,  persistent_rid, 
-		                                           body_first_p, body_last_p, chunked, error, hit_icookie, is_deny);
-		                }else{
-		                	mem_p=NULL;
-		                }
+		                                           cookie_list, cust_hdr_list,request_cacheable,
+		                                           source_ip, source_ip6, source_port, standard_headers, had_match, hint,
+		                                           embeded_cookie_p, insert_cookie_p,  persistent_rid, 
+		                                           body_first_p, body_last_p, chunked, error, hit_icookie, is_deny);
+		                }else{
+		                	mem_p=NULL;
+		                }
 			} else {
 				/*if a policy hits a group, we set had_match to 1 without consider the group is up or down*/
 				*had_match = 1;
@@ -2238,17 +2238,17 @@
 			       "%s():%d vs|vlink %s did not match %s",
 			       __func__, __LINE__, vs_p->name, 
 			       slb_get_policy_str(type));
-		}
-	                                         
-	}/* end of for POLICY_COUNT*/
-
-	if (is_deny) {
-		englog(ENGLOG_SLB, SLB_ENGLOG_DEBUG, "because no hit cookie policy,so acl deny");
-		return NULL;
-	}
-	
-	/* if we still don't have a membership, check the default policy */
-	if (SLB_GROUP_ID_VALID(vs_p->default_group_id)){
+		}
+	                                         
+	}/* end of for POLICY_COUNT*/
+
+	if (is_deny) {
+		englog(ENGLOG_SLB, SLB_ENGLOG_DEBUG, "because no hit cookie policy,so acl deny");
+		return NULL;
+	}
+	
+	/* if we still don't have a membership, check the default policy */
+	if (SLB_GROUP_ID_VALID(vs_p->default_group_id)){
 		/*default policy match*/
 		if (SLB_GROUP_IS_VLINK(vs_p->default_group_id)){
 			slb_vs_t * next_vlink = slb_group_table[vs_p->default_group_id].vlink_p;
@@ -2257,13 +2257,13 @@
 				/*Do recursion policy lookup on the vlink*/	
 				mem_p = slb_policy_nesting_lookup(depth+1,
 			                   next_vlink, url, url_len,hostname, hostname_len, sslsid, sslsid_len,
-		                           cookie_list, cust_hdr_list,request_cacheable,
-		                           source_ip, source_ip6, source_port, standard_headers, had_match, hint,
-		                           embeded_cookie_p, insert_cookie_p,  persistent_rid, 
-		                           body_first_p, body_last_p, chunked, error, hit_icookie, is_deny);
-			} else {
-				mem_p = NULL;
-			}
+		                           cookie_list, cust_hdr_list,request_cacheable,
+		                           source_ip, source_ip6, source_port, standard_headers, had_match, hint,
+		                           embeded_cookie_p, insert_cookie_p,  persistent_rid, 
+		                           body_first_p, body_last_p, chunked, error, hit_icookie, is_deny);
+			} else {
+				mem_p = NULL;
+			}
 		} else{
 			/*if a policy hits a group, we set had_match to 1 without consider the group is up or down*/
 			*had_match = 1;
@@ -2347,13 +2347,13 @@
 				/*Do recursion policy lookup on the vlink*/	
 				mem_p = slb_policy_nesting_lookup(depth+1,
 				                   next_vlink, url, url_len,hostname, hostname_len, sslsid, sslsid_len,
-			                           cookie_list, cust_hdr_list,request_cacheable,
-			                           source_ip, source_ip6, source_port, standard_headers, had_match, hint,
-			                           embeded_cookie_p, insert_cookie_p,  persistent_rid, 
-			                           body_first_p, body_last_p, chunked, error, hit_icookie, is_deny);
-			}else{
-				mem_p = NULL;
-			}
+			                           cookie_list, cust_hdr_list,request_cacheable,
+			                           source_ip, source_ip6, source_port, standard_headers, had_match, hint,
+			                           embeded_cookie_p, insert_cookie_p,  persistent_rid, 
+			                           body_first_p, body_last_p, chunked, error, hit_icookie, is_deny);
+			}else{
+				mem_p = NULL;
+			}
 		} else if (slb_group_is_up_graceful(vs_p->backup_group_id)) {
 			/* search the backup group for a real service */
 			if ((slb_group_table[vs_p->backup_group_id].method == METHOD_PERSISTENCE_SESSION) &&
