Enable raw sockets using VNET, and allow connections to 127.0.0.1.
authorDaniel Hokka Zakrisson <dhokka@cs.princeton.edu>
Wed, 13 Feb 2008 13:17:36 +0000 (13:17 +0000)
committerDaniel Hokka Zakrisson <dhokka@cs.princeton.edu>
Wed, 13 Feb 2008 13:17:36 +0000 (13:17 +0000)
src/planetlab.c

index 9300744..9a3e571 100644 (file)
@@ -48,11 +48,22 @@ POSSIBILITY OF SUCH DAMAGE.
 #include "vserver.h"
 #include "planetlab.h"
 
+#ifndef VC_NXC_RAW_SOCKET
+#  define VC_NXC_RAW_SOCKET    0x00000200ull
+#endif
+#ifndef VC_NXC_RAW_SEND
+#  define VC_NXC_RAW_SEND      0x00000400ull
+#endif
+#ifndef VC_NXF_LBACK_ALLOW
+#  define VC_NXF_LBACK_ALLOW   0x00000400ull
+#endif
+
 static int
 create_context(xid_t ctx, uint64_t bcaps)
 {
-  struct vc_ctx_caps  vc_caps;
+  struct vc_ctx_caps   vc_caps;
   struct vc_net_flags  vc_nf;
+  struct vc_net_caps   vc_ncaps;
 
   /* Create network context */
   if (vc_net_create(ctx) == VC_NOCTX) {
@@ -62,10 +73,15 @@ create_context(xid_t ctx, uint64_t bcaps)
   }
 
   /* Make the network context persistent */
-  vc_nf.mask = vc_nf.flagword = VC_NXF_PERSISTENT;
+  vc_nf.mask = vc_nf.flagword = VC_NXF_PERSISTENT | VC_NXF_LBACK_ALLOW;
   if (vc_set_nflags(ctx, &vc_nf))
     return -1;
 
+  /* Give it raw sockets capabilities */
+  vc_ncaps.ncaps = vc_ncaps.cmask = VC_NXC_RAW_ICMP | VC_NXC_RAW_SOCKET;
+  if (vc_set_ncaps(ctx, &vc_ncaps))
+    return -1;
+
 tag:
   /* Create tag context */
   if (vc_tag_create(ctx) == VC_NOCTX)