From: Mehak Mahajan Date: Mon, 22 Oct 2012 21:01:40 +0000 (-0700) Subject: Do not print ICMP fields for non IP packets. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19564d20d6ed03334299e69d078aa11b81c958af;p=openvswitch Do not print ICMP fields for non IP packets. The packet's nw_proto field overlaps with the ARP opcode field. The nw_proto for ICMP packets is 1. Hence when the packet is an ARP request (opcode 1), we erroneously print the ICMP code and ICMP type for ARP frames as well. With this commit, the ICMP code and ICMP type will be printed only if the packet is an IP packet and the nw_proto is ICMP. Signed-off-by: Mehak Mahajan Acked-by: Ethan Jackson --- diff --git a/lib/match.c b/lib/match.c index f5da97f5..e53a11a0 100644 --- a/lib/match.c +++ b/lib/match.c @@ -822,10 +822,12 @@ match_format(const struct match *match, struct ds *s, unsigned int priority) f->nw_frag & FLOW_NW_FRAG_LATER ? "later" : "not_later"); break; } - if (f->nw_proto == IPPROTO_ICMP) { + if (f->dl_type == htons(ETH_TYPE_IP) && + f->nw_proto == IPPROTO_ICMP) { format_be16_masked(s, "icmp_type", f->tp_src, wc->masks.tp_src); format_be16_masked(s, "icmp_code", f->tp_dst, wc->masks.tp_dst); - } else if (f->nw_proto == IPPROTO_ICMPV6) { + } else if (f->dl_type == htons(ETH_TYPE_IPV6) && + f->nw_proto == IPPROTO_ICMPV6) { format_be16_masked(s, "icmp_type", f->tp_src, wc->masks.tp_src); format_be16_masked(s, "icmp_code", f->tp_dst, wc->masks.tp_dst); format_ipv6_netmask(s, "nd_target", &f->nd_target, diff --git a/tests/ofp-print.at b/tests/ofp-print.at index 7e17a9d0..4474d35a 100644 --- a/tests/ofp-print.at +++ b/tests/ofp-print.at @@ -771,7 +771,7 @@ c0 a8 00 02 00 08 00 00 00 00 00 09 05 b8 d8 00 \ OFPST_FLOW reply (xid=0x4): cookie=0x0, duration=4.2s, table=0, n_packets=1, n_bytes=60, idle_timeout=5, priority=65535,arp,in_port=3,vlan_tci=0x0000,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:06,nw_src=192.168.0.1,nw_dst=192.168.0.2,arp_op=2,nw_tos=0,tp_src=0,tp_dst=0 actions=output:1 cookie=0x0, duration=8.9s, table=0, n_packets=13, n_bytes=1274, idle_timeout=5, priority=65535,icmp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,nw_tos=0,icmp_type=0,icmp_code=0 actions=output:3 - cookie=0x0, duration=4.28s, table=0, n_packets=1, n_bytes=60, idle_timeout=5, priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,arp_op=1,nw_tos=0,icmp_type=0,icmp_code=0 actions=output:3 + cookie=0x0, duration=4.28s, table=0, n_packets=1, n_bytes=60, idle_timeout=5, priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,arp_op=1,nw_tos=0,tp_src=0,tp_dst=0 actions=output:3 cookie=0x0, duration=9.096s, table=0, n_packets=13, n_bytes=1274, idle_timeout=5, icmp,vlan_tci=0x0000,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:06,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,icmp_type=8,icmp_code=0 actions=output:1 cookie=0x0, duration=0s, table=2, n_packets=0, n_bytes=0, actions=drop ])