diff options
author | Ben Pfaff <blp@ovn.org> | 2016-01-04 11:36:14 -0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2016-01-04 11:36:14 -0800 |
commit | 39cc5c4adea207465e88d309dedf61990201301b (patch) | |
tree | be85b60c8a728c72105ad53cd89007b46da09f78 /lib/ofp-parse.c | |
parent | d1a74e5e4ff438f805e94ead2440c5f3fa56ffdc (diff) | |
download | openvswitch-39cc5c4adea207465e88d309dedf61990201301b.tar.gz |
Use initializers for struct ofputil_flow_mod instead of assignments.
A few bugs have been fixed lately that were related to struct
ofputil_flow_mod not being fully initialized in a few places. This commit
changes several pieces of code from using individual assignments to fields
in struct ofputil_flow_mod, to using whole initializers or assignments to
a whole struct. This should help prevent similar problems in the future.
CC: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
Diffstat (limited to 'lib/ofp-parse.c')
-rw-r--r-- | lib/ofp-parse.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c index fdc30d9b7..c346f102b 100644 --- a/lib/ofp-parse.c +++ b/lib/ofp-parse.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc. + * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -332,27 +332,21 @@ parse_ofp_str__(struct ofputil_flow_mod *fm, int command, char *string, OVS_NOT_REACHED(); } - match_init_catchall(&fm->match); - fm->priority = OFP_DEFAULT_PRIORITY; - fm->cookie = htonll(0); - fm->cookie_mask = htonll(0); + *fm = (struct ofputil_flow_mod) { + .match = MATCH_CATCHALL_INITIALIZER, + .priority = OFP_DEFAULT_PRIORITY, + .table_id = 0xff, + .command = command, + .buffer_id = UINT32_MAX, + .out_port = OFPP_ANY, + .out_group = OFPG_ANY, + .delete_reason = OFPRR_DELETE, + }; + /* For modify, by default, don't update the cookie. */ if (command == OFPFC_MODIFY || command == OFPFC_MODIFY_STRICT) { - /* For modify, by default, don't update the cookie. */ fm->new_cookie = OVS_BE64_MAX; - } else{ - fm->new_cookie = htonll(0); } - fm->modify_cookie = false; - fm->table_id = 0xff; - fm->command = command; - fm->idle_timeout = OFP_FLOW_PERMANENT; - fm->hard_timeout = OFP_FLOW_PERMANENT; - fm->buffer_id = UINT32_MAX; - fm->out_port = OFPP_ANY; - fm->flags = 0; - fm->importance = 0; - fm->out_group = OFPG_ANY; - fm->delete_reason = OFPRR_DELETE; + if (fields & F_ACTIONS) { act_str = extract_actions(string); if (!act_str) { |