dhcp ipam: truncate client id to 254 bytes
Signed-off-by: SilverBut <SilverBut@users.noreply.github.com>
This commit is contained in:
parent
6d1f71e55a
commit
be383cf30d
@ -33,8 +33,6 @@ import (
|
|||||||
"github.com/coreos/go-systemd/v22/activation"
|
"github.com/coreos/go-systemd/v22/activation"
|
||||||
)
|
)
|
||||||
|
|
||||||
const listenFdsStart = 3
|
|
||||||
|
|
||||||
var errNoMoreTries = errors.New("no more tries")
|
var errNoMoreTries = errors.New("no more tries")
|
||||||
|
|
||||||
type DHCP struct {
|
type DHCP struct {
|
||||||
@ -54,8 +52,15 @@ func newDHCP(clientTimeout, clientResendMax time.Duration) *DHCP {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: current client ID is too long. At least the container ID should not be used directly.
|
||||||
|
// A seperate issue is necessary to ensure no breaking change is affecting other users.
|
||||||
func generateClientID(containerID string, netName string, ifName string) string {
|
func generateClientID(containerID string, netName string, ifName string) string {
|
||||||
return containerID + "/" + netName + "/" + ifName
|
clientID := containerID + "/" + netName + "/" + ifName
|
||||||
|
// defined in RFC 2132, length size can not be larger than 1 octet. So we truncate 254 to make everyone happy.
|
||||||
|
if len(clientID) > 254 {
|
||||||
|
clientID = clientID[0:254]
|
||||||
|
}
|
||||||
|
return clientID
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate acquires an IP from a DHCP server for a specified container.
|
// Allocate acquires an IP from a DHCP server for a specified container.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user