/*
- * Copyright (c) 2009 Nicira, Inc.
+ * Copyright (c) 2009, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "aes128.h"
-#include <assert.h>
-
#include "util.h"
static const uint32_t Te0[256] = {
rk[6] = rk[2] ^ rk[5];
rk[7] = rk[3] ^ rk[6];
}
- assert(rk == &aes->rk[40]);
+ ovs_assert(rk == &aes->rk[40]);
}
void
tag_type tags = 0;
struct flow flow;
- assert(may_send_learning_packets(bond));
+ ovs_assert(may_send_learning_packets(bond));
memset(&flow, 0, sizeof flow);
memcpy(flow.dl_src, eth_src, ETH_ADDR_LEN);
static unsigned int
bond_hash(const struct bond *bond, const struct flow *flow, uint16_t vlan)
{
- assert(bond->balance == BM_TCP || bond->balance == BM_SLB);
+ ovs_assert(bond->balance == BM_TCP || bond->balance == BM_SLB);
return (bond->balance == BM_TCP
? bond_hash_tcp(flow, vlan, bond->basis)
-/* Copyright (c) 2008, 2009 Nicira, Inc.
+/* Copyright (c) 2008, 2009, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <config.h>
#include "byteq.h"
-#include <assert.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
void
byteq_put(struct byteq *q, uint8_t c)
{
- assert(!byteq_is_full(q));
+ ovs_assert(!byteq_is_full(q));
*byteq_head(q) = c;
q->head++;
}
byteq_putn(struct byteq *q, const void *p_, size_t n)
{
const uint8_t *p = p_;
- assert(byteq_avail(q) >= n);
+ ovs_assert(byteq_avail(q) >= n);
while (n > 0) {
size_t chunk = MIN(n, byteq_headroom(q));
memcpy(byteq_head(q), p, chunk);
byteq_get(struct byteq *q)
{
uint8_t c;
- assert(!byteq_is_empty(q));
+ ovs_assert(!byteq_is_empty(q));
c = *byteq_tail(q);
q->tail++;
return c;
if (n > 0) {
byteq_advance_tail(q, n);
} else {
- assert(n < 0);
+ ovs_assert(n < 0);
return errno;
}
}
void
byteq_advance_tail(struct byteq *q, unsigned int n)
{
- assert(byteq_tailroom(q) >= n);
+ ovs_assert(byteq_tailroom(q) >= n);
q->tail += n;
}
void
byteq_advance_head(struct byteq *q, unsigned int n)
{
- assert(byteq_headroom(q) >= n);
+ ovs_assert(byteq_headroom(q) >= n);
q->head += n;
}
#include <config.h>
#include "cfm.h"
-#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
md_len = strlen(ovs_md_name);
ma_len = strlen(ovs_ma_name);
- assert(md_len && ma_len && md_len + ma_len + 4 <= CCM_MAID_LEN);
+ ovs_assert(md_len && ma_len && md_len + ma_len + 4 <= CCM_MAID_LEN);
cfm->maid[0] = 4; /* MD name string format. */
cfm->maid[1] = md_len; /* MD name size. */
cfm->health = (rmp->num_health_ccm * 100) / exp_ccm_recvd;
cfm->health = MIN(cfm->health, 100);
rmp->num_health_ccm = 0;
- assert(cfm->health >= 0 && cfm->health <= 100);
+ ovs_assert(cfm->health >= 0 && cfm->health <= 100);
}
cfm->health_interval = 0;
}
}
if (cfm->ccm_interval == 0) {
- assert(cfm->extended);
+ ovs_assert(cfm->extended);
ccm->interval_ms_x = htons(cfm->ccm_interval_ms);
} else {
ccm->interval_ms_x = htons(0);
#include <config.h>
#include "classifier.h"
-#include <assert.h>
#include <errno.h>
#include <netinet/in.h>
#include "byte-order.h"
classifier_insert(struct classifier *cls, struct cls_rule *rule)
{
struct cls_rule *displaced_rule = classifier_replace(cls, rule);
- assert(!displaced_rule);
+ ovs_assert(!displaced_rule);
}
/* Removes 'rule' from 'cls'. It is the caller's responsibility to destroy
#include <config.h>
#include "daemon.h"
-#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
void
daemon_save_fd(int fd)
{
- assert(fd == STDIN_FILENO || fd == STDOUT_FILENO || fd == STDERR_FILENO);
+ ovs_assert(fd == STDIN_FILENO ||
+ fd == STDOUT_FILENO ||
+ fd == STDERR_FILENO);
save_fds[fd] = true;
}
#include "dpif-linux.h"
-#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
struct nl_transaction *txnsp[MAX_OPS];
size_t i;
- assert(n_ops <= MAX_OPS);
+ ovs_assert(n_ops <= MAX_OPS);
for (i = 0; i < n_ops; i++) {
struct op_auxdata *aux = &auxes[i];
struct dpif_op *op = ops[i];
struct ofpbuf *request_buf;
int error;
- assert((reply != NULL) == (bufp != NULL));
+ ovs_assert((reply != NULL) == (bufp != NULL));
error = dpif_linux_init();
if (error) {
struct ofpbuf *request_buf;
int error;
- assert((reply != NULL) == (bufp != NULL));
+ ovs_assert((reply != NULL) == (bufp != NULL));
request_buf = ofpbuf_new(1024);
dpif_linux_dp_to_ofpbuf(request, request_buf);
}
/* We never need to send these to the kernel. */
- assert(!flow->stats);
- assert(!flow->tcp_flags);
- assert(!flow->used);
+ ovs_assert(!flow->stats);
+ ovs_assert(!flow->tcp_flags);
+ ovs_assert(!flow->used);
if (flow->clear) {
nl_msg_put_flag(buf, OVS_FLOW_ATTR_CLEAR);
struct ofpbuf *request_buf;
int error;
- assert((reply != NULL) == (bufp != NULL));
+ ovs_assert((reply != NULL) == (bufp != NULL));
if (reply) {
request->nlmsg_flags |= NLM_F_ECHO;
#include <config.h>
#include "dpif.h"
-#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
static struct dpif_netdev *
dpif_netdev_cast(const struct dpif *dpif)
{
- assert(dpif->dpif_class->open == dpif_netdev_open);
+ ovs_assert(dpif->dpif_class->open == dpif_netdev_open);
return CONTAINER_OF(dpif, struct dpif_netdev, dpif);
}
if (error) {
return error;
}
- assert(dp != NULL);
+ ovs_assert(dp != NULL);
}
} else {
if (dp->class != class) {
dpif_netdev_close(struct dpif *dpif)
{
struct dp_netdev *dp = get_dp_netdev(dpif);
- assert(dp->open_cnt > 0);
+ ovs_assert(dp->open_cnt > 0);
if (--dp->open_cnt == 0 && dp->destroyed) {
shash_find_and_delete(&dp_netdevs, dp->name);
dp_netdev_free(dp);
* exposed over OpenFlow as a single switch. Datapaths and the collections of
* ports that they contain may be fixed or dynamic. */
-#include <assert.h>
#include "openflow/openflow.h"
#include "dpif.h"
#include "util.h"
static inline void dpif_assert_class(const struct dpif *dpif,
const struct dpif_class *dpif_class)
{
- assert(dpif->dpif_class == dpif_class);
+ ovs_assert(dpif->dpif_class == dpif_class);
}
/* Datapath interface class structure, to be defined by each implementation of
#include <config.h>
#include "dpif-provider.h"
-#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
error = registered_class->dpif_class->open(registered_class->dpif_class,
name, create, &dpif);
if (!error) {
- assert(dpif->dpif_class == registered_class->dpif_class);
+ ovs_assert(dpif->dpif_class == registered_class->dpif_class);
registered_class->refcount++;
}
registered_class = shash_find_data(&dpif_classes,
dpif->dpif_class->type);
- assert(registered_class);
- assert(registered_class->refcount);
+ ovs_assert(registered_class);
+ ovs_assert(registered_class->refcount);
registered_class->refcount--;
dpif_uninit(dpif, true);
struct dpif_port port;
int error;
- assert(name_size > 0);
+ ovs_assert(name_size > 0);
error = dpif_port_query_by_number(dpif, port_no, &port);
if (!error) {
int error;
COVERAGE_INC(dpif_flow_put);
- assert(!(put->flags & ~(DPIF_FP_CREATE | DPIF_FP_MODIFY
- | DPIF_FP_ZERO_STATS)));
+ ovs_assert(!(put->flags & ~(DPIF_FP_CREATE | DPIF_FP_MODIFY
+ | DPIF_FP_ZERO_STATS)));
error = dpif->dpif_class->flow_put(dpif, put);
if (error && put->stats) {
#include <config.h>
#include "dynamic-string.h"
-#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
needed = vsnprintf(&ds->string[ds->length], available, format, args);
va_end(args);
- assert(needed < available);
+ ovs_assert(needed < available);
ds->length += needed;
}
}
*/
#include <config.h>
#include "fatal-signal.h"
-#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <stdbool.h>
{
fatal_signal_init();
- assert(n_hooks < MAX_HOOKS);
+ ovs_assert(n_hooks < MAX_HOOKS);
hooks[n_hooks].hook_cb = hook_cb;
hooks[n_hooks].cancel_cb = cancel_cb;
hooks[n_hooks].aux = aux;
#include <config.h>
#include <sys/types.h>
#include "flow.h"
-#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
memset(flow, 0, sizeof *flow);
if (tnl) {
- assert(tnl != &flow->tunnel);
+ ovs_assert(tnl != &flow->tunnel);
flow->tunnel = *tnl;
}
flow->in_port = ofp_in_port;
#include <config.h>
#include "hmap.h"
-#include <assert.h>
#include <stdint.h>
#include <string.h>
#include "coverage.h"
struct hmap tmp;
size_t i;
- assert(!(new_mask & (new_mask + 1)));
- assert(new_mask != SIZE_MAX);
+ ovs_assert(!(new_mask & (new_mask + 1)));
+ ovs_assert(new_mask != SIZE_MAX);
hmap_init(&tmp);
if (new_mask) {
/*
- * Copyright (c) 2011 Nicira, Inc.
+ * Copyright (c) 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "hmapx.h"
-#include <assert.h>
-
#include "hash.h"
static struct hmapx_node *
hmapx_add_assert(struct hmapx *map, void *data)
{
bool added OVS_UNUSED = hmapx_add(map, data);
- assert(added);
+ ovs_assert(added);
}
/* Removes all of the nodes from 'map'. */
hmapx_find_and_delete_assert(struct hmapx *map, const void *data)
{
bool deleted OVS_UNUSED = hmapx_find_and_delete(map, data);
- assert(deleted);
+ ovs_assert(deleted);
}
/* Searches for 'data' in 'map'. Returns its node, if found, otherwise a null
#include "json.h"
-#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
const char *
json_string(const struct json *json)
{
- assert(json->type == JSON_STRING);
+ ovs_assert(json->type == JSON_STRING);
return json->u.string;
}
struct json_array *
json_array(const struct json *json)
{
- assert(json->type == JSON_ARRAY);
+ ovs_assert(json->type == JSON_ARRAY);
return CONST_CAST(struct json_array *, &json->u.array);
}
struct shash *
json_object(const struct json *json)
{
- assert(json->type == JSON_OBJECT);
+ ovs_assert(json->type == JSON_OBJECT);
return CONST_CAST(struct shash *, json->u.object);
}
bool
json_boolean(const struct json *json)
{
- assert(json->type == JSON_TRUE || json->type == JSON_FALSE);
+ ovs_assert(json->type == JSON_TRUE || json->type == JSON_FALSE);
return json->type == JSON_TRUE;
}
double
json_real(const struct json *json)
{
- assert(json->type == JSON_REAL || json->type == JSON_INTEGER);
+ ovs_assert(json->type == JSON_REAL || json->type == JSON_INTEGER);
return json->type == JSON_REAL ? json->u.real : json->u.integer;
}
int64_t
json_integer(const struct json *json)
{
- assert(json->type == JSON_INTEGER);
+ ovs_assert(json->type == JSON_INTEGER);
return json->u.integer;
}
\f
}
if (!p->error) {
- assert(p->height == 1);
- assert(p->stack[0].json != NULL);
+ ovs_assert(p->height == 1);
+ ovs_assert(p->stack[0].json != NULL);
json = p->stack[--p->height].json;
} else {
json = json_string_create_nocopy(p->error);
#include "jsonrpc.h"
-#include <assert.h>
#include <errno.h>
#include "byteq.h"
{
struct jsonrpc *rpc;
- assert(stream != NULL);
+ ovs_assert(stream != NULL);
rpc = xzalloc(sizeof *rpc);
rpc->name = xstrdup(stream_get_name(stream));
static void
jsonrpc_error(struct jsonrpc *rpc, int error)
{
- assert(error);
+ ovs_assert(error);
if (!rpc->status) {
rpc->status = error;
jsonrpc_cleanup(rpc);
-/* Copyright (c) 2011 Nicira, Inc.
+/* Copyright (c) 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <config.h>
#include "lacp.h"
-#include <assert.h>
#include <stdlib.h>
#include "dynamic-string.h"
void
lacp_configure(struct lacp *lacp, const struct lacp_settings *s)
{
- assert(!eth_addr_is_zero(s->id));
+ ovs_assert(!eth_addr_is_zero(s->id));
if (!lacp->name || strcmp(s->name, lacp->name)) {
free(lacp->name);
struct ofp_switch_config *osc;
int ofp_version = rconn_get_version(sw->rconn);
- assert(ofp_version > 0 && ofp_version < 0xff);
+ ovs_assert(ofp_version > 0 && ofp_version < 0xff);
/* Send OFPT_FEATURES_REQUEST. */
b = ofpraw_alloc(OFPRAW_OFPT_FEATURES_REQUEST, ofp_version, 0);
*/
#include <config.h>
#include "list.h"
-#include <assert.h>
/* Initializes 'list' as an empty list. */
void
{
struct list *list = CONST_CAST(struct list *, list_);
- assert(!list_is_empty(list));
+ ovs_assert(!list_is_empty(list));
return list->next;
}
{
struct list *list = CONST_CAST(struct list *, list_);
- assert(!list_is_empty(list));
+ ovs_assert(!list_is_empty(list));
return list->prev;
}
#include <config.h>
#include "mac-learning.h"
-#include <assert.h>
#include <inttypes.h>
#include <stdlib.h>
} else {
struct mac_entry *e = mac_entry_lookup(ml, dst, vlan);
- assert(e == NULL || e->tag != 0);
+ ovs_assert(e == NULL || e->tag != 0);
if (tag) {
/* Tag either the learned port or the lack thereof. */
*tag |= e ? e->tag : make_unknown_mac_tag(ml, dst, vlan);
#include <config.h>
#include "match.h"
-#include <assert.h>
#include <stdlib.h>
#include "byte-order.h"
#include "dynamic-string.h"
match_set_reg_masked(struct match *match, unsigned int reg_idx,
uint32_t value, uint32_t mask)
{
- assert(reg_idx < FLOW_N_REGS);
+ ovs_assert(reg_idx < FLOW_N_REGS);
flow_wildcards_set_reg_mask(&match->wc, reg_idx, mask);
match->flow.regs[reg_idx] = value & mask;
}
/*
- * Copyright (c) 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "meta-flow.h"
-#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <netinet/icmp6.h>
const struct mf_field *
mf_from_id(enum mf_field_id id)
{
- assert((unsigned int) id < MFF_N_IDS);
+ ovs_assert((unsigned int) id < MFF_N_IDS);
return &mf_fields[id];
}
nxm_init_add_field(const struct mf_field *mf, uint32_t header)
{
if (header) {
- assert(!mf_from_nxm_header__(header));
+ ovs_assert(!mf_from_nxm_header__(header));
add_nxm_field(header, mf);
if (mf->maskable != MFM_NONE) {
add_nxm_field(NXM_MAKE_WILD_HEADER(header), mf);
uint8_t mac[ETH_ADDR_LEN],
uint8_t mask[ETH_ADDR_LEN])
{
- assert(mf->n_bytes == ETH_ADDR_LEN);
+ ovs_assert(mf->n_bytes == ETH_ADDR_LEN);
switch (sscanf(s, ETH_ADDR_SCAN_FMT"/"ETH_ADDR_SCAN_FMT,
ETH_ADDR_SCAN_ARGS(mac), ETH_ADDR_SCAN_ARGS(mask))){
{
int prefix;
- assert(mf->n_bytes == sizeof *ip);
+ ovs_assert(mf->n_bytes == sizeof *ip);
if (sscanf(s, IP_SCAN_FMT"/"IP_SCAN_FMT,
IP_SCAN_ARGS(ip), IP_SCAN_ARGS(mask)) == IP_SCAN_COUNT * 2) {
const char *name, *netmask;
int retval;
- assert(mf->n_bytes == sizeof *value);
+ ovs_assert(mf->n_bytes == sizeof *value);
name = strtok_r(str, "/", &save_ptr);
retval = name ? lookup_ipv6(name, value) : EINVAL;
{
uint16_t port;
- assert(mf->n_bytes == sizeof(ovs_be16));
+ ovs_assert(mf->n_bytes == sizeof(ovs_be16));
if (*s == '-') {
return xasprintf("%s: negative values not supported for %s",
s, mf->name);
return mf_from_frag_string(s, &value->u8, &mask->u8);
case MFS_TNL_FLAGS:
- assert(mf->n_bytes == sizeof(ovs_be16));
+ ovs_assert(mf->n_bytes == sizeof(ovs_be16));
return mf_from_tun_flags_string(s, &value->be16, &mask->be16);
}
NOT_REACHED();
unsigned long long int integer;
int i;
- assert(mf->n_bytes <= 8);
+ ovs_assert(mf->n_bytes <= 8);
integer = 0;
for (i = 0; i < mf->n_bytes; i++) {
#include <config.h>
#include <stdlib.h>
-#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#include "socket-util.h"
#include "shash.h"
#include "svec.h"
+#include "util.h"
#include "vlog.h"
VLOG_DEFINE_THIS_MODULE(netdev_bsd);
static struct netdev_bsd *
netdev_bsd_cast(const struct netdev *netdev)
{
- assert(is_netdev_bsd_class(netdev_dev_get_class(netdev_get_dev(netdev))));
+ ovs_assert(is_netdev_bsd_class(netdev_dev_get_class(
+ netdev_get_dev(netdev))));
return CONTAINER_OF(netdev, struct netdev_bsd, netdev);
}
static struct netdev_dev_bsd *
netdev_dev_bsd_cast(const struct netdev_dev *netdev_dev)
{
- assert(is_netdev_bsd_class(netdev_dev_get_class(netdev_dev)));
+ ovs_assert(is_netdev_bsd_class(netdev_dev_get_class(netdev_dev)));
return CONTAINER_OF(netdev_dev, struct netdev_dev_bsd, netdev_dev);
}
static struct netdev_dev_dummy *
netdev_dev_dummy_cast(const struct netdev_dev *netdev_dev)
{
- assert(is_dummy_class(netdev_dev_get_class(netdev_dev)));
+ ovs_assert(is_dummy_class(netdev_dev_get_class(netdev_dev)));
return CONTAINER_OF(netdev_dev, struct netdev_dev_dummy, netdev_dev);
}
netdev_dummy_cast(const struct netdev *netdev)
{
struct netdev_dev *netdev_dev = netdev_get_dev(netdev);
- assert(is_dummy_class(netdev_dev_get_class(netdev_dev)));
+ ovs_assert(is_dummy_class(netdev_dev_get_class(netdev_dev)));
return CONTAINER_OF(netdev, struct netdev_dummy, netdev);
}
#include "netdev-linux.h"
-#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <arpa/inet.h>
netdev_dev_linux_cast(const struct netdev_dev *netdev_dev)
{
const struct netdev_class *netdev_class = netdev_dev_get_class(netdev_dev);
- assert(is_netdev_linux_class(netdev_class));
+ ovs_assert(is_netdev_linux_class(netdev_class));
return CONTAINER_OF(netdev_dev, struct netdev_dev_linux, netdev_dev);
}
{
struct netdev_dev *netdev_dev = netdev_get_dev(netdev);
const struct netdev_class *netdev_class = netdev_dev_get_class(netdev_dev);
- assert(is_netdev_linux_class(netdev_class));
+ ovs_assert(is_netdev_linux_class(netdev_class));
return CONTAINER_OF(netdev, struct netdev_linux, netdev);
}
cache_notifier_ref(void)
{
if (!cache_notifier_refcount) {
- assert(!netdev_linux_cache_notifier);
+ ovs_assert(!netdev_linux_cache_notifier);
netdev_linux_cache_notifier =
rtnetlink_link_notifier_create(netdev_linux_cache_cb, NULL);
static void
cache_notifier_unref(void)
{
- assert(cache_notifier_refcount > 0);
+ ovs_assert(cache_notifier_refcount > 0);
if (!--cache_notifier_refcount) {
- assert(netdev_linux_cache_notifier);
+ ovs_assert(netdev_linux_cache_notifier);
rtnetlink_link_notifier_destroy(netdev_linux_cache_notifier);
netdev_linux_cache_notifier = NULL;
}
if (error) {
return error;
}
- assert(netdev_dev->tc == NULL);
+ ovs_assert(netdev_dev->tc == NULL);
/* Install new qdisc. */
error = new_ops->tc_install(netdev, details);
- assert((error == 0) == (netdev_dev->tc != NULL));
+ ovs_assert((error == 0) == (netdev_dev->tc != NULL));
return error;
}
/* Instantiate it. */
load_error = ops->tc_load(CONST_CAST(struct netdev *, netdev), qdisc);
- assert((load_error == 0) == (netdev_dev->tc != NULL));
+ ovs_assert((load_error == 0) == (netdev_dev->tc != NULL));
ofpbuf_delete(qdisc);
return error ? error : load_error;
/* Generic interface to network devices. */
-#include <assert.h>
-
#include "netdev.h"
#include "list.h"
#include "shash.h"
static inline void netdev_dev_assert_class(const struct netdev_dev *netdev_dev,
const struct netdev_class *class_)
{
- assert(netdev_dev->netdev_class == class_);
+ ovs_assert(netdev_dev->netdev_class == class_);
}
/* A instance of an open network device.
static const struct vport_class *
vport_class_cast(const struct netdev_class *class)
{
- assert(is_vport_class(class));
+ ovs_assert(is_vport_class(class));
return CONTAINER_OF(class, struct vport_class, netdev_class);
}
static struct netdev_dev_vport *
netdev_dev_vport_cast(const struct netdev_dev *netdev_dev)
{
- assert(is_vport_class(netdev_dev_get_class(netdev_dev)));
+ ovs_assert(is_vport_class(netdev_dev_get_class(netdev_dev)));
return CONTAINER_OF(netdev_dev, struct netdev_dev_vport, netdev_dev);
}
#include <config.h>
#include "netdev.h"
-#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <netinet/in.h>
if (error) {
return error;
}
- assert(netdev_dev->netdev_class == class);
+ ovs_assert(netdev_dev->netdev_class == class);
}
if (netdev) {
struct netdev_dev *netdev_dev = netdev_get_dev(netdev);
- assert(netdev_dev->ref_cnt);
+ ovs_assert(netdev_dev->ref_cnt);
netdev_dev->ref_cnt--;
netdev_uninit(netdev, true);
int (*recv)(struct netdev *, void *, size_t);
int retval;
- assert(buffer->size == 0);
- assert(ofpbuf_tailroom(buffer) >= ETH_TOTAL_MIN);
+ ovs_assert(buffer->size == 0);
+ ovs_assert(ofpbuf_tailroom(buffer) >= ETH_TOTAL_MIN);
recv = netdev_get_dev(netdev)->netdev_class->recv;
retval = (recv
netdev_dev_init(struct netdev_dev *netdev_dev, const char *name,
const struct netdev_class *netdev_class)
{
- assert(!shash_find(&netdev_dev_shash, name));
+ ovs_assert(!shash_find(&netdev_dev_shash, name));
memset(netdev_dev, 0, sizeof *netdev_dev);
netdev_dev->netdev_class = netdev_class;
{
char *name = netdev_dev->name;
- assert(!netdev_dev->ref_cnt);
+ ovs_assert(!netdev_dev->ref_cnt);
shash_delete(&netdev_dev_shash, netdev_dev->node);
#include "netlink-notifier.h"
-#include <assert.h>
#include <errno.h>
#include <poll.h>
#include <stdlib.h>
nln_destroy(struct nln *nln)
{
if (nln) {
- assert(list_is_empty(&nln->all_notifiers));
+ ovs_assert(list_is_empty(&nln->all_notifiers));
nl_sock_destroy(nln->notify_sock);
free(nln);
}
#include <config.h>
#include "netlink-socket.h"
-#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <stdlib.h>
int
nl_sock_leave_mcgroup(struct nl_sock *sock, unsigned int multicast_group)
{
- assert(!sock->dump);
+ ovs_assert(!sock->dump);
if (setsockopt(sock->fd, SOL_NETLINK, NETLINK_DROP_MEMBERSHIP,
&multicast_group, sizeof multicast_group) < 0) {
VLOG_WARN("could not leave multicast group %u (%s)",
struct msghdr msg;
ssize_t retval;
- assert(buf->allocated >= sizeof *nlmsghdr);
+ ovs_assert(buf->allocated >= sizeof *nlmsghdr);
ofpbuf_clear(buf);
iov[0].iov_base = buf->base;
while (!dump->status) {
struct ofpbuf reply;
if (!nl_dump_next(dump, &reply)) {
- assert(dump->status);
+ ovs_assert(dump->status);
}
}
}
ofpbuf_delete(reply);
- assert(*number != 0);
+ ovs_assert(*number != 0);
}
return *number > 0 ? 0 : -*number;
}
#include <config.h>
#include "netlink.h"
-#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <sys/types.h>
{
struct nlmsghdr *nlmsghdr;
- assert(msg->size == 0);
+ ovs_assert(msg->size == 0);
nl_msg_reserve(msg, NLMSG_HDRLEN + expected_payload);
nlmsghdr = nl_msg_put_uninit(msg, NLMSG_HDRLEN);
struct genlmsghdr *genlmsghdr;
nl_msg_put_nlmsghdr(msg, GENL_HDRLEN + expected_payload, family, flags);
- assert(msg->size == NLMSG_HDRLEN);
+ ovs_assert(msg->size == NLMSG_HDRLEN);
genlmsghdr = nl_msg_put_uninit(msg, GENL_HDRLEN);
genlmsghdr->cmd = cmd;
genlmsghdr->version = version;
{
size_t total_size = NLA_HDRLEN + size;
struct nlattr* nla = nl_msg_put_uninit(msg, total_size);
- assert(NLA_ALIGN(total_size) <= UINT16_MAX);
+ ovs_assert(NLA_ALIGN(total_size) <= UINT16_MAX);
nla->nla_len = total_size;
nla->nla_type = type;
return nla + 1;
{
size_t total_size = NLA_HDRLEN + size;
struct nlattr* nla = nl_msg_push_uninit(msg, total_size);
- assert(NLA_ALIGN(total_size) <= UINT16_MAX);
+ ovs_assert(NLA_ALIGN(total_size) <= UINT16_MAX);
nla->nla_len = total_size;
nla->nla_type = type;
return nla + 1;
const void *
nl_attr_get(const struct nlattr *nla)
{
- assert(nla->nla_len >= NLA_HDRLEN);
+ ovs_assert(nla->nla_len >= NLA_HDRLEN);
return nla + 1;
}
size_t
nl_attr_get_size(const struct nlattr *nla)
{
- assert(nla->nla_len >= NLA_HDRLEN);
+ ovs_assert(nla->nla_len >= NLA_HDRLEN);
return nla->nla_len - NLA_HDRLEN;
}
const void *
nl_attr_get_unspec(const struct nlattr *nla, size_t size)
{
- assert(nla->nla_len >= NLA_HDRLEN + size);
+ ovs_assert(nla->nla_len >= NLA_HDRLEN + size);
return nla + 1;
}
const char *
nl_attr_get_string(const struct nlattr *nla)
{
- assert(nla->nla_len > NLA_HDRLEN);
- assert(memchr(nl_attr_get(nla), '\0', nla->nla_len - NLA_HDRLEN) != NULL);
+ ovs_assert(nla->nla_len > NLA_HDRLEN);
+ ovs_assert(memchr(nl_attr_get(nla), '\0', nla->nla_len - NLA_HDRLEN));
return nl_attr_get(nla);
}
{
uint32_t header;
- assert((cookie != NULL) == (cookie_mask != NULL));
+ ovs_assert((cookie != NULL) == (cookie_mask != NULL));
match_init_catchall(match);
if (cookie) {
const struct mf_field *mf = load->dst.field;
union mf_value value;
- assert(load->ofpact.compat == OFPUTIL_OFPAT12_SET_FIELD);
+ ovs_assert(load->ofpact.compat == OFPUTIL_OFPAT12_SET_FIELD);
ds_put_format(s, "set_field:");
memset(&value, 0, sizeof value);
bitwise_copy(&load->subvalue, sizeof load->subvalue, 0,
#include "nx-match.h"
#include "ofp-util.h"
#include "ofpbuf.h"
+#include "util.h"
#include "vlog.h"
VLOG_DEFINE_THIS_MODULE(ofp_actions);
static inline const struct STRUCT * \
instruction_get_##ENUM(const struct ofp11_instruction *inst)\
{ \
- assert(inst->type == htons(ENUM)); \
+ ovs_assert(inst->type == htons(ENUM)); \
return (struct STRUCT *)inst; \
} \
\
void
ofpact_update_len(struct ofpbuf *ofpacts, struct ofpact *ofpact)
{
- assert(ofpact == ofpacts->l2);
+ ovs_assert(ofpact == ofpacts->l2);
ofpact->len = (char *) ofpbuf_tail(ofpacts) - (char *) ofpact;
}
static inline struct STRUCT * \
ofpact_get_##ENUM(const struct ofpact *ofpact) \
{ \
- assert(ofpact->type == OFPACT_##ENUM); \
+ ovs_assert(ofpact->type == OFPACT_##ENUM); \
return (struct STRUCT *) ofpact; \
} \
\
{
size_t ofs = error - OFPERR_OFS;
- assert(ofperr_is_valid(error));
+ ovs_assert(ofperr_is_valid(error));
return &domain->errors[ofs];
}
/*
- * Copyright (c) 2012 Nicira, Inc.
+ * Copyright (c) 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <config.h>
#include "ofp-msgs.h"
-#include <assert.h>
#include "byte-order.h"
#include "dynamic-string.h"
#include "hash.h"
const struct ofp_header *oh, size_t length)
{
enum ofperr error = ofphdrs_decode(hdrs, oh, length);
- assert(!error);
+ ovs_assert(!error);
}
static bool
enum ofpraw raw;
error = ofpraw_pull(&raw, msg);
- assert(!error);
+ ovs_assert(!error);
return raw;
}
error = ofpraw_decode_partial(&request_raw, request,
ntohs(request->length));
- assert(!error);
+ ovs_assert(!error);
reply_raw = ofpraw_stats_request_to_reply(request_raw, request->version);
- assert(reply_raw);
+ ovs_assert(reply_raw);
return ofpraw_alloc_reply(reply_raw, request, extra_tailroom);
}
enum ofpraw raw;
error = ofpraw_decode_partial(&raw, request, ntohs(request->length));
- assert(!error);
+ ovs_assert(!error);
raw = ofpraw_stats_request_to_reply(raw, request->version);
- assert(raw);
+ ovs_assert(raw);
ofpraw_put__(raw, request->version, request->xid, 0, buf);
}
if (hdrs->type == OFPT_VENDOR) {
struct nicira_header *nh = buf->l2;
- assert(hdrs->vendor == NX_VENDOR_ID);
+ ovs_assert(hdrs->vendor == NX_VENDOR_ID);
nh->vendor = htonl(hdrs->vendor);
nh->subtype = htonl(hdrs->subtype);
} else if (version == OFP10_VERSION
hdrs = instance->hdrs;
switch ((enum ofp_version)hdrs.version) {
case OFP10_VERSION:
- assert(hdrs.type == OFPT10_STATS_REQUEST);
+ ovs_assert(hdrs.type == OFPT10_STATS_REQUEST);
hdrs.type = OFPT10_STATS_REPLY;
break;
case OFP11_VERSION:
case OFP12_VERSION:
case OFP13_VERSION:
- assert(hdrs.type == OFPT11_STATS_REQUEST);
+ ovs_assert(hdrs.type == OFPT11_STATS_REQUEST);
hdrs.type = OFPT11_STATS_REPLY;
break;
default:
}
error = ofpraw_from_ofphdrs(&reply_raw, &hdrs);
- assert(!error);
+ ovs_assert(!error);
return reply_raw;
}
{
struct ofpbuf *msg = ofpbuf_from_list(list_back(replies));
- assert(start_ofs <= UINT16_MAX);
+ ovs_assert(start_ofs <= UINT16_MAX);
if (msg->size > UINT16_MAX) {
size_t len = msg->size - start_ofs;
memcpy(ofpmp_append(replies, len),
{
ofpmsgs_init();
- assert(raw < ARRAY_SIZE(raw_infos));
+ ovs_assert(raw < ARRAY_SIZE(raw_infos));
return &raw_infos[raw];
}
static struct raw_instance *
raw_instance_get(const struct raw_info *info, uint8_t version)
{
- assert(version >= info->min_version && version <= info->max_version);
+ ovs_assert(version >= info->min_version && version <= info->max_version);
return &info->instances[version - info->min_version];
}
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
struct ds s;
- assert(!(protocols & ~OFPUTIL_P_ANY));
+ ovs_assert(!(protocols & ~OFPUTIL_P_ANY));
if (protocols == 0) {
return xstrdup("none");
}
return ofputil_make_flow_mod_table_id(want_tid);
}
- assert(current == want);
+ ovs_assert(current == want);
*next = current;
return NULL;
struct nx_set_flow_format *sff;
struct ofpbuf *msg;
- assert(ofputil_nx_flow_format_is_valid(nxff));
+ ovs_assert(ofputil_nx_flow_format_is_valid(nxff));
msg = ofpraw_alloc(OFPRAW_NXT_SET_FLOW_FORMAT, OFP10_VERSION, 0);
sff = ofpbuf_put_zeros(msg, sizeof *sff);
ps->reason = ops->reason;
retval = ofputil_pull_phy_port(oh->version, &b, &ps->desc);
- assert(retval != EOF);
+ ovs_assert(retval != EOF);
return retval;
}
#include <config.h>
#include "ofpbuf.h"
-#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "dynamic-string.h"
void
ofpbuf_reserve(struct ofpbuf *b, size_t size)
{
- assert(!b->size);
+ ovs_assert(!b->size);
ofpbuf_prealloc_tailroom(b, size);
b->data = (char*)b->data + size;
}
void *
ofpbuf_at_assert(const struct ofpbuf *b, size_t offset, size_t size)
{
- assert(offset + size <= b->size);
+ ovs_assert(offset + size <= b->size);
return ((char *) b->data) + offset;
}
ofpbuf_pull(struct ofpbuf *b, size_t size)
{
void *data = b->data;
- assert(b->size >= size);
+ ovs_assert(b->size >= size);
b->data = (char*)b->data + size;
b->size -= size;
return data;
#include "ovsdb-data.h"
-#include <assert.h>
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
inited = true;
}
- assert(ovsdb_atomic_type_is_valid(type));
+ ovs_assert(ovsdb_atomic_type_is_valid(type));
return &default_atoms[type];
}
ovsdb_symbol_referenced(struct ovsdb_symbol *symbol,
const struct ovsdb_base_type *base)
{
- assert(base->type == OVSDB_TYPE_UUID);
+ ovs_assert(base->type == OVSDB_TYPE_UUID);
if (base->u.uuid.refTableName) {
switch (base->u.uuid.refType) {
int kt = type->key.type;
int vt = type->value.type;
- assert(ovsdb_type_is_valid(type));
+ ovs_assert(ovsdb_type_is_valid(type));
d = &default_data[kt][vt];
if (!d->n) {
&datum->keys[i].string, &datum->values[i].string);
i++;
}
- assert(i == datum->n);
+ ovs_assert(i == datum->n);
smap_destroy(smap);
ovsdb_datum_sort_unique(datum, OVSDB_TYPE_STRING, OVSDB_TYPE_STRING);
struct ovsdb_error *error;
a->n = n;
error = ovsdb_datum_sort(a, type->key.type);
- assert(!error);
+ ovs_assert(!error);
}
}
bool changed = false;
size_t i;
- assert(a_type->key.type == b_type->key.type);
- assert(a_type->value.type == b_type->value.type
- || b_type->value.type == OVSDB_TYPE_VOID);
+ ovs_assert(a_type->key.type == b_type->key.type);
+ ovs_assert(a_type->value.type == b_type->value.type
+ || b_type->value.type == OVSDB_TYPE_VOID);
/* XXX The big-O of this could easily be improved. */
for (i = 0; i < a->n; ) {
{
struct ovsdb_symbol *symbol;
- assert(!ovsdb_symbol_table_get(symtab, name));
+ ovs_assert(!ovsdb_symbol_table_get(symtab, name));
symbol = xmalloc(sizeof *symbol);
symbol->uuid = *uuid;
symbol->created = created;
#include "ovsdb-idl.h"
-#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
if (idl) {
size_t i;
- assert(!idl->txn);
+ ovs_assert(!idl->txn);
ovsdb_idl_clear(idl);
jsonrpc_session_close(idl->session);
{
int i;
- assert(!idl->txn);
+ ovs_assert(!idl->txn);
jsonrpc_session_run(idl->session);
for (i = 0; jsonrpc_session_is_connected(idl->session) && i < 50; i++) {
struct jsonrpc_msg *msg;
{
size_t i;
- assert(!idl->change_seqno);
+ ovs_assert(!idl->change_seqno);
for (i = 0; i < idl->class->n_tables; i++) {
const struct ovsdb_idl_table *table = &idl->tables[i];
static void
ovsdb_idl_row_clear_old(struct ovsdb_idl_row *row)
{
- assert(row->old == row->new);
+ ovs_assert(row->old == row->new);
if (!ovsdb_idl_row_is_orphan(row)) {
const struct ovsdb_idl_table_class *class = row->table->class;
size_t i;
const struct ovsdb_idl_table_class *class = row->table->class;
size_t i;
- assert(!row->old && !row->new);
+ ovs_assert(!row->old && !row->new);
row->old = row->new = xmalloc(class->n_columns * sizeof *row->old);
for (i = 0; i < class->n_columns; i++) {
ovsdb_datum_init_default(&row->old[i], &class->columns[i].type);
const struct ovsdb_idl_table_class *class;
size_t column_idx;
- assert(!ovsdb_idl_row_is_synthetic(row));
+ ovs_assert(!ovsdb_idl_row_is_synthetic(row));
class = row->table->class;
column_idx = column - class->columns;
- assert(row->new != NULL);
- assert(column_idx < class->n_columns);
+ ovs_assert(row->new != NULL);
+ ovs_assert(column_idx < class->n_columns);
if (row->written && bitmap_is_set(row->written, column_idx)) {
return &row->new[column_idx];
enum ovsdb_atomic_type key_type OVS_UNUSED,
enum ovsdb_atomic_type value_type OVS_UNUSED)
{
- assert(column->type.key.type == key_type);
- assert(column->type.value.type == value_type);
+ ovs_assert(column->type.key.type == key_type);
+ ovs_assert(column->type.value.type == value_type);
return ovsdb_idl_read(row, column);
}
{
struct ovsdb_idl_txn *txn;
- assert(!idl->txn);
+ ovs_assert(!idl->txn);
idl->txn = txn = xmalloc(sizeof *txn);
txn->request_id = NULL;
txn->idl = idl;
const struct ovsdb_idl_row *row,
const struct ovsdb_idl_column *column)
{
- assert(!txn->inc_table);
- assert(column->type.key.type == OVSDB_TYPE_INTEGER);
- assert(column->type.value.type == OVSDB_TYPE_VOID);
+ ovs_assert(!txn->inc_table);
+ ovs_assert(column->type.key.type == OVSDB_TYPE_INTEGER);
+ ovs_assert(column->type.value.type == OVSDB_TYPE_VOID);
txn->inc_table = row->table->class->name;
txn->inc_column = column->name;
int64_t
ovsdb_idl_txn_get_increment_new_value(const struct ovsdb_idl_txn *txn)
{
- assert(txn->status == TXN_SUCCESS);
+ ovs_assert(txn->status == TXN_SUCCESS);
return txn->inc_new_value;
}
{
const struct ovsdb_idl_txn_insert *insert;
- assert(txn->status == TXN_SUCCESS || txn->status == TXN_UNCHANGED);
+ ovs_assert(txn->status == TXN_SUCCESS || txn->status == TXN_UNCHANGED);
HMAP_FOR_EACH_IN_BUCKET (insert, hmap_node,
uuid_hash(uuid), &txn->inserted_rows) {
if (uuid_equals(uuid, &insert->dummy)) {
column_idx = column - class->columns;
write_only = row->table->modes[column_idx] == OVSDB_IDL_MONITOR;
- assert(row->new != NULL);
- assert(column_idx < class->n_columns);
- assert(row->old == NULL ||
- row->table->modes[column_idx] & OVSDB_IDL_MONITOR);
+ ovs_assert(row->new != NULL);
+ ovs_assert(column_idx < class->n_columns);
+ ovs_assert(row->old == NULL ||
+ row->table->modes[column_idx] & OVSDB_IDL_MONITOR);
if (row->table->idl->verify_write_only && !write_only) {
VLOG_ERR("Bug: Attempt to write to a read/write column (%s:%s) when"
class = row->table->class;
column_idx = column - class->columns;
- assert(row->new != NULL);
- assert(row->old == NULL ||
- row->table->modes[column_idx] & OVSDB_IDL_MONITOR);
+ ovs_assert(row->new != NULL);
+ ovs_assert(row->old == NULL ||
+ row->table->modes[column_idx] & OVSDB_IDL_MONITOR);
if (!row->old
|| (row->written && bitmap_is_set(row->written, column_idx))) {
return;
return;
}
- assert(row->new != NULL);
+ ovs_assert(row->new != NULL);
if (!row->old) {
ovsdb_idl_row_unparse(row);
ovsdb_idl_row_clear_new(row);
- assert(!row->prereqs);
+ ovs_assert(!row->prereqs);
hmap_remove(&row->table->rows, &row->hmap_node);
hmap_remove(&row->table->idl->txn->txn_rows, &row->txn_node);
free(row);
struct ovsdb_idl_row *row = ovsdb_idl_row_create__(class);
if (uuid) {
- assert(!ovsdb_idl_txn_get_row(txn, uuid));
+ ovs_assert(!ovsdb_idl_txn_get_row(txn, uuid));
row->uuid = *uuid;
} else {
uuid_generate(&row->uuid);
ovsdb_idl_txn_get(const struct ovsdb_idl_row *row)
{
struct ovsdb_idl_txn *txn = row->table->idl->txn;
- assert(txn != NULL);
+ ovs_assert(txn != NULL);
return txn;
}
void
ovsdb_idl_set_lock(struct ovsdb_idl *idl, const char *lock_name)
{
- assert(!idl->txn);
- assert(hmap_is_empty(&idl->outstanding_txns));
+ ovs_assert(!idl->txn);
+ ovs_assert(hmap_is_empty(&idl->outstanding_txns));
if (idl->lock_name && (!lock_name || strcmp(lock_name, idl->lock_name))) {
/* Release previous lock. */
/*
- * Copyright (c) 2009, 2010 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <config.h>
#include "pcap.h"
-#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <string.h>
{
FILE *file;
- assert(!strcmp(mode, "rb") || !strcmp(mode, "wb"));
+ ovs_assert(!strcmp(mode, "rb") || !strcmp(mode, "wb"));
file = fopen(file_name, mode);
if (file == NULL) {
#include <config.h>
#include "poll-loop.h"
-#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <poll.h>
new_waiter(int fd, short int events, const char *where)
{
struct poll_waiter *waiter = xzalloc(sizeof *waiter);
- assert(fd >= 0);
+ ovs_assert(fd >= 0);
waiter->fd = fd;
waiter->events = events;
waiter->where = where;
#include <config.h>
#include "process.h"
-#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
struct process *p;
const char *slash;
- assert(sigchld_is_blocked());
+ ovs_assert(sigchld_is_blocked());
p = xzalloc(sizeof *p);
p->pid = pid;
int
process_status(const struct process *p)
{
- assert(p->exited);
+ ovs_assert(p->exited);
return p->status;
}
#include <config.h>
#include "random.h"
-#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/time.h>
void
random_set_seed(uint32_t seed_)
{
- assert(seed_);
+ ovs_assert(seed_);
seed = seed_;
}
#include <config.h>
#include "rconn.h"
-#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
rconn_connect_unreliably(struct rconn *rc,
struct vconn *vconn, const char *name)
{
- assert(vconn != NULL);
+ ovs_assert(vconn != NULL);
rconn_disconnect(rc);
rconn_set_target__(rc, vconn_get_name(vconn), name);
rc->reliable = false;
rc->name, (unsigned int) (time_now() - base));
version = rconn_get_version(rc);
- assert(version >= 0 && version <= 0xff);
+ ovs_assert(version >= 0 && version <= 0xff);
/* Ordering is important here: rconn_send() can transition to BACKOFF,
* and we don't want to transition back to IDLE if so, because then we
rconn_packet_counter_destroy(struct rconn_packet_counter *c)
{
if (c) {
- assert(c->ref_cnt > 0);
+ ovs_assert(c->ref_cnt > 0);
if (!--c->ref_cnt && !c->n_packets) {
free(c);
}
void
rconn_packet_counter_dec(struct rconn_packet_counter *c, unsigned int n_bytes)
{
- assert(c->n_packets > 0);
- assert(c->n_bytes >= n_bytes);
+ ovs_assert(c->n_packets > 0);
+ ovs_assert(c->n_bytes >= n_bytes);
c->n_bytes -= n_bytes;
c->n_packets--;
if (!c->n_packets) {
- assert(!c->n_bytes);
+ ovs_assert(!c->n_bytes);
if (!c->ref_cnt) {
free(c);
}
#include <config.h>
#include "reconnect.h"
-#include <assert.h>
#include <stdlib.h>
#include "poll-loop.h"
static long long int
reconnect_deadline__(const struct reconnect *fsm)
{
- assert(fsm->state_entered != LLONG_MIN);
+ ovs_assert(fsm->state_entered != LLONG_MIN);
switch (fsm->state) {
case S_VOID:
case S_LISTENING:
#include "route-table.h"
-#include <assert.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <linux/rtnetlink.h>
route_table_register(void)
{
if (!register_count) {
- assert(!nln);
- assert(!route_notifier);
+ ovs_assert(!nln);
+ ovs_assert(!route_notifier);
nln = nln_create(NETLINK_ROUTE, RTNLGRP_IPV4_ROUTE,
(nln_parse_func *) route_table_parse, &rtmsg);
#include <config.h>
#include "shash.h"
-#include <assert.h>
#include "hash.h"
static struct shash_node *shash_find__(const struct shash *,
shash_add_assert(struct shash *sh, const char *name, const void *data)
{
bool added OVS_UNUSED = shash_add_once(sh, name, data);
- assert(added);
+ ovs_assert(added);
}
/* Searches for 'name' in 'sh'. If it does not already exist, adds it along
shash_find_and_delete_assert(struct shash *sh, const char *name)
{
void *data = shash_find_and_delete(sh, name);
- assert(data != NULL);
+ ovs_assert(data != NULL);
return data;
}
SHASH_FOR_EACH (node, sh) {
nodes[i++] = node;
}
- assert(i == n);
+ ovs_assert(i == n);
qsort(nodes, n, sizeof *nodes, compare_nodes_by_name);
#include <config.h>
#include "signals.h"
-#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <signal.h>
s->signr = signr;
/* Set up signal handler. */
- assert(signr >= 1 && signr < N_SIGNALS);
+ ovs_assert(signr >= 1 && signr < N_SIGNALS);
memset(&sa, 0, sizeof sa);
sa.sa_handler = signal_handler;
sigemptyset(&sa.sa_mask);
#include <config.h>
#include "simap.h"
-#include <assert.h>
#include "hash.h"
static size_t hash_name(const char *, size_t length);
SIMAP_FOR_EACH (node, simap) {
nodes[i++] = node;
}
- assert(i == n);
+ ovs_assert(i == n);
qsort(nodes, n, sizeof *nodes, compare_nodes_by_name);
#include <config.h>
#include "smap.h"
-#include <assert.h>
-
#include "hash.h"
#include "json.h"
SMAP_FOR_EACH (node, smap) {
nodes[i++] = node;
}
- assert(i == n);
+ ovs_assert(i == n);
qsort(nodes, n, sizeof *nodes, compare_nodes_by_key);
#include <config.h>
#include "socket-util.h"
#include <arpa/inet.h>
-#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <net/if.h>
const struct iovec *iovs, size_t n_iovs,
const int fds[], size_t n_fds)
{
- assert(sock >= 0);
+ ovs_assert(sock >= 0);
if (n_fds > 0) {
union {
struct cmsghdr cm;
} cmsg;
struct msghdr msg;
- assert(!iovec_is_empty(iovs, n_iovs));
- assert(n_fds <= SOUTIL_MAX_FDS);
+ ovs_assert(!iovec_is_empty(iovs, n_iovs));
+ ovs_assert(n_fds <= SOUTIL_MAX_FDS);
memset(&cmsg, 0, sizeof cmsg);
cmsg.cm.cmsg_len = CMSG_LEN(n_fds * sizeof *fds);
size_t n_fds = (p->cmsg_len - CMSG_LEN(0)) / sizeof *fds;
const int *fds_data = (const int *) CMSG_DATA(p);
- assert(n_fds > 0);
+ ovs_assert(n_fds > 0);
if (n_fds > SOUTIL_MAX_FDS) {
VLOG_ERR("%zu fds received but only %d supported",
n_fds, SOUTIL_MAX_FDS);
/*
- * Copyright (c) 2011 Nicira, Inc.
+ * Copyright (c) 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "sset.h"
-#include <assert.h>
-
#include "hash.h"
static uint32_t
sset_add_assert(struct sset *set, const char *name)
{
bool added OVS_UNUSED = sset_add(set, name);
- assert(added);
+ ovs_assert(added);
}
/* Adds a copy of each of the 'n' names in 'names' to 'set'. */
sset_find_and_delete_assert(struct sset *set, const char *name)
{
bool deleted OVS_UNUSED = sset_find_and_delete(set, name);
- assert(deleted);
+ ovs_assert(deleted);
}
/* Removes a string from 'set' and returns a copy of it. The caller must free
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <assert.h>
#include <inttypes.h>
#include <stdlib.h>
#include "byte-order.h"
struct stp_port *
stp_get_port(struct stp *stp, int port_no)
{
- assert(port_no >= 0 && port_no < ARRAY_SIZE(stp->ports));
+ ovs_assert(port_no >= 0 && port_no < ARRAY_SIZE(stp->ports));
return &stp->ports[port_no];
}
stp_port_no(const struct stp_port *p)
{
struct stp *stp = p->stp;
- assert(p >= stp->ports && p < &stp->ports[ARRAY_SIZE(stp->ports)]);
+ ovs_assert(p >= stp->ports && p < &stp->ports[ARRAY_SIZE(stp->ports)]);
return p - stp->ports;
}
static void
stp_initialize_port(struct stp_port *p, enum stp_state state)
{
- assert(state & (STP_DISABLED | STP_BLOCKING));
+ ovs_assert(state & (STP_DISABLED | STP_BLOCKING));
stp_become_designated_port(p);
stp_set_port_state(p, state);
p->topology_change_ack = false;
/*
- * Copyright (c) 2009, 2010 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#ifndef STREAM_PROVIDER_H
#define STREAM_PROVIDER_H 1
-#include <assert.h>
#include <sys/types.h>
#include "stream.h"
static inline void stream_assert_class(const struct stream *stream,
const struct stream_class *class)
{
- assert(stream->class == class);
+ ovs_assert(stream->class == class);
}
struct stream_class {
static inline void pstream_assert_class(const struct pstream *pstream,
const struct pstream_class *class)
{
- assert(pstream->class == class);
+ ovs_assert(pstream->class == class);
}
struct pstream_class {
#include <config.h>
#include "stream-ssl.h"
#include "dhparams.h"
-#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
ssize_t ret;
/* Behavior of zero-byte SSL_read is poorly defined. */
- assert(n > 0);
+ ovs_assert(n > 0);
old_state = SSL_get_state(sslv->ssl);
ret = SSL_read(sslv->ssl, buffer, n);
static int init_status = -1;
if (init_status < 0) {
init_status = do_ssl_init();
- assert(init_status >= 0);
+ ovs_assert(init_status >= 0);
}
return init_status;
}
#include <config.h>
#include "stream-provider.h"
-#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <netinet/in.h>
for (i = 0; i < ARRAY_SIZE(stream_classes); i++) {
const struct stream_class *class = stream_classes[i];
- assert(class->name != NULL);
- assert(class->open != NULL);
+ ovs_assert(class->name != NULL);
+ ovs_assert(class->open != NULL);
if (class->close || class->recv || class->send || class->run
|| class->run_wait || class->wait) {
- assert(class->close != NULL);
- assert(class->recv != NULL);
- assert(class->send != NULL);
- assert(class->wait != NULL);
+ ovs_assert(class->close != NULL);
+ ovs_assert(class->recv != NULL);
+ ovs_assert(class->send != NULL);
+ ovs_assert(class->wait != NULL);
} else {
/* This class delegates to another one. */
}
for (i = 0; i < ARRAY_SIZE(pstream_classes); i++) {
const struct pstream_class *class = pstream_classes[i];
- assert(class->name != NULL);
- assert(class->listen != NULL);
+ ovs_assert(class->name != NULL);
+ ovs_assert(class->listen != NULL);
if (class->close || class->accept || class->wait) {
- assert(class->close != NULL);
- assert(class->accept != NULL);
- assert(class->wait != NULL);
+ ovs_assert(class->close != NULL);
+ ovs_assert(class->accept != NULL);
+ ovs_assert(class->wait != NULL);
} else {
/* This class delegates to another one. */
}
stream_connect_wait(stream);
poll_block();
}
- assert(error != EINPROGRESS);
+ ovs_assert(error != EINPROGRESS);
}
if (error) {
scs_connecting(struct stream *stream)
{
int retval = (stream->class->connect)(stream);
- assert(retval != EINPROGRESS);
+ ovs_assert(retval != EINPROGRESS);
if (!retval) {
stream->state = SCS_CONNECTED;
} else if (retval != EAGAIN) {
void
stream_wait(struct stream *stream, enum stream_wait_type wait)
{
- assert(wait == STREAM_CONNECT || wait == STREAM_RECV
- || wait == STREAM_SEND);
+ ovs_assert(wait == STREAM_CONNECT || wait == STREAM_RECV
+ || wait == STREAM_SEND);
switch (stream->state) {
case SCS_CONNECTING:
if (retval) {
*new_stream = NULL;
} else {
- assert((*new_stream)->state != SCS_CONNECTING
- || (*new_stream)->class->connect);
+ ovs_assert((*new_stream)->state != SCS_CONNECTING
+ || (*new_stream)->class->connect);
}
return retval;
}
: SCS_DISCONNECTED);
stream->error = connect_status;
stream->name = xstrdup(name);
- assert(stream->state != SCS_CONNECTING || class->connect);
+ ovs_assert(stream->state != SCS_CONNECTING || class->connect);
}
void
/*
- * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <config.h>
#include "svec.h"
-#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
void
svec_unique(struct svec *svec)
{
- assert(svec_is_sorted(svec));
+ ovs_assert(svec_is_sorted(svec));
if (svec->n > 1) {
/* This algorithm is lazy and sub-optimal, but it's "obviously correct"
* and asymptotically optimal . */
{
size_t i, j;
- assert(svec_is_sorted(a));
- assert(svec_is_sorted(b));
+ ovs_assert(svec_is_sorted(a));
+ ovs_assert(svec_is_sorted(b));
if (a_only) {
svec_init(a_only);
}
{
char **p;
- assert(svec_is_sorted(svec));
+ ovs_assert(svec_is_sorted(svec));
p = bsearch(&name, svec->names, svec->n, sizeof *svec->names,
compare_strings);
return p ? p - svec->names : SIZE_MAX;
const char *
svec_get_duplicate(const struct svec *svec)
{
- assert(svec_is_sorted(svec));
+ ovs_assert(svec_is_sorted(svec));
if (svec->n > 1) {
size_t i;
for (i = 1; i < svec->n; i++) {
const char *
svec_back(const struct svec *svec)
{
- assert(svec->n);
+ ovs_assert(svec->n);
return svec->names[svec->n - 1];
}
void
svec_pop_back(struct svec *svec)
{
- assert(svec->n);
+ ovs_assert(svec->n);
free(svec->names[--svec->n]);
}
#include "table.h"
-#include <assert.h>
-
#include "dynamic-string.h"
#include "json.h"
#include "ovsdb-data.h"
struct column *column;
va_list args;
- assert(!table->n_rows);
+ ovs_assert(!table->n_rows);
if (table->n_columns >= table->allocated_columns) {
table->columns = x2nrealloc(table->columns, &table->allocated_columns,
sizeof *table->columns);
{
size_t x, y;
- assert(table->n_rows > 0);
- assert(table->current_column < table->n_columns);
+ ovs_assert(table->n_rows > 0);
+ ovs_assert(table->current_column < table->n_columns);
x = table->current_column++;
y = table->n_rows - 1;
#include <config.h>
#include "timeval.h"
-#include <assert.h>
#include <errno.h>
#if HAVE_EXECINFO_H
#include <execinfo.h>
{
struct ds ds = DS_EMPTY_INITIALIZER;
- assert(HAVE_EXECINFO_H && CACHE_TIME);
+ ovs_assert(HAVE_EXECINFO_H && CACHE_TIME);
format_backtraces(&ds, 0);
unixctl_command_reply(conn, ds_cstr(&ds));
ds_destroy(&ds);
#include <config.h>
#include "unixctl.h"
-#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include "coverage.h"
struct unixctl_command *command;
struct unixctl_command *lookup = shash_find_data(&commands, name);
- assert(!lookup || lookup->cb == cb);
+ ovs_assert(!lookup || lookup->cb == cb);
if (lookup) {
return;
struct jsonrpc_msg *reply;
COVERAGE_INC(unixctl_replied);
- assert(conn->request_id);
+ ovs_assert(conn->request_id);
if (!body) {
body = "";
/* Provider interface to vconns, which provide a virtual connection to an
* OpenFlow device. */
-#include <assert.h>
#include "vconn.h"
+#include "util.h"
#include "openflow/openflow-common.h"
\f
/* Active virtual connection to an OpenFlow device. */
static inline void vconn_assert_class(const struct vconn *vconn,
const struct vconn_class *class)
{
- assert(vconn->class == class);
+ ovs_assert(vconn->class == class);
}
struct vconn_class {
static inline void pvconn_assert_class(const struct pvconn *pvconn,
const struct pvconn_class *class)
{
- assert(pvconn->class == class);
+ ovs_assert(pvconn->class == class);
}
struct pvconn_class {
#include <config.h>
#include "vconn-provider.h"
-#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <netinet/in.h>
for (i = 0; i < ARRAY_SIZE(vconn_classes); i++) {
struct vconn_class *class = vconn_classes[i];
- assert(class->name != NULL);
- assert(class->open != NULL);
+ ovs_assert(class->name != NULL);
+ ovs_assert(class->open != NULL);
if (class->close || class->recv || class->send
|| class->run || class->run_wait || class->wait) {
- assert(class->close != NULL);
- assert(class->recv != NULL);
- assert(class->send != NULL);
- assert(class->wait != NULL);
+ ovs_assert(class->close != NULL);
+ ovs_assert(class->recv != NULL);
+ ovs_assert(class->send != NULL);
+ ovs_assert(class->wait != NULL);
} else {
/* This class delegates to another one. */
}
for (i = 0; i < ARRAY_SIZE(pvconn_classes); i++) {
struct pvconn_class *class = pvconn_classes[i];
- assert(class->name != NULL);
- assert(class->listen != NULL);
+ ovs_assert(class->name != NULL);
+ ovs_assert(class->listen != NULL);
if (class->close || class->accept || class->wait) {
- assert(class->close != NULL);
- assert(class->accept != NULL);
- assert(class->wait != NULL);
+ ovs_assert(class->close != NULL);
+ ovs_assert(class->accept != NULL);
+ ovs_assert(class->wait != NULL);
} else {
/* This class delegates to another one. */
}
}
/* Success. */
- assert(vconn->state != VCS_CONNECTING || vconn->class->connect);
+ ovs_assert(vconn->state != VCS_CONNECTING || vconn->class->connect);
*vconnp = vconn;
return 0;
vcs_connecting(struct vconn *vconn)
{
int retval = (vconn->class->connect)(vconn);
- assert(retval != EINPROGRESS);
+ ovs_assert(retval != EINPROGRESS);
if (!retval) {
vconn->state = VCS_SEND_HELLO;
} else if (retval != EAGAIN) {
{
int retval;
- assert(msg->size >= sizeof(struct ofp_header));
+ ovs_assert(msg->size >= sizeof(struct ofp_header));
ofpmsg_update_length(msg);
if (!VLOG_IS_DBG_ENABLED()) {
vconn_connect_wait(vconn);
poll_block();
}
- assert(error != EINPROGRESS);
+ ovs_assert(error != EINPROGRESS);
return error;
}
void
vconn_wait(struct vconn *vconn, enum vconn_wait_type wait)
{
- assert(wait == WAIT_CONNECT || wait == WAIT_RECV || wait == WAIT_SEND);
+ ovs_assert(wait == WAIT_CONNECT || wait == WAIT_RECV || wait == WAIT_SEND);
switch (vconn->state) {
case VCS_CONNECTING:
if (retval) {
*new_vconn = NULL;
} else {
- assert((*new_vconn)->state != VCS_CONNECTING
- || (*new_vconn)->class->connect);
+ ovs_assert((*new_vconn)->state != VCS_CONNECTING
+ || (*new_vconn)->class->connect);
}
return retval;
}
vconn->local_ip = 0;
vconn->local_port = 0;
vconn->name = xstrdup(name);
- assert(vconn->state != VCS_CONNECTING || class->connect);
+ ovs_assert(vconn->state != VCS_CONNECTING || class->connect);
}
void
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <syslog.h>
#include <time.h>
#include <unistd.h>
-#include "coverage.h"
#include "dirs.h"
#include "dynamic-string.h"
#include "ofpbuf.h"
VLOG_DEFINE_THIS_MODULE(vlog);
-COVERAGE_DEFINE(vlog_recursive);
-
/* Name for each logging level. */
static const char *level_names[VLL_N_LEVELS] = {
#define VLOG_LEVEL(NAME, SYSLOG_LEVEL) #NAME,
}
}
-static void
-set_all_rate_limits(bool enable)
-{
- struct vlog_module **mp;
-
- for (mp = vlog_modules; mp < &vlog_modules[n_vlog_modules]; mp++) {
- (*mp)->honor_rate_limits = enable;
- }
-}
-
-static void
-set_rate_limits(struct unixctl_conn *conn, int argc,
- const char *argv[], bool enable)
-{
- if (argc > 1) {
- int i;
-
- for (i = 1; i < argc; i++) {
- if (!strcasecmp(argv[i], "ANY")) {
- set_all_rate_limits(enable);
- } else {
- struct vlog_module *module = vlog_module_from_name(argv[i]);
- if (!module) {
- unixctl_command_reply_error(conn, "unknown module");
- return;
- }
- module->honor_rate_limits = enable;
- }
- }
- } else {
- set_all_rate_limits(enable);
- }
- unixctl_command_reply(conn, NULL);
-}
-
-static void
-vlog_enable_rate_limit(struct unixctl_conn *conn, int argc,
- const char *argv[], void *aux OVS_UNUSED)
-{
- set_rate_limits(conn, argc, argv, true);
-}
-
-static void
-vlog_disable_rate_limit(struct unixctl_conn *conn, int argc,
- const char *argv[], void *aux OVS_UNUSED)
-{
- set_rate_limits(conn, argc, argv, false);
-}
-
/* Initializes the logging subsystem and registers its unixctl server
* commands. */
void
"vlog/set", "{spec | PATTERN:facility:pattern}",
1, INT_MAX, vlog_unixctl_set, NULL);
unixctl_command_register("vlog/list", "", 0, 0, vlog_unixctl_list, NULL);
- unixctl_command_register("vlog/enable-rate-limit", "[module]...",
- 0, INT_MAX, vlog_enable_rate_limit, NULL);
- unixctl_command_register("vlog/disable-rate-limit", "[module]...",
- 0, INT_MAX, vlog_disable_rate_limit, NULL);
unixctl_command_register("vlog/reopen", "", 0, 0,
vlog_unixctl_reopen, NULL);
}
ds_put_format(&s, " ------- ------ ------\n");
for (mp = vlog_modules; mp < &vlog_modules[n_vlog_modules]; mp++) {
- struct ds line;
-
- ds_init(&line);
- ds_put_format(&line, "%-16s %4s %4s %4s",
- vlog_get_module_name(*mp),
- vlog_get_level_name(vlog_get_level(*mp, VLF_CONSOLE)),
- vlog_get_level_name(vlog_get_level(*mp, VLF_SYSLOG)),
- vlog_get_level_name(vlog_get_level(*mp, VLF_FILE)));
- if (!(*mp)->honor_rate_limits) {
- ds_put_cstr(&line, " (rate limiting disabled)");
- }
- ds_put_char(&line, '\n');
-
- svec_add_nocopy(&lines, ds_steal_cstr(&line));
+ line = xasprintf("%-16s %4s %4s %4s\n",
+ vlog_get_module_name(*mp),
+ vlog_get_level_name(vlog_get_level(*mp, VLF_CONSOLE)),
+ vlog_get_level_name(vlog_get_level(*mp, VLF_SYSLOG)),
+ vlog_get_level_name(vlog_get_level(*mp, VLF_FILE)));
+ svec_add_nocopy(&lines, line);
}
svec_sort(&lines);
vlog_should_drop(const struct vlog_module *module, enum vlog_level level,
struct vlog_rate_limit *rl)
{
- if (!module->honor_rate_limits) {
- return false;
- }
-
if (!vlog_is_enabled(module, level)) {
return true;
}
vlog_write_file(struct ds *s)
{
if (worker_is_running()) {
- static bool in_worker_request = false;
- if (!in_worker_request) {
- in_worker_request = true;
-
- worker_request(s->string, s->length,
- &log_fd, vlog_async_inited ? 0 : 1,
- vlog_async_write_request_cb, NULL, NULL);
- vlog_async_inited = true;
-
- in_worker_request = false;
- return;
- } else {
- /* We've been entered recursively. This can happen if
- * worker_request(), or a function that it calls, tries to log
- * something. We can't call worker_request() recursively, so fall
- * back to writing the log file directly. */
- COVERAGE_INC(vlog_recursive);
- }
+ worker_request(s->string, s->length,
+ &log_fd, vlog_async_inited ? 0 : 1,
+ vlog_async_write_request_cb, NULL, NULL);
+ vlog_async_inited = true;
+ } else {
+ ignore(write(log_fd, s->string, s->length));
}
- ignore(write(log_fd, s->string, s->length));
}
static void
{
const uint32_t *async_config;
- assert(reason < 32);
- assert((unsigned int) type < OAM_N_TYPES);
+ ovs_assert(reason < 32);
+ ovs_assert((unsigned int) type < OAM_N_TYPES);
if (ofconn_get_protocol(ofconn) == OFPUTIL_P_NONE
|| !rconn_is_connected(ofconn->rconn)) {
#include "ofproto-dpif-governor.h"
-#include <assert.h>
#include <stdlib.h>
#include "coverage.h"
bool install_flow;
uint8_t *e;
- assert(n > 0);
+ ovs_assert(n > 0);
/* Count these packets and begin a new generation if necessary. */
g->n_packets += n;
static void
governor_new_generation(struct governor *g, unsigned int size)
{
- assert(size >= MIN_SIZE && size <= MAX_SIZE);
- assert(is_pow2(size));
+ ovs_assert(size >= MIN_SIZE && size <= MAX_SIZE);
+ ovs_assert(is_pow2(size));
/* Allocate new table, if necessary. */
if (g->size != size) {
static struct ofport_dpif *
ofport_dpif_cast(const struct ofport *ofport)
{
- assert(ofport->ofproto->ofproto_class == &ofproto_dpif_class);
+ ovs_assert(ofport->ofproto->ofproto_class == &ofproto_dpif_class);
return ofport ? CONTAINER_OF(ofport, struct ofport_dpif, up) : NULL;
}
static struct ofproto_dpif *
ofproto_dpif_cast(const struct ofproto *ofproto)
{
- assert(ofproto->ofproto_class == &ofproto_dpif_class);
+ ovs_assert(ofproto->ofproto_class == &ofproto_dpif_class);
return CONTAINER_OF(ofproto, struct ofproto_dpif, up);
}
{
struct shash_node *node;
- assert(backer->refcount > 0);
+ ovs_assert(backer->refcount > 0);
if (--backer->refcount) {
return;
}
*rulep = rule_dpif_lookup__(ofproto, &fm.match.flow, TBL_INTERNAL);
- assert(*rulep != NULL);
+ ovs_assert(*rulep != NULL);
return 0;
}
return 0;
}
- assert(s->n_slaves == 1 || s->bond != NULL);
- assert((s->lacp != NULL) == (s->lacp_slaves != NULL));
+ ovs_assert(s->n_slaves == 1 || s->bond != NULL);
+ ovs_assert((s->lacp != NULL) == (s->lacp_slaves != NULL));
bundle = bundle_lookup(ofproto, aux);
if (!bundle) {
found: ;
}
}
- assert(list_size(&bundle->ports) <= s->n_slaves);
+ ovs_assert(list_size(&bundle->ports) <= s->n_slaves);
if (list_is_empty(&bundle->ports)) {
bundle_destroy(bundle);
HMAP_FOR_EACH (miss, hmap_node, &todo) {
handle_flow_miss(miss, flow_miss_ops, &n_ops);
}
- assert(n_ops <= ARRAY_SIZE(flow_miss_ops));
+ ovs_assert(n_ops <= ARRAY_SIZE(flow_miss_ops));
/* Execute batch. */
for (i = 0; i < n_ops; i++) {
int n_misses;
int i;
- assert(max_batch <= FLOW_MISS_MAX_BATCH);
+ ovs_assert(max_batch <= FLOW_MISS_MAX_BATCH);
n_misses = 0;
for (n_processed = 0; n_processed < max_batch; n_processed++) {
struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto);
struct subfacet *subfacet, *next_subfacet;
- assert(!list_is_empty(&facet->subfacets));
+ ovs_assert(!list_is_empty(&facet->subfacets));
/* First uninstall all of the subfacets to get final statistics. */
LIST_FOR_EACH (subfacet, list_node, &facet->subfacets) {
struct subfacet *subfacet;
LIST_FOR_EACH (subfacet, list_node, &facet->subfacets) {
- assert(!subfacet->dp_byte_count);
- assert(!subfacet->dp_packet_count);
+ ovs_assert(!subfacet->dp_byte_count);
+ ovs_assert(!subfacet->dp_packet_count);
}
facet_push_stats(facet);
{
struct dpif_flow_stats stats;
- assert(facet->packet_count >= facet->prev_packet_count);
- assert(facet->byte_count >= facet->prev_byte_count);
- assert(facet->used >= facet->prev_used);
+ ovs_assert(facet->packet_count >= facet->prev_packet_count);
+ ovs_assert(facet->byte_count >= facet->prev_byte_count);
+ ovs_assert(facet->used >= facet->prev_used);
stats.n_packets = facet->packet_count - facet->prev_packet_count;
stats.n_bytes = facet->byte_count - facet->prev_byte_count;
}
subfacet->path = SF_NOT_INSTALLED;
} else {
- assert(subfacet->dp_packet_count == 0);
- assert(subfacet->dp_byte_count == 0);
+ ovs_assert(subfacet->dp_packet_count == 0);
+ ovs_assert(subfacet->dp_byte_count == 0);
}
}
cookie = ofpbuf_at(ctx->odp_actions, ctx->user_cookie_offset,
sizeof(*cookie));
- assert(cookie->type == USER_ACTION_COOKIE_SFLOW);
+ ovs_assert(cookie->type == USER_ACTION_COOKIE_SFLOW);
compose_sflow_cookie(ctx->ofproto, base->vlan_tci,
ctx->sflow_odp_port, ctx->sflow_n_outputs, cookie);
/* If the Ethernet type is less than ETH_TYPE_MIN, it's likely an 802.2
* LLC frame. Calculating the Ethernet type of these frames is more
* trouble than seems appropriate for a simple assertion. */
- assert(ntohs(eh->eth_type) < ETH_TYPE_MIN
- || eh->eth_type == ctx->flow.dl_type);
+ ovs_assert(ntohs(eh->eth_type) < ETH_TYPE_MIN
+ || eh->eth_type == ctx->flow.dl_type);
memcpy(eh->eth_src, ctx->flow.dl_src, sizeof eh->eth_src);
memcpy(eh->eth_dst, ctx->flow.dl_dst, sizeof eh->eth_dst);
/* XXX remove recursion */
/* It is assumed that goto-table is last action */
struct ofpact_goto_table *ogt = ofpact_get_GOTO_TABLE(a);
- assert(ctx->table_id < ogt->table_id);
+ ovs_assert(ctx->table_id < ogt->table_id);
xlate_table_action(ctx, ctx->flow.in_port, ogt->table_id, true);
break;
}
/*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
* Copyright (c) 2010 Jean Tourrilhes - HP-Labs.
*
* Licensed under the Apache License, Version 2.0 (the "License");
bitmap_set1(ofproto->ofp_port_ids, 0);
/* Check that hidden tables, if any, are at the end. */
- assert(ofproto->n_tables);
+ ovs_assert(ofproto->n_tables);
for (i = 0; i + 1 < ofproto->n_tables; i++) {
enum oftable_flags flags = ofproto->tables[i].flags;
enum oftable_flags next_flags = ofproto->tables[i + 1].flags;
- assert(!(flags & OFTABLE_HIDDEN) || next_flags & OFTABLE_HIDDEN);
+ ovs_assert(!(flags & OFTABLE_HIDDEN) || next_flags & OFTABLE_HIDDEN);
}
ofproto->datapath_id = pick_datapath_id(ofproto);
{
struct oftable *table;
- assert(!ofproto->n_tables);
- assert(n_tables >= 1 && n_tables <= 255);
+ ovs_assert(!ofproto->n_tables);
+ ovs_assert(n_tables >= 1 && n_tables <= 255);
ofproto->n_tables = n_tables;
ofproto->tables = xmalloc(n_tables * sizeof *ofproto->tables);
void
ofproto_init_max_ports(struct ofproto *ofproto, uint16_t max_ports)
{
- assert(max_ports <= OFPP_MAX);
+ ovs_assert(max_ports <= OFPP_MAX);
ofproto->max_ports = max_ports;
}
{
struct oftable *table;
- assert(table_id >= 0 && table_id < ofproto->n_tables);
+ ovs_assert(table_id >= 0 && table_id < ofproto->n_tables);
table = &ofproto->tables[table_id];
oftable_set_name(table, s->name);
{
struct oftable *table;
- assert(list_is_empty(&ofproto->pending));
- assert(!ofproto->n_pending);
+ ovs_assert(list_is_empty(&ofproto->pending));
+ ovs_assert(!ofproto->n_pending);
connmgr_destroy(ofproto->connmgr);
void
ofproto_rule_destroy(struct rule *rule)
{
- assert(!rule->pending);
+ ovs_assert(!rule->pending);
oftable_remove_rule(rule);
ofproto_rule_destroy__(rule);
}
{
struct flow flow;
- assert(ofpbuf_headroom(packet) >= sizeof(struct ofp10_packet_in));
+ ovs_assert(ofpbuf_headroom(packet) >= sizeof(struct ofp10_packet_in));
flow_extract(packet, 0, 0, NULL, in_port, &flow);
return rule->ofproto->ofproto_class->rule_execute(rule, &flow, packet);
ofproto->ofproto_class->get_features(ofproto, &arp_match_ip,
&features.actions);
- assert(features.actions & OFPUTIL_A_OUTPUT); /* sanity check */
+ ovs_assert(features.actions & OFPUTIL_A_OUTPUT); /* sanity check */
/* Count only non-hidden tables in the number of tables. (Hidden tables,
* if present, are always at the end.) */
enum ofp_config_flags cur = ofproto->frag_handling;
enum ofp_config_flags next = flags & OFPC_FRAG_MASK;
- assert((cur & OFPC_FRAG_MASK) == cur);
+ ovs_assert((cur & OFPC_FRAG_MASK) == cur);
if (cur != next) {
if (ofproto->ofproto_class->set_frag_handling(ofproto, next)) {
ofproto->frag_handling = next;
if (error) {
return error;
}
- assert(table_id < ofproto->n_tables);
+ ovs_assert(table_id < ofproto->n_tables);
table = &ofproto->tables[table_id];
} else {
table = &ofproto->tables[0];
struct ofproto *ofproto = rule->ofproto;
struct ofopgroup *group;
- assert(reason == OFPRR_HARD_TIMEOUT || reason == OFPRR_IDLE_TIMEOUT);
+ ovs_assert(reason == OFPRR_HARD_TIMEOUT || reason == OFPRR_IDLE_TIMEOUT);
ofproto_rule_send_removed(rule, reason);
const struct ofp_header *oh)
{
if (ofproto->n_pending >= 50) {
- assert(!list_is_empty(&ofproto->pending));
+ ovs_assert(!list_is_empty(&ofproto->pending));
return OFPROTO_POSTPONE;
}
cls_cursor_init(&cursor, &table->cls, &target);
CLS_CURSOR_FOR_EACH (rule, cr, &cursor) {
- assert(!rule->pending); /* XXX */
+ ovs_assert(!rule->pending); /* XXX */
ofproto_collect_ofmonitor_refresh_rule(m, rule, seqno, rules);
}
}
if (ofconn) {
size_t request_len = ntohs(request->length);
- assert(ofconn_get_ofproto(ofconn) == ofproto);
+ ovs_assert(ofconn_get_ofproto(ofconn) == ofproto);
ofconn_add_opgroup(ofconn, &group->ofconn_node);
group->ofconn = ofconn;
struct ofoperation *op, *next_op;
int error;
- assert(!group->n_running);
+ ovs_assert(!group->n_running);
error = 0;
LIST_FOR_EACH (op, group_node, &group->ops) {
error = ofconn_pktbuf_retrieve(group->ofconn, group->buffer_id,
&packet, &in_port);
if (packet) {
- assert(!error);
+ ovs_assert(!error);
error = rule_execute(op->rule, in_port, packet);
}
break;
break;
case OFOPERATION_DELETE:
- assert(!op->error);
+ ovs_assert(!op->error);
ofproto_rule_destroy__(rule);
op->rule = NULL;
break;
ofmonitor_flush(ofproto->connmgr);
if (!list_is_empty(&group->ofproto_node)) {
- assert(ofproto->n_pending > 0);
+ ovs_assert(ofproto->n_pending > 0);
ofproto->n_pending--;
list_remove(&group->ofproto_node);
}
struct ofproto *ofproto = group->ofproto;
struct ofoperation *op;
- assert(!rule->pending);
+ ovs_assert(!rule->pending);
op = rule->pending = xzalloc(sizeof *op);
op->group = group;
{
struct ofopgroup *group = op->group;
- assert(op->rule->pending == op);
- assert(group->n_running > 0);
- assert(!error || op->type != OFOPERATION_DELETE);
+ ovs_assert(op->rule->pending == op);
+ ovs_assert(group->n_running > 0);
+ ovs_assert(!error || op->type != OFOPERATION_DELETE);
op->error = error;
if (!--group->n_running && !list_is_empty(&group->ofproto_node)) {
struct rule *
ofoperation_get_victim(struct ofoperation *op)
{
- assert(op->type == OFOPERATION_ADD);
+ ovs_assert(op->type == OFOPERATION_ADD);
return op->victim;
}
\f
static void
oftable_destroy(struct oftable *table)
{
- assert(classifier_is_empty(&table->cls));
+ ovs_assert(classifier_is_empty(&table->cls));
oftable_disable_eviction(table);
classifier_destroy(&table->cls);
free(table->name);
struct ofport *ofport;
int error;
- assert(vlandev_ofp_port != realdev_ofp_port);
+ ovs_assert(vlandev_ofp_port != realdev_ofp_port);
ofport = ofproto_get_port(ofproto, vlandev_ofp_port);
if (!ofport) {
#include <config.h>
-#include <assert.h>
#include <limits.h>
#include "column.h"
op_name);
}
} else {
- assert(ovsdb_parser_has_error(&parser));
+ ovs_assert(ovsdb_parser_has_error(&parser));
}
/* A parse error overrides any other error.
#include "file.h"
-#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
struct ovsdb_error *error;
struct json *json = NULL;
- assert(logp || schemap);
+ ovs_assert(logp || schemap);
error = ovsdb_log_open(file_name, open_mode, -1, &log);
if (error) {
struct ovsdb *db = NULL;
/* In read-only mode there is no ovsdb_file so 'filep' must be null. */
- assert(!(read_only && filep));
+ ovs_assert(!(read_only && filep));
open_mode = read_only ? OVSDB_LOG_READ_ONLY : OVSDB_LOG_READ_WRITE;
error = ovsdb_file_open_log(file_name, open_mode, &log,
struct ovsdb_error *
ovsdb_file_read_schema(const char *file_name, struct ovsdb_schema **schemap)
{
- assert(schemap != NULL);
+ ovs_assert(schemap != NULL);
return ovsdb_file_open_log(file_name, OVSDB_LOG_READ_ONLY, NULL, schemap);
}
\f
static struct ovsdb_file *
ovsdb_file_cast(struct ovsdb_replica *replica)
{
- assert(replica->class == &ovsdb_file_class);
+ ovs_assert(replica->class == &ovsdb_file_class);
return CONTAINER_OF(replica, struct ovsdb_file, replica);
}
#include "jsonrpc-server.h"
-#include <assert.h>
#include <errno.h>
#include "bitmap.h"
static struct ovsdb_jsonrpc_monitor *
ovsdb_jsonrpc_monitor_cast(struct ovsdb_replica *replica)
{
- assert(replica->class == &ovsdb_jsonrpc_replica_class);
+ ovs_assert(replica->class == &ovsdb_jsonrpc_replica_class);
return CONTAINER_OF(replica, struct ovsdb_jsonrpc_monitor, replica);
}
#include "log.h"
-#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
*filep = NULL;
- assert(locking == -1 || locking == false || locking == true);
+ ovs_assert(locking == -1 || locking == false || locking == true);
if (locking < 0) {
locking = open_mode != OVSDB_LOG_READ_ONLY;
}
void
ovsdb_log_unread(struct ovsdb_log *file)
{
- assert(file->mode == OVSDB_LOG_READ);
+ ovs_assert(file->mode == OVSDB_LOG_READ);
file->offset = file->prev_offset;
}
#include <config.h>
#include %s
-#include <assert.h>
#include <limits.h>
#include "ovsdb-data.h"
#include "ovsdb-error.h"
+#include "util.h"
#ifdef __CHECKER__
/* Sparse dislikes sizeof(bool) ("warning: expression using sizeof bool"). */
if type.is_smap():
print " size_t i;"
print
- print " assert(inited);"
+ print " ovs_assert(inited);"
print " smap_init(&row->%s);" % columnName
print " for (i = 0; i < datum->n; i++) {"
print " smap_add(&row->%s," % columnName
print " }"
elif (type.n_min == 1 and type.n_max == 1) or type.is_optional_pointer():
print
- print " assert(inited);"
+ print " ovs_assert(inited);"
print " if (datum->n >= 1) {"
if not type.key.ref_table:
print " %s = datum->keys[0].%s;" % (keyVar, type.key.type.to_string())
nMax = "datum->n"
print " size_t i;"
print
- print " assert(inited);"
+ print " ovs_assert(inited);"
print " %s = NULL;" % keyVar
if valueVar:
print " %s = NULL;" % valueVar
{
struct %(s)s *row = %(s)s_cast(row_);
- assert(inited);''' % {'s': structName, 'c': columnName}
+ ovs_assert(inited);''' % {'s': structName, 'c': columnName}
if type.is_smap():
print " smap_destroy(&row->%s);" % columnName
void
%(s)s_verify_%(c)s(const struct %(s)s *row)
{
- assert(inited);
+ ovs_assert(inited);
ovsdb_idl_txn_verify(&row->header_, &%(s)s_columns[%(S)s_COL_%(C)s]);
}''' % {'s': structName,
'S': structName.upper(),
for columnName, column in sorted(table.columns.iteritems()):
if column.type.value:
valueParam = ',\n\tenum ovsdb_atomic_type value_type OVS_UNUSED'
- valueType = '\n assert(value_type == %s);' % column.type.value.toAtomicType()
+ valueType = '\n ovs_assert(value_type == %s);' % column.type.value.toAtomicType()
valueComment = "\n * 'value_type' must be %s." % column.type.value.toAtomicType()
else:
valueParam = ''
%(s)s_get_%(c)s(const struct %(s)s *row,
\tenum ovsdb_atomic_type key_type OVS_UNUSED%(v)s)
{
- assert(key_type == %(kt)s);%(vt)s
+ ovs_assert(key_type == %(kt)s);%(vt)s
return ovsdb_idl_read(&row->header_, &%(s)s_col_%(c)s);
}""" % {'s': structName, 'c': columnName,
'kt': column.type.key.toAtomicType(),
{
struct ovsdb_datum datum;
- assert(inited);
+ ovs_assert(inited);
if (smap) {
struct smap_node *node;
size_t i;
print " struct ovsdb_datum datum;"
if type.n_min == 1 and type.n_max == 1:
print
- print " assert(inited);"
+ print " ovs_assert(inited);"
print " datum.n = 1;"
print " datum.keys = xmalloc(sizeof *datum.keys);"
print " " + type.key.copyCValue("datum.keys[0].%s" % type.key.type.to_string(), keyVar)
print " datum.values = NULL;"
elif type.is_optional_pointer():
print
- print " assert(inited);"
+ print " ovs_assert(inited);"
print " if (%s) {" % keyVar
print " datum.n = 1;"
print " datum.keys = xmalloc(sizeof *datum.keys);"
else:
print " size_t i;"
print
- print " assert(inited);"
+ print " ovs_assert(inited);"
print " datum.n = %s;" % nVar
print " datum.keys = xmalloc(%s * sizeof *datum.keys);" % nVar
if type.value:
#include "row.h"
-#include <assert.h>
#include <stddef.h>
#include "dynamic-string.h"
{
struct ovsdb_row_hash_node *node;
- assert(ovsdb_column_set_equals(&a->columns, &b->columns));
+ ovs_assert(ovsdb_column_set_equals(&a->columns, &b->columns));
HMAP_FOR_EACH (node, hmap_node, &b->rows) {
if (!ovsdb_row_hash_contains__(a, node->row, node->hmap_node.hash)) {
return false;
#include "server.h"
-#include <assert.h>
-
#include "hash.h"
#include "ovsdb.h"
void
ovsdb_session_destroy(struct ovsdb_session *session)
{
- assert(hmap_is_empty(&session->waiters));
+ ovs_assert(hmap_is_empty(&session->waiters));
hmap_destroy(&session->waiters);
}
void
ovsdb_lock_waiter_destroy(struct ovsdb_lock_waiter *waiter)
{
- assert(!waiter->lock);
+ ovs_assert(!waiter->lock);
hmap_remove(&waiter->session->waiters, &waiter->session_node);
free(waiter->lock_name);
free(waiter);
-/* Copyright (c) 2009, 2010, 2011 Nicira, Inc.
+/* Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "table.h"
-#include <assert.h>
#include <limits.h>
#include "json.h"
static void
add_column(struct ovsdb_table_schema *ts, struct ovsdb_column *column)
{
- assert(!shash_find(&ts->columns, column->name));
+ ovs_assert(!shash_find(&ts->columns, column->name));
column->index = shash_count(&ts->columns);
shash_add(&ts->columns, column->name, column);
}
uuid = ovsdb_column_create("_uuid", false, true, &ovsdb_type_uuid);
add_column(ts, uuid);
- assert(uuid->index == OVSDB_COL_UUID);
+ ovs_assert(uuid->index == OVSDB_COL_UUID);
version = ovsdb_column_create("_version", false, false, &ovsdb_type_uuid);
add_column(ts, version);
- assert(version->index == OVSDB_COL_VERSION);
+ ovs_assert(version->index == OVSDB_COL_VERSION);
ts->n_indexes = 0;
ts->indexes = NULL;
#include "transaction.h"
-#include <assert.h>
-
#include "bitmap.h"
#include "dynamic-string.h"
#include "hash.h"
static void
ovsdb_txn_free(struct ovsdb_txn *txn)
{
- assert(list_is_empty(&txn->txn_tables));
+ ovs_assert(list_is_empty(&txn->txn_tables));
ds_destroy(&txn->comment);
free(txn);
}
if (error) {
/* We don't support two-phase commit so only the first replica is
* allowed to report an error. */
- assert(&replica->node == txn->db->replicas.next);
+ ovs_assert(&replica->node == txn->db->replicas.next);
ovsdb_txn_abort(txn);
return error;
struct ovsdb_row *ro_row = CONST_CAST(struct ovsdb_row *, ro_row_);
if (ro_row->txn_row) {
- assert(ro_row == ro_row->txn_row->new);
+ ovs_assert(ro_row == ro_row->txn_row->new);
return ro_row;
} else {
struct ovsdb_table *table = ro_row->table;
if (!txn_row) {
ovsdb_txn_row_create(txn, table, row, NULL);
} else {
- assert(txn_row->new == row);
+ ovs_assert(txn_row->new == row);
if (txn_row->old) {
txn_row->new = NULL;
} else {
{
size_t i;
- assert(hmap_is_empty(&txn_table->txn_rows));
+ ovs_assert(hmap_is_empty(&txn_table->txn_rows));
for (i = 0; i < txn_table->table->schema->n_indexes; i++) {
hmap_destroy(&txn_table->txn_indexes[i]);
#include "trigger.h"
-#include <assert.h>
#include <limits.h>
#include "json.h"
static void
ovsdb_trigger_complete(struct ovsdb_trigger *t)
{
- assert(t->result != NULL);
+ ovs_assert(t->result != NULL);
list_remove(&t->node);
list_push_back(&t->session->completions, &t->node);
}
noinst_PROGRAMS += tests/test-list
tests_test_list_SOURCES = tests/test-list.c
-tests_test_list_LDADD = lib/libopenvswitch.a
+tests_test_list_LDADD = lib/libopenvswitch.a $(SSL_LIBS)
noinst_PROGRAMS += tests/test-lockfile
tests_test_lockfile_SOURCES = tests/test-lockfile.c
#include <config.h>
#include <arpa/inet.h>
-#include <assert.h>
#include <errno.h>
#include <getopt.h>
#include <inttypes.h>
size_t bytes = (uint8_t *) end - (uint8_t *) first;
size_t n = bytes / NL_A_U32_SIZE;
- assert(bytes % NL_A_U32_SIZE == 0);
+ ovs_assert(bytes % NL_A_U32_SIZE == 0);
qsort(first, n, NL_A_U32_SIZE, compare_output_actions);
}
HMAP_FOR_EACH (af, hmap_node, &actions_per_flow) {
afs[i++] = af;
}
- assert(i == n_afs);
+ ovs_assert(i == n_afs);
qsort(afs, n_afs, sizeof *afs, compare_actions_for_flow);
break;
}
}
- assert(IS_POW2(protocol));
+ ovs_assert(IS_POW2(protocol));
printf("chosen protocol: %s\n", ofputil_protocol_to_string(protocol));
#include <config.h>
-#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
char *equals;
int has_arg;
- assert(name[0] == '-' && name[1] == '-' && name[2]);
+ ovs_assert(name[0] == '-' && name[1] == '-' && name[2]);
name += 2;
equals = strchr(name, '=');
o = find_option(name, options, n_options);
if (o) {
- assert(o - options >= n_global_long_options);
- assert(o->has_arg == has_arg);
+ ovs_assert(o - options >= n_global_long_options);
+ ovs_assert(o->has_arg == has_arg);
} else {
o = add_option(&options, &n_options, &allocated_options);
o->name = xstrdup(name);
static void
del_cached_bridge(struct vsctl_context *ctx, struct vsctl_bridge *br)
{
- assert(list_is_empty(&br->ports));
- assert(hmap_is_empty(&br->children));
+ ovs_assert(list_is_empty(&br->ports));
+ ovs_assert(hmap_is_empty(&br->children));
if (br->parent) {
hmap_remove(&br->parent->children, &br->children_node);
}
static void
del_cached_port(struct vsctl_context *ctx, struct vsctl_port *port)
{
- assert(list_is_empty(&port->ifaces));
+ ovs_assert(list_is_empty(&port->ifaces));
list_remove(&port->ports_node);
shash_find_and_delete(&ctx->ports, port->port_cfg->name);
ovsrec_port_delete(port->port_cfg);
{
struct vsctl_bridge *br;
- assert(ctx->cache_valid);
+ ovs_assert(ctx->cache_valid);
br = shash_find_data(&ctx->bridges, name);
if (must_exist && !br) {
{
struct vsctl_port *port;
- assert(ctx->cache_valid);
+ ovs_assert(ctx->cache_valid);
port = shash_find_data(&ctx->ports, name);
if (port && !strcmp(name, port->bridge->name)) {
{
struct vsctl_iface *iface;
- assert(ctx->cache_valid);
+ ovs_assert(ctx->cache_valid);
iface = shash_find_data(&ctx->ifaces, name);
if (iface && !strcmp(name, iface->port->bridge->name)) {
char *column_name;
char *error;
- assert(!(operatorp && !valuep));
+ ovs_assert(!(operatorp && !valuep));
*keyp = NULL;
if (valuep) {
*valuep = NULL;
(c->syntax->prerequisites)(&ctx);
vsctl_context_done(&ctx, c);
- assert(!c->output.string);
- assert(!c->table);
+ ovs_assert(!c->output.string);
+ ovs_assert(!c->table);
}
}
}
#include <config.h>
#include "bridge.h"
-#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <stdlib.h>
COVERAGE_INC(bridge_reconfigure);
- assert(!reconfiguring);
+ ovs_assert(!reconfiguring);
reconfiguring = true;
/* Destroy "struct bridge"s, "struct port"s, and "struct iface"s according
struct bridge *br;
bool done;
- assert(reconfiguring);
+ ovs_assert(reconfiguring);
done = bridge_reconfigure_ofp();
/* Complete the configuration. */
{
struct bridge *br = iface->port->bridge;
- assert(iface->ofp_port < 0 && ofp_port >= 0);
+ ovs_assert(iface->ofp_port < 0 && ofp_port >= 0);
iface->ofp_port = ofp_port;
hmap_insert(&br->ifaces, &iface->ofp_port_node, hash_int(ofp_port, 0));
iface_set_ofport(iface->cfg, ofp_port);
* internal datastructures may not be consistent. Eventually, when port
* additions and deletions are cheaper, these calls should be removed. */
bridge_run_fast();
- assert(!iface_lookup(br, iface_cfg->name));
+ ovs_assert(!iface_lookup(br, iface_cfg->name));
error = iface_do_create(br, if_cfg, &ofp_port, &netdev);
bridge_run_fast();
if (error) {
#define IFACE_STAT(MEMBER, NAME) values[i++] = stats.MEMBER;
IFACE_STATS;
#undef IFACE_STAT
- assert(i == ARRAY_SIZE(keys));
+ ovs_assert(i == ARRAY_SIZE(keys));
ovsrec_interface_set_statistics(iface->cfg, keys, values,
ARRAY_SIZE(keys));
{
struct bridge *br;
- assert(!bridge_lookup(br_cfg->name));
+ ovs_assert(!bridge_lookup(br_cfg->name));
br = xzalloc(sizeof *br);
br->name = xstrdup(br_cfg->name);
struct shash new_ports;
size_t i;
- assert(hmap_is_empty(&br->if_cfg_todo));
+ ovs_assert(hmap_is_empty(&br->if_cfg_todo));
/* Collect new ports. */
shash_init(&new_ports);
#include "system-stats.h"
-#include <assert.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
static long long int cache_expiration = LLONG_MIN;
static long long int boot_time;
- assert(LINUX_DATAPATH);
+ ovs_assert(LINUX_DATAPATH);
if (time_msec() >= cache_expiration) {
static const char stat_file[] = "/proc/stat";
static unsigned long long int
ticks_to_ms(unsigned long long int ticks)
{
- assert(LINUX_DATAPATH);
+ ovs_assert(LINUX_DATAPATH);
#ifndef USER_HZ
#define USER_HZ 100
FILE *stream;
int n;
- assert(LINUX_DATAPATH);
+ ovs_assert(LINUX_DATAPATH);
sprintf(file_name, "/proc/%lu/stat", (unsigned long int) pid);
stream = fopen(file_name, "r");
int crashes = 0;
FILE *stream;
- assert(LINUX_DATAPATH);
+ ovs_assert(LINUX_DATAPATH);
sprintf(file_name, "/proc/%lu/cmdline", (unsigned long int) pid);
stream = fopen(file_name, "r");
{
struct raw_process_info child;
- assert(LINUX_DATAPATH);
+ ovs_assert(LINUX_DATAPATH);
if (!get_raw_process_info(pid, &child)) {
return false;
}
smap_init(received_stats);
smap_from_json(received_stats, json);
- assert(state == S_REQUEST_SENT);
+ ovs_assert(state == S_REQUEST_SENT);
state = S_REPLY_RECEIVED;
json_destroy(json);