Merge pull request #951 from majestrate/fix-ip-rewrite-on-snode-2019-12-06

use ipv6 only with ipv6 packets
This commit is contained in:
Jeff 2019-12-06 15:35:31 -05:00 committed by GitHub
commit 9c7355ff9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -154,7 +154,12 @@ namespace llarp
src = m_Parent->GetIfAddr();
else
src = pkt.srcv6();
if(pkt.IsV6())
pkt.UpdateIPv6Address(src, m_IP);
else
pkt.UpdateIPv4Address(xhtonl(net::IPPacket::TruncateV6(src)),
xhtonl(net::IPPacket::TruncateV6(m_IP)));
const auto _pktbuf = pkt.Buffer();
const llarp_buffer_t& pktbuf = _pktbuf.underlying;
const uint8_t queue_idx = pktbuf.sz / llarp::routing::ExitPadSize;

View File

@ -479,7 +479,11 @@ namespace llarp
if(!pkt.Load(buf))
return false;
// rewrite ip
if(m_UseV6)
pkt.UpdateIPv6Address(from, m_IfAddr);
else
pkt.UpdateIPv4Address(xhtonl(net::IPPacket::TruncateV6(from)),
xhtonl(net::IPPacket::TruncateV6(m_IfAddr)));
return llarp_ev_tun_async_write(&m_Tun, pkt.Buffer());
}
@ -579,6 +583,7 @@ namespace llarp
m_HigestAddr = m_OurRange.HighestAddr();
LogInfo(Name(), " set ifaddr range to ", m_Tun.ifaddr, "/",
m_Tun.netmask, " lo=", m_IfAddr, " hi=", m_HigestAddr);
m_UseV6 = false;
}
if(k == "ifname")
{