/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 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 "netdev.h"
#include "nx-match.h"
#include "ofp-actions.h"
+#include "ofpbuf.h"
#include "ofp-errors.h"
#include "ofp-msgs.h"
#include "ofp-util.h"
-#include "ofpbuf.h"
#include "openflow/openflow.h"
#include "openflow/nicira-ext.h"
#include "packets.h"
+#include "dp-packet.h"
#include "type-props.h"
#include "unaligned.h"
#include "odp-util.h"
ofp_packet_to_string(const void *data, size_t len)
{
struct ds ds = DS_EMPTY_INITIALIZER;
- const struct pkt_metadata md = PKT_METADATA_INITIALIZER(0);
- struct ofpbuf buf;
+ struct dp_packet buf;
struct flow flow;
size_t l4_size;
- ofpbuf_use_const(&buf, data, len);
- flow_extract(&buf, &md, &flow);
+ dp_packet_use_const(&buf, data, len);
+ flow_extract(&buf, &flow);
flow_format(&ds, &flow);
- l4_size = ofpbuf_l4_size(&buf);
+ l4_size = dp_packet_l4_size(&buf);
if (flow.nw_proto == IPPROTO_TCP && l4_size >= TCP_HEADER_LEN) {
- struct tcp_header *th = ofpbuf_l4(&buf);
+ struct tcp_header *th = dp_packet_l4(&buf);
ds_put_format(&ds, " tcp_csum:%"PRIx16, ntohs(th->tcp_csum));
} else if (flow.nw_proto == IPPROTO_UDP && l4_size >= UDP_HEADER_LEN) {
- struct udp_header *uh = ofpbuf_l4(&buf);
+ struct udp_header *uh = dp_packet_l4(&buf);
ds_put_format(&ds, " udp_csum:%"PRIx16, ntohs(uh->udp_csum));
} else if (flow.nw_proto == IPPROTO_SCTP && l4_size >= SCTP_HEADER_LEN) {
- struct sctp_header *sh = ofpbuf_l4(&buf);
+ struct sctp_header *sh = dp_packet_l4(&buf);
ds_put_format(&ds, " sctp_csum:%"PRIx32,
ntohl(get_16aligned_be32(&sh->sctp_csum)));
} else if (flow.nw_proto == IPPROTO_ICMP && l4_size >= ICMP_HEADER_LEN) {
- struct icmp_header *icmph = ofpbuf_l4(&buf);
+ struct icmp_header *icmph = dp_packet_l4(&buf);
ds_put_format(&ds, " icmp_csum:%"PRIx16,
ntohs(icmph->icmp_csum));
} else if (flow.nw_proto == IPPROTO_ICMPV6 && l4_size >= ICMP6_HEADER_LEN) {
- struct icmp6_header *icmp6h = ofpbuf_l4(&buf);
+ struct icmp6_header *icmp6h = dp_packet_l4(&buf);
ds_put_format(&ds, " icmp6_csum:%"PRIx16,
ntohs(icmp6h->icmp6_cksum));
}
char reasonbuf[OFPUTIL_PACKET_IN_REASON_BUFSIZE];
struct ofputil_packet_in pin;
int error;
- int i;
error = ofputil_decode_packet_in(&pin, oh);
if (error) {
ds_put_format(string, " cookie=0x%"PRIx64, ntohll(pin.cookie));
}
- ds_put_format(string, " total_len=%"PRIuSIZE" in_port=", pin.total_len);
- ofputil_format_port(pin.fmd.in_port, string);
-
- if (pin.fmd.tun_id != htonll(0)) {
- ds_put_format(string, " tun_id=0x%"PRIx64, ntohll(pin.fmd.tun_id));
- }
-
- if (pin.fmd.tun_src != htonl(0)) {
- ds_put_format(string, " tun_src="IP_FMT, IP_ARGS(pin.fmd.tun_src));
- }
-
- if (pin.fmd.tun_dst != htonl(0)) {
- ds_put_format(string, " tun_dst="IP_FMT, IP_ARGS(pin.fmd.tun_dst));
- }
-
- if (pin.fmd.gbp_id != htons(0)) {
- ds_put_format(string, " gbp_id=%"PRIu16,
- ntohs(pin.fmd.gbp_id));
- }
-
- if (pin.fmd.gbp_flags) {
- ds_put_format(string, " gbp_flags=0x%02"PRIx8, pin.fmd.gbp_flags);
- }
-
- if (pin.fmd.metadata != htonll(0)) {
- ds_put_format(string, " metadata=0x%"PRIx64, ntohll(pin.fmd.metadata));
- }
+ ds_put_format(string, " total_len=%"PRIuSIZE" ", pin.total_len);
- for (i = 0; i < FLOW_N_REGS; i++) {
- if (pin.fmd.regs[i]) {
- ds_put_format(string, " reg%d=0x%"PRIx32, i, pin.fmd.regs[i]);
- }
- }
-
- if (pin.fmd.pkt_mark != 0) {
- ds_put_format(string, " pkt_mark=0x%"PRIx32, pin.fmd.pkt_mark);
- }
+ match_format(&pin.flow_metadata, string, OFP_DEFAULT_PRIORITY);
ds_put_format(string, " (via %s)",
ofputil_packet_in_reason_to_string(pin.reason, reasonbuf,
return "eviction";
case OFPRR_METER_DELETE:
return "meter_delete";
+ case OVS_OFPRR_NONE:
default:
snprintf(reasonbuf, bufsize, "%d", (int) reason);
return reasonbuf;
ds_put_format(string, " %s\n", ofperr_get_name(error));
if (error == OFPERR_OFPHFC_INCOMPATIBLE || error == OFPERR_OFPHFC_EPERM) {
- ds_put_printable(string, ofpbuf_data(&payload), ofpbuf_size(&payload));
+ ds_put_printable(string, payload.data, payload.size);
} else {
- s = ofp_to_string(ofpbuf_data(&payload), ofpbuf_size(&payload), 1);
+ s = ofp_to_string(payload.data, payload.size, 1);
ds_put_cstr(string, s);
free(s);
}
static void
ofp_print_group(struct ds *s, uint32_t group_id, uint8_t type,
- struct ovs_list *p_buckets, enum ofp_version ofp_version,
- bool suppress_type)
+ struct ovs_list *p_buckets, struct ofputil_group_props *props,
+ enum ofp_version ofp_version, bool suppress_type)
{
struct ofputil_bucket *bucket;
ds_put_format(s, ",type=%s", type_str[type > 4 ? 4 : type]);
}
+ if (props->selection_method[0]) {
+ size_t mark, start;
+
+ ds_put_format(s, ",selection_method=%s,", props->selection_method);
+ if (props->selection_method_param) {
+ ds_put_format(s, "selection_method_param=%"PRIu64",",
+ props->selection_method_param);
+ }
+
+ /* Allow rewinding to immediately before the trailing ',' */
+ mark = s->length - 1;
+
+ ds_put_cstr(s, "fields=");
+ start = s->length;
+ oxm_format_field_array(s, &props->fields);
+ if (s->length == start) {
+ ds_truncate(s, mark);
+ }
+ }
+
if (!p_buckets) {
return;
}
ds_put_cstr(s, "bucket=");
ofp_print_bucket_id(s, "bucket_id:", bucket->bucket_id, ofp_version);
- if (bucket->weight != 1) {
+ if (bucket->weight != (type == OFPGT11_SELECT ? 1 : 0)) {
ds_put_format(s, "weight:%"PRIu16",", bucket->weight);
}
if (bucket->watch_port != OFPP_NONE) {
ds_put_char(s, '\n');
ds_put_char(s, ' ');
- ofp_print_group(s, gd.group_id, gd.type, &gd.buckets, oh->version,
- false);
+ ofp_print_group(s, gd.group_id, gd.type, &gd.buckets, &gd.props,
+ oh->version, false);
ofputil_bucket_list_destroy(&gd.buckets);
}
}
gm.command_bucket_id, oh->version);
}
- ofp_print_group(s, gm.group_id, gm.type, &gm.buckets, oh->version,
- bucket_command);
+ ofp_print_group(s, gm.group_id, gm.type, &gm.buckets, &gm.props,
+ oh->version, bucket_command);
ofputil_bucket_list_destroy(&gm.buckets);
}
struct ofputil_bundle_add_msg badd;
char *msg;
- error = ofputil_decode_bundle_add(oh, &badd);
+ error = ofputil_decode_bundle_add(oh, &badd, NULL);
if (error) {
ofp_print_error(s, error);
return;