summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/inet/tcp/tcp_fusion.c
diff options
context:
space:
mode:
authorErik Nordmark <Erik.Nordmark@Sun.COM>2009-11-11 11:49:49 -0800
committerErik Nordmark <Erik.Nordmark@Sun.COM>2009-11-11 11:49:49 -0800
commitbd670b35a010421b6e1a5536c34453a827007c81 (patch)
tree97c2057b6771dd40411a12eb89d2db2e2b2cce31 /usr/src/uts/common/inet/tcp/tcp_fusion.c
parentb3388e4fc5f5c24c8a39fbe132a00b02dae5b717 (diff)
downloadillumos-gate-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/tcp/tcp_fusion.c')
-rw-r--r--usr/src/uts/common/inet/tcp/tcp_fusion.c440
1 files changed, 146 insertions, 294 deletions
diff --git a/usr/src/uts/common/inet/tcp/tcp_fusion.c b/usr/src/uts/common/inet/tcp/tcp_fusion.c
index 3ee909cc4d..313b024943 100644
--- a/usr/src/uts/common/inet/tcp/tcp_fusion.c
+++ b/usr/src/uts/common/inet/tcp/tcp_fusion.c
@@ -69,50 +69,6 @@
boolean_t do_tcp_fusion = B_TRUE;
/*
- * Return true if this connection needs some IP functionality
- */
-static boolean_t
-tcp_loopback_needs_ip(tcp_t *tcp, netstack_t *ns)
-{
- ipsec_stack_t *ipss = ns->netstack_ipsec;
-
- /*
- * If ire is not cached, do not use fusion
- */
- if (tcp->tcp_connp->conn_ire_cache == NULL) {
- /*
- * There is no need to hold conn_lock here because when called
- * from tcp_fuse() there can be no window where conn_ire_cache
- * can change. This is not true when called from
- * tcp_fuse_output() as conn_ire_cache can become null just
- * after the check. It will be necessary to recheck for a NULL
- * conn_ire_cache in tcp_fuse_output() to avoid passing a
- * stale ill pointer to FW_HOOKS.
- */
- return (B_TRUE);
- }
- if (tcp->tcp_ipversion == IPV4_VERSION) {
- if (tcp->tcp_ip_hdr_len != IP_SIMPLE_HDR_LENGTH)
- return (B_TRUE);
- if (CONN_OUTBOUND_POLICY_PRESENT(tcp->tcp_connp, ipss))
- return (B_TRUE);
- if (CONN_INBOUND_POLICY_PRESENT(tcp->tcp_connp, ipss))
- return (B_TRUE);
- } else {
- if (tcp->tcp_ip_hdr_len != IPV6_HDR_LEN)
- return (B_TRUE);
- if (CONN_OUTBOUND_POLICY_PRESENT_V6(tcp->tcp_connp, ipss))
- return (B_TRUE);
- if (CONN_INBOUND_POLICY_PRESENT_V6(tcp->tcp_connp, ipss))
- return (B_TRUE);
- }
- if (!CONN_IS_LSO_MD_FASTPATH(tcp->tcp_connp))
- return (B_TRUE);
- return (B_FALSE);
-}
-
-
-/*
* This routine gets called by the eager tcp upon changing state from
* SYN_RCVD to ESTABLISHED. It fuses a direct path between itself
* and the active connect tcp such that the regular tcp processings
@@ -124,10 +80,10 @@ tcp_loopback_needs_ip(tcp_t *tcp, netstack_t *ns)
* same squeue as the one given to the active connect tcp during open.
*/
void
-tcp_fuse(tcp_t *tcp, uchar_t *iphdr, tcph_t *tcph)
+tcp_fuse(tcp_t *tcp, uchar_t *iphdr, tcpha_t *tcpha)
{
- conn_t *peer_connp, *connp = tcp->tcp_connp;
- tcp_t *peer_tcp;
+ conn_t *peer_connp, *connp = tcp->tcp_connp;
+ tcp_t *peer_tcp;
tcp_stack_t *tcps = tcp->tcp_tcps;
netstack_t *ns;
ip_stack_t *ipst = tcps->tcps_netstack->netstack_ip;
@@ -136,20 +92,16 @@ tcp_fuse(tcp_t *tcp, uchar_t *iphdr, tcph_t *tcph)
ASSERT(tcp->tcp_loopback);
ASSERT(tcp->tcp_loopback_peer == NULL);
/*
- * We need to inherit tcp_recv_hiwater of the listener tcp,
+ * We need to inherit conn_rcvbuf of the listener tcp,
* but we can't really use tcp_listener since we get here after
- * sending up T_CONN_IND and tcp_wput_accept() may be called
+ * sending up T_CONN_IND and tcp_tli_accept() may be called
* independently, at which point tcp_listener is cleared;
* this is why we use tcp_saved_listener. The listener itself
* is guaranteed to be around until tcp_accept_finish() is called
* on this eager -- this won't happen until we're done since we're
* inside the eager's perimeter now.
- *
- * We can also get called in the case were a connection needs
- * to be re-fused. In this case tcp_saved_listener will be
- * NULL but tcp_refuse will be true.
*/
- ASSERT(tcp->tcp_saved_listener != NULL || tcp->tcp_refuse);
+ ASSERT(tcp->tcp_saved_listener != NULL);
/*
* Lookup peer endpoint; search for the remote endpoint having
* the reversed address-port quadruplet in ESTABLISHED state,
@@ -157,12 +109,12 @@ tcp_fuse(tcp_t *tcp, uchar_t *iphdr, tcph_t *tcph)
* is applied accordingly for loopback address, but not for
* local address since we want fusion to happen across Zones.
*/
- if (tcp->tcp_ipversion == IPV4_VERSION) {
+ if (connp->conn_ipversion == IPV4_VERSION) {
peer_connp = ipcl_conn_tcp_lookup_reversed_ipv4(connp,
- (ipha_t *)iphdr, tcph, ipst);
+ (ipha_t *)iphdr, tcpha, ipst);
} else {
peer_connp = ipcl_conn_tcp_lookup_reversed_ipv6(connp,
- (ip6_t *)iphdr, tcph, ipst);
+ (ip6_t *)iphdr, tcpha, ipst);
}
/*
@@ -202,28 +154,20 @@ tcp_fuse(tcp_t *tcp, uchar_t *iphdr, tcph_t *tcph)
/*
* Fuse the endpoints; we perform further checks against both
* tcp endpoints to ensure that a fusion is allowed to happen.
- * In particular we bail out for non-simple TCP/IP or if IPsec/
- * IPQoS policy/kernel SSL exists. We also need to check if
- * the connection is quiescent to cover the case when we are
- * trying to re-enable fusion after IPobservability is turned off.
+ * In particular we bail out if kernel SSL exists.
*/
ns = tcps->tcps_netstack;
ipst = ns->netstack_ip;
if (!tcp->tcp_unfusable && !peer_tcp->tcp_unfusable &&
- !tcp_loopback_needs_ip(tcp, ns) &&
- !tcp_loopback_needs_ip(peer_tcp, ns) &&
- tcp->tcp_kssl_ent == NULL &&
- tcp->tcp_xmit_head == NULL && peer_tcp->tcp_xmit_head == NULL &&
- !IPP_ENABLED(IPP_LOCAL_OUT|IPP_LOCAL_IN, ipst)) {
+ (tcp->tcp_kssl_ent == NULL) && (tcp->tcp_xmit_head == NULL) &&
+ (peer_tcp->tcp_xmit_head == NULL)) {
mblk_t *mp;
- queue_t *peer_rq = peer_tcp->tcp_rq;
+ queue_t *peer_rq = peer_connp->conn_rq;
ASSERT(!TCP_IS_DETACHED(peer_tcp));
- ASSERT(tcp->tcp_fused_sigurg_mp == NULL ||
- (!IPCL_IS_NONSTR(connp) && tcp->tcp_refuse));
- ASSERT(peer_tcp->tcp_fused_sigurg_mp == NULL ||
- (!IPCL_IS_NONSTR(peer_connp) && peer_tcp->tcp_refuse));
+ ASSERT(tcp->tcp_fused_sigurg_mp == NULL);
+ ASSERT(peer_tcp->tcp_fused_sigurg_mp == NULL);
ASSERT(tcp->tcp_kssl_ctx == NULL);
/*
@@ -272,54 +216,40 @@ tcp_fuse(tcp_t *tcp, uchar_t *iphdr, tcph_t *tcph)
tcp_timers_stop(tcp);
tcp_timers_stop(peer_tcp);
- if (!tcp->tcp_refuse) {
- /*
- * Set receive buffer and max packet size for the
- * active open tcp.
- * eager's values will be set in tcp_accept_finish.
- */
-
- (void) tcp_rwnd_set(peer_tcp,
- peer_tcp->tcp_recv_hiwater);
+ /*
+ * Set receive buffer and max packet size for the
+ * active open tcp.
+ * eager's values will be set in tcp_accept_finish.
+ */
+ (void) tcp_rwnd_set(peer_tcp, peer_tcp->tcp_connp->conn_rcvbuf);
- /*
- * Set the write offset value to zero since we won't
- * be needing any room for TCP/IP headers.
- */
- if (!IPCL_IS_NONSTR(peer_tcp->tcp_connp)) {
- struct stroptions *stropt;
+ /*
+ * Set the write offset value to zero since we won't
+ * be needing any room for TCP/IP headers.
+ */
+ if (!IPCL_IS_NONSTR(peer_tcp->tcp_connp)) {
+ struct stroptions *stropt;
- DB_TYPE(mp) = M_SETOPTS;
- mp->b_wptr += sizeof (*stropt);
+ DB_TYPE(mp) = M_SETOPTS;
+ mp->b_wptr += sizeof (*stropt);
- stropt = (struct stroptions *)mp->b_rptr;
- stropt->so_flags = SO_WROFF;
- stropt->so_wroff = 0;
+ stropt = (struct stroptions *)mp->b_rptr;
+ stropt->so_flags = SO_WROFF;
+ stropt->so_wroff = 0;
- /* Send the options up */
- putnext(peer_rq, mp);
- } else {
- struct sock_proto_props sopp;
+ /* Send the options up */
+ putnext(peer_rq, mp);
+ } else {
+ struct sock_proto_props sopp;
- /* The peer is a non-STREAMS end point */
- ASSERT(IPCL_IS_TCP(peer_connp));
+ /* The peer is a non-STREAMS end point */
+ ASSERT(IPCL_IS_TCP(peer_connp));
- sopp.sopp_flags = SOCKOPT_WROFF;
- sopp.sopp_wroff = 0;
- (*peer_connp->conn_upcalls->su_set_proto_props)
- (peer_connp->conn_upper_handle, &sopp);
- }
- } else {
- /*
- * Endpoints are being re-fused, so options will not
- * be sent up. In case of STREAMS, free the stroptions
- * mblk.
- */
- if (!IPCL_IS_NONSTR(connp))
- freemsg(mp);
+ sopp.sopp_flags = SOCKOPT_WROFF;
+ sopp.sopp_wroff = 0;
+ (*peer_connp->conn_upcalls->su_set_proto_props)
+ (peer_connp->conn_upper_handle, &sopp);
}
- tcp->tcp_refuse = B_FALSE;
- peer_tcp->tcp_refuse = B_FALSE;
} else {
TCP_STAT(tcps, tcp_fusion_unqualified);
}
@@ -374,12 +304,12 @@ tcp_unfuse(tcp_t *tcp)
* when called from tcp_rcv_drain().
*/
if (!TCP_IS_DETACHED(tcp)) {
- (void) tcp_fuse_rcv_drain(tcp->tcp_rq, tcp,
+ (void) tcp_fuse_rcv_drain(tcp->tcp_connp->conn_rq, tcp,
&tcp->tcp_fused_sigurg_mp);
}
if (!TCP_IS_DETACHED(peer_tcp)) {
- (void) tcp_fuse_rcv_drain(peer_tcp->tcp_rq, peer_tcp,
- &peer_tcp->tcp_fused_sigurg_mp);
+ (void) tcp_fuse_rcv_drain(peer_tcp->tcp_connp->conn_rq,
+ peer_tcp, &peer_tcp->tcp_fused_sigurg_mp);
}
/* Lift up any flow-control conditions */
@@ -398,12 +328,12 @@ tcp_unfuse(tcp_t *tcp)
mutex_exit(&peer_tcp->tcp_non_sq_lock);
/*
- * Update th_seq and th_ack in the header template
+ * Update tha_seq and tha_ack in the header template
*/
- U32_TO_ABE32(tcp->tcp_snxt, tcp->tcp_tcph->th_seq);
- U32_TO_ABE32(tcp->tcp_rnxt, tcp->tcp_tcph->th_ack);
- U32_TO_ABE32(peer_tcp->tcp_snxt, peer_tcp->tcp_tcph->th_seq);
- U32_TO_ABE32(peer_tcp->tcp_rnxt, peer_tcp->tcp_tcph->th_ack);
+ tcp->tcp_tcpha->tha_seq = htonl(tcp->tcp_snxt);
+ tcp->tcp_tcpha->tha_ack = htonl(tcp->tcp_rnxt);
+ peer_tcp->tcp_tcpha->tha_seq = htonl(peer_tcp->tcp_snxt);
+ peer_tcp->tcp_tcpha->tha_ack = htonl(peer_tcp->tcp_rnxt);
/* Unfuse the endpoints */
peer_tcp->tcp_fused = tcp->tcp_fused = B_FALSE;
@@ -509,59 +439,28 @@ tcp_fuse_output_urg(tcp_t *tcp, mblk_t *mp)
boolean_t
tcp_fuse_output(tcp_t *tcp, mblk_t *mp, uint32_t send_size)
{
- tcp_t *peer_tcp = tcp->tcp_loopback_peer;
- boolean_t flow_stopped, peer_data_queued = B_FALSE;
- boolean_t urgent = (DB_TYPE(mp) != M_DATA);
- boolean_t push = B_TRUE;
- mblk_t *mp1 = mp;
- ill_t *ilp, *olp;
- ipif_t *iifp, *oifp;
- ipha_t *ipha;
- ip6_t *ip6h;
- tcph_t *tcph;
- uint_t ip_hdr_len;
- uint32_t seq;
- uint32_t recv_size = send_size;
+ conn_t *connp = tcp->tcp_connp;
+ tcp_t *peer_tcp = tcp->tcp_loopback_peer;
+ conn_t *peer_connp = peer_tcp->tcp_connp;
+ boolean_t flow_stopped, peer_data_queued = B_FALSE;
+ boolean_t urgent = (DB_TYPE(mp) != M_DATA);
+ boolean_t push = B_TRUE;
+ mblk_t *mp1 = mp;
+ uint_t ip_hdr_len;
+ uint32_t recv_size = send_size;
tcp_stack_t *tcps = tcp->tcp_tcps;
netstack_t *ns = tcps->tcps_netstack;
ip_stack_t *ipst = ns->netstack_ip;
+ ipsec_stack_t *ipss = ns->netstack_ipsec;
+ iaflags_t ixaflags = connp->conn_ixa->ixa_flags;
+ boolean_t do_ipsec, hooks_out, hooks_in, ipobs_enabled;
ASSERT(tcp->tcp_fused);
ASSERT(peer_tcp != NULL && peer_tcp->tcp_loopback_peer == tcp);
- ASSERT(tcp->tcp_connp->conn_sqp == peer_tcp->tcp_connp->conn_sqp);
+ ASSERT(connp->conn_sqp == peer_connp->conn_sqp);
ASSERT(DB_TYPE(mp) == M_DATA || DB_TYPE(mp) == M_PROTO ||
DB_TYPE(mp) == M_PCPROTO);
- /* If this connection requires IP, unfuse and use regular path */
- if (tcp_loopback_needs_ip(tcp, ns) ||
- tcp_loopback_needs_ip(peer_tcp, ns) ||
- IPP_ENABLED(IPP_LOCAL_OUT|IPP_LOCAL_IN, ipst) ||
- (tcp->tcp_ipversion == IPV4_VERSION &&
- ipst->ips_ip4_observe.he_interested) ||
- (tcp->tcp_ipversion == IPV6_VERSION &&
- ipst->ips_ip6_observe.he_interested)) {
- TCP_STAT(tcps, tcp_fusion_aborted);
- tcp->tcp_refuse = B_TRUE;
- peer_tcp->tcp_refuse = B_TRUE;
-
- bcopy(peer_tcp->tcp_tcph, &tcp->tcp_saved_tcph,
- sizeof (tcph_t));
- bcopy(tcp->tcp_tcph, &peer_tcp->tcp_saved_tcph,
- sizeof (tcph_t));
- if (tcp->tcp_ipversion == IPV4_VERSION) {
- bcopy(peer_tcp->tcp_ipha, &tcp->tcp_saved_ipha,
- sizeof (ipha_t));
- bcopy(tcp->tcp_ipha, &peer_tcp->tcp_saved_ipha,
- sizeof (ipha_t));
- } else {
- bcopy(peer_tcp->tcp_ip6h, &tcp->tcp_saved_ip6h,
- sizeof (ip6_t));
- bcopy(tcp->tcp_ip6h, &peer_tcp->tcp_saved_ip6h,
- sizeof (ip6_t));
- }
- goto unfuse;
- }
-
if (send_size == 0) {
freemsg(mp);
return (B_TRUE);
@@ -578,123 +477,74 @@ tcp_fuse_output(tcp_t *tcp, mblk_t *mp, uint32_t send_size)
mp1 = mp->b_cont;
}
- if (tcp->tcp_ipversion == IPV4_VERSION &&
- (HOOKS4_INTERESTED_LOOPBACK_IN(ipst) ||
- HOOKS4_INTERESTED_LOOPBACK_OUT(ipst)) ||
- tcp->tcp_ipversion == IPV6_VERSION &&
- (HOOKS6_INTERESTED_LOOPBACK_IN(ipst) ||
- HOOKS6_INTERESTED_LOOPBACK_OUT(ipst))) {
- /*
- * Build ip and tcp header to satisfy FW_HOOKS.
- * We only build it when any hook is present.
- */
+ /*
+ * Check that we are still using an IRE_LOCAL or IRE_LOOPBACK before
+ * further processes.
+ */
+ if (!ip_output_verify_local(connp->conn_ixa))
+ goto unfuse;
+
+ /*
+ * Build IP and TCP header in case we have something that needs the
+ * headers. Those cases are:
+ * 1. IPsec
+ * 2. IPobs
+ * 3. FW_HOOKS
+ *
+ * If tcp_xmit_mp() fails to dupb() the message, unfuse the connection
+ * and back to regular path.
+ */
+ if (ixaflags & IXAF_IS_IPV4) {
+ do_ipsec = (ixaflags & IXAF_IPSEC_SECURE) ||
+ CONN_INBOUND_POLICY_PRESENT(peer_connp, ipss);
+
+ hooks_out = HOOKS4_INTERESTED_LOOPBACK_OUT(ipst);
+ hooks_in = HOOKS4_INTERESTED_LOOPBACK_IN(ipst);
+ ipobs_enabled = (ipst->ips_ip4_observe.he_interested != 0);
+ } else {
+ do_ipsec = (ixaflags & IXAF_IPSEC_SECURE) ||
+ CONN_INBOUND_POLICY_PRESENT_V6(peer_connp, ipss);
+
+ hooks_out = HOOKS6_INTERESTED_LOOPBACK_OUT(ipst);
+ hooks_in = HOOKS6_INTERESTED_LOOPBACK_IN(ipst);
+ ipobs_enabled = (ipst->ips_ip6_observe.he_interested != 0);
+ }
+
+ /* We do logical 'or' for efficiency */
+ if (ipobs_enabled | do_ipsec | hooks_in | hooks_out) {
if ((mp1 = tcp_xmit_mp(tcp, mp1, tcp->tcp_mss, NULL, NULL,
tcp->tcp_snxt, B_TRUE, NULL, B_FALSE)) == NULL)
/* If tcp_xmit_mp fails, use regular path */
goto unfuse;
/*
- * The ipif and ill can be safely referenced under the
- * protection of conn_lock - see head of function comment for
- * conn_get_held_ipif(). It is necessary to check that both
- * the ipif and ill can be looked up (i.e. not condemned). If
- * not, bail out and unfuse this connection.
+ * Leave all IP relevant processes to ip_output_process_local(),
+ * which handles IPsec, IPobs, and FW_HOOKS.
*/
- mutex_enter(&peer_tcp->tcp_connp->conn_lock);
- if ((peer_tcp->tcp_connp->conn_ire_cache == NULL) ||
- (peer_tcp->tcp_connp->conn_ire_cache->ire_marks &
- IRE_MARK_CONDEMNED) ||
- ((oifp = peer_tcp->tcp_connp->conn_ire_cache->ire_ipif)
- == NULL) ||
- (!IPIF_CAN_LOOKUP(oifp)) ||
- ((olp = oifp->ipif_ill) == NULL) ||
- (ill_check_and_refhold(olp) != 0)) {
- mutex_exit(&peer_tcp->tcp_connp->conn_lock);
- goto unfuse;
- }
- mutex_exit(&peer_tcp->tcp_connp->conn_lock);
-
- /* PFHooks: LOOPBACK_OUT */
- if (tcp->tcp_ipversion == IPV4_VERSION) {
- ipha = (ipha_t *)mp1->b_rptr;
-
- DTRACE_PROBE4(ip4__loopback__out__start,
- ill_t *, NULL, ill_t *, olp,
- ipha_t *, ipha, mblk_t *, mp1);
- FW_HOOKS(ipst->ips_ip4_loopback_out_event,
- ipst->ips_ipv4firewall_loopback_out,
- NULL, olp, ipha, mp1, mp1, 0, ipst);
- DTRACE_PROBE1(ip4__loopback__out__end, mblk_t *, mp1);
- } else {
- ip6h = (ip6_t *)mp1->b_rptr;
-
- DTRACE_PROBE4(ip6__loopback__out__start,
- ill_t *, NULL, ill_t *, olp,
- ip6_t *, ip6h, mblk_t *, mp1);
- FW_HOOKS6(ipst->ips_ip6_loopback_out_event,
- ipst->ips_ipv6firewall_loopback_out,
- NULL, olp, ip6h, mp1, mp1, 0, ipst);
- DTRACE_PROBE1(ip6__loopback__out__end, mblk_t *, mp1);
- }
- ill_refrele(olp);
+ mp1 = ip_output_process_local(mp1, connp->conn_ixa, hooks_out,
+ hooks_in, do_ipsec ? peer_connp : NULL);
+ /* If the message is dropped for any reason. */
if (mp1 == NULL)
goto unfuse;
/*
- * The ipif and ill can be safely referenced under the
- * protection of conn_lock - see head of function comment for
- * conn_get_held_ipif(). It is necessary to check that both
- * the ipif and ill can be looked up (i.e. not condemned). If
- * not, bail out and unfuse this connection.
+ * Data length might have been changed by FW_HOOKS.
+ * We assume that the first mblk contains the TCP/IP headers.
*/
- mutex_enter(&tcp->tcp_connp->conn_lock);
- if ((tcp->tcp_connp->conn_ire_cache == NULL) ||
- (tcp->tcp_connp->conn_ire_cache->ire_marks &
- IRE_MARK_CONDEMNED) ||
- ((iifp = tcp->tcp_connp->conn_ire_cache->ire_ipif)
- == NULL) ||
- (!IPIF_CAN_LOOKUP(iifp)) ||
- ((ilp = iifp->ipif_ill) == NULL) ||
- (ill_check_and_refhold(ilp) != 0)) {
- mutex_exit(&tcp->tcp_connp->conn_lock);
- goto unfuse;
- }
- mutex_exit(&tcp->tcp_connp->conn_lock);
-
- /* PFHooks: LOOPBACK_IN */
- if (tcp->tcp_ipversion == IPV4_VERSION) {
- DTRACE_PROBE4(ip4__loopback__in__start,
- ill_t *, ilp, ill_t *, NULL,
- ipha_t *, ipha, mblk_t *, mp1);
- FW_HOOKS(ipst->ips_ip4_loopback_in_event,
- ipst->ips_ipv4firewall_loopback_in,
- ilp, NULL, ipha, mp1, mp1, 0, ipst);
- DTRACE_PROBE1(ip4__loopback__in__end, mblk_t *, mp1);
- ill_refrele(ilp);
- if (mp1 == NULL)
- goto unfuse;
-
- ip_hdr_len = IPH_HDR_LENGTH(ipha);
- } else {
- DTRACE_PROBE4(ip6__loopback__in__start,
- ill_t *, ilp, ill_t *, NULL,
- ip6_t *, ip6h, mblk_t *, mp1);
- FW_HOOKS6(ipst->ips_ip6_loopback_in_event,
- ipst->ips_ipv6firewall_loopback_in,
- ilp, NULL, ip6h, mp1, mp1, 0, ipst);
- DTRACE_PROBE1(ip6__loopback__in__end, mblk_t *, mp1);
- ill_refrele(ilp);
- if (mp1 == NULL)
- goto unfuse;
-
- ip_hdr_len = ip_hdr_length_v6(mp1, ip6h);
- }
+ if (hooks_in || hooks_out) {
+ tcpha_t *tcpha;
+
+ ip_hdr_len = (ixaflags & IXAF_IS_IPV4) ?
+ IPH_HDR_LENGTH((ipha_t *)mp1->b_rptr) :
+ ip_hdr_length_v6(mp1, (ip6_t *)mp1->b_rptr);
- /* Data length might be changed by FW_HOOKS */
- tcph = (tcph_t *)&mp1->b_rptr[ip_hdr_len];
- seq = ABE32_TO_U32(tcph->th_seq);
- recv_size += seq - tcp->tcp_snxt;
+ tcpha = (tcpha_t *)&mp1->b_rptr[ip_hdr_len];
+ ASSERT((uchar_t *)tcpha + sizeof (tcpha_t) <=
+ mp1->b_wptr);
+ recv_size += htonl(tcpha->tha_seq) - tcp->tcp_snxt;
+
+ }
/*
* The message duplicated by tcp_xmit_mp is freed.
@@ -712,7 +562,7 @@ tcp_fuse_output(tcp_t *tcp, mblk_t *mp, uint32_t send_size)
* detached we use tcp_rcv_enqueue() instead. Queued data will be
* drained when the accept completes (in tcp_accept_finish()).
*/
- if (IPCL_IS_NONSTR(peer_tcp->tcp_connp) &&
+ if (IPCL_IS_NONSTR(peer_connp) &&
!TCP_IS_DETACHED(peer_tcp)) {
int error;
int flags = 0;
@@ -720,18 +570,18 @@ tcp_fuse_output(tcp_t *tcp, mblk_t *mp, uint32_t send_size)
if ((tcp->tcp_valid_bits & TCP_URG_VALID) &&
(tcp->tcp_urg == tcp->tcp_snxt)) {
flags = MSG_OOB;
- (*peer_tcp->tcp_connp->conn_upcalls->su_signal_oob)
- (peer_tcp->tcp_connp->conn_upper_handle, 0);
+ (*peer_connp->conn_upcalls->su_signal_oob)
+ (peer_connp->conn_upper_handle, 0);
tcp->tcp_valid_bits &= ~TCP_URG_VALID;
}
- if ((*peer_tcp->tcp_connp->conn_upcalls->su_recv)(
- peer_tcp->tcp_connp->conn_upper_handle, mp, recv_size,
+ if ((*peer_connp->conn_upcalls->su_recv)(
+ peer_connp->conn_upper_handle, mp, recv_size,
flags, &error, &push) < 0) {
ASSERT(error != EOPNOTSUPP);
peer_data_queued = B_TRUE;
}
} else {
- if (IPCL_IS_NONSTR(peer_tcp->tcp_connp) &&
+ if (IPCL_IS_NONSTR(peer_connp) &&
(tcp->tcp_valid_bits & TCP_URG_VALID) &&
(tcp->tcp_urg == tcp->tcp_snxt)) {
/*
@@ -744,7 +594,8 @@ tcp_fuse_output(tcp_t *tcp, mblk_t *mp, uint32_t send_size)
return (B_TRUE);
}
- tcp_rcv_enqueue(peer_tcp, mp, recv_size);
+ tcp_rcv_enqueue(peer_tcp, mp, recv_size,
+ tcp->tcp_connp->conn_cred);
/* In case it wrapped around and also to keep it constant */
peer_tcp->tcp_rwnd += recv_size;
@@ -764,22 +615,21 @@ tcp_fuse_output(tcp_t *tcp, mblk_t *mp, uint32_t send_size)
mutex_enter(&tcp->tcp_non_sq_lock);
flow_stopped = tcp->tcp_flow_stopped;
if ((TCP_IS_DETACHED(peer_tcp) &&
- (peer_tcp->tcp_rcv_cnt >= peer_tcp->tcp_recv_hiwater)) ||
+ (peer_tcp->tcp_rcv_cnt >= peer_connp->conn_rcvbuf)) ||
(!TCP_IS_DETACHED(peer_tcp) &&
- !IPCL_IS_NONSTR(peer_tcp->tcp_connp) &&
- !canputnext(peer_tcp->tcp_rq))) {
+ !IPCL_IS_NONSTR(peer_connp) && !canputnext(peer_connp->conn_rq))) {
peer_data_queued = B_TRUE;
}
if (!flow_stopped && (peer_data_queued ||
- (TCP_UNSENT_BYTES(tcp) >= tcp->tcp_xmit_hiwater))) {
+ (TCP_UNSENT_BYTES(tcp) >= connp->conn_sndbuf))) {
tcp_setqfull(tcp);
flow_stopped = B_TRUE;
TCP_STAT(tcps, tcp_fusion_flowctl);
DTRACE_PROBE3(tcp__fuse__output__flowctl, tcp_t *, tcp,
uint_t, send_size, uint_t, peer_tcp->tcp_rcv_cnt);
} else if (flow_stopped && !peer_data_queued &&
- (TCP_UNSENT_BYTES(tcp) <= tcp->tcp_xmit_lowater)) {
+ (TCP_UNSENT_BYTES(tcp) <= connp->conn_sndlowat)) {
tcp_clrqfull(tcp);
TCP_STAT(tcps, tcp_fusion_backenabled);
flow_stopped = B_FALSE;
@@ -818,13 +668,14 @@ tcp_fuse_output(tcp_t *tcp, mblk_t *mp, uint32_t send_size)
/*
* For TLI-based streams, a thread in tcp_accept_swap()
* can race with us. That thread will ensure that the
- * correct peer_tcp->tcp_rq is globally visible before
- * peer_tcp->tcp_detached is visible as clear, but we
- * must also ensure that the load of tcp_rq cannot be
- * reordered to be before the tcp_detached check.
+ * correct peer_connp->conn_rq is globally visible
+ * before peer_tcp->tcp_detached is visible as clear,
+ * but we must also ensure that the load of conn_rq
+ * cannot be reordered to be before the tcp_detached
+ * check.
*/
membar_consumer();
- (void) tcp_fuse_rcv_drain(peer_tcp->tcp_rq, peer_tcp,
+ (void) tcp_fuse_rcv_drain(peer_connp->conn_rq, peer_tcp,
NULL);
}
}
@@ -928,11 +779,11 @@ tcp_fuse_rcv_drain(queue_t *q, tcp_t *tcp, mblk_t **sigurg_mpp)
tcp->tcp_rcv_last_head = NULL;
tcp->tcp_rcv_last_tail = NULL;
tcp->tcp_rcv_cnt = 0;
- tcp->tcp_rwnd = tcp->tcp_recv_hiwater;
+ tcp->tcp_rwnd = tcp->tcp_connp->conn_rcvbuf;
mutex_enter(&peer_tcp->tcp_non_sq_lock);
if (peer_tcp->tcp_flow_stopped && (TCP_UNSENT_BYTES(peer_tcp) <=
- peer_tcp->tcp_xmit_lowater)) {
+ peer_tcp->tcp_connp->conn_sndlowat)) {
tcp_clrqfull(peer_tcp);
TCP_STAT(tcps, tcp_fusion_backenabled);
}
@@ -964,8 +815,8 @@ tcp_fuse_set_rcv_hiwat(tcp_t *tcp, size_t rwnd)
* Record high water mark, this is used for flow-control
* purposes in tcp_fuse_output().
*/
- tcp->tcp_recv_hiwater = rwnd;
- tcp->tcp_rwnd = tcp->tcp_recv_hiwater;
+ tcp->tcp_connp->conn_rcvbuf = rwnd;
+ tcp->tcp_rwnd = rwnd;
return (rwnd);
}
@@ -976,12 +827,13 @@ int
tcp_fuse_maxpsz(tcp_t *tcp)
{
tcp_t *peer_tcp = tcp->tcp_loopback_peer;
- uint_t sndbuf = tcp->tcp_xmit_hiwater;
+ conn_t *connp = tcp->tcp_connp;
+ uint_t sndbuf = connp->conn_sndbuf;
uint_t maxpsz = sndbuf;
ASSERT(tcp->tcp_fused);
ASSERT(peer_tcp != NULL);
- ASSERT(peer_tcp->tcp_recv_hiwater != 0);
+ ASSERT(peer_tcp->tcp_connp->conn_rcvbuf != 0);
/*
* In the fused loopback case, we want the stream head to split
* up larger writes into smaller chunks for a more accurate flow-
@@ -990,8 +842,8 @@ tcp_fuse_maxpsz(tcp_t *tcp)
* We round up the buffer to system page size due to the lack of
* TCP MSS concept in Fusion.
*/
- if (maxpsz > peer_tcp->tcp_recv_hiwater)
- maxpsz = peer_tcp->tcp_recv_hiwater;
+ if (maxpsz > peer_tcp->tcp_connp->conn_rcvbuf)
+ maxpsz = peer_tcp->tcp_connp->conn_rcvbuf;
maxpsz = P2ROUNDUP_TYPED(maxpsz, PAGESIZE, uint_t) >> 1;
return (maxpsz);
@@ -1013,12 +865,12 @@ tcp_fuse_backenable(tcp_t *tcp)
peer_tcp->tcp_connp->conn_sqp);
if (tcp->tcp_rcv_list != NULL)
- (void) tcp_fuse_rcv_drain(tcp->tcp_rq, tcp, NULL);
+ (void) tcp_fuse_rcv_drain(tcp->tcp_connp->conn_rq, tcp, NULL);
mutex_enter(&peer_tcp->tcp_non_sq_lock);
if (peer_tcp->tcp_flow_stopped &&
(TCP_UNSENT_BYTES(peer_tcp) <=
- peer_tcp->tcp_xmit_lowater)) {
+ peer_tcp->tcp_connp->conn_sndlowat)) {
tcp_clrqfull(peer_tcp);
}
mutex_exit(&peer_tcp->tcp_non_sq_lock);