本文整理汇总了C++中VLOG_RATE_LIMIT_INIT函数的典型用法代码示例。如果您正苦于以下问题:C++ VLOG_RATE_LIMIT_INIT函数的具体用法?C++ VLOG_RATE_LIMIT_INIT怎么用?C++ VLOG_RATE_LIMIT_INIT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VLOG_RATE_LIMIT_INIT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: check_connection_completion
int
check_connection_completion(int fd)
{
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 10);
struct pollfd pfd;
int retval;
pfd.fd = fd;
pfd.events = POLLOUT;
#ifndef _WIN32
do {
retval = poll(&pfd, 1, 0);
} while (retval < 0 && errno == EINTR);
#else
retval = WSAPoll(&pfd, 1, 0);
#endif
if (retval == 1) {
if (pfd.revents & POLLERR) {
ssize_t n = send(fd, "", 1, 0);
if (n < 0) {
return sock_errno();
} else {
VLOG_ERR_RL(&rl, "poll return POLLERR but send succeeded");
return EPROTO;
}
}
return 0;
} else if (retval < 0) {
VLOG_ERR_RL(&rl, "poll: %s", sock_strerror(sock_errno()));
return errno;
} else {
return EAGAIN;
}
}
示例4: resize
static void
resize(struct hmap *hmap, size_t new_mask, const char *where)
{
struct hmap tmp;
size_t i;
ovs_assert(is_pow2(new_mask + 1));
hmap_init(&tmp);
if (new_mask) {
tmp.buckets = xmalloc(sizeof *tmp.buckets * (new_mask + 1));
tmp.mask = new_mask;
for (i = 0; i <= tmp.mask; i++) {
tmp.buckets[i] = NULL;
}
}
for (i = 0; i <= hmap->mask; i++) {
struct hmap_node *node, *next;
int count = 0;
for (node = hmap->buckets[i]; node; node = next) {
next = node->next;
hmap_insert_fast(&tmp, node, node->hash);
count++;
}
if (count > 5) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 10);
COVERAGE_INC(hmap_pathological);
VLOG_DBG_RL(&rl, "%s: %d nodes in bucket (%"PRIuSIZE" nodes, %"PRIuSIZE" buckets)",
where, count, hmap->n, hmap->mask + 1);
}
}
hmap_swap(hmap, &tmp);
hmap_destroy(&tmp);
}
示例5: daemon_run
/* Perform all of the per-loop processing. */
static void
daemon_run(void)
{
unsigned int new_idl_seqno = ovsdb_idl_get_seqno(idl);
ovsdb_idl_run(idl);
if (ovsdb_idl_is_lock_contended(idl)) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
VLOG_ERR_RL(&rl, "another ops-usermgmt process is running, "
"disabling this process until it goes away");
return;
} else if (!ovsdb_idl_has_lock(idl)) {
return;
}
/* Acquired lock, we're officially ops-usermgmt now. */
if (!populated) {
/* First time we got this far, populate database from passwd. */
if (sync_to_db())
populated = true;
daemonize_complete();
vlog_enable_async();
VLOG_INFO_ONCE("%s (OpenSwitch usermgmt)", program_name);
}
if (new_idl_seqno == idl_seqno)
return;
/* Change in OVSDB detected. */
idl_seqno = new_idl_seqno;
sync_from_db();
}
示例6: 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;
}
示例7: classifierd_run
void
classifierd_run(void)
{
struct ovsdb_idl_txn *txn;
/* Process a batch of messages from OVSDB. */
ovsdb_idl_run(idl);
if (ovsdb_idl_is_lock_contended(idl)) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
VLOG_ERR_RL(&rl, "Another classifierd process is running, "
"disabling this process until it goes away");
return;
} else if (!ovsdb_idl_has_lock(idl)) {
return;
}
/* Nothing to do until system has been configured, i.e. cur_cfg > 0. */
if (!classifierd_system_is_configured()) {
return;
}
/* Update the local configuration and push any changes to the dB. */
txn = ovsdb_idl_txn_create(idl);
if (classifierd_reconfigure()) {
VLOG_DBG("%s: Committing changes\n",__FUNCTION__);
/* Some OVSDB write needs to happen. */
ovsdb_idl_txn_commit_block(txn);
}
ovsdb_idl_txn_destroy(txn);
return;
} /* classifierd_run */
示例8: mac_learning_learn
/* Attempts to make 'ml' learn from the fact that a frame from 'src_mac' was
* just observed arriving from 'src_port' on the given 'vlan'.
*
* Returns nonzero if we actually learned something from this, zero if it just
* confirms what we already knew. The nonzero return value is the tag of flows
* that now need revalidation.
*
* The 'vlan' parameter is used to maintain separate per-VLAN learning tables.
* Specify 0 if this behavior is undesirable.
*
* 'lock_type' specifies whether the entry should be locked or existing locks
* are check. */
tag_type
mac_learning_learn(struct mac_learning *ml,
const uint8_t src_mac[ETH_ADDR_LEN], uint16_t vlan,
uint16_t src_port, enum grat_arp_lock_type lock_type)
{
struct mac_entry *e;
struct list *bucket;
if (!is_learning_vlan(ml, vlan)) {
return 0;
}
if (eth_addr_is_multicast(src_mac)) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(30, 30);
VLOG_DBG_RL(&rl, "multicast packet source "ETH_ADDR_FMT,
ETH_ADDR_ARGS(src_mac));
return 0;
}
bucket = mac_table_bucket(ml, src_mac, vlan);
e = search_bucket(bucket, src_mac, vlan);
if (!e) {
if (!list_is_empty(&ml->free)) {
e = mac_entry_from_lru_node(ml->free.next);
} else {
e = mac_entry_from_lru_node(ml->lrus.next);
list_remove(&e->hash_node);
}
memcpy(e->mac, src_mac, ETH_ADDR_LEN);
list_push_front(bucket, &e->hash_node);
e->port = -1;
e->vlan = vlan;
e->tag = make_unknown_mac_tag(ml, src_mac, vlan);
e->grat_arp_lock = TIME_MIN;
}
if (lock_type != GRAT_ARP_LOCK_CHECK || time_now() >= e->grat_arp_lock) {
/* Make the entry most-recently-used. */
list_remove(&e->lru_node);
list_push_back(&ml->lrus, &e->lru_node);
e->expires = time_now() + MAC_ENTRY_IDLE_TIME;
if (lock_type == GRAT_ARP_LOCK_SET) {
e->grat_arp_lock = time_now() + MAC_GRAT_ARP_LOCK_TIME;
}
/* Did we learn something? */
if (e->port != src_port) {
tag_type old_tag = e->tag;
e->port = src_port;
e->tag = tag_create_random();
COVERAGE_INC(mac_learning_learned);
return old_tag;
}
}
return 0;
}
示例9: lookup_ipv6
/* Translates 'host_name', which must be a string representation of an IPv6
* address, into a numeric IPv6 address in '*addr'. Returns 0 if successful,
* otherwise a positive errno value. */
int
lookup_ipv6(const char *host_name, struct in6_addr *addr)
{
if (!ipv6_parse(host_name, addr)) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
VLOG_ERR_RL(&rl, "\"%s\" is not a valid IPv6 address", host_name);
return ENOENT;
}
return 0;
}
示例10: lookup_ip
/* Translates 'host_name', which must be a string representation of an IP
* address, into a numeric IP address in '*addr'. Returns 0 if successful,
* otherwise a positive errno value. */
int
lookup_ip(const char *host_name, struct in_addr *addr)
{
if (!inet_pton(AF_INET, host_name, addr)) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
VLOG_ERR_RL(&rl, "\"%s\" is not a valid IP address", host_name);
return ENOENT;
}
return 0;
}
示例11: ipf_print_reass_packet
static void
ipf_print_reass_packet(const char *es, const void *pkt)
{
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 10);
if (!VLOG_DROP_WARN(&rl)) {
struct ds ds = DS_EMPTY_INITIALIZER;
ds_put_hex_dump(&ds, pkt, 128, 0, false);
VLOG_WARN("%s\n%s", es, ds_cstr(&ds));
ds_destroy(&ds);
}
}
示例12: extract_lsp_addresses
/* Extracts the mac, IPv4 and IPv6 addresses from * 'address' which
* should be of the format 'MAC [IP1 IP2 ..]" where IPn should be a
* valid IPv4 or IPv6 address and stores them in the 'ipv4_addrs' and
* 'ipv6_addrs' fields of 'laddrs'.
*
* Return true if at least 'MAC' is found in 'address', false otherwise.
*
* The caller must call destroy_lport_addresses(). */
bool
extract_lsp_addresses(const char *address, struct lport_addresses *laddrs)
{
int ofs;
bool success = extract_addresses(address, laddrs, &ofs);
if (success && ofs < strlen(address)) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
VLOG_INFO_RL(&rl, "invalid syntax '%s' in address", address);
}
return success;
}
示例13: get_chassis_id
static const char *
get_chassis_id(const struct ovsdb_idl *ovs_idl)
{
const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_first(ovs_idl);
const char *chassis_id = cfg ? smap_get(&cfg->external_ids, "system-id") : NULL;
if (!chassis_id) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
VLOG_WARN_RL(&rl, "'system-id' in Open_vSwitch database is missing.");
}
return chassis_id;
}
示例14: check_connection_completion
int
check_connection_completion(int fd)
{
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 10);
struct pollfd pfd;
int retval;
pfd.fd = fd;
pfd.events = POLLOUT;
#ifndef _WIN32
do {
retval = poll(&pfd, 1, 0);
} while (retval < 0 && errno == EINTR);
#else
fd_set wrset, exset;
FD_ZERO(&wrset);
FD_ZERO(&exset);
FD_SET(fd, &exset);
FD_SET(fd, &wrset);
pfd.revents = 0;
struct timeval tv = { 0, 0 };
/* WSAPoll is broken on Windows, instead do a select */
retval = select(0, NULL, &wrset, &exset, &tv);
if (retval == 1) {
if (FD_ISSET(fd, &wrset)) {
pfd.revents |= pfd.events;
}
if (FD_ISSET(fd, &exset)) {
pfd.revents |= POLLERR;
}
}
#endif
if (retval == 1) {
if (pfd.revents & POLLERR) {
ssize_t n = send(fd, "", 1, 0);
if (n < 0) {
return sock_errno();
} else {
VLOG_ERR_RL(&rl, "poll return POLLERR but send succeeded");
return EPROTO;
}
}
return 0;
} else if (retval < 0) {
VLOG_ERR_RL(&rl, "poll: %s", sock_strerror(sock_errno()));
return errno;
} else {
return EAGAIN;
}
}
示例15: extract_lsp_addresses
/* Extracts the mac, IPv4 and IPv6 addresses from * 'address' which
* should be of the format 'MAC [IP1 IP2 ..]" where IPn should be a
* valid IPv4 or IPv6 address and stores them in the 'ipv4_addrs' and
* 'ipv6_addrs' fields of 'laddrs'.
*
* Return true if at least 'MAC' is found in 'address', false otherwise.
*
* The caller must call destroy_lport_addresses(). */
bool
extract_lsp_addresses(const char *address, struct lport_addresses *laddrs)
{
memset(laddrs, 0, sizeof *laddrs);
const char *buf = address;
int buf_index = 0;
const char *buf_end = buf + strlen(address);
if (!ovs_scan_len(buf, &buf_index, ETH_ADDR_SCAN_FMT,
ETH_ADDR_SCAN_ARGS(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));
ovs_be32 ip4;
struct in6_addr ip6;
unsigned int plen;
char *error;
/* Loop through the buffer and extract the IPv4/IPv6 addresses
* and store in the 'laddrs'. Break the loop if invalid data is found.
*/
buf += buf_index;
while (buf < buf_end) {
buf_index = 0;
error = ip_parse_cidr_len(buf, &buf_index, &ip4, &plen);
if (!error) {
add_ipv4_netaddr(laddrs, ip4, plen);
buf += buf_index;
continue;
}
free(error);
error = ipv6_parse_cidr_len(buf, &buf_index, &ip6, &plen);
if (!error) {
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 address", address);
free(error);
break;
}
buf += buf_index;
}
return true;
}