Re: use per cpu counters for udp statistics

2016-11-14 Thread Mike Belopuhov
On 14 November 2016 at 09:38, Martin Pieuchot  wrote:
> On 14/11/16(Mon) 14:29, David Gwynne wrote:
>> its as close to the ipstat change as i can make it.
>>
>> ok?
>
> [...]
>
>> @@ -142,6 +143,7 @@ void  udp_notify(struct inpcb *, int);
>>  void
>>  udp_init(void)
>>  {
>> + udpcounters = counters_alloc(udps_ncounters, M_COUNTERS);
>
> No need to pass M_COUNTERS to counter_alloc(), it's repetitive :)
>

Yes, I've also pointed that out in my previous mail for IP stats.

> Other than that ok mpi@
>

Looks good to me as well. OK mikeb



Re: use per cpu counters for udp statistics

2016-11-14 Thread Martin Pieuchot
On 14/11/16(Mon) 14:29, David Gwynne wrote:
> its as close to the ipstat change as i can make it.
> 
> ok?
 
[...]

> @@ -142,6 +143,7 @@ void  udp_notify(struct inpcb *, int);
>  void
>  udp_init(void)
>  {
> + udpcounters = counters_alloc(udps_ncounters, M_COUNTERS);

No need to pass M_COUNTERS to counter_alloc(), it's repetitive :)

Other than that ok mpi@



use per cpu counters for udp statistics

2016-11-13 Thread David Gwynne
its as close to the ipstat change as i can make it.

ok?

Index: net/pipex.c
===
RCS file: /cvs/src/sys/net/pipex.c,v
retrieving revision 1.89
diff -u -p -r1.89 pipex.c
--- net/pipex.c 15 Sep 2016 02:00:18 -  1.89
+++ net/pipex.c 14 Nov 2016 04:27:42 -
@@ -1986,7 +1986,7 @@ pipex_l2tp_output(struct mbuf *m0, struc
break;
 #endif
}
-   udpstat.udps_opackets++;
+   udpstat_inc(udps_opackets);
 
if (datalen > 0) {  /* network layer only */
/* countup statistics */
Index: netinet/ip_output.c
===
RCS file: /cvs/src/sys/netinet/ip_output.c,v
retrieving revision 1.328
diff -u -p -r1.328 ip_output.c
--- netinet/ip_output.c 14 Nov 2016 03:51:53 -  1.328
+++ netinet/ip_output.c 14 Nov 2016 04:27:42 -
@@ -1811,7 +1811,7 @@ in_proto_cksum_out(struct mbuf *m, struc
} else if (m->m_pkthdr.csum_flags & M_UDP_CSUM_OUT) {
if (!ifp || !(ifp->if_capabilities & IFCAP_CSUM_UDPv4) ||
ip->ip_hl != 5 || ifp->if_bridgeport != NULL) {
-   udpstat.udps_outswcsum++;
+   udpstat_inc(udps_outswcsum);
in_delayed_cksum(m);
m->m_pkthdr.csum_flags &= ~M_UDP_CSUM_OUT; /* Clear */
}
Index: netinet/udp_usrreq.c
===
RCS file: /cvs/src/sys/netinet/udp_usrreq.c,v
retrieving revision 1.220
diff -u -p -r1.220 udp_usrreq.c
--- netinet/udp_usrreq.c3 Nov 2016 18:42:35 -   1.220
+++ netinet/udp_usrreq.c14 Nov 2016 04:27:42 -
@@ -130,10 +130,11 @@ u_int udp_recvspace = 40 * (1024 + sizeo
 int *udpctl_vars[UDPCTL_MAXID] = UDPCTL_VARS;
 
 struct inpcbtable udbtable;
-struct udpstat udpstat;
+struct cpumem *udpcounters;
 
 intudp_output(struct inpcb *, struct mbuf *, struct mbuf *, struct mbuf *);
 void   udp_notify(struct inpcb *, int);
+intudp_sysctl_udpstat(void *, size_t *, void *);
 
 #ifndefUDB_INITIAL_HASH_SIZE
 #defineUDB_INITIAL_HASH_SIZE   128
@@ -142,6 +143,7 @@ voidudp_notify(struct inpcb *, int);
 void
 udp_init(void)
 {
+   udpcounters = counters_alloc(udps_ncounters, M_COUNTERS);
in_pcbinit(, UDB_INITIAL_HASH_SIZE);
 }
 
@@ -189,7 +191,7 @@ udp_input(struct mbuf *m, ...)
iphlen = va_arg(ap, int);
va_end(ap);
 
-   udpstat.udps_ipackets++;
+   udpstat_inc(udps_ipackets);
 
switch (mtod(m, struct ip *)->ip_v) {
case 4:
@@ -212,13 +214,13 @@ udp_input(struct mbuf *m, ...)
 
IP6_EXTHDR_GET(uh, struct udphdr *, m, iphlen, sizeof(struct udphdr));
if (!uh) {
-   udpstat.udps_hdrops++;
+   udpstat_inc(udps_hdrops);
return;
}
 
/* Check for illegal destination port 0 */
if (uh->uh_dport == 0) {
-   udpstat.udps_noport++;
+   udpstat_inc(udps_noport);
goto bad;
}
 
@@ -231,7 +233,7 @@ udp_input(struct mbuf *m, ...)
if (m->m_pkthdr.len - iphlen != len) {
if (len > (m->m_pkthdr.len - iphlen) ||
len < sizeof(struct udphdr)) {
-   udpstat.udps_badlen++;
+   udpstat_inc(udps_badlen);
goto bad;
}
m_adj(m, len - (m->m_pkthdr.len - iphlen));
@@ -243,7 +245,7 @@ udp_input(struct mbuf *m, ...)
if (len == 0 && m->m_pkthdr.len - iphlen > 0x)
len = m->m_pkthdr.len - iphlen;
if (len != m->m_pkthdr.len - iphlen) {
-   udpstat.udps_badlen++;
+   udpstat_inc(udps_badlen);
goto bad;
}
}
@@ -276,7 +278,7 @@ udp_input(struct mbuf *m, ...)
 */
savesum = uh->uh_sum;
if (uh->uh_sum == 0) {
-   udpstat.udps_nosum++;
+   udpstat_inc(udps_nosum);
 #ifdef INET6
/*
 * In IPv6, the UDP checksum is ALWAYS used.
@@ -287,10 +289,10 @@ udp_input(struct mbuf *m, ...)
} else {
if ((m->m_pkthdr.csum_flags & M_UDP_CSUM_IN_OK) == 0) {
if (m->m_pkthdr.csum_flags & M_UDP_CSUM_IN_BAD) {
-   udpstat.udps_badsum++;
+   udpstat_inc(udps_badsum);
goto bad;
}
-   udpstat.udps_inswcsum++;
+   udpstat_inc(udps_inswcsum);
 
if (ip)
uh->uh_sum = in4_cksum(m, IPPROTO_UDP,
@@ -301,7 +303,7 @@ udp_input(struct mbuf *m, ...)
iphlen,