【sdn】openflow1.3学习笔记(二)

【sdn】openflow1.3学习笔记(二)_第1张图片

OpenFlow 系列文章链接归类:

【sdn】openflow1.3学习笔记(一)


文章目录

  • OpenFlow 系列文章链接归类:
  • 前言
  • 五、OpenFlow channel
    • controller-to-switch
    • Asynchronize
    • Symmetric
    • 多控制器模式
      • 多控制器的角色:
      • 辅助连接
      • openflow 的一些结构体
  • controller-to-switch 消息
  • Error Message
  • 参考


前言

   在这篇文章里我们了解一下openflow1.3的全部特性

五、OpenFlow channel

   openflow channel 是openflow-switch和controller之间的一套接口,通过这套接口,controller能够下发配置给openflow-switch,接受从openflow-switch报告回来的事件,以及下发packet-out消息。

   openflow channel 支持三种类型的消息:

  • 控制器发往switch(controller-to-switch):由控制器发起,用于控制器直接管理或配置交换机。
  • 异步(asynchronous):由交换机发起,向控制器上报事件或者交换机的变化。
  • 同步(symmetric):控制器、交换机 双方均可发起,

controller-to-switch

controller-to-switch 模式的消息:

  • feature:发送给交换机关于开启特性功能的请求,交换机会给控制器response,feature消息常常发生在创建openflow channel时。
  • configuration: 控制器可以查询或者设定交换机配置,交换机会回复查询消息。
  • modify-state:增删改流表内的 flow / group 或者设定switch port配置
  • read-state:读取交换机内的不同信息,诸如:当前配置,统计数据,功能。
  • packet-out:转发通过packet-in接收到的包,packet-out消息要么包含整个packet的内容,要么指定buffer-id标记包,packet-out消息中必须包含action,空的action会被drop。
  • barrier:用于确保消息依赖关系已经满足或接收操作完成的通知。
  • role-request: 用于控制器去设定openflow channel的角色,常用于一台交换机连接了多个控制器
  • asynchronous-configuration: 希望在OpenFlow通道上接收的异步消息上设置一个额外的过滤器,或者查询该过滤器,常用于一台交换机连接了多个控制器,在建立openflow channel时下发。

Asynchronize

Asynchronize模式的消息:

  • Packet-in: 将当前的pkt发送给控制器,如果交换机有能力缓存报文且有足够内存缓存,可以使用buffer-id来标记该报文,此时,只需将buffer-id和部分pkt header传给控制器即可,减少了上报报文的大小,当控制器下发packet-out消息时,指定buffer-id为之前的ID,即可在交换机中找到之前缓存的报文,进行下一步转发。缓存的数据包缓存一定时间后会做过期处理drop掉。不支持缓存报文或者内存大小不足的交换机,只能将完整报文发送给控制器进行处理。
  • flow-removed: 通知控制器 流表里删除了一条流,该msg里会带上 OFPFF_SEND_FLOW_REM 标记位,以及删除结果或者流过期结果。
  • port-status: 通知控制器关于port的配置或者状态变化,比如port被用户手动down掉,或者port自身出问题down掉
  • error: 向控制器通知一些error信息。

Symmetric

Symmetric模式的消息:

  • Hello:交换机和控制器之间在连接启动时交换Hello消息
  • Echo: Echo request/reply消息可以从交换机或控制器发送,且必须返回一个Echo reply。它们主要用于验证控制器-交换机连接的有效性,也可以用于测量其延迟或带宽。
  • Experimenter:这是一个用于未来OpenFlow修订的特性的暂存区。

多控制器模式

多控制器的角色:

  • OFPCR_ROLE_EQUAL:每个控制器都有操控交换机的全部权限,每个控制器都会接收到所有的交换机异步消息,交换机无需进行控制器的资源仲裁或平衡。
  • OFPCR_ROLE_SLAVE:控制器只有只读权限,异步消息通常只会接收到port-status,当slave角色下发改变switch状态的controller-to-switch消息时(OFPT_PACKET_OUT, OFPT_FLOW_MOD, OFPT_GROUP_MOD, OFPT_PORT_MOD, OFPT_TABLE_MOD),会接到OFPT_ERROR。
  • OFPCR_ROLE_MASTER:成为master的控制器拥有全部权限,一个switch只允许有一台master,成为master之后会将除了本身其他所有的控制器变为slave。

多控制器场景下,controller可以设定不同的controller接受特定的消息,这样就可以在master上屏蔽某些不想监听的消息,卸载到从控制器上进行监听。

辅助连接

   默认情况下,OpenFlow交换机和OpenFlow控制器之间的OpenFlow通道是一个单一的网络连接。OpenFlow通道也可以由一个主连接和多个辅助连接组成。辅助连接由OpenFlow交换机创建,有助于提高交换机处理性能并利用大多数交换机实现的并行性。
  辅助连接用datapath ID 和 auxiliary ID 进行一个唯一标识,主链接 auxiliary ID 为0,辅助连接必须使用与主连接相同的源IP,目的IP可以在交换机上配置与主连接不同
  只有在相应的主连接是活的时候,它才必须与控制器建立和保持辅助连接。辅助连接的连接设置与主连接相同。如果交换机检测到与某个控制器的主连接断开,它必须立即关闭与该控制器的所有辅助连接,使控制器能够正确解决Datapath ID冲突。

openflow 的一些结构体

/* Header on all OpenFlow packets. */
struct ofp_header {
    uint8_t version; /* OFP_VERSION. */
    uint8_t type; /* One of the OFPT_ constants. */
    uint16_t length; /* Length including this ofp_header. */
    uint32_t xid; /* Transaction id associated with this packet.
    Replies use the same id as was in the request
    to facilitate pairing. */
};
OFP_ASSERT(sizeof(struct ofp_header) == 8);
enum ofp_type {
    /* Immutable messages. */
    OFPT_HELLO = 0, /* Symmetric message */
    OFPT_ERROR = 1, /* Symmetric message */
    OFPT_ECHO_REQUEST = 2, /* Symmetric message */
    OFPT_ECHO_REPLY = 3, /* Symmetric message */
    OFPT_EXPERIMENTER = 4, /* Symmetric message */
    /* Switch configuration messages. */
    OFPT_FEATURES_REQUEST = 5, /* Controller/switch message */
    OFPT_FEATURES_REPLY = 6, /* Controller/switch message */
    OFPT_GET_CONFIG_REQUEST = 7, /* Controller/switch message */
    OFPT_GET_CONFIG_REPLY = 8, /* Controller/switch message */
    OFPT_SET_CONFIG = 9, /* Controller/switch message */
    /* Asynchronous messages. */
    OFPT_PACKET_IN = 10, /* Async message */
    OFPT_FLOW_REMOVED = 11, /* Async message */
    OFPT_PORT_STATUS = 12, /* Async message */
    /* Controller command messages. */
    OFPT_PACKET_OUT = 13, /* Controller/switch message */
    OFPT_FLOW_MOD = 14, /* Controller/switch message */
    OFPT_GROUP_MOD = 15, /* Controller/switch message */
    OFPT_PORT_MOD = 16, /* Controller/switch message */
    OFPT_TABLE_MOD = 17, /* Controller/switch message */
    /* Multipart messages. */
    OFPT_MULTIPART_REQUEST = 18, /* Controller/switch message */
    OFPT_MULTIPART_REPLY = 19, /* Controller/switch message */
    /* Barrier messages. */
    OFPT_BARRIER_REQUEST = 20, /* Controller/switch message */
    OFPT_BARRIER_REPLY = 21, /* Controller/switch message */
    /* Queue Configuration messages. */
    OFPT_QUEUE_GET_CONFIG_REQUEST = 22, /* Controller/switch message */
    OFPT_QUEUE_GET_CONFIG_REPLY = 23, /* Controller/switch message */
    /* Controller role change request messages. */
    OFPT_ROLE_REQUEST = 24, /* Controller/switch message */
    OFPT_ROLE_REPLY = 25, /* Controller/switch message */
    /* Asynchronous message configuration. */
    OFPT_GET_ASYNC_REQUEST = 26, /* Controller/switch message */
    OFPT_GET_ASYNC_REPLY = 27, /* Controller/switch message */
    OFPT_SET_ASYNC = 28, /* Controller/switch message */
    /* Meters and rate limiters configuration messages. */
    OFPT_METER_MOD = 29, /* Controller/switch message */
};
/* Description of a port */
struct ofp_port {
    uint32_t port_no;
    uint8_t pad[4];
    uint8_t hw_addr[OFP_ETH_ALEN];
    uint8_t pad2[2]; /* Align to 64 bits. */
    char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
    uint32_t config; /* Bitmap of OFPPC_* flags. */
    uint32_t state; /* Bitmap of OFPPS_* flags. */
    /* Bitmaps of OFPPF_* that describe features. All bits zeroed if
    * unsupported or unavailable. */
    uint32_t curr; /* Current features. */
    uint32_t advertised; /* Features being advertised by the port. */
    uint32_t supported; /* Features supported by the port. */
    uint32_t peer; /* Features advertised by peer. */
    uint32_t curr_speed; /* Current port bitrate in kbps. */
    uint32_t max_speed; /* Max port bitrate in kbps */
};
OFP_ASSERT(sizeof(struct ofp_port) == 64);
/* Full description for a queue. */
struct ofp_packet_queue {
    uint32_t queue_id; /* id for the specific queue. */
    uint32_t port; /* Port this queue is attached to. */
    uint16_t len; /* Length in bytes of this queue desc. */
    uint8_t pad[6]; /* 64-bit alignment. */
    struct ofp_queue_prop_header properties[0]; /* List of properties. */
};

OpenFlow交换机通过简单的排队机制实现QoS

/* Common description for a queue. */
struct ofp_queue_prop_header {
    uint16_t property; /* One of OFPQT_. */
    uint16_t len; /* Length of property, including this header. */
    uint8_t pad[4]; /* 64-bit alignemnt. */
};
OFP_ASSERT(sizeof(struct ofp_queue_prop_header) == 8);
/* Min-Rate queue property description. */
struct ofp_queue_prop_min_rate {
    struct ofp_queue_prop_header prop_header; /* prop: OFPQT_MIN, len: 16. */
    uint16_t rate; /* In 1/10 of a percent; >1000 -> disabled. */
    uint8_t pad[6]; /* 64-bit alignment */
};
OFP_ASSERT(sizeof(struct ofp_queue_prop_min_rate) == 16);
/* Max-Rate queue property description. */
struct ofp_queue_prop_max_rate {
    struct ofp_queue_prop_header prop_header; /* prop: OFPQT_MAX, len: 16. */
    uint16_t rate; /* In 1/10 of a percent; >1000 -> disabled. */
    uint8_t pad[6]; /* 64-bit alignment */
};
OFP_ASSERT(sizeof(struct ofp_queue_prop_max_rate) == 16);
/* Experimenter queue property description. */
struct ofp_queue_prop_experimenter {
   struct ofp_queue_prop_header prop_header; /* prop: OFPQT_EXPERIMENTER, len: 16. */
   uint32_t experimenter; /* Experimenter ID which takes the same
   form as in struct
   ofp_experimenter_header. */
   uint8_t pad[4]; /* 64-bit alignment */
   uint8_t data[0]; /* Experimenter defined data. */
};
OFP_ASSERT(sizeof(struct ofp_queue_prop_experimenter) == 16);

流匹配:

/* Fields to match against flows */
struct ofp_match {
    uint16_t type; /* One of OFPMT_* */
    uint16_t length; /* Length of ofp_match (excluding padding) */
    /* Followed by:
    * - Exactly (length - 4) (possibly 0) bytes containing OXM TLVs, then
    * - Exactly ((length + 7)/8*8 - length) (between 0 and 7) bytes of
    * all-zero bytes
    * In summary, ofp_match is padded as needed, to make its overall size
    * a multiple of 8, to preserve alignement in structures using it.
    */
    uint8_t oxm_fields[4]; /* OXMs start here - Make compiler happy */
};
OFP_ASSERT(sizeof(struct ofp_match) == 8);
/* The match type indicates the match structure (set of fields that compose the
* match) in use. The match type is placed in the type field at the beginning
* of all match structures. The "OpenFlow Extensible Match" type corresponds
* to OXM TLV format described below and must be supported by all OpenFlow
* switches. Extensions that define other match types may be published on the
* ONF wiki. Support for extensions is optional.
*/
enum ofp_match_type {
	OFPMT_STANDARD = 0, /* Deprecated. */
	OFPMT_OXM = 1, /* OpenFlow Extensible Match */
};

【sdn】openflow1.3学习笔记(二)_第2张图片
【sdn】openflow1.3学习笔记(二)_第3张图片

/* OXM Class IDs.
* The high order bit differentiate reserved classes from member classes.
* Classes 0x0000 to 0x7FFF are member classes, allocated by ONF.
* Classes 0x8000 to 0xFFFE are reserved classes, reserved for standardisation.
*/
enum ofp_oxm_class {
	OFPXMC_NXM_0 = 0x0000, /* Backward compatibility with NXM */
	OFPXMC_NXM_1 = 0x0001, /* Backward compatibility with NXM */
	OFPXMC_OPENFLOW_BASIC = 0x8000, /* Basic class for OpenFlow */
	OFPXMC_EXPERIMENTER = 0xFFFF, /* Experimenter class */
};
/* OXM Flow match field types for OpenFlow basic class. */
enum oxm_ofb_match_fields {
    OFPXMT_OFB_IN_PORT = 0, /* Switch input port. */
    OFPXMT_OFB_IN_PHY_PORT = 1, /* Switch physical input port. */
    OFPXMT_OFB_METADATA = 2, /* Metadata passed between tables. */
    OFPXMT_OFB_ETH_DST = 3, /* Ethernet destination address. */
    OFPXMT_OFB_ETH_SRC = 4, /* Ethernet source address. */
    OFPXMT_OFB_ETH_TYPE = 5, /* Ethernet frame type. */
    OFPXMT_OFB_VLAN_VID = 6, /* VLAN id. */
    OFPXMT_OFB_VLAN_PCP = 7, /* VLAN priority. */
    OFPXMT_OFB_IP_DSCP = 8, /* IP DSCP (6 bits in ToS field). */
    OFPXMT_OFB_IP_ECN = 9, /* IP ECN (2 bits in ToS field). */
    OFPXMT_OFB_IP_PROTO = 10, /* IP protocol. */
    OFPXMT_OFB_IPV4_SRC = 11, /* IPv4 source address. */
    OFPXMT_OFB_IPV4_DST = 12, /* IPv4 destination address. */
    OFPXMT_OFB_TCP_SRC = 13, /* TCP source port. */
    OFPXMT_OFB_TCP_DST = 14, /* TCP destination port. */
    OFPXMT_OFB_UDP_SRC = 15, /* UDP source port. */
    OFPXMT_OFB_UDP_DST = 16, /* UDP destination port. */
    OFPXMT_OFB_SCTP_SRC = 17, /* SCTP source port. */
    OFPXMT_OFB_SCTP_DST = 18, /* SCTP destination port. */
    OFPXMT_OFB_ICMPV4_TYPE = 19, /* ICMP type. */
    OFPXMT_OFB_ICMPV4_CODE = 20, /* ICMP code. */
    OFPXMT_OFB_ARP_OP = 21, /* ARP opcode. */
    OFPXMT_OFB_ARP_SPA = 22, /* ARP source IPv4 address. */
    OFPXMT_OFB_ARP_TPA = 23, /* ARP target IPv4 address. */
    OFPXMT_OFB_ARP_SHA = 24, /* ARP source hardware address. */
    OFPXMT_OFB_ARP_THA = 25, /* ARP target hardware address. */
    OFPXMT_OFB_IPV6_SRC = 26, /* IPv6 source address. */
    OFPXMT_OFB_IPV6_DST = 27, /* IPv6 destination address. */
    OFPXMT_OFB_IPV6_FLABEL = 28, /* IPv6 Flow Label */
    OFPXMT_OFB_ICMPV6_TYPE = 29, /* ICMPv6 type. */
    OFPXMT_OFB_ICMPV6_CODE = 30, /* ICMPv6 code. */
    OFPXMT_OFB_IPV6_ND_TARGET = 31, /* Target address for ND. */
    OFPXMT_OFB_IPV6_ND_SLL = 32, /* Source link-layer for ND. */
    OFPXMT_OFB_IPV6_ND_TLL = 33, /* Target link-layer for ND. */
    OFPXMT_OFB_MPLS_LABEL = 34, /* MPLS label. */
    OFPXMT_OFB_MPLS_TC = 35, /* MPLS TC. */
    OFPXMT_OFP_MPLS_BOS = 36, /* MPLS BoS bit. */
    OFPXMT_OFB_PBB_ISID = 37, /* PBB I-SID. */
    OFPXMT_OFB_TUNNEL_ID = 38, /* Logical Port Metadata. */
    OFPXMT_OFB_IPV6_EXTHDR = 39, /* IPv6 Extension Header pseudo-field */
};

匹配域的细节表:
【sdn】openflow1.3学习笔记(二)_第4张图片
of指令type:

enum ofp_instruction_type {
	OFPIT_GOTO_TABLE = 1, /* Setup the next table in the lookup
	pipeline */
	OFPIT_WRITE_METADATA = 2, /* Setup the metadata field for use later in
	pipeline */
	OFPIT_WRITE_ACTIONS = 3, /* Write the action(s) onto the datapath action
	set */
	OFPIT_APPLY_ACTIONS = 4, /* Applies the action(s) immediately */
	OFPIT_CLEAR_ACTIONS = 5, /* Clears all actions from the datapath
	action set */
	OFPIT_METER = 6, /* Apply meter (rate limiter) */
	OFPIT_EXPERIMENTER = 0xFFFF /* Experimenter instruction */
};
enum ofp_action_type {
	OFPAT_OUTPUT = 0, /* Output to switch port. */
	OFPAT_COPY_TTL_OUT = 11, /* Copy TTL "outwards" -- from next-to-outermost
	to outermost */
	OFPAT_COPY_TTL_IN = 12, /* Copy TTL "inwards" -- from outermost to
	next-to-outermost */
	OFPAT_SET_MPLS_TTL = 15, /* MPLS TTL */
	OFPAT_DEC_MPLS_TTL = 16, /* Decrement MPLS TTL */
	OFPAT_PUSH_VLAN = 17, /* Push a new VLAN tag */
		OFPAT_POP_VLAN = 18, /* Pop the outer VLAN tag */
	OFPAT_PUSH_MPLS = 19, /* Push a new MPLS tag */
	OFPAT_POP_MPLS = 20, /* Pop the outer MPLS tag */
	OFPAT_SET_QUEUE = 21, /* Set queue id when outputting to a port */
	OFPAT_GROUP = 22, /* Apply group. */
	OFPAT_SET_NW_TTL = 23, /* IP TTL. */
	OFPAT_DEC_NW_TTL = 24, /* Decrement IP TTL. */
	OFPAT_SET_FIELD = 25, /* Set a header field using OXM TLV format. */
	OFPAT_PUSH_PBB = 26, /* Push a new PBB service tag (I-TAG) */
	OFPAT_POP_PBB = 27, /* Pop the outer PBB service tag (I-TAG) */
	OFPAT_EXPERIMENTER = 0xffff
};

controller-to-switch 消息

/* Switch features. */
struct ofp_switch_features {
	struct ofp_header header;
	uint64_t datapath_id; /* Datapath unique ID. The lower 48-bits are for
	a MAC address, while the upper 16-bits are
	implementer-defined. */
	uint32_t n_buffers; /* Max packets buffered at once. */
	uint8_t n_tables; /* Number of tables supported by datapath. */
	uint8_t auxiliary_id; /* Identify auxiliary connections */
	uint8_t pad[2]; /* Align to 64-bits. */
	/* Features. */
	uint32_t capabilities; /* Bitmap of support "ofp_capabilities". */
	uint32_t reserved;
};
OFP_ASSERT(sizeof(struct ofp_switch_features) == 32);
/* Capabilities supported by the datapath. */
enum ofp_capabilities {
	OFPC_FLOW_STATS = 1 << 0, /* Flow statistics. */
	OFPC_TABLE_STATS = 1 << 1, /* Table statistics. */
	OFPC_PORT_STATS = 1 << 2, /* Port statistics. */
	OFPC_GROUP_STATS = 1 << 3, /* Group statistics. */
	OFPC_IP_REASM = 1 << 5, /* Can reassemble IP fragments. */
	OFPC_QUEUE_STATS = 1 << 6, /* Queue statistics. */
	OFPC_PORT_BLOCKED = 1 << 8 /* Switch will block looping ports. */
};

OFPT_GET_CONFIG_REPLY:

/* Switch configuration. */
struct ofp_switch_config {
	struct ofp_header header;
	uint16_t flags; /* OFPC_* flags. */
	uint16_t miss_send_len; /* Max bytes of packet that datapath
	should send to the controller. See
	ofp_controller_max_len for valid values.
	*/
};
OFP_ASSERT(sizeof(struct ofp_switch_config) == 12);
/* Table numbering. Tables can use any number up to OFPT_MAX. */
enum ofp_table {
	/* Last usable table number. */
	OFPTT_MAX = 0xfe,
	/* Fake tables. */
	OFPTT_ALL = 0xff /* Wildcard table used for table config,
	flow stats and flow deletes. */
};
/* Configure/Modify behavior of a flow table */
struct ofp_table_mod {
	struct ofp_header header;
	uint8_t table_id; /* ID of the table, OFPTT_ALL indicates all tables */
	uint8_t pad[3]; /* Pad to 32 bits */
	uint32_t config; /* Bitmap of OFPTC_* flags */
	};
OFP_ASSERT(sizeof(struct ofp_table_mod) == 16);
/* Flow setup and teardown (controller -> datapath). */
struct ofp_flow_mod {
    struct ofp_header header;
    uint64_t cookie; /* Opaque controller-issued identifier. */
    uint64_t cookie_mask; /* Mask used to restrict the cookie bits
    that must match when the command is
    OFPFC_MODIFY* or OFPFC_DELETE*. A value
    of 0 indicates no restriction. */
    /* Flow actions. */
    uint8_t table_id; /* ID of the table to put the flow in.
    For OFPFC_DELETE_* commands, OFPTT_ALL
    can also be used to delete matching
    flows from all tables. */
    uint8_t command; /* One of OFPFC_*. */
    uint16_t idle_timeout; /* Idle time before discarding (seconds). */
    uint16_t hard_timeout; /* Max time before discarding (seconds). */
    uint16_t priority; /* Priority level of flow entry. */
    uint32_t buffer_id; /* Buffered packet to apply to, or
    OFP_NO_BUFFER.
    Not meaningful for OFPFC_DELETE*. */
    uint32_t out_port; /* For OFPFC_DELETE* commands, require
    matching entries to include this as an
    output port. A value of OFPP_ANY
    indicates no restriction. */
    uint32_t out_group; /* For OFPFC_DELETE* commands, require
    matching entries to include this as an
    output group. A value of OFPG_ANY
    indicates no restriction. */
    uint16_t flags; /* One of OFPFF_*. */
    uint8_t pad[2];
    struct ofp_match match; /* Fields to match. Variable size. */
    //struct ofp_instruction instructions[0]; /* Instruction set */
};OFP_ASSERT(sizeof(struct ofp_flow_mod) == 56);
enum ofp_flow_mod_command {
	OFPFC_ADD = 0, /* New flow. */
	OFPFC_MODIFY = 1, /* Modify all matching flows. */
	OFPFC_MODIFY_STRICT = 2, /* Modify entry strictly matching wildcards and
	priority. */
	OFPFC_DELETE = 3, /* Delete all matching flows. */
	OFPFC_DELETE_STRICT = 4, /* Delete entry strictly matching wildcards and
	priority. */
};

Error Message

该部分会经常用到,下发流表时由于违反某些规定而返回的错误:

/* OFPT_ERROR: Error message (datapath -> controller). */
struct ofp_error_msg {
	struct ofp_header header;
	uint16_t type;
	uint16_t code;
	uint8_t data[0]; /* Variable-length data. Interpreted based
	on the type and code. No padding. */
};
OFP_ASSERT(sizeof(struct ofp_error_msg) == 12);
/* Values for ’type’ in ofp_error_message. These values are immutable: they
* will not change in future versions of the protocol (although new values may
* be added). */
enum ofp_error_type {
	OFPET_HELLO_FAILED = 0, /* Hello protocol failed. */
	OFPET_BAD_REQUEST = 1, /* Request was not understood. */
	OFPET_BAD_ACTION = 2, /* Error in action description. */
	OFPET_BAD_INSTRUCTION = 3, /* Error in instruction list. */
	OFPET_BAD_MATCH = 4, /* Error in match. */
	OFPET_FLOW_MOD_FAILED = 5, /* Problem modifying flow entry. */
	OFPET_GROUP_MOD_FAILED = 6, /* Problem modifying group entry. */
	OFPET_PORT_MOD_FAILED = 7, /* Port mod request failed. */
	OFPET_TABLE_MOD_FAILED = 8, /* Table mod request failed. */
	OFPET_QUEUE_OP_FAILED = 9, /* Queue operation failed. */
	OFPET_SWITCH_CONFIG_FAILED = 10, /* Switch config request failed. */
	OFPET_ROLE_REQUEST_FAILED = 11, /* Controller Role request failed. */
	OFPET_METER_MOD_FAILED = 12, /* Error in meter. */
	OFPET_TABLE_FEATURES_FAILED = 13, /* Setting table features failed. */
	OFPET_EXPERIMENTER = 0xffff /* Experimenter error messages. */
};
/* ofp_error_msg ’code’ values for OFPET_HELLO_FAILED. ’data’ contains an
* ASCII text string that may give failure details. */
enum ofp_hello_failed_code {
	OFPHFC_INCOMPATIBLE = 0, /* No compatible version. */
	OFPHFC_EPERM = 1, /* Permissions error. */
};
/* ofp_error_msg ’code’ values for OFPET_BAD_REQUEST. ’data’ contains at least
* the first 64 bytes of the failed request. */
enum ofp_bad_request_code {
	OFPBRC_BAD_VERSION = 0, /* ofp_header.version not supported. */
	OFPBRC_BAD_TYPE = 1, /* ofp_header.type not supported. */
	OFPBRC_BAD_MULTIPART = 2, /* ofp_multipart_request.type not supported. */
	OFPBRC_BAD_EXPERIMENTER = 3, /* Experimenter id not supported
	* (in ofp_experimenter_header or
	* ofp_multipart_request or
	* ofp_multipart_reply). */
	OFPBRC_BAD_EXP_TYPE = 4, /* Experimenter type not supported. */
	OFPBRC_EPERM = 5, /* Permissions error. */
	OFPBRC_BAD_LEN = 6, /* Wrong request length for type. */
	OFPBRC_BUFFER_EMPTY = 7, /* Specified buffer has already been used. */
	OFPBRC_BUFFER_UNKNOWN = 8, /* Specified buffer does not exist. */
	OFPBRC_BAD_TABLE_ID = 9, /* Specified table-id invalid or does not
	* exist. */
	OFPBRC_IS_SLAVE = 10, /* Denied because controller is slave. */
	OFPBRC_BAD_PORT = 11, /* Invalid port. */
	OFPBRC_BAD_PACKET = 12, /* Invalid packet in packet-out. */
	OFPBRC_MULTIPART_BUFFER_OVERFLOW = 13, /* ofp_multipart_request
	overflowed the assigned buffer. */
};
/* ofp_error_msg ’code’ values for OFPET_BAD_ACTION. ’data’ contains at least
* the first 64 bytes of the failed request. */
enum ofp_bad_action_code {
	OFPBAC_BAD_TYPE = 0, /* Unknown action type. */
	OFPBAC_BAD_LEN = 1, /* Length problem in actions. */
	OFPBAC_BAD_EXPERIMENTER = 2, /* Unknown experimenter id specified. */
	OFPBAC_BAD_EXP_TYPE = 3, /* Unknown action for experimenter id. */
	OFPBAC_BAD_OUT_PORT = 4, /* Problem validating output port. */
	OFPBAC_BAD_ARGUMENT = 5, /* Bad action argument. */
	OFPBAC_EPERM = 6, /* Permissions error. */
	OFPBAC_TOO_MANY = 7, /* Can’t handle this many actions. */
	OFPBAC_BAD_QUEUE = 8, /* Problem validating output queue. */
	OFPBAC_BAD_OUT_GROUP = 9, /* Invalid group id in forward action. */
	OFPBAC_MATCH_INCONSISTENT = 10, /* Action can’t apply for this match,
	or Set-Field missing prerequisite. */
	OFPBAC_UNSUPPORTED_ORDER = 11, /* Action order is unsupported for the
	action list in an Apply-Actions instruction */
	OFPBAC_BAD_TAG = 12, /* Actions uses an unsupported
	tag/encap. */
	OFPBAC_BAD_SET_TYPE = 13, /* Unsupported type in SET_FIELD action. */
	OFPBAC_BAD_SET_LEN = 14, /* Length problem in SET_FIELD action. */
	OFPBAC_BAD_SET_ARGUMENT = 15, /* Bad argument in SET_FIELD action. */
};
/* ofp_error_msg ’code’ values for OFPET_BAD_INSTRUCTION. ’data’ contains at least
* the first 64 bytes of the failed request. */
enum ofp_bad_instruction_code {
	OFPBIC_UNKNOWN_INST = 0, /* Unknown instruction. */
	OFPBIC_UNSUP_INST = 1, /* Switch or table does not support the instruction. */
	OFPBIC_BAD_TABLE_ID = 2, /* Invalid Table-ID specified. */
	OFPBIC_UNSUP_METADATA = 3, /* Metadata value unsupported by datapath. */
	OFPBIC_UNSUP_METADATA_MASK = 4, /* Metadata mask value unsupported by
	datapath. */
	OFPBIC_BAD_EXPERIMENTER = 5, /* Unknown experimenter id specified. */
	OFPBIC_BAD_EXP_TYPE = 6, /* Unknown instruction for experimenter id. */
	OFPBIC_BAD_LEN = 7, /* Length problem in instructions. */
	OFPBIC_EPERM = 8, /* Permissions error. */
};
/* ofp_error_msg ’code’ values for OFPET_BAD_MATCH. ’data’ contains at least
* the first 64 bytes of the failed request. */
enum ofp_bad_match_code {
	OFPBMC_BAD_TYPE = 0, /* Unsupported match type specified by the match */
	OFPBMC_BAD_LEN = 1, /* Length problem in match. */
	OFPBMC_BAD_TAG = 2, /* Match uses an unsupported tag/encap. */
	OFPBMC_BAD_DL_ADDR_MASK = 3, /* Unsupported datalink addr mask - switch
	does not support arbitrary datalink
	address mask. */
	OFPBMC_BAD_NW_ADDR_MASK = 4, /* Unsupported network addr mask - switch
	does not support arbitrary network
	address mask. */
	OFPBMC_BAD_WILDCARDS = 5, /* Unsupported combination of fields masked
	or omitted in the match. */
	OFPBMC_BAD_FIELD = 6, /* Unsupported field type in the match. */
	OFPBMC_BAD_VALUE = 7, /* Unsupported value in a match field. */
	OFPBMC_BAD_MASK = 8, /* Unsupported mask specified in the match,
	field is not dl-address or nw-address. */
	OFPBMC_BAD_PREREQ = 9, /* A prerequisite was not met. */
	OFPBMC_DUP_FIELD = 10, /* A field type was duplicated. */
	OFPBMC_EPERM = 11, /* Permissions error. */
};
/* ofp_error_msg ’code’ values for OFPET_FLOW_MOD_FAILED. ’data’ contains
* at least the first 64 bytes of the failed request. */
enum ofp_flow_mod_failed_code {
    OFPFMFC_UNKNOWN = 0, /* Unspecified error. */
    OFPFMFC_TABLE_FULL = 1, /* Flow not added because table was full. */
    OFPFMFC_BAD_TABLE_ID = 2, /* Table does not exist */
    OFPFMFC_OVERLAP = 3, /* Attempted to add overlapping flow with
    CHECK_OVERLAP flag set. */
    OFPFMFC_EPERM = 4, /* Permissions error. */
    OFPFMFC_BAD_TIMEOUT = 5, /* Flow not added because of unsupported
    idle/hard timeout. */
    OFPFMFC_BAD_COMMAND = 6, /* Unsupported or unknown command. */
    OFPFMFC_BAD_FLAGS = 7, /* Unsupported or unknown flags. */
};
/* ofp_error_msg ’code’ values for OFPET_GROUP_MOD_FAILED. ’data’ contains
* at least the first 64 bytes of the failed request. */
enum ofp_group_mod_failed_code {
    OFPGMFC_GROUP_EXISTS = 0, /* Group not added because a group ADD
    attempted to replace an
    already-present group. */
    OFPGMFC_INVALID_GROUP = 1, /* Group not added because Group
    specified is invalid. */
    OFPGMFC_WEIGHT_UNSUPPORTED = 2, /* Switch does not support unequal load
    sharing with select groups. */
    OFPGMFC_OUT_OF_GROUPS = 3, /* The group table is full. */
    OFPGMFC_OUT_OF_BUCKETS = 4, /* The maximum number of action buckets
    for a group has been exceeded. */
    OFPGMFC_CHAINING_UNSUPPORTED = 5, /* Switch does not support groups that
    forward to groups. */
    OFPGMFC_WATCH_UNSUPPORTED = 6, /* This group cannot watch the watch_port
    or watch_group specified. */
    OFPGMFC_LOOP = 7, /* Group entry would cause a loop. */
    OFPGMFC_UNKNOWN_GROUP = 8, /* Group not modified because a group
    MODIFY attempted to modify a
    non-existent group. */
    OFPGMFC_CHAINED_GROUP = 9, /* Group not deleted because another
    group is forwarding to it. */
    OFPGMFC_BAD_TYPE = 10, /* Unsupported or unknown group type. */
    OFPGMFC_BAD_COMMAND = 11, /* Unsupported or unknown command. */
    OFPGMFC_BAD_BUCKET = 12, /* Error in bucket. */
    OFPGMFC_BAD_WATCH = 13, /* Error in watch port/group. */
    OFPGMFC_EPERM = 14, /* Permissions error. */
};
/* ofp_error_msg ’code’ values for OFPET_PORT_MOD_FAILED. ’data’ contains
* at least the first 64 bytes of the failed request. */
enum ofp_port_mod_failed_code {
    OFPPMFC_BAD_PORT = 0, /* Specified port number does not exist. */
    OFPPMFC_BAD_HW_ADDR = 1, /* Specified hardware address does not
    * match the port number. */
    OFPPMFC_BAD_CONFIG = 2, /* Specified config is invalid. */
    OFPPMFC_BAD_ADVERTISE = 3, /* Specified advertise is invalid. */
    OFPPMFC_EPERM = 4, /* Permissions error. */
};
/* ofp_error_msg ’code’ values for OFPET_TABLE_MOD_FAILED. ’data’ contains
* at least the first 64 bytes of the failed request. */
enum ofp_table_mod_failed_code {
    OFPTMFC_BAD_TABLE = 0, /* Specified table does not exist. */
    OFPTMFC_BAD_CONFIG = 1, /* Specified config is invalid. */
    OFPTMFC_EPERM = 2, /* Permissions error. */
};
/* ofp_error msg ’code’ values for OFPET_QUEUE_OP_FAILED. ’data’ contains
* at least the first 64 bytes of the failed request */
enum ofp_queue_op_failed_code {
    OFPQOFC_BAD_PORT = 0, /* Invalid port (or port does not exist). */
    OFPQOFC_BAD_QUEUE = 1, /* Queue does not exist. */
    OFPQOFC_EPERM = 2, /* Permissions error. */
};
/* ofp_error_msg ’code’ values for OFPET_SWITCH_CONFIG_FAILED. ’data’ contains
* at least the first 64 bytes of the failed request. */
enum ofp_switch_config_failed_code {
    OFPSCFC_BAD_FLAGS = 0, /* Specified flags is invalid. */
    OFPSCFC_BAD_LEN = 1, /* Specified len is invalid. */
    OFPQCFC_EPERM = 2, /* Permissions error. */
};
/* ofp_error_msg ’code’ values for OFPET_ROLE_REQUEST_FAILED. ’data’ contains
* at least the first 64 bytes of the failed request. */
enum ofp_role_request_failed_code {
    OFPRRFC_STALE = 0, /* Stale Message: old generation_id. */
    OFPRRFC_UNSUP = 1, /* Controller role change unsupported. */
    OFPRRFC_BAD_ROLE = 2, /* Invalid role. */
};
/* ofp_error_msg ’code’ values for OFPET_METER_MOD_FAILED. ’data’ contains
* at least the first 64 bytes of the failed request. */
enum ofp_meter_mod_failed_code {
    OFPMMFC_UNKNOWN = 0, /* Unspecified error. */
    OFPMMFC_METER_EXISTS = 1, /* Meter not added because a Meter ADD
    * attempted to replace an existing Meter. */
    OFPMMFC_INVALID_METER = 2, /* Meter not added because Meter specified
    * is invalid. */
    OFPMMFC_UNKNOWN_METER = 3, /* Meter not modified because a Meter
    MODIFY attempted to modify a non-existent
    Meter. */
    OFPMMFC_BAD_COMMAND = 4, /* Unsupported or unknown command. */
    OFPMMFC_BAD_FLAGS = 5, /* Flag configuration unsupported. */
    OFPMMFC_BAD_RATE = 6, /* Rate unsupported. */
    OFPMMFC_BAD_BURST = 7, /* Burst size unsupported. */
    OFPMMFC_BAD_BAND = 8, /* Band unsupported. */
    OFPMMFC_BAD_BAND_VALUE = 9, /* Band value unsupported. */
    OFPMMFC_OUT_OF_METERS = 10, /* No more meters available. */
    OFPMMFC_OUT_OF_BANDS = 11, /* The maximum number of properties
    * for a meter has been exceeded. */
    };
    For the OFPET_TABLE_FEATURES_FAILED error type, the following codes are currently defined:
    /* ofp_error_msg ’code’ values for OFPET_TABLE_FEATURES_FAILED. ’data’ contains
    * at least the first 64 bytes of the failed request. */
    enum ofp_table_features_failed_code {
    OFPTFFC_BAD_TABLE = 0, /* Specified table does not exist. */
    OFPTFFC_BAD_METADATA = 1, /* Invalid metadata mask. */
    OFPTFFC_BAD_TYPE = 2, /* Unknown property type. */
    OFPTFFC_BAD_LEN = 3, /* Length problem in properties. */
    OFPTFFC_BAD_ARGUMENT = 4, /* Unsupported property value. */
    OFPTFFC_EPERM = 5, /* Permissions error. */
};
fields, followed by experimenter defined data:
/* OFPET_EXPERIMENTER: Error message (datapath -> controller). */
struct ofp_error_experimenter_msg {
    struct ofp_header header;
    uint16_t type; /* OFPET_EXPERIMENTER. */
    uint16_t exp_type; /* Experimenter defined. */
    uint32_t experimenter; /* Experimenter ID which takes the same form
    as in struct ofp_experimenter_header. */
    uint8_t data[0]; /* Variable-length data. Interpreted based
    on the type and code. No padding. */
};
OFP_ASSERT(sizeof(struct ofp_error_experimenter_msg) == 16);

参考

https://opennetworking.org/wp-content/uploads/2014/10/openflow-spec-v1.3.0.pdf
https://info.support.huawei.com/info-finder/encyclopedia/zh/OpenFlow.html
https://www.cnblogs.com/CasonChan/p/4626099.html

你可能感兴趣的:(sdn,学习,网络)