MFREE -> m_freediff -r1.170 -r1.171 src/sys/net/if_gre.c
(christos)
--- src/sys/net/if_gre.c 2016/08/07 17:38:33 1.170
+++ src/sys/net/if_gre.c 2016/10/02 14:17:07 1.171
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_gre.c,v 1.170 2016/08/07 17:38:33 christos Exp $ */ | 1 | /* $NetBSD: if_gre.c,v 1.171 2016/10/02 14:17:07 christos Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Heiko W.Rupp <hwr@pilhuhn.de> | 8 | * by Heiko W.Rupp <hwr@pilhuhn.de> | |
9 | * | 9 | * | |
10 | * IPv6-over-GRE contributed by Gert Doering <gert@greenie.muc.de> | 10 | * IPv6-over-GRE contributed by Gert Doering <gert@greenie.muc.de> | |
11 | * | 11 | * | |
12 | * GRE over UDP/IPv4/IPv6 sockets contributed by David Young <dyoung@NetBSD.org> | 12 | * GRE over UDP/IPv4/IPv6 sockets contributed by David Young <dyoung@NetBSD.org> | |
13 | * | 13 | * | |
14 | * Redistribution and use in source and binary forms, with or without | 14 | * Redistribution and use in source and binary forms, with or without | |
@@ -35,27 +35,27 @@ | @@ -35,27 +35,27 @@ | |||
35 | * This material is based upon work partially supported by NSF | 35 | * This material is based upon work partially supported by NSF | |
36 | * under Contract No. NSF CNS-0626584. | 36 | * under Contract No. NSF CNS-0626584. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | /* | 39 | /* | |
40 | * Encapsulate L3 protocols into IP | 40 | * Encapsulate L3 protocols into IP | |
41 | * See RFC 1701 and 1702 for more details. | 41 | * See RFC 1701 and 1702 for more details. | |
42 | * If_gre is compatible with Cisco GRE tunnels, so you can | 42 | * If_gre is compatible with Cisco GRE tunnels, so you can | |
43 | * have a NetBSD box as the other end of a tunnel interface of a Cisco | 43 | * have a NetBSD box as the other end of a tunnel interface of a Cisco | |
44 | * router. See gre(4) for more details. | 44 | * router. See gre(4) for more details. | |
45 | */ | 45 | */ | |
46 | 46 | |||
47 | #include <sys/cdefs.h> | 47 | #include <sys/cdefs.h> | |
48 | __KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.170 2016/08/07 17:38:33 christos Exp $"); | 48 | __KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.171 2016/10/02 14:17:07 christos Exp $"); | |
49 | 49 | |||
50 | #ifdef _KERNEL_OPT | 50 | #ifdef _KERNEL_OPT | |
51 | #include "opt_atalk.h" | 51 | #include "opt_atalk.h" | |
52 | #include "opt_gre.h" | 52 | #include "opt_gre.h" | |
53 | #include "opt_inet.h" | 53 | #include "opt_inet.h" | |
54 | #include "opt_mpls.h" | 54 | #include "opt_mpls.h" | |
55 | #endif | 55 | #endif | |
56 | 56 | |||
57 | #include <sys/param.h> | 57 | #include <sys/param.h> | |
58 | #include <sys/file.h> | 58 | #include <sys/file.h> | |
59 | #include <sys/filedesc.h> | 59 | #include <sys/filedesc.h> | |
60 | #include <sys/malloc.h> | 60 | #include <sys/malloc.h> | |
61 | #include <sys/mallocvar.h> | 61 | #include <sys/mallocvar.h> | |
@@ -599,40 +599,38 @@ gre_soreceive(struct socket *so, struct | @@ -599,40 +599,38 @@ gre_soreceive(struct socket *so, struct | |||
599 | */ | 599 | */ | |
600 | if (curlwp != NULL) | 600 | if (curlwp != NULL) | |
601 | curlwp->l_ru.ru_msgrcv++; | 601 | curlwp->l_ru.ru_msgrcv++; | |
602 | KASSERT(m == so->so_rcv.sb_mb); | 602 | KASSERT(m == so->so_rcv.sb_mb); | |
603 | SBLASTRECORDCHK(&so->so_rcv, "soreceive 1"); | 603 | SBLASTRECORDCHK(&so->so_rcv, "soreceive 1"); | |
604 | SBLASTMBUFCHK(&so->so_rcv, "soreceive 1"); | 604 | SBLASTMBUFCHK(&so->so_rcv, "soreceive 1"); | |
605 | nextrecord = m->m_nextpkt; | 605 | nextrecord = m->m_nextpkt; | |
606 | if (pr->pr_flags & PR_ADDR) { | 606 | if (pr->pr_flags & PR_ADDR) { | |
607 | #ifdef DIAGNOSTIC | 607 | #ifdef DIAGNOSTIC | |
608 | if (m->m_type != MT_SONAME) | 608 | if (m->m_type != MT_SONAME) | |
609 | panic("receive 1a"); | 609 | panic("receive 1a"); | |
610 | #endif | 610 | #endif | |
611 | sbfree(&so->so_rcv, m); | 611 | sbfree(&so->so_rcv, m); | |
612 | MFREE(m, so->so_rcv.sb_mb); | 612 | m = so->so_rcv.sb_mb = m_free(m); | |
613 | m = so->so_rcv.sb_mb; | |||
614 | } | 613 | } | |
615 | while (m != NULL && m->m_type == MT_CONTROL && error == 0) { | 614 | while (m != NULL && m->m_type == MT_CONTROL && error == 0) { | |
616 | sbfree(&so->so_rcv, m); | 615 | sbfree(&so->so_rcv, m); | |
617 | /* | 616 | /* | |
618 | * Dispose of any SCM_RIGHTS message that went | 617 | * Dispose of any SCM_RIGHTS message that went | |
619 | * through the read path rather than recv. | 618 | * through the read path rather than recv. | |
620 | */ | 619 | */ | |
621 | if (pr->pr_domain->dom_dispose && | 620 | if (pr->pr_domain->dom_dispose && | |
622 | mtod(m, struct cmsghdr *)->cmsg_type == SCM_RIGHTS) | 621 | mtod(m, struct cmsghdr *)->cmsg_type == SCM_RIGHTS) | |
623 | (*pr->pr_domain->dom_dispose)(m); | 622 | (*pr->pr_domain->dom_dispose)(m); | |
624 | MFREE(m, so->so_rcv.sb_mb); | 623 | m = so->so_rcv.sb_mb = m_free(m); | |
625 | m = so->so_rcv.sb_mb; | |||
626 | } | 624 | } | |
627 | 625 | |||
628 | /* | 626 | /* | |
629 | * If m is non-NULL, we have some data to read. From now on, | 627 | * If m is non-NULL, we have some data to read. From now on, | |
630 | * make sure to keep sb_lastrecord consistent when working on | 628 | * make sure to keep sb_lastrecord consistent when working on | |
631 | * the last packet on the chain (nextrecord == NULL) and we | 629 | * the last packet on the chain (nextrecord == NULL) and we | |
632 | * change m->m_nextpkt. | 630 | * change m->m_nextpkt. | |
633 | */ | 631 | */ | |
634 | if (m != NULL) { | 632 | if (m != NULL) { | |
635 | m->m_nextpkt = nextrecord; | 633 | m->m_nextpkt = nextrecord; | |
636 | /* | 634 | /* | |
637 | * If nextrecord == NULL (this is a single chain), | 635 | * If nextrecord == NULL (this is a single chain), | |
638 | * then sb_lastrecord may not be valid here if m | 636 | * then sb_lastrecord may not be valid here if m |
--- src/sys/net/if_ppp.c 2016/08/07 17:38:34 1.157
+++ src/sys/net/if_ppp.c 2016/10/02 14:17:07 1.158
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_ppp.c,v 1.157 2016/08/07 17:38:34 christos Exp $ */ | 1 | /* $NetBSD: if_ppp.c,v 1.158 2016/10/02 14:17:07 christos Exp $ */ | |
2 | /* Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp */ | 2 | /* Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver. | 5 | * if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver. | |
6 | * | 6 | * | |
7 | * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. | 7 | * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * | 12 | * | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -92,27 +92,27 @@ | @@ -92,27 +92,27 @@ | |||
92 | /* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */ | 92 | /* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */ | |
93 | 93 | |||
94 | /* | 94 | /* | |
95 | * XXX IMP ME HARDER | 95 | * XXX IMP ME HARDER | |
96 | * | 96 | * | |
97 | * This is an explanation of that comment. This code used to use | 97 | * This is an explanation of that comment. This code used to use | |
98 | * splimp() to block both network and tty interrupts. However, | 98 | * splimp() to block both network and tty interrupts. However, | |
99 | * that call is deprecated. So, we have replaced the uses of | 99 | * that call is deprecated. So, we have replaced the uses of | |
100 | * splimp() with splhigh() in order to applomplish what it needs | 100 | * splimp() with splhigh() in order to applomplish what it needs | |
101 | * to accomplish, and added that happy little comment. | 101 | * to accomplish, and added that happy little comment. | |
102 | */ | 102 | */ | |
103 | 103 | |||
104 | #include <sys/cdefs.h> | 104 | #include <sys/cdefs.h> | |
105 | __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.157 2016/08/07 17:38:34 christos Exp $"); | 105 | __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.158 2016/10/02 14:17:07 christos Exp $"); | |
106 | 106 | |||
107 | #ifdef _KERNEL_OPT | 107 | #ifdef _KERNEL_OPT | |
108 | #include "ppp.h" | 108 | #include "ppp.h" | |
109 | #include "opt_inet.h" | 109 | #include "opt_inet.h" | |
110 | #include "opt_gateway.h" | 110 | #include "opt_gateway.h" | |
111 | #include "opt_ppp.h" | 111 | #include "opt_ppp.h" | |
112 | #endif | 112 | #endif | |
113 | 113 | |||
114 | #ifdef INET | 114 | #ifdef INET | |
115 | #define VJC | 115 | #define VJC | |
116 | #endif | 116 | #endif | |
117 | #define PPP_COMPRESS | 117 | #define PPP_COMPRESS | |
118 | 118 | |||
@@ -1583,27 +1583,27 @@ ppp_inproc(struct ppp_softc *sc, struct | @@ -1583,27 +1583,27 @@ ppp_inproc(struct ppp_softc *sc, struct | |||
1583 | bcopy(iphdr, cp + PPP_HDRLEN, hlen); | 1583 | bcopy(iphdr, cp + PPP_HDRLEN, hlen); | |
1584 | mp->m_len = hlen + PPP_HDRLEN; | 1584 | mp->m_len = hlen + PPP_HDRLEN; | |
1585 | 1585 | |||
1586 | /* | 1586 | /* | |
1587 | * Trim the PPP and VJ headers off the old mbuf | 1587 | * Trim the PPP and VJ headers off the old mbuf | |
1588 | * and stick the new and old mbufs together. | 1588 | * and stick the new and old mbufs together. | |
1589 | */ | 1589 | */ | |
1590 | m->m_data += PPP_HDRLEN + xlen; | 1590 | m->m_data += PPP_HDRLEN + xlen; | |
1591 | m->m_len -= PPP_HDRLEN + xlen; | 1591 | m->m_len -= PPP_HDRLEN + xlen; | |
1592 | if (m->m_len <= M_TRAILINGSPACE(mp)) { | 1592 | if (m->m_len <= M_TRAILINGSPACE(mp)) { | |
1593 | bcopy(mtod(m, u_char *), | 1593 | bcopy(mtod(m, u_char *), | |
1594 | mtod(mp, u_char *) + mp->m_len, m->m_len); | 1594 | mtod(mp, u_char *) + mp->m_len, m->m_len); | |
1595 | mp->m_len += m->m_len; | 1595 | mp->m_len += m->m_len; | |
1596 | MFREE(m, mp->m_next); | 1596 | mp->m_next = m_free(m); | |
1597 | } else | 1597 | } else | |
1598 | mp->m_next = m; | 1598 | mp->m_next = m; | |
1599 | m = mp; | 1599 | m = mp; | |
1600 | ilen += hlen - xlen; | 1600 | ilen += hlen - xlen; | |
1601 | 1601 | |||
1602 | } else if (proto == PPP_VJC_UNCOMP) { | 1602 | } else if (proto == PPP_VJC_UNCOMP) { | |
1603 | if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0) | 1603 | if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0) | |
1604 | goto bad; | 1604 | goto bad; | |
1605 | 1605 | |||
1606 | xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, | 1606 | xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, | |
1607 | m->m_len - PPP_HDRLEN, ilen - PPP_HDRLEN, | 1607 | m->m_len - PPP_HDRLEN, ilen - PPP_HDRLEN, | |
1608 | TYPE_UNCOMPRESSED_TCP, sc->sc_comp, &iphdr, &hlen); | 1608 | TYPE_UNCOMPRESSED_TCP, sc->sc_comp, &iphdr, &hlen); | |
1609 | 1609 |
--- src/sys/net/if_sl.c 2016/08/07 17:38:34 1.126
+++ src/sys/net/if_sl.c 2016/10/02 14:17:07 1.127
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_sl.c,v 1.126 2016/08/07 17:38:34 christos Exp $ */ | 1 | /* $NetBSD: if_sl.c,v 1.127 2016/10/02 14:17:07 christos Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1987, 1989, 1992, 1993 | 4 | * Copyright (c) 1987, 1989, 1992, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -50,27 +50,27 @@ | @@ -50,27 +50,27 @@ | |||
50 | * Converted to 4.3BSD Beta by Chris Torek. | 50 | * Converted to 4.3BSD Beta by Chris Torek. | |
51 | * Other changes made at Berkeley, based in part on code by Kirk Smith. | 51 | * Other changes made at Berkeley, based in part on code by Kirk Smith. | |
52 | * W. Jolitz added slip abort. | 52 | * W. Jolitz added slip abort. | |
53 | * | 53 | * | |
54 | * Hacked almost beyond recognition by Van Jacobson (van@helios.ee.lbl.gov). | 54 | * Hacked almost beyond recognition by Van Jacobson (van@helios.ee.lbl.gov). | |
55 | * Added priority queuing for "interactive" traffic; hooks for TCP | 55 | * Added priority queuing for "interactive" traffic; hooks for TCP | |
56 | * header compression; ICMP filtering (at 2400 baud, some cretin | 56 | * header compression; ICMP filtering (at 2400 baud, some cretin | |
57 | * pinging you can use up all your bandwidth). Made low clist behavior | 57 | * pinging you can use up all your bandwidth). Made low clist behavior | |
58 | * more robust and slightly less likely to hang serial line. | 58 | * more robust and slightly less likely to hang serial line. | |
59 | * Sped up a bunch of things. | 59 | * Sped up a bunch of things. | |
60 | */ | 60 | */ | |
61 | 61 | |||
62 | #include <sys/cdefs.h> | 62 | #include <sys/cdefs.h> | |
63 | __KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.126 2016/08/07 17:38:34 christos Exp $"); | 63 | __KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.127 2016/10/02 14:17:07 christos Exp $"); | |
64 | 64 | |||
65 | #ifdef _KERNEL_OPT | 65 | #ifdef _KERNEL_OPT | |
66 | #include "opt_inet.h" | 66 | #include "opt_inet.h" | |
67 | #endif | 67 | #endif | |
68 | 68 | |||
69 | #include <sys/param.h> | 69 | #include <sys/param.h> | |
70 | #include <sys/proc.h> | 70 | #include <sys/proc.h> | |
71 | #include <sys/malloc.h> | 71 | #include <sys/malloc.h> | |
72 | #include <sys/mbuf.h> | 72 | #include <sys/mbuf.h> | |
73 | #include <sys/buf.h> | 73 | #include <sys/buf.h> | |
74 | #include <sys/dkstat.h> | 74 | #include <sys/dkstat.h> | |
75 | #include <sys/socket.h> | 75 | #include <sys/socket.h> | |
76 | #include <sys/ioctl.h> | 76 | #include <sys/ioctl.h> | |
@@ -836,28 +836,27 @@ slintr(void *arg) | @@ -836,28 +836,27 @@ slintr(void *arg) | |||
836 | if (putc(FRAME_ESCAPE, &tp->t_outq)) | 836 | if (putc(FRAME_ESCAPE, &tp->t_outq)) | |
837 | break; | 837 | break; | |
838 | if (putc(*cp++ == FRAME_ESCAPE ? | 838 | if (putc(*cp++ == FRAME_ESCAPE ? | |
839 | TRANS_FRAME_ESCAPE : | 839 | TRANS_FRAME_ESCAPE : | |
840 | TRANS_FRAME_END, | 840 | TRANS_FRAME_END, | |
841 | &tp->t_outq)) { | 841 | &tp->t_outq)) { | |
842 | (void)unputc(&tp->t_outq); | 842 | (void)unputc(&tp->t_outq); | |
843 | break; | 843 | break; | |
844 | } | 844 | } | |
845 | sc->sc_if.if_obytes += 2; | 845 | sc->sc_if.if_obytes += 2; | |
846 | } | 846 | } | |
847 | bp = cp; | 847 | bp = cp; | |
848 | } | 848 | } | |
849 | MFREE(m, m2); | 849 | m = m2 = m_free(m); | |
850 | m = m2; | |||
851 | } | 850 | } | |
852 | 851 | |||
853 | if (putc(FRAME_END, &tp->t_outq)) { | 852 | if (putc(FRAME_END, &tp->t_outq)) { | |
854 | /* | 853 | /* | |
855 | * Not enough room. Remove a char to make | 854 | * Not enough room. Remove a char to make | |
856 | * room and end the packet normally. If | 855 | * room and end the packet normally. If | |
857 | * you get many collisions (more than one | 856 | * you get many collisions (more than one | |
858 | * or two a day), you probably do not have | 857 | * or two a day), you probably do not have | |
859 | * enough clists and you should increase | 858 | * enough clists and you should increase | |
860 | * "nclist" in param.c | 859 | * "nclist" in param.c | |
861 | */ | 860 | */ | |
862 | (void)unputc(&tp->t_outq); | 861 | (void)unputc(&tp->t_outq); | |
863 | (void)putc(FRAME_END, &tp->t_outq); | 862 | (void)putc(FRAME_END, &tp->t_outq); |
--- src/sys/net/Attic/if_strip.c 2016/08/07 17:38:34 1.106
+++ src/sys/net/Attic/if_strip.c 2016/10/02 14:17:07 1.107
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_strip.c,v 1.106 2016/08/07 17:38:34 christos Exp $ */ | 1 | /* $NetBSD: if_strip.c,v 1.107 2016/10/02 14:17:07 christos Exp $ */ | |
2 | /* from: NetBSD: if_sl.c,v 1.38 1996/02/13 22:00:23 christos Exp $ */ | 2 | /* from: NetBSD: if_sl.c,v 1.38 1996/02/13 22:00:23 christos Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright 1996 The Board of Trustees of The Leland Stanford | 5 | * Copyright 1996 The Board of Trustees of The Leland Stanford | |
6 | * Junior University. All Rights Reserved. | 6 | * Junior University. All Rights Reserved. | |
7 | * | 7 | * | |
8 | * Permission to use, copy, modify, and distribute this | 8 | * Permission to use, copy, modify, and distribute this | |
9 | * software and its documentation for any purpose and without | 9 | * software and its documentation for any purpose and without | |
10 | * fee is hereby granted, provided that the above copyright | 10 | * fee is hereby granted, provided that the above copyright | |
11 | * notice appear in all copies. Stanford University | 11 | * notice appear in all copies. Stanford University | |
12 | * makes no representations about the suitability of this | 12 | * makes no representations about the suitability of this | |
13 | * software for any purpose. It is provided "as is" without | 13 | * software for any purpose. It is provided "as is" without | |
14 | * express or implied warranty. | 14 | * express or implied warranty. | |
@@ -77,27 +77,27 @@ | @@ -77,27 +77,27 @@ | |||
77 | * Converted to 4.3BSD Beta by Chris Torek. | 77 | * Converted to 4.3BSD Beta by Chris Torek. | |
78 | * Other changes made at Berkeley, based in part on code by Kirk Smith. | 78 | * Other changes made at Berkeley, based in part on code by Kirk Smith. | |
79 | * W. Jolitz added slip abort. | 79 | * W. Jolitz added slip abort. | |
80 | * | 80 | * | |
81 | * Hacked almost beyond recognition by Van Jacobson (van@helios.ee.lbl.gov). | 81 | * Hacked almost beyond recognition by Van Jacobson (van@helios.ee.lbl.gov). | |
82 | * Added priority queuing for "interactive" traffic; hooks for TCP | 82 | * Added priority queuing for "interactive" traffic; hooks for TCP | |
83 | * header compression; ICMP filtering (at 2400 baud, some cretin | 83 | * header compression; ICMP filtering (at 2400 baud, some cretin | |
84 | * pinging you can use up all your bandwidth). Made low clist behavior | 84 | * pinging you can use up all your bandwidth). Made low clist behavior | |
85 | * more robust and slightly less likely to hang serial line. | 85 | * more robust and slightly less likely to hang serial line. | |
86 | * Sped up a bunch of things. | 86 | * Sped up a bunch of things. | |
87 | */ | 87 | */ | |
88 | 88 | |||
89 | #include <sys/cdefs.h> | 89 | #include <sys/cdefs.h> | |
90 | __KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.106 2016/08/07 17:38:34 christos Exp $"); | 90 | __KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.107 2016/10/02 14:17:07 christos Exp $"); | |
91 | 91 | |||
92 | #ifdef _KERNEL_OPT | 92 | #ifdef _KERNEL_OPT | |
93 | #include "opt_inet.h" | 93 | #include "opt_inet.h" | |
94 | #endif | 94 | #endif | |
95 | 95 | |||
96 | #include <sys/param.h> | 96 | #include <sys/param.h> | |
97 | #include <sys/proc.h> | 97 | #include <sys/proc.h> | |
98 | #include <sys/mbuf.h> | 98 | #include <sys/mbuf.h> | |
99 | #include <sys/buf.h> | 99 | #include <sys/buf.h> | |
100 | #include <sys/dkstat.h> | 100 | #include <sys/dkstat.h> | |
101 | #include <sys/socket.h> | 101 | #include <sys/socket.h> | |
102 | #include <sys/ioctl.h> | 102 | #include <sys/ioctl.h> | |
103 | #include <sys/file.h> | 103 | #include <sys/file.h> | |
@@ -666,28 +666,27 @@ strip_sendbody(struct strip_softc *sc, s | @@ -666,28 +666,27 @@ strip_sendbody(struct strip_softc *sc, s | |||
666 | 666 | |||
667 | while (m) { | 667 | while (m) { | |
668 | if (m->m_len != 0) { | 668 | if (m->m_len != 0) { | |
669 | /* | 669 | /* | |
670 | * Byte-stuff/run-length encode this mbuf's data | 670 | * Byte-stuff/run-length encode this mbuf's data | |
671 | * into the output buffer. | 671 | * into the output buffer. | |
672 | * XXX Note that chained calls to stuffdata() | 672 | * XXX Note that chained calls to stuffdata() | |
673 | * require that the stuffed data be left in the | 673 | * require that the stuffed data be left in the | |
674 | * output buffer until the entire packet is encoded. | 674 | * output buffer until the entire packet is encoded. | |
675 | */ | 675 | */ | |
676 | dp = StuffData(mtod(m, u_char *), m->m_len, dp, | 676 | dp = StuffData(mtod(m, u_char *), m->m_len, dp, | |
677 | &rllstate_ptr); | 677 | &rllstate_ptr); | |
678 | } | 678 | } | |
679 | MFREE(m, m2); | 679 | m = m2 = m_free(m); | |
680 | m = m2; | |||
681 | } | 680 | } | |
682 | 681 | |||
683 | /* | 682 | /* | |
684 | * Put the entire stuffed packet into the tty output queue. | 683 | * Put the entire stuffed packet into the tty output queue. | |
685 | */ | 684 | */ | |
686 | len = dp - sc->sc_txbuf; | 685 | len = dp - sc->sc_txbuf; | |
687 | if (b_to_q((ttychar_t *)sc->sc_txbuf, len, &tp->t_outq)) { | 686 | if (b_to_q((ttychar_t *)sc->sc_txbuf, len, &tp->t_outq)) { | |
688 | if (sc->sc_if.if_flags & IFF_DEBUG) | 687 | if (sc->sc_if.if_flags & IFF_DEBUG) | |
689 | addlog("%s: tty output overflow\n", | 688 | addlog("%s: tty output overflow\n", | |
690 | sc->sc_if.if_xname); | 689 | sc->sc_if.if_xname); | |
691 | return; | 690 | return; | |
692 | } | 691 | } | |
693 | sc->sc_if.if_obytes += len; | 692 | sc->sc_if.if_obytes += len; |
--- src/sys/net/if_tap.c 2016/08/15 05:10:33 1.92
+++ src/sys/net/if_tap.c 2016/10/02 14:17:07 1.93
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_tap.c,v 1.92 2016/08/15 05:10:33 christos Exp $ */ | 1 | /* $NetBSD: if_tap.c,v 1.93 2016/10/02 14:17:07 christos Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation. | 4 | * Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -23,27 +23,27 @@ | @@ -23,27 +23,27 @@ | |||
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | /* | 29 | /* | |
30 | * tap(4) is a virtual Ethernet interface. It appears as a real Ethernet | 30 | * tap(4) is a virtual Ethernet interface. It appears as a real Ethernet | |
31 | * device to the system, but can also be accessed by userland through a | 31 | * device to the system, but can also be accessed by userland through a | |
32 | * character device interface, which allows reading and injecting frames. | 32 | * character device interface, which allows reading and injecting frames. | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #include <sys/cdefs.h> | 35 | #include <sys/cdefs.h> | |
36 | __KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.92 2016/08/15 05:10:33 christos Exp $"); | 36 | __KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.93 2016/10/02 14:17:07 christos Exp $"); | |
37 | 37 | |||
38 | #if defined(_KERNEL_OPT) | 38 | #if defined(_KERNEL_OPT) | |
39 | 39 | |||
40 | #include "opt_modular.h" | 40 | #include "opt_modular.h" | |
41 | #include "opt_compat_netbsd.h" | 41 | #include "opt_compat_netbsd.h" | |
42 | #endif | 42 | #endif | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/systm.h> | 45 | #include <sys/systm.h> | |
46 | #include <sys/kernel.h> | 46 | #include <sys/kernel.h> | |
47 | #include <sys/malloc.h> | 47 | #include <sys/malloc.h> | |
48 | #include <sys/conf.h> | 48 | #include <sys/conf.h> | |
49 | #include <sys/cprng.h> | 49 | #include <sys/cprng.h> | |
@@ -977,28 +977,27 @@ tap_dev_read(int unit, struct uio *uio, | @@ -977,28 +977,27 @@ tap_dev_read(int unit, struct uio *uio, | |||
977 | error = 0; | 977 | error = 0; | |
978 | goto out; | 978 | goto out; | |
979 | } | 979 | } | |
980 | 980 | |||
981 | ifp->if_opackets++; | 981 | ifp->if_opackets++; | |
982 | bpf_mtap(ifp, m); | 982 | bpf_mtap(ifp, m); | |
983 | 983 | |||
984 | /* | 984 | /* | |
985 | * One read is one packet. | 985 | * One read is one packet. | |
986 | */ | 986 | */ | |
987 | do { | 987 | do { | |
988 | error = uiomove(mtod(m, void *), | 988 | error = uiomove(mtod(m, void *), | |
989 | min(m->m_len, uio->uio_resid), uio); | 989 | min(m->m_len, uio->uio_resid), uio); | |
990 | MFREE(m, n); | 990 | m = n = m_free(m); | |
991 | m = n; | |||
992 | } while (m != NULL && uio->uio_resid > 0 && error == 0); | 991 | } while (m != NULL && uio->uio_resid > 0 && error == 0); | |
993 | 992 | |||
994 | if (m != NULL) | 993 | if (m != NULL) | |
995 | m_freem(m); | 994 | m_freem(m); | |
996 | 995 | |||
997 | out: | 996 | out: | |
998 | mutex_exit(&sc->sc_rdlock); | 997 | mutex_exit(&sc->sc_rdlock); | |
999 | return (error); | 998 | return (error); | |
1000 | } | 999 | } | |
1001 | 1000 | |||
1002 | static int | 1001 | static int | |
1003 | tap_fops_stat(file_t *fp, struct stat *st) | 1002 | tap_fops_stat(file_t *fp, struct stat *st) | |
1004 | { | 1003 | { |
--- src/sys/net/if_tun.c 2016/09/07 10:27:44 1.132
+++ src/sys/net/if_tun.c 2016/10/02 14:17:07 1.133
@@ -1,31 +1,31 @@ | @@ -1,31 +1,31 @@ | |||
1 | /* $NetBSD: if_tun.c,v 1.132 2016/09/07 10:27:44 ozaki-r Exp $ */ | 1 | /* $NetBSD: if_tun.c,v 1.133 2016/10/02 14:17:07 christos Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk> | 4 | * Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk> | |
5 | * Nottingham University 1987. | 5 | * Nottingham University 1987. | |
6 | * | 6 | * | |
7 | * This source may be freely distributed, however I would be interested | 7 | * This source may be freely distributed, however I would be interested | |
8 | * in any changes that are made. | 8 | * in any changes that are made. | |
9 | * | 9 | * | |
10 | * This driver takes packets off the IP i/f and hands them up to a | 10 | * This driver takes packets off the IP i/f and hands them up to a | |
11 | * user process to have its wicked way with. This driver has its | 11 | * user process to have its wicked way with. This driver has its | |
12 | * roots in a similar driver written by Phil Cockcroft (formerly) at | 12 | * roots in a similar driver written by Phil Cockcroft (formerly) at | |
13 | * UCL. This driver is based much more on read/write/poll mode of | 13 | * UCL. This driver is based much more on read/write/poll mode of | |
14 | * operation though. | 14 | * operation though. | |
15 | */ | 15 | */ | |
16 | 16 | |||
17 | #include <sys/cdefs.h> | 17 | #include <sys/cdefs.h> | |
18 | __KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.132 2016/09/07 10:27:44 ozaki-r Exp $"); | 18 | __KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.133 2016/10/02 14:17:07 christos Exp $"); | |
19 | 19 | |||
20 | #ifdef _KERNEL_OPT | 20 | #ifdef _KERNEL_OPT | |
21 | #include "opt_inet.h" | 21 | #include "opt_inet.h" | |
22 | #endif | 22 | #endif | |
23 | 23 | |||
24 | #include <sys/param.h> | 24 | #include <sys/param.h> | |
25 | #include <sys/proc.h> | 25 | #include <sys/proc.h> | |
26 | #include <sys/systm.h> | 26 | #include <sys/systm.h> | |
27 | #include <sys/mbuf.h> | 27 | #include <sys/mbuf.h> | |
28 | #include <sys/buf.h> | 28 | #include <sys/buf.h> | |
29 | #include <sys/protosw.h> | 29 | #include <sys/protosw.h> | |
30 | #include <sys/socket.h> | 30 | #include <sys/socket.h> | |
31 | #include <sys/ioctl.h> | 31 | #include <sys/ioctl.h> | |
@@ -830,28 +830,27 @@ tunread(dev_t dev, struct uio *uio, int | @@ -830,28 +830,27 @@ tunread(dev_t dev, struct uio *uio, int | |||
830 | } | 830 | } | |
831 | } | 831 | } | |
832 | } | 832 | } | |
833 | } while (m0 == 0); | 833 | } while (m0 == 0); | |
834 | 834 | |||
835 | mutex_exit(&tp->tun_lock); | 835 | mutex_exit(&tp->tun_lock); | |
836 | splx(s); | 836 | splx(s); | |
837 | 837 | |||
838 | /* Copy the mbuf chain */ | 838 | /* Copy the mbuf chain */ | |
839 | while (m0 && uio->uio_resid > 0 && error == 0) { | 839 | while (m0 && uio->uio_resid > 0 && error == 0) { | |
840 | len = min(uio->uio_resid, m0->m_len); | 840 | len = min(uio->uio_resid, m0->m_len); | |
841 | if (len != 0) | 841 | if (len != 0) | |
842 | error = uiomove(mtod(m0, void *), len, uio); | 842 | error = uiomove(mtod(m0, void *), len, uio); | |
843 | MFREE(m0, m); | 843 | m0 = m = m_free(m0); | |
844 | m0 = m; | |||
845 | } | 844 | } | |
846 | 845 | |||
847 | if (m0) { | 846 | if (m0) { | |
848 | TUNDEBUG("Dropping mbuf\n"); | 847 | TUNDEBUG("Dropping mbuf\n"); | |
849 | m_freem(m0); | 848 | m_freem(m0); | |
850 | } | 849 | } | |
851 | if (error) | 850 | if (error) | |
852 | ifp->if_ierrors++; | 851 | ifp->if_ierrors++; | |
853 | 852 | |||
854 | return (error); | 853 | return (error); | |
855 | 854 | |||
856 | out: | 855 | out: | |
857 | mutex_exit(&tp->tun_lock); | 856 | mutex_exit(&tp->tun_lock); |
--- src/sys/net/ppp_tty.c 2016/08/06 02:35:06 1.62
+++ src/sys/net/ppp_tty.c 2016/10/02 14:17:07 1.63
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ppp_tty.c,v 1.62 2016/08/06 02:35:06 pgoyette Exp $ */ | 1 | /* $NetBSD: ppp_tty.c,v 1.63 2016/10/02 14:17:07 christos Exp $ */ | |
2 | /* Id: ppp_tty.c,v 1.3 1996/07/01 01:04:11 paulus Exp */ | 2 | /* Id: ppp_tty.c,v 1.3 1996/07/01 01:04:11 paulus Exp */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * ppp_tty.c - Point-to-Point Protocol (PPP) driver for asynchronous | 5 | * ppp_tty.c - Point-to-Point Protocol (PPP) driver for asynchronous | |
6 | * tty devices. | 6 | * tty devices. | |
7 | * | 7 | * | |
8 | * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. | 8 | * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * | 13 | * | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -83,27 +83,27 @@ | @@ -83,27 +83,27 @@ | |||
83 | * caused system crashes and packet corruption. Changed pppstart | 83 | * caused system crashes and packet corruption. Changed pppstart | |
84 | * so that it doesn't just give up with a "collision" if the whole | 84 | * so that it doesn't just give up with a "collision" if the whole | |
85 | * packet doesn't fit in the output ring buffer. | 85 | * packet doesn't fit in the output ring buffer. | |
86 | * | 86 | * | |
87 | * Added priority queueing for interactive IP packets, following | 87 | * Added priority queueing for interactive IP packets, following | |
88 | * the model of if_sl.c, plus hooks for bpf. | 88 | * the model of if_sl.c, plus hooks for bpf. | |
89 | * Paul Mackerras (paulus@cs.anu.edu.au). | 89 | * Paul Mackerras (paulus@cs.anu.edu.au). | |
90 | */ | 90 | */ | |
91 | 91 | |||
92 | /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */ | 92 | /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */ | |
93 | /* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */ | 93 | /* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */ | |
94 | 94 | |||
95 | #include <sys/cdefs.h> | 95 | #include <sys/cdefs.h> | |
96 | __KERNEL_RCSID(0, "$NetBSD: ppp_tty.c,v 1.62 2016/08/06 02:35:06 pgoyette Exp $"); | 96 | __KERNEL_RCSID(0, "$NetBSD: ppp_tty.c,v 1.63 2016/10/02 14:17:07 christos Exp $"); | |
97 | 97 | |||
98 | #ifdef _KERNEL_OPT | 98 | #ifdef _KERNEL_OPT | |
99 | #include "ppp.h" | 99 | #include "ppp.h" | |
100 | #include "opt_ppp.h" | 100 | #include "opt_ppp.h" | |
101 | #endif | 101 | #endif | |
102 | #define VJC | 102 | #define VJC | |
103 | #define PPP_COMPRESS | 103 | #define PPP_COMPRESS | |
104 | 104 | |||
105 | #include <sys/param.h> | 105 | #include <sys/param.h> | |
106 | #include <sys/proc.h> | 106 | #include <sys/proc.h> | |
107 | #include <sys/mbuf.h> | 107 | #include <sys/mbuf.h> | |
108 | #include <sys/dkstat.h> | 108 | #include <sys/dkstat.h> | |
109 | #include <sys/socket.h> | 109 | #include <sys/socket.h> | |
@@ -823,28 +823,27 @@ pppasyncstart(struct ppp_softc *sc) | @@ -823,28 +823,27 @@ pppasyncstart(struct ppp_softc *sc) | |||
823 | } | 823 | } | |
824 | if (done) | 824 | if (done) | |
825 | sc->sc_stats.ppp_obytes += q - endseq; | 825 | sc->sc_stats.ppp_obytes += q - endseq; | |
826 | } | 826 | } | |
827 | 827 | |||
828 | if (!done) { | 828 | if (!done) { | |
829 | /* remember where we got to */ | 829 | /* remember where we got to */ | |
830 | m->m_data = start; | 830 | m->m_data = start; | |
831 | m->m_len = len; | 831 | m->m_len = len; | |
832 | break; | 832 | break; | |
833 | } | 833 | } | |
834 | 834 | |||
835 | /* Finished with this mbuf; free it and move on. */ | 835 | /* Finished with this mbuf; free it and move on. */ | |
836 | MFREE(m, m2); | 836 | m = m2 = m_free(m); | |
837 | m = m2; | |||
838 | if (m == NULL) { | 837 | if (m == NULL) { | |
839 | /* Finished a packet */ | 838 | /* Finished a packet */ | |
840 | break; | 839 | break; | |
841 | } | 840 | } | |
842 | sc->sc_outfcs = pppfcs(sc->sc_outfcs, mtod(m, uint8_t *), m->m_len); | 841 | sc->sc_outfcs = pppfcs(sc->sc_outfcs, mtod(m, uint8_t *), m->m_len); | |
843 | } | 842 | } | |
844 | 843 | |||
845 | /* | 844 | /* | |
846 | * If m == NULL, we have finished a packet. | 845 | * If m == NULL, we have finished a packet. | |
847 | * If m != NULL, we've either done as much work this time | 846 | * If m != NULL, we've either done as much work this time | |
848 | * as we need to, or else we've filled up the output queue. | 847 | * as we need to, or else we've filled up the output queue. | |
849 | */ | 848 | */ | |
850 | sc->sc_outm = m; | 849 | sc->sc_outm = m; |