diff options
-rw-r--r-- | configure.ac | 12 | ||||
-rw-r--r-- | ethernet_interface.cpp | 10 | ||||
-rw-r--r-- | ipaddress.cpp | 3 | ||||
-rw-r--r-- | network_config.cpp | 8 |
4 files changed, 31 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index bba116d..9930889 100644 --- a/configure.ac +++ b/configure.ac @@ -76,6 +76,18 @@ AS_IF([test "x$enable_oe_sdk" == "xyes"], AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags]) ) +# If set, auto-configure a link-local address on the NIC. +AC_ARG_ENABLE([link-local-autoconfiguration], + AS_HELP_STRING([--disable-link-local-autoconfiguration], [Disable link-local IP address autoconfiguration]) +) + +AC_ARG_VAR(LINK_LOCAL_AUTOCONFIGURATION, [Enable link-local address autoconfiguration]) + +AS_IF([test "x$enable_link_local_autoconfiguration" != "xno"], + [LINK_LOCAL_AUTOCONFIGURATION="yes"] + AC_DEFINE_UNQUOTED([LINK_LOCAL_AUTOCONFIGURATION], ["$LINK_LOCAL_AUTOCONFIGURATION"], [Enable link-local IP address autoconfiguration]) +) + AC_ARG_VAR(DNS_ENTRY_FILE, [File having DNS entries supplied by DHCP]) AS_IF([test "x$DNS_ENTRY_FILE" == "x"], [DNS_ENTRY_FILE="/run/systemd/netif/state"]) AC_DEFINE_UNQUOTED([DNS_ENTRY_FILE], ["$DNS_ENTRY_FILE"], [File having DNS entries supplied by DHCP]) diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp index d887bf5..b70db40 100644 --- a/ethernet_interface.cpp +++ b/ethernet_interface.cpp @@ -555,7 +555,11 @@ void EthernetInterface::writeConfigurationFile() // write the network section stream << "[" << "Network" << "]\n"; +#ifdef LINK_LOCAL_AUTOCONFIGURATION stream << "LinkLocalAddressing=yes\n"; +#else + stream << "LinkLocalAddressing=no\n"; +#endif stream << "IPv6AcceptRA=false\n"; // Add the VLAN entry @@ -587,7 +591,11 @@ void EthernetInterface::writeConfigurationFile() // Static for (const auto& addr : addrs) { - if (addr.second->origin() == AddressOrigin::Static) + if (addr.second->origin() == AddressOrigin::Static +#ifndef LINK_LOCAL_AUTOCONFIGURATION + || addr.second->origin() == AddressOrigin::LinkLocal +#endif + ) { std::string address = addr.second->address() + "/" + std::to_string(addr.second->prefixLength()); diff --git a/ipaddress.cpp b/ipaddress.cpp index 9244b24..0d1c9ae 100644 --- a/ipaddress.cpp +++ b/ipaddress.cpp @@ -1,3 +1,4 @@ +#include "config.h" #include "ipaddress.hpp" #include "ethernet_interface.hpp" #include "util.hpp" @@ -45,6 +46,7 @@ void IPAddress::delete_() return; } +#ifdef LINK_LOCAL_AUTOCONFIGURATION if (isLinkLocalIP(address())) { log<level::ERR>("Can not delete the LinkLocal address"), @@ -52,6 +54,7 @@ void IPAddress::delete_() parent.interfaceName().c_str(), address().c_str()); return; } +#endif parent.deleteObject(address()); } diff --git a/network_config.cpp b/network_config.cpp index 84cf3dc..d492bf3 100644 --- a/network_config.cpp +++ b/network_config.cpp @@ -1,3 +1,4 @@ +#include "config.h" #include "network_config.hpp" #include <fstream> #include <string> @@ -16,7 +17,12 @@ namespace bmc filestream.open(filename); filestream << "[Match]\nName=" << interface << - "\n[Network]\nDHCP=true\nLinkLocalAddressing=yes\n" + "\n[Network]\nDHCP=true\n" +#ifdef LINK_LOCAL_AUTOCONFIGURATION + "LinkLocalAddressing=yes\n" +#else + "LinkLocalAddressing=no\n" +#endif "IPv6AcceptRA=false\n" "[DHCP]\nClientIdentifier=mac\n"; filestream.close(); |