Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

f-93: DHCP4v2 onelease plugin code for VRouter #139

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dffed0b
f-93: DHCP4v2 onelease plugin code for VRouter
aleixrm Nov 20, 2024
74debb6
f-93: Corrects plugin return variables
aleixrm Nov 20, 2024
39abbfc
f-93: Wraps server creation for each interface
aleixrm Nov 21, 2024
5afcd98
F93: Alpine 3.19 and compile dhcp server
jaimecb Nov 21, 2024
a1b7ca5
f-93: Implements config steps and tests
aleixrm Nov 22, 2024
4aa3eee
F93: Update install function and add iptables
jaimecb Nov 22, 2024
0c6b9e0
f-93: corrects config file name
aleixrm Nov 25, 2024
10e1f7e
f-93: creates constants for service and config dirs
aleixrm Nov 25, 2024
a7f8207
f-93: Excludes old VNF dhcp4 from the VRouter package
aleixrm Nov 26, 2024
92f34d6
f-93: corrects VRouter dhcp4v2 reference in failover
aleixrm Nov 26, 2024
1e8ec97
f-93: Adds custom leases plugin with excluded ips
aleixrm Nov 26, 2024
a1de3d1
F-93: custom mac prefix support
jaimecb Nov 26, 2024
259cfb5
f-93: Corrects tests
aleixrm Nov 26, 2024
6cf6ccc
f-93: Merges onelease behavior in onerange
aleixrm Nov 26, 2024
b598a84
f-93: Corrects test and config file generation
aleixrm Nov 27, 2024
eb37b6f
F-93: onerange plugin to onelease
jaimecb Nov 27, 2024
dd4822f
f-93: Corrects naming from dhcpcore to coredhcp
aleixrm Nov 27, 2024
ab3940b
f-93: Changes plugin name from range to onelease
aleixrm Nov 27, 2024
4f74bcf
F-93: add coredhcp-onelease tests
jaimecb Nov 28, 2024
367f499
f-93: fix check excluded IP is in range
aleixrm Nov 29, 2024
5bff324
F-93: Packer script rm source code and go test case
jaimecb Nov 29, 2024
f50daba
F-93: Fix log output and improve test coverage
jaimecb Dec 2, 2024
b8e4137
f-93: Fixes returned response when error
aleixrm Dec 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
F-93: Fix log output and improve test coverage
Signed-off-by: Jaime <jconchello@opennebula.io>
jaimecb committed Dec 2, 2024
commit f50dabac34e35fd58813b4c3d36b20ef20b419d8
Original file line number Diff line number Diff line change
@@ -83,7 +83,7 @@ func (p *PluginState) Handler4(req, resp *dhcpv4.DHCPv4) (*dhcpv4.DHCPv4, bool)
macPrefixMatches = true
//propose the least 4 bytes of the mac address for allocating an IP address
ipToAllocate = net.IPNet{IP: ipFromMAC}
log.Infof("MAC %s matches the prefix %x, trying to allocate IP %s...", macAddress.String(), p.MACPrefix, ipToAllocate.IP.String())
log.Infof("MAC %s matches the prefix %02x:%02x, trying to allocate IP %s...", macAddress.String(), p.MACPrefix[0], p.MACPrefix[1], ipToAllocate.IP.String())
} else {
log.Infof("MAC %s does not match the prefix %x, providing conventional lease...", macAddress.String(), p.MACPrefix)
}
@@ -98,7 +98,7 @@ func (p *PluginState) Handler4(req, resp *dhcpv4.DHCPv4) (*dhcpv4.DHCPv4, bool)
// if the MAC address is mapped to an IP address, check if the allocated IP address matches the requested one, if not, revert the allocation and return
if p.enableMAC2IP && macPrefixMatches && !ip.IP.Equal(ipToAllocate.IP) {
p.allocator.Free(ip)
log.Errorf("MAC2IP: Could not allocate IP %s for MAC %s: IP already allocated", req.ClientHWAddr.String(), err)
log.Errorf("MAC2IP: Could not allocate IP %s for MAC \"%s\": IP already allocated", ipToAllocate.IP.String(), req.ClientHWAddr.String())
return resp, true
}

@@ -127,7 +127,7 @@ func (p *PluginState) Handler4(req, resp *dhcpv4.DHCPv4) (*dhcpv4.DHCPv4, bool)
}
resp.YourIPAddr = record.IP
resp.Options.Update(dhcpv4.OptIPAddressLeaseTime(p.LeaseTime.Round(time.Second)))
log.Printf("found IP address %s for MAC %s", record.IP, req.ClientHWAddr.String())
log.Printf("Found IP address %s for MAC %s", record.IP, req.ClientHWAddr.String())
return resp, true
}

Original file line number Diff line number Diff line change
@@ -364,7 +364,7 @@ func TestSetupRange(t *testing.T) {
expectHandlerError: false,
},
{
name: "Try to out of range IP (192.168.1.255) with MAC2IP",
name: "Try to get out of range IP (192.168.1.255) with MAC2IP",
args: []string{
"test_leases.db", // filename
"192.168.1.1", // start IP
@@ -392,6 +392,20 @@ func TestSetupRange(t *testing.T) {
expectSetUpError: false,
expectHandlerError: false,
},
{
name: "Try to get IP with all IPs leased and no MAC2IP",
args: []string{
"test_leases.db", // filename
"192.168.1.1", // start IP
"192.168.1.7", // end IP
"60s", // lease time
"--excluded-ips", "192.168.1.3,192.168.1.4", // excluded IPs
},
expectedLeaseTime: 60 * time.Second,
reqMACAddr: net.HardwareAddr{0x53, 0x21, 0xc0, 0xa8, 0x01, 0x64},
expectSetUpError: false,
expectHandlerError: true,
},
{
name: "Invalid Number of Arguments",
args: []string{
@@ -423,6 +437,17 @@ func TestSetupRange(t *testing.T) {
expectSetUpError: true,
expectHandlerError: false,
},
{
name: "Not compatible IP range with previously defined",
args: []string{
"test_leases.db", // filename
"0.0.0.0", // invalid start IP
"0.0.0.1", // end IP
"1h", // lease time
},
expectSetUpError: true,
expectHandlerError: false,
},
{
name: "Invalid Lease Time",
args: []string{