Clean up csum detection output, misc fixes.

remotes/origin/master-1.2.x
Victor Julien 14 years ago
parent 279b8b4027
commit d24b3a0e50

@ -205,9 +205,7 @@ void *ParseAFPConfig(const char *iface)
aconf->promisc = 0;
}
if (ConfGetChildValue(if_root, "checksum-checks", &tmpctype) != 1) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "Could not get checksum-checks from config");
} else {
if (ConfGetChildValue(if_root, "checksum-checks", &tmpctype) == 1) {
if (strcmp(tmpctype, "auto") == 0) {
aconf->checksum_mode = CHECKSUM_VALIDATION_AUTO;
} else if (strcmp(tmpctype, "yes") == 0) {

@ -145,9 +145,7 @@ void *ParsePcapConfig(const char *iface)
SCLogInfo("BPF filter set from command line or via old 'bpf-filter' option.");
}
if (ConfGetChildValue(if_root, "checksum-checks", &tmpctype) != 1) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "Could not get checksum-checks from config");
} else {
if (ConfGetChildValue(if_root, "checksum-checks", &tmpctype) == 1) {
if (strcmp(tmpctype, "auto") == 0) {
aconf->checksum_mode = CHECKSUM_VALIDATION_AUTO;
} else if (strcmp(tmpctype, "yes") == 0) {

@ -194,8 +194,8 @@ void *ParsePfringConfig(const char *iface)
ConfNode *pf_ring_node;
PfringIfaceConfig *pfconf = SCMalloc(sizeof(*pfconf));
char *tmpclusterid;
#ifdef HAVE_PFRING_CLUSTER_TYPE
char *tmpctype = NULL;
#ifdef HAVE_PFRING_CLUSTER_TYPE
cluster_type default_ctype = CLUSTER_ROUND_ROBIN;
int getctype = 0;
#endif
@ -316,9 +316,9 @@ void *ParsePfringConfig(const char *iface)
}
}
if (ConfGetChildValue(if_root, "checksum-checks", &tmpctype) != 1) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "Could not get checksum-checks from config");
} else {
#endif /* HAVE_PFRING_CLUSTER_TYPE */
if (ConfGetChildValue(if_root, "checksum-checks", &tmpctype) == 1) {
if (strcmp(tmpctype, "auto") == 0) {
pfconf->checksum_mode = CHECKSUM_VALIDATION_AUTO;
} else if (strcmp(tmpctype, "yes") == 0) {
@ -332,9 +332,6 @@ void *ParsePfringConfig(const char *iface)
}
}
#endif
return pfconf;
}

@ -393,7 +393,8 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) {
#ifdef HAVE_PCAP_SET_BUFF
ptv->pcap_buffer_size = pcapconfig->buffer_size;
if (ptv->pcap_buffer_size >= 0 && ptv->pcap_buffer_size <= INT_MAX) {
SCLogInfo("Going to use pcap buffer size of %" PRId32 "", ptv->pcap_buffer_size);
if (ptv->pcap_buffer_size > 0)
SCLogInfo("Going to use pcap buffer size of %" PRId32 "", ptv->pcap_buffer_size);
int pcap_set_buffer_size_r = pcap_set_buffer_size(ptv->pcap_handle,ptv->pcap_buffer_size);
//printf("ReceivePcapThreadInit: pcap_set_timeout(%p) returned %" PRId32 "\n", ptv->pcap_handle, pcap_set_buffer_size_r);

@ -1,4 +1,4 @@
/* Copyright (C) 2011 Open Information Security Foundation
/* Copyright (C) 2011-2012 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -60,25 +60,30 @@ int ReCalculateChecksum(Packet *p)
return 0;
}
/**
* \brief Check if the number of invalid checksums indicate checksum
* offloading in place.
*
* \retval 1 yes, offloading in place
* \retval 0 no, no offloading used
*/
int ChecksumAutoModeCheck(uint32_t thread_count,
uint32_t iface_count,
uint32_t iface_fail)
unsigned int iface_count, unsigned int iface_fail)
{
if (thread_count == CHECKSUM_SAMPLE_COUNT) {
if (iface_fail != 0) {
if ((iface_count / iface_fail) < CHECKSUM_INVALID_RATIO) {
SCLogInfo("More than 1/10 of invalid checksum, assuming checksum offloading is used (%d/%d)",
iface_fail,
iface_count);
SCLogInfo("More than 1/10th of packets have an invalid "
"checksum, assuming checksum offloading is used (%d/%d)",
iface_fail, iface_count);
return 1;
} else {
SCLogInfo("Less than 1/10 of invalid checksum, assuming checksum offloading is NOT used (%d/%d)",
iface_fail,
iface_count);
SCLogInfo("Less than 1/10th of packet have an invalid "
"checksum, assuming checksum offloading is NOT used (%d/%d)",
iface_fail, iface_count);
}
} else {
SCLogInfo("No packet with invalid checksum, assuming checksum offloading is NOT used");
SCLogInfo("No packets with invalid checksum, assuming checksum offloading is NOT used");
}
}
return 0;

@ -1,4 +1,4 @@
/* Copyright (C) 2011 Open Information Security Foundation
/* Copyright (C) 2011-2012 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -26,8 +26,7 @@
int ReCalculateChecksum(Packet *p);
int ChecksumAutoModeCheck(uint32_t thread_count,
uint32_t iface_count,
uint32_t iface_fail);
unsigned int iface_count, unsigned int iface_fail);
/* constant linked with detection of interface with
* invalid checksums */

@ -1,4 +1,4 @@
/* Copyright (C) 2011 Open Information Security Foundation
/* Copyright (C) 2011-2012 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free

@ -1,4 +1,4 @@
/* Copyright (C) 2011 Open Information Security Foundation
/* Copyright (C) 2011-2012 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -24,8 +24,8 @@
typedef struct LiveDevice_ {
char *dev; /**< the device (e.g. "eth0") */
int ignore_checksum;
SC_ATOMIC_DECLARE(uint32_t, pkts);
SC_ATOMIC_DECLARE(uint32_t, invalid_checksums);
SC_ATOMIC_DECLARE(unsigned int, pkts);
SC_ATOMIC_DECLARE(unsigned int, invalid_checksums);
TAILQ_ENTRY(LiveDevice_) next;
} LiveDevice;

Loading…
Cancel
Save