Add -hostprefix in DHCP daemon to run the daemon as container
This diff adds -hostprefix option in dhcp daemon. This option could be used to run dhcp daemon as container because container cannot touch host's netns directly. The diff changes dhcp daemon to touch procfs mounted to another path, like '/hostfs/proc'.
This commit is contained in:
@ -33,11 +33,13 @@ const socketPath = "/run/cni/dhcp.sock"
|
||||
func main() {
|
||||
if len(os.Args) > 1 && os.Args[1] == "daemon" {
|
||||
var pidfilePath string
|
||||
var hostPrefix string
|
||||
daemonFlags := flag.NewFlagSet("daemon", flag.ExitOnError)
|
||||
daemonFlags.StringVar(&pidfilePath, "pidfile", "", "optional path to write daemon PID to")
|
||||
daemonFlags.StringVar(&hostPrefix, "hostprefix", "", "optional prefix to netns")
|
||||
daemonFlags.Parse(os.Args[2:])
|
||||
|
||||
if err := runDaemon(pidfilePath); err != nil {
|
||||
if err := runDaemon(pidfilePath, hostPrefix); err != nil {
|
||||
log.Printf(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
Reference in New Issue
Block a user