pppac(4) uses per cpu counters for collect `ifnet' statistics, but in
pipex(4) layer this `ifnet' still uses `if_data'. Also pppx(4) doesn't
use per cpu counters but `if_data'. I propose to use per cpu counters
for pppx(4) and pipex(4) to avoid interface statistics collecting mix.
Also this will be the step to remove netlock from pppx(4) output.
Index: sys/net/if_pppx.c
===================================================================
RCS file: /cvs/src/sys/net/if_pppx.c,v
retrieving revision 1.102
diff -u -p -r1.102 if_pppx.c
--- sys/net/if_pppx.c 27 Aug 2020 10:47:52 -0000 1.102
+++ sys/net/if_pppx.c 28 Aug 2020 07:48:08 -0000
@@ -658,6 +658,7 @@ pppx_add_session(struct pppx_dev *pxd, s
ifp->if_type = IFT_PPP;
ifp->if_softc = pxi;
/* ifp->if_rdomain = req->pr_rdomain; */
+ if_counters_alloc(ifp);
/* XXXSMP breaks atomicity */
NET_UNLOCK();
@@ -878,7 +879,7 @@ pppx_if_output(struct ifnet *ifp, struct
out:
if (error)
- ifp->if_oerrors++;
+ counters_inc(ifp->if_counters, ifc_oerrors);
return (error);
}
Index: sys/net/pipex.c
===================================================================
RCS file: /cvs/src/sys/net/pipex.c,v
retrieving revision 1.125
diff -u -p -r1.125 pipex.c
--- sys/net/pipex.c 27 Aug 2020 10:47:52 -0000 1.125
+++ sys/net/pipex.c 28 Aug 2020 07:48:08 -0000
@@ -912,8 +912,7 @@ pipex_ip_input(struct mbuf *m0, struct p
bpf_mtap_af(ifp->if_bpf, AF_INET, m0, BPF_DIRECTION_IN);
#endif
- ifp->if_ipackets++;
- ifp->if_ibytes += len;
+ counters_pkt(ifp->if_counters, ifc_ipackets, ifc_ibytes, len);
session->stat.ipackets++;
session->stat.ibytes += len;
ipv4_input(ifp, m0);
@@ -962,8 +961,7 @@ pipex_ip6_input(struct mbuf *m0, struct
bpf_mtap_af(ifp->if_bpf, AF_INET6, m0, BPF_DIRECTION_IN);
#endif
- ifp->if_ipackets++;
- ifp->if_ibytes += len;
+ counters_pkt(ifp->if_counters, ifc_ipackets, ifc_ibytes, len);
session->stat.ipackets++;
session->stat.ibytes += len;
ipv6_input(ifp, m0);