veh->veth_tci |= htons(tci);
} else {
/* Insert new 802.1Q header. */
- struct eth_header *eh = packet->l2;
struct vlan_eth_header tmp;
memcpy(tmp.veth_dst, eh->eth_dst, ETH_ADDR_LEN);
memcpy(tmp.veth_src, eh->eth_src, ETH_ADDR_LEN);
if (needed < available) {
ds->length += needed;
} else {
- size_t available;
-
ds_reserve(ds, ds->length + needed);
va_copy(args, args_);
*
* We suppress negative zeros as a matter of policy. */
if (!significand) {
- struct json_token token;
token.type = T_INTEGER;
token.u.integer = 0;
json_parser_input(p, &token);
}
}
if (VLOG_IS_DBG_ENABLED()) {
- char *p = ofp_to_string(msg->data, msg->size, 2);
+ char *s = ofp_to_string(msg->data, msg->size, 2);
VLOG_DBG_RL(&rl, "%016llx: OpenFlow packet ignored: %s",
- sw->datapath_id, p);
- free(p);
+ sw->datapath_id, s);
+ free(s);
}
}
\f
if (file != NULL) {
const char *name = netdev_get_name(netdev_);
while (fgets(line, sizeof line, file)) {
- struct in6_addr in6;
+ struct in6_addr in6_tmp;
char ifname[16 + 1];
- if (parse_if_inet6_line(line, &in6, ifname)
+ if (parse_if_inet6_line(line, &in6_tmp, ifname)
&& !strcmp(name, ifname))
{
- netdev_dev->in6 = in6;
+ netdev_dev->in6 = in6_tmp;
break;
}
}
type = nla->nla_type;
if (type < n_attrs && policy[type].type != NL_A_NO_ATTR) {
- const struct nl_policy *p = &policy[type];
+ const struct nl_policy *e = &policy[type];
size_t min_len, max_len;
/* Validate length and content. */
- min_len = p->min_len ? p->min_len : attr_len_range[p->type][0];
- max_len = p->max_len ? p->max_len : attr_len_range[p->type][1];
+ min_len = e->min_len ? e->min_len : attr_len_range[e->type][0];
+ max_len = e->max_len ? e->max_len : attr_len_range[e->type][1];
if (len < min_len || len > max_len) {
VLOG_DBG_RL(&rl, "%zu: attr %"PRIu16" length %zu not in "
"allowed range %zu...%zu",
offset, type, len, min_len, max_len);
return false;
}
- if (p->type == NL_A_STRING) {
+ if (e->type == NL_A_STRING) {
if (((char *) nla)[nla->nla_len - 1]) {
VLOG_DBG_RL(&rl, "%zu: attr %"PRIu16" lacks null at end",
offset, type);
return false;
}
}
- if (!p->optional && attrs[type] == NULL) {
+ if (!e->optional && attrs[type] == NULL) {
assert(n_required > 0);
--n_required;
}
put_output_action(b, str_to_u32(arg));
} else if (!strcasecmp(act, "enqueue")) {
char *sp = NULL;
- char *port = strtok_r(arg, ":q", &sp);
+ char *port_s = strtok_r(arg, ":q", &sp);
char *queue = strtok_r(NULL, "", &sp);
- if (port == NULL || queue == NULL) {
+ if (port_s == NULL || queue == NULL) {
ovs_fatal(0, "\"enqueue\" syntax is \"enqueue:PORT:QUEUE\"");
}
- put_enqueue_action(b, str_to_u32(port), str_to_u32(queue));
+ put_enqueue_action(b, str_to_u32(port_s), str_to_u32(queue));
} else if (!strcasecmp(act, "drop")) {
/* A drop action in OpenFlow occurs by just not setting
* an action. */
const struct ovsdb_idl_table *table = &idl->tables[i];
const struct ovsdb_idl_table_class *tc = table->class;
struct json *monitor_request, *columns;
- size_t i;
+ size_t j;
monitor_request = json_object_create();
columns = json_array_create_empty();
- for (i = 0; i < tc->n_columns; i++) {
- const struct ovsdb_idl_column *column = &tc->columns[i];
- if (table->modes[i] != OVSDB_IDL_MODE_NONE) {
+ for (j = 0; j < tc->n_columns; j++) {
+ const struct ovsdb_idl_column *column = &tc->columns[j];
+ if (table->modes[j] != OVSDB_IDL_MODE_NONE) {
json_array_add(columns, json_string_create(column->name));
}
}
block_sigchld(&oldsigs);
pid = fork();
if (pid < 0) {
- int error = errno;
+ error = errno;
unblock_sigchld(&oldsigs);
VLOG_WARN("fork failed: %s", strerror(error));
new_fd = accept(ps->fd, (struct sockaddr *) &ss, &ss_len);
if (new_fd < 0) {
- int retval = errno;
+ retval = errno;
if (retval != EAGAIN) {
VLOG_DBG_RL(&rl, "accept: %s", strerror(retval));
}
file = fdopen(fd, "w");
if (!file) {
- int error = errno;
+ error = errno;
VLOG_ERR("could not bootstrap CA cert: fdopen failed: %s",
strerror(error));
unlink(ca_cert.file_name);
}
if (fclose(file)) {
- int error = errno;
+ error = errno;
VLOG_ERR("could not bootstrap CA cert: writing %s failed: %s",
ca_cert.file_name, strerror(error));
unlink(ca_cert.file_name);
new_fd = accept(pssl->fd, &sin, &sin_len);
if (new_fd < 0) {
- int error = errno;
+ error = errno;
if (error != EAGAIN) {
VLOG_DBG_RL(&rl, "accept: %s", strerror(error));
}
for (i = 0; i < 50; i++) {
struct ofpbuf *buf;
- int error;
error = dpif_recv(p->dpif, &buf);
if (error) {
retval = pvconn_accept(ofservice->pvconn, OFP_VERSION, &vconn);
if (!retval) {
- struct ofconn *ofconn;
struct rconn *rconn;
char *name;
|| !params->u.array.n
|| params->u.array.elems[0]->type != JSON_STRING
|| strcmp(params->u.array.elems[0]->u.string, db->schema->name)) {
- struct ovsdb_error *error;
-
if (params->type != JSON_ARRAY) {
error = ovsdb_syntax_error(params, NULL, "array expected");
} else {
/*
- * Copyright (c) 2009 Nicira Networks.
+ * Copyright (c) 2009, 2010 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
const uint16_t *data16 = (const uint16_t *) tc->data;
const uint32_t *data32 = (const uint32_t *) tc->data;
uint32_t partial;
- size_t i;
/* Test csum(). */
assert(ntohs(csum(tc->data, tc->size)) == tc->csum);
size_t n_classes;
struct json *json;
int exit_code = 0;
- size_t i, j, k;
+ size_t i;
/* Parse table schema, create table. */
json = unbox_json(parse_json(argv[1]));
for (i = 0; i < json->u.array.n; i++) {
struct ovsdb_row_set results;
struct ovsdb_condition cnd;
+ size_t j;
check_ovsdb_error(ovsdb_condition_from_json(ts, json->u.array.elems[i],
NULL, &cnd));
ovsdb_row_set_init(&results);
ovsdb_query_distinct(table, &cnd, &columns, &results);
for (j = 0; j < results.n_rows; j++) {
+ size_t k;
+
for (k = 0; k < n_rows; k++) {
if (uuid_equals(ovsdb_row_get_uuid(results.rows[j]),
&rows[k].uuid)) {
for (i = 2; i < argc; i++) {
char *arg = argv[i];
struct jsonrpc_msg *request, *reply;
- int error;
if (*arg == '+') {
/* The previous transaction didn't change anything. */
for (i = optind; i < argc; i++) {
const char *name = argv[i];
struct vconn *vconn;
- int retval;
retval = vconn_open(name, OFP_VERSION, &vconn);
if (!retval) {
while (n_switches > 0 || n_listeners > 0) {
int iteration;
- int i;
/* Accept connections on listening vconns. */
for (i = 0; i < n_listeners && n_switches < MAX_SWITCHES; ) {
struct vconn *new_vconn;
- int retval;
retval = pvconn_accept(listeners[i], OFP_VERSION, &new_vconn);
if (!retval || retval == EAGAIN) {
bool progress = false;
for (i = 0; i < n_switches; ) {
struct switch_ *this = &switches[i];
- int retval = do_switching(this);
+
+ retval = do_switching(this);
if (!retval || retval == EAGAIN) {
if (!retval) {
progress = true;
s->n_controllers = controllers.n;
s->controllers = xmalloc(s->n_controllers * sizeof *s->controllers);
if (argc > 1) {
- size_t i;
-
for (i = 0; i < s->n_controllers; i++) {
s->controllers[i] = controller_opts;
s->controllers[i].target = controllers.names[i];
/* Sanity check. */
if (controller_opts.band == OFPROTO_OUT_OF_BAND) {
- size_t i;
-
for (i = 0; i < s->n_controllers; i++) {
if (!strcmp(s->controllers[i].target, "discover")) {
ovs_fatal(0, "Cannot perform discovery with out-of-band "
get_info(ctx->ovs, &info);
if (may_exist) {
- struct vsctl_port *port;
+ struct vsctl_port *vsctl_port;
- port = find_port(&info, port_name, false);
- if (port) {
+ vsctl_port = find_port(&info, port_name, false);
+ if (vsctl_port) {
struct svec want_names, have_names;
- size_t i;
svec_init(&want_names);
for (i = 0; i < n_ifaces; i++) {
svec_sort(&want_names);
svec_init(&have_names);
- for (i = 0; i < port->port_cfg->n_interfaces; i++) {
- svec_add(&have_names, port->port_cfg->interfaces[i]->name);
+ for (i = 0; i < vsctl_port->port_cfg->n_interfaces; i++) {
+ svec_add(&have_names,
+ vsctl_port->port_cfg->interfaces[i]->name);
}
svec_sort(&have_names);
- if (strcmp(port->bridge->name, br_name)) {
+ if (strcmp(vsctl_port->bridge->name, br_name)) {
char *command = vsctl_context_to_string(ctx);
vsctl_fatal("\"%s\" but %s is actually attached to bridge %s",
- command, port_name, port->bridge->name);
+ command, port_name, vsctl_port->bridge->name);
}
if (!svec_equal(&want_names, &have_names)) {
ds_chomp(ds, '\n');
for (j = 0; j < ds->length; j++) {
- int c = ds->string[j];
- switch (c) {
+ int ch = ds->string[j];
+ switch (ch) {
case '\n':
fputs("\\n", stdout);
break;
break;
default:
- putchar(c);
+ putchar(ch);
}
}
putchar('\n');
if (wait_for_reload && status != TXN_UNCHANGED) {
for (;;) {
- const struct ovsrec_open_vswitch *ovs;
-
ovsdb_idl_run(idl);
OVSREC_OPEN_VSWITCH_FOR_EACH (ovs, idl) {
if (ovs->cur_cfg >= next_cfg) {
struct odp_port *dpif_ports;
size_t n_dpif_ports;
struct shash cur_ifaces, want_ifaces;
- struct shash_node *node;
/* Get the set of interfaces currently in this datapath. */
dpif_port_list(br->dpif, &dpif_ports, &n_dpif_ports);
struct ovsrec_controller **controllers;
struct ofproto_sflow_options oso;
size_t n_controllers;
- size_t i;
memset(&oso, 0, sizeof oso);
* smallest hashes instead of the biggest ones. There is little
* reason behind this decision; we could use the opposite sort
* order to shift away big hashes ahead of small ones. */
- size_t i;
bool order_swapped;
for (i = 0; i < from->n_hashes; i++) {
trunks = NULL;
if (vlan < 0 && cfg->n_trunks) {
size_t n_errors;
- size_t i;
trunks = bitmap_allocate(4096);
n_errors = 0;