Commit 4d79049a authored by aligungr's avatar aligungr

UE TUN MTU decreased to 1400

parent 05f1c4fa
......@@ -202,7 +202,7 @@ void UeAppTask::setupTunInterface(const PduSession *pduSession)
std::string ipAddress = utils::OctetStringToIp(pduSession->pduAddress->pduAddressInformation);
bool r = tun::TunConfigure(allocatedName, ipAddress, m_base->config->configureRouting, error);
bool r = tun::TunConfigure(allocatedName, ipAddress, cons::TunMtu, m_base->config->configureRouting, error);
if (!r || error.length() > 0)
{
m_logger->err("TUN configuration failure [%s]", error.c_str());
......
......@@ -109,7 +109,7 @@ static const char *NextInterfaceName(const std::string &prefix)
return nullptr;
}
static void TunSetIpAndUp(const char *ifName, const char *ipAddr)
static void TunSetIpAndUp(const char *ifName, const char *ipAddr, int mtu)
{
ifreq ifr{};
memset(&ifr, 0, sizeof(struct ifreq));
......@@ -133,14 +133,15 @@ static void TunSetIpAndUp(const char *ifName, const char *ipAddr)
memcpy((((char *)&ifr + offsetof(struct ifreq, ifr_addr))), p, sizeof(struct sockaddr));
if (ioctl(sockFd, SIOCSIFADDR, &ifr) < 0)
{
throw LibError("ioctl(SIOCSIFADDR)", errno);
}
if (ioctl(sockFd, SIOCGIFFLAGS, &ifr) < 0)
throw LibError("ioctl(SIOCGIFFLAGS)", errno);
ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
ifr.ifr_mtu = mtu;
if (ioctl(sockFd, SIOCSIFMTU, &ifr) < 0)
throw LibError("ioctl(SIOCSIFMTU)", errno);
ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
if (ioctl(sockFd, SIOCSIFFLAGS, &ifr) < 0)
throw LibError("ioctl(SIOCSIFFLAGS)", errno);
......@@ -349,12 +350,12 @@ int AllocateTun(const char *ifPrefix, char **allocatedName)
return fd;
}
void ConfigureTun(const char *tunName, const char *ipAddr, bool configureRoute)
void ConfigureTun(const char *tunName, const char *ipAddr, int mtu, bool configureRoute)
{
// acquire the configuration lock
const std::lock_guard<std::mutex> lock(configMutex);
TunSetIpAndUp(tunName, ipAddr);
TunSetIpAndUp(tunName, ipAddr, mtu);
if (configureRoute)
{
std::string table_name = ROUTING_TABLE_PREFIX + std::string(tunName);
......
......@@ -16,6 +16,6 @@ namespace nr::ue::tun
{
int AllocateTun(const char *ifPrefix, char **allocatedName);
void ConfigureTun(const char *tunName, const char *ipAddr, bool configureRoute);
void ConfigureTun(const char *tunName, const char *ipAddr, int mtu, bool configureRoute);
} // namespace nr::ue::tun
......@@ -32,11 +32,11 @@ int TunAllocate(const char *namePrefix, std::string &allocatedName, std::string
return fd;
}
bool TunConfigure(const std::string &tunName, const std::string &ipAddress, bool configureRouting, std::string &error)
bool TunConfigure(const std::string &tunName, const std::string &ipAddress, int mtu, bool configureRouting, std::string &error)
{
try
{
tun::ConfigureTun(tunName.c_str(), ipAddress.c_str(), configureRouting);
tun::ConfigureTun(tunName.c_str(), ipAddress.c_str(), mtu, configureRouting);
}
catch (const LibError &e)
{
......
......@@ -14,6 +14,6 @@ namespace nr::ue::tun
{
int TunAllocate(const char *namePrefix, std::string &allocatedName, std::string &error);
bool TunConfigure(const std::string &tunName, const std::string &ipAddress, bool configureRouting, std::string &error);
bool TunConfigure(const std::string &tunName, const std::string &ipAddress, int mtu, bool configureRouting, std::string &error);
} // namespace nr::ue::tun
\ No newline at end of file
......@@ -27,6 +27,7 @@ struct cons
// TUN interface
static constexpr const char *TunNamePrefix = "uesimtun";
static constexpr const int TunMtu = 1400;
// Constraints
static constexpr const int MinNodeName = 3;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment