From: Denis Ovsienko Date: Sat, 26 Sep 2020 21:41:10 +0000 (+0100) Subject: OpenFlow 1.0: Update of10_header_body_print(). X-Git-Tag: tcpdump-4.99-bp~190 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/99e7b8ee5e2b43fd8775b995893384b03796a638?ds=sidebyside OpenFlow 1.0: Update of10_header_body_print(). Fix a field name for OFPT_QUEUE_GET_CONFIG_REQUEST and OFPT_QUEUE_GET_CONFIG_REPLY. Update the tests. Use break instead of goto inside the switch block and lose a label. --- diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c index 567a8953..4548f4ee 100644 --- a/print-openflow-1.0.c +++ b/print-openflow-1.0.c @@ -2115,7 +2115,7 @@ of10_header_body_print(netdissect_options *ndo, case OFPT_BARRIER_REPLY: /* ibid */ if (len) goto invalid; - break; + return; /* OpenFlow header and fixed-size message body. */ case OFPT_SET_CONFIG: /* [OF10] Section 5.3.2 */ @@ -2123,7 +2123,7 @@ of10_header_body_print(netdissect_options *ndo, if (len != OF_SWITCH_CONFIG_FIXLEN - OF_HEADER_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) - goto next_message; + break; /* flags */ ND_PRINT("\n\t flags %s", tok2str(ofp_config_str, "invalid (0x%04x)", @@ -2136,16 +2136,16 @@ of10_header_body_print(netdissect_options *ndo, if (len != OF_PORT_MOD_FIXLEN - OF_HEADER_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) - goto next_message; + break; of10_port_mod_print(ndo, cp); return; case OFPT_QUEUE_GET_CONFIG_REQUEST: /* [OF10] Section 5.3.4 */ if (len != OF_QUEUE_GET_CONFIG_REQUEST_FIXLEN - OF_HEADER_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) - goto next_message; + break; /* port */ - ND_PRINT("\n\t port_no %s", + ND_PRINT("\n\t port %s", tok2str(ofpp_str, "%u", GET_BE_U_2(cp))); OF_FWD(2); /* pad */ @@ -2156,14 +2156,14 @@ of10_header_body_print(netdissect_options *ndo, if (len != OF_FLOW_REMOVED_FIXLEN - OF_HEADER_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) - goto next_message; + break; of10_flow_removed_print(ndo, cp); return; case OFPT_PORT_STATUS: /* [OF10] Section 5.4.3 */ if (len != OF_PORT_STATUS_FIXLEN - OF_HEADER_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) - goto next_message; + break; /* reason */ ND_PRINT("\n\t reason %s", tok2str(ofppr_str, "invalid (0x%02x)", GET_U_1(cp))); @@ -2180,7 +2180,7 @@ of10_header_body_print(netdissect_options *ndo, if (len < OF_FEATURES_REPLY_MINLEN - OF_HEADER_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) - goto next_message; + break; of10_features_reply_print(ndo, cp, len); return; @@ -2189,7 +2189,7 @@ of10_header_body_print(netdissect_options *ndo, case OFPT_ECHO_REQUEST: /* [OF10] Section 5.5.2 */ case OFPT_ECHO_REPLY: /* [OF10] Section 5.5.3 */ if (ndo->ndo_vflag < 1) - goto next_message; + break; of10_data_print(ndo, cp, len); return; @@ -2198,7 +2198,7 @@ of10_header_body_print(netdissect_options *ndo, if (len < OF_ERROR_MSG_MINLEN - OF_HEADER_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) - goto next_message; + break; of10_error_print(ndo, cp, len); return; case OFPT_VENDOR: @@ -2206,7 +2206,7 @@ of10_header_body_print(netdissect_options *ndo, if (len < OF_VENDOR_MINLEN - OF_HEADER_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) - goto next_message; + break; of10_vendor_message_print(ndo, cp, len); return; case OFPT_PACKET_IN: @@ -2214,7 +2214,7 @@ of10_header_body_print(netdissect_options *ndo, if (len < OF_PACKET_IN_MINLEN - 2 - OF_HEADER_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) - goto next_message; + break; of10_packet_in_print(ndo, cp, len); return; @@ -2225,7 +2225,7 @@ of10_header_body_print(netdissect_options *ndo, if (len < OF_STATS_REQUEST_MINLEN - OF_HEADER_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) - goto next_message; + break; of10_stats_request_print(ndo, cp, len); return; @@ -2237,7 +2237,7 @@ of10_header_body_print(netdissect_options *ndo, if (len < OF_STATS_REPLY_MINLEN - OF_HEADER_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) - goto next_message; + break; of10_stats_reply_print(ndo, cp, len); return; @@ -2246,7 +2246,7 @@ of10_header_body_print(netdissect_options *ndo, if (len < OF_PACKET_OUT_MINLEN - OF_HEADER_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) - goto next_message; + break; of10_packet_out_print(ndo, cp, len); return; @@ -2255,7 +2255,7 @@ of10_header_body_print(netdissect_options *ndo, if (len < OF_FLOW_MOD_MINLEN - OF_HEADER_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) - goto next_message; + break; of10_flow_mod_print(ndo, cp, len); return; @@ -2264,9 +2264,9 @@ of10_header_body_print(netdissect_options *ndo, if (len < OF_QUEUE_GET_CONFIG_REPLY_MINLEN - OF_HEADER_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) - goto next_message; + break; /* port */ - ND_PRINT("\n\t port_no %s", + ND_PRINT("\n\t port %s", tok2str(ofpp_str, "%u", GET_BE_U_2(cp))); OF_FWD(2); /* pad */ @@ -2276,10 +2276,14 @@ of10_header_body_print(netdissect_options *ndo, of10_queues_print(ndo, cp, len); return; } /* switch (type) */ - goto next_message; + /* + * Not a recognised type or did not print the details, fall back to + * a bounds check. + */ + ND_TCHECK_LEN(cp, len); + return; invalid: /* skip the message body */ nd_print_invalid(ndo); -next_message: ND_TCHECK_LEN(cp, len); } diff --git a/tests/of10_7050sx_bsn-vv.out b/tests/of10_7050sx_bsn-vv.out index 8fc027e1..7f8c25fa 100644 --- a/tests/of10_7050sx_bsn-vv.out +++ b/tests/of10_7050sx_bsn-vv.out @@ -255,32 +255,32 @@ 41 16:11:54.461743 IP (tos 0x0, ttl 64, id 60710, offset 0, flags [DF], proto TCP (6), length 120) 109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x3a28 (incorrect -> 0x9a6c), seq 273:341, ack 1293, win 252, options [nop,nop,TS val 590230863 ecr 50526774], length 68: OpenFlow version 1.0, type QUEUE_GET_CONFIG_REQUEST, length 12, xid 0x00000014 - port_no 16 + port 16 version 1.0, type QUEUE_GET_CONFIG_REQUEST, length 12, xid 0x00000015 - port_no 20 + port 20 version 1.0, type QUEUE_GET_CONFIG_REQUEST, length 12, xid 0x00000016 - port_no 18 + port 18 version 1.0, type QUEUE_GET_CONFIG_REQUEST, length 12, xid 0x00000017 - port_no 22 + port 22 version 1.0, type QUEUE_GET_CONFIG_REQUEST, length 12, xid 0x00000018 - port_no 17 + port 17 version 1.0, type BARRIER_REQUEST, length 8, xid 0x00000019 42 16:11:54.464033 IP (tos 0x0, ttl 55, id 49513, offset 0, flags [DF], proto TCP (6), length 68) 88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0xa139 (correct), seq 1293:1309, ack 341, win 115, options [nop,nop,TS val 50526775 ecr 590230863], length 16: OpenFlow version 1.0, type QUEUE_GET_CONFIG_REPLY, length 16, xid 0x00000014 - port_no 16 + port 16 43 16:11:54.501564 IP (tos 0x0, ttl 64, id 60711, offset 0, flags [DF], proto TCP (6), length 52) 109.74.202.168.6653 > 88.150.169.52.4756: Flags [.], cksum 0x39e4 (incorrect -> 0xa1f5), seq 341, ack 1309, win 252, options [nop,nop,TS val 590230875 ecr 50526775], length 0 44 16:11:54.504038 IP (tos 0x0, ttl 55, id 49514, offset 0, flags [DF], proto TCP (6), length 124) 88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0x9bb5 (correct), seq 1309:1381, ack 341, win 115, options [nop,nop,TS val 50526785 ecr 590230875], length 72: OpenFlow version 1.0, type QUEUE_GET_CONFIG_REPLY, length 16, xid 0x00000015 - port_no 20 + port 20 version 1.0, type QUEUE_GET_CONFIG_REPLY, length 16, xid 0x00000016 - port_no 18 + port 18 version 1.0, type QUEUE_GET_CONFIG_REPLY, length 16, xid 0x00000017 - port_no 22 + port 22 version 1.0, type QUEUE_GET_CONFIG_REPLY, length 16, xid 0x00000018 - port_no 17 + port 17 version 1.0, type BARRIER_REPLY, length 8, xid 0x00000019 45 16:11:54.504155 IP (tos 0x0, ttl 64, id 60712, offset 0, flags [DF], proto TCP (6), length 52) 109.74.202.168.6653 > 88.150.169.52.4756: Flags [.], cksum 0x39e4 (incorrect -> 0xa1a3), seq 341, ack 1381, win 252, options [nop,nop,TS val 590230875 ecr 50526785], length 0 diff --git a/tests/of10_pf5240-vv.out b/tests/of10_pf5240-vv.out index 6e8d867d..fd0738dc 100644 --- a/tests/of10_pf5240-vv.out +++ b/tests/of10_pf5240-vv.out @@ -121,14 +121,14 @@ 21 12:21:14.029852 IP (tos 0x0, ttl 64, id 16036, offset 0, flags [DF], proto TCP (6), length 84) 172.16.1.51.6633 > 172.16.1.101.62221: Flags [P.], cksum 0x5aff (incorrect -> 0x95e2), seq 129:161, ack 1509, win 139, options [nop,nop,TS val 2256458060 ecr 1], length 32: OpenFlow version 1.0, type QUEUE_GET_CONFIG_REQUEST, length 12, xid 0x00000008 - port_no 1 + port 1 version 1.0, type QUEUE_GET_CONFIG_REQUEST, length 12, xid 0x00000009 - port_no 2 + port 2 version 1.0, type BARRIER_REQUEST, length 8, xid 0x0000000a 22 12:21:14.030813 IP (tos 0xa0, ttl 64, id 10687, offset 0, flags [DF], proto TCP (6), length 196) 172.16.1.101.62221 > 172.16.1.51.6633: Flags [P.], cksum 0x8b77 (correct), seq 1509:1653, ack 161, win 2900, options [nop,nop,TS val 1 ecr 2256458060], length 144: OpenFlow version 1.0, type QUEUE_GET_CONFIG_REPLY, length 144, xid 0x00000008 - port_no 1 + port 1 queue_id 0, len 16 property NONE, len 8 queue_id 1, len 16 @@ -150,7 +150,7 @@ 24 12:21:14.071040 IP (tos 0xa0, ttl 64, id 10688, offset 0, flags [DF], proto TCP (6), length 204) 172.16.1.101.62221 > 172.16.1.51.6633: Flags [P.], cksum 0x89a4 (correct), seq 1653:1805, ack 161, win 2920, options [nop,nop,TS val 1 ecr 2256458060], length 152: OpenFlow version 1.0, type QUEUE_GET_CONFIG_REPLY, length 144, xid 0x00000009 - port_no 2 + port 2 queue_id 0, len 16 property NONE, len 8 queue_id 1, len 16