Print this page
dccp: ips_ipcl_dccp_fanout


  99 #include <inet/ipsec_impl.h>
 100 #include <inet/ipdrop.h>
 101 #include <inet/ip_netinfo.h>
 102 #include <inet/ilb_ip.h>
 103 #include <sys/squeue_impl.h>
 104 #include <sys/squeue.h>
 105 
 106 #include <sys/ethernet.h>
 107 #include <net/if_types.h>
 108 #include <sys/cpuvar.h>
 109 
 110 #include <ipp/ipp.h>
 111 #include <ipp/ipp_impl.h>
 112 #include <ipp/ipgpc/ipgpc.h>
 113 
 114 #include <sys/pattr.h>
 115 #include <inet/ipclassifier.h>
 116 #include <inet/sctp_ip.h>
 117 #include <inet/sctp/sctp_impl.h>
 118 #include <inet/udp_impl.h>

 119 #include <sys/sunddi.h>
 120 
 121 #include <sys/tsol/label.h>
 122 #include <sys/tsol/tnet.h>
 123 
 124 #include <sys/clock_impl.h>       /* For LBOLT_FASTPATH{,64} */
 125 
 126 #ifdef  DEBUG
 127 extern boolean_t skip_sctp_cksum;
 128 #endif
 129 
 130 static void     ip_input_local_v4(ire_t *, mblk_t *, ipha_t *,
 131     ip_recv_attr_t *);
 132 
 133 static void     ip_input_broadcast_v4(ire_t *, mblk_t *, ipha_t *,
 134     ip_recv_attr_t *);
 135 static void     ip_input_multicast_v4(ire_t *, mblk_t *, ipha_t *,
 136     ip_recv_attr_t *);
 137 
 138 #pragma inline(ip_input_common_v4, ip_input_local_v4, ip_forward_xmit_v4)


2372                         /* ip_drop_packet and MIB done */
2373                         return;
2374                 }
2375         }
2376 
2377         /* Determine the minimum required size of the upper-layer header */
2378         /* Need to do this for at least the set of ULPs that TX handles. */
2379         switch (protocol) {
2380         case IPPROTO_TCP:
2381                 min_ulp_header_length = TCP_MIN_HEADER_LENGTH;
2382                 break;
2383         case IPPROTO_SCTP:
2384                 min_ulp_header_length = SCTP_COMMON_HDR_LENGTH;
2385                 break;
2386         case IPPROTO_UDP:
2387                 min_ulp_header_length = UDPH_SIZE;
2388                 break;
2389         case IPPROTO_ICMP:
2390                 min_ulp_header_length = ICMPH_SIZE;
2391                 break;



2392         default:
2393                 min_ulp_header_length = 0;
2394                 break;
2395         }
2396         /* Make sure we have the min ULP header length */
2397         len = mp->b_wptr - rptr;
2398         if (len < ip_hdr_length + min_ulp_header_length) {
2399                 if (ira->ira_pktlen < ip_hdr_length + min_ulp_header_length) {
2400                         BUMP_MIB(ill->ill_ip_mib, ipIfStatsInTruncatedPkts);
2401                         ip_drop_input("ipIfStatsInTruncatedPkts", mp, ill);
2402                         freemsg(mp);
2403                         return;
2404                 }
2405                 IP_STAT(ipst, ip_recv_pullup);
2406                 ipha = ip_pullup(mp, ip_hdr_length + min_ulp_header_length,
2407                     ira);
2408                 if (ipha == NULL)
2409                         goto discard;
2410                 len = mp->b_wptr - rptr;
2411         }


2697                                  * Packet was consumed - probably sent to
2698                                  * ip_fanout_v4.
2699                                  */
2700                                 CONN_DEC_REF(connp);
2701                                 return;
2702                         }
2703                         /* Else continue like a normal UDP packet. */
2704                         ipha = (ipha_t *)mp->b_rptr;
2705                         protocol = ipha->ipha_protocol;
2706                         ira->ira_protocol = protocol;
2707                 }
2708                 /* Found a client; up it goes */
2709                 IP_STAT(ipst, ip_udp_fannorm);
2710                 BUMP_MIB(ill->ill_ip_mib, ipIfStatsHCInDelivers);
2711                 ira->ira_ill = ira->ira_rill = NULL;
2712                 (connp->conn_recv)(connp, mp, NULL, ira);
2713                 CONN_DEC_REF(connp);
2714                 ira->ira_ill = ill;
2715                 ira->ira_rill = rill;
2716                 return;




























































2717         default:
2718                 break;
2719         }
2720 
2721         /*
2722          * Clear hardware checksumming flag as it is currently only
2723          * used by TCP and UDP.
2724          */
2725         DB_CKSUMFLAGS(mp) = 0;
2726 
2727         switch (protocol) {
2728         case IPPROTO_ICMP:
2729                 /*
2730                  * We need to accomodate icmp messages coming in clear
2731                  * until we get everything secure from the wire. If
2732                  * icmp_accept_clear_messages is zero we check with
2733                  * the global policy and act accordingly. If it is
2734                  * non-zero, we accept the message without any checks.
2735                  * But *this does not mean* that this will be delivered
2736                  * to RAW socket clients. By accepting we might send




  99 #include <inet/ipsec_impl.h>
 100 #include <inet/ipdrop.h>
 101 #include <inet/ip_netinfo.h>
 102 #include <inet/ilb_ip.h>
 103 #include <sys/squeue_impl.h>
 104 #include <sys/squeue.h>
 105 
 106 #include <sys/ethernet.h>
 107 #include <net/if_types.h>
 108 #include <sys/cpuvar.h>
 109 
 110 #include <ipp/ipp.h>
 111 #include <ipp/ipp_impl.h>
 112 #include <ipp/ipgpc/ipgpc.h>
 113 
 114 #include <sys/pattr.h>
 115 #include <inet/ipclassifier.h>
 116 #include <inet/sctp_ip.h>
 117 #include <inet/sctp/sctp_impl.h>
 118 #include <inet/udp_impl.h>
 119 #include <inet/dccp/dccp_impl.h>
 120 #include <sys/sunddi.h>
 121 
 122 #include <sys/tsol/label.h>
 123 #include <sys/tsol/tnet.h>
 124 
 125 #include <sys/clock_impl.h>       /* For LBOLT_FASTPATH{,64} */
 126 
 127 #ifdef  DEBUG
 128 extern boolean_t skip_sctp_cksum;
 129 #endif
 130 
 131 static void     ip_input_local_v4(ire_t *, mblk_t *, ipha_t *,
 132     ip_recv_attr_t *);
 133 
 134 static void     ip_input_broadcast_v4(ire_t *, mblk_t *, ipha_t *,
 135     ip_recv_attr_t *);
 136 static void     ip_input_multicast_v4(ire_t *, mblk_t *, ipha_t *,
 137     ip_recv_attr_t *);
 138 
 139 #pragma inline(ip_input_common_v4, ip_input_local_v4, ip_forward_xmit_v4)


2373                         /* ip_drop_packet and MIB done */
2374                         return;
2375                 }
2376         }
2377 
2378         /* Determine the minimum required size of the upper-layer header */
2379         /* Need to do this for at least the set of ULPs that TX handles. */
2380         switch (protocol) {
2381         case IPPROTO_TCP:
2382                 min_ulp_header_length = TCP_MIN_HEADER_LENGTH;
2383                 break;
2384         case IPPROTO_SCTP:
2385                 min_ulp_header_length = SCTP_COMMON_HDR_LENGTH;
2386                 break;
2387         case IPPROTO_UDP:
2388                 min_ulp_header_length = UDPH_SIZE;
2389                 break;
2390         case IPPROTO_ICMP:
2391                 min_ulp_header_length = ICMPH_SIZE;
2392                 break;
2393         case IPPROTO_DCCP:
2394                 min_ulp_header_length = DCCP_MIN_HEADER_LENGTH;
2395                 break;
2396         default:
2397                 min_ulp_header_length = 0;
2398                 break;
2399         }
2400         /* Make sure we have the min ULP header length */
2401         len = mp->b_wptr - rptr;
2402         if (len < ip_hdr_length + min_ulp_header_length) {
2403                 if (ira->ira_pktlen < ip_hdr_length + min_ulp_header_length) {
2404                         BUMP_MIB(ill->ill_ip_mib, ipIfStatsInTruncatedPkts);
2405                         ip_drop_input("ipIfStatsInTruncatedPkts", mp, ill);
2406                         freemsg(mp);
2407                         return;
2408                 }
2409                 IP_STAT(ipst, ip_recv_pullup);
2410                 ipha = ip_pullup(mp, ip_hdr_length + min_ulp_header_length,
2411                     ira);
2412                 if (ipha == NULL)
2413                         goto discard;
2414                 len = mp->b_wptr - rptr;
2415         }


2701                                  * Packet was consumed - probably sent to
2702                                  * ip_fanout_v4.
2703                                  */
2704                                 CONN_DEC_REF(connp);
2705                                 return;
2706                         }
2707                         /* Else continue like a normal UDP packet. */
2708                         ipha = (ipha_t *)mp->b_rptr;
2709                         protocol = ipha->ipha_protocol;
2710                         ira->ira_protocol = protocol;
2711                 }
2712                 /* Found a client; up it goes */
2713                 IP_STAT(ipst, ip_udp_fannorm);
2714                 BUMP_MIB(ill->ill_ip_mib, ipIfStatsHCInDelivers);
2715                 ira->ira_ill = ira->ira_rill = NULL;
2716                 (connp->conn_recv)(connp, mp, NULL, ira);
2717                 CONN_DEC_REF(connp);
2718                 ira->ira_ill = ill;
2719                 ira->ira_rill = rill;
2720                 return;
2721         case IPPROTO_DCCP:
2722                 /* For DCCP, discard broadcast and multicast packets */
2723                 if (iraflags & IRAF_MULTIBROADCAST) {
2724                         goto discard;
2725                 }
2726 
2727                 /* First mblk contains IP+DCCP headers per above check */
2728                 ASSERT(len >= ip_hdr_length + DCCP_MIN_HEADER_LENGTH);
2729 
2730                 /* XXX:DCCP valid options */
2731 
2732                 /* Squeue hint */
2733                 if (ira->ira_sqp == NULL) {
2734                         ira->ira_sqp = ip_squeue_get(ira->ira_ring);
2735                 }
2736 
2737                 connp = ipcl_classify_v4(mp, IPPROTO_DCCP, ip_hdr_length,
2738                     ira, ipst);
2739                 if (connp == NULL) {
2740                         cmn_err(CE_NOTE, "ip_input.c: ip_fanout_v4 connp not found");
2741                         /* Send the reset packet */
2742                         BUMP_MIB(ill->ill_ip_mib, ipIfStatsHCInDelivers);
2743                         dccp_xmit_listeners_reset(mp, ira, ipst, NULL);
2744                         return;
2745                 }
2746 
2747                 if (connp->conn_incoming_ifindex != 0 &&
2748                     connp->conn_incoming_ifindex != ira->ira_ruifindex) {
2749                         cmn_err(CE_NOTE, "ip_input.c: ip_fanout_v4 ifindex problem");
2750                         /* Send the reset packet */
2751                         BUMP_MIB(ill->ill_ip_mib, ipIfStatsHCInDelivers);
2752                         dccp_xmit_listeners_reset(mp, ira, ipst, NULL);
2753                         return;
2754                 }
2755 
2756                 if (CONN_INBOUND_POLICY_PRESENT(connp, ipss) ||
2757                     (iraflags & IRAF_IPSEC_SECURE)) {
2758                         mp = ipsec_check_inbound_policy(mp, connp,
2759                             ipha, NULL, ira);
2760                         if (mp == NULL) {
2761                                 BUMP_MIB(ill->ill_ip_mib, ipIfStatsInDiscards);
2762                                 /* Note that mp is NULL */
2763                                 ip_drop_input("ipIfStatsInDiscards", mp, ill);
2764                                 CONN_DEC_REF(connp);
2765                                 return;
2766                         }
2767                 }
2768 
2769                 /* Found a client; up it goes */
2770                 BUMP_MIB(ill->ill_ip_mib, ipIfStatsHCInDelivers);
2771                 ira->ira_ill = ira->ira_rill = NULL;
2772 
2773                 /* XXX SOCK_RAW for DCCP? */
2774 
2775                 SQUEUE_ENTER_ONE(connp->conn_sqp, mp, connp->conn_recv,
2776                     connp, ira, ip_squeue_flag, SQTAG_IP_DCCP_INPUT);
2777 
2778                 ira->ira_ill = ill;
2779                 ira->ira_rill = rill;
2780                 return;
2781         default:
2782                 break;
2783         }
2784 
2785         /*
2786          * Clear hardware checksumming flag as it is currently only
2787          * used by TCP and UDP.
2788          */
2789         DB_CKSUMFLAGS(mp) = 0;
2790 
2791         switch (protocol) {
2792         case IPPROTO_ICMP:
2793                 /*
2794                  * We need to accomodate icmp messages coming in clear
2795                  * until we get everything secure from the wire. If
2796                  * icmp_accept_clear_messages is zero we check with
2797                  * the global policy and act accordingly. If it is
2798                  * non-zero, we accept the message without any checks.
2799                  * But *this does not mean* that this will be delivered
2800                  * to RAW socket clients. By accepting we might send