diff options
author | Ben Pfaff <blp@ovn.org> | 2018-11-14 16:07:30 -0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-11-19 08:47:55 -0800 |
commit | 024d93f62ca7a7fef9c8fc5f69a38b60ebf7e0ab (patch) | |
tree | 63fb7f06d61f70042de6128e91950297fe90b9e6 /lib | |
parent | 9a403b07608fb1853c1b3e350250c204a1ca8496 (diff) | |
download | openvswitch-024d93f62ca7a7fef9c8fc5f69a38b60ebf7e0ab.tar.gz |
ofp-actions: Make all actions a multiple of OFPACT_ALIGNTO bytes.
The functions to put ofpacts into ofpbufs have always padded them to
OFPACT_ALIGNTO boundaries, but the underlying structures weren't
necessarily padded out. That led to difficulties in a few places where
structures were allocated on the stack instead in an ofpbuf, because
functions like ofpact_init_*() would access beyond the end of the actual
structure. This is true, for example, in test_multipath_main() in
tests/test-multipath.c, which allocates a struct ofpact_multipath on the
stack, and in lswitch_handshake() in learning-switch.c, which allocates
a struct ofpact_output on the stack.
It's possible to fix these individual cases, but it's possible that there
are others that haven't been identified. This commit addresses the issue
another way, by padding all of the ofpact structures to a full multiple
of OFPACT_ALIGNTO and adding assertions to ensure that it can't be screwed
up in the future.
This commit removes the OFPACT_*_SIZE enums, because they are now
equivalent to sizeof(struct ofpact_*) in every case.
Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ofp-actions.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index f25fdec64..96e39d6c6 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -840,7 +840,7 @@ decode_NXAST_RAW_CONTROLLER2(const struct ext_action_header *eah, } case NXAC2PT_USERDATA: - out->size = start_ofs + OFPACT_CONTROLLER_SIZE; + out->size = start_ofs + sizeof(struct ofpact_controller); ofpbuf_put(out, payload.msg, ofpbuf_msgsize(&payload)); oc = ofpbuf_at_assert(out, start_ofs, sizeof *oc); oc->userdata_len = ofpbuf_msgsize(&payload); |