diff options
| author | Erik Nordmark <Erik.Nordmark@Sun.COM> | 2009-11-11 11:49:49 -0800 |
|---|---|---|
| committer | Erik Nordmark <Erik.Nordmark@Sun.COM> | 2009-11-11 11:49:49 -0800 |
| commit | bd670b35a010421b6e1a5536c34453a827007c81 (patch) | |
| tree | 97c2057b6771dd40411a12eb89d2db2e2b2cce31 /usr/src/uts/common/inet/ip/rts.c | |
| parent | b3388e4fc5f5c24c8a39fbe132a00b02dae5b717 (diff) | |
| download | illumos-joyent-bd670b35a010421b6e1a5536c34453a827007c81.tar.gz | |
PSARC/2009/331 IP Datapath Refactoring
PSARC/2008/522 EOF of 2001/070 IPsec HW Acceleration support
PSARC/2009/495 netstat -r flags for blackhole and reject routes
PSARC 2009/496 EOF of XRESOLV
PSARC/2009/494 IP_DONTFRAG socket option
PSARC/2009/515 fragmentation controls for ping and traceroute
6798716 ip_newroute delenda est
6798739 ARP and IP are too separate
6807265 IPv4 ip2mac() support
6756382 Please remove Venus IPsec HWACCEL code
6880632 sendto/sendmsg never returns EHOSTUNREACH in Solaris
6748582 sendmsg() return OK, but doesn't send message using IPv4-mapped x IPv6 addr
1119790 TCP and path mtu discovery
4637227 should support equal-cost multi-path (ECMP)
5078568 getsockopt() for IPV6_PATHMTU on a non-connected socket should not succeed
6419648 "AR* contract private note" should be removed as part of ATM SW EOL
6274715 Arp could keep the old entry in the cache while it waits for an arp response
6605615 Remove duplicated TCP/IP opt_set/opt_get code; use conn_t
6874677 IP_TTL can be used to send with ttl zero
4034090 arp should not let you delete your own entry
6882140 Implement IP_DONTFRAG socket option
6883858 Implement ping -D option; traceroute -F should work for IPv6 and shared-IP zones
1119792 TCP/IP black hole detection is broken on receiver
4078796 Directed broadcast forwarding code has problems
4104337 restrict the IPPROTO_IP and IPPROTO_IPV6 options based on the socket family
4203747 Source address selection for source routed packets
4230259 pmtu is increased every ip_ire_pathmtu_interval timer value.
4300533 When sticky option ipv6_pktinfo set to bogus address subsequent connect time out
4471035 ire_delete_cache_gw is called through ire_walk unnecessarily
4514572 SO_DONTROUTE socket option doesn't work with IPv6
4524980 tcp_lookup_ipv4() should compare the ifindex against tcpb->tcpb_bound_if
4532714 machine fails to switch quickly among failed default routes
4634219 IPv6 path mtu discovery is broken when using routing header
4691581 udp broadcast handling causes too many replicas
4708405 mcast is broken on machines when all interfaces are IFF_POINTOPOINT
4770457 netstat/route: source address of interface routes pretends to be gateway address
4786974 use routing table to determine routes/interface for multicast
4792619 An ip_fanout_udp_ipc_v6() routine might lead to some simpler code
4816115 Nuke ipsec_out_use_global_policy
4862844 ipsec offload corner case
4867533 tcp_rq and tcp_wq are redundant
4868589 NCEs should be shared across an IPMP group
4872093 unplumbing an improper virtual interface panics in ip_newroute_get_dst_ill()
4901671 FireEngine needs some cleanup
4907617 IPsec identity latching should be done before sending SYN-ACK
4941461 scopeid and IPV6_PKTINFO with UDP/ICMP connect() does not work properly
4944981 ip does nothing with IP6I_NEXTHOP
4963353 IPv4 and IPv6 proto fanout codes could be brought closer
4963360 consider passing zoneid using ip6i_t instead of ipsec_out_t in NDP
4963734 new ip6_asp locking is used incorrectly in ip_newroute_v6()
5008315 IPv6 code passes ip6i_t to IPsec code instead of ip6_t
5009636 memory leak in ip_fanout_proto_v6()
5092337 tcp/udp option handling can use some cleanup
5035841 Solaris can fail to create a valid broadcast ire
5043747 ar_query_xmit: Could not find the ace
5051574 tcp_check_policy is missing some checks
6305037 full hardware checksum is discarded when there're more than 2 mblks in the chain
6311149 ip.c needs to be put through a woodchipper
4708860 Unable to reassemble CGTP fragmented multicast packets
6224628 Large IPv6 packets with IPsec protection sometimes have length mismatch.
6213243 Solaris does not currently support Dead Gateway Detection
5029091 duplicate code in IP's input path for TCP/UDP/SCTP
4674643 through IPv6 CGTP routes, the very first packet is sent only after a while
6207318 Multiple default routes do not round robin connections to routers.
4823410 IP has an inconsistent view of link mtu
5105520 adding interface route to down interface causes ifconfig hang
5105707 advanced sockets API introduced some dead code
6318399 IP option handling for icmp and udp is too complicated
6321434 Every dropped packet in IP should use ip_drop_packet()
6341693 ifconfig mtu should operate on the physical interface, not individual ipif's
6352430 The credentials attached to an mblk are not particularly useful
6357894 uninitialised ipp_hoplimit needs to be cleaned up.
6363568 ip_xmit_v6() may be missing IRE releases in error cases
6364828 ip_rput_forward needs a makeover
6384416 System panics when running as multicast forwarder using multicast tunnels
6402382 TX: UDP v6 slowpath is not modified to handle mac_exempt conns
6418413 assertion failed ipha->ipha_ident == 0||ipha->ipha_ident == 0xFFFF
6420916 assertion failures in ipv6 wput path
6430851 use of b_prev to store ifindex is not 100% safe
6446106 IPv6 packets stored in nce->nce_qd_mp will be sent with incorrect tcp/udp checksums
6453711 SCTP OOTB sent as if genetated by global zone
6465212 ARP/IP merge should remove ire_freemblk.esballoc
6490163 ip_input() could misbehave if the first mblk's size is not big enough
6496664 missing ipif_refrele leads to reference leak and deferred crash in ip_wput_ipsec_out_v6
6504856 memory leak in ip_fanout_proto_v6() when using link local outer tunnel addresses
6507765 IRE cache hash function performs badly
6510186 IP_FORWARD_PROG bit is easily overlooked
6514727 cgtp ipv6 failure on snv54
6528286 MULTIRT (CGTP) should offload checksum to hardware
6533904 SCTP: doesn't support traffic class for IPv6
6539415 TX: ipif source selection is flawed for unlabeled gateways
6539851 plumbed unworking nic blocks sending broadcast packets
6564468 non-solaris SCTP stack over rawip socket: netstat command counts rawipInData not rawipOutDatagrams
6568511 ipIfStatsOutDiscards not bumped when discarding an ipsec packet on the wrong NIC
6584162 tcp_g_q_inactive() makes incorrect use of taskq_dispatch()
6603974 round-robin default with many interfaces causes infinite temporary IRE thrashing
6611750 ilm_lookup_ill_index_v4 was born an orphan
6618423 ip_wput_frag_mdt sends out packets that void pfhooks
6620964 IRE max bucket count calculations performed in ip_ire_init() are flawed
6626266 various _broadcasts seem redundant
6638182 IP_PKTINFO + SO_DONTROUTE + CIPSO IP option == panic
6647710 IPv6 possible DoS vulnerability
6657357 nce should be kmem_cache alloc'ed from an nce_cache.
6685131 ilg_add -> conn_ilg_alloc interacting with conn_ilg[] walkers can cause panic.
6730298 adding 0.0.0.0 key with mask != 0 causes 'route delete default' to fail
6730976 vni and ipv6 doesn't quite work.
6740956 assertion failed: mp->b_next == 0L && mp->b_prev == 0L in nce_queue_mp_common()
6748515 BUMP_MIB() is occasionally done on the wrong ill
6753250 ip_output_v6() `notv6' error path has an errant ill_refrele()
6756411 NULL-pointer dereference in ip_wput_local()
6769582 IP must forward packet returned from FW-HOOK
6781525 bogus usesrc usage leads directly to panic
6422839 System paniced in ip_multicast_loopback due to NULL pointer dereference
6785521 initial IPv6 DAD solicitation is dropped in ip_newroute_ipif_v6()
6787370 ipnet devices not seeing forwarded IP packets on outgoing interface
6791187 ip*dbg() calls in ip_output_options() claim to originate from ip_wput()
6794047 nce_fp_mp prevents sharing of NCEs across an IPMP group
6797926 many unnecessary ip0dbg() in ip_rput_data_v6
6846919 Packet queued for ND gets sent in the clear.
6856591 ping doesn't send packets with DF set
6861113 arp module has incorrect dependency path for hook module
6865664 IPV6_NEXTHOP does not work with TCP socket
6874681 No ICMP time exceeded when a router receives packet with ttl = 0
6880977 ip_wput_ire() uses over 1k of stack
6595433 IPsec performance could be significantly better when calling hw crypto provider synchronously
6848397 ifconfig down of an interface can hang.
6849602 IPV6_PATHMTU size issue for UDP
6885359 Add compile-time option for testing pure IPsec overhead
6889268 Odd loopback source address selection with IPMP
6895420 assertion failed: connp->conn_helper_info == NULL
6851189 Routing-related panic occurred during reboot on T2000 system running snv_117
6896174 Post-async-encryption, AH+ESP packets may have misinitialized ipha/ip6
6896687 iptun presents IPv6 with an MTU < 1280
6897006 assertion failed: ipif->ipif_id != 0 in ip_sioctl_slifzone_restart
Diffstat (limited to 'usr/src/uts/common/inet/ip/rts.c')
| -rw-r--r-- | usr/src/uts/common/inet/ip/rts.c | 456 |
1 files changed, 146 insertions, 310 deletions
diff --git a/usr/src/uts/common/inet/ip/rts.c b/usr/src/uts/common/inet/ip/rts.c index ce3ac6faca..d5a1d84395 100644 --- a/usr/src/uts/common/inet/ip/rts.c +++ b/usr/src/uts/common/inet/ip/rts.c @@ -72,7 +72,6 @@ * Addresses are assigned to interfaces. * ICMP redirects are processed and a IRE_HOST/RTF_DYNAMIC is installed. * No route is found while sending a packet. - * When TCP requests IP to remove an IRE_CACHE of a troubled destination. * * Since all we do is reformat the messages between routing socket and * ioctl forms, no synchronization is necessary in this module; all @@ -113,7 +112,8 @@ static rtsparam_t lcl_param_arr[] = { static void rts_err_ack(queue_t *q, mblk_t *mp, t_scalar_t t_error, int sys_error); -static void rts_input(void *, mblk_t *, void *); +static void rts_input(void *, mblk_t *, void *, ip_recv_attr_t *); +static void rts_icmp_input(void *, mblk_t *, void *, ip_recv_attr_t *); static mblk_t *rts_ioctl_alloc(mblk_t *data); static int rts_param_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr); static boolean_t rts_param_register(IDP *ndp, rtsparam_t *rtspa, int cnt); @@ -211,28 +211,28 @@ rts_common_close(queue_t *q, conn_t *connp) if (!IPCL_IS_NONSTR(connp)) { qprocsoff(q); + } - /* - * Now we are truly single threaded on this stream, and can - * delete the things hanging off the connp, and finally the - * connp. - * We removed this connp from the fanout list, it cannot be - * accessed thru the fanouts, and we already waited for the - * conn_ref to drop to 0. We are already in close, so - * there cannot be any other thread from the top. qprocsoff - * has completed, and service has completed or won't run in - * future. - */ + /* + * Now we are truly single threaded on this stream, and can + * delete the things hanging off the connp, and finally the connp. + * We removed this connp from the fanout list, it cannot be + * accessed thru the fanouts, and we already waited for the + * conn_ref to drop to 0. We are already in close, so + * there cannot be any other thread from the top. qprocsoff + * has completed, and service has completed or won't run in + * future. + */ + ASSERT(connp->conn_ref == 1); + + if (!IPCL_IS_NONSTR(connp)) { inet_minor_free(connp->conn_minor_arena, connp->conn_dev); } else { ip_free_helper_stream(connp); } - ASSERT(connp->conn_ref == 1); - connp->conn_ref--; ipcl_conn_destroy(connp); - return (0); } @@ -256,7 +256,6 @@ rts_stream_open(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp) { conn_t *connp; dev_t conn_dev; - rts_stack_t *rtss; rts_t *rts; /* If the stream is already open, return immediately. */ @@ -266,7 +265,6 @@ rts_stream_open(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp) if (sflag == MODOPEN) return (EINVAL); - /* * Since RTS is not used so heavily, allocating from the small * arena should be sufficient. @@ -278,44 +276,31 @@ rts_stream_open(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp) connp = rts_open(flag, credp); ASSERT(connp != NULL); - *devp = makedevice(getemajor(*devp), (minor_t)conn_dev); rts = connp->conn_rts; - rw_enter(&rts->rts_rwlock, RW_WRITER); connp->conn_dev = conn_dev; connp->conn_minor_arena = ip_minor_arena_sa; - /* - * Initialize the rts_t structure for this stream. - */ q->q_ptr = connp; WR(q)->q_ptr = connp; connp->conn_rq = q; connp->conn_wq = WR(q); - rtss = rts->rts_rtss; - q->q_hiwat = rtss->rtss_recv_hiwat; - WR(q)->q_hiwat = rtss->rtss_xmit_hiwat; - WR(q)->q_lowat = rtss->rtss_xmit_lowat; - - + WR(q)->q_hiwat = connp->conn_sndbuf; + WR(q)->q_lowat = connp->conn_sndlowat; mutex_enter(&connp->conn_lock); connp->conn_state_flags &= ~CONN_INCIPIENT; mutex_exit(&connp->conn_lock); - - qprocson(q); rw_exit(&rts->rts_rwlock); - /* - * Indicate the down IP module that this is a routing socket - * client by sending an RTS IOCTL without any user data. Although - * this is just a notification message (without any real routing - * request), we pass in any credential for correctness sake. - */ + + /* Indicate to IP that this is a routing socket client */ ip_rts_register(connp); + qprocson(q); + return (0); } @@ -352,22 +337,38 @@ rts_open(int flag, cred_t *credp) */ netstack_rele(ns); - rw_enter(&rts->rts_rwlock, RW_WRITER); ASSERT(connp->conn_rts == rts); ASSERT(rts->rts_connp == connp); + connp->conn_ixa->ixa_flags |= IXAF_MULTICAST_LOOP | IXAF_SET_ULP_CKSUM; + /* conn_allzones can not be set this early, hence no IPCL_ZONEID */ + connp->conn_ixa->ixa_zoneid = zoneid; connp->conn_zoneid = zoneid; connp->conn_flow_cntrld = B_FALSE; - connp->conn_ulp_labeled = is_system_labeled(); - rts->rts_rtss = rtss; - rts->rts_xmit_hiwat = rtss->rtss_xmit_hiwat; + + connp->conn_rcvbuf = rtss->rtss_recv_hiwat; + connp->conn_sndbuf = rtss->rtss_xmit_hiwat; + connp->conn_sndlowat = rtss->rtss_xmit_lowat; + connp->conn_rcvlowat = rts_mod_info.mi_lowat; + + connp->conn_family = PF_ROUTE; + connp->conn_so_type = SOCK_RAW; + /* SO_PROTOTYPE is always sent down by sockfs setting conn_proto */ connp->conn_recv = rts_input; + connp->conn_recvicmp = rts_icmp_input; + crhold(credp); connp->conn_cred = credp; + connp->conn_cpid = curproc->p_pid; + /* Cache things in ixa without an extra refhold */ + connp->conn_ixa->ixa_cred = connp->conn_cred; + connp->conn_ixa->ixa_cpid = connp->conn_cpid; + if (is_system_labeled()) + connp->conn_ixa->ixa_tsl = crgetlabel(connp->conn_cred); /* * rts sockets start out as bound and connected @@ -429,7 +430,6 @@ rts_tpi_bind(queue_t *q, mblk_t *mp) { conn_t *connp = Q_TO_CONN(q); rts_t *rts = connp->conn_rts; - mblk_t *mp1; struct T_bind_req *tbr; if ((mp->b_wptr - mp->b_rptr) < sizeof (*tbr)) { @@ -444,16 +444,6 @@ rts_tpi_bind(queue_t *q, mblk_t *mp) rts_err_ack(q, mp, TOUTSTATE, 0); return; } - /* - * Reallocate the message to make sure we have enough room for an - * address and the protocol type. - */ - mp1 = reallocb(mp, sizeof (struct T_bind_ack) + sizeof (sin_t), 1); - if (mp1 == NULL) { - rts_err_ack(q, mp, TSYSERR, ENOMEM); - return; - } - mp = mp1; tbr = (struct T_bind_req *)mp->b_rptr; if (tbr->ADDR_length != 0) { (void) mi_strlog(q, 1, SL_ERROR|SL_TRACE, @@ -465,6 +455,7 @@ rts_tpi_bind(queue_t *q, mblk_t *mp) tbr->ADDR_offset = (t_scalar_t)sizeof (struct T_bind_req); tbr->ADDR_length = 0; tbr->PRIM_type = T_BIND_ACK; + mp->b_datap->db_type = M_PCPROTO; rts->rts_state = TS_IDLE; qreply(q, mp); } @@ -545,70 +536,30 @@ static int rts_opt_get(conn_t *connp, int level, int name, uchar_t *ptr) { rts_t *rts = connp->conn_rts; - int *i1 = (int *)ptr; + conn_opt_arg_t coas; + int retval; ASSERT(RW_READ_HELD(&rts->rts_rwlock)); switch (level) { - case SOL_SOCKET: - switch (name) { - case SO_DEBUG: - *i1 = rts->rts_debug; - break; - case SO_REUSEADDR: - *i1 = rts->rts_reuseaddr; - break; - case SO_TYPE: - *i1 = SOCK_RAW; - break; - /* - * The following three items are available here, - * but are only meaningful to IP. - */ - case SO_DONTROUTE: - *i1 = rts->rts_dontroute; - break; - case SO_USELOOPBACK: - *i1 = rts->rts_useloopback; - break; - case SO_BROADCAST: - *i1 = rts->rts_broadcast; - break; - case SO_PROTOTYPE: - *i1 = rts->rts_proto; - break; - /* - * The following two items can be manipulated, - * but changing them should do nothing. - */ - case SO_SNDBUF: - ASSERT(rts->rts_xmit_hiwat <= INT_MAX); - *i1 = (int)(rts->rts_xmit_hiwat); - break; - case SO_RCVBUF: - ASSERT(rts->rts_recv_hiwat <= INT_MAX); - *i1 = (int)(rts->rts_recv_hiwat); - break; - case SO_DOMAIN: - *i1 = PF_ROUTE; - break; - default: - return (-1); - } - break; + /* do this in conn_opt_get? */ case SOL_ROUTE: switch (name) { case RT_AWARE: mutex_enter(&connp->conn_lock); - *i1 = connp->conn_rtaware; + *(int *)ptr = connp->conn_rtaware; mutex_exit(&connp->conn_lock); - break; + return (0); } break; - default: - return (-1); } - return ((int)sizeof (int)); + coas.coa_connp = connp; + coas.coa_ixa = connp->conn_ixa; + coas.coa_ipp = &connp->conn_xmit_ipp; + mutex_enter(&connp->conn_lock); + retval = conn_opt_get(&coas, level, name, ptr); + mutex_exit(&connp->conn_lock); + return (retval); } /* ARGSUSED */ @@ -620,6 +571,12 @@ rts_do_opt_set(conn_t *connp, int level, int name, uint_t inlen, int *i1 = (int *)invalp; rts_t *rts = connp->conn_rts; rts_stack_t *rtss = rts->rts_rtss; + int error; + conn_opt_arg_t coas; + + coas.coa_connp = connp; + coas.coa_ixa = connp->conn_ixa; + coas.coa_ipp = &connp->conn_xmit_ipp; ASSERT(RW_WRITE_HELD(&rts->rts_rwlock)); @@ -638,38 +595,6 @@ rts_do_opt_set(conn_t *connp, int level, int name, uint_t inlen, switch (level) { case SOL_SOCKET: switch (name) { - case SO_REUSEADDR: - if (!checkonly) { - rts->rts_reuseaddr = *i1 ? 1 : 0; - connp->conn_reuseaddr = *i1 ? 1 : 0; - } - break; /* goto sizeof (int) option return */ - case SO_DEBUG: - if (!checkonly) - rts->rts_debug = *i1 ? 1 : 0; - break; /* goto sizeof (int) option return */ - /* - * The following three items are available here, - * but are only meaningful to IP. - */ - case SO_DONTROUTE: - if (!checkonly) { - rts->rts_dontroute = *i1 ? 1 : 0; - connp->conn_dontroute = *i1 ? 1 : 0; - } - break; /* goto sizeof (int) option return */ - case SO_USELOOPBACK: - if (!checkonly) { - rts->rts_useloopback = *i1 ? 1 : 0; - connp->conn_loopback = *i1 ? 1 : 0; - } - break; /* goto sizeof (int) option return */ - case SO_BROADCAST: - if (!checkonly) { - rts->rts_broadcast = *i1 ? 1 : 0; - connp->conn_broadcast = *i1 ? 1 : 0; - } - break; /* goto sizeof (int) option return */ case SO_PROTOTYPE: /* * Routing socket applications that call socket() with @@ -678,13 +603,15 @@ rts_do_opt_set(conn_t *connp, int level, int name, uint_t inlen, * down the SO_PROTOTYPE and rts_queue_input() * implements the filtering. */ - if (*i1 != AF_INET && *i1 != AF_INET6) + if (*i1 != AF_INET && *i1 != AF_INET6) { + *outlenp = 0; return (EPROTONOSUPPORT); - if (!checkonly) { - rts->rts_proto = *i1; - connp->conn_proto = *i1; } - break; /* goto sizeof (int) option return */ + if (!checkonly) + connp->conn_proto = *i1; + *outlenp = inlen; + return (0); + /* * The following two items can be manipulated, * but changing them should do nothing. @@ -694,36 +621,13 @@ rts_do_opt_set(conn_t *connp, int level, int name, uint_t inlen, *outlenp = 0; return (ENOBUFS); } - if (!checkonly) { - rts->rts_xmit_hiwat = *i1; - if (!IPCL_IS_NONSTR(connp)) - connp->conn_wq->q_hiwat = *i1; - } break; /* goto sizeof (int) option return */ case SO_RCVBUF: if (*i1 > rtss->rtss_max_buf) { *outlenp = 0; return (ENOBUFS); } - if (!checkonly) { - rts->rts_recv_hiwat = *i1; - rw_exit(&rts->rts_rwlock); - (void) proto_set_rx_hiwat(connp->conn_rq, connp, - *i1); - rw_enter(&rts->rts_rwlock, RW_WRITER); - } - break; /* goto sizeof (int) option return */ - case SO_RCVTIMEO: - case SO_SNDTIMEO: - /* - * Pass these two options in order for third part - * protocol usage. Here just return directly. - */ - return (0); - default: - *outlenp = 0; - return (EINVAL); } break; case SOL_ROUTE: @@ -734,15 +638,17 @@ rts_do_opt_set(conn_t *connp, int level, int name, uint_t inlen, connp->conn_rtaware = *i1; mutex_exit(&connp->conn_lock); } - break; /* goto sizeof (int) option return */ - default: - *outlenp = 0; - return (EINVAL); + *outlenp = inlen; + return (0); } break; - default: + } + /* Serialized setsockopt since we are D_MTQPAIR */ + error = conn_opt_set(&coas, level, name, inlen, invalp, + checkonly, cr); + if (error != 0) { *outlenp = 0; - return (EINVAL); + return (error); } /* * Common case of return from an option that is sizeof (int) @@ -832,7 +738,7 @@ rts_tpi_opt_get(queue_t *q, t_scalar_t level, t_scalar_t name, uchar_t *ptr) int rts_tpi_opt_set(queue_t *q, uint_t optset_context, int level, int name, uint_t inlen, uchar_t *invalp, uint_t *outlenp, - uchar_t *outvalp, void *thisdg_attrs, cred_t *cr, mblk_t *mblk) + uchar_t *outvalp, void *thisdg_attrs, cred_t *cr) { conn_t *connp = Q_TO_CONN(q); int error; @@ -1009,10 +915,6 @@ err_ret: * consumes the message or passes it downstream; it never queues a * a message. The data messages that go down are wrapped in an IOCTL * message. - * - * FIXME? Should we call IP rts_request directly? Could punt on returning - * errno in the case when it defers processing due to - * IPIF_CHANGING/ILL_CHANGING??? */ static void rts_wput(queue_t *q, mblk_t *mp) @@ -1057,7 +959,7 @@ rts_wput(queue_t *q, mblk_t *mp) } return; } - ip_output(connp, mp1, q, IP_WPUT); + ip_wput_nondata(q, mp1); } @@ -1120,11 +1022,9 @@ rts_wput_other(queue_t *q, mblk_t *mp) } if (((union T_primitives *)rptr)->type == T_SVR4_OPTMGMT_REQ) { - (void) svr4_optcom_req(q, mp, cr, - &rts_opt_obj, B_TRUE); + svr4_optcom_req(q, mp, cr, &rts_opt_obj); } else { - (void) tpi_optcom_req(q, mp, cr, - &rts_opt_obj, B_TRUE); + tpi_optcom_req(q, mp, cr, &rts_opt_obj); } return; case O_T_CONN_RES: @@ -1168,7 +1068,7 @@ rts_wput_other(queue_t *q, mblk_t *mp) default: break; } - ip_output(connp, mp, q, IP_WPUT); + ip_wput_nondata(q, mp); } /* @@ -1177,7 +1077,6 @@ rts_wput_other(queue_t *q, mblk_t *mp) static void rts_wput_iocdata(queue_t *q, mblk_t *mp) { - conn_t *connp = Q_TO_CONN(q); struct sockaddr *rtsaddr; mblk_t *mp1; STRUCT_HANDLE(strbuf, sb); @@ -1188,7 +1087,7 @@ rts_wput_iocdata(queue_t *q, mblk_t *mp) case TI_GETPEERNAME: break; default: - ip_output(connp, mp, q, IP_WPUT); + ip_wput_nondata(q, mp); return; } switch (mi_copy_state(q, mp, &mp1)) { @@ -1233,9 +1132,12 @@ rts_wput_iocdata(queue_t *q, mblk_t *mp) mi_copyout(q, mp); } +/* + * IP passes up a NULL ira. + */ /*ARGSUSED2*/ static void -rts_input(void *arg1, mblk_t *mp, void *arg2) +rts_input(void *arg1, mblk_t *mp, void *arg2, ip_recv_attr_t *ira) { conn_t *connp = (conn_t *)arg1; rts_t *rts = connp->conn_rts; @@ -1248,27 +1150,17 @@ rts_input(void *arg1, mblk_t *mp, void *arg2) case M_IOCACK: case M_IOCNAK: iocp = (struct iocblk *)mp->b_rptr; - if (IPCL_IS_NONSTR(connp)) { - ASSERT(rts->rts_flag & (RTS_REQ_PENDING)); - mutex_enter(&rts->rts_send_mutex); - rts->rts_flag &= ~RTS_REQ_INPROG; + ASSERT(!IPCL_IS_NONSTR(connp)); + if (rts->rts_flag & (RTS_WPUT_PENDING)) { + rts->rts_flag &= ~RTS_WPUT_PENDING; rts->rts_error = iocp->ioc_error; - cv_signal(&rts->rts_io_cv); - mutex_exit(&rts->rts_send_mutex); + /* + * Tell rts_wvw/qwait that we are done. + * Note: there is no qwait_wakeup() we can use. + */ + qenable(connp->conn_rq); freemsg(mp); return; - } else { - if (rts->rts_flag & (RTS_WPUT_PENDING)) { - rts->rts_flag &= ~RTS_WPUT_PENDING; - rts->rts_error = iocp->ioc_error; - /* - * Tell rts_wvw/qwait that we are done. - * Note: there is no qwait_wakeup() we can use. - */ - qenable(connp->conn_rq); - freemsg(mp); - return; - } } break; case M_DATA: @@ -1316,6 +1208,12 @@ rts_input(void *arg1, mblk_t *mp, void *arg2) } } +/*ARGSUSED*/ +static void +rts_icmp_input(void *arg1, mblk_t *mp, void *arg2, ip_recv_attr_t *ira) +{ + freemsg(mp); +} void rts_ddi_g_init(void) @@ -1427,11 +1325,6 @@ int rts_getpeername(sock_lower_handle_t proto_handle, struct sockaddr *addr, socklen_t *addrlen, cred_t *cr) { - conn_t *connp = (conn_t *)proto_handle; - rts_t *rts = connp->conn_rts; - - ASSERT(rts != NULL); - bzero(addr, sizeof (struct sockaddr)); addr->sa_family = AF_ROUTE; *addrlen = sizeof (struct sockaddr); @@ -1444,7 +1337,11 @@ int rts_getsockname(sock_lower_handle_t proto_handle, struct sockaddr *addr, socklen_t *addrlen, cred_t *cr) { - return (EOPNOTSUPP); + bzero(addr, sizeof (struct sockaddr)); + addr->sa_family = AF_ROUTE; + *addrlen = sizeof (struct sockaddr); + + return (0); } static int @@ -1461,7 +1358,6 @@ rts_getsockopt(sock_lower_handle_t proto_handle, int level, int option_name, error = proto_opt_check(level, option_name, *optlen, &max_optbuf_len, rts_opt_obj.odb_opt_des_arr, rts_opt_obj.odb_opt_arr_cnt, - rts_opt_obj.odb_topmost_tpiprovider, B_FALSE, B_TRUE, cr); if (error != 0) { if (error < 0) @@ -1473,25 +1369,20 @@ rts_getsockopt(sock_lower_handle_t proto_handle, int level, int option_name, rw_enter(&rts->rts_rwlock, RW_READER); len = rts_opt_get(connp, level, option_name, optvalp_buf); rw_exit(&rts->rts_rwlock); - - if (len < 0) { - /* - * Pass on to IP - */ - error = ip_get_options(connp, level, option_name, - optvalp, optlen, cr); - } else { - /* - * update optlen and copy option value - */ - t_uscalar_t size = MIN(len, *optlen); - bcopy(optvalp_buf, optvalp, size); - bcopy(&size, optlen, sizeof (size)); - error = 0; + if (len == -1) { + kmem_free(optvalp_buf, max_optbuf_len); + return (EINVAL); } + /* + * update optlen and copy option value + */ + t_uscalar_t size = MIN(len, *optlen); + + bcopy(optvalp_buf, optvalp, size); + bcopy(&size, optlen, sizeof (size)); kmem_free(optvalp_buf, max_optbuf_len); - return (error); + return (0); } static int @@ -1505,7 +1396,6 @@ rts_setsockopt(sock_lower_handle_t proto_handle, int level, int option_name, error = proto_opt_check(level, option_name, optlen, NULL, rts_opt_obj.odb_opt_des_arr, rts_opt_obj.odb_opt_arr_cnt, - rts_opt_obj.odb_topmost_tpiprovider, B_TRUE, B_FALSE, cr); if (error != 0) { @@ -1530,9 +1420,7 @@ static int rts_send(sock_lower_handle_t proto_handle, mblk_t *mp, struct nmsghdr *msg, cred_t *cr) { - mblk_t *mp1; conn_t *connp = (conn_t *)proto_handle; - rts_t *rts = connp->conn_rts; rt_msghdr_t *rtm; int error; @@ -1546,65 +1434,19 @@ rts_send(sock_lower_handle_t proto_handle, mblk_t *mp, */ if ((mp->b_wptr - mp->b_rptr) < sizeof (rt_msghdr_t)) { if (!pullupmsg(mp, sizeof (rt_msghdr_t))) { - rts->rts_error = EINVAL; freemsg(mp); - return (rts->rts_error); + return (EINVAL); } } rtm = (rt_msghdr_t *)mp->b_rptr; rtm->rtm_pid = curproc->p_pid; - mp1 = rts_ioctl_alloc(mp); - if (mp1 == NULL) { - ASSERT(rts != NULL); - freemsg(mp); - return (ENOMEM); - } - /* - * Allow only one outstanding request(ioctl) at any given time + * We are not constrained by the ioctl interface and + * ip_rts_request_common processing requests synchronously hence + * we can send them down concurrently. */ - mutex_enter(&rts->rts_send_mutex); - while (rts->rts_flag & RTS_REQ_PENDING) { - int ret; - - ret = cv_wait_sig(&rts->rts_send_cv, &rts->rts_send_mutex); - if (ret <= 0) { - mutex_exit(&rts->rts_send_mutex); - freemsg(mp); - return (EINTR); - } - } - - rts->rts_flag |= RTS_REQ_PENDING; - - rts->rts_flag |= RTS_REQ_INPROG; - - mutex_exit(&rts->rts_send_mutex); - - CONN_INC_REF(connp); - - error = ip_rts_request_common(rts->rts_connp->conn_wq, mp1, connp, cr); - - mutex_enter(&rts->rts_send_mutex); - if (error == EINPROGRESS) { - ASSERT(rts->rts_flag & RTS_REQ_INPROG); - if (rts->rts_flag & RTS_REQ_INPROG) { - /* - * Once the request has been issued we wait for - * completion - */ - cv_wait(&rts->rts_io_cv, &rts->rts_send_mutex); - error = rts->rts_error; - } - } - - ASSERT((error != 0) || !(rts->rts_flag & RTS_REQ_INPROG)); - ASSERT(MUTEX_HELD(&rts->rts_send_mutex)); - - rts->rts_flag &= ~(RTS_REQ_PENDING | RTS_REQ_INPROG); - cv_signal(&rts->rts_send_cv); - mutex_exit(&rts->rts_send_mutex); + error = ip_rts_request_common(mp, connp, cr); return (error); } @@ -1614,8 +1456,6 @@ rts_create(int family, int type, int proto, sock_downcalls_t **sock_downcalls, uint_t *smodep, int *errorp, int flags, cred_t *credp) { conn_t *connp; - rts_t *rts; - rts_stack_t *rtss; if (family != AF_ROUTE || type != SOCK_RAW || (proto != 0 && proto != AF_INET && proto != AF_INET6)) { @@ -1627,25 +1467,7 @@ rts_create(int family, int type, int proto, sock_downcalls_t **sock_downcalls, ASSERT(connp != NULL); connp->conn_flags |= IPCL_NONSTR; - rts = connp->conn_rts; - rtss = rts->rts_rtss; - - rts->rts_xmit_hiwat = rtss->rtss_xmit_hiwat; - rts->rts_xmit_lowat = rtss->rtss_xmit_lowat; - rts->rts_recv_hiwat = rtss->rtss_recv_hiwat; - rts->rts_recv_lowat = rts_mod_info.mi_lowat; - - ASSERT(rtss->rtss_ldi_ident != NULL); - - *errorp = ip_create_helper_stream(connp, rtss->rtss_ldi_ident); - if (*errorp != 0) { -#ifdef DEBUG - cmn_err(CE_CONT, "rts_create: create of IP helper stream" - " failed\n"); -#endif - (void) rts_close((sock_lower_handle_t)connp, 0, credp); - return (NULL); - } + connp->conn_proto = proto; mutex_enter(&connp->conn_lock); connp->conn_state_flags &= ~CONN_INCIPIENT; @@ -1663,8 +1485,6 @@ rts_activate(sock_lower_handle_t proto_handle, sock_upper_handle_t sock_handle, sock_upcalls_t *sock_upcalls, int flags, cred_t *cr) { conn_t *connp = (conn_t *)proto_handle; - rts_t *rts = connp->conn_rts; - rts_stack_t *rtss = rts->rts_rtss; struct sock_proto_props sopp; connp->conn_upcalls = sock_upcalls; @@ -1673,8 +1493,8 @@ rts_activate(sock_lower_handle_t proto_handle, sock_upper_handle_t sock_handle, sopp.sopp_flags = SOCKOPT_WROFF | SOCKOPT_RCVHIWAT | SOCKOPT_RCVLOWAT | SOCKOPT_MAXBLK | SOCKOPT_MAXPSZ | SOCKOPT_MINPSZ; sopp.sopp_wroff = 0; - sopp.sopp_rxhiwat = rtss->rtss_recv_hiwat; - sopp.sopp_rxlowat = rts_mod_info.mi_lowat; + sopp.sopp_rxhiwat = connp->conn_rcvbuf; + sopp.sopp_rxlowat = connp->conn_rcvlowat; sopp.sopp_maxblk = INFPSZ; sopp.sopp_maxpsz = rts_mod_info.mi_maxpsz; sopp.sopp_minpsz = (rts_mod_info.mi_minpsz == 1) ? 0 : @@ -1689,12 +1509,7 @@ rts_activate(sock_lower_handle_t proto_handle, sock_upper_handle_t sock_handle, (*connp->conn_upcalls->su_connected) (connp->conn_upper_handle, 0, NULL, -1); - /* - * Indicate the down IP module that this is a routing socket - * client by sending an RTS IOCTL without any user data. Although - * this is just a notification message (without any real routing - * request), we pass in any credential for correctness sake. - */ + /* Indicate to IP that this is a routing socket client */ ip_rts_register(connp); } @@ -1743,6 +1558,27 @@ rts_ioctl(sock_lower_handle_t proto_handle, int cmd, intptr_t arg, conn_t *connp = (conn_t *)proto_handle; int error; + /* + * If we don't have a helper stream then create one. + * ip_create_helper_stream takes care of locking the conn_t, + * so this check for NULL is just a performance optimization. + */ + if (connp->conn_helper_info == NULL) { + rts_stack_t *rtss = connp->conn_rts->rts_rtss; + + ASSERT(rtss->rtss_ldi_ident != NULL); + + /* + * Create a helper stream for non-STREAMS socket. + */ + error = ip_create_helper_stream(connp, rtss->rtss_ldi_ident); + if (error != 0) { + ip0dbg(("rts_ioctl: create of IP helper stream " + "failed %d\n", error)); + return (error); + } + } + switch (cmd) { case ND_SET: case ND_GET: |
