From: Justin Pettit Date: Fri, 2 May 2008 00:10:20 +0000 (-0700) Subject: - Add priority to flow expiration messages. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=917160e3841cd70925378960a654bbe64fe0cec9;p=openvswitch - Add priority to flow expiration messages. - Clear contents of "pad" field port status messages. --- diff --git a/datapath/datapath.c b/datapath/datapath.c index d5cd1dcd..1f7d432e 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -788,6 +788,7 @@ send_port_status(struct net_bridge_port *p, uint8_t status) if (!ops) return -ENOMEM; ops->reason = status; + memset(ops->pad, 0, sizeof ops->pad); fill_port_desc(p, &ops->desc); return send_openflow_skb(skb, NULL); @@ -805,10 +806,15 @@ dp_send_flow_expired(struct datapath *dp, struct sw_flow *flow) return -ENOMEM; flow_fill_match(&ofe->match, &flow->key); + + memset(ofe->pad, 0, sizeof ofe->pad); + ofe->priority = htons(flow->priority); + duration_j = (flow->timeout - HZ * flow->max_idle) - flow->init_time; - ofe->duration = htonl(duration_j / HZ); - ofe->packet_count = cpu_to_be64(flow->packet_count); - ofe->byte_count = cpu_to_be64(flow->byte_count); + ofe->duration = htonl(duration_j / HZ); + ofe->packet_count = cpu_to_be64(flow->packet_count); + ofe->byte_count = cpu_to_be64(flow->byte_count); + return send_openflow_skb(skb, NULL); } diff --git a/include/openflow.h b/include/openflow.h index 776dafdc..10eee8b0 100644 --- a/include/openflow.h +++ b/include/openflow.h @@ -50,7 +50,7 @@ /* The most significant bit being set in the version field indicates an * experimental OpenFlow version. */ -#define OFP_VERSION 0x82 +#define OFP_VERSION 0x83 #define OFP_MAX_TABLE_NAME_LEN 32 #define OFP_MAX_PORT_NAME_LEN 16 @@ -350,6 +350,9 @@ struct ofp_flow_expired { struct ofp_header header; struct ofp_match match; /* Description of fields */ + uint16_t priority; /* Priority level of flow entry. */ + uint8_t pad[2]; /* Align to 32-bits. */ + uint32_t duration; /* Time flow was alive in seconds. */ uint64_t packet_count; uint64_t byte_count; diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 4c19bb95..d5dc0d87 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -406,8 +406,10 @@ ofp_print_flow_expired(struct ds *string, const void *oh, size_t len, ofp_print_match(string, &ofe->match); ds_put_format(string, - " secs%d pkts%lld bytes%lld\n", ntohl(ofe->duration), - ntohll(ofe->packet_count), ntohll(ofe->byte_count)); + " pri%d secs%d pkts%lld bytes%lld\n", + ofe->match.wildcards ? ntohs(ofe->priority) : (uint16_t)-1, + ntohl(ofe->duration), ntohll(ofe->packet_count), + ntohll(ofe->byte_count)); } /* Pretty-print the OFPT_ERROR_MSG packet of 'len' bytes at 'oh' to 'string' diff --git a/switch/datapath.c b/switch/datapath.c index b569b774..c1b124b2 100644 --- a/switch/datapath.c +++ b/switch/datapath.c @@ -674,8 +674,10 @@ send_port_status(struct sw_port *p, uint8_t status) struct ofp_port_status *ops; ops = alloc_openflow_buffer(p->dp, sizeof *ops, OFPT_PORT_STATUS, NULL, &buffer); - ops->reason = status; + ops->reason = status; + memset(ops->pad, 0, sizeof ops->pad); fill_port_desc(p->dp, p, &ops->desc); + send_openflow_buffer(p->dp, buffer, NULL); } @@ -687,9 +689,13 @@ send_flow_expired(struct datapath *dp, struct sw_flow *flow) ofe = alloc_openflow_buffer(dp, sizeof *ofe, OFPT_FLOW_EXPIRED, NULL, &buffer); flow_fill_match(&ofe->match, &flow->key); - ofe->duration = htonl(flow->timeout - flow->max_idle - flow->created); - ofe->packet_count = htonll(flow->packet_count); - ofe->byte_count = htonll(flow->byte_count); + + memset(ofe->pad, 0, sizeof ofe->pad); + ofe->priority = htons(flow->priority); + + ofe->duration = htonl(flow->timeout - flow->max_idle - flow->created); + ofe->packet_count = htonll(flow->packet_count); + ofe->byte_count = htonll(flow->byte_count); send_openflow_buffer(dp, buffer, NULL); }