Giter Site home page Giter Site logo

softnet's Introduction

Softnet

Softnet is a software networking for Tart which provides better network isolation and alleviates DHCP shortage on production systems. Please check out this blog post for backstory.

Working model

Softnet solves two problems:

  1. VM network isolation
  1. DHCP exhaustion
  • macOS built-in DHCP-server allocates a /24 subnet with 86400 seconds lease time by default, which only allows for ~253 VMs a day (or 1 VM every ~6 minutes) to be spawned without causing a denial-of-service, which is pretty limiting for CI services like Cirrus CI

And assumes that:

  1. Tart gives it's VMs unique MAC-addresses
  2. macOS built-in DHCP-server won't re-use the IP-addresses from it's pool until their lease expire

...otherwise it's possible for two VMs to receive an identical IP-address from the macOS built-in DHCP-server (even in the presence of Softnet's packet filtering) and thus bypass the protections offered by Softnet.

Installing

For proper functioning, Softnet binary requires two things:

  • a SUID-bit to be set on the binary or a passwordless sudo to be configured, which effectively gives the binary root privileges
    • these privileges are needed to create vmnet.framework interface and perform DHCP-related system tweaks
    • the privileges will be dropped automatically to that of the calling user (or those represented by the --user and --group command-line arguments) once all of the initialization is completed
  • the binary to be available in PATH
    • so that the Tart will be able to find it

Running

Softnet is started and managed automatically by Tart if --net-softnet flag is provided when calling tart run.

softnet's People

Contributors

dependabot[bot] avatar edigaryev avatar fkorotkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

softnet's Issues

Network provisioning delay when creating 2 VMs simultaneously with softnet

This bug appears on both an AWS MacOS instance as well as my Macbook Pro.

I have a cloned image called testing. The name or MacOS image version are not relevant

Reproduce

I have a script that:

  • creates a new clone of the testing image
  • runs the image with softnet and puts it to the background
  • tries to SSH to the VM to run a command
  • keeps the VM around for 20s
  • deletes the VM

vm_start.sh:

#!/bin/bash

IMAGE_NAME=testing

tart clone $IMAGE_NAME $1
tart run $1 --no-graphics --net-softnet &
killpid=$!
sshpass -padmin ssh -o ConnectTimeout=3600 -o StrictHostKeyChecking=no admin@$(tart ip $1 --wait 300) echo "$1 is done"
sleep 20
kill $killpid
wait $killpid 2>/dev/null
tart delete $1
  • ./vm_start.sh a: works fine, as only bringing up one VM
  • ./vm_start.sh a &; sleep 5; ./vm_start.sh b;: works fine, because although I'm bringing up 2 VMs, I'm stagging the creation with a sleep
  • ./vm_start.sh a &; ./vm_start.sh b: one VM is successful, but the other one typically fails because the SSH command times out.

Expected behaviour would be seeing the output a is done and b is done each time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.