tcp_misc.c (4ba231ce) | tcp_misc.c (6e91bba0) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 618 unchanged lines hidden (view full) --- 627 break; 628 } 629 } 630 mutex_exit(&tcps->tcps_listener_conf_lock); 631 return (ratio); 632} 633 634/* | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 618 unchanged lines hidden (view full) --- 627 break; 628 } 629 } 630 mutex_exit(&tcps->tcps_listener_conf_lock); 631 return (ratio); 632} 633 634/* |
635 * Ndd param helper routine to return the current list of listener limit 636 * configuration. 637 */ 638/* ARGSUSED */ 639int 640tcp_listener_conf_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr) 641{ 642 tcp_stack_t *tcps = Q_TO_TCP(q)->tcp_tcps; 643 tcp_listener_t *tl; 644 645 mutex_enter(&tcps->tcps_listener_conf_lock); 646 for (tl = list_head(&tcps->tcps_listener_conf); tl != NULL; 647 tl = list_next(&tcps->tcps_listener_conf, tl)) { 648 (void) mi_mpprintf(mp, "%d:%d ", tl->tl_port, tl->tl_ratio); 649 } 650 mutex_exit(&tcps->tcps_listener_conf_lock); 651 return (0); 652} 653 654/* 655 * Ndd param helper routine to add a new listener limit configuration. 656 */ 657/* ARGSUSED */ 658int 659tcp_listener_conf_add(queue_t *q, mblk_t *mp, char *value, caddr_t cp, 660 cred_t *cr) 661{ 662 tcp_listener_t *new_tl; 663 tcp_listener_t *tl; 664 long lport; 665 long ratio; 666 char *colon; 667 tcp_stack_t *tcps = Q_TO_TCP(q)->tcp_tcps; 668 669 if (ddi_strtol(value, &colon, 10, &lport) != 0 || lport <= 0 || 670 lport > USHRT_MAX || *colon != ':') { 671 return (EINVAL); 672 } 673 if (ddi_strtol(colon + 1, NULL, 10, &ratio) != 0 || ratio <= 0) 674 return (EINVAL); 675 676 mutex_enter(&tcps->tcps_listener_conf_lock); 677 for (tl = list_head(&tcps->tcps_listener_conf); tl != NULL; 678 tl = list_next(&tcps->tcps_listener_conf, tl)) { 679 /* There is an existing entry, so update its ratio value. */ 680 if (tl->tl_port == lport) { 681 tl->tl_ratio = ratio; 682 mutex_exit(&tcps->tcps_listener_conf_lock); 683 return (0); 684 } 685 } 686 687 if ((new_tl = kmem_alloc(sizeof (tcp_listener_t), KM_NOSLEEP)) == 688 NULL) { 689 mutex_exit(&tcps->tcps_listener_conf_lock); 690 return (ENOMEM); 691 } 692 693 new_tl->tl_port = lport; 694 new_tl->tl_ratio = ratio; 695 list_insert_tail(&tcps->tcps_listener_conf, new_tl); 696 mutex_exit(&tcps->tcps_listener_conf_lock); 697 return (0); 698} 699 700/* 701 * Ndd param helper routine to remove a listener limit configuration. 702 */ 703/* ARGSUSED */ 704int 705tcp_listener_conf_del(queue_t *q, mblk_t *mp, char *value, caddr_t cp, 706 cred_t *cr) 707{ 708 tcp_listener_t *tl; 709 long lport; 710 tcp_stack_t *tcps = Q_TO_TCP(q)->tcp_tcps; 711 712 if (ddi_strtol(value, NULL, 10, &lport) != 0 || lport <= 0 || 713 lport > USHRT_MAX) { 714 return (EINVAL); 715 } 716 mutex_enter(&tcps->tcps_listener_conf_lock); 717 for (tl = list_head(&tcps->tcps_listener_conf); tl != NULL; 718 tl = list_next(&tcps->tcps_listener_conf, tl)) { 719 if (tl->tl_port == lport) { 720 list_remove(&tcps->tcps_listener_conf, tl); 721 mutex_exit(&tcps->tcps_listener_conf_lock); 722 kmem_free(tl, sizeof (tcp_listener_t)); 723 return (0); 724 } 725 } 726 mutex_exit(&tcps->tcps_listener_conf_lock); 727 return (ESRCH); 728} 729 730/* | |
731 * To remove all listener limit configuration in a tcp_stack_t. 732 */ 733void 734tcp_listener_conf_cleanup(tcp_stack_t *tcps) 735{ 736 tcp_listener_t *tl; 737 738 mutex_enter(&tcps->tcps_listener_conf_lock); --- 164 unchanged lines hidden --- | 635 * To remove all listener limit configuration in a tcp_stack_t. 636 */ 637void 638tcp_listener_conf_cleanup(tcp_stack_t *tcps) 639{ 640 tcp_listener_t *tl; 641 642 mutex_enter(&tcps->tcps_listener_conf_lock); --- 164 unchanged lines hidden --- |