Mercurial > illumos > illumos-gate
diff usr/src/uts/common/inet/ip/icmp.c @ 12016:0248e987199b
PSARC 2009/306 Brussels II - ipadm and libipadm
PSARC 2010/080 Brussels II addendum
6827318 Brussels Phase II aka ipadm(1m)
6731945 need BSD getifaddrs() API
6909065 explicitly disallow non-contiguous netmasks in the next minor release
6853922 ifconfig dumps core when ether address is non-hexadecimal.
6815806 ipReasmTimeout value should be variable
6567083 nd_getset has some dead and confusing code.
6884466 remove unused tcp/sctp ndd tunables
6928813 Comments at odds with default value of tcp_time_wait_interval
6236982 ifconfig usesrc lets adapter use itself as source address
6936855 modifying the ip6_strict_src_multihoming to non-zero value will unbind V4 IREs
author | Girish Moodalbail <Girish.Moodalbail@Sun.COM> |
---|---|
date | Fri, 26 Mar 2010 17:53:11 -0400 |
parents | 90b0a05a5e2c |
children | d0c06a2b2de5 |
line wrap: on
line diff
--- a/usr/src/uts/common/inet/ip/icmp.c Fri Mar 26 14:31:08 2010 -0700 +++ b/usr/src/uts/common/inet/ip/icmp.c Fri Mar 26 17:53:11 2010 -0400 @@ -128,10 +128,6 @@ uchar_t *ptr); static int icmp_output_newdst(conn_t *connp, mblk_t *data_mp, sin_t *sin, sin6_t *sin6, cred_t *cr, pid_t pid, ip_xmit_attr_t *ixa); -static int icmp_param_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr); -static boolean_t icmp_param_register(IDP *ndp, icmpparam_t *icmppa, int cnt); -static int icmp_param_set(queue_t *q, mblk_t *mp, char *value, - caddr_t cp, cred_t *cr); static mblk_t *icmp_prepend_hdr(conn_t *, ip_xmit_attr_t *, const ip_pkt_t *, const in6_addr_t *, const in6_addr_t *, uint32_t, mblk_t *, int *); static mblk_t *icmp_prepend_header_template(conn_t *, ip_xmit_attr_t *, @@ -219,33 +215,69 @@ }; /* - * Table of ND variables supported by icmp. These are loaded into is_nd - * when the stack instance is created. * All of these are alterable, within the min/max values given, at run time. + * + * Note: All those tunables which do not start with "icmp_" are Committed and + * therefore are public. See PSARC 2009/306. */ -static icmpparam_t icmp_param_arr[] = { - /* min max value name */ - { 0, 128, 32, "icmp_wroff_extra" }, - { 1, 255, 255, "icmp_ipv4_ttl" }, - { 0, IPV6_MAX_HOPS, IPV6_DEFAULT_HOPS, "icmp_ipv6_hoplimit"}, - { 0, 1, 1, "icmp_bsd_compat" }, - { 4096, 65536, 8192, "icmp_xmit_hiwat"}, - { 0, 65536, 1024, "icmp_xmit_lowat"}, - { 4096, 65536, 8192, "icmp_recv_hiwat"}, - { 65536, 1024*1024*1024, 256*1024, "icmp_max_buf"}, - { 0, 1, 0, "icmp_pmtu_discovery" }, - { 0, 1, 0, "icmp_sendto_ignerr" }, +static mod_prop_info_t icmp_propinfo_tbl[] = { + /* tunable - 0 */ + { "icmp_wroff_extra", MOD_PROTO_RAWIP, + mod_set_uint32, mod_get_uint32, + {0, 128, 32}, {32} }, + + { "icmp_ipv4_ttl", MOD_PROTO_RAWIP, + mod_set_uint32, mod_get_uint32, + {1, 255, 255}, {255} }, + + { "icmp_ipv6_hoplimit", MOD_PROTO_RAWIP, + mod_set_uint32, mod_get_uint32, + {0, IPV6_MAX_HOPS, IPV6_DEFAULT_HOPS}, + {IPV6_DEFAULT_HOPS} }, + + { "icmp_bsd_compat", MOD_PROTO_RAWIP, + mod_set_boolean, mod_get_boolean, + {B_TRUE}, {B_TRUE} }, + + { "send_maxbuf", MOD_PROTO_RAWIP, + mod_set_uint32, mod_get_uint32, + {4096, 65536, 8192}, {8192} }, + + { "icmp_xmit_lowat", MOD_PROTO_RAWIP, + mod_set_uint32, mod_get_uint32, + {0, 65536, 1024}, {1024} }, + + { "recv_maxbuf", MOD_PROTO_RAWIP, + mod_set_uint32, mod_get_uint32, + {4096, 65536, 8192}, {8192} }, + + { "icmp_max_buf", MOD_PROTO_RAWIP, + mod_set_uint32, mod_get_uint32, + {65536, 1024*1024*1024, 256*1024}, {256 * 1024} }, + + { "icmp_pmtu_discovery", MOD_PROTO_RAWIP, + mod_set_boolean, mod_get_boolean, + {B_FALSE}, {B_FALSE} }, + + { "icmp_sendto_ignerr", MOD_PROTO_RAWIP, + mod_set_boolean, mod_get_boolean, + {B_FALSE}, {B_FALSE} }, + + { "?", MOD_PROTO_RAWIP, NULL, mod_get_allprop, {0}, {0} }, + + { NULL, 0, NULL, NULL, {0}, {0} } }; -#define is_wroff_extra is_param_arr[0].icmp_param_value -#define is_ipv4_ttl is_param_arr[1].icmp_param_value -#define is_ipv6_hoplimit is_param_arr[2].icmp_param_value -#define is_bsd_compat is_param_arr[3].icmp_param_value -#define is_xmit_hiwat is_param_arr[4].icmp_param_value -#define is_xmit_lowat is_param_arr[5].icmp_param_value -#define is_recv_hiwat is_param_arr[6].icmp_param_value -#define is_max_buf is_param_arr[7].icmp_param_value -#define is_pmtu_discovery is_param_arr[8].icmp_param_value -#define is_sendto_ignerr is_param_arr[9].icmp_param_value + +#define is_wroff_extra is_propinfo_tbl[0].prop_cur_uval +#define is_ipv4_ttl is_propinfo_tbl[1].prop_cur_uval +#define is_ipv6_hoplimit is_propinfo_tbl[2].prop_cur_uval +#define is_bsd_compat is_propinfo_tbl[3].prop_cur_bval +#define is_xmit_hiwat is_propinfo_tbl[4].prop_cur_uval +#define is_xmit_lowat is_propinfo_tbl[5].prop_cur_uval +#define is_recv_hiwat is_propinfo_tbl[6].prop_cur_uval +#define is_max_buf is_propinfo_tbl[7].prop_cur_uval +#define is_pmtu_discovery is_propinfo_tbl[8].prop_cur_bval +#define is_sendto_ignerr is_propinfo_tbl[9].prop_cur_bval typedef union T_primitives *t_primp_t; @@ -2423,63 +2455,6 @@ return (0); } -/* - * This routine retrieves the value of an ND variable in a icmpparam_t - * structure. It is called through nd_getset when a user reads the - * variable. - */ -/* ARGSUSED */ -static int -icmp_param_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr) -{ - icmpparam_t *icmppa = (icmpparam_t *)cp; - - (void) mi_mpprintf(mp, "%d", icmppa->icmp_param_value); - return (0); -} - -/* - * Walk through the param array specified registering each element with the - * named dispatch (ND) handler. - */ -static boolean_t -icmp_param_register(IDP *ndp, icmpparam_t *icmppa, int cnt) -{ - for (; cnt-- > 0; icmppa++) { - if (icmppa->icmp_param_name && icmppa->icmp_param_name[0]) { - if (!nd_load(ndp, icmppa->icmp_param_name, - icmp_param_get, icmp_param_set, - (caddr_t)icmppa)) { - nd_free(ndp); - return (B_FALSE); - } - } - } - return (B_TRUE); -} - -/* This routine sets an ND variable in a icmpparam_t structure. */ -/* ARGSUSED */ -static int -icmp_param_set(queue_t *q, mblk_t *mp, char *value, caddr_t cp, cred_t *cr) -{ - long new_value; - icmpparam_t *icmppa = (icmpparam_t *)cp; - - /* - * Fail the request if the new value does not lie within the - * required bounds. - */ - if (ddi_strtol(value, NULL, 10, &new_value) != 0 || - new_value < icmppa->icmp_param_min || - new_value > icmppa->icmp_param_max) { - return (EINVAL); - } - /* Set the new value */ - icmppa->icmp_param_value = new_value; - return (0); -} - static mblk_t * icmp_queue_fallback(icmp_t *icmp, mblk_t *mp) { @@ -4706,7 +4681,6 @@ struct iocblk *iocp; conn_t *connp = Q_TO_CONN(q); icmp_t *icmp = connp->conn_icmp; - icmp_stack_t *is = icmp->icmp_is; cred_t *cr; switch (mp->b_datap->db_type) { @@ -4837,14 +4811,6 @@ mi_copyin(q, mp, NULL, SIZEOF_STRUCT(strbuf, iocp->ioc_flag)); return; - case ND_SET: - /* nd_getset performs the necessary checking */ - case ND_GET: - if (nd_getset(q, is->is_nd, mp)) { - qreply(q, mp); - return; - } - break; default: break; } @@ -4990,19 +4956,17 @@ rawip_stack_init(netstackid_t stackid, netstack_t *ns) { icmp_stack_t *is; - icmpparam_t *pa; int error = 0; + size_t arrsz; major_t major; is = (icmp_stack_t *)kmem_zalloc(sizeof (*is), KM_SLEEP); is->is_netstack = ns; - pa = (icmpparam_t *)kmem_alloc(sizeof (icmp_param_arr), KM_SLEEP); - is->is_param_arr = pa; - bcopy(icmp_param_arr, is->is_param_arr, sizeof (icmp_param_arr)); - - (void) icmp_param_register(&is->is_nd, - is->is_param_arr, A_CNT(icmp_param_arr)); + arrsz = sizeof (icmp_propinfo_tbl); + is->is_propinfo_tbl = (mod_prop_info_t *)kmem_alloc(arrsz, KM_SLEEP); + bcopy(icmp_propinfo_tbl, is->is_propinfo_tbl, arrsz); + is->is_ksp = rawip_kstat_init(stackid); major = mod_name_to_major(INET_NAME); @@ -5019,9 +4983,8 @@ { icmp_stack_t *is = (icmp_stack_t *)arg; - nd_free(&is->is_nd); - kmem_free(is->is_param_arr, sizeof (icmp_param_arr)); - is->is_param_arr = NULL; + kmem_free(is->is_propinfo_tbl, sizeof (icmp_propinfo_tbl)); + is->is_propinfo_tbl = NULL; rawip_kstat_fini(stackid, is->is_ksp); is->is_ksp = NULL; @@ -5599,8 +5562,6 @@ } switch (cmd) { - case ND_SET: - case ND_GET: case _SIOCSOCKFALLBACK: case TI_GETPEERNAME: case TI_GETMYNAME: