dhcp ipam: fix client id

First byte of client ID is type, instead of value. See this from
RFC2132:

   Code   Len   Type  Client-Identifier
   +-----+-----+-----+-----+-----+---
   |  61 |  n  |  t1 |  i1 |  i2 | ...
   +-----+-----+-----+-----+-----+---

Signed-off-by: SilverBut <SilverBut@users.noreply.github.com>
This commit is contained in:
SilverBut 2021-10-03 05:56:31 +08:00
parent a1051f3bf1
commit 27fdec5cb9

View File

@ -218,6 +218,10 @@ func (l *DHCPLease) acquire() error {
for k, v := range l.optsProviding { for k, v := range l.optsProviding {
opts[k] = v opts[k] = v
} }
// client identifier's first byte is "type"
newClientID := []byte{0}
newClientID = append(newClientID, opts[dhcp4.OptionClientIdentifier]...)
opts[dhcp4.OptionClientIdentifier] = newClientID
pkt, err := backoffRetry(l.resendMax, func() (*dhcp4.Packet, error) { pkt, err := backoffRetry(l.resendMax, func() (*dhcp4.Packet, error) {
ok, ack, err := DhcpRequest(c, opts) ok, ack, err := DhcpRequest(c, opts)