/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <netinet/in.h>
#include <netinet/icmp6.h>
#include <stdlib.h>
-#include "autopath.h"
#include "bundle.h"
#include "byte-order.h"
#include "classifier.h"
void
ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *wc)
{
- BUILD_ASSERT_DECL(FLOW_WC_SEQ == 18);
+ BUILD_ASSERT_DECL(FLOW_WC_SEQ == 20);
/* Initialize most of wc. */
flow_wildcards_init_catchall(wc);
}
}
- if (match->flow.dl_type == htons(ETH_TYPE_MPLS) ||
- match->flow.dl_type == htons(ETH_TYPE_MPLS_MCAST)) {
+ if (eth_type_mpls(match->flow.dl_type)) {
enum { OFPFW11_MPLS_ALL = OFPFW11_MPLS_LABEL | OFPFW11_MPLS_TC };
if ((wc & OFPFW11_MPLS_ALL) != OFPFW11_MPLS_ALL) {
static const struct proto_abbrev proto_abbrevs[] = {
{ OFPUTIL_P_ANY, "any" },
{ OFPUTIL_P_OF10_STD_ANY, "OpenFlow10" },
- { OFPUTIL_P_OF10_NXM_ANY, "NXM" },
+ { OFPUTIL_P_OF10_NXM_ANY, "NXM" },
+ { OFPUTIL_P_ANY_OXM, "OXM" },
};
#define N_PROTO_ABBREVS ARRAY_SIZE(proto_abbrevs)
};
size_t ofputil_n_flow_dump_protocols = ARRAY_SIZE(ofputil_flow_dump_protocols);
-/* Returns the ofputil_protocol that is initially in effect on an OpenFlow
- * connection that has negotiated the given 'version'. 'version' should
- * normally be an 8-bit OpenFlow version identifier (e.g. 0x01 for OpenFlow
- * 1.0, 0x02 for OpenFlow 1.1). Returns 0 if 'version' is not supported or
- * outside the valid range. */
+/* Returns the set of ofputil_protocols that are supported with the given
+ * OpenFlow 'version'. 'version' should normally be an 8-bit OpenFlow version
+ * identifier (e.g. 0x01 for OpenFlow 1.0, 0x02 for OpenFlow 1.1). Returns 0
+ * if 'version' is not supported or outside the valid range. */
enum ofputil_protocol
-ofputil_protocol_from_ofp_version(enum ofp_version version)
+ofputil_protocols_from_ofp_version(enum ofp_version version)
{
switch (version) {
case OFP10_VERSION:
- return OFPUTIL_P_OF10_STD;
+ return OFPUTIL_P_OF10_STD_ANY | OFPUTIL_P_OF10_NXM_ANY;
case OFP12_VERSION:
return OFPUTIL_P_OF12_OXM;
case OFP13_VERSION:
}
}
+/* Returns the ofputil_protocol that is initially in effect on an OpenFlow
+ * connection that has negotiated the given 'version'. 'version' should
+ * normally be an 8-bit OpenFlow version identifier (e.g. 0x01 for OpenFlow
+ * 1.0, 0x02 for OpenFlow 1.1). Returns 0 if 'version' is not supported or
+ * outside the valid range. */
+enum ofputil_protocol
+ofputil_protocol_from_ofp_version(enum ofp_version version)
+{
+ return rightmost_1bit(ofputil_protocols_from_ofp_version(version));
+}
+
/* Returns the OpenFlow protocol version number (e.g. OFP10_VERSION,
* etc.) that corresponds to 'protocol'. */
enum ofp_version
NOT_REACHED();
}
+/* Returns a bitmap of OpenFlow versions that are supported by at
+ * least one of the 'protocols'. */
+uint32_t
+ofputil_protocols_to_version_bitmap(enum ofputil_protocol protocols)
+{
+ uint32_t bitmap = 0;
+
+ for (; protocols; protocols = zero_rightmost_1bit(protocols)) {
+ enum ofputil_protocol protocol = rightmost_1bit(protocols);
+
+ bitmap |= 1u << ofputil_protocol_to_ofp_version(protocol);
+ }
+
+ return bitmap;
+}
+
+/* Returns the set of protocols that are supported on top of the
+ * OpenFlow versions included in 'bitmap'. */
+enum ofputil_protocol
+ofputil_protocols_from_version_bitmap(uint32_t bitmap)
+{
+ enum ofputil_protocol protocols = 0;
+
+ for (; bitmap; bitmap = zero_rightmost_1bit(bitmap)) {
+ enum ofp_version version = rightmost_1bit_idx(bitmap);
+
+ protocols |= ofputil_protocols_from_ofp_version(version);
+ }
+
+ return protocols;
+}
+
/* Returns true if 'protocol' is a single OFPUTIL_P_* value, false
* otherwise. */
bool
return "OpenFlow10+table_id";
case OFPUTIL_P_OF12_OXM:
- return "OXM";
+ return "OXM-OpenFlow12";
case OFPUTIL_P_OF13_OXM:
- return "OpenFlow13";
+ return "OXM-OpenFlow13";
}
/* Check abbreviations. */
{
struct ds s;
- assert(!(protocols & ~OFPUTIL_P_ANY));
+ ovs_assert(!(protocols & ~OFPUTIL_P_ANY));
if (protocols == 0) {
return xstrdup("none");
}
}
static bool
-is_delimiter(char c)
+is_delimiter(unsigned char c)
{
return isspace(c) || c == ',';
}
return true;
}
-static bool
-tun_parms_fully_wildcarded(const struct flow_wildcards *wc)
-{
- return (!wc->masks.tunnel.ip_src &&
- !wc->masks.tunnel.ip_dst &&
- !wc->masks.tunnel.ip_ttl &&
- !wc->masks.tunnel.ip_tos &&
- !wc->masks.tunnel.flags);
-}
-
/* Returns a bit-mask of ofputil_protocols that can be used for sending 'match'
* to a switch (e.g. to add or remove a flow). Only NXM can handle tunnel IDs,
* registers, or fixing the Ethernet multicast bit. Otherwise, it's better to
{
const struct flow_wildcards *wc = &match->wc;
- BUILD_ASSERT_DECL(FLOW_WC_SEQ == 18);
+ BUILD_ASSERT_DECL(FLOW_WC_SEQ == 20);
- /* tunnel params other than tun_id can't be sent in a flow_mod */
- if (!tun_parms_fully_wildcarded(wc)) {
+ /* These tunnel params can't be sent in a flow_mod */
+ if (wc->masks.tunnel.ip_ttl
+ || wc->masks.tunnel.ip_tos || wc->masks.tunnel.flags) {
+ return OFPUTIL_P_NONE;
+ }
+
+ /* skb_mark and skb_priority can't be sent in a flow_mod */
+ if (wc->masks.skb_mark || wc->masks.skb_priority) {
return OFPUTIL_P_NONE;
}
| OFPUTIL_P_OF13_OXM;
}
- /* NXM and OXM support matching tun_id. */
- if (wc->masks.tunnel.tun_id != htonll(0)) {
+ /* NXM and OXM support matching tun_id, tun_src, and tun_dst. */
+ if (wc->masks.tunnel.tun_id != htonll(0)
+ || wc->masks.tunnel.ip_src != htonl(0)
+ || wc->masks.tunnel.ip_dst != htonl(0)) {
return OFPUTIL_P_OF10_NXM_ANY | OFPUTIL_P_OF12_OXM
| OFPUTIL_P_OF13_OXM;
}
| OFPUTIL_P_OF13_OXM;
}
+ /* NXM and OF1.1+ support matching MPLS label */
+ if (wc->masks.mpls_lse & htonl(MPLS_LABEL_MASK)) {
+ return OFPUTIL_P_OF10_NXM_ANY | OFPUTIL_P_OF12_OXM
+ | OFPUTIL_P_OF13_OXM;
+ }
+
+ /* NXM and OF1.1+ support matching MPLS TC */
+ if (wc->masks.mpls_lse & htonl(MPLS_TC_MASK)) {
+ return OFPUTIL_P_OF10_NXM_ANY | OFPUTIL_P_OF12_OXM
+ | OFPUTIL_P_OF13_OXM;
+ }
+
+ /* NXM and OF1.3+ support matching MPLS stack flag */
+ /* Allow for OF1.2 as there doesn't seem to be a
+ * particularly good reason not to */
+ if (wc->masks.mpls_lse & htonl(MPLS_BOS_MASK)) {
+ return OFPUTIL_P_OF10_NXM_ANY | OFPUTIL_P_OF12_OXM
+ | OFPUTIL_P_OF13_OXM;
+ }
+
/* Other formats can express this rule. */
return OFPUTIL_P_ANY;
}
return ofputil_make_flow_mod_table_id(want_tid);
}
- assert(current == want);
+ ovs_assert(current == want);
*next = current;
return NULL;
struct nx_set_flow_format *sff;
struct ofpbuf *msg;
- assert(ofputil_nx_flow_format_is_valid(nxff));
+ ovs_assert(ofputil_nx_flow_format_is_valid(nxff));
msg = ofpraw_alloc(OFPRAW_NXT_SET_FLOW_FORMAT, OFP10_VERSION, 0);
sff = ofpbuf_put_zeros(msg, sizeof *sff);
return error;
}
- error = ofpacts_pull_openflow11_instructions(&b, b.size, ofpacts);
+ error = ofpacts_pull_openflow11_instructions(&b, b.size, ofm->table_id,
+ ofpacts);
if (error) {
return error;
}
if (fm->flags & OFPFF10_EMERG) {
/* We do not support the OpenFlow 1.0 emergency flow cache, which
* is not required in OpenFlow 1.0.1 and removed from OpenFlow 1.1.
- * There is no good error code, so just state that the flow table
- * is full.
- * Moreover, OFPFF10_EMERG overlaps with OFPFF12_RESET_COUNTS,
- * so this check must be here */
- return OFPERR_OFPFMFC_TABLE_FULL;
+ *
+ * OpenFlow 1.0 specifies the error code to use when idle_timeout
+ * or hard_timeout is nonzero. Otherwise, there is no good error
+ * code, so just state that the flow table is full. */
+ return (fm->hard_timeout || fm->idle_timeout
+ ? OFPERR_OFPFMFC_BAD_EMERG_TIMEOUT
+ : OFPERR_OFPFMFC_TABLE_FULL);
}
if (protocol & OFPUTIL_P_TID) {
}
if (ofpacts_pull_openflow11_instructions(msg, length - sizeof *ofs -
- padded_match_len, ofpacts)) {
+ padded_match_len,
+ ofs->table_id, ofpacts)) {
VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply bad instructions");
return EINVAL;
}
fr->packet_count = ntohll(ofr->packet_count);
fr->byte_count = ntohll(ofr->byte_count);
} else if (raw == OFPRAW_OFPT10_FLOW_REMOVED) {
- const struct ofp_flow_removed *ofr;
+ const struct ofp10_flow_removed *ofr;
ofr = ofpbuf_pull(&b, sizeof *ofr);
fr->priority = ntohs(nfr->priority);
fr->cookie = nfr->cookie;
fr->reason = nfr->reason;
- fr->table_id = 255;
+ fr->table_id = nfr->table_id ? nfr->table_id - 1 : 255;
fr->duration_sec = ntohl(nfr->duration_sec);
fr->duration_nsec = ntohl(nfr->duration_nsec);
fr->idle_timeout = ntohs(nfr->idle_timeout);
case OFPUTIL_P_OF10_STD:
case OFPUTIL_P_OF10_STD_TID: {
- struct ofp_flow_removed *ofr;
+ struct ofp10_flow_removed *ofr;
msg = ofpraw_alloc_xid(OFPRAW_OFPT10_FLOW_REMOVED, OFP10_VERSION,
htonl(0), 0);
nfr->cookie = fr->cookie;
nfr->priority = htons(fr->priority);
nfr->reason = fr->reason;
+ nfr->table_id = fr->table_id + 1;
nfr->duration_sec = htonl(fr->duration_sec);
nfr->duration_nsec = htonl(fr->duration_nsec);
nfr->idle_timeout = htons(fr->idle_timeout);
pin->fmd.in_port = match->flow.in_port;
pin->fmd.tun_id = match->flow.tunnel.tun_id;
+ pin->fmd.tun_src = match->flow.tunnel.ip_src;
+ pin->fmd.tun_dst = match->flow.tunnel.ip_dst;
pin->fmd.metadata = match->flow.metadata;
memcpy(pin->fmd.regs, match->flow.regs, sizeof pin->fmd.regs);
}
ofputil_decode_packet_in_finish(pin, &match, &b);
} else if (raw == OFPRAW_OFPT10_PACKET_IN) {
- const struct ofp_packet_in *opi;
+ const struct ofp10_packet_in *opi;
- opi = ofpbuf_pull(&b, offsetof(struct ofp_packet_in, data));
+ opi = ofpbuf_pull(&b, offsetof(struct ofp10_packet_in, data));
pin->packet = opi->data;
pin->packet_len = b.size;
if (pin->fmd.tun_id != htonll(0)) {
match_set_tun_id(match, pin->fmd.tun_id);
}
+ if (pin->fmd.tun_src != htonl(0)) {
+ match_set_tun_src(match, pin->fmd.tun_src);
+ }
+ if (pin->fmd.tun_dst != htonl(0)) {
+ match_set_tun_dst(match, pin->fmd.tun_dst);
+ }
if (pin->fmd.metadata != htonll(0)) {
match_set_metadata(match, pin->fmd.metadata);
}
opi->cookie = pin->cookie;
}
} else if (packet_in_format == NXPIF_OPENFLOW10) {
- struct ofp_packet_in *opi;
+ struct ofp10_packet_in *opi;
packet = ofpraw_alloc_xid(OFPRAW_OFPT10_PACKET_IN, OFP10_VERSION,
htonl(0), send_len);
- opi = ofpbuf_put_zeros(packet, offsetof(struct ofp_packet_in, data));
+ opi = ofpbuf_put_zeros(packet, offsetof(struct ofp10_packet_in, data));
opi->total_len = htons(pin->total_len);
opi->in_port = htons(pin->fmd.in_port);
opi->reason = pin->reason;
}
} else if (raw == OFPRAW_OFPT10_PACKET_OUT) {
enum ofperr error;
- const struct ofp_packet_out *opo = ofpbuf_pull(&b, sizeof *opo);
+ const struct ofp10_packet_out *opo = ofpbuf_pull(&b, sizeof *opo);
po->buffer_id = ntohl(opo->buffer_id);
po->in_port = ntohs(opo->in_port);
{
const struct ofp_header *oh = b->data;
- ofputil_put_phy_port(oh->version, pp, b);
+ if (oh->version < OFP13_VERSION) {
+ ofputil_put_phy_port(oh->version, pp, b);
+ }
}
\f
/* ofputil_port_status */
ps->reason = ops->reason;
retval = ofputil_pull_phy_port(oh->version, &b, &ps->desc);
- assert(retval != EOF);
+ ovs_assert(retval != EOF);
return retval;
}
return b;
}
\f
+/* ofputil_role_request */
+
+/* Decodes the OpenFlow "role request" or "role reply" message in '*oh' into
+ * an abstract form in '*rr'. Returns 0 if successful, otherwise an
+ * OFPERR_* value. */
+enum ofperr
+ofputil_decode_role_message(const struct ofp_header *oh,
+ struct ofputil_role_request *rr)
+{
+ struct ofpbuf b;
+ enum ofpraw raw;
+
+ ofpbuf_use_const(&b, oh, ntohs(oh->length));
+ raw = ofpraw_pull_assert(&b);
+
+ if (raw == OFPRAW_OFPT12_ROLE_REQUEST ||
+ raw == OFPRAW_OFPT12_ROLE_REPLY) {
+ const struct ofp12_role_request *orr = b.l3;
+
+ if (orr->role != htonl(OFPCR12_ROLE_NOCHANGE) &&
+ orr->role != htonl(OFPCR12_ROLE_EQUAL) &&
+ orr->role != htonl(OFPCR12_ROLE_MASTER) &&
+ orr->role != htonl(OFPCR12_ROLE_SLAVE)) {
+ return OFPERR_OFPRRFC_BAD_ROLE;
+ }
+
+ rr->role = ntohl(orr->role);
+ if (raw == OFPRAW_OFPT12_ROLE_REQUEST
+ ? orr->role == htonl(OFPCR12_ROLE_NOCHANGE)
+ : orr->generation_id == htonll(UINT64_MAX)) {
+ rr->have_generation_id = false;
+ rr->generation_id = 0;
+ } else {
+ rr->have_generation_id = true;
+ rr->generation_id = ntohll(orr->generation_id);
+ }
+ } else if (raw == OFPRAW_NXT_ROLE_REQUEST ||
+ raw == OFPRAW_NXT_ROLE_REPLY) {
+ const struct nx_role_request *nrr = b.l3;
+
+ BUILD_ASSERT(NX_ROLE_OTHER + 1 == OFPCR12_ROLE_EQUAL);
+ BUILD_ASSERT(NX_ROLE_MASTER + 1 == OFPCR12_ROLE_MASTER);
+ BUILD_ASSERT(NX_ROLE_SLAVE + 1 == OFPCR12_ROLE_SLAVE);
+
+ if (nrr->role != htonl(NX_ROLE_OTHER) &&
+ nrr->role != htonl(NX_ROLE_MASTER) &&
+ nrr->role != htonl(NX_ROLE_SLAVE)) {
+ return OFPERR_OFPRRFC_BAD_ROLE;
+ }
+
+ rr->role = ntohl(nrr->role) + 1;
+ rr->have_generation_id = false;
+ rr->generation_id = 0;
+ } else {
+ NOT_REACHED();
+ }
+
+ return 0;
+}
+
+/* Returns an encoded form of a role reply suitable for the "request" in a
+ * buffer owned by the caller. */
+struct ofpbuf *
+ofputil_encode_role_reply(const struct ofp_header *request,
+ const struct ofputil_role_request *rr)
+{
+ struct ofpbuf *buf;
+ enum ofpraw raw;
+
+ raw = ofpraw_decode_assert(request);
+ if (raw == OFPRAW_OFPT12_ROLE_REQUEST) {
+ struct ofp12_role_request *orr;
+
+ buf = ofpraw_alloc_reply(OFPRAW_OFPT12_ROLE_REPLY, request, 0);
+ orr = ofpbuf_put_zeros(buf, sizeof *orr);
+
+ orr->role = htonl(rr->role);
+ orr->generation_id = htonll(rr->have_generation_id
+ ? rr->generation_id
+ : UINT64_MAX);
+ } else if (raw == OFPRAW_NXT_ROLE_REQUEST) {
+ struct nx_role_request *nrr;
+
+ BUILD_ASSERT(NX_ROLE_OTHER == OFPCR12_ROLE_EQUAL - 1);
+ BUILD_ASSERT(NX_ROLE_MASTER == OFPCR12_ROLE_MASTER - 1);
+ BUILD_ASSERT(NX_ROLE_SLAVE == OFPCR12_ROLE_SLAVE - 1);
+
+ buf = ofpraw_alloc_reply(OFPRAW_NXT_ROLE_REPLY, request, 0);
+ nrr = ofpbuf_put_zeros(buf, sizeof *nrr);
+ nrr->role = htonl(rr->role - 1);
+ } else {
+ NOT_REACHED();
+ }
+
+ return buf;
+}
+\f
/* Table stats. */
static void
struct ofpbuf *buf)
{
struct wc_map {
- enum ofp_flow_wildcards wc10;
+ enum ofp10_flow_wildcards wc10;
enum oxm12_ofb_match_fields mf12;
};
struct ofp10_table_stats *out;
const struct wc_map *p;
- out = ofpbuf_put_uninit(buf, sizeof *out);
+ out = ofpbuf_put_zeros(buf, sizeof *out);
out->table_id = in->table_id;
- strcpy(out->name, in->name);
+ ovs_strlcpy(out->name, in->name, sizeof out->name);
out->wildcards = 0;
for (p = wc_map; p < &wc_map[ARRAY_SIZE(wc_map)]; p++) {
if (in->wildcards & htonll(1ULL << p->mf12)) {
{
struct ofp11_table_stats *out;
- out = ofpbuf_put_uninit(buf, sizeof *out);
+ out = ofpbuf_put_zeros(buf, sizeof *out);
out->table_id = in->table_id;
- strcpy(out->name, in->name);
+ ovs_strlcpy(out->name, in->name, sizeof out->name);
out->wildcards = oxm12_to_ofp11_flow_match_fields(in->wildcards);
out->match = oxm12_to_ofp11_flow_match_fields(in->match);
out->instructions = in->instructions;
VLOG_WARN_RL(&bad_ofmsg_rl,
"NXST_FLOW_MONITOR reply has bad event %"PRIu16,
ntohs(nfuh->event));
- return OFPERR_OFPET_BAD_REQUEST;
+ return OFPERR_NXBRC_FM_BAD_EVENT;
}
bad_len:
switch (ofp_version) {
case OFP10_VERSION: {
- struct ofp_packet_out *opo;
+ struct ofp10_packet_out *opo;
size_t actions_ofs;
msg = ofpraw_alloc(OFPRAW_OFPT10_PACKET_OUT, OFP10_VERSION, size);
/* Converts the OpenFlow 1.1+ port number 'ofp11_port' into an OpenFlow 1.0
* port number and stores the latter in '*ofp10_port', for the purpose of
* decoding OpenFlow 1.1+ protocol messages. Returns 0 if successful,
- * otherwise an OFPERR_* number.
+ * otherwise an OFPERR_* number. On error, stores OFPP_NONE in '*ofp10_port'.
*
* See the definition of OFP11_MAX for an explanation of the mapping. */
enum ofperr
*ofp10_port = ofp11_port_h - OFPP11_OFFSET;
return 0;
} else {
+ *ofp10_port = OFPP_NONE;
VLOG_WARN_RL(&bad_ofmsg_rl, "port %"PRIu32" is outside the supported "
"range 0 through %d or 0x%"PRIx32" through 0x%"PRIx32,
ofp11_port_h, OFPP_MAX - 1,
*portp = port32;
return true;
} else if (port32 <= OFPP_LAST_RESV) {
- struct ds s;
+ struct ds msg;
- ds_init(&s);
- ofputil_format_port(port32, &s);
+ ds_init(&msg);
+ ofputil_format_port(port32, &msg);
VLOG_WARN_ONCE("referring to port %s as %u is deprecated for "
"compatibility with future versions of OpenFlow",
- ds_cstr(&s), port32);
- ds_destroy(&s);
+ ds_cstr(&msg), port32);
+ ds_destroy(&msg);
*portp = port32;
return true;
} else if (port32 < OFPP11_MAX) {
VLOG_WARN("port %u is outside the supported range 0 through "
- "%"PRIx16"or 0x%x through 0x%"PRIx32, port32,
+ "%"PRIx16" or 0x%x through 0x%"PRIx32, port32,
UINT16_MAX, (unsigned int) OFPP11_MAX, UINT32_MAX);
return false;
} else {
int
ofputil_action_code_from_name(const char *name)
{
- static const char *names[OFPUTIL_N_ACTIONS] = {
+ static const char *const names[OFPUTIL_N_ACTIONS] = {
NULL,
#define OFPAT10_ACTION(ENUM, STRUCT, NAME) NAME,
#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) NAME,
#include "ofp-util.def"
};
- const char **p;
+ const char *const *p;
for (p = names; p < &names[ARRAY_SIZE(names)]; p++) {
if (*p && !strcasecmp(name, *p)) {
MAY_ARP_SHA = 1 << 4, /* arp_sha */
MAY_ARP_THA = 1 << 5, /* arp_tha */
MAY_IPV6 = 1 << 6, /* ipv6_src, ipv6_dst, ipv6_label */
- MAY_ND_TARGET = 1 << 7 /* nd_target */
+ MAY_ND_TARGET = 1 << 7, /* nd_target */
+ MAY_MPLS = 1 << 8, /* mpls label and tc */
} may_match;
struct flow_wildcards wc;
} else if (match->flow.dl_type == htons(ETH_TYPE_ARP) ||
match->flow.dl_type == htons(ETH_TYPE_RARP)) {
may_match = MAY_NW_PROTO | MAY_NW_ADDR | MAY_ARP_SHA | MAY_ARP_THA;
+ } else if (eth_type_mpls(match->flow.dl_type)) {
+ may_match = MAY_MPLS;
} else {
may_match = 0;
}
if (!(may_match & MAY_ND_TARGET)) {
wc.masks.nd_target = in6addr_any;
}
+ if (!(may_match & MAY_MPLS)) {
+ wc.masks.mpls_lse = htonl(0);
+ wc.masks.mpls_depth = 0;
+ }
/* Log any changes. */
if (!flow_wildcards_equal(&wc, &match->wc)) {
* will be for Open Flow version 'ofp_version'. Returns message
* as a struct ofpbuf. Returns encoded message on success, NULL on error */
struct ofpbuf *
-ofputil_encode_dump_ports_request(enum ofp_version ofp_version, int16_t port)
+ofputil_encode_dump_ports_request(enum ofp_version ofp_version, uint16_t port)
{
struct ofpbuf *request;
struct ofp13_port_stats *ps13)
{
ofputil_port_stats_to_ofp11(ops, &ps13->ps);
-
- /* OF 1.3 adds duration fields */
- /* FIXME: Need to implement port alive duration (sec + nsec) */
- ps13->duration_sec = htonl(~0);
- ps13->duration_nsec = htonl(~0);
+ ps13->duration_sec = htonl(ops->duration_sec);
+ ps13->duration_nsec = htonl(ops->duration_nsec);
}
ops->stats.rx_over_errors = ntohll(get_32aligned_be64(&ps10->rx_over_err));
ops->stats.rx_crc_errors = ntohll(get_32aligned_be64(&ps10->rx_crc_err));
ops->stats.collisions = ntohll(get_32aligned_be64(&ps10->collisions));
+ ops->duration_sec = ops->duration_nsec = UINT32_MAX;
return 0;
}
ops->stats.rx_over_errors = ntohll(ps11->rx_over_err);
ops->stats.rx_crc_errors = ntohll(ps11->rx_crc_err);
ops->stats.collisions = ntohll(ps11->collisions);
+ ops->duration_sec = ops->duration_nsec = UINT32_MAX;
return 0;
}
ofputil_port_stats_from_ofp13(struct ofputil_port_stats *ops,
const struct ofp13_port_stats *ps13)
{
- enum ofperr error =
- ofputil_port_stats_from_ofp11(ops, &ps13->ps);
+ enum ofperr error = ofputil_port_stats_from_ofp11(ops, &ps13->ps);
if (!error) {
- /* FIXME: Get ps13->duration_sec and ps13->duration_nsec,
- * Add to netdev_stats? */
+ ops->duration_sec = ntohl(ps13->duration_sec);
+ ops->duration_nsec = ntohl(ps13->duration_nsec);
}
-
return error;
}