Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet6 undo interface addition attempt if in6_ifinit()...
details: https://anonhg.NetBSD.org/src/rev/47e367b7ea32
branches: trunk
changeset: 483532:47e367b7ea32
user: itojun <itojun%NetBSD.org@localhost>
date: Sun Mar 12 05:23:07 2000 +0000
description:
undo interface addition attempt if in6_ifinit() fails.
without it, :: will be kept if in6_ifinit() fails.
diffstat:
sys/netinet6/in6.c | 38 +++++++++++++++++++++++++++++++++-----
1 files changed, 33 insertions(+), 5 deletions(-)
diffs (74 lines):
diff -r 71986f02d11d -r 47e367b7ea32 sys/netinet6/in6.c
--- a/sys/netinet6/in6.c Sun Mar 12 05:04:44 2000 +0000
+++ b/sys/netinet6/in6.c Sun Mar 12 05:23:07 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6.c,v 1.23 2000/03/02 07:14:52 itojun Exp $ */
+/* $NetBSD: in6.c,v 1.24 2000/03/12 05:23:07 itojun Exp $ */
/* $KAME: in6.c,v 1.56 2000/03/02 07:11:00 itojun Exp $ */
/*
@@ -327,7 +327,8 @@
#ifdef COMPAT_IN6IFIOCTL
struct sockaddr_in6 net;
#endif
- int error = 0, hostIsNew, prefixIsNew;
+ int error = 0, hostIsNew, prefixIsNew;
+ int newifaddr;
time_t time_second = (time_t)time.tv_sec;
int privileged;
@@ -488,7 +489,10 @@
TAILQ_INSERT_TAIL(&ifp->if_addrlist, &ia->ia_ifa,
ifa_list);
IFAREF(&ia->ia_ifa);
- }
+
+ newifaddr = 1;
+ } else
+ newifaddr = 0;
if (cmd == SIOCAIFADDR_IN6) {
/* sanity for overflow - beware unsigned */
@@ -639,7 +643,28 @@
break;
case SIOCSIFADDR_IN6:
- return(in6_ifinit(ifp, ia, &ifr->ifr_addr, 1));
+ error = in6_ifinit(ifp, ia, &ifr->ifr_addr, 1);
+ undo:
+ if (error && newifaddr) {
+ TAILQ_REMOVE(&ifp->if_addrlist, &ia->ia_ifa, ifa_list);
+ IFAFREE(&ia->ia_ifa);
+
+ oia = ia;
+ if (oia == (ia = in6_ifaddr))
+ in6_ifaddr = ia->ia_next;
+ else {
+ while (ia->ia_next && (ia->ia_next != oia))
+ ia = ia->ia_next;
+ if (ia->ia_next)
+ ia->ia_next = oia->ia_next;
+ else {
+ printf("Didn't unlink in6_ifaddr "
+ "from list\n");
+ }
+ }
+ IFAFREE(&ia->ia_ifa);
+ }
+ return error;
#ifdef COMPAT_IN6IFIOCTL /* XXX should be unused */
case SIOCSIFNETMASK_IN6:
@@ -719,8 +744,11 @@
}
prefixIsNew = 1; /* We lie; but effect's the same */
}
- if (hostIsNew || prefixIsNew)
+ if (hostIsNew || prefixIsNew) {
error = in6_ifinit(ifp, ia, &ifra->ifra_addr, 0);
+ if (error)
+ goto undo;
+ }
if (hostIsNew && (ifp->if_flags & IFF_MULTICAST)) {
int error_local = 0;
Home |
Main Index |
Thread Index |
Old Index