Print this page
dccp: starting module template


  94 #include <netinet/ip_mroute.h>
  95 #include <inet/ipp_common.h>
  96 
  97 #include <net/pfkeyv2.h>
  98 #include <inet/sadb.h>
  99 #include <inet/ipsec_impl.h>
 100 #include <inet/iptun/iptun_impl.h>
 101 #include <inet/ipdrop.h>
 102 #include <inet/ip_netinfo.h>
 103 #include <inet/ilb_ip.h>
 104 
 105 #include <sys/ethernet.h>
 106 #include <net/if_types.h>
 107 #include <sys/cpuvar.h>
 108 
 109 #include <ipp/ipp.h>
 110 #include <ipp/ipp_impl.h>
 111 #include <ipp/ipgpc/ipgpc.h>
 112 
 113 #include <sys/pattr.h>



 114 #include <inet/ipclassifier.h>
 115 #include <inet/sctp_ip.h>
 116 #include <inet/sctp/sctp_impl.h>
 117 #include <inet/udp_impl.h>
 118 #include <inet/rawip_impl.h>
 119 #include <inet/rts_impl.h>
 120 
 121 #include <sys/tsol/label.h>
 122 #include <sys/tsol/tnet.h>
 123 
 124 #include <sys/squeue_impl.h>
 125 #include <inet/ip_arp.h>
 126 
 127 #include <sys/clock_impl.h>       /* For LBOLT_FASTPATH{,64} */
 128 
 129 /*
 130  * Values for squeue switch:
 131  * IP_SQUEUE_ENTER_NODRAIN: SQ_NODRAIN
 132  * IP_SQUEUE_ENTER: SQ_PROCESS
 133  * IP_SQUEUE_FILL: SQ_FILL


4294 {
4295         freemsg(mp);
4296 }
4297 
4298 /*
4299  * Called when the module is about to be unloaded
4300  */
4301 void
4302 ip_ddi_destroy(void)
4303 {
4304         /* This needs to be called before destroying any transports. */
4305         mutex_enter(&cpu_lock);
4306         unregister_cpu_setup_func(ip_tp_cpu_update, NULL);
4307         mutex_exit(&cpu_lock);
4308 
4309         tnet_fini();
4310 
4311         icmp_ddi_g_destroy();
4312         rts_ddi_g_destroy();
4313         udp_ddi_g_destroy();

4314         sctp_ddi_g_destroy();
4315         tcp_ddi_g_destroy();
4316         ilb_ddi_g_destroy();
4317         dce_g_destroy();
4318         ipsec_policy_g_destroy();
4319         ipcl_g_destroy();
4320         ip_net_g_destroy();
4321         ip_ire_g_fini();
4322         inet_minor_destroy(ip_minor_arena_sa);
4323 #if defined(_LP64)
4324         inet_minor_destroy(ip_minor_arena_la);
4325 #endif
4326 
4327 #ifdef DEBUG
4328         list_destroy(&ip_thread_list);
4329         rw_destroy(&ip_thread_rwlock);
4330         tsd_destroy(&ip_thread_data);
4331 #endif
4332 
4333         netstack_unregister(NS_IP);


4530             INET_MIN_DEV + 2, MAXMIN, KM_SLEEP)) == NULL) {
4531                 cmn_err(CE_PANIC,
4532                     "ip_ddi_init: ip_minor_arena_sa creation failed\n");
4533         }
4534 #endif
4535         ip_poll_normal_ticks = MSEC_TO_TICK_ROUNDUP(ip_poll_normal_ms);
4536 
4537         ipcl_g_init();
4538         ip_ire_g_init();
4539         ip_net_g_init();
4540 
4541 #ifdef DEBUG
4542         tsd_create(&ip_thread_data, ip_thread_exit);
4543         rw_init(&ip_thread_rwlock, NULL, RW_DEFAULT, NULL);
4544         list_create(&ip_thread_list, sizeof (th_hash_t),
4545             offsetof(th_hash_t, thh_link));
4546 #endif
4547         ipsec_policy_g_init();
4548         tcp_ddi_g_init();
4549         sctp_ddi_g_init();

4550         dce_g_init();
4551 
4552         /*
4553          * We want to be informed each time a stack is created or
4554          * destroyed in the kernel, so we can maintain the
4555          * set of udp_stack_t's.
4556          */
4557         netstack_register(NS_IP, ip_stack_init, ip_stack_shutdown,
4558             ip_stack_fini);
4559 
4560         tnet_init();
4561 
4562         udp_ddi_g_init();
4563         rts_ddi_g_init();
4564         icmp_ddi_g_init();
4565         ilb_ddi_g_init();
4566 
4567         /* This needs to be called after all transports are initialized. */
4568         mutex_enter(&cpu_lock);
4569         register_cpu_setup_func(ip_tp_cpu_update, NULL);


9667 
9668         if ((mpctl = ip_snmp_get_mib2_virt_multi(q, mpctl, ipst)) == NULL) {
9669                 return (1);
9670         }
9671 
9672         if ((mpctl = ip_snmp_get_mib2_multi_rtable(q, mpctl, ipst)) == NULL) {
9673                 return (1);
9674         }
9675 
9676         mpctl = ip_snmp_get_mib2_ip_route_media(q, mpctl, level, ipst);
9677         if (mpctl == NULL)
9678                 return (1);
9679 
9680         mpctl = ip_snmp_get_mib2_ip6_route_media(q, mpctl, level, ipst);
9681         if (mpctl == NULL)
9682                 return (1);
9683 
9684         if ((mpctl = sctp_snmp_get_mib2(q, mpctl, sctps)) == NULL) {
9685                 return (1);
9686         }

9687         if ((mpctl = ip_snmp_get_mib2_ip_dce(q, mpctl, ipst)) == NULL) {
9688                 return (1);
9689         }





9690         freemsg(mpctl);
9691         return (1);
9692 }
9693 
9694 /* Get global (legacy) IPv4 statistics */
9695 static mblk_t *
9696 ip_snmp_get_mib2_ip(queue_t *q, mblk_t *mpctl, mib2_ipIfStatsEntry_t *ipmib,
9697     ip_stack_t *ipst, boolean_t legacy_req)
9698 {
9699         mib2_ip_t               old_ip_mib;
9700         struct opthdr           *optp;
9701         mblk_t                  *mp2ctl;
9702         mib2_ipAddrEntry_t      mae;
9703 
9704         /*
9705          * make a copy of the original message
9706          */
9707         mp2ctl = copymsg(mpctl);
9708 
9709         /* fixed length IP structure... */


15220  * Transport protocol call back function for CPU state change.
15221  */
15222 /* ARGSUSED */
15223 static int
15224 ip_tp_cpu_update(cpu_setup_t what, int id, void *arg)
15225 {
15226         processorid_t cpu_seqid;
15227         netstack_handle_t nh;
15228         netstack_t *ns;
15229 
15230         ASSERT(MUTEX_HELD(&cpu_lock));
15231 
15232         switch (what) {
15233         case CPU_CONFIG:
15234         case CPU_ON:
15235         case CPU_INIT:
15236         case CPU_CPUPART_IN:
15237                 cpu_seqid = cpu[id]->cpu_seqid;
15238                 netstack_next_init(&nh);
15239                 while ((ns = netstack_next(&nh)) != NULL) {

15240                         tcp_stack_cpu_add(ns->netstack_tcp, cpu_seqid);
15241                         sctp_stack_cpu_add(ns->netstack_sctp, cpu_seqid);
15242                         udp_stack_cpu_add(ns->netstack_udp, cpu_seqid);
15243                         netstack_rele(ns);
15244                 }
15245                 netstack_next_fini(&nh);
15246                 break;
15247         case CPU_UNCONFIG:
15248         case CPU_OFF:
15249         case CPU_CPUPART_OUT:
15250                 /*
15251                  * Nothing to do.  We don't remove the per CPU stats from
15252                  * the IP stack even when the CPU goes offline.
15253                  */
15254                 break;
15255         default:
15256                 break;
15257         }
15258         return (0);
15259 }


  94 #include <netinet/ip_mroute.h>
  95 #include <inet/ipp_common.h>
  96 
  97 #include <net/pfkeyv2.h>
  98 #include <inet/sadb.h>
  99 #include <inet/ipsec_impl.h>
 100 #include <inet/iptun/iptun_impl.h>
 101 #include <inet/ipdrop.h>
 102 #include <inet/ip_netinfo.h>
 103 #include <inet/ilb_ip.h>
 104 
 105 #include <sys/ethernet.h>
 106 #include <net/if_types.h>
 107 #include <sys/cpuvar.h>
 108 
 109 #include <ipp/ipp.h>
 110 #include <ipp/ipp_impl.h>
 111 #include <ipp/ipgpc/ipgpc.h>
 112 
 113 #include <sys/pattr.h>
 114 #include <inet/dccp.h>
 115 #include <inet/dccp_impl.h>
 116 #include <inet/dccp_ip.h>
 117 #include <inet/ipclassifier.h>
 118 #include <inet/sctp_ip.h>
 119 #include <inet/sctp/sctp_impl.h>
 120 #include <inet/udp_impl.h>
 121 #include <inet/rawip_impl.h>
 122 #include <inet/rts_impl.h>
 123 
 124 #include <sys/tsol/label.h>
 125 #include <sys/tsol/tnet.h>
 126 
 127 #include <sys/squeue_impl.h>
 128 #include <inet/ip_arp.h>
 129 
 130 #include <sys/clock_impl.h>       /* For LBOLT_FASTPATH{,64} */
 131 
 132 /*
 133  * Values for squeue switch:
 134  * IP_SQUEUE_ENTER_NODRAIN: SQ_NODRAIN
 135  * IP_SQUEUE_ENTER: SQ_PROCESS
 136  * IP_SQUEUE_FILL: SQ_FILL


4297 {
4298         freemsg(mp);
4299 }
4300 
4301 /*
4302  * Called when the module is about to be unloaded
4303  */
4304 void
4305 ip_ddi_destroy(void)
4306 {
4307         /* This needs to be called before destroying any transports. */
4308         mutex_enter(&cpu_lock);
4309         unregister_cpu_setup_func(ip_tp_cpu_update, NULL);
4310         mutex_exit(&cpu_lock);
4311 
4312         tnet_fini();
4313 
4314         icmp_ddi_g_destroy();
4315         rts_ddi_g_destroy();
4316         udp_ddi_g_destroy();
4317         dccp_ddi_g_destroy();
4318         sctp_ddi_g_destroy();
4319         tcp_ddi_g_destroy();
4320         ilb_ddi_g_destroy();
4321         dce_g_destroy();
4322         ipsec_policy_g_destroy();
4323         ipcl_g_destroy();
4324         ip_net_g_destroy();
4325         ip_ire_g_fini();
4326         inet_minor_destroy(ip_minor_arena_sa);
4327 #if defined(_LP64)
4328         inet_minor_destroy(ip_minor_arena_la);
4329 #endif
4330 
4331 #ifdef DEBUG
4332         list_destroy(&ip_thread_list);
4333         rw_destroy(&ip_thread_rwlock);
4334         tsd_destroy(&ip_thread_data);
4335 #endif
4336 
4337         netstack_unregister(NS_IP);


4534             INET_MIN_DEV + 2, MAXMIN, KM_SLEEP)) == NULL) {
4535                 cmn_err(CE_PANIC,
4536                     "ip_ddi_init: ip_minor_arena_sa creation failed\n");
4537         }
4538 #endif
4539         ip_poll_normal_ticks = MSEC_TO_TICK_ROUNDUP(ip_poll_normal_ms);
4540 
4541         ipcl_g_init();
4542         ip_ire_g_init();
4543         ip_net_g_init();
4544 
4545 #ifdef DEBUG
4546         tsd_create(&ip_thread_data, ip_thread_exit);
4547         rw_init(&ip_thread_rwlock, NULL, RW_DEFAULT, NULL);
4548         list_create(&ip_thread_list, sizeof (th_hash_t),
4549             offsetof(th_hash_t, thh_link));
4550 #endif
4551         ipsec_policy_g_init();
4552         tcp_ddi_g_init();
4553         sctp_ddi_g_init();
4554         dccp_ddi_g_init();
4555         dce_g_init();
4556 
4557         /*
4558          * We want to be informed each time a stack is created or
4559          * destroyed in the kernel, so we can maintain the
4560          * set of udp_stack_t's.
4561          */
4562         netstack_register(NS_IP, ip_stack_init, ip_stack_shutdown,
4563             ip_stack_fini);
4564 
4565         tnet_init();
4566 
4567         udp_ddi_g_init();
4568         rts_ddi_g_init();
4569         icmp_ddi_g_init();
4570         ilb_ddi_g_init();
4571 
4572         /* This needs to be called after all transports are initialized. */
4573         mutex_enter(&cpu_lock);
4574         register_cpu_setup_func(ip_tp_cpu_update, NULL);


9672 
9673         if ((mpctl = ip_snmp_get_mib2_virt_multi(q, mpctl, ipst)) == NULL) {
9674                 return (1);
9675         }
9676 
9677         if ((mpctl = ip_snmp_get_mib2_multi_rtable(q, mpctl, ipst)) == NULL) {
9678                 return (1);
9679         }
9680 
9681         mpctl = ip_snmp_get_mib2_ip_route_media(q, mpctl, level, ipst);
9682         if (mpctl == NULL)
9683                 return (1);
9684 
9685         mpctl = ip_snmp_get_mib2_ip6_route_media(q, mpctl, level, ipst);
9686         if (mpctl == NULL)
9687                 return (1);
9688 
9689         if ((mpctl = sctp_snmp_get_mib2(q, mpctl, sctps)) == NULL) {
9690                 return (1);
9691         }
9692 
9693         if ((mpctl = ip_snmp_get_mib2_ip_dce(q, mpctl, ipst)) == NULL) {
9694                 return (1);
9695         }
9696 
9697         if ((mpctl = dccp_snmp_get(q, mpctl, legacy_req)) == NULL) {
9698                 return (1);
9699         }
9700 
9701         freemsg(mpctl);
9702         return (1);
9703 }
9704 
9705 /* Get global (legacy) IPv4 statistics */
9706 static mblk_t *
9707 ip_snmp_get_mib2_ip(queue_t *q, mblk_t *mpctl, mib2_ipIfStatsEntry_t *ipmib,
9708     ip_stack_t *ipst, boolean_t legacy_req)
9709 {
9710         mib2_ip_t               old_ip_mib;
9711         struct opthdr           *optp;
9712         mblk_t                  *mp2ctl;
9713         mib2_ipAddrEntry_t      mae;
9714 
9715         /*
9716          * make a copy of the original message
9717          */
9718         mp2ctl = copymsg(mpctl);
9719 
9720         /* fixed length IP structure... */


15231  * Transport protocol call back function for CPU state change.
15232  */
15233 /* ARGSUSED */
15234 static int
15235 ip_tp_cpu_update(cpu_setup_t what, int id, void *arg)
15236 {
15237         processorid_t cpu_seqid;
15238         netstack_handle_t nh;
15239         netstack_t *ns;
15240 
15241         ASSERT(MUTEX_HELD(&cpu_lock));
15242 
15243         switch (what) {
15244         case CPU_CONFIG:
15245         case CPU_ON:
15246         case CPU_INIT:
15247         case CPU_CPUPART_IN:
15248                 cpu_seqid = cpu[id]->cpu_seqid;
15249                 netstack_next_init(&nh);
15250                 while ((ns = netstack_next(&nh)) != NULL) {
15251                         dccp_stack_cpu_add(ns->netstack_dccp, cpu_seqid);
15252                         tcp_stack_cpu_add(ns->netstack_tcp, cpu_seqid);
15253                         sctp_stack_cpu_add(ns->netstack_sctp, cpu_seqid);
15254                         udp_stack_cpu_add(ns->netstack_udp, cpu_seqid);
15255                         netstack_rele(ns);
15256                 }
15257                 netstack_next_fini(&nh);
15258                 break;
15259         case CPU_UNCONFIG:
15260         case CPU_OFF:
15261         case CPU_CPUPART_OUT:
15262                 /*
15263                  * Nothing to do.  We don't remove the per CPU stats from
15264                  * the IP stack even when the CPU goes offline.
15265                  */
15266                 break;
15267         default:
15268                 break;
15269         }
15270         return (0);
15271 }