From: Ben Pfaff Date: Sat, 17 Jan 2009 01:17:47 +0000 (-0800) Subject: Move flow_fill_match() from udatapath to lib, so that other code can use it. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ab8fa38f0cc98945e972d2b1478920224a153e2;p=openvswitch Move flow_fill_match() from udatapath to lib, so that other code can use it. --- diff --git a/lib/flow.c b/lib/flow.c index 2145d596..489540a6 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -201,6 +201,24 @@ flow_extract(struct ofpbuf *packet, uint16_t in_port, struct flow *flow) return retval; } +void +flow_fill_match(struct ofp_match *to, const struct flow *from, + uint32_t wildcards) +{ + to->wildcards = htonl(wildcards); + to->in_port = from->in_port; + to->dl_vlan = from->dl_vlan; + memcpy(to->dl_src, from->dl_src, ETH_ADDR_LEN); + memcpy(to->dl_dst, from->dl_dst, ETH_ADDR_LEN); + to->dl_type = from->dl_type; + to->nw_src = from->nw_src; + to->nw_dst = from->nw_dst; + to->nw_proto = from->nw_proto; + to->tp_src = from->tp_src; + to->tp_dst = from->tp_dst; + to->pad = 0; +} + void flow_print(FILE *stream, const struct flow *flow) { diff --git a/lib/flow.h b/lib/flow.h index 99b5752c..5c6c71d7 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -39,6 +39,7 @@ #include "hash.h" #include "util.h" +struct ofp_match; struct ofpbuf; /* Identification data for a flow. @@ -61,6 +62,8 @@ struct flow { BUILD_ASSERT_DECL(sizeof(struct flow) == 32); int flow_extract(struct ofpbuf *, uint16_t in_port, struct flow *); +void flow_fill_match(struct ofp_match *, const struct flow *, + uint32_t wildcards); void flow_print(FILE *, const struct flow *); static inline int flow_compare(const struct flow *, const struct flow *); static inline bool flow_equal(const struct flow *, const struct flow *); diff --git a/udatapath/datapath.c b/udatapath/datapath.c index 06c31164..6324b192 100644 --- a/udatapath/datapath.c +++ b/udatapath/datapath.c @@ -744,7 +744,7 @@ dp_send_flow_end(struct datapath *dp, struct sw_flow *flow, nfe->header.vendor = htonl(NX_VENDOR_ID); nfe->header.subtype = htonl(NXT_FLOW_END); - flow_fill_match(&nfe->match, &flow->key); + flow_fill_match(&nfe->match, &flow->key.flow, flow->key.wildcards); nfe->priority = htons(flow->priority); nfe->reason = reason; diff --git a/udatapath/switch-flow.c b/udatapath/switch-flow.c index 5eca39e8..6bc2d3c5 100644 --- a/udatapath/switch-flow.c +++ b/udatapath/switch-flow.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford +/* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford * Junior University * * We are making the OpenFlow specification and associated documentation @@ -152,23 +152,6 @@ flow_extract_match(struct sw_flow_key* to, const struct ofp_match* from) to->nw_dst_mask = make_nw_mask(to->wildcards >> OFPFW_NW_DST_SHIFT); } -void -flow_fill_match(struct ofp_match* to, const struct sw_flow_key* from) -{ - to->wildcards = htonl(from->wildcards); - to->in_port = from->flow.in_port; - to->dl_vlan = from->flow.dl_vlan; - memcpy(to->dl_src, from->flow.dl_src, ETH_ADDR_LEN); - memcpy(to->dl_dst, from->flow.dl_dst, ETH_ADDR_LEN); - to->dl_type = from->flow.dl_type; - to->nw_src = from->flow.nw_src; - to->nw_dst = from->flow.nw_dst; - to->nw_proto = from->flow.nw_proto; - to->tp_src = from->flow.tp_src; - to->tp_dst = from->flow.tp_dst; - to->pad = 0; -} - /* Allocates and returns a new flow with room for 'actions_len' actions. * Returns the new flow or a null pointer on failure. */ struct sw_flow * diff --git a/udatapath/switch-flow.h b/udatapath/switch-flow.h index 78fc1148..5c5ab7b0 100644 --- a/udatapath/switch-flow.h +++ b/udatapath/switch-flow.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford +/* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford * Junior University * * We are making the OpenFlow specification and associated documentation @@ -89,7 +89,6 @@ void flow_deferred_free_acts(struct sw_flow_actions *); void flow_replace_acts(struct sw_flow *, const struct ofp_action_header *, size_t); void flow_extract_match(struct sw_flow_key* to, const struct ofp_match* from); -void flow_fill_match(struct ofp_match* to, const struct sw_flow_key* from); void print_flow(const struct sw_flow_key *); bool flow_timeout(struct sw_flow *flow);