kernel - Replace zalloc zones with kmalloc for PCBs
[dragonfly.git] / sys / netinet / ip_divert.c
index 5b1afc6..496c626 100644 (file)
 #include <sys/systm.h>
 #include <sys/proc.h>
 #include <sys/priv.h>
-#include <sys/thread2.h>
 #include <sys/in_cksum.h>
 #include <sys/lock.h>
 #ifdef SMP
 #include <sys/msgport.h>
 #endif
 
-#include <vm/vm_zone.h>
-
 #include <net/if.h>
 #include <net/route.h>
+
 #ifdef SMP
 #include <net/netmsg2.h>
 #endif
+#include <sys/thread2.h>
+#include <sys/mplock2.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
@@ -142,8 +142,7 @@ div_init(void)
        divcbinfo.porthashbase = hashinit(1, M_PCB, &divcbinfo.porthashmask);
        divcbinfo.wildcardhashbase = hashinit(1, M_PCB,
                                              &divcbinfo.wildcardhashmask);
-       divcbinfo.ipi_zone = zinit("divcb", sizeof(struct inpcb),
-                                  maxsockets, ZONE_INTERRUPT, 0);
+       divcbinfo.ipi_size = sizeof(struct inpcb);
        ip_divert_p = ip_divert;
 }
 
@@ -159,17 +158,12 @@ div_input(struct mbuf *m, ...)
 }
 
 struct lwkt_port *
-div_soport(struct socket *so, struct sockaddr *nam,
-          struct mbuf **mptr, int req)
+div_soport(struct socket *so, struct sockaddr *nam, struct mbuf **mptr)
 {
        struct sockaddr_in *sin;
        struct mbuf *m;
        int dir;
 
-       /* Except for send(), everything happens on CPU0 */
-       if (req != PRU_SEND)
-               return cpu0_soport(so, nam, mptr, req);
-
        sin = (struct sockaddr_in *)nam;
        m = *mptr;
        M_ASSERTPKTHDR(m);
@@ -374,8 +368,8 @@ divert_packet(struct mbuf *m, int incoming)
                struct lwkt_msg *msg;
 
                nmp = &m->m_hdr.mh_netmsg;
-               netmsg_init(&nmp->nm_netmsg, &netisr_apanic_rport, MSGF_MPSAFE,
-                           div_packet_handler);
+               netmsg_init(&nmp->nm_netmsg, NULL, &netisr_apanic_rport,
+                   MSGF_MPSAFE, div_packet_handler);
                nmp->nm_packet = m;
 
                msg = &nmp->nm_netmsg.nm_lmsg;
@@ -484,6 +478,7 @@ div_attach(struct socket *so, int proto, struct pru_attach_info *ai)
         * The socket is always "connected" because
         * we always know "where" to send the packet.
         */
+       so->so_port = cpu0_soport(so, NULL, NULL);
        so->so_state |= SS_ISCONNECTED;
        return 0;
 }