[ovs-dev] [flow_metadata 1/5] flow: Use struct flow_tnl in struct flow_metadata.
Ben Pfaff
blp at nicira.com
Fri May 10 23:42:24 UTC 2013
We can't currently match on some of the fields in struct flow_tnl via
OpenFlow, but it still seems reasonable to use struct flow_tnl in place of
duplicating much of it.
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
lib/flow.c | 6 ++----
lib/flow.h | 4 +---
lib/learning-switch.c | 4 ++--
lib/ofp-print.c | 15 +++++++++------
lib/ofp-util.c | 16 +++++++---------
5 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/lib/flow.c b/lib/flow.c
index 3c12984..680b3230 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -1,5 +1,5 @@
/*
- * 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.
@@ -493,9 +493,7 @@ flow_get_metadata(const struct flow *flow, struct flow_metadata *fmd)
{
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 20);
- fmd->tun_id = flow->tunnel.tun_id;
- fmd->tun_src = flow->tunnel.ip_src;
- fmd->tun_dst = flow->tunnel.ip_dst;
+ fmd->tunnel = flow->tunnel;
fmd->metadata = flow->metadata;
memcpy(fmd->regs, flow->regs, sizeof fmd->regs);
fmd->in_port = flow->in_port;
diff --git a/lib/flow.h b/lib/flow.h
index 0fdf4ef..2271418 100644
--- a/lib/flow.h
+++ b/lib/flow.h
@@ -117,9 +117,7 @@ BUILD_ASSERT_DECL(sizeof(struct flow) == sizeof(struct flow_tnl) + 160 &&
/* Represents the metadata fields of struct flow. */
struct flow_metadata {
- ovs_be64 tun_id; /* Encapsulating tunnel ID. */
- ovs_be32 tun_src; /* Tunnel outer IPv4 src addr */
- ovs_be32 tun_dst; /* Tunnel outer IPv4 dst addr */
+ struct flow_tnl tunnel; /* Encapsulating tunnel parameters. */
ovs_be64 metadata; /* OpenFlow 1.1+ metadata field. */
uint32_t regs[FLOW_N_REGS]; /* Registers. */
uint16_t in_port; /* OpenFlow port or zero. */
diff --git a/lib/learning-switch.c b/lib/learning-switch.c
index 4a95dc1..98923fb 100644
--- a/lib/learning-switch.c
+++ b/lib/learning-switch.c
@@ -1,5 +1,5 @@
/*
- * 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.
@@ -559,7 +559,7 @@ process_packet_in(struct lswitch *sw, const struct ofp_header *oh)
/* Extract flow data from 'opi' into 'flow'. */
ofpbuf_use_const(&pkt, pi.packet, pi.packet_len);
flow_extract(&pkt, 0, 0, NULL, pi.fmd.in_port, &flow);
- flow.tunnel.tun_id = pi.fmd.tun_id;
+ flow.tunnel = pi.fmd.tunnel;
/* Choose output port. */
out_port = lswitch_choose_destination(sw, &flow);
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 8d99844..1b89d3d 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -107,16 +107,19 @@ ofp_print_packet_in(struct ds *string, const struct ofp_header *oh,
ds_put_format(string, " total_len=%"PRIu16" 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.tunnel.tun_id != htonll(0)) {
+ ds_put_format(string, " tun_id=0x%"PRIx64,
+ ntohll(pin.fmd.tunnel.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.tunnel.ip_src != htonl(0)) {
+ ds_put_format(string, " tun_src="IP_FMT,
+ IP_ARGS(pin.fmd.tunnel.ip_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.tunnel.ip_dst != htonl(0)) {
+ ds_put_format(string, " tun_dst="IP_FMT,
+ IP_ARGS(pin.fmd.tunnel.ip_dst));
}
if (pin.fmd.metadata != htonll(0)) {
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 2ca0077..658b541 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -2442,9 +2442,7 @@ ofputil_decode_packet_in_finish(struct ofputil_packet_in *pin,
pin->packet_len = b->size;
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.tunnel = match->flow.tunnel;
pin->fmd.metadata = match->flow.metadata;
memcpy(pin->fmd.regs, match->flow.regs, sizeof pin->fmd.regs);
}
@@ -2542,14 +2540,14 @@ ofputil_packet_in_to_match(const struct ofputil_packet_in *pin,
int i;
match_init_catchall(match);
- if (pin->fmd.tun_id != htonll(0)) {
- match_set_tun_id(match, pin->fmd.tun_id);
+ if (pin->fmd.tunnel.tun_id != htonll(0)) {
+ match_set_tun_id(match, pin->fmd.tunnel.tun_id);
}
- if (pin->fmd.tun_src != htonl(0)) {
- match_set_tun_src(match, pin->fmd.tun_src);
+ if (pin->fmd.tunnel.ip_src != htonl(0)) {
+ match_set_tun_src(match, pin->fmd.tunnel.ip_src);
}
- if (pin->fmd.tun_dst != htonl(0)) {
- match_set_tun_dst(match, pin->fmd.tun_dst);
+ if (pin->fmd.tunnel.ip_dst != htonl(0)) {
+ match_set_tun_dst(match, pin->fmd.tunnel.ip_dst);
}
if (pin->fmd.metadata != htonll(0)) {
match_set_metadata(match, pin->fmd.metadata);
--
1.7.10.4
More information about the dev
mailing list