nanovms / nanos

A kernel designed to run one and only one application in a virtualized environment
https://nanos.org
Apache License 2.0
2.64k stars 137 forks source link

Network: add support for starting program after IPv6 initialization #1953

Closed francescolavra closed 1 year ago

francescolavra commented 1 year ago

This change implements a new kernel configuration option "exec_wait_for_ip6_secs", which instructs the kernel to wait for an IPv6 address to be acquired before starting the user program; the value of this option indicates a timeout, expressed in seconds, after which the kernel starts the program even without an IPv6 address. IPv6 address acquisition is considered complete when one of the IPv6 addresses associated to a network interface is a global address in a valid state. Both dynamic address acquisition via DHCPv6 and static configuration via the "ip6addr" option lead the network interface to reach a state which allows the kernel to start the user program. In addition, this change allows both the "exec_wait_for_ip6_secs" option and the already existing "exec_wait_for_ip4_secs" option to be associated to a specific network interface; this is useful in instances with multiple network interfaces where the user program has to be started following address assignment to an interface different from the default interface. Example Ops configuration to wait for both IPv4 and IPv6 addresses (with a 10-second timeout) on the default network interface:

  "ManifestPassthrough": {
    "exec_wait_for_ip4_secs": "10",
    "exec_wait_for_ip6_secs": "10"
  }

Example Ops configuration to wait for an IPv6 addresses (with a 5-second timeout) on the second network interface:

  "ManifestPassthrough": {
    "en2": {
      "exec_wait_for_ip6_secs": "5"
    }
  }