Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/bfcli/chain.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ int bfc_chain_update_set(const struct bfc_opts *opts)
return bf_err_r(r, "failed to parse set element '%s'", raw_elem);
}

r = bf_set_new(&to_remove, opts->set_name, dest_set->key, dest_set->n_comps);
r = bf_set_new(&to_remove, opts->set_name, dest_set->key,
dest_set->n_comps);
if (r)
return bf_err_r(r, "failed to create set");

Expand All @@ -316,7 +317,8 @@ int bfc_chain_update_set(const struct bfc_opts *opts)

r = bf_chain_update_set(opts->name, to_add, to_remove);
if (r)
return bf_err_r(r, "failed to update set '%s' in chain '%s'", opts->set_name, opts->name);
return bf_err_r(r, "failed to update set '%s' in chain '%s'",
opts->set_name, opts->name);

bf_info("updated set '%s' in chain '%s'", opts->set_name, opts->name);

Expand Down
12 changes: 6 additions & 6 deletions src/bfcli/opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ static void _bfc_opts_set_name_cb(struct argp_state *state, const char *arg,
opts->set_name = arg;
};

static void _bfc_opts_set_add_cb(struct argp_state *state,
const char *arg, struct bfc_opts *opts)
static void _bfc_opts_set_add_cb(struct argp_state *state, const char *arg,
struct bfc_opts *opts)
{
int r;

Expand All @@ -394,9 +394,8 @@ static void _bfc_opts_set_add_cb(struct argp_state *state,
argp_error(state, "failed to add element to list");
};

static void _bfc_opts_set_remove_cb(struct argp_state *state,
const char *arg,
struct bfc_opts *opts)
static void _bfc_opts_set_remove_cb(struct argp_state *state, const char *arg,
struct bfc_opts *opts)
{
int r;

Expand Down Expand Up @@ -522,7 +521,8 @@ struct bfc_opts_opt
.key = 'R',
.name = "remove",
.arg = "ELEMENT",
.doc = "Element to remove from the set. Can be specified multiple times.",
.doc =
"Element to remove from the set. Can be specified multiple times.",
.parser = _bfc_opts_set_remove_cb,
},
{
Expand Down
3 changes: 2 additions & 1 deletion src/bfcli/opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ struct bfc_opts_cmd
* @brief Initialize a `bfc_opts` object to default values.
*/
#define bfc_opts_default() \
{.object = _BFC_OBJECT_MAX, .action = _BFC_ACTION_MAX, \
{.object = _BFC_OBJECT_MAX, \
.action = _BFC_ACTION_MAX, \
.set_add = bf_list_default(NULL, NULL), \
.set_remove = bf_list_default(NULL, NULL)};

Expand Down
3 changes: 2 additions & 1 deletion src/libbpfilter/chain.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ struct bf_set *bf_chain_get_set_for_matcher(const struct bf_chain *chain,
return bf_list_get_at(&chain->sets, set_id);
}

struct bf_set *bf_chain_get_set_by_name(struct bf_chain *chain, const char *set_name)
struct bf_set *bf_chain_get_set_by_name(struct bf_chain *chain,
const char *set_name)
{
assert(chain);
assert(set_name);
Expand Down
7 changes: 4 additions & 3 deletions src/libbpfilter/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,11 @@ int bf_chain_update_set(const char *name, const struct bf_set *to_add,
return r;
bf_wpack_close_object(wpack);

r = bf_request_new_from_pack(&request, BF_FRONT_CLI, BF_REQ_CHAIN_UPDATE_SET,
wpack);
r = bf_request_new_from_pack(&request, BF_FRONT_CLI,
BF_REQ_CHAIN_UPDATE_SET, wpack);
if (r)
return bf_err_r(r, "bf_chain_update_set: failed to create a new request");
return bf_err_r(r,
"bf_chain_update_set: failed to create a new request");

fd = bf_connect_to_daemon();
if (fd < 0)
Expand Down
3 changes: 2 additions & 1 deletion src/libbpfilter/include/bpfilter/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ struct bf_set *bf_chain_get_set_for_matcher(const struct bf_chain *chain,
* @param set_name Name of the set to retrieve. Can't be NULL.
* @return Pointer to the set, or NULL if not found.
*/
struct bf_set *bf_chain_get_set_by_name(struct bf_chain *chain, const char *set_name);
struct bf_set *bf_chain_get_set_by_name(struct bf_chain *chain,
const char *set_name);

/** Allocate and initialize a chain as a copy of another chain.
*
Expand Down
6 changes: 4 additions & 2 deletions src/libbpfilter/matcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ int _bf_parse_iface(enum bf_matcher_type type, enum bf_matcher_op op,

r = bf_if_index_from_str(raw_payload, (uint32_t *)payload);
if (r) {
return bf_err_r(r,
return bf_err_r(
r,
"\"%s %s\" expects an interface name (e.g., \"eth0\", \"wlan0\") or a decimal interface index (e.g., \"1\", \"2\"), not '%s'",
bf_matcher_type_to_str(type), bf_matcher_op_to_str(op), raw_payload);
bf_matcher_type_to_str(type), bf_matcher_op_to_str(op),
raw_payload);
}

return 0;
Expand Down
7 changes: 3 additions & 4 deletions src/libbpfilter/set.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,7 @@ static int _bf_set_cmp_key_format(const struct bf_set *first,

if (memcmp(first->key, second->key,
first->n_comps * sizeof(enum bf_matcher_type)) != 0)
return bf_err_r(
-EINVAL,
"set key component type mismatch");
return bf_err_r(-EINVAL, "set key component type mismatch");

return 0;
}
Expand Down Expand Up @@ -481,7 +479,8 @@ int bf_set_add_many(struct bf_set *dest, struct bf_set **to_add)
}

if (!found) {
r = bf_list_add_tail(&dest->elems, bf_list_node_get_data(elem_node));
r = bf_list_add_tail(&dest->elems,
bf_list_node_get_data(elem_node));
if (r)
return bf_err_r(r, "failed to add element to set");
// Take ownership of data to stop to_add cleanup from freeing it.
Expand Down