#define __must_check __attribute__((warn_unused_result))
#define __noreturn __attribute__((__noreturn__))
-#define BUG(fmt, arg...) ({ fprintf(stderr, "BUG: " fmt, ##arg); assert(0); abort(); })
+#define BUG(fmt, arg...) ({ fprintf(stderr, "BUG: " fmt "\n", ##arg); assert(0); abort(); })
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
false, octx);
} while ((dtype = dtype->basetype));
- BUG("datatype %s has no print method or symbol table\n",
+ BUG("datatype %s has no print method or symbol table",
expr->dtype->name);
}
case INDESC_NETLINK:
break;
default:
- BUG("invalid input descriptor type %u\n", indesc->type);
+ BUG("invalid input descriptor type %u", indesc->type);
}
f = octx->error_fp;
default:
break;
}
- BUG("invalid byte order conversion %u => %u\n",
+ BUG("invalid byte order conversion %u => %u",
expr->byteorder, byteorder);
}
&extra_len);
break;
default:
- BUG("Unknown expression %s\n", expr_name(expr));
+ BUG("Unknown expression %s", expr_name(expr));
}
masklen = len + shift;
byteorder = BYTEORDER_HOST_ENDIAN;
break;
default:
- BUG("invalid unary operation %u\n", unary->op);
+ BUG("invalid unary operation %u", unary->op);
}
__datatype_set(unary, datatype_clone(arg->dtype));
mpz_rshift_ui(val, mpz_get_uint32(right->value));
break;
default:
- BUG("invalid binary operation %u\n", op->op);
+ BUG("invalid binary operation %u", op->op);
}
new = constant_expr_alloc(&op->location, op->dtype, op->byteorder,
ret = expr_evaluate_bitwise(ctx, expr);
break;
default:
- BUG("invalid binary operation %u\n", op->op);
+ BUG("invalid binary operation %u", op->op);
}
case CMD_RESET:
break;
default:
- BUG("unhandled op %d\n", ctx->cmd->op);
+ BUG("unhandled op %d", ctx->cmd->op);
break;
}
return -1;
if (ectx.len && mappings->set->data->len != ectx.len)
- BUG("%d vs %d\n", mappings->set->data->len, ectx.len);
+ BUG("%d vs %d", mappings->set->data->len, ectx.len);
map->mappings = mappings;
*right, expr_get(left->right));
break;
default:
- BUG("invalid binary operation %u\n", left->op);
+ BUG("invalid binary operation %u", left->op);
}
return expr_evaluate(ctx, right);
"Use concatenations with sets and maps, not singleton values");
break;
default:
- BUG("invalid expression type %s\n", expr_name(right));
+ BUG("invalid expression type %s", expr_name(right));
}
break;
case OP_LT:
return -1;
break;
default:
- BUG("invalid relational operation %u\n", rel->op);
+ BUG("invalid relational operation %u", rel->op);
}
if (binop_transfer(ctx, expr) < 0)
case EXPR_RANGE_SYMBOL:
return expr_evaluate_symbol_range(ctx, expr);
default:
- BUG("unknown expression type %s\n", expr_name(*expr));
+ BUG("unknown expression type %s", expr_name(*expr));
}
}
case EXPR_MAP:
break;
default:
- BUG("invalid verdict expression %s\n", expr_name(stmt->expr));
+ BUG("invalid verdict expression %s", expr_name(stmt->expr));
}
return 0;
}
case STMT_OPTSTRIP:
return stmt_evaluate_optstrip(ctx, stmt);
default:
- BUG("unknown statement type %d\n", stmt->type);
+ BUG("unknown statement type %d", stmt->type);
}
}
expr = key;
break;
default:
- BUG("invalid expression type %s\n", expr_name(expr));
+ BUG("invalid expression type %s", expr_name(expr));
break;
}
case EXPR_VALUE:
break;
default:
- BUG("invalid expression type %s\n", expr_name(expr));
+ BUG("invalid expression type %s", expr_name(expr));
break;
}
handle_merge(&cmd->object->handle, &cmd->handle);
return obj_evaluate(ctx, cmd->object);
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
}
obj_del_cache(ctx, cmd, NFT_OBJECT_TUNNEL);
return 0;
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
}
case CMD_OBJ_ELEMENTS:
return setelem_evaluate(ctx, cmd);
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
}
}
return 0;
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
}
case CMD_OBJ_MAP:
return cmd_evaluate_list(ctx, cmd);
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
}
return 0;
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
return 0;
}
break;
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
return 0;
}
break;
};
- BUG("invalid command operation %u\n", cmd->op);
+ BUG("invalid command operation %u", cmd->op);
}
case EXPR_SET_ELEM:
return range_expr_value_low(rop, expr->key);
default:
- BUG("invalid range expression type %s\n", expr_name(expr));
+ BUG("invalid range expression type %s", expr_name(expr));
}
}
case EXPR_SET_ELEM:
return range_expr_value_high(rop, expr->key);
default:
- BUG("invalid range expression type %s\n", expr_name(expr));
+ BUG("invalid range expression type %s", expr_name(expr));
}
}
ops = __expr_ops_by_type(e->etype);
if (!ops)
- BUG("Unknown expression type %d\n", e->etype);
+ BUG("Unknown expression type %d", e->etype);
return ops;
}
type = &fib_addr_type;
break;
default:
- BUG("Unknown result %d\n", result);
+ BUG("Unknown result %d", result);
}
if (flags & NFTA_FIB_F_PRESENT) {
expr->key = key;
break;
default:
- BUG("unhandled key type %s\n", expr_name(expr->key));
+ BUG("unhandled key type %s", expr_name(expr->key));
}
}
elem = i;
break;
default:
- BUG("unhandled expression type %d\n", i->etype);
+ BUG("unhandled expression type %d", i->etype);
return NULL;
}
key = expr->key;
break;
default:
- BUG("unhandled expression type %d\n", expr->etype);
+ BUG("unhandled expression type %d", expr->etype);
return NULL;
}
}
if (key->etype != EXPR_RANGE_VALUE)
- BUG("key must be RANGE_VALUE, not %s\n", expr_name(key));
+ BUG("key must be RANGE_VALUE, not %s", expr_name(key));
assert(!next_key || next_key->etype == EXPR_RANGE_VALUE);
}
} while ((dtype = dtype->basetype));
- BUG("datatype %s has no print method or symbol table\n",
+ BUG("datatype %s has no print method or symbol table",
expr->dtype->name);
}
errno = EOPNOTSUPP;
return -1;
case CMD_OBJ_INVALID:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
break;
}
mpz_bitmask(value, expr->len);
break;
default:
- BUG("Unknown expression %s\n", expr_name(expr));
+ BUG("Unknown expression %s", expr_name(expr));
}
return value;
}
char ifname[IFNAMSIZ];
if (expr->etype != EXPR_VALUE)
- BUG("Must be a value, not %s\n", expr_name(expr));
+ BUG("Must be a value, not %s", expr_name(expr));
ifname_len = div_round_up(expr->len, BITS_PER_BYTE);
memset(ifname, 0, sizeof(ifname));
if (ifname_len > sizeof(ifname))
- BUG("Interface length %u exceeds limit\n", ifname_len);
+ BUG("Interface length %u exceeds limit", ifname_len);
mpz_export_data(ifname, expr->value, BYTEORDER_HOST_ENDIAN, ifname_len);
if (strnlen(ifname, IFNAMSIZ) >= IFNAMSIZ)
- BUG("Interface length %zu exceeds limit, no NUL byte\n", strnlen(ifname, IFNAMSIZ));
+ BUG("Interface length %zu exceeds limit, no NUL byte", strnlen(ifname, IFNAMSIZ));
dev_array[i].ifname = xstrdup(ifname);
dev_array[i].location = &expr->location;
obj_tunnel_add_opts(nlo, &obj->tunnel);
break;
default:
- BUG("Unknown type %d\n", obj->type);
+ BUG("Unknown type %d", obj->type);
break;
}
netlink_dump_obj(nlo, ctx);
elem = expr;
}
if (elem->etype != EXPR_SET_ELEM)
- BUG("Unexpected expression type: got %d\n", elem->etype);
+ BUG("Unexpected expression type: got %d", elem->etype);
key = elem->key;
nld.value, nld.len);
break;
default:
- BUG("unexpected set element expression\n");
+ BUG("unexpected set element expression");
break;
}
}
const void *src, unsigned int len)
{
if (len > sizeof(nld->value))
- BUG("nld buffer overflow: want to copy %u, max %u\n", len, (unsigned int)sizeof(nld->value));
+ BUG("nld buffer overflow: want to copy %u, max %u",
+ len, (unsigned int)sizeof(nld->value));
memcpy(nld->value, src, len);
nld->len = len;
case EXPR_PREFIX:
return netlink_gen_prefix(expr, data);
default:
- BUG("invalid data expression type %s\n", expr_name(expr));
+ BUG("invalid data expression type %s", expr_name(expr));
}
}
case EXPR_PREFIX:
return netlink_gen_prefix(expr, data);
default:
- BUG("invalid data expression type %s\n", expr_name(expr));
+ BUG("invalid data expression type %s", expr_name(expr));
}
}
value->len = left->len;
break;
default:
- BUG("unknown expression type %s\n", expr_name(left));
+ BUG("unknown expression type %s", expr_name(left));
break;
}
}
binop_adjust(binop, i->key->key, shift);
break;
default:
- BUG("unknown expression type %s\n", expr_name(i->key));
+ BUG("unknown expression type %s",
+ expr_name(i->key));
}
}
break;
binop_adjust_one(binop, right->right, shift);
break;
default:
- BUG("unknown expression type %s\n", expr_name(right));
+ BUG("unknown expression type %s", expr_name(right));
break;
}
}
expr->op = OP_NEG;
break;
default:
- BUG("unknown operation type %d\n", expr->op);
+ BUG("unknown operation type %d", expr->op);
}
expr_free(binop);
} else if (datatype_prefix_notation(binop->left->dtype) &&
ct_expr_update_type(&dl->pctx, expr);
break;
default:
- BUG("unknown expression type %s\n", expr_name(expr));
+ BUG("unknown expression type %s", expr_name(expr));
}
}
n = netlink_register_space(size);
if (ctx->reg_low + n > NFT_REG_1 + NFT_REG32_15 - NFT_REG32_00 + 1)
- BUG("register reg_low %u invalid\n", ctx->reg_low);
+ BUG("register reg_low %u invalid", ctx->reg_low);
reg = ctx->reg_low;
ctx->reg_low += n;
n = netlink_register_space(size);
if (ctx->reg_low < NFT_REG_1 + n)
- BUG("register reg_low %u invalid\n", ctx->reg_low);
+ BUG("register reg_low %u invalid", ctx->reg_low);
ctx->reg_low -= n;
}
case OP_GTE:
return NFT_CMP_GTE;
default:
- BUG("invalid comparison operation %u\n", op);
+ BUG("invalid comparison operation %u", op);
}
}
nft_rule_add_expr(ctx, nle, &expr->location);
break;
default:
- BUG("invalid range operation %u\n", expr->op);
+ BUG("invalid range operation %u", expr->op);
}
case OP_NEG:
break;
default:
- BUG("invalid relational operation %u\n", expr->op);
+ BUG("invalid relational operation %u", expr->op);
}
switch (expr->right->etype) {
combine_binop(mask, xor, tmp, val);
break;
default:
- BUG("invalid binary operation %u\n", i->op);
+ BUG("invalid binary operation %u", i->op);
}
}
nftnl_expr_set_u32(nle, NFTNL_EXPR_BITWISE_OP, NFT_BITWISE_OR);
break;
default:
- BUG("invalid binary operation %u\n", expr->op);
+ BUG("invalid binary operation %u", expr->op);
}
netlink_gen_expr(ctx, expr->left, dreg);
case OP_NTOH:
return NFT_BYTEORDER_NTOH;
default:
- BUG("invalid unary operation %u\n", op);
+ BUG("invalid unary operation %u", op);
}
}
case EXPR_XFRM:
return netlink_gen_xfrm(ctx, expr, dreg);
default:
- BUG("unknown expression type %s\n", expr_name(expr));
+ BUG("unknown expression type %s", expr_name(expr));
}
}
stmt->objref.type);
break;
default:
- BUG("unsupported expression %u\n", expr->etype);
+ BUG("unsupported expression %u", expr->etype);
}
nft_rule_add_expr(ctx, nle, &expr->location);
}
case STMT_LAST:
return netlink_gen_last_stmt(stmt);
default:
- BUG("unknown stateful statement type %d\n", stmt->type);
+ BUG("unknown stateful statement type %d", stmt->type);
}
}
case NFPROTO_IPV6: return 128;
}
- BUG("invalid nat family %u\n", family);
+ BUG("invalid nat family %u", family);
return 0;
}
nftnl_reg_pmax = NFTNL_EXPR_REDIR_REG_PROTO_MAX;
break;
default:
- BUG("unknown nat type %d\n", stmt->nat.type);
+ BUG("unknown nat type %d", stmt->nat.type);
break;
}
case STMT_OPTSTRIP:
return netlink_gen_optstrip_stmt(ctx, stmt);
default:
- BUG("unknown statement type %d\n", stmt->type);
+ BUG("unknown statement type %d", stmt->type);
}
}
case INDESC_NETLINK:
break;
default:
- BUG("invalid input descriptor type %u\n", indesc->type);
+ BUG("invalid input descriptor type %u", indesc->type);
}
print_location(octx->error_fp, indesc, loc);
flowtable_free(cmd->flowtable);
break;
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
}
free(cmd->attr);
case CMD_OBJ_FLOWTABLE:
return mnl_nft_flowtable_add(ctx, cmd, flags);
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
return 0;
}
case CMD_OBJ_RULE:
return mnl_nft_rule_replace(ctx, cmd);
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
return 0;
}
case CMD_OBJ_RULE:
return mnl_nft_rule_add(ctx, cmd, flags);
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
return 0;
}
case CMD_OBJ_FLOWTABLE:
return mnl_nft_flowtable_del(ctx, cmd);
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
}
break;
}
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
return 0;
}
case CMD_OBJ_ELEMENTS:
return do_get_setelems(ctx, cmd, false);
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
return 0;
case CMD_OBJ_RULESET:
return mnl_nft_table_del(ctx, cmd);
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
return 0;
}
return mnl_nft_chain_rename(ctx, cmd, chain);
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
return 0;
}
case CMD_DESCRIBE:
return do_command_describe(ctx, cmd, &ctx->nft->output);
default:
- BUG("invalid command object type %u\n", cmd->obj);
+ BUG("invalid command object type %u", cmd->obj);
}
}
case EXPR_VALUE:
return expr;
default:
- BUG("invalid expression type %s\n", expr_name(expr));
+ BUG("invalid expression type %s", expr_name(expr));
}
}
ops = __stmt_ops_by_type(stmt->type);
if (!ops)
- BUG("Unknown statement type %d\n", stmt->type);
+ BUG("Unknown statement type %d", stmt->type);
return ops;
}