Wed Jan 29 05:52:27 2020 UTC ()
Adopt <net/if_stats.h>.


(thorpej)
diff -r1.21 -r1.22 src/sys/dist/pf/net/if_pflog.c
diff -r1.19 -r1.20 src/sys/dist/pf/net/if_pfsync.c

cvs diff -r1.21 -r1.22 src/sys/dist/pf/net/if_pflog.c (expand / switch to unified diff)

--- src/sys/dist/pf/net/if_pflog.c 2018/06/26 06:48:02 1.21
+++ src/sys/dist/pf/net/if_pflog.c 2020/01/29 05:52:27 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_pflog.c,v 1.21 2018/06/26 06:48:02 msaitoh Exp $ */ 1/* $NetBSD: if_pflog.c,v 1.22 2020/01/29 05:52:27 thorpej Exp $ */
2/* $OpenBSD: if_pflog.c,v 1.24 2007/05/26 17:13:30 jason Exp $ */ 2/* $OpenBSD: if_pflog.c,v 1.24 2007/05/26 17:13:30 jason Exp $ */
3 3
4/* 4/*
5 * The authors of this code are John Ioannidis (ji@tla.org), 5 * The authors of this code are John Ioannidis (ji@tla.org),
6 * Angelos D. Keromytis (kermit@csd.uch.gr) and  6 * Angelos D. Keromytis (kermit@csd.uch.gr) and
7 * Niels Provos (provos@physnet.uni-hamburg.de). 7 * Niels Provos (provos@physnet.uni-hamburg.de).
8 * 8 *
9 * This code was written by John Ioannidis for BSD/OS in Athens, Greece,  9 * This code was written by John Ioannidis for BSD/OS in Athens, Greece,
10 * in November 1995. 10 * in November 1995.
11 * 11 *
12 * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996, 12 * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
13 * by Angelos D. Keromytis. 13 * by Angelos D. Keromytis.
14 * 14 *
@@ -26,27 +26,27 @@ @@ -26,27 +26,27 @@
26 * You may use this code under the GNU public license if you so wish. Please 26 * You may use this code under the GNU public license if you so wish. Please
27 * contribute changes back to the authors under this freer than GPL license 27 * contribute changes back to the authors under this freer than GPL license
28 * so that we may further the use of strong encryption without limitations to 28 * so that we may further the use of strong encryption without limitations to
29 * all. 29 * all.
30 * 30 *
31 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR 31 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
32 * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY 32 * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
33 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE 33 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
34 * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR 34 * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
35 * PURPOSE. 35 * PURPOSE.
36 */ 36 */
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39__KERNEL_RCSID(0, "$NetBSD: if_pflog.c,v 1.21 2018/06/26 06:48:02 msaitoh Exp $"); 39__KERNEL_RCSID(0, "$NetBSD: if_pflog.c,v 1.22 2020/01/29 05:52:27 thorpej Exp $");
40 40
41#ifdef _KERNEL_OPT 41#ifdef _KERNEL_OPT
42#include "opt_inet.h" 42#include "opt_inet.h"
43#endif 43#endif
44 44
45#include "pflog.h" 45#include "pflog.h"
46 46
47#include <sys/param.h> 47#include <sys/param.h>
48#include <sys/systm.h> 48#include <sys/systm.h>
49#include <sys/mbuf.h> 49#include <sys/mbuf.h>
50#include <sys/proc.h> 50#include <sys/proc.h>
51#include <sys/socket.h> 51#include <sys/socket.h>
52#include <sys/ioctl.h> 52#include <sys/ioctl.h>
@@ -284,26 +284,30 @@ pflog_packet(struct pfi_kif *kif, struct @@ -284,26 +284,30 @@ pflog_packet(struct pfi_kif *kif, struct
284 hdr.rule_pid = rm->cpid; 284 hdr.rule_pid = rm->cpid;
285 hdr.dir = dir; 285 hdr.dir = dir;
286 286
287#ifdef INET 287#ifdef INET
288 if (af == AF_INET && dir == PF_OUT) { 288 if (af == AF_INET && dir == PF_OUT) {
289 struct ip *ip; 289 struct ip *ip;
290 290
291 ip = mtod(m, struct ip *); 291 ip = mtod(m, struct ip *);
292 ip->ip_sum = 0; 292 ip->ip_sum = 0;
293 ip->ip_sum = in_cksum(m, ip->ip_hl << 2); 293 ip->ip_sum = in_cksum(m, ip->ip_hl << 2);
294 } 294 }
295#endif /* INET */ 295#endif /* INET */
296 296
 297#ifdef __NetBSD__
 298 if_statadd2(ifn, if_opackets, 1, if_obytes, m->m_pkthdr.len);
 299#else
297 ifn->if_opackets++; 300 ifn->if_opackets++;
298 ifn->if_obytes += m->m_pkthdr.len; 301 ifn->if_obytes += m->m_pkthdr.len;
 302#endif /* __NetBSD__ */
299 303
300#ifdef __NetBSD__ 304#ifdef __NetBSD__
301 bpf_mtap2(ifn->if_bpf, &hdr, PFLOG_HDRLEN, m, BPF_D_OUT); 305 bpf_mtap2(ifn->if_bpf, &hdr, PFLOG_HDRLEN, m, BPF_D_OUT);
302#else 306#else
303 bpf_mtap_hdr(ifn->if_bpf, (char *)&hdr, PFLOG_HDRLEN, m, 307 bpf_mtap_hdr(ifn->if_bpf, (char *)&hdr, PFLOG_HDRLEN, m,
304 BPF_DIRECTION_OUT); 308 BPF_DIRECTION_OUT);
305#endif /* !__NetBSD__ */ 309#endif /* !__NetBSD__ */
306 310
307 311
308 return (0); 312 return (0);
309} 313}

cvs diff -r1.19 -r1.20 src/sys/dist/pf/net/if_pfsync.c (expand / switch to unified diff)

--- src/sys/dist/pf/net/if_pfsync.c 2018/12/22 14:28:56 1.19
+++ src/sys/dist/pf/net/if_pfsync.c 2020/01/29 05:52:27 1.20
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_pfsync.c,v 1.19 2018/12/22 14:28:56 maxv Exp $ */ 1/* $NetBSD: if_pfsync.c,v 1.20 2020/01/29 05:52:27 thorpej Exp $ */
2/* $OpenBSD: if_pfsync.c,v 1.83 2007/06/26 14:44:12 mcbride Exp $ */ 2/* $OpenBSD: if_pfsync.c,v 1.83 2007/06/26 14:44:12 mcbride Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2002 Michael Shalayeff 5 * Copyright (c) 2002 Michael Shalayeff
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -18,27 +18,27 @@ @@ -18,27 +18,27 @@
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, 20 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGE. 27 * THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31__KERNEL_RCSID(0, "$NetBSD: if_pfsync.c,v 1.19 2018/12/22 14:28:56 maxv Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: if_pfsync.c,v 1.20 2020/01/29 05:52:27 thorpej Exp $");
32 32
33#ifdef _KERNEL_OPT 33#ifdef _KERNEL_OPT
34#include "opt_inet.h" 34#include "opt_inet.h"
35#include "opt_inet6.h" 35#include "opt_inet6.h"
36#endif 36#endif
37 37
38#include <sys/param.h> 38#include <sys/param.h>
39#include <sys/proc.h> 39#include <sys/proc.h>
40#include <sys/systm.h> 40#include <sys/systm.h>
41#include <sys/time.h> 41#include <sys/time.h>
42#include <sys/mbuf.h> 42#include <sys/mbuf.h>
43#include <sys/socket.h> 43#include <sys/socket.h>
44#include <sys/ioctl.h> 44#include <sys/ioctl.h>
@@ -1035,27 +1035,31 @@ pfsync_setmtu(struct pfsync_softc *sc, i @@ -1035,27 +1035,31 @@ pfsync_setmtu(struct pfsync_softc *sc, i
1035 sc->sc_if.if_mtu = sizeof(struct pfsync_header) + 1035 sc->sc_if.if_mtu = sizeof(struct pfsync_header) +
1036 sc->sc_maxcount * sizeof(struct pfsync_state); 1036 sc->sc_maxcount * sizeof(struct pfsync_state);
1037} 1037}
1038 1038
1039struct mbuf * 1039struct mbuf *
1040pfsync_get_mbuf(struct pfsync_softc *sc, u_int8_t action, void **sp) 1040pfsync_get_mbuf(struct pfsync_softc *sc, u_int8_t action, void **sp)
1041{ 1041{
1042 struct pfsync_header *h; 1042 struct pfsync_header *h;
1043 struct mbuf *m; 1043 struct mbuf *m;
1044 int len; 1044 int len;
1045 1045
1046 MGETHDR(m, M_DONTWAIT, MT_DATA); 1046 MGETHDR(m, M_DONTWAIT, MT_DATA);
1047 if (m == NULL) { 1047 if (m == NULL) {
 1048#ifdef __NetBSD__
 1049 if_statinc(&sc->sc_if, if_oerrors);
 1050#else
1048 sc->sc_if.if_oerrors++; 1051 sc->sc_if.if_oerrors++;
 1052#endif /* __NetBSD__ */
1049 return (NULL); 1053 return (NULL);
1050 } 1054 }
1051 1055
1052 switch (action) { 1056 switch (action) {
1053 case PFSYNC_ACT_CLR: 1057 case PFSYNC_ACT_CLR:
1054 len = sizeof(struct pfsync_header) + 1058 len = sizeof(struct pfsync_header) +
1055 sizeof(struct pfsync_state_clr); 1059 sizeof(struct pfsync_state_clr);
1056 break; 1060 break;
1057 case PFSYNC_ACT_UPD_C: 1061 case PFSYNC_ACT_UPD_C:
1058 len = (sc->sc_maxcount * sizeof(struct pfsync_state_upd)) + 1062 len = (sc->sc_maxcount * sizeof(struct pfsync_state_upd)) +
1059 sizeof(struct pfsync_header); 1063 sizeof(struct pfsync_header);
1060 break; 1064 break;
1061 case PFSYNC_ACT_DEL_C: 1065 case PFSYNC_ACT_DEL_C:
@@ -1074,27 +1078,31 @@ pfsync_get_mbuf(struct pfsync_softc *sc, @@ -1074,27 +1078,31 @@ pfsync_get_mbuf(struct pfsync_softc *sc,
1074 len = (sc->sc_maxcount * sizeof(struct pfsync_tdb)) + 1078 len = (sc->sc_maxcount * sizeof(struct pfsync_tdb)) +
1075 sizeof(struct pfsync_header); 1079 sizeof(struct pfsync_header);
1076 break; 1080 break;
1077 default: 1081 default:
1078 len = (sc->sc_maxcount * sizeof(struct pfsync_state)) + 1082 len = (sc->sc_maxcount * sizeof(struct pfsync_state)) +
1079 sizeof(struct pfsync_header); 1083 sizeof(struct pfsync_header);
1080 break; 1084 break;
1081 } 1085 }
1082 1086
1083 if (len > MHLEN) { 1087 if (len > MHLEN) {
1084 MCLGET(m, M_DONTWAIT); 1088 MCLGET(m, M_DONTWAIT);
1085 if ((m->m_flags & M_EXT) == 0) { 1089 if ((m->m_flags & M_EXT) == 0) {
1086 m_free(m); 1090 m_free(m);
 1091#ifdef __NetBSD__
 1092 if_statinc(&sc->sc_if, if_oerrors);
 1093#else
1087 sc->sc_if.if_oerrors++; 1094 sc->sc_if.if_oerrors++;
 1095#endif /* __NetBSD__ */
1088 return (NULL); 1096 return (NULL);
1089 } 1097 }
1090 m->m_data += (MCLBYTES - len) &~ (sizeof(long) - 1); 1098 m->m_data += (MCLBYTES - len) &~ (sizeof(long) - 1);
1091 } else 1099 } else
1092 m_align(m, len); 1100 m_align(m, len);
1093 1101
1094 m_reset_rcvif(m); 1102 m_reset_rcvif(m);
1095 m->m_pkthdr.len = m->m_len = sizeof(struct pfsync_header); 1103 m->m_pkthdr.len = m->m_len = sizeof(struct pfsync_header);
1096 h = mtod(m, struct pfsync_header *); 1104 h = mtod(m, struct pfsync_header *);
1097 h->version = PFSYNC_VERSION; 1105 h->version = PFSYNC_VERSION;
1098 h->af = 0; 1106 h->af = 0;
1099 h->count = 0; 1107 h->count = 0;
1100 h->action = action; 1108 h->action = action;