Module Name:    src
Committed By:   knakahara
Date:           Thu Dec 27 07:56:12 UTC 2018

Modified Files:
        src/sys/net: if_l2tp.c

Log Message:
l2tp(4): fix output bytes counter. Pointed by k-goda@IIJ, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/net/if_l2tp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_l2tp.c
diff -u src/sys/net/if_l2tp.c:1.32 src/sys/net/if_l2tp.c:1.33
--- src/sys/net/if_l2tp.c:1.32	Sat Dec 22 14:28:56 2018
+++ src/sys/net/if_l2tp.c	Thu Dec 27 07:56:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_l2tp.c,v 1.32 2018/12/22 14:28:56 maxv Exp $	*/
+/*	$NetBSD: if_l2tp.c,v 1.33 2018/12/27 07:56:11 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.32 2018/12/22 14:28:56 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.33 2018/12/27 07:56:11 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -426,9 +426,12 @@ l2tpintr(struct l2tp_variant *var)
 	}
 
 	for (;;) {
+		int len;
+
 		IFQ_DEQUEUE(&ifp->if_snd, m);
 		if (m == NULL)
 			break;
+		len = m->m_pkthdr.len;
 		m->m_flags &= ~(M_BCAST|M_MCAST);
 		bpf_mtap(ifp, m, BPF_D_OUT);
 		switch (var->lv_psrc->sa_family) {
@@ -452,13 +455,9 @@ l2tpintr(struct l2tp_variant *var)
 			ifp->if_oerrors++;
 		else {
 			ifp->if_opackets++;
-			/*
-			 * obytes is incremented at ether_output() or
-			 * bridge_enqueue().
-			 */
+			ifp->if_obytes += len;
 		}
 	}
-
 }
 
 void
@@ -570,6 +569,7 @@ int
 l2tp_transmit(struct ifnet *ifp, struct mbuf *m)
 {
 	int error;
+	int len;
 	struct psref psref;
 	struct l2tp_variant *var;
 	struct l2tp_softc *sc = container_of(ifp, struct l2tp_softc,
@@ -587,6 +587,7 @@ l2tp_transmit(struct ifnet *ifp, struct 
 		goto out;
 	}
 
+	len = m->m_pkthdr.len;
 	m->m_flags &= ~(M_BCAST|M_MCAST);
 	bpf_mtap(ifp, m, BPF_D_OUT);
 	switch (var->lv_psrc->sa_family) {
@@ -610,9 +611,7 @@ l2tp_transmit(struct ifnet *ifp, struct 
 		ifp->if_oerrors++;
 	else {
 		ifp->if_opackets++;
-		/*
-		 * obytes is incremented at ether_output() or bridge_enqueue().
-		 */
+		ifp->if_obytes += len;
 	}
 
 out:

Reply via email to