- 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 67c4cf43bad5852a1d837d42baba894011208647..432315b115e2557ffa1ea68e818838391fa246da 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 d81e2f4cffe9dbfd3e0e6b99ca1f5a75a2cabfee..0da13162c5845c56bf3b2a496c9a240eef6341f5 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 c1b70ca73e1e10dac86ddbea13b13a88f479e911..6f8636a01964674704e95f79d435751feeb2a7bb 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 7847ef139842ae99dcb0f1019245bfb8e9691904..87d3f65054364253ec82809aa3fa17e85f52e0e9 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 0b60838ac9c23ccd6096251f979ffb9949b9ef57..cf0e3f8a4ae0b83910bd84c4ad05a08df384d018 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 eba5017e67a302ebddc363619df13ac934051213..bc2e432ce14d549fe4f0b11655d2fd452083a6b7 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.