]> code.ossystems Code Review - openembedded-core.git/blob
25a0a0e40fd0dc9f2c338763eeb6f8001f5d1389
[openembedded-core.git] /
1 From de7cde877e4daa5d9d4fb5b1a349299eaa94969d Mon Sep 17 00:00:00 2001
2 From: Trent Lloyd <trent@lloyd.id.au>
3 Date: Sat, 10 Oct 2015 06:20:46 +0800
4 Subject: [PATCH] Don't log warnings about invalid packets (Fixes
5  lathiat/avahi#10)
6
7 Various invalid packets would generate a warning, in particular
8 Windows 10 generates response packets with no answer records and
9 generally seemingly empty.  Unsure why at this stage.
10
11 This results in spamming syslog quite a lot on busy networks,
12 similar issues like this have occured over time due to changes
13 in various operating systems and specs (e.g. Avahi #284, #282)
14
15 Rather than just disable this single message or case, I have
16 pre-emptively turned the majority of these bad packet messages
17 into debug messages.  They can still be output on production
18 builds if reuqired using the --debug option (no rebuild required).
19
20 External References:
21 https://bugs.launchpad.net/ubuntu/+source/avahi/+bug/1342400
22 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=794145
23 https://bugzilla.redhat.com/show_bug.cgi?id=1240711
24
25 Pulled from git://github.com/lathiat/avahi de7cde87, which
26 is slated for avahi 0.6.32.
27
28 Signed-off-by: Brad Mouring <brad.mouring@ni.com>
29 Upstream-Status: Backport
30
31 ---
32  avahi-core/server.c | 28 ++++++++++++++--------------
33  1 file changed, 14 insertions(+), 14 deletions(-)
34
35 diff --git a/avahi-core/server.c b/avahi-core/server.c
36 index e87f035..a2cb19a 100644
37 --- a/avahi-core/server.c
38 +++ b/avahi-core/server.c
39 @@ -587,7 +587,7 @@ static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterfac
40          int unicast_response = 0;
41  
42          if (!(key = avahi_dns_packet_consume_key(p, &unicast_response))) {
43 -            avahi_log_warn(__FILE__": Packet too short or invalid while reading question key. (Maybe a UTF-8 problem?)");
44 +            avahi_log_debug(__FILE__": Packet too short or invalid while reading question key. (Maybe a UTF-8 problem?)");
45              goto fail;
46          }
47  
48 @@ -615,7 +615,7 @@ static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterfac
49              int unique = 0;
50  
51              if (!(record = avahi_dns_packet_consume_record(p, &unique))) {
52 -                avahi_log_warn(__FILE__": Packet too short or invalid while reading known answer record. (Maybe a UTF-8 problem?)");
53 +                avahi_log_debug(__FILE__": Packet too short or invalid while reading known answer record. (Maybe a UTF-8 problem?)");
54                  goto fail;
55              }
56  
57 @@ -632,7 +632,7 @@ static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterfac
58              int unique = 0;
59  
60              if (!(record = avahi_dns_packet_consume_record(p, &unique))) {
61 -                avahi_log_warn(__FILE__": Packet too short or invalid while reading probe record. (Maybe a UTF-8 problem?)");
62 +                avahi_log_debug(__FILE__": Packet too short or invalid while reading probe record. (Maybe a UTF-8 problem?)");
63                  goto fail;
64              }
65  
66 @@ -669,7 +669,7 @@ static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInter
67          int cache_flush = 0;
68  
69          if (!(record = avahi_dns_packet_consume_record(p, &cache_flush))) {
70 -            avahi_log_warn(__FILE__": Packet too short or invalid while reading response record. (Maybe a UTF-8 problem?)");
71 +            avahi_log_debug(__FILE__": Packet too short or invalid while reading response record. (Maybe a UTF-8 problem?)");
72              break;
73          }
74  
75 @@ -901,13 +901,13 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddres
76  
77      if (!(i = avahi_interface_monitor_get_interface(s->monitor, iface, src_address->proto)) ||
78          !i->announcing) {
79 -        avahi_log_warn("Received packet from invalid interface.");
80 +        avahi_log_debug("Received packet from invalid interface.");
81          return;
82      }
83  
84      if (port <= 0) {
85          /* This fixes RHBZ #475394 */
86 -        avahi_log_warn("Received packet from invalid source port %u.", (unsigned) port);
87 +        avahi_log_debug("Received packet from invalid source port %u.", (unsigned) port);
88          return;
89      }
90  
91 @@ -924,7 +924,7 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddres
92          from_local_iface = originates_from_local_iface(s, iface, src_address, port);
93  
94      if (avahi_dns_packet_check_valid_multicast(p) < 0) {
95 -        avahi_log_warn("Received invalid packet.");
96 +        avahi_log_debug("Received invalid packet.");
97          return;
98      }
99  
100 @@ -940,7 +940,7 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddres
101  
102              if ((avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) != 0 ||
103                   avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_NSCOUNT) != 0)) {
104 -                avahi_log_warn("Invalid legacy unicast query packet.");
105 +                avahi_log_debug("Invalid legacy unicast query packet.");
106                  return;
107              }
108  
109 @@ -956,19 +956,19 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddres
110          char t[AVAHI_ADDRESS_STR_MAX];
111  
112          if (port != AVAHI_MDNS_PORT) {
113 -            avahi_log_warn("Received response from host %s with invalid source port %u on interface '%s.%i'", avahi_address_snprint(t, sizeof(t), src_address), port, i->hardware->name, i->protocol);
114 +            avahi_log_debug("Received response from host %s with invalid source port %u on interface '%s.%i'", avahi_address_snprint(t, sizeof(t), src_address), port, i->hardware->name, i->protocol);
115              return;
116          }
117  
118          if (ttl != 255 && s->config.check_response_ttl) {
119 -            avahi_log_warn("Received response from host %s with invalid TTL %u on interface '%s.%i'.", avahi_address_snprint(t, sizeof(t), src_address), ttl, i->hardware->name, i->protocol);
120 +            avahi_log_debug("Received response from host %s with invalid TTL %u on interface '%s.%i'.", avahi_address_snprint(t, sizeof(t), src_address), ttl, i->hardware->name, i->protocol);
121              return;
122          }
123  
124          if (!is_mdns_mcast_address(dst_address) &&
125              !avahi_interface_address_on_link(i, src_address)) {
126  
127 -            avahi_log_warn("Received non-local response from host %s on interface '%s.%i'.", avahi_address_snprint(t, sizeof(t), src_address), i->hardware->name, i->protocol);
128 +            avahi_log_debug("Received non-local response from host %s on interface '%s.%i'.", avahi_address_snprint(t, sizeof(t), src_address), i->hardware->name, i->protocol);
129              return;
130          }
131  
132 @@ -976,7 +976,7 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddres
133              avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) == 0 ||
134              avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_NSCOUNT) != 0) {
135  
136 -            avahi_log_warn("Invalid response packet from host %s.", avahi_address_snprint(t, sizeof(t), src_address));
137 +            avahi_log_debug("Invalid response packet from host %s.", avahi_address_snprint(t, sizeof(t), src_address));
138              return;
139          }
140  
141 @@ -992,12 +992,12 @@ static void dispatch_legacy_unicast_packet(AvahiServer *s, AvahiDnsPacket *p) {
142      assert(p);
143  
144      if (avahi_dns_packet_check_valid(p) < 0 || avahi_dns_packet_is_query(p)) {
145 -        avahi_log_warn("Received invalid packet.");
146 +        avahi_log_debug("Received invalid packet.");
147          return;
148      }
149  
150      if (!(slot = find_slot(s, avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ID)))) {
151 -        avahi_log_warn("Received legacy unicast response with unknown id");
152 +        avahi_log_debug("Received legacy unicast response with unknown id");
153          return;
154      }
155  
156 -- 
157 2.6.4
158