X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=lib%2Flearning-switch.c;h=aba3525fdc03472d1200da8d68ce6a8df72d52fe;hb=abfec865566e6cce961cc8660de1ddfdc85dae5f;hp=22fa70d5d3b13dad3fd27a555151d167d1ba5ac1;hpb=aaaa7553a9b7fef47436e96fb0177981b09e4a83;p=openvswitch diff --git a/lib/learning-switch.c b/lib/learning-switch.c index 22fa70d5..aba3525f 100644 --- a/lib/learning-switch.c +++ b/lib/learning-switch.c @@ -533,22 +533,29 @@ process_packet_in(struct lswitch *sw, struct rconn *rconn, void *opi_) out_port = lswitch_choose_destination(sw, &flow); /* Make actions. */ - memset(actions, 0, sizeof actions); if (out_port == OFPP_NONE) { actions_len = 0; } else if (sw->queue == UINT32_MAX || out_port >= OFPP_MAX) { - struct ofp_action_output *oao = (struct ofp_action_output *) actions; - oao->type = htons(OFPAT_OUTPUT); - oao->len = htons(sizeof *oao); - oao->port = htons(out_port); - actions_len = sizeof *oao; + struct ofp_action_output oao; + + memset(&oao, 0, sizeof oao); + oao.type = htons(OFPAT_OUTPUT); + oao.len = htons(sizeof oao); + oao.port = htons(out_port); + + memcpy(actions, &oao, sizeof oao); + actions_len = sizeof oao; } else { - struct ofp_action_enqueue *oae = (struct ofp_action_enqueue *) actions; - oae->type = htons(OFPAT_ENQUEUE); - oae->len = htons(sizeof *oae); - oae->port = htons(out_port); - oae->queue_id = htonl(sw->queue); - actions_len = sizeof *oae; + struct ofp_action_enqueue oae; + + memset(&oae, 0, sizeof oae); + oae.type = htons(OFPAT_ENQUEUE); + oae.len = htons(sizeof oae); + oae.port = htons(out_port); + oae.queue_id = htonl(sw->queue); + + memcpy(actions, &oae, sizeof oae); + actions_len = sizeof oae; } assert(actions_len <= sizeof actions);