ncsid: Set MAC address using ioctl calls
Set the MAC address directly via ioctl calls, removing the
dependency on phosphor-networkd. This simplifies the process
and reduces overhead as phosphor-networkd is not extensively
utilized in this context.
Change-Id: If3465f52834ba38c551d5152ef354cbf455f6a90
Signed-off-by: Mo Elbadry <elbadrym@google.com>
diff --git a/subprojects/ncsid/src/net_config.h b/subprojects/ncsid/src/net_config.h
index 7aeb18b..02c9aff 100644
--- a/subprojects/ncsid/src/net_config.h
+++ b/subprojects/ncsid/src/net_config.h
@@ -53,22 +53,22 @@
virtual int set_nic_hostless(bool is_nic_hostless) = 0;
};
-// Calls phosphord-networkd
+// Calls Socket Ioctl to obtain information about NIC (previously
+// phosphor-networkd)
class PhosphorConfig : public ConfigBase
{
public:
explicit PhosphorConfig(const std::string& iface_name);
- // Reads the MAC address from phosphor-networkd interface or internal
+ // Reads the MAC address from socket interface or internal
// cache, and store in the mac pointer.
// Returns -1 if failed, 0 if succeeded.
int get_mac_addr(mac_addr_t* mac) override;
- // Sets the MAC address over phosphor-networkd, and update internal
+ // Sets the MAC address over socket, and update internal
// cache.
// Returns -1 if failed, 0 if succeeded.
int set_mac_addr(const mac_addr_t& mac) override;
-
virtual int set_nic_hostless(bool is_nic_hostless) override;
private:
@@ -81,6 +81,10 @@
// Stores the currently configured nic state, if previously set
std::optional<bool> was_nic_hostless_;
+ // Function helper allows get_mac_addr and set_mac_addr to do
+ // ioctl calls to get and set different states of NIC.
+ void call_nic(auto fd, struct ifreq& ifr, int op);
+
// The MAC address obtained from NIC.
// ncsid will commit this MAC address over DBus to phosphor-networkd
// and expect it to be persisted. If actual host MAC address changes or