properly free mbuf space
[unix-history] / usr / src / sys / netinet / ip_icmp.c
index 51656bc..8cf82fd 100644 (file)
@@ -1,4 +1,4 @@
-/*     ip_icmp.c       4.8     81/11/26        */
+/*     ip_icmp.c       4.13    82/04/07        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -42,7 +42,7 @@ COUNT(ICMP_ERROR);
         * of the mbuf, followed by the old IP header and 8 bytes
         * of its data.
         */
         * of the mbuf, followed by the old IP header and 8 bytes
         * of its data.
         */
-       m = m_get(0);
+       m = m_get(M_DONTWAIT);
        if (m == 0)
                goto free;
        m->m_off = MMAXOFF - (oiplen + 8);
        if (m == 0)
                goto free;
        m->m_off = MMAXOFF - (oiplen + 8);
@@ -64,10 +64,10 @@ COUNT(ICMP_ERROR);
        *nip = *oip;
        icmp_reflect(nip);
 
        *nip = *oip;
        icmp_reflect(nip);
 
+free:
        /*
         * Discard mbufs of original datagram
         */
        /*
         * Discard mbufs of original datagram
         */
-free:
        m_freem(dtom(oip));
 }
 
        m_freem(dtom(oip));
 }
 
@@ -82,6 +82,7 @@ icmp_input(m)
        int hlen = ip->ip_hl << 2;
        int icmplen = ip->ip_len - hlen;
        int i;
        int hlen = ip->ip_hl << 2;
        int icmplen = ip->ip_len - hlen;
        int i;
+       extern u_char ip_protox[];
 COUNT(ICMP_INPUT);
 
        /*
 COUNT(ICMP_INPUT);
 
        /*
@@ -113,7 +114,7 @@ COUNT(ICMP_INPUT);
                 */
                if (icmplen < ICMP_ADVLENMIN || icmplen < ICMP_ADVLEN(icp))
                        goto free;
                 */
                if (icmplen < ICMP_ADVLENMIN || icmplen < ICMP_ADVLEN(icp))
                        goto free;
-               icmp_ctlinput(ip);
+               (*protosw[ip_protox[ip->ip_p]].pr_ctlinput)(m);
                goto free;
 
        case ICMP_ECHO:
                goto free;
 
        case ICMP_ECHO:
@@ -173,26 +174,17 @@ COUNT(ICMP_REFLECT);
 icmp_send(ip)
        struct ip *ip;
 {
 icmp_send(ip)
        struct ip *ip;
 {
-       struct icmp *icp = 0;                                   /* XXX */
 COUNT(ICMP_SEND);
 
 COUNT(ICMP_SEND);
 
-       icp->icmp_cksum = 0;
-       icp->icmp_cksum = in_cksum(dtom(ip), 0);                /* XXX */
-       ip->ip_ttl = MAXTTL;
-       ip_output(dtom(ip), (struct mbuf *)0);
+       m_freem(dtom(ip));
 }
 
 }
 
-/*
- * Advise a higher level protocol of a problem reported by
- * a gateway or another host.
- */
-icmp_ctlinput(ip)
-       struct ip *ip;
+icmp_ctlinput(m)
+       struct mbuf *m;
 {
 {
-       extern u_char ip_protox[];              /* XXX */
 COUNT(ICMP_CTLINPUT);
 
 COUNT(ICMP_CTLINPUT);
 
-       (*protosw[ip_protox[ip->ip_p]].pr_ctlinput)(ip);
+       m_freem(m);
 }
 
 /*
 }
 
 /*