ip: fix smp fragment reassembly

ipv4::handle_on_cpu() did not properly convert from network byte order, so
it saw any packets with DF=1 as fragmented.

Fix by applying the proper conversion.
This commit is contained in:
Avi Kivity
2014-12-07 11:59:23 +02:00
parent 2ee0239a4a
commit a2016bc1dd

View File

@@ -35,27 +35,27 @@ ipv4::ipv4(interface* netif)
unsigned ipv4::handle_on_cpu(packet& p, size_t off)
{
auto iph = p.get_header<ip_hdr>(off);
auto iph = ntoh(*p.get_header<ip_hdr>(off));
if (_packet_filter) {
bool h = false;
auto r = _packet_filter->forward(p, off + sizeof(ip_hdr), iph->src_ip, iph->dst_ip, h);
auto r = _packet_filter->forward(p, off + sizeof(ip_hdr), iph.src_ip, iph.dst_ip, h);
if (h) {
return r;
}
}
auto l4 = _l4[iph->ip_proto];
auto l4 = _l4[iph.ip_proto];
if (!l4) {
return engine.cpu_id();
}
if (iph->mf() == false && iph->offset() == 0) {
if (iph.mf() == false && iph.offset() == 0) {
// This IP datagram is atomic, forward according to tcp or udp connection hash
return l4->forward(p, off + sizeof(ip_hdr), iph->src_ip, iph->dst_ip);
return l4->forward(p, off + sizeof(ip_hdr), iph.src_ip, iph.dst_ip);
} else {
// otherwise, forward according to frag_id hash
auto frag_id = ipv4_frag_id{ntoh(iph->src_ip), ntoh(iph->dst_ip), iph->id, iph->ip_proto};
auto frag_id = ipv4_frag_id{iph.src_ip, iph.dst_ip, iph.id, iph.ip_proto};
return ipv4_frag_id::hash()(frag_id) % smp::count;
}
}