summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2010-04-17 17:46:33 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2010-04-17 17:46:33 +0000
commit0ce12e1362d853420da3d1778cd033c53982ca49 (patch)
treee0bbee2648f9382c796a243b8ba00a6c87ab3f6c /sys/net
parent7bd2e9dcad78057dab150575417eade09d8de704 (diff)
split SIOCSIFLLADDR code out into an ifnewlladr() function
ok stsp
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c58
-rw-r--r--sys/net/if.h3
2 files changed, 43 insertions, 18 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 9ee3f1cfa47..2ea274ecf03 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.211 2010/03/08 21:00:27 henning Exp $ */
+/* $OpenBSD: if.c,v 1.212 2010/04/17 17:46:32 deraadt Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -103,6 +103,8 @@
#endif
#include <netinet6/in6_ifattach.h>
#include <netinet6/nd6.h>
+#include <netinet/ip6.h>
+#include <netinet6/ip6_var.h>
#endif
#if NBPFILTER > 0
@@ -1559,22 +1561,8 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p)
default:
return (ENODEV);
}
- if (ifp->if_flags & IFF_UP) {
- struct ifreq ifrq;
- int s = splnet();
- ifp->if_flags &= ~IFF_UP;
- ifrq.ifr_flags = ifp->if_flags;
- (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifrq);
- ifp->if_flags |= IFF_UP;
- ifrq.ifr_flags = ifp->if_flags;
- (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifrq);
- splx(s);
- TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
- if (ifa->ifa_addr != NULL &&
- ifa->ifa_addr->sa_family == AF_INET)
- arp_ifinit((struct arpcom *)ifp, ifa);
- }
- }
+
+ ifnewlladdr(ifp);
break;
default:
@@ -2233,3 +2221,39 @@ ifa_item_remove(struct sockaddr *sa, struct ifaddr *ifa, struct ifnet *ifp)
ifai_last->ifai_next = ifai->ifai_next;
pool_put(&ifaddr_item_pl, ifai);
}
+
+void
+ifnewlladdr(struct ifnet *ifp)
+{
+ struct ifaddr *ifa;
+ struct ifreq ifrq;
+ short up;
+ int s;
+
+ s = splnet();
+ up = ifp->if_flags & IFF_UP;
+
+ if (up) {
+ /* go down for a moment... */
+ ifp->if_flags &= ~IFF_UP;
+ ifrq.ifr_flags = ifp->if_flags;
+ (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifrq);
+ }
+
+ ifp->if_flags |= IFF_UP;
+ ifrq.ifr_flags = ifp->if_flags;
+ (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifrq);
+
+ TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
+ if (ifa->ifa_addr != NULL &&
+ ifa->ifa_addr->sa_family == AF_INET)
+ arp_ifinit((struct arpcom *)ifp, ifa);
+ }
+ if (!up) {
+ /* go back down */
+ ifp->if_flags &= ~IFF_UP;
+ ifrq.ifr_flags = ifp->if_flags;
+ (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifrq);
+ }
+ splx(s);
+}
diff --git a/sys/net/if.h b/sys/net/if.h
index d467bbaa20e..4f8d0ad24a0 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.h,v 1.114 2010/04/06 14:12:10 stsp Exp $ */
+/* $OpenBSD: if.h,v 1.115 2010/04/17 17:46:32 deraadt Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
@@ -810,6 +810,7 @@ int if_delgroup(struct ifnet *, const char *);
void if_group_routechange(struct sockaddr *, struct sockaddr *);
struct ifnet *ifunit(const char *);
void if_start(struct ifnet *);
+void ifnewlladdr(struct ifnet *);
struct ifaddr *ifa_ifwithaddr(struct sockaddr *, u_int);
struct ifaddr *ifa_ifwithaf(int, u_int);