diff options
| author | Johnathan Mantey <johnathanx.mantey@intel.com> | 2019-12-17 09:18:34 -0800 |
|---|---|---|
| committer | Vernon Mauery <vernon.mauery@linux.intel.com> | 2020-01-31 15:56:38 +0000 |
| commit | 930104a86aa997ba91bd6d588eb3abda39c2fa52 (patch) | |
| tree | 5a5ac20bdfafe2cd467e3fed8ba8d43b4293f64d | |
| parent | 4e1fe77dfde1291b48d4109f3bb89077809d24a2 (diff) | |
| download | phosphor-host-ipmid-930104a86aa997ba91bd6d588eb3abda39c2fa52.tar.gz phosphor-host-ipmid-930104a86aa997ba91bd6d588eb3abda39c2fa52.zip | |
Return an error when assigning static values to a DHCP enabled NIC
Assigning static IP addresses, subnet masks, and gateway values to a
DHCP enabled NIC should be flagged with an error response to indicate
the operation was not completed successfully.
Tested:
Used some raw commands to witness the return code directly
-- Enable DHCP for NIC 3
ipmitool lan set 3 ipsrc dhcp
-- Assign a static IPv4 Address, expect a failure
ipmitool raw 0xc 1 3 3 192 168 20 12 # returns 0xd5 error message
-- Assign a static IPv4 Subnet mask, expect a failure
ipmitool raw 0xc 1 3 6 255 255 255 0 # returns 0xd5 error message
-- Assign a static IPv4 Gateway, expect a failure
ipmitool raw 0xc 1 3 12 192 168 20 1 # returns 0xd5 error message
-- Enable Static address assignment for NIC 3
ipmitool lan set 3 ipsrc static
-- Assign a static IPv4 Address, expect success
ipmitool raw 0xc 1 3 3 192 168 20 12 # returns successfully
-- Assign a static IPv4 Subnet mask, expect success
ipmitool raw 0xc 1 3 6 255 255 255 0 # returns successfully
-- Assign a static IPv4 Gateway, expect success
ipmitool raw 0xc 1 3 12 192 168 20 1 # returns successfully
IPv4 settings have been updated.
Change-Id: I807ec45a0c86b33dd46bfeb64724b91d5afad408
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
| -rw-r--r-- | transporthandler.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/transporthandler.cpp b/transporthandler.cpp index e112668..a3b3c35 100644 --- a/transporthandler.cpp +++ b/transporthandler.cpp @@ -1401,6 +1401,10 @@ RspType<> setLan(uint4_t channelBits, uint4_t, uint8_t parameter, } case LanParam::IP: { + if (channelCall<getDHCPProperty>(channel)) + { + return responseCommandNotAvailable(); + } in_addr ip; std::array<uint8_t, sizeof(ip)> bytes; if (req.unpack(bytes) != 0 || !req.fullyUnpacked()) @@ -1460,6 +1464,10 @@ RspType<> setLan(uint4_t channelBits, uint4_t, uint8_t parameter, } case LanParam::SubnetMask: { + if (channelCall<getDHCPProperty>(channel)) + { + return responseCommandNotAvailable(); + } in_addr netmask; std::array<uint8_t, sizeof(netmask)> bytes; if (req.unpack(bytes) != 0 || !req.fullyUnpacked()) @@ -1473,6 +1481,10 @@ RspType<> setLan(uint4_t channelBits, uint4_t, uint8_t parameter, } case LanParam::Gateway1: { + if (channelCall<getDHCPProperty>(channel)) + { + return responseCommandNotAvailable(); + } in_addr gateway; std::array<uint8_t, sizeof(gateway)> bytes; if (req.unpack(bytes) != 0 || !req.fullyUnpacked()) |

