summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if.c20
-rw-r--r--sys/net/if.h3
2 files changed, 16 insertions, 7 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 6968e645c27..d5460277f67 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.380 2015/09/13 18:15:03 mpi Exp $ */
+/* $OpenBSD: if.c,v 1.381 2015/09/27 16:50:03 stsp Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -1568,6 +1568,18 @@ if_put(struct ifnet *ifp)
atomic_dec_int(&ifp->if_refcnt);
}
+int
+if_setlladdr(struct ifnet *ifp, const uint8_t *lladdr)
+{
+ if (ifp->if_sadl == NULL)
+ return (EINVAL);
+
+ memcpy(((struct arpcom *)ifp)->ac_enaddr, lladdr, ETHER_ADDR_LEN);
+ memcpy(LLADDR(ifp->if_sadl), lladdr, ETHER_ADDR_LEN);
+
+ return (0);
+}
+
/*
* Interface ioctls.
*/
@@ -1969,11 +1981,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p)
case IFT_CARP:
case IFT_XETHER:
case IFT_ISO88025:
- bcopy((caddr_t)ifr->ifr_addr.sa_data,
- (caddr_t)((struct arpcom *)ifp)->ac_enaddr,
- ETHER_ADDR_LEN);
- bcopy((caddr_t)ifr->ifr_addr.sa_data,
- LLADDR(sdl), ETHER_ADDR_LEN);
+ if_setlladdr(ifp, ifr->ifr_addr.sa_data);
error = (*ifp->if_ioctl)(ifp, cmd, data);
if (error == ENOTTY)
error = 0;
diff --git a/sys/net/if.h b/sys/net/if.h
index b9749b72abc..09c2e98ba20 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.h,v 1.167 2015/09/11 13:02:28 stsp Exp $ */
+/* $OpenBSD: if.h,v 1.168 2015/09/27 16:50:03 stsp Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
@@ -469,6 +469,7 @@ void ifnewlladdr(struct ifnet *);
void if_congestion(void);
int if_congested(void);
__dead void unhandled_af(int);
+int if_setlladdr(struct ifnet *, const uint8_t *);
#endif /* _KERNEL */