Skip to content

Commit

Permalink
bfdlib: follow TTL/hop limit in RFC5881 explicitly.
Browse files Browse the repository at this point in the history
Signed-off-by: Wei-Li Tang <alextwl@xinguard.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
  • Loading branch information
alextwl authored and fujita committed Oct 10, 2014
1 parent 49aa2ff commit 5aa14c6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ryu/lib/bfdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,10 @@ def bfd_packet(src_mac, dst_mac, src_ip, dst_ip, ipv4_id,
pkt.add_protocol(eth_pkt)

# IPv4 encapsulation
# ToS sets to 192 (Network control/CS6)
# set ToS to 192 (Network control/CS6)
# set TTL to 255 (RFC5881 Section 5.)
ipv4_pkt = ipv4.ipv4(proto=inet.IPPROTO_UDP, src=src_ip, dst=dst_ip,
tos=192, identification=ipv4_id)
tos=192, identification=ipv4_id, ttl=255)
pkt.add_protocol(ipv4_pkt)

# UDP encapsulation
Expand Down Expand Up @@ -861,6 +862,10 @@ def recv_bfd_pkt(self, datapath, in_port, data):

ip_pkt = pkt.get_protocols(ipv4.ipv4)[0]

# Discard it if TTL != 255 for single hop bfd. (RFC5881 Section 5.)
if ip_pkt.ttl != 255:
return

# Parse BFD packet here.
bfd_pkt = BFDPacket.bfd_parse(data)

Expand Down

0 comments on commit 5aa14c6

Please sign in to comment.