本文整理汇总了C++中VLOG_WARN_RL函数的典型用法代码示例。如果您正苦于以下问题:C++ VLOG_WARN_RL函数的具体用法?C++ VLOG_WARN_RL怎么用?C++ VLOG_WARN_RL使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VLOG_WARN_RL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: multipath_from_openflow
/* Converts 'nam' into 'mp'. Returns 0 if successful, otherwise an
* OFPERR_*. */
enum ofperr
multipath_from_openflow(const struct nx_action_multipath *nam,
struct ofpact_multipath *mp)
{
uint32_t n_links = ntohs(nam->max_link) + 1;
size_t min_n_bits = log_2_ceil(n_links);
ofpact_init_MULTIPATH(mp);
mp->fields = ntohs(nam->fields);
mp->basis = ntohs(nam->basis);
mp->algorithm = ntohs(nam->algorithm);
mp->max_link = ntohs(nam->max_link);
mp->arg = ntohl(nam->arg);
mp->dst.field = mf_from_nxm_header(ntohl(nam->dst));
mp->dst.ofs = nxm_decode_ofs(nam->ofs_nbits);
mp->dst.n_bits = nxm_decode_n_bits(nam->ofs_nbits);
if (!flow_hash_fields_valid(mp->fields)) {
VLOG_WARN_RL(&rl, "unsupported fields %d", (int) mp->fields);
return OFPERR_OFPBAC_BAD_ARGUMENT;
} else if (mp->algorithm != NX_MP_ALG_MODULO_N
&& mp->algorithm != NX_MP_ALG_HASH_THRESHOLD
&& mp->algorithm != NX_MP_ALG_HRW
&& mp->algorithm != NX_MP_ALG_ITER_HASH) {
VLOG_WARN_RL(&rl, "unsupported algorithm %d", (int) mp->algorithm);
return OFPERR_OFPBAC_BAD_ARGUMENT;
} else if (mp->dst.n_bits < min_n_bits) {
VLOG_WARN_RL(&rl, "multipath action requires at least %zu bits for "
"%"PRIu32" links", min_n_bits, n_links);
return OFPERR_OFPBAC_BAD_ARGUMENT;
}
return multipath_check(mp, NULL);
}
示例2: jsonrpc_parse_received_message
/* Attempts to parse the content of 'rpc->parser' (which is complete JSON) as a
* JSON-RPC message. If successful, returns the JSON-RPC message. On failure,
* signals an error on 'rpc' with jsonrpc_error() and returns NULL. */
static struct jsonrpc_msg *
jsonrpc_parse_received_message(struct jsonrpc *rpc)
{
struct jsonrpc_msg *msg;
struct json *json;
char *error;
json = json_parser_finish(rpc->parser);
rpc->parser = NULL;
if (json->type == JSON_STRING) {
VLOG_WARN_RL(&rl, "%s: error parsing stream: %s",
rpc->name, json_string(json));
jsonrpc_error(rpc, EPROTO);
json_destroy(json);
return NULL;
}
error = jsonrpc_msg_from_json(json, &msg);
if (error) {
VLOG_WARN_RL(&rl, "%s: received bad JSON-RPC message: %s",
rpc->name, error);
free(error);
jsonrpc_error(rpc, EPROTO);
return NULL;
}
jsonrpc_log_msg(rpc, "received", msg);
return msg;
}
示例3: multipath_check
/* multipath_check(). */
enum ofperr
multipath_check(const struct nx_action_multipath *mp, const struct flow *flow)
{
uint32_t n_links = ntohs(mp->max_link) + 1;
size_t min_n_bits = log_2_ceil(n_links);
struct mf_subfield dst;
enum ofperr error;
nxm_decode(&dst, mp->dst, mp->ofs_nbits);
error = mf_check_dst(&dst, flow);
if (error) {
return error;
}
if (!flow_hash_fields_valid(ntohs(mp->fields))) {
VLOG_WARN_RL(&rl, "unsupported fields %"PRIu16, ntohs(mp->fields));
} else if (mp->algorithm != htons(NX_MP_ALG_MODULO_N)
&& mp->algorithm != htons(NX_MP_ALG_HASH_THRESHOLD)
&& mp->algorithm != htons(NX_MP_ALG_HRW)
&& mp->algorithm != htons(NX_MP_ALG_ITER_HASH)) {
VLOG_WARN_RL(&rl, "unsupported algorithm %"PRIu16,
ntohs(mp->algorithm));
} else if (dst.n_bits < min_n_bits) {
VLOG_WARN_RL(&rl, "multipath action requires at least %zu bits for "
"%"PRIu32" links", min_n_bits, n_links);
} else {
return 0;
}
return OFPERR_OFPBAC_BAD_ARGUMENT;
}
示例4: bundle_check
enum ofperr
bundle_check(const struct ofpact_bundle *bundle, ofp_port_t max_ports,
const struct flow *flow)
{
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
size_t i;
if (bundle->dst.field) {
enum ofperr error = mf_check_dst(&bundle->dst, flow);
if (error) {
return error;
}
}
for (i = 0; i < bundle->n_slaves; i++) {
ofp_port_t ofp_port = bundle->slaves[i];
enum ofperr error;
error = ofpact_check_output_port(ofp_port, max_ports);
if (error) {
VLOG_WARN_RL(&rl, "invalid slave %"PRIu16, ofp_port);
return error;
}
/* Controller slaves are unsupported due to the lack of a max_len
* argument. This may or may not change in the future. There doesn't
* seem to be a real-world use-case for supporting it. */
if (ofp_port == OFPP_CONTROLLER) {
VLOG_WARN_RL(&rl, "unsupported controller slave");
return OFPERR_OFPBAC_BAD_OUT_PORT;
}
}
return 0;
}
示例5: ofputil_decode_bundle_add
enum ofperr
ofputil_decode_bundle_add(const struct ofp_header *oh,
struct ofputil_bundle_add_msg *msg,
enum ofptype *typep)
{
struct ofpbuf b = ofpbuf_const_initializer(oh, ntohs(oh->length));
/* Pull the outer ofp_header. */
enum ofpraw raw = ofpraw_pull_assert(&b);
ovs_assert(raw == OFPRAW_OFPT14_BUNDLE_ADD_MESSAGE
|| raw == OFPRAW_ONFT13_BUNDLE_ADD_MESSAGE);
/* Pull the bundle_ctrl header. */
const struct ofp14_bundle_ctrl_msg *m = ofpbuf_pull(&b, sizeof *m);
msg->bundle_id = ntohl(m->bundle_id);
msg->flags = ntohs(m->flags);
/* Pull the inner ofp_header. */
if (b.size < sizeof(struct ofp_header)) {
return OFPERR_OFPBFC_MSG_BAD_LEN;
}
msg->msg = b.data;
if (msg->msg->version != oh->version) {
return OFPERR_OFPBFC_BAD_VERSION;
}
size_t inner_len = ntohs(msg->msg->length);
if (inner_len < sizeof(struct ofp_header) || inner_len > b.size) {
return OFPERR_OFPBFC_MSG_BAD_LEN;
}
if (msg->msg->xid != oh->xid) {
return OFPERR_OFPBFC_MSG_BAD_XID;
}
/* Reject unbundlable messages. */
enum ofptype type;
enum ofperr error = ofptype_decode(&type, msg->msg);
if (error) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
VLOG_WARN_RL(&rl, "OFPT14_BUNDLE_ADD_MESSAGE contained "
"message is unparsable (%s)", ofperr_get_name(error));
return OFPERR_OFPBFC_MSG_UNSUP; /* 'error' would be confusing. */
}
if (!ofputil_is_bundlable(type)) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
VLOG_WARN_RL(&rl, "%s message not allowed inside "
"OFPT14_BUNDLE_ADD_MESSAGE", ofptype_get_name(type));
return OFPERR_OFPBFC_MSG_UNSUP;
}
if (typep) {
*typep = type;
}
return 0;
}
示例6: extract_lrp_networks
/* Extracts the mac, IPv4 and IPv6 addresses from the
* "nbrec_logical_router_port" parameter 'lrp'. Stores the IPv4 and
* IPv6 addresses in the 'ipv4_addrs' and 'ipv6_addrs' fields of
* 'laddrs', respectively. In addition, a link local IPv6 address
* based on the 'mac' member of 'lrp' is added to the 'ipv6_addrs'
* field.
*
* Return true if a valid 'mac' address is found in 'lrp', false otherwise.
*
* The caller must call destroy_lport_addresses(). */
bool
extract_lrp_networks(const struct nbrec_logical_router_port *lrp,
struct lport_addresses *laddrs)
{
memset(laddrs, 0, sizeof *laddrs);
if (!eth_addr_from_string(lrp->mac, &laddrs->ea)) {
laddrs->ea = eth_addr_zero;
return false;
}
snprintf(laddrs->ea_s, sizeof laddrs->ea_s, ETH_ADDR_FMT,
ETH_ADDR_ARGS(laddrs->ea));
for (int i = 0; i < lrp->n_networks; i++) {
ovs_be32 ip4;
struct in6_addr ip6;
unsigned int plen;
char *error;
error = ip_parse_cidr(lrp->networks[i], &ip4, &plen);
if (!error) {
if (!ip4 || plen == 32) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
VLOG_WARN_RL(&rl, "bad 'networks' %s", lrp->networks[i]);
continue;
}
add_ipv4_netaddr(laddrs, ip4, plen);
continue;
}
free(error);
error = ipv6_parse_cidr(lrp->networks[i], &ip6, &plen);
if (!error) {
if (plen == 128) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
VLOG_WARN_RL(&rl, "bad 'networks' %s", lrp->networks[i]);
continue;
}
add_ipv6_netaddr(laddrs, ip6, plen);
} else {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
VLOG_INFO_RL(&rl, "invalid syntax '%s' in networks",
lrp->networks[i]);
free(error);
}
}
/* Always add the IPv6 link local address. */
struct in6_addr lla;
in6_generate_lla(laddrs->ea, &lla);
add_ipv6_netaddr(laddrs, lla, 64);
return true;
}
示例7: set_nw_dst
/* Executes set nw dst action. */
static void
set_nw_dst(struct packet *pkt, struct ofl_action_nw_addr *act) {
packet_handle_std_validate(pkt->handle_std);
if (pkt->handle_std->proto->ipv4 != NULL) {
struct ip_header *ipv4 = pkt->handle_std->proto->ipv4;
// update TCP/UDP checksum
if (pkt->handle_std->proto->tcp != NULL) {
struct tcp_header *tcp = pkt->handle_std->proto->tcp;
tcp->tcp_csum = recalc_csum32(tcp->tcp_csum, ipv4->ip_dst, act->nw_addr);
} else if (pkt->handle_std->proto->udp != NULL) {
struct udp_header *udp = pkt->handle_std->proto->udp;
udp->udp_csum = recalc_csum32(udp->udp_csum, ipv4->ip_dst, act->nw_addr);
}
ipv4->ip_csum = recalc_csum32(ipv4->ip_csum, ipv4->ip_dst, act->nw_addr);
ipv4->ip_dst = act->nw_addr;
pkt->handle_std->match->nw_dst = act->nw_addr;
} else {
VLOG_WARN_RL(LOG_MODULE, &rl, "Trying to execute SET_NW_DST action on packet with no nw.");
}
}
示例8: flow_table_lookup
struct flow_entry *
flow_table_lookup(struct flow_table *table, struct packet *pkt) {
struct flow_entry *entry;
table->stats->lookup_count++;
LIST_FOR_EACH(entry, struct flow_entry, match_node, &table->match_entries) {
struct ofl_match_header *m;
m = entry->match == NULL ? entry->stats->match : entry->match;
/* select appropriate handler, based on match type of flow entry. */
switch (m->type) {
case (OFPMT_STANDARD): {
if (packet_handle_std_match(pkt->handle_std,
(struct ofl_match_standard *)m)) {
entry->stats->byte_count += pkt->buffer->size;
entry->stats->packet_count++;
entry->last_used = time_msec();
table->stats->matched_count++;
return entry;
}
break;
}
default: {
VLOG_WARN_RL(LOG_MODULE, &rl, "Trying to process flow entry with unknown match type (%u).", m->type);
}
}
}
return NULL;
}
示例9: init_group_refs
/* Initializes the group references of the flow entry. */
static void
init_group_refs(struct flow_entry *entry) {
struct group_ref_entry *e;
size_t i,j;
for (i=0; i<entry->stats->instructions_num; i++) {
if (entry->stats->instructions[i]->type == OFPIT_APPLY_ACTIONS ||
entry->stats->instructions[i]->type == OFPIT_WRITE_ACTIONS) {
struct ofl_instruction_actions *ia = (struct ofl_instruction_actions *)entry->stats->instructions[i];
for (j=0; j < ia->actions_num; j++) {
if (ia->actions[j]->type == OFPAT_GROUP) {
struct ofl_action_group *ag = (struct ofl_action_group *)(ia->actions[j]);
if (!has_group_ref(entry, ag->group_id)) {
struct group_ref_entry *gre = xmalloc(sizeof(struct group_ref_entry));
gre->group_id = ag->group_id;
list_insert(&entry->group_refs, &gre->node);
}
}
}
}
}
/* notify groups of the new referencing flow entry */
LIST_FOR_EACH(e, struct group_ref_entry, node, &entry->group_refs) {
struct group_entry *group = group_table_find(entry->dp->groups, e->group_id);
if (group != NULL) {
group_entry_add_flow_ref(group, entry);
} else {
VLOG_WARN_RL(LOG_MODULE, &rl, "Trying to access non-existing group(%u).", e->group_id);
}
}
}
示例10: jsonrpc_run
/* Performs periodic maintenance on 'rpc', such as flushing output buffers. */
void
jsonrpc_run(struct jsonrpc *rpc)
{
if (rpc->status) {
return;
}
stream_run(rpc->stream);
while (!list_is_empty(&rpc->output)) {
struct ofpbuf *buf = ofpbuf_from_list(rpc->output.next);
int retval;
retval = stream_send(rpc->stream, buf->data, buf->size);
if (retval >= 0) {
rpc->backlog -= retval;
ofpbuf_pull(buf, retval);
if (!buf->size) {
list_remove(&buf->list_node);
rpc->output_count--;
ofpbuf_delete(buf);
}
} else {
if (retval != -EAGAIN) {
VLOG_WARN_RL(&rl, "%s: send error: %s",
rpc->name, ovs_strerror(-retval));
jsonrpc_error(rpc, -retval);
}
break;
}
}
}
示例11: ssl_do_tx
static int
ssl_do_tx(struct stream *stream)
{
struct ssl_stream *sslv = ssl_stream_cast(stream);
for (;;) {
int old_state = SSL_get_state(sslv->ssl);
int ret = SSL_write(sslv->ssl, sslv->txbuf->data, sslv->txbuf->size);
if (old_state != SSL_get_state(sslv->ssl)) {
sslv->rx_want = SSL_NOTHING;
}
sslv->tx_want = SSL_NOTHING;
if (ret > 0) {
ofpbuf_pull(sslv->txbuf, ret);
if (sslv->txbuf->size == 0) {
return 0;
}
} else {
int ssl_error = SSL_get_error(sslv->ssl, ret);
if (ssl_error == SSL_ERROR_ZERO_RETURN) {
VLOG_WARN_RL(&rl, "SSL_write: connection closed");
return EPIPE;
} else {
return interpret_ssl_error("SSL_write", ret, ssl_error,
&sslv->tx_want);
}
}
}
}
示例12: nl_dump_next
/* Attempts to retrieve another reply from 'dump', which must have been
* initialized with nl_dump_start().
*
* If successful, returns true and points 'reply->data' and 'reply->size' to
* the message that was retrieved. The caller must not modify 'reply' (because
* it points into the middle of a larger buffer).
*
* On failure, returns false and sets 'reply->data' to NULL and 'reply->size'
* to 0. Failure might indicate an actual error or merely the end of replies.
* An error status for the entire dump operation is provided when it is
* completed by calling nl_dump_done().
*/
bool
nl_dump_next(struct nl_dump *dump, struct ofpbuf *reply)
{
struct nlmsghdr *nlmsghdr;
reply->data = NULL;
reply->size = 0;
if (dump->status) {
return false;
}
while (!dump->buffer.size) {
int retval = nl_dump_recv(dump);
if (retval) {
ofpbuf_clear(&dump->buffer);
if (retval != EAGAIN) {
dump->status = retval;
return false;
}
}
}
nlmsghdr = nl_msg_next(&dump->buffer, reply);
if (!nlmsghdr) {
VLOG_WARN_RL(&rl, "netlink dump reply contains message fragment");
dump->status = EPROTO;
return false;
} else if (nlmsghdr->nlmsg_type == NLMSG_DONE) {
dump->status = EOF;
return false;
}
return true;
}
示例13: group_entry_execute
void
group_entry_execute(struct group_entry *entry,
struct packet *packet) {
VLOG_DBG_RL(LOG_MODULE, &rl, "Executing group %u.", entry->stats->group_id);
/* NOTE: Packet is copied for all buckets now (even if there is only one).
* This allows execution of the original packet onward. It is not clear
* whether that is allowed or not according to the spec. though. */
switch (entry->desc->type) {
case (OFPGT_ALL): {
execute_all(entry, packet);
break;
}
case (OFPGT_SELECT): {
execute_select(entry, packet);
break;
}
case (OFPGT_INDIRECT): {
execute_indirect(entry, packet);
break;
}
case (OFPGT_FF): {
execute_ff(entry, packet);
break;
}
default: {
VLOG_WARN_RL(LOG_MODULE, &rl, "Trying to execute unknown group type (%u) in group (%u).", entry->desc->type, entry->stats->group_id);
}
}
}
示例14: dp_run
void
dp_run(struct datapath *dp) {
time_t now = time_now();
struct remote *r, *rn;
size_t i;
if (now != dp->last_timeout) {
dp->last_timeout = now;
pipeline_timeout(dp->pipeline);
}
poll_timer_wait(1000);
dp_ports_run(dp);
/* Talk to remotes. */
LIST_FOR_EACH_SAFE (r, rn, struct remote, node, &dp->remotes) {
remote_run(dp, r);
}
for (i = 0; i < dp->n_listeners; ) {
struct pvconn *pvconn = dp->listeners[i];
struct vconn *new_vconn;
int retval = pvconn_accept(pvconn, OFP_VERSION, &new_vconn);
if (!retval) {
remote_create(dp, rconn_new_from_vconn("passive", new_vconn));
} else if (retval != EAGAIN) {
VLOG_WARN_RL(LOG_MODULE, &rl, "accept failed (%s)", strerror(retval));
dp->listeners[i] = dp->listeners[--dp->n_listeners];
continue;
}
i++;
}
}
示例15: select_from_select_group
/* Selects a bucket from a select group, based on the w.r.r. algorithm. */
static size_t
select_from_select_group(struct group_entry *entry) {
struct group_entry_wrr_data *data;
size_t guard;
if (entry->desc->buckets_num == 0) {
return -1;
}
data = (struct group_entry_wrr_data *)entry->data;
guard = 0;
while (guard < entry->desc->buckets_num) {
data->curr_bucket = (data->curr_bucket + 1) % entry->desc->buckets_num;
if (data->curr_bucket == 0) {
if (data->curr_weight <= data->gcd_weight) {
data->curr_weight = data->max_weight;
} else {
data->curr_weight = data->curr_weight - data->gcd_weight;
}
}
if (entry->desc->buckets[data->curr_bucket]->weight >= data->curr_weight) {
return data->curr_bucket;
}
guard++;
}
VLOG_WARN_RL(LOG_MODULE, &rl, "Could not select from select group.");
return -1;
}