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/dccp_ip.h>
115 #include <inet/dccp/dccp_impl.h>
116 #include <inet/ipclassifier.h>
117 #include <inet/sctp_ip.h>
118 #include <inet/sctp/sctp_impl.h>
119 #include <inet/udp_impl.h>
120 #include <inet/rawip_impl.h>
121 #include <inet/rts_impl.h>
122
123 #include <sys/tsol/label.h>
124 #include <sys/tsol/tnet.h>
125
126 #include <sys/squeue_impl.h>
127 #include <inet/ip_arp.h>
128
129 #include <sys/clock_impl.h> /* For LBOLT_FASTPATH{,64} */
130
131 /*
132 * Values for squeue switch:
133 * IP_SQUEUE_ENTER_NODRAIN: SQ_NODRAIN
134 * IP_SQUEUE_ENTER: SQ_PROCESS
135 * IP_SQUEUE_FILL: SQ_FILL
4296 {
4297 freemsg(mp);
4298 }
4299
4300 /*
4301 * Called when the module is about to be unloaded
4302 */
4303 void
4304 ip_ddi_destroy(void)
4305 {
4306 /* This needs to be called before destroying any transports. */
4307 mutex_enter(&cpu_lock);
4308 unregister_cpu_setup_func(ip_tp_cpu_update, NULL);
4309 mutex_exit(&cpu_lock);
4310
4311 tnet_fini();
4312
4313 icmp_ddi_g_destroy();
4314 rts_ddi_g_destroy();
4315 udp_ddi_g_destroy();
4316 dccp_ddi_g_destroy();
4317 sctp_ddi_g_destroy();
4318 tcp_ddi_g_destroy();
4319 ilb_ddi_g_destroy();
4320 dce_g_destroy();
4321 ipsec_policy_g_destroy();
4322 ipcl_g_destroy();
4323 ip_net_g_destroy();
4324 ip_ire_g_fini();
4325 inet_minor_destroy(ip_minor_arena_sa);
4326 #if defined(_LP64)
4327 inet_minor_destroy(ip_minor_arena_la);
4328 #endif
4329
4330 #ifdef DEBUG
4331 list_destroy(&ip_thread_list);
4332 rw_destroy(&ip_thread_rwlock);
4333 tsd_destroy(&ip_thread_data);
4334 #endif
4335
4336 netstack_unregister(NS_IP);
4533 INET_MIN_DEV + 2, MAXMIN, KM_SLEEP)) == NULL) {
4534 cmn_err(CE_PANIC,
4535 "ip_ddi_init: ip_minor_arena_sa creation failed\n");
4536 }
4537 #endif
4538 ip_poll_normal_ticks = MSEC_TO_TICK_ROUNDUP(ip_poll_normal_ms);
4539
4540 ipcl_g_init();
4541 ip_ire_g_init();
4542 ip_net_g_init();
4543
4544 #ifdef DEBUG
4545 tsd_create(&ip_thread_data, ip_thread_exit);
4546 rw_init(&ip_thread_rwlock, NULL, RW_DEFAULT, NULL);
4547 list_create(&ip_thread_list, sizeof (th_hash_t),
4548 offsetof(th_hash_t, thh_link));
4549 #endif
4550 ipsec_policy_g_init();
4551 tcp_ddi_g_init();
4552 sctp_ddi_g_init();
4553 dccp_ddi_g_init();
4554 dce_g_init();
4555
4556 /*
4557 * We want to be informed each time a stack is created or
4558 * destroyed in the kernel, so we can maintain the
4559 * set of udp_stack_t's.
4560 */
4561 netstack_register(NS_IP, ip_stack_init, ip_stack_shutdown,
4562 ip_stack_fini);
4563
4564 tnet_init();
4565
4566 udp_ddi_g_init();
4567 rts_ddi_g_init();
4568 icmp_ddi_g_init();
4569 ilb_ddi_g_init();
4570
4571 /* This needs to be called after all transports are initialized. */
4572 mutex_enter(&cpu_lock);
4573 register_cpu_setup_func(ip_tp_cpu_update, NULL);
9671
9672 if ((mpctl = ip_snmp_get_mib2_virt_multi(q, mpctl, ipst)) == NULL) {
9673 return (1);
9674 }
9675
9676 if ((mpctl = ip_snmp_get_mib2_multi_rtable(q, mpctl, ipst)) == NULL) {
9677 return (1);
9678 }
9679
9680 mpctl = ip_snmp_get_mib2_ip_route_media(q, mpctl, level, ipst);
9681 if (mpctl == NULL)
9682 return (1);
9683
9684 mpctl = ip_snmp_get_mib2_ip6_route_media(q, mpctl, level, ipst);
9685 if (mpctl == NULL)
9686 return (1);
9687
9688 if ((mpctl = sctp_snmp_get_mib2(q, mpctl, sctps)) == NULL) {
9689 return (1);
9690 }
9691
9692 if ((mpctl = ip_snmp_get_mib2_ip_dce(q, mpctl, ipst)) == NULL) {
9693 return (1);
9694 }
9695
9696 if ((mpctl = dccp_snmp_get(q, mpctl, legacy_req)) == NULL) {
9697 return (1);
9698 }
9699
9700 freemsg(mpctl);
9701 return (1);
9702 }
9703
9704 /* Get global (legacy) IPv4 statistics */
9705 static mblk_t *
9706 ip_snmp_get_mib2_ip(queue_t *q, mblk_t *mpctl, mib2_ipIfStatsEntry_t *ipmib,
9707 ip_stack_t *ipst, boolean_t legacy_req)
9708 {
9709 mib2_ip_t old_ip_mib;
9710 struct opthdr *optp;
9711 mblk_t *mp2ctl;
9712 mib2_ipAddrEntry_t mae;
9713
9714 /*
9715 * make a copy of the original message
9716 */
9717 mp2ctl = copymsg(mpctl);
9718
9719 /* fixed length IP structure... */
15230 * Transport protocol call back function for CPU state change.
15231 */
15232 /* ARGSUSED */
15233 static int
15234 ip_tp_cpu_update(cpu_setup_t what, int id, void *arg)
15235 {
15236 processorid_t cpu_seqid;
15237 netstack_handle_t nh;
15238 netstack_t *ns;
15239
15240 ASSERT(MUTEX_HELD(&cpu_lock));
15241
15242 switch (what) {
15243 case CPU_CONFIG:
15244 case CPU_ON:
15245 case CPU_INIT:
15246 case CPU_CPUPART_IN:
15247 cpu_seqid = cpu[id]->cpu_seqid;
15248 netstack_next_init(&nh);
15249 while ((ns = netstack_next(&nh)) != NULL) {
15250 dccp_stack_cpu_add(ns->netstack_dccp, cpu_seqid);
15251 tcp_stack_cpu_add(ns->netstack_tcp, cpu_seqid);
15252 sctp_stack_cpu_add(ns->netstack_sctp, cpu_seqid);
15253 udp_stack_cpu_add(ns->netstack_udp, cpu_seqid);
15254 netstack_rele(ns);
15255 }
15256 netstack_next_fini(&nh);
15257 break;
15258 case CPU_UNCONFIG:
15259 case CPU_OFF:
15260 case CPU_CPUPART_OUT:
15261 /*
15262 * Nothing to do. We don't remove the per CPU stats from
15263 * the IP stack even when the CPU goes offline.
15264 */
15265 break;
15266 default:
15267 break;
15268 }
15269 return (0);
15270 }
|