From: Denis Ovsienko Date: Fri, 2 Oct 2020 11:52:48 +0000 (+0100) Subject: OpenFlow 1.3: Recognise 5 more messages types. X-Git-Tag: tcpdump-4.99-bp~162 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/853e9dccefb7b2049305fa57cc7f3e7d2f85965b OpenFlow 1.3: Recognise 5 more messages types. Also add new OUIs and experimenter IDs for OFPT_EXPERIMENTER. Update two tests. --- diff --git a/openflow.h b/openflow.h index c9c04c36..996835b5 100644 --- a/openflow.h +++ b/openflow.h @@ -58,6 +58,9 @@ #define ONF_EXP_WMOB 0xff000005 #define ONF_EXP_FABS 0xff000006 #define ONF_EXP_OTRANS 0xff000007 +#define ONF_EXP_NBLNCTU 0xff000008 +#define ONF_EXP_MPCE 0xff000009 +#define ONF_EXP_MPLSTPSPTN 0xff00000a extern const struct tok onf_exp_str[]; extern const char * of_vendor_name(const uint32_t); diff --git a/oui.c b/oui.c index 9d4c818e..25d08e21 100644 --- a/oui.c +++ b/oui.c @@ -48,6 +48,9 @@ const struct tok oui_values[] = { { OUI_ONLAB, "Open Networking Lab" }, { OUI_FREESCALE, "Freescale" }, { OUI_NETRONOME, "Netronome" }, + { OUI_BROADCOM, "Broadcom" }, + { OUI_PMC_SIERRA, "PMC-Sierra" }, + { OUI_ERICSSON, "Ericsson" }, { 0, NULL } }; diff --git a/oui.h b/oui.h index e876316b..3c824756 100644 --- a/oui.h +++ b/oui.h @@ -40,6 +40,9 @@ extern const struct tok smi_values[]; #define OUI_ONLAB 0xa42305 /* Open Networking Lab */ #define OUI_FREESCALE 0x00049f /* Freescale */ #define OUI_NETRONOME 0x0015ad /* Netronome */ +#define OUI_BROADCOM 0x001018 /* Broadcom */ +#define OUI_PMC_SIERRA 0x00e004 /* PMC-Sierra */ +#define OUI_ERICSSON 0xd0f0db /* Ericsson */ /* * These are SMI Network Management Private Enterprise Codes for diff --git a/print-openflow-1.3.c b/print-openflow-1.3.c index 1e799e89..93f6383c 100644 --- a/print-openflow-1.3.c +++ b/print-openflow-1.3.c @@ -42,6 +42,7 @@ #define ND_LONGJMP_FROM_TCHECK #include "netdissect.h" #include "extract.h" +#include "addrtoname.h" #include "openflow.h" #define OFPT_HELLO 0U @@ -129,6 +130,79 @@ static const struct tok ofp_capabilities_bm[] = { OFPC_GROUP_STATS | OFPC_IP_REASM | OFPC_QUEUE_STATS | \ OFPC_PORT_BLOCKED)) +#define OFPC_FRAG_NORMAL 0U +#define OFPC_FRAG_DROP 1U +#define OFPC_FRAG_REASM 2U +static const struct tok ofp_config_str[] = { + { OFPC_FRAG_NORMAL, "FRAG_NORMAL" }, + { OFPC_FRAG_DROP, "FRAG_DROP" }, + { OFPC_FRAG_REASM, "FRAG_REASM" }, + { 0, NULL } +}; + +#define OFPCML_MAX 0xffe5U +#define OFPCML_NO_BUFFER 0xffffU +static const struct tok ofpcml_str[] = { + { OFPCML_MAX, "MAX" }, + { OFPCML_NO_BUFFER, "NO_BUFFER" }, + { 0, NULL } +}; + +#define OFPPC_PORT_DOWN (1U <<0) +#define OFPPC_NO_RECV (1U <<2) +#define OFPPC_NO_FWD (1U <<5) +#define OFPPC_NO_PACKET_IN (1U <<6) +static const struct tok ofppc_bm[] = { + { OFPPC_PORT_DOWN, "PORT_DOWN" }, + { OFPPC_NO_RECV, "NO_RECV" }, + { OFPPC_NO_FWD, "NO_FWD" }, + { OFPPC_NO_PACKET_IN, "NO_PACKET_IN" }, + { 0, NULL } +}; +#define OFPPC_U (~(OFPPC_PORT_DOWN | OFPPC_NO_RECV | OFPPC_NO_FWD | \ + OFPPC_NO_PACKET_IN)) + +#define OFPPF_10MB_HD (1U << 0) +#define OFPPF_10MB_FD (1U << 1) +#define OFPPF_100MB_HD (1U << 2) +#define OFPPF_100MB_FD (1U << 3) +#define OFPPF_1GB_HD (1U << 4) +#define OFPPF_1GB_FD (1U << 5) +#define OFPPF_10GB_FD (1U << 6) +#define OFPPF_40GB_FD (1U << 7) +#define OFPPF_100GB_FD (1U << 8) +#define OFPPF_1TB_FD (1U << 9) +#define OFPPF_OTHER (1U << 10) +#define OFPPF_COPPER (1U << 11) +#define OFPPF_FIBER (1U << 12) +#define OFPPF_AUTONEG (1U << 13) +#define OFPPF_PAUSE (1U << 14) +#define OFPPF_PAUSE_ASYM (1U << 15) +static const struct tok ofppf_bm[] = { + { OFPPF_10MB_HD, "10MB_HD" }, + { OFPPF_10MB_FD, "10MB_FD" }, + { OFPPF_100MB_HD, "100MB_HD" }, + { OFPPF_100MB_FD, "100MB_FD" }, + { OFPPF_1GB_HD, "1GB_HD" }, + { OFPPF_1GB_FD, "1GB_FD" }, + { OFPPF_10GB_FD, "10GB_FD" }, + { OFPPF_40GB_FD, "40GB_FD" }, + { OFPPF_100GB_FD, "100GB_FD" }, + { OFPPF_1TB_FD, "1TB_FD" }, + { OFPPF_OTHER, "OTHER" }, + { OFPPF_COPPER, "COPPER" }, + { OFPPF_FIBER, "FIBER" }, + { OFPPF_AUTONEG, "AUTONEG" }, + { OFPPF_PAUSE, "PAUSE" }, + { OFPPF_PAUSE_ASYM, "PAUSE_ASYM" }, + { 0, NULL } +}; +#define OFPPF_U (~(OFPPF_10MB_HD | OFPPF_10MB_FD | OFPPF_100MB_HD | \ + OFPPF_100MB_FD | OFPPF_1GB_HD | OFPPF_1GB_FD | \ + OFPPF_10GB_FD | OFPPF_40GB_FD | OFPPF_100GB_FD | \ + OFPPF_1TB_FD | OFPPF_OTHER | OFPPF_COPPER | OFPPF_FIBER | \ + OFPPF_AUTONEG | OFPPF_PAUSE | OFPPF_PAUSE_ASYM)) + #define OFPHET_VERSIONBITMAP 1U static const struct tok ofphet_str[] = { { OFPHET_VERSIONBITMAP, "VERSIONBITMAP" }, @@ -510,7 +584,10 @@ static const struct uint_tokary of13_ofpet2tokary[] = { #define OF_HELLO_ELEM_MINSIZE 4U #define OF_ERROR_MSG_MINLEN 12U #define OF_FEATURES_REPLY_FIXLEN 32U +#define OF_PORT_MOD_FIXLEN 40U +#define OF_SWITCH_CONFIG_MSG_FIXLEN 12U #define OF_QUEUE_GET_CONFIG_REQUEST_FIXLEN 16U +#define OF_EXPERIMENTER_MSG_MINLEN 16U /* [OF13] Section A.1 */ const char * @@ -546,6 +623,52 @@ of13_features_reply_print(netdissect_options *ndo, ND_TCHECK_4(cp); } +/* [OF13] Section 7.3.2 */ +static void +of13_switch_config_msg_print(netdissect_options *ndo, + const u_char *cp, u_int len) +{ + /* flags */ + ND_PRINT("\n\t flags %s", + tok2str(ofp_config_str, "invalid (0x%04x)", GET_BE_U_2(cp))); + OF_FWD(2); + /* miss_send_len */ + ND_PRINT(", miss_send_len %s", + tok2str(ofpcml_str, "%u", GET_BE_U_2(cp))); +} + +/* [OF13] Section 7.3.4.3 */ +static void +of13_port_mod_print(netdissect_options *ndo, + const u_char *cp, u_int len) +{ + /* port_no */ + ND_PRINT("\n\t port_no %s", tok2str(ofpp_str, "%u", GET_BE_U_4(cp))); + OF_FWD(4); + /* pad */ + OF_FWD(4); + /* hw_addr */ + ND_PRINT(", hw_addr %s", GET_ETHERADDR_STRING(cp)); + OF_FWD(MAC_ADDR_LEN); + /* pad2 */ + OF_FWD(2); + /* config */ + ND_PRINT("\n\t config 0x%08x", GET_BE_U_4(cp)); + of_bitmap_print(ndo, ofppc_bm, GET_BE_U_4(cp), OFPPC_U); + OF_FWD(4); + /* mask */ + ND_PRINT("\n\t mask 0x%08x", GET_BE_U_4(cp)); + of_bitmap_print(ndo, ofppc_bm, GET_BE_U_4(cp), OFPPC_U); + OF_FWD(4); + /* advertise */ + ND_PRINT("\n\t advertise 0x%08x", GET_BE_U_4(cp)); + of_bitmap_print(ndo, ofppf_bm, GET_BE_U_4(cp), OFPPF_U); + OF_FWD(4); + /* pad3 */ + /* Always the last field, check bounds. */ + ND_TCHECK_4(cp); +} + /* [OF13] Section 7.5.1 */ static void of13_hello_elements_print(netdissect_options *ndo, @@ -600,6 +723,25 @@ invalid: ND_TCHECK_LEN(cp, len); } +/* [OF13] Section 7.5.4 */ +static void +of13_experimenter_message_print(netdissect_options *ndo, + const u_char *cp, u_int len) +{ + uint32_t experimenter; + + /* experimenter */ + experimenter = GET_BE_U_4(cp); + OF_FWD(4); + ND_PRINT("\n\t experimenter 0x%08x (%s)", experimenter, + of_vendor_name(experimenter)); + /* exp_type */ + ND_PRINT(", exp_type 0x%08x", GET_BE_U_4(cp)); + OF_FWD(4); + /* data */ + of_data_print(ndo, cp, len); +} + /* [OF13] Section A.4.4 */ static void of13_error_print(netdissect_options *ndo, @@ -636,6 +778,7 @@ of13_message_print(netdissect_options *ndo, case OFPT_GET_CONFIG_REQUEST: /* [OF13] Section A.3.2 */ case OFPT_BARRIER_REQUEST: /* [OF13] Section A.3.8 */ case OFPT_BARRIER_REPLY: /* ibid */ + case OFPT_GET_ASYNC_REQUEST: /* [OF13] Section 7.3.10 */ if (len) goto invalid; return; @@ -661,6 +804,21 @@ of13_message_print(netdissect_options *ndo, /* Always the last field, check bounds. */ ND_TCHECK_4(cp); return; + case OFPT_GET_CONFIG_REPLY: /* [OF13] Section 7.3.2 */ + case OFPT_SET_CONFIG: /* ibid */ + if (len != OF_SWITCH_CONFIG_MSG_FIXLEN - OF_HEADER_FIXLEN) + goto invalid; + if (ndo->ndo_vflag < 1) + break; + of13_switch_config_msg_print(ndo, cp, len); + return; + case OFPT_PORT_MOD: /* [OF13] Section 7.3.4.3 */ + if (len != OF_PORT_MOD_FIXLEN - OF_HEADER_FIXLEN) + goto invalid; + if (ndo->ndo_vflag < 1) + break; + of13_port_mod_print(ndo, cp, len); + return; /* OpenFlow header and variable-size data. */ case OFPT_ECHO_REQUEST: /* [OF13] Section A.5.2 */ @@ -685,6 +843,13 @@ of13_message_print(netdissect_options *ndo, break; of13_error_print(ndo, cp, len); return; + case OFPT_EXPERIMENTER: /* [OF13] Section 7.5.4 */ + if (len < OF_EXPERIMENTER_MSG_MINLEN - OF_HEADER_FIXLEN) + goto invalid; + if (ndo->ndo_vflag < 1) + break; + of13_experimenter_message_print(ndo, cp, len); + return; } /* * Not a recognised type or did not print the details, fall back to diff --git a/print-openflow.c b/print-openflow.c index 5b9b7614..935c6526 100644 --- a/print-openflow.c +++ b/print-openflow.c @@ -64,6 +64,9 @@ const struct tok onf_exp_str[] = { { ONF_EXP_WMOB, "Wireless and Mobility Extensions" }, { ONF_EXP_FABS, "Forwarding Abstractions Extensions" }, { ONF_EXP_OTRANS, "Optical Transport Extensions" }, + { ONF_EXP_NBLNCTU, "Network Benchmarking Lab, NCTU" }, + { ONF_EXP_MPCE, "Mobile Packet Core Extensions" }, + { ONF_EXP_MPLSTPSPTN, "MPLS-TP OpenFlow Extensions for SPTN" }, { 0, NULL } }; diff --git a/tests/of13_ericsson-v.out b/tests/of13_ericsson-v.out index b022be4d..f1ed98ce 100644 --- a/tests/of13_ericsson-v.out +++ b/tests/of13_ericsson-v.out @@ -109,6 +109,7 @@ 41 15:41:10.777155 IP (tos 0x0, ttl 64, id 14454, offset 0, flags [DF], proto TCP (6), length 68) 127.0.0.1.6633 > 127.0.0.1.58445: Flags [P.], cksum 0xfe38 (incorrect -> 0x994a), seq 2142345193:2142345209, ack 115176160, win 94, options [nop,nop,TS val 175830 ecr 174634], length 16: OpenFlow version 1.3, type EXPERIMENTER, length 16, xid 0x00000041 + experimenter 0x00d0f0db (Ericsson), exp_type 0x00000065 42 15:41:10.782182 IP (tos 0x0, ttl 64, id 51401, offset 0, flags [DF], proto TCP (6), length 80) 127.0.0.1.58445 > 127.0.0.1.6633: Flags [P.], cksum 0xfe44 (incorrect -> 0x9024), seq 1:29, ack 16, win 86, options [nop,nop,TS val 175831 ecr 175830], length 28: OpenFlow version 1.3, type ERROR, length 28, xid 0x00000041 @@ -127,6 +128,8 @@ 47 15:41:11.640555 IP (tos 0x0, ttl 64, id 14458, offset 0, flags [DF], proto TCP (6), length 85) 127.0.0.1.6633 > 127.0.0.1.58445: Flags [P.], cksum 0xfe49 (incorrect -> 0x4af3), seq 24:57, ack 37, win 94, options [nop,nop,TS val 176046 ecr 175881], length 33: OpenFlow version 1.3, type EXPERIMENTER, length 33, xid 0x00000043 + experimenter 0x00d0f0db (Ericsson), exp_type 0x00000065 + data (17 octets) 48 15:41:11.649632 IP (tos 0x0, ttl 64, id 51403, offset 0, flags [DF], proto TCP (6), length 97) 127.0.0.1.58445 > 127.0.0.1.6633: Flags [P.], cksum 0xfe55 (incorrect -> 0x45af), seq 37:82, ack 57, win 86, options [nop,nop,TS val 176048 ecr 176046], length 45: OpenFlow version 1.3, type ERROR, length 45, xid 0x00000043 @@ -155,6 +158,7 @@ 56 16:32:34.844806 IP (tos 0x0, ttl 64, id 44799, offset 0, flags [DF], proto TCP (6), length 64) 127.0.0.1.6633 > 127.0.0.1.58447: Flags [P.], cksum 0xfe34 (incorrect -> 0x3760), seq 8:20, ack 9, win 94, options [nop,nop,TS val 946847 ecr 946792], length 12: OpenFlow version 1.3, type SET_CONFIG, length 12, xid 0x0000002f + flags FRAG_REASM, miss_send_len 200 57 16:32:34.883698 IP (tos 0x0, ttl 64, id 3494, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.58447 > 127.0.0.1.6633: Flags [.], cksum 0xfe28 (incorrect -> 0x3c3d), ack 20, win 86, options [nop,nop,TS val 946857 ecr 946847], length 0 58 16:32:36.376083 IP (tos 0x0, ttl 64, id 44800, offset 0, flags [DF], proto TCP (6), length 60) @@ -165,6 +169,7 @@ 60 16:32:36.378403 IP (tos 0x0, ttl 64, id 3496, offset 0, flags [DF], proto TCP (6), length 64) 127.0.0.1.58447 > 127.0.0.1.6633: Flags [P.], cksum 0xfe34 (incorrect -> 0x3420), seq 9:21, ack 28, win 86, options [nop,nop,TS val 947230 ecr 947230], length 12: OpenFlow version 1.3, type GET_CONFIG_REPLY, length 12, xid 0x00000030 + flags FRAG_DROP, miss_send_len 200 61 16:32:36.378465 IP (tos 0x0, ttl 64, id 44801, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.6633 > 127.0.0.1.58447: Flags [.], cksum 0xfe28 (incorrect -> 0x392d), ack 21, win 94, options [nop,nop,TS val 947230 ecr 947230], length 0 62 17:39:10.589931 IP (tos 0x0, ttl 64, id 28700, offset 0, flags [DF], proto TCP (6), length 60) @@ -399,6 +404,10 @@ 149 19:53:23.472776 IP (tos 0x0, ttl 64, id 17917, offset 0, flags [DF], proto TCP (6), length 92) 127.0.0.1.6633 > 127.0.0.1.51984: Flags [P.], cksum 0xfe50 (incorrect -> 0xb18a), seq 936:976, ack 1361, win 98, options [nop,nop,TS val 6303167 ecr 6302673], length 40: OpenFlow version 1.3, type PORT_MOD, length 40, xid 0x000000d4 + port_no 1, hw_addr 0a:ea:83:10:db:09 + config 0x00000040 (NO_PACKET_IN) + mask 0x00000040 (NO_PACKET_IN) + advertise 0x0000080a (10MB_FD, 100MB_FD, COPPER) 150 19:53:23.473744 IP (tos 0x0, ttl 64, id 23790, offset 0, flags [DF], proto TCP (6), length 132) 127.0.0.1.51984 > 127.0.0.1.6633: Flags [P.], cksum 0xfe78 (incorrect -> 0x92a0), seq 1361:1441, ack 976, win 86, options [nop,nop,TS val 6303167 ecr 6303167], length 80: OpenFlow version 1.3, type PORT_STATUS, length 80, xid 0x00000000 diff --git a/tests/of13_ericsson-vv.out b/tests/of13_ericsson-vv.out index ef6c4846..bdba0e71 100644 --- a/tests/of13_ericsson-vv.out +++ b/tests/of13_ericsson-vv.out @@ -148,6 +148,7 @@ 41 15:41:10.777155 IP (tos 0x0, ttl 64, id 14454, offset 0, flags [DF], proto TCP (6), length 68) 127.0.0.1.6633 > 127.0.0.1.58445: Flags [P.], cksum 0xfe38 (incorrect -> 0x994a), seq 2142345193:2142345209, ack 115176160, win 94, options [nop,nop,TS val 175830 ecr 174634], length 16: OpenFlow version 1.3, type EXPERIMENTER, length 16, xid 0x00000041 + experimenter 0x00d0f0db (Ericsson), exp_type 0x00000065 42 15:41:10.782182 IP (tos 0x0, ttl 64, id 51401, offset 0, flags [DF], proto TCP (6), length 80) 127.0.0.1.58445 > 127.0.0.1.6633: Flags [P.], cksum 0xfe44 (incorrect -> 0x9024), seq 1:29, ack 16, win 86, options [nop,nop,TS val 175831 ecr 175830], length 28: OpenFlow version 1.3, type ERROR, length 28, xid 0x00000041 @@ -167,6 +168,10 @@ 47 15:41:11.640555 IP (tos 0x0, ttl 64, id 14458, offset 0, flags [DF], proto TCP (6), length 85) 127.0.0.1.6633 > 127.0.0.1.58445: Flags [P.], cksum 0xfe49 (incorrect -> 0x4af3), seq 24:57, ack 37, win 94, options [nop,nop,TS val 176046 ecr 175881], length 33: OpenFlow version 1.3, type EXPERIMENTER, length 33, xid 0x00000043 + experimenter 0x00d0f0db (Ericsson), exp_type 0x00000065 + data (17 octets) + 0x0000: 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f ................ + 0x0010: 10 . 48 15:41:11.649632 IP (tos 0x0, ttl 64, id 51403, offset 0, flags [DF], proto TCP (6), length 97) 127.0.0.1.58445 > 127.0.0.1.6633: Flags [P.], cksum 0xfe55 (incorrect -> 0x45af), seq 37:82, ack 57, win 86, options [nop,nop,TS val 176048 ecr 176046], length 45: OpenFlow version 1.3, type ERROR, length 45, xid 0x00000043 @@ -198,6 +203,7 @@ 56 16:32:34.844806 IP (tos 0x0, ttl 64, id 44799, offset 0, flags [DF], proto TCP (6), length 64) 127.0.0.1.6633 > 127.0.0.1.58447: Flags [P.], cksum 0xfe34 (incorrect -> 0x3760), seq 8:20, ack 9, win 94, options [nop,nop,TS val 946847 ecr 946792], length 12: OpenFlow version 1.3, type SET_CONFIG, length 12, xid 0x0000002f + flags FRAG_REASM, miss_send_len 200 57 16:32:34.883698 IP (tos 0x0, ttl 64, id 3494, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.58447 > 127.0.0.1.6633: Flags [.], cksum 0xfe28 (incorrect -> 0x3c3d), seq 9, ack 20, win 86, options [nop,nop,TS val 946857 ecr 946847], length 0 58 16:32:36.376083 IP (tos 0x0, ttl 64, id 44800, offset 0, flags [DF], proto TCP (6), length 60) @@ -208,6 +214,7 @@ 60 16:32:36.378403 IP (tos 0x0, ttl 64, id 3496, offset 0, flags [DF], proto TCP (6), length 64) 127.0.0.1.58447 > 127.0.0.1.6633: Flags [P.], cksum 0xfe34 (incorrect -> 0x3420), seq 9:21, ack 28, win 86, options [nop,nop,TS val 947230 ecr 947230], length 12: OpenFlow version 1.3, type GET_CONFIG_REPLY, length 12, xid 0x00000030 + flags FRAG_DROP, miss_send_len 200 61 16:32:36.378465 IP (tos 0x0, ttl 64, id 44801, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.6633 > 127.0.0.1.58447: Flags [.], cksum 0xfe28 (incorrect -> 0x392d), seq 28, ack 21, win 94, options [nop,nop,TS val 947230 ecr 947230], length 0 62 17:39:10.589931 IP (tos 0x0, ttl 64, id 28700, offset 0, flags [DF], proto TCP (6), length 60) @@ -442,6 +449,10 @@ 149 19:53:23.472776 IP (tos 0x0, ttl 64, id 17917, offset 0, flags [DF], proto TCP (6), length 92) 127.0.0.1.6633 > 127.0.0.1.51984: Flags [P.], cksum 0xfe50 (incorrect -> 0xb18a), seq 936:976, ack 1361, win 98, options [nop,nop,TS val 6303167 ecr 6302673], length 40: OpenFlow version 1.3, type PORT_MOD, length 40, xid 0x000000d4 + port_no 1, hw_addr 0a:ea:83:10:db:09 + config 0x00000040 (NO_PACKET_IN) + mask 0x00000040 (NO_PACKET_IN) + advertise 0x0000080a (10MB_FD, 100MB_FD, COPPER) 150 19:53:23.473744 IP (tos 0x0, ttl 64, id 23790, offset 0, flags [DF], proto TCP (6), length 132) 127.0.0.1.51984 > 127.0.0.1.6633: Flags [P.], cksum 0xfe78 (incorrect -> 0x92a0), seq 1361:1441, ack 976, win 86, options [nop,nop,TS val 6303167 ecr 6303167], length 80: OpenFlow version 1.3, type PORT_STATUS, length 80, xid 0x00000000