flow->actions, flow->n_actions);
} else {
dp_output_control(chain->dp, skb, fwd_save_skb(skb),
- chain->dp->miss_send_len, OFPR_NO_MATCH);
+ chain->dp->miss_send_len,
+ OFPR_NO_MATCH);
}
}
}
static int
-recv_control_hello(struct sw_chain *chain, const void *msg)
+recv_features_request(struct sw_chain *chain, const struct sender *sender,
+ const void *msg)
{
- const struct ofp_control_hello *och = msg;
-
- printk("control_hello(version=%d)\n", ntohl(och->version));
+ return dp_send_features_reply(chain->dp, sender);
+}
- if (ntohs(och->miss_send_len) != OFP_MISS_SEND_LEN_UNCHANGED) {
- chain->dp->miss_send_len = ntohs(och->miss_send_len);
- }
+static int
+recv_get_config_request(struct sw_chain *chain, const struct sender *sender,
+ const void *msg)
+{
+ return dp_send_config_reply(chain->dp, sender);
+}
- chain->dp->hello_flags = ntohs(och->flags);
+static int
+recv_set_config(struct sw_chain *chain, const struct sender *sender,
+ const void *msg)
+{
+ const struct ofp_switch_config *osc = msg;
- dp_send_hello(chain->dp);
+ chain->dp->flags = ntohs(osc->flags);
+ chain->dp->miss_send_len = ntohs(osc->miss_send_len);
return 0;
}
static int
-recv_packet_out(struct sw_chain *chain, const void *msg)
+recv_packet_out(struct sw_chain *chain, const struct sender *sender,
+ const void *msg)
{
const struct ofp_packet_out *opo = msg;
struct sk_buff *skb;
}
static int
-recv_port_mod(struct sw_chain *chain, const void *msg)
+recv_port_mod(struct sw_chain *chain, const struct sender *sender,
+ const void *msg)
{
const struct ofp_port_mod *opm = msg;
/* Fill out flow. */
flow_extract_match(&flow->key, &ofm->match);
- flow->group_id = ntohl(ofm->group_id);
flow->max_idle = ntohs(ofm->max_idle);
+ flow->priority = ntohs(ofm->priority);
flow->timeout = jiffies + flow->max_idle * HZ;
flow->n_actions = n_acts;
flow->init_time = jiffies;
}
static int
-recv_flow(struct sw_chain *chain, const void *msg)
+recv_flow(struct sw_chain *chain, const struct sender *sender, const void *msg)
{
const struct ofp_flow_mod *ofm = msg;
uint16_t command = ntohs(ofm->command);
} else if (command == OFPFC_DELETE) {
struct sw_flow_key key;
flow_extract_match(&key, &ofm->match);
- return chain_delete(chain, &key, 0) ? 0 : -ESRCH;
+ return chain_delete(chain, &key, 0, 0) ? 0 : -ESRCH;
} else if (command == OFPFC_DELETE_STRICT) {
struct sw_flow_key key;
flow_extract_match(&key, &ofm->match);
- return chain_delete(chain, &key, 1) ? 0 : -ESRCH;
+ return chain_delete(chain, &key, ntohs(ofm->priority), 1) ? 0 : -ESRCH;
} else {
return -ENOTSUPP;
}
}
-/* 'msg', which is 'length' bytes long, was received from the control path.
- * Apply it to 'chain'. */
+static int
+recv_port_stats_request(struct sw_chain *chain, const struct sender *sender,
+ const void *msg)
+{
+ return dp_send_port_stats(chain->dp, sender);
+}
+
+static int
+recv_table_stats_request(struct sw_chain *chain, const struct sender *sender,
+ const void *msg)
+{
+ return dp_send_table_stats(chain->dp, sender);
+}
+
+/* 'msg', which is 'length' bytes long, was received across Netlink from
+ * 'sender'. Apply it to 'chain'. */
int
-fwd_control_input(struct sw_chain *chain, const void *msg, size_t length)
+fwd_control_input(struct sw_chain *chain, const struct sender *sender,
+ const void *msg, size_t length)
{
struct openflow_packet {
size_t min_size;
- int (*handler)(struct sw_chain *, const void *);
+ int (*handler)(struct sw_chain *, const struct sender *,
+ const void *);
};
static const struct openflow_packet packets[] = {
- [OFPT_CONTROL_HELLO] = {
- sizeof (struct ofp_control_hello),
- recv_control_hello,
+ [OFPT_FEATURES_REQUEST] = {
+ sizeof (struct ofp_header),
+ recv_features_request,
+ },
+ [OFPT_GET_CONFIG_REQUEST] = {
+ sizeof (struct ofp_header),
+ recv_get_config_request,
+ },
+ [OFPT_SET_CONFIG] = {
+ sizeof (struct ofp_switch_config),
+ recv_set_config,
},
[OFPT_PACKET_OUT] = {
sizeof (struct ofp_packet_out),
sizeof (struct ofp_port_mod),
recv_port_mod,
},
+ [OFPT_PORT_STATS_REQUEST] = {
+ sizeof (struct ofp_port_stats_request),
+ recv_port_stats_request,
+ },
+ [OFPT_TABLE_STATS_REQUEST] = {
+ sizeof (struct ofp_table_stats_request),
+ recv_table_stats_request,
+ },
};
const struct openflow_packet *pkt;
struct ofp_header *oh;
- if (length < sizeof(struct ofp_header))
- return -EINVAL;
-
oh = (struct ofp_header *) msg;
- if (oh->version != 1 || oh->type >= ARRAY_SIZE(packets)
+ if (oh->version != OFP_VERSION || oh->type >= ARRAY_SIZE(packets)
|| ntohs(oh->length) > length)
return -EINVAL;
if (length < pkt->min_size)
return -EFAULT;
- return pkt->handler(chain, msg);
+ return pkt->handler(chain, sender, msg);
}
/* Packet buffering. */