Book Image

OpenFlow Cookbook

Book Image

OpenFlow Cookbook

Overview of this book

Table of Contents (17 chapters)
16
Index

Handling a switch configuration message from the controller

Switch configuration messages are used by the controller to set and get switch configuration parameters.

The Switch should be able to handle OFPT_SET_CONFIG and OFPT_GET_CONFIG messages from the controller and should reply back with OFPT_GET_CONFIG_REPLY messages to the controller.

Tip

OFPT_SET_CONFIG and OFPT_GET_CONFIG messages are sent from the controller to the switch whereas the OFPT_GET_CONFIG message is sent from the switch to the controller.

How to do it...

On reception of an OFPT_GET_CONFIG_REQUEST message, the switch should prepare an OFPT_GET_CONFIG_REPLY message and send it to the controller.

The OFPT_GET_CONFIG_REQUEST message doesn't contain a body other than an OpenFlow header which is defined in the OpenFlow Header section of the Appendix.

The OFPT_GET_CONFIG_REPLY message uses the following message format:

/* Switch configuration. */
struct ofp_switch_config {
struct ofp_header header;
uint16_t flags;           /* Bitmap of OFPC_* flags. */
uint16_t miss_send_len;   /* Max bytes of packet that datapath
                             should send to the controller.*/
};
How to do it...

The flags take the value as:

enum ofp_config_flags {
/* Handling of IP fragments. */
OFPC_FRAG_NORMAL = 0,     /* No special handling for fragments. */
OFPC_FRAG_DROP = 1 << 0,  /* Drop fragments. */
OFPC_FRAG_REASM = 1 << 1, /* Reassemble (only if OFPC_IP_REASM set). */
OFPC_FRAG_MASK = 3,
};

The value in miss_send_len should be set to the switch's current maximum bytes of data that will be sent to the controller while sending buffered packets. By default this value is 128 bits.

The flag value should be set to the configured value of the IP fragment detail.

On reception of OFPT_SET_CONFIG, which has the same message format as that of OFPT_GET_CONFIG_REPLY, the switch should set the value of miss_send_len and IP fragment related details.

Tip

The switch need not send a reply message to the OFPT_SET_CONFIG message.

The procedure to handle OFPT_GET_CONFIG_REQUEST is as follows;

handle_get_config_message (struct ofp_header get_config_request)
{
  struct ofp_switch_config config_reply;
  features_reply.flags = htons(supported_flags);
  features_reply.miss_send_len = 128; /* default value */
  send_openflow_message (connection, config_reply);
  /* The send_openflow_message function adds the OF header */
}

See also

  • For more information about sending the switch configuration message from the controller, refer to the Sending a switch configuration message to the switch recipe of Chapter 1, OpenFlow Channel Connection Establishment (Part 2)