From: Justin Pettit Date: Wed, 16 Apr 2008 21:09:27 +0000 (-0700) Subject: - Keep datapath config in host-byte order (and fix a couple of bugs related to this). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=541d0fee0dbb7af69f7d33e163838a95bfc021b0;p=openvswitch - Keep datapath config in host-byte order (and fix a couple of bugs related to this). - Fix type for "get config" replies. --- diff --git a/datapath/datapath.c b/datapath/datapath.c index 67c4cf43..432315b1 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -240,8 +240,8 @@ static int new_dp(int dp_idx) printk("datapath: problem setting up 'of' device\n"); #endif - dp->config.flags = 0; - dp->config.miss_send_len = htons(OFP_DEFAULT_MISS_SEND_LEN); + dp->flags = 0; + dp->miss_send_len = OFP_DEFAULT_MISS_SEND_LEN; dp->dp_task = kthread_run(dp_maint_func, dp, "dp%d", dp_idx); if (IS_ERR(dp->dp_task)) @@ -698,13 +698,14 @@ dp_send_config_reply(struct datapath *dp, const struct sender *sender) struct sk_buff *skb; struct ofp_switch_config *osc; - osc = alloc_openflow_skb(dp, sizeof *osc, OFPT_PORT_STATUS, sender, + osc = alloc_openflow_skb(dp, sizeof *osc, OFPT_GET_CONFIG_REPLY, sender, &skb); if (!osc) return -ENOMEM; - memcpy(((char *)osc) + sizeof osc->header, - ((char *)&dp->config) + sizeof dp->config.header, - sizeof dp->config - sizeof dp->config.header); + + osc->flags = htons(dp->flags); + osc->miss_send_len = htons(dp->miss_send_len); + return send_openflow_skb(skb, sender); } diff --git a/datapath/datapath.h b/datapath/datapath.h index d81e2f4c..0da13162 100644 --- a/datapath/datapath.h +++ b/datapath/datapath.h @@ -48,7 +48,9 @@ struct datapath { struct net_device dev; struct net_device_stats stats; - struct ofp_switch_config config; + /* Configuration set from controller */ + uint16_t flags; + uint16_t miss_send_len; /* Switch ports. */ struct net_bridge_port *ports[OFPP_MAX]; diff --git a/datapath/forward.c b/datapath/forward.c index c1b70ca7..6f8636a0 100644 --- a/datapath/forward.c +++ b/datapath/forward.c @@ -41,7 +41,7 @@ void fwd_port_input(struct sw_chain *chain, struct sk_buff *skb, int in_port) flow->actions, flow->n_actions); } else { dp_output_control(chain->dp, skb, fwd_save_skb(skb), - ntohs(chain->dp->config.miss_send_len), + chain->dp->miss_send_len, OFPR_NO_MATCH); } } @@ -275,7 +275,10 @@ recv_set_config(struct sw_chain *chain, const struct sender *sender, const void *msg) { const struct ofp_switch_config *osc = msg; - chain->dp->config = *osc; + + chain->dp->flags = ntohs(osc->flags); + chain->dp->miss_send_len = ntohs(osc->miss_send_len); + return 0; } diff --git a/datapath/table-hash.c b/datapath/table-hash.c index 7847ef13..87d3f650 100644 --- a/datapath/table-hash.c +++ b/datapath/table-hash.c @@ -123,7 +123,7 @@ static int table_hash_timeout(struct datapath *dp, struct sw_table *swt) struct sw_flow *flow = *bucket; if (flow && flow_timeout(flow)) { count += do_delete(bucket, flow); - if (dp->config.flags & OFPC_SEND_FLOW_EXP) + if (dp->flags & OFPC_SEND_FLOW_EXP) dp_send_flow_expired(dp, flow); } } diff --git a/datapath/table-linear.c b/datapath/table-linear.c index 0b60838a..cf0e3f8a 100644 --- a/datapath/table-linear.c +++ b/datapath/table-linear.c @@ -102,7 +102,7 @@ static int table_linear_timeout(struct datapath *dp, struct sw_table *swt) struct sw_flow *flow = list_entry(pos, struct sw_flow, u.node); if (flow_timeout(flow)) { count += do_delete(swt, flow); - if (dp->config.flags & OFPC_SEND_FLOW_EXP) + if (dp->flags & OFPC_SEND_FLOW_EXP) dp_send_flow_expired(dp, flow); } } diff --git a/include/openflow.h b/include/openflow.h index eba5017e..bc2e432c 100644 --- a/include/openflow.h +++ b/include/openflow.h @@ -102,7 +102,7 @@ enum ofp_type { /* Header on all OpenFlow packets. */ struct ofp_header { - uint8_t version; /* Always 1. */ + uint8_t version; /* OFP_VERSION. */ uint8_t type; /* One of the OFPT_ constants. */ uint16_t length; /* Length including this ofp_header. */ uint32_t xid; /* Transactin id associated with this packet.