summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/netinet/icmp6.h4
-rw-r--r--sys/netinet6/in6.c35
-rw-r--r--sys/netinet6/in6_var.h22
3 files changed, 42 insertions, 19 deletions
diff --git a/sys/netinet/icmp6.h b/sys/netinet/icmp6.h
index 50d480c..15f4c2d 100644
--- a/sys/netinet/icmp6.h
+++ b/sys/netinet/icmp6.h
@@ -692,7 +692,9 @@ void icmp6_mtudisc_update(struct ip6ctlparam *, int);
#define icmp6_ifstat_inc(ifp, tag) \
do { \
if (ifp) \
- ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat->tag++; \
+ counter_u64_add(((struct in6_ifextra *) \
+ ((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat[\
+ offsetof(struct icmp6_ifstat, tag) / sizeof(uint64_t)], 1);\
} while (/*CONSTCOND*/ 0)
#define icmp6_ifoutstat_inc(ifp, type, code) \
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 9e005c5..e0a9128 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -570,10 +570,10 @@ in6_control(struct socket *so, u_long cmd, caddr_t data,
error = EINVAL;
goto out;
}
- bzero(&ifr->ifr_ifru.ifru_stat,
- sizeof(ifr->ifr_ifru.ifru_stat));
- ifr->ifr_ifru.ifru_stat =
- *((struct in6_ifextra *)ifp->if_afdata[AF_INET6])->in6_ifstat;
+ COUNTER_ARRAY_COPY(((struct in6_ifextra *)
+ ifp->if_afdata[AF_INET6])->in6_ifstat,
+ &ifr->ifr_ifru.ifru_stat,
+ sizeof(struct in6_ifstat) / sizeof(uint64_t));
break;
case SIOCGIFSTAT_ICMP6:
@@ -581,10 +581,10 @@ in6_control(struct socket *so, u_long cmd, caddr_t data,
error = EINVAL;
goto out;
}
- bzero(&ifr->ifr_ifru.ifru_icmp6stat,
- sizeof(ifr->ifr_ifru.ifru_icmp6stat));
- ifr->ifr_ifru.ifru_icmp6stat =
- *((struct in6_ifextra *)ifp->if_afdata[AF_INET6])->icmp6_ifstat;
+ COUNTER_ARRAY_COPY(((struct in6_ifextra *)
+ ifp->if_afdata[AF_INET6])->icmp6_ifstat,
+ &ifr->ifr_ifru.ifru_icmp6stat,
+ sizeof(struct icmp6_ifstat) / sizeof(uint64_t));
break;
case SIOCGIFALIFETIME_IN6:
@@ -2749,14 +2749,15 @@ in6_domifattach(struct ifnet *ifp)
ext = (struct in6_ifextra *)malloc(sizeof(*ext), M_IFADDR, M_WAITOK);
bzero(ext, sizeof(*ext));
- ext->in6_ifstat = (struct in6_ifstat *)malloc(sizeof(struct in6_ifstat),
- M_IFADDR, M_WAITOK);
- bzero(ext->in6_ifstat, sizeof(*ext->in6_ifstat));
+ ext->in6_ifstat = malloc(sizeof(struct in6_ifstat), M_IFADDR,
+ M_WAITOK);
+ COUNTER_ARRAY_ALLOC(ext->in6_ifstat,
+ sizeof(struct in6_ifstat) / sizeof(uint64_t), M_WAITOK);
- ext->icmp6_ifstat =
- (struct icmp6_ifstat *)malloc(sizeof(struct icmp6_ifstat),
- M_IFADDR, M_WAITOK);
- bzero(ext->icmp6_ifstat, sizeof(*ext->icmp6_ifstat));
+ ext->icmp6_ifstat = malloc(sizeof(struct icmp6_ifstat), M_IFADDR,
+ M_WAITOK);
+ COUNTER_ARRAY_ALLOC(ext->icmp6_ifstat,
+ sizeof(struct icmp6_ifstat) / sizeof(uint64_t), M_WAITOK);
ext->nd_ifinfo = nd6_ifattach(ifp);
ext->scope6_id = scope6_ifattach(ifp);
@@ -2781,7 +2782,11 @@ in6_domifdetach(struct ifnet *ifp, void *aux)
scope6_ifdetach(ext->scope6_id);
nd6_ifdetach(ext->nd_ifinfo);
lltable_free(ext->lltable);
+ COUNTER_ARRAY_FREE(ext->in6_ifstat,
+ sizeof(struct in6_ifstat) / sizeof(uint64_t));
free(ext->in6_ifstat, M_IFADDR);
+ COUNTER_ARRAY_FREE(ext->icmp6_ifstat,
+ sizeof(struct icmp6_ifstat) / sizeof(uint64_t));
free(ext->icmp6_ifstat, M_IFADDR);
free(ext, M_IFADDR);
}
diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h
index 766082d..e2f356d 100644
--- a/sys/netinet6/in6_var.h
+++ b/sys/netinet6/in6_var.h
@@ -98,14 +98,28 @@ struct scope6_id;
struct lltable;
struct mld_ifinfo;
+#ifdef _KERNEL
+#include <sys/counter.h>
+
+struct in6_ifextra {
+ counter_u64_t *in6_ifstat;
+ counter_u64_t *icmp6_ifstat;
+ struct nd_ifinfo *nd_ifinfo;
+ struct scope6_id *scope6_id;
+ struct lltable *lltable;
+ struct mld_ifinfo *mld_ifinfo;
+};
+#else
+
struct in6_ifextra {
- struct in6_ifstat *in6_ifstat;
- struct icmp6_ifstat *icmp6_ifstat;
+ void *in6_ifstat;
+ void *icmp6_ifstat;
struct nd_ifinfo *nd_ifinfo;
struct scope6_id *scope6_id;
struct lltable *lltable;
struct mld_ifinfo *mld_ifinfo;
};
+#endif /* !_KERNEL */
#define LLTABLE6(ifp) (((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->lltable)
@@ -537,7 +551,9 @@ extern struct rwlock in6_ifaddr_lock;
#define in6_ifstat_inc(ifp, tag) \
do { \
if (ifp) \
- ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->in6_ifstat->tag++; \
+ counter_u64_add(((struct in6_ifextra *) \
+ ((ifp)->if_afdata[AF_INET6]))->in6_ifstat[ \
+ offsetof(struct in6_ifstat, tag) / sizeof(uint64_t)], 1);\
} while (/*CONSTCOND*/ 0)
extern u_char inet6ctlerrmap[];
OpenPOWER on IntegriCloud