mirror of
https://github.com/openvswitch/ovs
synced 2025-09-03 07:45:30 +00:00
ofp-util: Reduce scope of variables in ofputil_encode_flow_mod()
Reduce scope of per-protocol variables in ofputil_encode_flow_mod() These variables are only needed in one of the cases covered by the switch statement and will increase in number as more cases (protocols) are supported. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -1266,11 +1266,8 @@ struct ofpbuf *
|
|||||||
ofputil_encode_flow_mod(const struct ofputil_flow_mod *fm,
|
ofputil_encode_flow_mod(const struct ofputil_flow_mod *fm,
|
||||||
enum ofputil_protocol protocol)
|
enum ofputil_protocol protocol)
|
||||||
{
|
{
|
||||||
struct ofp10_flow_mod *ofm;
|
|
||||||
struct nx_flow_mod *nfm;
|
|
||||||
struct ofpbuf *msg;
|
struct ofpbuf *msg;
|
||||||
uint16_t command;
|
uint16_t command;
|
||||||
int match_len;
|
|
||||||
|
|
||||||
command = (protocol & OFPUTIL_P_TID
|
command = (protocol & OFPUTIL_P_TID
|
||||||
? (fm->command & 0xff) | (fm->table_id << 8)
|
? (fm->command & 0xff) | (fm->table_id << 8)
|
||||||
@@ -1278,7 +1275,9 @@ ofputil_encode_flow_mod(const struct ofputil_flow_mod *fm,
|
|||||||
|
|
||||||
switch (protocol) {
|
switch (protocol) {
|
||||||
case OFPUTIL_P_OF10:
|
case OFPUTIL_P_OF10:
|
||||||
case OFPUTIL_P_OF10_TID:
|
case OFPUTIL_P_OF10_TID: {
|
||||||
|
struct ofp10_flow_mod *ofm;
|
||||||
|
|
||||||
msg = ofpraw_alloc(OFPRAW_OFPT10_FLOW_MOD, OFP10_VERSION,
|
msg = ofpraw_alloc(OFPRAW_OFPT10_FLOW_MOD, OFP10_VERSION,
|
||||||
fm->ofpacts_len);
|
fm->ofpacts_len);
|
||||||
ofm = ofpbuf_put_zeros(msg, sizeof *ofm);
|
ofm = ofpbuf_put_zeros(msg, sizeof *ofm);
|
||||||
@@ -1292,9 +1291,13 @@ ofputil_encode_flow_mod(const struct ofputil_flow_mod *fm,
|
|||||||
ofm->out_port = htons(fm->out_port);
|
ofm->out_port = htons(fm->out_port);
|
||||||
ofm->flags = htons(fm->flags);
|
ofm->flags = htons(fm->flags);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case OFPUTIL_P_NXM:
|
case OFPUTIL_P_NXM:
|
||||||
case OFPUTIL_P_NXM_TID:
|
case OFPUTIL_P_NXM_TID: {
|
||||||
|
struct nx_flow_mod *nfm;
|
||||||
|
int match_len;
|
||||||
|
|
||||||
msg = ofpraw_alloc(OFPRAW_NXT_FLOW_MOD, OFP10_VERSION,
|
msg = ofpraw_alloc(OFPRAW_NXT_FLOW_MOD, OFP10_VERSION,
|
||||||
NXM_TYPICAL_LEN + fm->ofpacts_len);
|
NXM_TYPICAL_LEN + fm->ofpacts_len);
|
||||||
nfm = ofpbuf_put_zeros(msg, sizeof *nfm);
|
nfm = ofpbuf_put_zeros(msg, sizeof *nfm);
|
||||||
@@ -1311,6 +1314,7 @@ ofputil_encode_flow_mod(const struct ofputil_flow_mod *fm,
|
|||||||
nfm->flags = htons(fm->flags);
|
nfm->flags = htons(fm->flags);
|
||||||
nfm->match_len = htons(match_len);
|
nfm->match_len = htons(match_len);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case OFPUTIL_P_OF12:
|
case OFPUTIL_P_OF12:
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user