diff --git a/bsd/sys/net/if.cc b/bsd/sys/net/if.cc
index 074de5c90e74a55338f18f99bc329f3da273c4ed..ed0d2298dd434ff954d17efc6c98b2b0fc886515 100644
--- a/bsd/sys/net/if.cc
+++ b/bsd/sys/net/if.cc
@@ -365,15 +365,15 @@ if_grow(void)
 struct ifnet *
 if_alloc(u_char type)
 {
-	struct ifnet *ifp;
+	// bsd defines a variable named 'ifnet', so we must do this ugliness
+	typedef struct ifnet s_ifnet;
+	std::unique_ptr<s_ifnet> ifp;
 	u_short idx;
 
-	ifp = (struct ifnet *)malloc(sizeof(struct ifnet));
-	bzero(ifp, sizeof(struct ifnet));
+	ifp.reset(new s_ifnet{});
 	IFNET_WLOCK();
 	if (ifindex_alloc_locked(&idx) != 0) {
 		IFNET_WUNLOCK();
-		free(ifp);
 		return (NULL);
 	}
 	ifnet_setbyindex_locked(idx, IFNET_HOLD);
@@ -382,26 +382,23 @@ if_alloc(u_char type)
 	ifp->if_type = type;
 	ifp->if_alloctype = type;
 	if (if_com_alloc[type] != NULL) {
-		ifp->if_l2com = if_com_alloc[type](type, ifp);
+		ifp->if_l2com = if_com_alloc[type](type, ifp.get());
 		if (ifp->if_l2com == NULL) {
-			free(ifp);
 			ifindex_free(idx);
 			return (NULL);
 		}
 	}
 
-	IF_ADDR_LOCK_INIT(ifp);
 	ifp->if_afdata_initialized = 0;
-	IF_AFDATA_LOCK_INIT(ifp);
 	TAILQ_INIT(&ifp->if_addrhead);
 	TAILQ_INIT(&ifp->if_prefixhead);
 	TAILQ_INIT(&ifp->if_multiaddrs);
 	TAILQ_INIT(&ifp->if_groups);
-	ifq_init(&ifp->if_snd, ifp);
+	ifq_init(&ifp->if_snd, ifp.get());
 
 	refcount_init(&ifp->if_refcount, 1);	/* Index reference. */
-	ifnet_setbyindex(ifp->if_index, ifp);
-	return (ifp);
+	ifnet_setbyindex(ifp->if_index, ifp.get());
+	return ifp.release();
 }
 
 /*
@@ -422,10 +419,8 @@ if_free_internal(struct ifnet *ifp)
 
 	if (ifp->if_description != NULL)
 		free(ifp->if_description);
-	IF_AFDATA_DESTROY(ifp);
-	IF_ADDR_LOCK_DESTROY(ifp);
 	ifq_delete(&ifp->if_snd);
-	free(ifp);
+	delete ifp;
 }
 
 /*
diff --git a/bsd/sys/net/if_var.h b/bsd/sys/net/if_var.h
index 7bb9ac02ed1396c144e54ab63cbcb7aa045d29b6..efad62857eff59d7bf38c92733648cfc0e9dd595 100644
--- a/bsd/sys/net/if_var.h
+++ b/bsd/sys/net/if_var.h
@@ -248,9 +248,6 @@ typedef void if_init_f_t(void *);
 /*
  * Locks for address lists on the network interface.
  */
-#define	IF_ADDR_LOCK_INIT(if)	mtx_init(&(if)->if_addr_mtx,		\
-				    "if_addr_mtx", NULL, MTX_DEF)
-#define	IF_ADDR_LOCK_DESTROY(if)	mtx_destroy(&(if)->if_addr_mtx)
 #define	IF_ADDR_WLOCK(if)	mtx_lock(&(if)->if_addr_mtx)
 #define	IF_ADDR_WUNLOCK(if)	mtx_unlock(&(if)->if_addr_mtx)
 #define	IF_ADDR_RLOCK(if)	mtx_lock(&(if)->if_addr_mtx)
@@ -409,9 +406,6 @@ EVENTHANDLER_DECLARE(group_detach_event, group_detach_event_handler_t);
 typedef void (*group_change_event_handler_t)(void *, const char *);
 EVENTHANDLER_DECLARE(group_change_event, group_change_event_handler_t);
 
-#define	IF_AFDATA_LOCK_INIT(ifp)	\
-	rw_init(&(ifp)->if_afdata_lock, "if_afdata")
-
 #define	IF_AFDATA_WLOCK(ifp)	rw_wlock(&(ifp)->if_afdata_lock)
 #define	IF_AFDATA_RLOCK(ifp)	rw_rlock(&(ifp)->if_afdata_lock)
 #define	IF_AFDATA_WUNLOCK(ifp)	rw_wunlock(&(ifp)->if_afdata_lock)
@@ -419,7 +413,6 @@ EVENTHANDLER_DECLARE(group_change_event, group_change_event_handler_t);
 #define	IF_AFDATA_LOCK(ifp)	IF_AFDATA_WLOCK(ifp)
 #define	IF_AFDATA_UNLOCK(ifp)	IF_AFDATA_WUNLOCK(ifp)
 #define	IF_AFDATA_TRYLOCK(ifp)	rw_try_wlock(&(ifp)->if_afdata_lock)
-#define	IF_AFDATA_DESTROY(ifp)	rw_destroy(&(ifp)->if_afdata_lock)
 
 #define	IF_AFDATA_LOCK_ASSERT(ifp)	rw_assert(&(ifp)->if_afdata_lock, RA_LOCKED)
 #define	IF_AFDATA_RLOCK_ASSERT(ifp)	rw_assert(&(ifp)->if_afdata_lock, RA_RLOCKED)