Merge pull request #268 from s1061123/fix/dhcp_daemon_hostprefix
Fix -hostprefix option
This commit is contained in:
commit
fbd9accd14
@ -18,7 +18,7 @@ $ ./dhcp daemon
|
|||||||
|
|
||||||
If given `-pidfile <path>` arguments after 'daemon', the dhcp plugin will write
|
If given `-pidfile <path>` arguments after 'daemon', the dhcp plugin will write
|
||||||
its PID to the given file.
|
its PID to the given file.
|
||||||
If given `-hostprefix <prefix>` arguments after 'daemon', the dhcp plugin will use this prefix for netns as `<prefix>/<original netns>`. It could be used in case of running dhcp daemon as container.
|
If given `-hostprefix <prefix>` arguments after 'daemon', the dhcp plugin will use this prefix for DHCP socket as `<prefix>/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.
|
Alternatively, you can use systemd socket activation protocol.
|
||||||
Be sure that the .socket file uses /run/cni/dhcp.sock as the socket path.
|
Be sure that the .socket file uses /run/cni/dhcp.sock as the socket path.
|
||||||
|
@ -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 {
|
if err != nil {
|
||||||
return fmt.Errorf("Error getting listener: %v", err)
|
return fmt.Errorf("Error getting listener: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func main() {
|
|||||||
var socketPath string
|
var socketPath string
|
||||||
daemonFlags := flag.NewFlagSet("daemon", flag.ExitOnError)
|
daemonFlags := flag.NewFlagSet("daemon", flag.ExitOnError)
|
||||||
daemonFlags.StringVar(&pidfilePath, "pidfile", "", "optional path to write daemon PID to")
|
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.StringVar(&socketPath, "socketpath", "", "optional dhcp server socketpath")
|
||||||
daemonFlags.Parse(os.Args[2:])
|
daemonFlags.Parse(os.Args[2:])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user