18 February 2019: Wouter
- Print query name with ip_ratelimit exceeded log lines.
- Spaces instead of tabs in that log message.
+ - Print query name and IP address when domain rate limit exceeded.
14 February 2019: Wouter
- Fix capsforid canonical sort qsort callback.
* now will also exceed the rate, keeping cache fresh */
(void)infra_ratelimit_inc(qstate->env->infra_cache,
iq->dp->name, iq->dp->namelen,
- *qstate->env->now);
+ *qstate->env->now, &qstate->qinfo,
+ qstate->reply);
/* see if we are passed through with slip factor */
if(qstate->env->cfg->ratelimit_factor != 0 &&
ub_random_max(qstate->env->rnd,
/* if not forwarding, check ratelimits per delegationpoint name */
if(!(iq->chase_flags & BIT_RD) && !iq->ratelimit_ok) {
if(!infra_ratelimit_inc(qstate->env->infra_cache, iq->dp->name,
- iq->dp->namelen, *qstate->env->now)) {
+ iq->dp->namelen, *qstate->env->now, &qstate->qinfo,
+ qstate->reply)) {
lock_basic_lock(&ie->queries_ratelimit_lock);
ie->num_queries_ratelimited++;
lock_basic_unlock(&ie->queries_ratelimit_lock);
}
int infra_ratelimit_inc(struct infra_cache* infra, uint8_t* name,
- size_t namelen, time_t timenow)
+ size_t namelen, time_t timenow, struct query_info* qinfo,
+ struct comm_reply* replylist)
{
int lim, max;
struct lruhash_entry* entry;
lock_rw_unlock(&entry->lock);
if(premax < lim && max >= lim) {
- char buf[257];
+ char buf[257], qnm[257], ts[12], cs[12], ip[128];
dname_str(name, buf);
- verbose(VERB_OPS, "ratelimit exceeded %s %d", buf, lim);
+ dname_str(qinfo->qname, qnm);
+ sldns_wire2str_type_buf(qinfo->qtype, ts, sizeof(ts));
+ sldns_wire2str_class_buf(qinfo->qclass, cs, sizeof(cs));
+ ip[0]=0;
+ if(replylist) {
+ addr_to_str((struct sockaddr_storage *)&replylist->addr,
+ replylist->addrlen, ip, sizeof(ip));
+ verbose(VERB_OPS, "ratelimit exceeded %s %d query %s %s %s from %s", buf, lim, qnm, cs, ts, ip);
+ } else {
+ verbose(VERB_OPS, "ratelimit exceeded %s %d query %s %s %s", buf, lim, qnm, cs, ts);
+ }
}
return (max < lim);
}
* @param name: zone name
* @param namelen: zone name length
* @param timenow: what time it is now.
+ * @param qinfo: for logging, query name.
+ * @param replylist: for logging, querier's address (if any).
* @return 1 if it could be incremented. 0 if the increment overshot the
* ratelimit or if in the previous second the ratelimit was exceeded.
* Failures like alloc failures are not returned (probably as 1).
*/
int infra_ratelimit_inc(struct infra_cache* infra, uint8_t* name,
- size_t namelen, time_t timenow);
+ size_t namelen, time_t timenow, struct query_info* qinfo,
+ struct comm_reply* replylist);
/**
* Decrement the query rate counter for a delegation point.