From 32d81996ccf670c924f46e1b0b3e9873177f0d1f Mon Sep 17 00:00:00 2001
From: Guy Zana <guy@cloudius-systems.com>
Date: Mon, 18 Mar 2013 23:32:19 +0200
Subject: [PATCH] net: verify UDP related port in in_pcb.c and in.c

---
 bsd/sys/netinet/in.c     | 6 ++++--
 bsd/sys/netinet/in_pcb.c | 8 +++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/bsd/sys/netinet/in.c b/bsd/sys/netinet/in.c
index 580b63f8c..7d6105b2e 100644
--- a/bsd/sys/netinet/in.c
+++ b/bsd/sys/netinet/in.c
@@ -54,6 +54,9 @@
 #include <bsd/sys/netinet/ip_var.h>
 #include <bsd/sys/netinet/igmp_var.h>
 
+#include <bsd/sys/netinet/udp.h>
+#include <bsd/sys/netinet/udp_var.h>
+
 static int in_mask2len(struct in_addr *);
 static void in_len2mask(struct in_addr *, int);
 static int in_lifaddr_ioctl(struct socket *, u_long, caddr_t,
@@ -1246,8 +1249,7 @@ in_ifdetach(struct ifnet *ifp)
 {
 
 	in_pcbpurgeif0(&V_ripcbinfo, ifp);
-	/* FIXME: OSv - un-comment when UDP is enabled */
-	// in_pcbpurgeif0(&V_udbinfo, ifp);
+	in_pcbpurgeif0(&V_udbinfo, ifp);
 	in_purgemaddrs(ifp);
 }
 
diff --git a/bsd/sys/netinet/in_pcb.c b/bsd/sys/netinet/in_pcb.c
index 61c60dbd7..4fdc605b9 100644
--- a/bsd/sys/netinet/in_pcb.c
+++ b/bsd/sys/netinet/in_pcb.c
@@ -63,10 +63,10 @@
 #include <bsd/sys/netinet/ip_var.h>
 #if 0
 #include <bsd/sys/netinet/tcp_var.h>
+#endif
 #include <bsd/sys/netinet/udp.h>
 #include <bsd/sys/netinet/udp_var.h>
 #endif
-#endif
 #ifdef INET
 #include <bsd/sys/netinet/in_var.h>
 #endif
@@ -390,12 +390,10 @@ in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp, u_short *lportp,
 	if (first == last)
 		dorandom = 0;
 
-	/* FIXME: OSv - undef when UDP is enabled */
-#if 0
 	/* Make sure to not include UDP packets in the count. */
 	if (pcbinfo != &V_udbinfo)
 		V_ipport_tcpallocs++;
-#endif
+
 	/*
 	 * Instead of having two loops further down counting up or down
 	 * make sure that first is always <= last and go with only one
@@ -574,7 +572,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
 				 * being in use (for now).  This is better
 				 * than a panic, but not desirable.
 				 */
-/* FIXME: OSv: undef when we have TCP/UDP */
+/* FIXME: OSv: undef when we have TCP */
 #if 0
 				tw = intotw(t);
 				if (tw == NULL ||
-- 
GitLab