PERFORCE change 113551 for review

Marko Zec zec at FreeBSD.org
Fri Jan 26 12:01:19 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=113551

Change 113551 by zec at zec_tca51 on 2007/01/26 12:00:29

	Let gif(4) compile with options VIMAGE.

Affected files ...

.. //depot/projects/vimage/src/sys/netinet/in_gif.c#2 edit
.. //depot/projects/vimage/src/sys/netinet/vinet.h#9 edit
.. //depot/projects/vimage/src/sys/netinet6/in6_gif.c#3 edit

Differences ...

==== //depot/projects/vimage/src/sys/netinet/in_gif.c#2 (text+ko) ====

@@ -33,6 +33,7 @@
 #include "opt_mrouting.h"
 #include "opt_inet.h"
 #include "opt_inet6.h"
+#include "opt_vimage.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -43,12 +44,13 @@
 #include <sys/kernel.h>
 #include <sys/sysctl.h>
 #include <sys/protosw.h>
-
 #include <sys/malloc.h>
+#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
 
+#include <netinet/vinet.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
@@ -70,6 +72,7 @@
 
 static int gif_validate4(const struct ip *, struct gif_softc *,
 	struct ifnet *);
+static void in_gif_init(void);
 
 extern  struct domain inetdomain;
 struct protosw in_gif_protosw = {
@@ -80,12 +83,23 @@
 	.pr_input =		in_gif_input,
 	.pr_output =		(pr_output_t*)rip_output,
 	.pr_ctloutput =		rip_ctloutput,
+	.pr_init =		in_gif_init,
 	.pr_usrreqs =		&rip_usrreqs
 };
 
-static int ip_gif_ttl = GIF_TTL;
-SYSCTL_INT(_net_inet_ip, IPCTL_GIF_TTL, gifttl, CTLFLAG_RW,
-	&ip_gif_ttl,	0, "");
+#ifndef VIMAGE
+static int ip_gif_ttl;
+#endif
+SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, IPCTL_GIF_TTL, gifttl,
+	CTLFLAG_RW, ip_gif_ttl,	0, "");
+
+static void
+in_gif_init(void)
+{
+	INIT_VNET_INET(curvnetb);
+
+	V_ip_gif_ttl = GIF_TTL;
+}
 
 int
 in_gif_output(ifp, family, m)
@@ -93,6 +107,7 @@
 	int		family;
 	struct mbuf	*m;
 {
+	INIT_VNET_INET(ifp->if_vnetb);
 	struct gif_softc *sc = ifp->if_softc;
 	struct sockaddr_in *dst = (struct sockaddr_in *)&sc->gif_ro.ro_dst;
 	struct sockaddr_in *sin_src = (struct sockaddr_in *)sc->gif_psrc;
@@ -177,7 +192,7 @@
 	}
 	iphdr.ip_p = proto;
 	/* version will be set in ip_output() */
-	iphdr.ip_ttl = ip_gif_ttl;
+	iphdr.ip_ttl = V_ip_gif_ttl;
 	iphdr.ip_len = m->m_pkthdr.len + sizeof(struct ip);
 	ip_ecn_ingress((ifp->if_flags & IFF_LINK1) ? ECN_ALLOWED : ECN_NOCARE,
 		       &iphdr.ip_tos, &tos);
@@ -242,6 +257,7 @@
 	struct mbuf *m;
 	int off;
 {
+	INIT_VNET_INET(curvnetb);
 	struct ifnet *gifp = NULL;
 	struct gif_softc *sc;
 	struct ip *ip;
@@ -255,14 +271,14 @@
 	sc = (struct gif_softc *)encap_getarg(m);
 	if (sc == NULL) {
 		m_freem(m);
-		ipstat.ips_nogif++;
+		V_ipstat.ips_nogif++;
 		return;
 	}
 
 	gifp = GIF2IFP(sc);
 	if (gifp == NULL || (gifp->if_flags & IFF_UP) == 0) {
 		m_freem(m);
-		ipstat.ips_nogif++;
+		V_ipstat.ips_nogif++;
 		return;
 	}
 
@@ -322,7 +338,7 @@
  		break;	
 
 	default:
-		ipstat.ips_nogif++;
+		V_ipstat.ips_nogif++;
 		m_freem(m);
 		return;
 	}
@@ -339,6 +355,7 @@
 	struct gif_softc *sc;
 	struct ifnet *ifp;
 {
+	INIT_VNET_INET(curvnetb);
 	struct sockaddr_in *src, *dst;
 	struct in_ifaddr *ia4;
 
@@ -358,7 +375,7 @@
 		return 0;
 	}
 	/* reject packets with broadcast on source */
-	TAILQ_FOREACH(ia4, &in_ifaddrhead, ia_link) {
+	TAILQ_FOREACH(ia4, &V_in_ifaddrhead, ia_link) {
 		if ((ia4->ia_ifa.ifa_ifp->if_flags & IFF_BROADCAST) == 0)
 			continue;
 		if (ip->ip_src.s_addr == ia4->ia_broadaddr.sin_addr.s_addr)

==== //depot/projects/vimage/src/sys/netinet/vinet.h#9 (text+ko) ====

@@ -104,6 +104,8 @@
 
 	int	_rtq_timeout;
 	struct	callout _rtq_timer;
+
+	int	_ip_gif_ttl;
 };
 
 extern struct vnet_inet vnet_inet_0;
@@ -167,4 +169,6 @@
 #define V_rtq_timeout		VNET_INET(rtq_timeout)
 #define V_rtq_timer		VNET_INET(rtq_timer)
 
+#define V_ip_gif_ttl		VNET_INET(ip_gif_ttl)
+
 #endif /* !_NETINET_VINET_H_ */

==== //depot/projects/vimage/src/sys/netinet6/in6_gif.c#3 (text+ko) ====

@@ -32,6 +32,7 @@
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
+#include "opt_vimage.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -42,8 +43,8 @@
 #include <sys/queue.h>
 #include <sys/syslog.h>
 #include <sys/protosw.h>
-
 #include <sys/malloc.h>
+#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
@@ -55,6 +56,7 @@
 #endif
 #include <netinet/ip_encap.h>
 #ifdef INET6
+#include <netinet6/vinet6.h>
 #include <netinet/ip6.h>
 #include <netinet6/ip6_var.h>
 #include <netinet6/in6_gif.h>
@@ -247,6 +249,7 @@
 	struct mbuf **mp;
 	int *offp, proto;
 {
+	INIT_VNET_INET6(curvnetb);
 	struct mbuf *m = *mp;
 	struct ifnet *gifp = NULL;
 	struct gif_softc *sc;
@@ -259,14 +262,14 @@
 	sc = (struct gif_softc *)encap_getarg(m);
 	if (sc == NULL) {
 		m_freem(m);
-		ip6stat.ip6s_nogif++;
+		V_ip6stat.ip6s_nogif++;
 		return IPPROTO_DONE;
 	}
 
 	gifp = GIF2IFP(sc);
 	if (gifp == NULL || (gifp->if_flags & IFF_UP) == 0) {
 		m_freem(m);
-		ip6stat.ip6s_nogif++;
+		V_ip6stat.ip6s_nogif++;
 		return IPPROTO_DONE;
 	}
 
@@ -321,7 +324,7 @@
  		break;	
 
 	default:
-		ip6stat.ip6s_nogif++;
+		V_ip6stat.ip6s_nogif++;
 		m_freem(m);
 		return IPPROTO_DONE;
 	}


More information about the p4-projects mailing list