Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Move INET6 specific in6_if_{up, down}() and in6_if_link_{...
details: https://anonhg.NetBSD.org/src/rev/f8c85398ce17
branches: trunk
changeset: 337661:f8c85398ce17
user: roy <roy%NetBSD.org@localhost>
date: Wed Apr 22 19:46:08 2015 +0000
description:
Move INET6 specific in6_if_{up,down}() and in6_if_link_{up,down}()
into agnostic domain functions.
diffstat:
sys/net/if.c | 55 ++++++++++++++++++++++-------------------------
sys/netinet6/in6.c | 18 +++++++++++++-
sys/netinet6/in6.h | 3 +-
sys/netinet6/in6_proto.c | 6 +++-
sys/sys/domain.h | 8 ++++++-
5 files changed, 55 insertions(+), 35 deletions(-)
diffs (256 lines):
diff -r f26d86d9a795 -r f8c85398ce17 sys/net/if.c
--- a/sys/net/if.c Wed Apr 22 19:43:45 2015 +0000
+++ b/sys/net/if.c Wed Apr 22 19:46:08 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.311 2015/04/21 10:39:41 pooka Exp $ */
+/* $NetBSD: if.c,v 1.312 2015/04/22 19:46:08 roy Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.311 2015/04/21 10:39:41 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.312 2015/04/22 19:46:08 roy Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -1423,9 +1423,8 @@
if_link_state_change(struct ifnet *ifp, int link_state)
{
int s;
-#if defined(DEBUG) || defined(INET6)
int old_link_state;
-#endif
+ struct domain *dp;
s = splnet();
if (ifp->if_link_state == link_state) {
@@ -1433,9 +1432,7 @@
return;
}
-#if defined(DEBUG) || defined(INET6)
old_link_state = ifp->if_link_state;
-#endif
ifp->if_link_state = link_state;
#ifdef DEBUG
log(LOG_DEBUG, "%s: link state %s (was %s)\n", ifp->if_xname,
@@ -1447,7 +1444,6 @@
"UNKNOWN");
#endif
-#ifdef INET6
/*
* When going from UNKNOWN to UP, we need to mark existing
* IPv6 addresses as tentative and restart DAD as we may have
@@ -1457,10 +1453,15 @@
* listeners would have an address and expect it to work right
* away.
*/
- if (in6_present && link_state == LINK_STATE_UP &&
+ if (link_state == LINK_STATE_UP &&
old_link_state == LINK_STATE_UNKNOWN)
- in6_if_link_down(ifp);
-#endif
+ {
+ DOMAIN_FOREACH(dp) {
+ if (dp->dom_if_link_state_change != NULL)
+ dp->dom_if_link_state_change(ifp,
+ LINK_STATE_DOWN);
+ }
+ }
/* Notify that the link state has changed. */
rt_ifmsg(ifp);
@@ -1470,14 +1471,10 @@
carp_carpdev_state(ifp);
#endif
-#ifdef INET6
- if (in6_present) {
- if (link_state == LINK_STATE_DOWN)
- in6_if_link_down(ifp);
- else if (link_state == LINK_STATE_UP)
- in6_if_link_up(ifp);
+ DOMAIN_FOREACH(dp) {
+ if (dp->dom_if_link_state_change != NULL)
+ dp->dom_if_link_state_change(ifp, link_state);
}
-#endif
splx(s);
}
@@ -1543,6 +1540,7 @@
if_down(struct ifnet *ifp)
{
struct ifaddr *ifa;
+ struct domain *dp;
ifp->if_flags &= ~IFF_UP;
nanotime(&ifp->if_lastchange);
@@ -1554,10 +1552,10 @@
carp_carpdev_state(ifp);
#endif
rt_ifmsg(ifp);
-#ifdef INET6
- if (in6_present)
- in6_if_down(ifp);
-#endif
+ DOMAIN_FOREACH(dp) {
+ if (dp->dom_if_down)
+ dp->dom_if_down(ifp);
+ }
}
/*
@@ -1571,6 +1569,7 @@
#ifdef notyet
struct ifaddr *ifa;
#endif
+ struct domain *dp;
ifp->if_flags |= IFF_UP;
nanotime(&ifp->if_lastchange);
@@ -1584,10 +1583,10 @@
carp_carpdev_state(ifp);
#endif
rt_ifmsg(ifp);
-#ifdef INET6
- if (in6_present)
- in6_if_up(ifp);
-#endif
+ DOMAIN_FOREACH(dp) {
+ if (dp->dom_if_down)
+ dp->dom_if_down(ifp);
+ }
}
/*
@@ -2067,13 +2066,11 @@
}
if (((oif_flags ^ ifp->if_flags) & IFF_UP) != 0) {
-#ifdef INET6
- if (in6_present && (ifp->if_flags & IFF_UP) != 0) {
+ if ((ifp->if_flags & IFF_UP) != 0) {
int s = splnet();
- in6_if_up(ifp);
+ if_up(ifp);
splx(s);
}
-#endif
}
#ifdef COMPAT_OIFREQ
if (cmd != ocmd)
diff -r f26d86d9a795 -r f8c85398ce17 sys/netinet6/in6.c
--- a/sys/netinet6/in6.c Wed Apr 22 19:43:45 2015 +0000
+++ b/sys/netinet6/in6.c Wed Apr 22 19:46:08 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6.c,v 1.187 2015/04/20 10:19:54 roy Exp $ */
+/* $NetBSD: in6.c,v 1.188 2015/04/22 19:46:08 roy Exp $ */
/* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.187 2015/04/20 10:19:54 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.188 2015/04/22 19:46:08 roy Exp $");
#include "opt_inet.h"
#include "opt_compat_netbsd.h"
@@ -2099,6 +2099,20 @@
in6_if_link_down(ifp);
}
+void
+in6_if_link_state_change(struct ifnet *ifp, int link_state)
+{
+
+ switch (link_state) {
+ case LINK_STATE_DOWN:
+ in6_if_link_down(ifp);
+ break;
+ case LINK_STATE_UP:
+ in6_if_link_up(ifp);
+ break;
+ }
+}
+
/*
* Calculate max IPv6 MTU through all the interfaces and store it
* to in6_maxmtu.
diff -r f26d86d9a795 -r f8c85398ce17 sys/netinet6/in6.h
--- a/sys/netinet6/in6.h Wed Apr 22 19:43:45 2015 +0000
+++ b/sys/netinet6/in6.h Wed Apr 22 19:46:08 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6.h,v 1.83 2015/02/20 22:13:48 rjs Exp $ */
+/* $NetBSD: in6.h,v 1.84 2015/04/22 19:46:08 roy Exp $ */
/* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */
/*
@@ -705,6 +705,7 @@
struct in6_ifaddr *in6_ifawithifp(struct ifnet *, struct in6_addr *);
extern void in6_if_link_up(struct ifnet *);
extern void in6_if_link_down(struct ifnet *);
+extern void in6_if_link_state_change(struct ifnet *, int);
extern void in6_if_up(struct ifnet *);
extern void in6_if_down(struct ifnet *);
#ifndef __FreeBSD__
diff -r f26d86d9a795 -r f8c85398ce17 sys/netinet6/in6_proto.c
--- a/sys/netinet6/in6_proto.c Wed Apr 22 19:43:45 2015 +0000
+++ b/sys/netinet6/in6_proto.c Wed Apr 22 19:46:08 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_proto.c,v 1.104 2015/02/10 19:11:52 rjs Exp $ */
+/* $NetBSD: in6_proto.c,v 1.105 2015/04/22 19:46:08 roy Exp $ */
/* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.104 2015/02/10 19:11:52 rjs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.105 2015/04/22 19:46:08 roy Exp $");
#include "opt_gateway.h"
#include "opt_inet.h"
@@ -397,7 +397,9 @@
.dom_rtattach = rt_inithead,
.dom_rtoffset = offsetof(struct sockaddr_in6, sin6_addr) << 3,
.dom_maxrtkey = sizeof(struct ip_pack6),
+ .dom_if_up = in6_if_up, .dom_if_down = in6_if_down,
.dom_ifattach = in6_domifattach, .dom_ifdetach = in6_domifdetach,
+ .dom_if_link_state_change = in6_if_link_state_change,
.dom_ifqueues = { NULL, NULL },
.dom_link = { NULL },
.dom_mowner = MOWNER_INIT("",""),
diff -r f26d86d9a795 -r f8c85398ce17 sys/sys/domain.h
--- a/sys/sys/domain.h Wed Apr 22 19:43:45 2015 +0000
+++ b/sys/sys/domain.h Wed Apr 22 19:46:08 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: domain.h,v 1.31 2011/06/26 16:43:12 christos Exp $ */
+/* $NetBSD: domain.h,v 1.32 2015/04/22 19:46:08 roy Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -66,10 +66,16 @@
(rtbl_t **, int);
int dom_rtoffset; /* an arg to rtattach, in bits */
int dom_maxrtkey; /* for routing layer */
+ void (*dom_if_up) /* ifnet brought up */
+ (struct ifnet *);
+ void (*dom_if_down) /* ifnet brought down */
+ (struct ifnet *);
void *(*dom_ifattach) /* attach af-dependent data on ifnet */
(struct ifnet *);
void (*dom_ifdetach) /* detach af-dependent data on ifnet */
(struct ifnet *, void *);
+ void (*dom_if_link_state_change)
+ (struct ifnet *, int);
const void *(*dom_sockaddr_const_addr)(const struct sockaddr *,
socklen_t *);
void *(*dom_sockaddr_addr)(struct sockaddr *, socklen_t *);
Home |
Main Index |
Thread Index |
Old Index