- Keep datapath config in host-byte order (and fix a couple of bugs related to this).
authorJustin Pettit <jpettit@nicira.com>
Wed, 16 Apr 2008 21:09:27 +0000 (14:09 -0700)
committerJustin Pettit <jpettit@nicira.com>
Wed, 16 Apr 2008 21:09:27 +0000 (14:09 -0700)
- Fix type for "get config" replies.

datapath/datapath.c
datapath/datapath.h
datapath/forward.c
datapath/table-hash.c
datapath/table-linear.c
include/openflow.h

index 67c4cf4..432315b 100644 (file)
@@ -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);
 }
 
index d81e2f4..0da1316 100644 (file)
@@ -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];
index c1b70ca..6f8636a 100644 (file)
@@ -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;
 }
 
index 7847ef1..87d3f65 100644 (file)
@@ -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);
                }
        }
index 0b60838..cf0e3f8 100644 (file)
@@ -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);
                }
        }
index eba5017..bc2e432 100644 (file)
@@ -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.