View | Details | Raw Unified | Return to bug 172675 | Differences between
and this patch

Collapse All | Expand All

(-)src/sys/netinet/tcp_hostcache.c (-7 / +14 lines)
Lines 360-366 Link Here
360
		}
360
		}
361
		TAILQ_REMOVE(&hc_head->hch_bucket, hc_entry, rmx_q);
361
		TAILQ_REMOVE(&hc_head->hch_bucket, hc_entry, rmx_q);
362
		V_tcp_hostcache.hashbase[hash].hch_length--;
362
		V_tcp_hostcache.hashbase[hash].hch_length--;
363
		V_tcp_hostcache.cache_count--;
363
		atomic_subtract_int(&V_tcp_hostcache.cache_count, 1);
364
		TCPSTAT_INC(tcps_hc_bucketoverflow);
364
		TCPSTAT_INC(tcps_hc_bucketoverflow);
365
#if 0
365
#if 0
366
		uma_zfree(V_tcp_hostcache.zone, hc_entry);
366
		uma_zfree(V_tcp_hostcache.zone, hc_entry);
Lines 392-398 Link Here
392
	 */
392
	 */
393
	TAILQ_INSERT_HEAD(&hc_head->hch_bucket, hc_entry, rmx_q);
393
	TAILQ_INSERT_HEAD(&hc_head->hch_bucket, hc_entry, rmx_q);
394
	V_tcp_hostcache.hashbase[hash].hch_length++;
394
	V_tcp_hostcache.hashbase[hash].hch_length++;
395
	V_tcp_hostcache.cache_count++;
395
	atomic_add_int(&V_tcp_hostcache.cache_count, 1);
396
	TCPSTAT_INC(tcps_hc_added);
396
	TCPSTAT_INC(tcps_hc_added);
397
397
398
	return hc_entry;
398
	return hc_entry;
Lines 587-592 Link Here
587
static int
587
static int
588
sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
588
sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
589
{
589
{
590
	int alloclines;
590
	int bufsize;
591
	int bufsize;
591
	int linesize = 128;
592
	int linesize = 128;
592
	char *p, *buf;
593
	char *p, *buf;
Lines 595-602 Link Here
595
#ifdef INET6
596
#ifdef INET6
596
	char ip6buf[INET6_ADDRSTRLEN];
597
	char ip6buf[INET6_ADDRSTRLEN];
597
#endif
598
#endif
598
599
	
599
	bufsize = linesize * (V_tcp_hostcache.cache_count + 1);
600
	/* overallocate in case the host cache size changes while we're reading it */
601
	alloclines = V_tcp_hostcache.cache_count*3/2;
602
	bufsize = linesize * (alloclines + 1);
600
603
601
	p = buf = (char *)malloc(bufsize, M_TEMP, M_WAITOK|M_ZERO);
604
	p = buf = (char *)malloc(bufsize, M_TEMP, M_WAITOK|M_ZERO);
602
605
Lines 606-612 Link Here
606
	p += len;
609
	p += len;
607
610
608
#define msec(u) (((u) + 500) / 1000)
611
#define msec(u) (((u) + 500) / 1000)
609
	for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
612
	for (i = 0; i < V_tcp_hostcache.hashsize && alloclines > 0; i++) {
610
		THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
613
		THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
611
		TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket,
614
		TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket,
612
			      rmx_q) {
615
			      rmx_q) {
Lines 624-630 Link Here
624
			    msec(hc_entry->rmx_rtt *
627
			    msec(hc_entry->rmx_rtt *
625
				(RTM_RTTUNIT / (hz * TCP_RTT_SCALE))),
628
				(RTM_RTTUNIT / (hz * TCP_RTT_SCALE))),
626
			    msec(hc_entry->rmx_rttvar *
629
			    msec(hc_entry->rmx_rttvar *
627
				(RTM_RTTUNIT / (hz * TCP_RTT_SCALE))),
630
				(RTM_RTTUNIT / (hz * TCP_RTTVAR_SCALE))),
628
			    hc_entry->rmx_bandwidth * 8,
631
			    hc_entry->rmx_bandwidth * 8,
629
			    hc_entry->rmx_cwnd,
632
			    hc_entry->rmx_cwnd,
630
			    hc_entry->rmx_sendpipe,
633
			    hc_entry->rmx_sendpipe,
Lines 633-638 Link Here
633
			    hc_entry->rmx_updates,
636
			    hc_entry->rmx_updates,
634
			    hc_entry->rmx_expire);
637
			    hc_entry->rmx_expire);
635
			p += len;
638
			p += len;
639
			alloclines--;
640
			if (alloclines == 0) {
641
				break;
642
			}
636
		}
643
		}
637
		THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
644
		THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
638
	}
645
	}
Lines 660-666 Link Here
660
					      hc_entry, rmx_q);
667
					      hc_entry, rmx_q);
661
				uma_zfree(V_tcp_hostcache.zone, hc_entry);
668
				uma_zfree(V_tcp_hostcache.zone, hc_entry);
662
				V_tcp_hostcache.hashbase[i].hch_length--;
669
				V_tcp_hostcache.hashbase[i].hch_length--;
663
				V_tcp_hostcache.cache_count--;
670
				atomic_subtract_int(&V_tcp_hostcache.cache_count, 1);
664
			} else
671
			} else
665
				hc_entry->rmx_expire -= V_tcp_hostcache.prune;
672
				hc_entry->rmx_expire -= V_tcp_hostcache.prune;
666
		}
673
		}

Return to bug 172675