From 4ec62ac295fdf64de6938f58bbf264380be2fc58 Mon Sep 17 00:00:00 2001 From: Tomofumi Hayashi Date: Fri, 22 Feb 2019 17:13:36 +0900 Subject: [PATCH 1/2] Fix -hostprefix option Fix #267 --- plugins/ipam/dhcp/README.md | 2 +- plugins/ipam/dhcp/daemon.go | 2 +- plugins/ipam/dhcp/main.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/ipam/dhcp/README.md b/plugins/ipam/dhcp/README.md index 0ec4c4cb..eff852ac 100644 --- a/plugins/ipam/dhcp/README.md +++ b/plugins/ipam/dhcp/README.md @@ -18,7 +18,7 @@ $ ./dhcp daemon If given `-pidfile ` arguments after 'daemon', the dhcp plugin will write its PID to the given file. -If given `-hostprefix ` arguments after 'daemon', the dhcp plugin will use this prefix for netns as `/`. It could be used in case of running dhcp daemon as container. +If given `-hostprefix ` arguments after 'daemon', the dhcp plugin will use this prefix for DHCP socket as `/run/cni/dhcp.sock`. It could be used in case of running dhcp daemon as container. Alternatively, you can use systemd socket activation protocol. Be sure that the .socket file uses /run/cni/dhcp.sock as the socket path. diff --git a/plugins/ipam/dhcp/daemon.go b/plugins/ipam/dhcp/daemon.go index 4d1c1a6f..aeb87aaa 100644 --- a/plugins/ipam/dhcp/daemon.go +++ b/plugins/ipam/dhcp/daemon.go @@ -172,7 +172,7 @@ func runDaemon(pidfilePath string, hostPrefix string, socketPath string) error { } } - l, err := getListener(socketPath) + l, err := getListener(hostPrefix + socketPath) if err != nil { return fmt.Errorf("Error getting listener: %v", err) } diff --git a/plugins/ipam/dhcp/main.go b/plugins/ipam/dhcp/main.go index 70768b43..3222316c 100644 --- a/plugins/ipam/dhcp/main.go +++ b/plugins/ipam/dhcp/main.go @@ -38,7 +38,7 @@ func main() { var socketPath 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.StringVar(&hostPrefix, "hostprefix", "", "optional prefix to host root") daemonFlags.StringVar(&socketPath, "socketpath", "", "optional dhcp server socketpath") daemonFlags.Parse(os.Args[2:]) From 8b53f80fa8de96b500beeafcc23f419be6c03b46 Mon Sep 17 00:00:00 2001 From: Tomofumi Hayashi Date: Fri, 5 Apr 2019 03:38:20 +0900 Subject: [PATCH 2/2] Incorporate with @bboreham comment --- plugins/ipam/dhcp/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ipam/dhcp/README.md b/plugins/ipam/dhcp/README.md index eff852ac..8b46180f 100644 --- a/plugins/ipam/dhcp/README.md +++ b/plugins/ipam/dhcp/README.md @@ -18,7 +18,7 @@ $ ./dhcp daemon If given `-pidfile ` arguments after 'daemon', the dhcp plugin will write its PID to the given file. -If given `-hostprefix ` arguments after 'daemon', the dhcp plugin will use this prefix for DHCP socket as `/run/cni/dhcp.sock`. It could be used in case of running dhcp daemon as container. +If given `-hostprefix ` arguments after 'daemon', the dhcp plugin will use this prefix for DHCP socket as `/run/cni/dhcp.sock`. You can use this prefix for references to the host filesystem, e.g. to access netns and the unix socket. Alternatively, you can use systemd socket activation protocol. Be sure that the .socket file uses /run/cni/dhcp.sock as the socket path.