diff --git a/datapath/datapath.c b/datapath/datapath.c index 9374232..d9bad58 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -1026,7 +1026,10 @@ dp_send_flow_end(struct datapath *dp, struct sw_flow *flow, enum ofp_flow_removed_reason reason) { struct sk_buff *skb; - struct nx_flow_end *nfe; + struct ofp_flow_removed *ofr; + + u64 end_time; + u64 init_time; if (!flow->send_flow_rem) return 0; @@ -1034,31 +1037,23 @@ dp_send_flow_end(struct datapath *dp, struct sw_flow *flow, if (flow->emerg_flow) return 0; - nfe = alloc_openflow_skb(dp, sizeof *nfe, OFPT_VENDOR, 0, &skb); - if (!nfe) + ofr = alloc_openflow_skb(dp, sizeof *ofr, OFPT_FLOW_REMOVED, 0, &skb); + if (!ofr) return -ENOMEM; - nfe->header.vendor = htonl(NX_VENDOR_ID); - nfe->header.subtype = htonl(NXT_FLOW_END); + flow_fill_match(&ofr->match, &flow->key); - flow_fill_match(&nfe->match, &flow->key); + ofr->priority = htons(flow->priority); + ofr->reason = reason; - nfe->priority = htons(flow->priority); - nfe->reason = reason; + init_time = jiffies_64_to_msecs(flow->created); + end_time = jiffies_64_to_msecs(get_jiffies_64()); - nfe->tcp_flags = flow->tcp_flags; - nfe->ip_tos = flow->ip_tos; + ofr->duration = htonl((end_time-init_time)/1000); + ofr->idle_timeout = htons(flow->idle_timeout); - nfe->send_flow_exp = flow->send_flow_rem; - - nfe->idle_timeout = htons(flow->idle_timeout); - - nfe->init_time = cpu_to_be64(jiffies_64_to_msecs(flow->created)); - nfe->used_time = cpu_to_be64(jiffies_64_to_msecs(flow->used)); - nfe->end_time = cpu_to_be64(jiffies_64_to_msecs(get_jiffies_64())); - - nfe->packet_count = cpu_to_be64(flow->packet_count); - nfe->byte_count = cpu_to_be64(flow->byte_count); + ofr->packet_count = cpu_to_be64(flow->packet_count); + ofr->byte_count = cpu_to_be64(flow->byte_count); return send_openflow_skb(dp, skb, NULL); } diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 3920e83..15eb034 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -785,51 +785,6 @@ ofp_print_flow_removed(struct ds *string, const void *oh, size_t len UNUSED, ntohl(ofe->duration), ntohs(ofe->idle_timeout), ntohll(ofe->packet_count), ntohll(ofe->byte_count)); } -/* Pretty-print the NXT_FLOW_EXPIRED packet of 'len' bytes at 'oh' to 'string' - * at the given 'verbosity' level. */ -static void -nx_print_flow_end(struct ds *string, const void *oh, size_t len, - int verbosity) -{ - const struct nx_flow_end *nfe = oh; - - ds_put_cstr(string, "nx_flow_end: "); - - if (len < sizeof(*nfe)) { - ds_put_format(string, " (***length=%zu < min_size=%zu***)\n", - len, sizeof(*nfe)); - return; - } - - ofp_print_match(string, &nfe->match, verbosity); - ds_put_cstr(string, " reason="); - switch (nfe->reason) { - case NXFER_IDLE_TIMEOUT: - ds_put_cstr(string, "idle"); - break; - case NXFER_HARD_TIMEOUT: - ds_put_cstr(string, "hard"); - break; - case NXFER_DELETE: - ds_put_cstr(string, "delete"); - break; - case NXFER_EJECT: - ds_put_cstr(string, "eject"); - break; - default: - ds_put_format(string, "**%"PRIu8"**", nfe->reason); - break; - } - ds_put_format(string, - " pri=%"PRIu16" init=%"PRIu64" used=%"PRIu64" end=%"PRIu64" idle=%"PRIu16, - nfe->match.wildcards ? ntohs(nfe->priority) : (uint16_t)-1, - ntohll(nfe->init_time), ntohll(nfe->used_time), - ntohll(nfe->end_time), ntohs(nfe->idle_timeout)); - ds_put_format(string, - " tflags=0x%x tos=0x%x pkts=%"PRIu64" bytes=%"PRIu64"\n", - nfe->tcp_flags, nfe->ip_tos, ntohll(nfe->packet_count), - ntohll(nfe->byte_count)); -} static void nx_print_msg(struct ds *string, const void *oh, size_t len, int verbosity) @@ -838,9 +793,6 @@ nx_print_msg(struct ds *string, const void *oh, size_t len, int verbosity) switch(ntohl(nh->subtype)) { - case NXT_FLOW_END: - nx_print_flow_end(string, oh, len, verbosity); - return; } } diff --git a/secchan/automake.mk b/secchan/automake.mk index de5f973..14ece8e 100644 --- a/secchan/automake.mk +++ b/secchan/automake.mk @@ -12,8 +12,6 @@ secchan_ofprotocol_SOURCES = \ secchan/fail-open.h \ secchan/failover.c \ secchan/failover.h \ - secchan/flow-end.c \ - secchan/flow-end.h \ secchan/in-band.c \ secchan/in-band.h \ secchan/port-watcher.c \ diff --git a/secchan/flow-end.c b/secchan/flow-end.c deleted file mode 100644 index 27d21ef..0000000 --- a/secchan/flow-end.c +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford - * Junior University - * - * We are making the OpenFlow specification and associated documentation - * (Software) available for public use and benefit with the expectation - * that others will use, modify and enhance the Software and contribute - * those enhancements back to the community. However, since we would - * like to make the Software available for broadest use, with as few - * restrictions as possible permission is hereby granted, free of - * charge, to any person obtaining a copy of this Software to deal in - * the Software under the copyrights without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * The name and trademarks of copyright holder(s) may NOT be used in - * advertising or publicity pertaining to the Software or any - * derivatives without specific, written prior permission. - */ - -#include -#include "flow-end.h" -#include -#include -#include -#include -#include -#include -#include -#include "openflow/nicira-ext.h" -#include "openflow/openflow.h" -#include "secchan.h" -#include "ofpbuf.h" -#include "vconn.h" -#include "rconn.h" -#include "socket-util.h" -#include "xtoxll.h" - -#define THIS_MODULE VLM_flow_end -#include "vlog.h" - -struct flow_end_data { - struct rconn *remote_rconn; - struct rconn *local_rconn; -}; - -static void -send_ofp_expired(const struct nx_flow_end *nfe, const struct flow_end_data *fe) -{ - struct ofp_flow_removed *ofe; - struct ofpbuf *b; - - if ((nfe->reason != NXFER_IDLE_TIMEOUT) - && (nfe->reason != NXFER_HARD_TIMEOUT) - && (nfe->reason != NXFER_DELETE)) { - return; - } - - ofe = make_openflow(sizeof(*ofe), OFPT_FLOW_REMOVED, &b); - ofe->match = nfe->match; - ofe->priority = nfe->priority; - if (nfe->reason == NXFER_IDLE_TIMEOUT) { - ofe->reason = OFPRR_IDLE_TIMEOUT; - } else if (nfe->reason == NXFER_HARD_TIMEOUT) { - ofe->reason = OFPRR_HARD_TIMEOUT; - } else { - ofe->reason = OFPRR_DELETE; - } - /* 'duration' is in seconds, but we keeping track of milliseconds. */ - ofe->duration = htonl((ntohll(nfe->end_time)-ntohll(nfe->init_time))/1000); - ofe->idle_timeout = nfe->idle_timeout; - ofe->packet_count = nfe->packet_count; - ofe->byte_count = nfe->byte_count; - - rconn_send(fe->remote_rconn, b, NULL); -} - -static bool -flow_end_local_packet_cb(struct relay *r, void *flow_end_) -{ - struct flow_end_data *fe = flow_end_; - struct ofpbuf *msg = r->halves[HALF_LOCAL].rxbuf; - struct nicira_header *request = msg->data; - struct nx_flow_end *nfe = msg->data; - - - if (msg->size < sizeof(*nfe)) { - return false; - } - request = msg->data; - if (request->header.type != OFPT_VENDOR - || request->vendor != htonl(NX_VENDOR_ID) - || request->subtype != htonl(NXT_FLOW_END)) { - return false; - } - - if (nfe->send_flow_exp) { - send_ofp_expired(nfe, fe); - } - - /* We always consume these Flow End messages. */ - return true; -} - -static bool -flow_end_remote_packet_cb(struct relay *r, void *flow_end_) -{ - struct flow_end_data *fe = flow_end_; - struct ofpbuf *msg = r->halves[HALF_REMOTE].rxbuf; - struct ofp_switch_config *osc = msg->data; - - /* Check for OFPT_SET_CONFIG messages to see if the controller wants - * to receive 'flow expired' messages. If so, we need to intercept - * the datapath's 'flow end' meta-messages and convert. */ - - if ((msg->size < sizeof(*osc)) - || (osc->header.type != OFPT_SET_CONFIG)) { - return false; - } - - /* Perform any processing of set config messages here */ - - return false; -} - -static struct hook_class flow_end_hook_class = { - flow_end_local_packet_cb, /* local_packet_cb */ - flow_end_remote_packet_cb, /* remote_packet_cb */ - NULL, /* periodic_cb */ - NULL, /* wait_cb */ - NULL, /* closing_cb */ -}; - -void -flow_end_start(struct secchan *secchan, - struct rconn *local, struct rconn *remote) -{ - struct flow_end_data *fe; - - fe = xcalloc(1, sizeof *fe); - - fe->remote_rconn = remote; - fe->local_rconn = local; - - add_hook(secchan, &flow_end_hook_class, fe); -} diff --git a/secchan/flow-end.h b/secchan/flow-end.h deleted file mode 100644 index b427808..0000000 --- a/secchan/flow-end.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford - * Junior University - * - * We are making the OpenFlow specification and associated documentation - * (Software) available for public use and benefit with the expectation - * that others will use, modify and enhance the Software and contribute - * those enhancements back to the community. However, since we would - * like to make the Software available for broadest use, with as few - * restrictions as possible permission is hereby granted, free of - * charge, to any person obtaining a copy of this Software to deal in - * the Software under the copyrights without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * The name and trademarks of copyright holder(s) may NOT be used in - * advertising or publicity pertaining to the Software or any - * derivatives without specific, written prior permission. - */ - -#ifndef FLOW_END_H -#define FLOW_END_H 1 - -struct secchan; -struct rconn; - -void flow_end_start(struct secchan *, struct rconn *, struct rconn *); - -#endif /* flow-end.h */ diff --git a/secchan/secchan.c b/secchan/secchan.c index b0551cd..29aa665 100644 --- a/secchan/secchan.c +++ b/secchan/secchan.c @@ -62,7 +62,6 @@ #include "poll-loop.h" #include "ratelimit.h" #include "rconn.h" -#include "flow-end.h" #include "stp-secchan.h" #include "status.h" #include "timeval.h" @@ -211,7 +210,6 @@ main(int argc, char *argv[]) /* Set up hooks. */ port_watcher_start(&secchan, local_rconn, remote_rconn, &pw); discovery = s.discovery ? discovery_init(&s, pw, switch_status) : NULL; - flow_end_start(&secchan, local_rconn, remote_rconn); if (s.enable_stp) { stp_start(&secchan, pw, local_rconn, remote_rconn); } diff --git a/udatapath/datapath.c b/udatapath/datapath.c index 8282a32..178f2d9 100644 --- a/udatapath/datapath.c +++ b/udatapath/datapath.c @@ -731,7 +731,7 @@ dp_send_flow_end(struct datapath *dp, struct sw_flow *flow, enum ofp_flow_removed_reason reason) { struct ofpbuf *buffer; - struct nx_flow_end *nfe; + struct ofp_flow_removed *ofr; if (!flow->send_flow_rem) { return; @@ -741,31 +741,21 @@ dp_send_flow_end(struct datapath *dp, struct sw_flow *flow, return; } - nfe = make_openflow_xid(sizeof *nfe, OFPT_VENDOR, 0, &buffer); - if (!nfe) { + ofr = make_openflow_xid(sizeof *ofr, OFPT_FLOW_REMOVED, 0, &buffer); + if (!ofr) { return; } - nfe->header.vendor = htonl(NX_VENDOR_ID); - nfe->header.subtype = htonl(NXT_FLOW_END); - flow_fill_match(&nfe->match, &flow->key.flow, flow->key.wildcards); + flow_fill_match(&ofr->match, &flow->key.flow, flow->key.wildcards); - nfe->priority = htons(flow->priority); - nfe->reason = reason; + ofr->priority = htons(flow->priority); + ofr->reason = reason; - nfe->tcp_flags = flow->tcp_flags; - nfe->ip_tos = flow->ip_tos; + ofr->duration = htonl((time_msec()-flow->created)/1000); + ofr->idle_timeout = htons(flow->idle_timeout); - nfe->send_flow_exp = flow->send_flow_rem; - - nfe->idle_timeout = htons(flow->idle_timeout); - - nfe->init_time = htonll(flow->created); - nfe->used_time = htonll(flow->used); - nfe->end_time = htonll(time_msec()); - - nfe->packet_count = htonll(flow->packet_count); - nfe->byte_count = htonll(flow->byte_count); + ofr->packet_count = htonll(flow->packet_count); + ofr->byte_count = htonll(flow->byte_count); send_openflow_buffer(dp, buffer, NULL); }