Device Emulation (contd.): Lookup NDP Cache for IPv6 neighbor mac
This commit is contained in:
parent
21197146e2
commit
07dd945f50
@ -382,11 +382,30 @@ quint64 Device::neighborMac(const PacketBuffer *pktBuf)
|
|||||||
|
|
||||||
dstIp = qFromBigEndian<quint32>(pktData + ipHdrLen - 4);
|
dstIp = qFromBigEndian<quint32>(pktData + ipHdrLen - 4);
|
||||||
mask = ~0 << (32 - ip4PrefixLength_);
|
mask = ~0 << (32 - ip4PrefixLength_);
|
||||||
qDebug("dst %x self %x mask %x", dstIp, ip4_, mask);
|
qDebug("dst %x mask %x self %x", dstIp, mask, ip4_);
|
||||||
tgtIp = ((dstIp & mask) == (ip4_ & mask)) ? dstIp : ip4Gateway_;
|
tgtIp = ((dstIp & mask) == (ip4_ & mask)) ? dstIp : ip4Gateway_;
|
||||||
|
|
||||||
return arpTable_.value(tgtIp);
|
return arpTable_.value(tgtIp);
|
||||||
}
|
}
|
||||||
|
else if ((ethType == kEthTypeIp6) && hasIp6_) { // IPv6
|
||||||
|
UInt128 dstIp, tgtIp, mask;
|
||||||
|
|
||||||
|
if (pktBuf->length() < (kIp6HdrLen+2)) {
|
||||||
|
qDebug("incomplete IPv6 header: expected %d, actual %d",
|
||||||
|
kIp6HdrLen, pktBuf->length()-2);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
dstIp = qFromBigEndian<UInt128>(pktData + 24);
|
||||||
|
mask = ~UInt128(0, 0) << (128 - ip6PrefixLength_);
|
||||||
|
qDebug("dst %s mask %s self %s",
|
||||||
|
qPrintable(QHostAddress(dstIp.toArray()).toString()),
|
||||||
|
qPrintable(QHostAddress(mask.toArray()).toString()),
|
||||||
|
qPrintable(QHostAddress(ip6_.toArray()).toString()));
|
||||||
|
tgtIp = ((dstIp & mask) == (ip6_ & mask)) ? dstIp : ip6Gateway_;
|
||||||
|
|
||||||
|
return ndpTable_.value(tgtIp);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -447,6 +447,7 @@ def test_multiEmulDevNoVlan(drone, ports, dut, dut_ports, dut_ip,
|
|||||||
s = stream_cfg.stream.add()
|
s = stream_cfg.stream.add()
|
||||||
s.stream_id.id = stream_id.stream_id[i].id
|
s.stream_id.id = stream_id.stream_id[i].id
|
||||||
s.core.is_enabled = True
|
s.core.is_enabled = True
|
||||||
|
s.core.frame_len = 80 # FIXME: change to 128
|
||||||
s.control.packets_per_sec = 100
|
s.control.packets_per_sec = 100
|
||||||
s.control.num_packets = 10
|
s.control.num_packets = 10
|
||||||
|
|
||||||
@ -703,13 +704,24 @@ def test_multiEmulDevNoVlan(drone, ports, dut, dut_ports, dut_ip,
|
|||||||
print(cap_pkts)
|
print(cap_pkts)
|
||||||
log.info('dumping Rx capture buffer (filtered)')
|
log.info('dumping Rx capture buffer (filtered)')
|
||||||
for i in range(num_devs):
|
for i in range(num_devs):
|
||||||
cap_pkts = subprocess.check_output([tshark, '-nr', 'capture.pcap',
|
if has_ip4:
|
||||||
'-Y', '(ip.src == 10.10.1.' + str(101+i*ip_step) + ') '
|
cap_pkts = subprocess.check_output([tshark, '-nr', 'capture.pcap',
|
||||||
' && (ip.dst == 10.10.2.' + str(101+i*ip_step) + ')'
|
'-Y', '(ip.src == 10.10.1.' + str(101+i*ip_step) + ') '
|
||||||
' && (eth.dst == 00:01:02:03:0b:'
|
' && (ip.dst == 10.10.2.' + str(101+i*ip_step) + ')'
|
||||||
+ format(1+i*mac_step, '02x')+')'])
|
' && (eth.dst == 00:01:02:03:0b:'
|
||||||
print(cap_pkts)
|
+ format(1+i*mac_step, '02x')+')'])
|
||||||
assert cap_pkts.count('\n') == s.control.num_packets/num_devs
|
print(cap_pkts)
|
||||||
|
assert cap_pkts.count('\n') == s.control.num_packets/num_devs
|
||||||
|
if has_ip6:
|
||||||
|
cap_pkts = subprocess.check_output([tshark, '-nr', 'capture.pcap',
|
||||||
|
'-Y', '(ipv6.src == 1234:1::'
|
||||||
|
+ format(101+i*ip_step, 'x') + ') '
|
||||||
|
' && (ipv6.dst == 1234:2::'
|
||||||
|
+ format(101+i*ip_step, 'x') + ')'
|
||||||
|
' && (eth.dst == 00:01:02:03:0b:'
|
||||||
|
+ format(1+i*mac_step, '02x')+')'])
|
||||||
|
print(cap_pkts)
|
||||||
|
assert cap_pkts.count('\n') == s.control.num_packets/num_devs
|
||||||
os.remove('capture.pcap')
|
os.remove('capture.pcap')
|
||||||
|
|
||||||
drone.stopTransmit(ports.tx)
|
drone.stopTransmit(ports.tx)
|
||||||
|
Loading…
Reference in New Issue
Block a user