From 4d34da9e99f9d70f2c492e5a420168f188de6f41 Mon Sep 17 00:00:00 2001
From: Guy Zana <guy@cloudius-systems.com>
Date: Tue, 26 Feb 2013 13:36:36 +0200
Subject: [PATCH] net: cleaned up if_llatbl.h and add to net_init()

---
 bsd/net.cc              |  2 ++
 bsd/porting/netport.h   |  1 +
 bsd/sys/net/if_llatbl.c | 11 ++++++-----
 bsd/sys/net/if_llatbl.h | 12 ++++++------
 4 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/bsd/net.cc b/bsd/net.cc
index 49b0b4934..2c3f9fbe3 100644
--- a/bsd/net.cc
+++ b/bsd/net.cc
@@ -10,6 +10,7 @@ extern "C" {
     #include <bsd/sys/sys/domain.h>
     #include <bsd/sys/net/netisr.h>
     #include <bsd/sys/net/if.h>
+    #include <bsd/sys/net/if_llatbl.h>
     #include <bsd/sys/net/pfil.h>
     #include <bsd/sys/netinet/igmp.h>
     #include <bsd/sys/netinet/if_ether.h>
@@ -37,6 +38,7 @@ void net_init(void)
     eventhandler_init(NULL);
     mbuf_init(NULL);
     netisr_init(NULL);
+    vnet_lltable_init();
     arp_init();
     ether_init(NULL);
     if_init(NULL);
diff --git a/bsd/porting/netport.h b/bsd/porting/netport.h
index 7021499a4..fef163a8c 100644
--- a/bsd/porting/netport.h
+++ b/bsd/porting/netport.h
@@ -63,6 +63,7 @@ int tvtohz(struct timeval *tv);
 #define hz (1000000000L)
 
 #define MALLOC_DEFINE(...)
+#define MALLOC_DECLARE(...)
 
 #define SYSINIT(...)
 #define SYSUNINIT(...)
diff --git a/bsd/sys/net/if_llatbl.c b/bsd/sys/net/if_llatbl.c
index 571ba8e1c..6cdcaa904 100644
--- a/bsd/sys/net/if_llatbl.c
+++ b/bsd/sys/net/if_llatbl.c
@@ -40,8 +40,12 @@
 #include <bsd/sys/net/route.h>
 #include <bsd/sys/net/vnet.h>
 #include <bsd/sys/netinet/if_ether.h>
-// #include <netinet6/in6_var.h>
-// #include <netinet6/nd6.h>
+#if 0
+#include <netinet6/in6_var.h>
+#include <netinet6/nd6.h>
+#endif
+
+MALLOC_DEFINE(M_LLTABLE, "lltable", "link level address tables");
 
 static VNET_DEFINE(SLIST_HEAD(, lltable), lltables);
 #define	V_lltables	VNET(lltables)
@@ -384,11 +388,8 @@ void vnet_lltable_init()
     rw_init(&lltable_rwlock, "lltable_rwlock");
 	SLIST_INIT(&V_lltables);
 }
-
-#if 0
 VNET_SYSINIT(vnet_lltable_init, SI_SUB_PSEUDO, SI_ORDER_FIRST,
     vnet_lltable_init, NULL);
-#endif
 
 #ifdef DDB
 struct llentry_sa {
diff --git a/bsd/sys/net/if_llatbl.h b/bsd/sys/net/if_llatbl.h
index 2c9d4d401..4c2bf1cd2 100644
--- a/bsd/sys/net/if_llatbl.h
+++ b/bsd/sys/net/if_llatbl.h
@@ -24,19 +24,18 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-
-#include <bsd/porting/netport.h>
-#include <bsd/porting/callout.h>
-#include <bsd/porting/rwlock.h>
-
 #include <sys/cdefs.h>
 
 #ifndef	_NET_IF_LLATBL_H_
 #define	_NET_IF_LLATBL_H_
 
+#include <bsd/porting/netport.h>
+#include <bsd/porting/callout.h>
+#include <bsd/porting/rwlock.h>
+
 #include <bsd/sys/netinet/in.h>
 
-void vnet_lltable_init();
+void vnet_lltable_init(void);
 
 struct ifnet;
 struct sysctl_req;
@@ -166,6 +165,7 @@ struct lltable {
 	int			(*llt_dump)(struct lltable *,
 				    struct sysctl_req *);
 };
+MALLOC_DECLARE(M_LLTABLE);
 
 /*
  * flags to be passed to arplookup.
-- 
GitLab