Skip to content

Commit

Permalink
actions: Make "free" functions per-struct, not per-action.
Browse files Browse the repository at this point in the history
In some cases multiple kinds of OVN action share the same structure.  In
all of these cases, a given kind of structure is freed one particular way
(it would be confusing if this were not the case), so there's no benefit
in having per-action free functions.  Therefore, this commit switches to
a free function per structure type.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mickey Spiegel <mickeys.dev@gmail.com>
  • Loading branch information
blp committed Jan 21, 2017
1 parent 66f56ca commit 80b6743
Showing 1 changed file with 20 additions and 73 deletions.
93 changes: 20 additions & 73 deletions ovn/lib/actions.c
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016 Nicira, Inc.
* Copyright (c) 2015, 2016, 2017 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,7 +45,7 @@ VLOG_DEFINE_THIS_MODULE(actions);
static void encode_##ENUM(const struct STRUCT *, \
const struct ovnact_encode_params *, \
struct ofpbuf *ofpacts); \
static void free_##ENUM(struct STRUCT *a);
static void STRUCT##_free(struct STRUCT *a);
OVNACTS
#undef OVNACT

Expand Down Expand Up @@ -226,6 +226,11 @@ add_prerequisite(struct action_context *ctx, const char *prerequisite)
ovs_assert(!error);
ctx->prereqs = expr_combine(EXPR_T_AND, ctx->prereqs, expr);
}

static void
ovnact_null_free(struct ovnact_null *a OVS_UNUSED)
{
}

static void
format_OUTPUT(const struct ovnact_null *a OVS_UNUSED, struct ds *s)
Expand All @@ -248,11 +253,6 @@ encode_OUTPUT(const struct ovnact_null *a OVS_UNUSED,
{
emit_resubmit(ofpacts, ep->output_ptable);
}

static void
free_OUTPUT(struct ovnact_null *a OVS_UNUSED)
{
}

static void
parse_NEXT(struct action_context *ctx)
Expand Down Expand Up @@ -300,7 +300,7 @@ encode_NEXT(const struct ovnact_next *next,
}

static void
free_NEXT(struct ovnact_next *a OVS_UNUSED)
ovnact_next_free(struct ovnact_next *a OVS_UNUSED)
{
}

Expand Down Expand Up @@ -374,7 +374,7 @@ encode_LOAD(const struct ovnact_load *load,
}

static void
free_LOAD(struct ovnact_load *load)
ovnact_load_free(struct ovnact_load *load)
{
expr_constant_destroy(&load->imm, load_type(load));
}
Expand Down Expand Up @@ -490,12 +490,7 @@ encode_EXCHANGE(const struct ovnact_move *xchg,
}

static void
free_MOVE(struct ovnact_move *move OVS_UNUSED)
{
}

static void
free_EXCHANGE(struct ovnact_move *xchg OVS_UNUSED)
ovnact_move_free(struct ovnact_move *move OVS_UNUSED)
{
}

Expand All @@ -520,11 +515,6 @@ encode_DEC_TTL(const struct ovnact_null *null OVS_UNUSED,
{
ofpact_put_DEC_TTL(ofpacts);
}

static void
free_DEC_TTL(struct ovnact_null *null OVS_UNUSED)
{
}

static void
parse_CT_NEXT(struct action_context *ctx)
Expand Down Expand Up @@ -558,11 +548,6 @@ encode_CT_NEXT(const struct ovnact_next *next,
ct->zone_src.n_bits = 16;
ofpact_finish(ofpacts, &ct->ofpact);
}

static void
free_CT_NEXT(struct ovnact_next *next OVS_UNUSED)
{
}

static void
parse_ct_commit_arg(struct action_context *ctx,
Expand Down Expand Up @@ -680,7 +665,7 @@ encode_CT_COMMIT(const struct ovnact_ct_commit *cc,
}

static void
free_CT_COMMIT(struct ovnact_ct_commit *cc OVS_UNUSED)
ovnact_ct_commit_free(struct ovnact_ct_commit *cc OVS_UNUSED)
{
}

Expand Down Expand Up @@ -819,12 +804,7 @@ encode_CT_SNAT(const struct ovnact_ct_nat *cn,
}

static void
free_CT_DNAT(struct ovnact_ct_nat *ct_nat OVS_UNUSED)
{
}

static void
free_CT_SNAT(struct ovnact_ct_nat *ct_nat OVS_UNUSED)
ovnact_ct_nat_free(struct ovnact_ct_nat *ct_nat OVS_UNUSED)
{
}

Expand Down Expand Up @@ -1016,7 +996,7 @@ encode_CT_LB(const struct ovnact_ct_lb *cl,
}

static void
free_CT_LB(struct ovnact_ct_lb *ct_lb)
ovnact_ct_lb_free(struct ovnact_ct_lb *ct_lb)
{
free(ct_lb->dsts);
}
Expand Down Expand Up @@ -1133,24 +1113,13 @@ encode_ND_NA(const struct ovnact_nest *on,
encode_nested_actions(on, ep, ACTION_OPCODE_ND_NA, ofpacts);
}


static void
free_nested_actions(struct ovnact_nest *on)
ovnact_nest_free(struct ovnact_nest *on)
{
ovnacts_free(on->nested, on->nested_len);
free(on->nested);
}

static void
free_ARP(struct ovnact_nest *nest)
{
free_nested_actions(nest);
}

static void
free_ND_NA(struct ovnact_nest *nest)
{
free_nested_actions(nest);
}

static void
parse_get_mac_bind(struct action_context *ctx, int width,
Expand Down Expand Up @@ -1221,12 +1190,7 @@ encode_GET_ND(const struct ovnact_get_mac_bind *get_mac,
}

static void
free_GET_ARP(struct ovnact_get_mac_bind *get_mac OVS_UNUSED)
{
}

static void
free_GET_ND(struct ovnact_get_mac_bind *get_mac OVS_UNUSED)
ovnact_get_mac_bind_free(struct ovnact_get_mac_bind *get_mac OVS_UNUSED)
{
}

Expand Down Expand Up @@ -1300,12 +1264,7 @@ encode_PUT_ND(const struct ovnact_put_mac_bind *put_mac,
}

static void
free_PUT_ARP(struct ovnact_put_mac_bind *put_mac OVS_UNUSED)
{
}

static void
free_PUT_ND(struct ovnact_put_mac_bind *put_mac OVS_UNUSED)
ovnact_put_mac_bind_free(struct ovnact_put_mac_bind *put_mac OVS_UNUSED)
{
}

Expand Down Expand Up @@ -1602,23 +1561,11 @@ encode_PUT_DHCPV6_OPTS(const struct ovnact_put_dhcp_opts *pdo,
}

static void
free_put_dhcp_opts(struct ovnact_put_dhcp_opts *pdo)
ovnact_put_dhcp_opts_free(struct ovnact_put_dhcp_opts *pdo)
{
free_dhcp_options(pdo->options, pdo->n_options);
}

static void
free_PUT_DHCPV4_OPTS(struct ovnact_put_dhcp_opts *pdo)
{
free_put_dhcp_opts(pdo);
}

static void
free_PUT_DHCPV6_OPTS(struct ovnact_put_dhcp_opts *pdo)
{
free_put_dhcp_opts(pdo);
}

static void
parse_SET_QUEUE(struct action_context *ctx)
{
Expand Down Expand Up @@ -1655,7 +1602,7 @@ encode_SET_QUEUE(const struct ovnact_set_queue *set_queue,
}

static void
free_SET_QUEUE(struct ovnact_set_queue *a OVS_UNUSED)
ovnact_set_queue_free(struct ovnact_set_queue *a OVS_UNUSED)
{
}

Expand Down Expand Up @@ -1901,7 +1848,7 @@ ovnact_free(struct ovnact *a)
switch (a->type) {
#define OVNACT(ENUM, STRUCT) \
case OVNACT_##ENUM: \
free_##ENUM(ALIGNED_CAST(struct STRUCT *, a)); \
STRUCT##_free(ALIGNED_CAST(struct STRUCT *, a)); \
break;
OVNACTS
#undef OVNACT
Expand Down

0 comments on commit 80b6743

Please sign in to comment.