Skip to content

Commit

Permalink
Fix ICMP error encapsulation to hosts behind B4s
Browse files Browse the repository at this point in the history
  • Loading branch information
Katerina Barone-Adesi authored and dpino committed Aug 5, 2016
1 parent f64f07e commit cb79190
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
17 changes: 13 additions & 4 deletions src/apps/lwaftr/lwaftr.lua
Expand Up @@ -387,14 +387,23 @@ local function transmit_ipv4(lwstate, pkt)
end
end

-- Only locally generated error packets are handled here. We transmit
-- them right away, instead of calling transmit_ipv4, because they are
-- never hairpinned and should not be counted by the "out-ipv4" counter.
-- However, they should be tunneled if the error is to be sent to a host
-- behind a B4, whether or not hairpinning is enabled; this is not hairpinning.
local function transmit_icmpv4_reply(lwstate, pkt, orig_pkt)
drop(orig_pkt)
counter.add(lwstate.counters["out-icmpv4-bytes"], pkt.length)
counter.add(lwstate.counters["out-icmpv4-packets"])
-- Only locally generated error packets are handled here. We transmit
-- them right away, instead of calling transmit_ipv4, because they are
-- never hairpinned and should not be counted by the "out-ipv4" counter.
return transmit(lwstate.o4, pkt)

local ipv4_header = get_ethernet_payload(pkt)
local dst_ip = get_ipv4_dst_address(ipv4_header)
if ipv4_in_binding_table(lwstate, dst_ip) then
return transmit(lwstate.input.v4, pkt)
else
return transmit(lwstate.o4, pkt)
end
end

-- ICMPv4 type 3 code 1, as per RFC 7596.
Expand Down
9 changes: 4 additions & 5 deletions src/program/lwaftr/tests/end-to-end/end-to-end-vlan.sh
Expand Up @@ -253,11 +253,10 @@ snabb_run_and_cmp ${TEST_CONF}/tunnel_icmp_vlan.conf \
${EMPTY} ${TEST_DATA}/hairpinned-icmpv4-echo-reply-unbound-from-aftr.pcap \
${COUNTERS}/in-1p-ipv6-out-1p-icmpv6-2.lua

# FIXME: fix and reenable this test.
# echo "Testing: from-to-b4 TCP packet, with hairpinning, TTL 1"
# snabb_run_and_cmp ${TEST_CONF}/tunnel_icmp_vlan.conf \
# ${EMPTY} ${TEST_DATA}/tcp-fromb4-tob4-ipv6-ttl-1.pcap \
# ${EMPTY} ${TEST_DATA}/tcp-fromb4-tob4-ipv6-ttl-1-reply.pcap
echo "Testing: from-to-b4 TCP packet, with hairpinning, TTL 1"
snabb_run_and_cmp ${TEST_CONF}/tunnel_icmp_vlan.conf \
${EMPTY} ${TEST_DATA}/tcp-fromb4-tob4-ipv6-ttl-1.pcap \
${EMPTY} ${TEST_DATA}/tcp-fromb4-tob4-ipv6-ttl-1-reply.pcap

echo "Testing: from-b4 IPv6 packet, with hairpinning, to B4 with custom lwAFTR address"
snabb_run_and_cmp ${TEST_CONF}/no_icmp_vlan.conf \
Expand Down
9 changes: 4 additions & 5 deletions src/program/lwaftr/tests/end-to-end/end-to-end.sh
Expand Up @@ -270,11 +270,10 @@ snabb_run_and_cmp ${TEST_BASE}/tunnel_icmp.conf \
${EMPTY} ${TEST_BASE}/hairpinned-icmpv4-echo-reply-unbound-from-aftr.pcap \
${COUNTERS}/in-1p-ipv6-out-1p-icmpv6-2.lua

# FIXME: fix and reenable this test.
# echo "Testing: from-to-b4 TCP packet, with hairpinning, TTL 1"
# snabb_run_and_cmp ${TEST_BASE}/tunnel_icmp.conf \
# ${EMPTY} ${TEST_BASE}/tcp-fromb4-tob4-ipv6-ttl-1.pcap \
# ${EMPTY} ${TEST_BASE}/tcp-fromb4-tob4-ipv6-ttl-1-reply.pcap
echo "Testing: from-to-b4 TCP packet, with hairpinning, TTL 1"
snabb_run_and_cmp ${TEST_BASE}/tunnel_icmp.conf \
${EMPTY} ${TEST_BASE}/tcp-fromb4-tob4-ipv6-ttl-1.pcap \
${EMPTY} ${TEST_BASE}/tcp-fromb4-tob4-ipv6-ttl-1-reply.pcap

echo "Testing: from-to-b4 IPv6 packet, with hairpinning, with vlan tag"
snabb_run_and_cmp ${TEST_BASE}/vlan.conf \
Expand Down

0 comments on commit cb79190

Please sign in to comment.