Skip to content

Commit

Permalink
Merge pull request snabbco#1073 from dpino/fix-ttl
Browse files Browse the repository at this point in the history
Init TTL and hop_limit in Echo response
  • Loading branch information
dpino authored Jun 1, 2018
2 parents e63f9e7 + aafbe6e commit f310d4e
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/apps/ipv4/echo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ function ICMPEcho:respond_to_echo_request(pkt)
out_h.ipv4.flags_and_fragment_offset =
bit.band(out_h.ipv4.flags_and_fragment_offset, ipv4_fragment_offset_mask)

-- Set TTL.
out_h.ipv4.ttl = 64

-- Recalculate IPv4 checksum.
out_h.ipv4.checksum = 0
out_h.ipv4.checksum = htons(
Expand Down
3 changes: 3 additions & 0 deletions src/apps/ipv6/echo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ function ICMPEcho:respond_to_echo_request(pkt)
out_h.ether.dhost, out_h.ether.shost = h.ether.shost, h.ether.dhost
out_h.ipv6.src_ip, out_h.ipv6.dst_ip = h.ipv6.dst_ip, h.ipv6.src_ip

-- Set hop limit.
out_h.ipv6.hop_limit = 64

-- Change ICMP message type.
icmp = ffi.cast(icmp_header_ptr_t, out_h.ipv6.payload)
icmp.type = icmpv6_echo_reply
Expand Down
2 changes: 2 additions & 0 deletions src/program/lwaftr/tests/data/add-vlan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ V4=(
udp-frominet-3frag-bound.pcap
udp-frominet-bound.pcap
ping-v4.pcap
ping-v4-ttl-32.pcap
ping-v4-reply.pcap
ping-v4-and-data.pcap
)
Expand Down Expand Up @@ -110,6 +111,7 @@ V6=(
udp-afteraftr-reassembled-ipv6-2frags.pcap
udp-fromb4-2frags-bound.pcap
ping-v6.pcap
ping-v6-hop-limit-32.pcap
ping-v6-reply.pcap
ping-v6-and-data.pcap
)
Expand Down
Binary file added src/program/lwaftr/tests/data/ping-v4-ttl-32.pcap
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions src/program/lwaftr/tests/end-to-end/test_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -385,18 +385,30 @@ TEST_DATA=(
"no_icmp_with_filters_drop.conf" "tcp-frominet-trafficclass.pcap" "" "" ""
"in-1p-ipv4-out-0p-drop.lua"

# Ping to lwAFTR (IPv4).

"ICMP Echo to AFTR (IPv4)"
"no_icmp.conf" "ping-v4.pcap" "" "ping-v4-reply.pcap" ""
"nofrag4.lua"

"ICMP Echo to AFTR (IPv4) (ttl=32)"
"no_icmp.conf" "ping-v4-ttl-32.pcap" "" "ping-v4-reply.pcap" ""
"nofrag4.lua"

"ICMP Echo to AFTR (IPv4) + data"
"no_icmp.conf" "ping-v4-and-data.pcap" "" "ping-v4-reply.pcap" "tcp-afteraftr-ipv6.pcap"
"in-1p-ipv4-out-1p-ipv6-echo.lua"

# Ping to lwAFTR (IPv6).

"ICMP Echo to AFTR (IPv6)"
"no_icmp.conf" "" "ping-v6.pcap" "" "ping-v6-reply.pcap"
"icmpv6-ping-and-reply.lua"

"ICMP Echo to AFTR (IPv6) (hop-limit=32)"
"no_icmp.conf" "" "ping-v6-hop-limit-32.pcap" "" "ping-v6-reply.pcap"
"icmpv6-ping-and-reply.lua"

"ICMP Echo to AFTR (IPv6) + data"
"no_icmp.conf" "" "ping-v6-and-data.pcap" "decap-ipv4.pcap" "ping-v6-reply.pcap"
"in-1p-ipv6-out-1p-ipv4-4-and-echo.lua"
Expand Down

0 comments on commit f310d4e

Please sign in to comment.