Setup MTU for WG/AWG protocol (#576)

Setup MTU for AWG/WG protocol
This commit is contained in:
Mykola Baibuz 2024-03-18 12:41:53 +02:00 committed by GitHub
parent 9f82b4c21f
commit e646b85e56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 512 additions and 56 deletions

View file

@ -20,9 +20,6 @@
#include "logger.h"
#include "macosdaemon.h"
constexpr uint32_t ETH_MTU = 1500;
constexpr uint32_t WG_MTU_OVERHEAD = 80;
namespace {
Logger logger("IPUtilsMacos");
}
@ -56,10 +53,10 @@ bool IPUtilsMacos::setMTUAndUp(const InterfaceConfig& config) {
// MTU
strncpy(ifr.ifr_name, qPrintable(ifname), IFNAMSIZ);
ifr.ifr_mtu = ETH_MTU - WG_MTU_OVERHEAD;
ifr.ifr_mtu = config.m_deviceMTU;
int ret = ioctl(sockfd, SIOCSIFMTU, &ifr);
if (ret) {
logger.error() << "Failed to set MTU:" << strerror(errno);
logger.error() << "Failed to set MTU -- " << config.m_deviceMTU << " -- Return code: " << ret;
return false;
}