summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRajashekar Gade Reddy <raja.sekhar.reddy.gade@linux.intel.com>2019-12-24 16:37:15 +0530
committerVernon Mauery <vernon.mauery@linux.intel.com>2020-01-07 19:16:21 +0000
commit0b993fd4508b06ff9427ccd947d7813965155925 (patch)
treef6e001a23964cd3be77944fc3a4b02e4e22eee5a
parentebc53cb165ea26aa48f0bbf01d9bce0e4abb0b7d (diff)
downloadphosphor-host-ipmid-0b993fd4508b06ff9427ccd947d7813965155925.tar.gz
phosphor-host-ipmid-0b993fd4508b06ff9427ccd947d7813965155925.zip
Fix cc issue in setLan cmd for MAC addr parametr.
Issue: set lan command for MAC address parameter returns invalid completion code for invalid MAC address. Fix: added proper conditional check. Tested: Note: While setting the mac addr using "ipmitool lan set 1 macaddr <mac_addr>" internaly tool valiadtes the completion code and shows generic error. Previouly the completion code is 0XFF(unspecified error) and now it returns 0xCC(Invalid data field in request). // setting mac addr to 00:00:00:00:00:00(invalid) ipmitool lan set 1 macaddr "00:00:00:00:00:00" Setting LAN MAC Address to 00:00:00:00:00:00 LAN Parameter Data does not match! Write may have failed. // setting mac addr to FF:FF:FF:FF:FF:FF(invalid) ipmitool lan set 1 macaddr "FF:FF:FF:FF:FF:FF" Setting LAN MAC Address to ff:ff:ff:ff:ff:ff LAN Parameter Data does not match! Write may have failed. // setting mac addr to "2a:6c:72:42:f3:a4"(valid) ipmitool lan set 1 macaddr "2a:6c:72:42:f3:a4" Setting LAN MAC Address to 2a:6c:72:42:f3:a4 Signed-off-by: Rajashekar Gade Reddy <raja.sekhar.reddy.gade@linux.intel.com> Change-Id: I4de54e68a7bb5ff2c64f515e40d06c59535825e5
-rw-r--r--transporthandler.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/transporthandler.cpp b/transporthandler.cpp
index c8dccb3..d7eef14 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -1313,6 +1313,30 @@ RspType<message::Payload> getLanOem(uint8_t channel, uint8_t parameter,
{
return response(ccParamNotSupported);
}
+/**
+ * @brief is MAC address valid.
+ *
+ * This function checks whether the MAC address is valid or not.
+ *
+ * @param[in] mac - MAC address.
+ * @return true if MAC address is valid else retun false.
+ **/
+bool isValidMACAddress(const ether_addr& mac)
+{
+ // check if mac address is empty
+ if (equal(mac, ether_addr{}))
+ {
+ return false;
+ }
+ // we accept only unicast MAC addresses and same thing has been checked in
+ // phosphor-network layer. If the least significant bit of the first octet
+ // is set to 1, it is multicast MAC else it is unicast MAC address.
+ if (mac.ether_addr_octet[0] & 1)
+ {
+ return false;
+ }
+ return true;
+}
RspType<> setLan(uint4_t channelBits, uint4_t, uint8_t parameter,
message::Payload& req)
@@ -1426,6 +1450,11 @@ RspType<> setLan(uint4_t channelBits, uint4_t, uint8_t parameter,
return responseReqDataLenInvalid();
}
copyInto(mac, bytes);
+
+ if (!isValidMACAddress(mac))
+ {
+ return responseInvalidFieldRequest();
+ }
channelCall<setMACProperty>(channel, mac);
return responseSuccess();
}
OpenPOWER on IntegriCloud