diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2002-05-29 02:59:13 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2002-05-29 02:59:13 +0000 |
commit | fc3544ce32f3831afe6e02be0ff23c0784ef21de (patch) | |
tree | 12ed07b787ad4aa6382f67b88c2476a2e0ccd7fe /sys/netinet6 | |
parent | eea1698a30be8765c09516e1c73b223e53d6ea08 (diff) |
move per-interface ip6/icmp6 stat to ifnet->if_afdata. sync w/kame
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/in6.c | 64 | ||||
-rw-r--r-- | sys/netinet6/in6_ifattach.c | 59 | ||||
-rw-r--r-- | sys/netinet6/in6_proto.c | 5 | ||||
-rw-r--r-- | sys/netinet6/in6_var.h | 22 |
4 files changed, 68 insertions, 82 deletions
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index cd86a930586..24604f2db53 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.c,v 1.33 2002/05/23 06:56:16 itojun Exp $ */ +/* $OpenBSD: in6.c,v 1.34 2002/05/29 02:59:12 itojun Exp $ */ /* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */ /* @@ -532,26 +532,19 @@ in6_control(so, cmd, data, ifp, p) case SIOCGIFSTAT_IN6: if (ifp == NULL) return EINVAL; - if (in6_ifstat == NULL || ifp->if_index >= in6_ifstatmax - || in6_ifstat[ifp->if_index] == NULL) { - /* return EAFNOSUPPORT? */ - bzero(&ifr->ifr_ifru.ifru_stat, - sizeof(ifr->ifr_ifru.ifru_stat)); - } else - ifr->ifr_ifru.ifru_stat = *in6_ifstat[ifp->if_index]; + 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; break; case SIOCGIFSTAT_ICMP6: if (ifp == NULL) return EINVAL; - if (icmp6_ifstat == NULL || ifp->if_index >= icmp6_ifstatmax || - icmp6_ifstat[ifp->if_index] == NULL) { - /* return EAFNOSUPPORT? */ - bzero(&ifr->ifr_ifru.ifru_stat, - sizeof(ifr->ifr_ifru.ifru_icmp6stat)); - } else - ifr->ifr_ifru.ifru_icmp6stat = - *icmp6_ifstat[ifp->if_index]; + bzero(&ifr->ifr_ifru.ifru_stat, + sizeof(ifr->ifr_ifru.ifru_icmp6stat)); + ifr->ifr_ifru.ifru_icmp6stat = + *((struct in6_ifextra *)ifp->if_afdata[AF_INET6])->icmp6_ifstat; break; #ifdef COMPAT_IN6IFIOCTL /* should be unused */ @@ -2156,3 +2149,42 @@ in6_setmaxmtu() if (maxmtu) /* update only when maxmtu is positive */ in6_maxmtu = maxmtu; } + +void * +in6_domifattach(ifp) + struct ifnet *ifp; +{ + struct in6_ifextra *ext; + + 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->icmp6_ifstat = + (struct icmp6_ifstat *)malloc(sizeof(struct icmp6_ifstat), + M_IFADDR, M_WAITOK); + bzero(ext->icmp6_ifstat, sizeof(*ext->icmp6_ifstat)); + +#if 0 + ext->nd_ifinfo = nd6_ifattach(ifp); +#endif + return ext; +} + +void +in6_domifdetach(ifp, aux) + struct ifnet *ifp; + void *aux; +{ + struct in6_ifextra *ext = (struct in6_ifextra *)aux; + +#if 0 + nd6_ifdetach(ext->nd_ifinfo); +#endif + free(ext->in6_ifstat, M_IFADDR); + free(ext->icmp6_ifstat, M_IFADDR); + free(ext, M_IFADDR); +} diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 85d6c6da8e0..bc471e7da87 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_ifattach.c,v 1.23 2002/05/23 06:56:16 itojun Exp $ */ +/* $OpenBSD: in6_ifattach.c,v 1.24 2002/05/29 02:59:12 itojun Exp $ */ /* $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $ */ /* @@ -54,10 +54,6 @@ #include <netinet6/ip6_var.h> #include <netinet6/nd6.h> -struct in6_ifstat **in6_ifstat = NULL; -struct icmp6_ifstat **icmp6_ifstat = NULL; -size_t in6_ifstatmax = 0; -size_t icmp6_ifstatmax = 0; unsigned long in6_maxmtu = 0; static int get_rand_ifid(struct ifnet *, struct in6_addr *); @@ -561,7 +557,6 @@ in6_ifattach(ifp, altifp) struct ifnet *ifp; struct ifnet *altifp; /* secondary EUI64 source */ { - static size_t if_indexlim = 8; struct sockaddr_in6 mltaddr; struct sockaddr_in6 mltmask; struct sockaddr_in6 gate; @@ -583,47 +578,6 @@ in6_ifattach(ifp, altifp) break; } - /* - * We have some arrays that should be indexed by if_index. - * since if_index will grow dynamically, they should grow too. - * struct in6_ifstat **in6_ifstat - * struct icmp6_ifstat **icmp6_ifstat - */ - if (in6_ifstat == NULL || icmp6_ifstat == NULL || - if_index >= if_indexlim) { - size_t n; - caddr_t q; - size_t olim; - - olim = if_indexlim; - while (if_index >= if_indexlim) - if_indexlim <<= 1; - - /* grow in6_ifstat */ - n = if_indexlim * sizeof(struct in6_ifstat *); - q = (caddr_t)malloc(n, M_IFADDR, M_WAITOK); - bzero(q, n); - if (in6_ifstat) { - bcopy((caddr_t)in6_ifstat, q, - olim * sizeof(struct in6_ifstat *)); - free((caddr_t)in6_ifstat, M_IFADDR); - } - in6_ifstat = (struct in6_ifstat **)q; - in6_ifstatmax = if_indexlim; - - /* grow icmp6_ifstat */ - n = if_indexlim * sizeof(struct icmp6_ifstat *); - q = (caddr_t)malloc(n, M_IFADDR, M_WAITOK); - bzero(q, n); - if (icmp6_ifstat) { - bcopy((caddr_t)icmp6_ifstat, q, - olim * sizeof(struct icmp6_ifstat *)); - free((caddr_t)icmp6_ifstat, M_IFADDR); - } - icmp6_ifstat = (struct icmp6_ifstat **)q; - icmp6_ifstatmax = if_indexlim; - } - /* create a multicast kludge storage (if we have not had one) */ in6_createmkludge(ifp); @@ -774,17 +728,6 @@ statinit:; if (in6_maxmtu < ifp->if_mtu) in6_maxmtu = ifp->if_mtu; - if (in6_ifstat[ifp->if_index] == NULL) { - in6_ifstat[ifp->if_index] = (struct in6_ifstat *) - malloc(sizeof(struct in6_ifstat), M_IFADDR, M_WAITOK); - bzero(in6_ifstat[ifp->if_index], sizeof(struct in6_ifstat)); - } - if (icmp6_ifstat[ifp->if_index] == NULL) { - icmp6_ifstat[ifp->if_index] = (struct icmp6_ifstat *) - malloc(sizeof(struct icmp6_ifstat), M_IFADDR, M_WAITOK); - bzero(icmp6_ifstat[ifp->if_index], sizeof(struct icmp6_ifstat)); - } - /* initialize NDP variables */ nd6_ifattach(ifp); } diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index 8f1fda7ff09..83c58e34803 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_proto.c,v 1.33 2002/05/28 03:04:38 itojun Exp $ */ +/* $OpenBSD: in6_proto.c,v 1.34 2002/05/29 02:59:12 itojun Exp $ */ /* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */ /* @@ -228,7 +228,8 @@ struct domain inet6domain = (struct protosw *)&inet6sw[sizeof(inet6sw)/sizeof(inet6sw[0])], 0, rn_inithead, offsetof(struct sockaddr_in6, sin6_addr) << 3, - sizeof(struct sockaddr_in6) }; + sizeof(struct sockaddr_in6), + in6_domifattach, in6_domifdetach, }; /* * Internet configuration info diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h index 8b046f501ef..57093449d29 100644 --- a/sys/netinet6/in6_var.h +++ b/sys/netinet6/in6_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_var.h,v 1.15 2002/05/23 06:56:16 itojun Exp $ */ +/* $OpenBSD: in6_var.h,v 1.16 2002/05/29 02:59:12 itojun Exp $ */ /* $KAME: in6_var.h,v 1.55 2001/02/16 12:49:45 itojun Exp $ */ /* @@ -90,6 +90,17 @@ struct in6_addrlifetime { u_int32_t ia6t_pltime; /* prefix lifetime */ }; +#if 0 +struct nd_ifinfo; +#endif +struct in6_ifextra { + struct in6_ifstat *in6_ifstat; + struct icmp6_ifstat *icmp6_ifstat; +#if 0 + struct nd_ifinfo *nd_ifinfo; +#endif +}; + struct in6_ifaddr { struct ifaddr ia_ifa; /* protocol-independent info */ #define ia_ifp ia_ifa.ifa_ifp @@ -435,11 +446,8 @@ extern struct icmp6_ifstat **icmp6_ifstat; extern size_t icmp6_ifstatmax; #define in6_ifstat_inc(ifp, tag) \ do { \ - if ((ifp) && (ifp)->if_index <= if_index \ - && (ifp)->if_index < in6_ifstatmax \ - && in6_ifstat && in6_ifstat[(ifp)->if_index]) { \ - in6_ifstat[(ifp)->if_index]->tag++; \ - } \ + if (ifp) \ + ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->in6_ifstat->tag++; \ } while (0) extern struct ifqueue ip6intrq; /* IP6 packet input queue */ @@ -567,6 +575,8 @@ void in6_purgeaddr(struct ifaddr *, struct ifnet *); int in6if_do_dad(struct ifnet *); void in6_savemkludge(struct in6_ifaddr *); void in6_setmaxmtu(void); +void *in6_domifattach(struct ifnet *); +void in6_domifdetach(struct ifnet *, void *); void in6_restoremkludge(struct in6_ifaddr *, struct ifnet *); void in6_createmkludge(struct ifnet *); void in6_purgemkludge(struct ifnet *); |