#include "resolved-dns-domain.h"
#include "resolved-dns-scope.h"
+#define MULTICAST_RATELIMIT_INTERVAL_USEC (1*USEC_PER_SEC)
+#define MULTICAST_RATELIMIT_BURST 1000
+
int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol protocol, int family) {
DnsScope *s;
log_debug("New scope on link %s, protocol %s, family %s", l ? l->name : "*", dns_protocol_to_string(protocol), family == AF_UNSPEC ? "*" : af_to_name(family));
+ /* Enforce ratelimiting for the multicast protocols */
+ RATELIMIT_INIT(s->ratelimit, MULTICAST_RATELIMIT_INTERVAL_USEC, MULTICAST_RATELIMIT_BURST);
+
*ret = s;
return 0;
}
if (DNS_PACKET_QDCOUNT(p) > 1)
return -ENOTSUP;
+ if (!ratelimit_test(&s->ratelimit))
+ return -EBUSY;
+
family = s->family;
port = 5355;
if (stream)
r = dns_stream_write_packet(stream, reply);
else {
+ if (!ratelimit_test(&s->ratelimit))
+ return;
+
if (p->family == AF_INET)
fd = manager_llmnr_ipv4_udp_fd(s->manager);
else if (p->family == AF_INET6)
char name[IF_NAMESIZE];
uint32_t mtu;
-
- RateLimit mdns_ratelimit;
- RateLimit llmnr_ratelimit;
};
int link_new(Manager *m, Link **ret, int ifindex);