Silence excessively chatty messages from ARP handling. Random received

packets that are discarded for simply not being targets for examination
should not trigger prints.
This commit is contained in:
Nicholas J. Kain 2011-06-25 10:02:09 -04:00
parent 5cf572c2fd
commit 19f7e6d11e

View File

@ -1,5 +1,5 @@
/* arp.c - arp ping checking /* arp.c - arp ping checking
* Time-stamp: <2011-06-11 11:12:58 njk> * Time-stamp: <2011-06-16 21:37:52 njk>
* *
* Copyright 2010-2011 Nicholas J. Kain <njkain@gmail.com> * Copyright 2010-2011 Nicholas J. Kain <njkain@gmail.com>
* *
@ -228,6 +228,9 @@ static void arp_gw_success(struct client_state_t *cs)
cs->dhcpState = cs->arpPrevState; cs->dhcpState = cs->arpPrevState;
} }
// Note that this function will see all ARP traffic on the interface.
// Therefore the validation shouldn't be noisy, and should silently
// reject non-malformed ARP packets that are irrelevant.
static int arp_validate(struct arpMsg *am) static int arp_validate(struct arpMsg *am)
{ {
if (!am) if (!am)
@ -253,15 +256,16 @@ static int arp_validate(struct arpMsg *am)
return 0; return 0;
} }
if (am->operation != htons(ARPOP_REPLY)) { if (am->operation != htons(ARPOP_REPLY)) {
log_warning("arp: ARP operation type is not 'reply'"); /* log_warning("arp: ARP operation type is not 'reply': %x", */
/* ntohs(am->operation)); */
return 0; return 0;
} }
if (memcmp(am->h_dest, client_config.arp, 6)) { if (memcmp(am->h_dest, client_config.arp, 6)) {
log_warning("arp: Ethernet destination does not equal our MAC"); /* log_warning("arp: Ethernet destination does not equal our MAC"); */
return 0; return 0;
} }
if (memcmp(am->dmac, client_config.arp, 6)) { if (memcmp(am->dmac, client_config.arp, 6)) {
log_warning("arp: ARP destination does not equal our MAC"); /* log_warning("arp: ARP destination does not equal our MAC"); */
return 0; return 0;
} }
return 1; return 1;
@ -291,10 +295,8 @@ void handle_arp_response(struct client_state_t *cs)
return; return;
} }
if (!arp_validate(&arpreply)) { if (!arp_validate(&arpreply))
log_warning("arp: ARP message header is invalid -- ignoring");
return; return;
}
++arp_packet_num; ++arp_packet_num;
switch (cs->dhcpState) { switch (cs->dhcpState) {