According to RFC 792, the Destination Unreachable and Time Exceeded ICMP types 
should have the following as data:

"Internet Header + 64 bits of Original Data Datagram”

We should ensure, when creating ICMP packets of these types, that the amount of 
data sent compiles with the RFC.
The only sample application known to use either of these types is rest_router.

Signed-off-by: Victor J. Orlikowski <[email protected]>

diff --git a/ryu/app/rest_router.py b/ryu/app/rest_router.py
index 30812a7..629ca1e 100644
--- a/ryu/app/rest_router.py
+++ b/ryu/app/rest_router.py
@@ -1523,8 +1523,12 @@ class OfCtl(object):
         eth = protocol_list[ETHERNET]
         e = ethernet.ethernet(eth.src, eth.dst, ether_proto)
 
+        ip = protocol_list[IPV4]
+
         if icmp_data is None and msg_data is not None:
-            ip_datagram = msg_data[offset:]
+            # Per RFC 792, only send IP header plus first 64 bits
+            send_data_len = offset + len(ip) + 8 + 1
+            ip_datagram = msg_data[offset:send_data_len]
             if icmp_type == icmp.ICMP_DEST_UNREACH:
                 icmp_data = icmp.dest_unreach(data_len=len(ip_datagram),
                                               data=ip_datagram)
@@ -1534,7 +1538,6 @@ class OfCtl(object):
 
         ic = icmp.icmp(icmp_type, icmp_code, csum, data=icmp_data)
 
-        ip = protocol_list[IPV4]
         if src_ip is None:
             src_ip = ip.dst
         ip_total_length = ip.header_length * 4 + ic._MIN_LEN


Best,
Victor
--
Victor J. Orlikowski <> vjo@[cs.]duke.edu

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to