summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* conntrack: support diminutives for -LPablo Neira Ayuso2008-11-281-2/+2
| | | | | | | | | | | | | | | | With this patch, you can specify the following command to dump the expectation table, instead of writing 'expect'. # conntrack -L e also, it is valid the following command: # conntrack -L ex # conntrack -L exp and so on. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* conntrack: remove hardcoded buffer size, use sizeof insteadPablo Neira Ayuso2008-11-281-3/+3
| | | | | | | This patch replaces a couple of hardcoded buffer sizes by sizeof() calls. This sort of code is error-prone. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* conntrack: do_parse_parameter show warning to stderr (not to stdout)Pablo Neira Ayuso2008-11-281-2/+4
| | | | | | | This patch fixes a wrong warning display to stdout instead of stderr. Make the warning message homogeneous to others. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* src: move callbacks to run.c for better readabilityPablo Neira Ayuso2008-11-275-142/+149
| | | | | | | | | This patch is a cleanup. It moves the callbacks from netlink.c to run.c where they are actually invoked. This is better for code readability as I usually have to switch from run.c to netlink.c to remember what the callbacks actually do. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* ftfw: remove useless ftfw_run invocation in the alive alarm handlerPablo Neira Ayuso2008-11-261-6/+0
| | | | | | | | This patch removes a forced run of the transmission queue. This is not required since we currently have an event descriptor that indicates when to give a queue run to push pending messages. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* fds: remove unused array of file descriptorsPablo Neira Ayuso2008-11-261-29/+1
| | | | | | | This patch removes an unused array of file descriptors inside the fds structure. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* run: release fds structure in the exit pathPablo Neira Ayuso2008-11-261-0/+1
| | | | | | This patch adds the missing destroy_fds() in the exit path. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* filter: CIDR-based filtering supportPablo Neira Ayuso2008-11-256-20/+313
| | | | | | | | | | This patch adds CIDR-based filtering support. The current implementation is O(n). This patch also introduces the vector data type which is used to store the IP address and the network mask. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* build: add attribute header size to total attribute lengthPablo Neira Ayuso2008-11-251-2/+5
| | | | | | | | | | | | | | This patch adds the size of the attribute header (4 bytes) to the length field of netattr. This fixes a possible invalid memory access in malformed messages. This change is included in the set of scheduled changes for 0.9.9 that break backward compatibility. This patch also removes a memset of 4096 by one to initialize the headers and the netattr paddings. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* filter: choose the filtering method via configuration filePablo Neira Ayuso2008-11-184-8/+23
| | | | | | | | | | | | | | | | This patch changes the current behaviour of the filtering selection. Up to now, conntrackd has used the kernel version to select the filtering method based on the following logic: If kernel is >= 2.6.26 we use BSF-based filtering from kernel-space, otherwise, default to userspace. However, this filtering method still lacks of IPv6 support and it requires a patch that got into 2.6.29 to filter IPv6 addresses from kernel-space. To fix this issue, we default to user-space filtering and let the user choose the method via the configuration file. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* conntrack: --status should not be mandatory with -IPablo Neira Ayuso2008-11-151-1/+1
| | | | | | | | | This patch relaxes the parameter checking as now we don't need to pass --status when we create a conntrack via command line interface. In this case, the conntrack entry is created only with the IPS_CONFIRMED flag. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* filter: remove useless branch in the check functionsPablo Neira Ayuso2008-11-151-8/+2
| | | | | | | | | If the logic is set to -1, this means that we do not perform any filtering for this sort of network address. Therefore, we don't need to re-check if there is any filter later. This patch also inlines the check functions. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* filter: use jhash2 instead of jhash for IPv6 addressesPablo Neira Ayuso2008-11-151-1/+1
| | | | | | | Since an IPv6 address can be seen as an array of uint32_t. Use the optimized jhash2() function instead of the generic jhash(). Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* filter: use XOR instead of branchesPablo Neira Ayuso2008-11-091-13/+5
| | | | | | use XOR instead of branches in ct_filter_check. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* network: rework TLV-based protocolPablo Neira Ayuso2008-11-022-145/+210
| | | | | | | | | | | | | | | This patch reworks the TLV-based protocol to reduce the overhead in the message building. The idea is to group some attributes that must be present in a consistent configuration. Putting them together help us to save some cycles in the message building. Now, oprofile reports ~15% of samples in the build path instead of ~25%. CPU consumption for 3000 HTTP GET requests per second (1000 concurrent with apache benchmark tool) is ~45% in my testbed, that is ~19% more consumption than with no replication at all. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* network: add protocol version field (breaks backward compatibility)Pablo Neira Ayuso2008-11-023-10/+13
| | | | | | | | | | | | | This patch adds the version field (8-bits long) to the nethdr structure. This fields can be used to indicate the protocol version in case that we detect an incompatibility between two conntrackd daemons working with different protocol versions. Unfortunately, this patch breaks backward compatibility, ie. conntrackd <= 0.9.8 protocol is not compatible with the upcoming conntrackd >= 0.9.9. Better do this now than later. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* network: remove message omission test-codePablo Neira Ayuso2008-11-021-13/+0
| | | | | | | | | This patch removes a part of the code that can be used to simulate message loss in the replication. This was useful to test the FT-FW code. However, this code is not useful anymore as long as we have netem: tc qdisc add dev eth0 root netem loss 0.1% Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* ftfw: remove bottleneck in ack/nack handlingPablo Neira Ayuso2008-10-261-26/+38
| | | | | | | | | Since the resend list/queue contain elements in order, we can break looping once we find the first element that is after the ack/nack window. This patch fixes a bottleneck in the ack/nack handling reported by oprofile. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* ftfw: add option `-v' to output debugging information (if any)Pablo Neira Ayuso2008-10-262-35/+41
| | | | | | | | | | | | | | | | This patch introduces the option `-v' to show useful debugging information, if any. As for now, only sync-ftfw.c make use of it to display the content and the length of the resent list/queue. This is useful to check for message leaks. Other working modes or synchronization approaches may use it to display debugging information in the future. This patch removes _SIGNAL_DEBUG in sync-ftfw.c that was used for for the same purpose. However, it could only be enabled at compilation time and it uses signalling instead of the standard UNIX socket interface that conntrackd provides. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* ftfw: rise the size of the acknowledgment window in the examplePablo Neira Ayuso2008-10-211-2/+2
| | | | | | | | | This patch increases the size of the acknowledgment window based on some experiments in my testbed with oprofile. The previous default value was too small. This resulted in too many cycles to empty the resend queue. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* conntrackd: add missing information on -t to the helpPablo Neira Ayuso2008-10-211-2/+3
| | | | | | | This patch adds missing information on -t when conntrackd is invoked with -h. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* filter: do not filter in user-space if kernel supports BSFPablo Neira Ayuso2008-10-213-7/+8
| | | | | | | | | This patch avoids a double filtering in user-space and kernel-space if the kernel support BSF. Since we do not use BSF for dumps and resyncs, we add a new parameter to ignore_conntrack to indicate if we have to perform the filtering in user-space or not. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* cache: use jhash2 instead of double jhash+jhash_2wordsPablo Neira Ayuso2008-10-211-19/+17
| | | | | | | | Currently, oprofile reports ~17% of sample in the hashing. With this patch, that uses jhash2 instead of a double call to jhash and one to jhash_2words, it goes down to ~11%. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* filter: fix segfault if the Filter clause is unusedPablo Neira Ayuso2008-10-211-1/+2
| | | | | | | This patch fixes a segfault when conntrackd -k is invoked for an instance of conntrackd with no use of the Filter clause. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* netlink: report when kernel-space event filtering is in usePablo Neira Ayuso2008-10-211-0/+1
| | | | | | | This patch adds a log message to tell that conntrackd are using kernel-space filtering. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* notrack: fix double receival of resync requestsPablo Neira Ayuso2008-10-201-0/+21
| | | | | | | This patch fixes double insertion in the tx_list if we receive two (or more) consecutive resync request in short time. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* config: fix usage of 'PurgeTimeout' in Sync NOTRACKPablo Neira Ayuso2008-10-201-2/+4
| | | | | | | | | This patch fixes a problem that is reported by conntrackd while trying to parse the example configuration file. We fix this instead of the example file to make it consistent with other replication approaches. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* cache-iterators: improve committingPablo Neira Ayuso2008-10-201-4/+16
| | | | | | | | | | | | | This patches fixes two problems: - If we failt to update an entry, we remove it and try again. This happens when we still have an entry in a final state like TIME_WAIT while we see a new connection (SYN_SENT) with the same tuple. In this particular case, we fail to update since some status bits are only settable, but not unsettable. - If we hit ETIME in an update, we have to go over the creation patch, otherwise we hit ENOENT in the next run. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* cache: fix update of scheduled-to-timeout entriesPablo Neira Ayuso2008-10-201-44/+55
| | | | | | | This patch fixes a problem that allows the update of entries that are scheduled to be removed. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* conntrack: cleanup for NAT filteringPablo Neira Ayuso2008-10-161-24/+9
| | | | | | | | | | This patch cleanups the NAT filtering. The former code had three branches, one if src and dst NAT are set, else one if src NAT is set, else one if dst NAT is set. Now, we check if src NAT is set or if dst NAT is set. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* conntrack: fix dump counter displayed with -L expectPablo Neira Ayuso2008-10-091-0/+1
| | | | | | This patch fixes the dump counter displayed with -L expect. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* conntrack: fix filtering for unsupported protocolPablo Neira Ayuso2008-10-042-17/+51
| | | | | | | | | This patch fixes filtering for unsupported protocol. Thus, you can use -L -p 47 or -L -p gre to filter `gre' traffic. Based on an initial patch from Bryan Duff <bduff@astrocorp.com>. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* conntrack: fix mark-based filtering for event displayPablo Neira Ayuso2008-10-021-3/+6
| | | | | | | | | | | The mark-based filtering for events does not work if the mark is not present in the event message. This happens because nfct_cmp() skips the comparison of the compared objects since it they do not have the same attributes set. This patch make use of the new NFCT_CMP_MASK flag that returns false if the first object passed as parameter is set and the second is not. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* conntrack: cleanup XML header handlingPablo Neira Ayuso2008-09-281-22/+6
| | | | | | | This patch removes the use of snprintf and directly print the XML header to the standard output. This simplifies the handling. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* conntrack: cleanup for the update pathPablo Neira Ayuso2008-09-281-4/+5
| | | | | | This patch cleans up the update path for the conntrack utility. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* ftfw: reset window and flush the resend queue during helloingPablo Neira Ayuso2008-09-251-1/+21
| | | | | | | | | | | | | This fixes two bugs when a hello message is received: * We can create malformed nack messages during the helloing. We have to reset the acknowlegdment window, otherwise we may create malformed nack messages. * We have to empty the resend list/queue when a hello message is received, otherwise the entries get stuck to the resend queue once the sequence number wraps around. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* ftfw: fix race condition in the helloing routinePablo Neira Ayuso2008-09-251-14/+30
| | | | | | | | | | | | | | | | | | | | This patch fixes a race condition that can prevent one node from sending the initial hello message required to reset the sequence tracking. node A node B | | start | | hello msg |----------------------->| stop | | start | | |<-----------------------| hello-back msg In the picture above, the node A never sends the hello messages. Thus, the node B drops the next messages as they are in the before boundary. This patch adds a new state to the the helloing state-machine to fix this problem. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* ftfw: fix race that triggers a double insertion into tx_listPablo Neira Ayuso2008-09-251-2/+9
| | | | | | | | This patch fixes a race condition that can trigger a double insertion to the tx_list. This happens if we receive two resync request very close or resync just after a nack or vice-versa. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* fix: remove node from tx_list when the state-entry is destroyPablo Neira Ayuso2008-09-211-6/+9
| | | | | | | | | This patches fixes a race that triggers a read-after-free access to the tx_list. The state-entry is destroyed but it is still in the list. The fix removes the state-entry from the tx_list in the destroy path. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* cleanup: remove some debug messages from sync-ftfw.cPablo Neira Ayuso2008-09-171-31/+8
| | | | | | | Remove useless debug messages, now we have a pluging for tcpdump to debug the FT-FW protocol. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* filter: check if kernel-space filtering is availablePablo Neira Ayuso2008-09-172-10/+11
| | | | | | | | Check if the Linux kernel is >= 2.6.26, otherwise it does not support kernel-space filtering. This is not clean but we have no choice, the BSF infrastructure does not return ENOTSUPP for unsupported operations. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* cleanup: Linux kernel version checkingPablo Neira Ayuso2008-09-171-6/+1
| | | | | | | Minor cleanup to save a couple of lines in the Linux kernel version checking. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* filter: fix NAT detection tweakPablo Neira Ayuso2008-09-162-18/+3
| | | | | | | | With this patch, we rely on the real source and destination of the packet to perform the filter. The current NAT detection tweak is broken for certain situations. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* ftfw: check for malformed ack and nack messagesPablo Neira Ayuso2008-09-161-0/+8
| | | | | | | This patch checks that the [from, to] interval of ack and nack messages is OK. In other words, we check that: to >= from Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* cli: insert `conntrack-tools' string in help and error messagesPablo Neira Ayuso2008-08-121-4/+4
| | | | | | | Insert string `conntrack-tools' in error messages to explicitly print that this version is inside the conntrack-tools package. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* cli: check for missing arguments in getopt_longPablo Neira Ayuso2008-08-121-7/+13
| | | | | | | | | From: Pablo Neira Ayuso <pablo@netfilter.org> If getopt_long returns '?', show an error telling that some arguments are missing. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* cli: remove unrequired \n in error messagePablo Neira Ayuso2008-08-121-1/+1
| | | | | | Remove extra \n in error message. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* cli: remove duplicated optarg checkingPablo Neira Ayuso2008-08-121-36/+0
| | | | | | | Remove duplicated optarg checkings for options that require mandatory paramaters. This checking is already done by getopt_long(). Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* netlink: avoid errors related to the expected bit handlingPablo Neira Ayuso2008-08-071-2/+15
| | | | | | | | We hit error if we try to change the expected bit for already existing conntracks. On the other hand, if the conntrack does not exist, do not change the expected bit, otherwise we also hit error. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* cache iterators: commit master entries before related onesPablo Neira Ayuso2008-08-072-5/+36
| | | | | | Commit master entries before related ones to avoid ENOENT errors. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>