From 2301f7ebc15e7f46a73d5c4638eec221cc9d57d4 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 8 May 2013 13:21:11 -0700 Subject: [PATCH] tunnel: Make tnl_port_receive() parameter 'const'. This function no longer has much need to modify its argument, because the caller can now easily do the modification itself, so this commit makes that change. Signed-off-by: Ben Pfaff --- ofproto/ofproto-dpif.c | 1 + ofproto/tunnel.c | 16 +++++----------- ofproto/tunnel.h | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 0d17dbf42..a42625bcc 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -3927,6 +3927,7 @@ ofproto_receive(const struct dpif_backer *backer, struct ofpbuf *packet, flow->in_port = OFPP_NONE; goto exit; } + flow->in_port = ofport->ofp_port; port = ofport_dpif_cast(ofport); /* XXX: Since the tunnel module is not scoped per backer, it's diff --git a/ofproto/tunnel.c b/ofproto/tunnel.c index f5bbfb9d9..31aaf3b1c 100644 --- a/ofproto/tunnel.c +++ b/ofproto/tunnel.c @@ -159,17 +159,14 @@ tnl_port_del(struct tnl_port *tnl_port) } } -/* Transforms 'flow' so that it appears to have been received by a tunnel - * OpenFlow port controlled by this module instead of the datapath port it - * actually came in on. Sets 'flow''s in_port to the appropriate OpenFlow port - * number. Returns the 'ofport' corresponding to the new in_port. +/* Looks in the table of tunnels for a tunnel matching the metadata in 'flow'. + * Returns the 'ofport' corresponding to the new in_port, or a null pointer if + * none is found. * * Callers should verify that 'flow' needs to be received by calling - * tnl_port_should_receive() before this function. - * - * Leaves 'flow' untouched and returns null if unsuccessful. */ + * tnl_port_should_receive() before this function. */ const struct ofport * -tnl_port_receive(struct flow *flow) +tnl_port_receive(const struct flow *flow) { char *pre_flow_str = NULL; struct tnl_port *tnl_port; @@ -196,9 +193,6 @@ tnl_port_receive(struct flow *flow) pre_flow_str = flow_to_string(flow); } - flow->in_port = tnl_port->ofport->ofp_port; - /* Keep flow->tunnel to allow matching on tunnel metadata */ - if (pre_flow_str) { char *post_flow_str = flow_to_string(flow); char *tnl_str = tnl_port_fmt(tnl_port); diff --git a/ofproto/tunnel.h b/ofproto/tunnel.h index 1b055aef4..34c113368 100644 --- a/ofproto/tunnel.h +++ b/ofproto/tunnel.h @@ -37,7 +37,7 @@ bool tnl_port_reconfigure(const struct ofport *, uint32_t odp_port, struct tnl_port *tnl_port_add(const struct ofport *, uint32_t odp_port); void tnl_port_del(struct tnl_port *); -const struct ofport *tnl_port_receive(struct flow *); +const struct ofport *tnl_port_receive(const struct flow *); uint32_t tnl_port_send(const struct tnl_port *, struct flow *); /* Returns true if 'flow' should be submitted to tnl_port_receive(). */ -- 2.43.0