diff options
author | Mark Bryars <mark@darkskiez.co.uk> | 2012-12-13 00:37:39 +0000 |
---|---|---|
committer | Mark Bryars <mark@darkskiez.co.uk> | 2012-12-13 00:37:39 +0000 |
commit | 8a6619431108429a28d0be76b10c926e9a66a3ee (patch) | |
tree | 64964c159dc6c6c98057e5869107e758c6ab0807 | |
parent | 5a04d1e49bb7e3cf3d3149e3c718acedaf61c891 (diff) | |
parent | f934da394a4c807d58966b846e7a3f0ca5e4f280 (diff) | |
download | vyos-opennhrp-8a6619431108429a28d0be76b10c926e9a66a3ee.tar.gz vyos-opennhrp-8a6619431108429a28d0be76b10c926e9a66a3ee.zip |
Merge tag 'upstream/0.14'
Upstream version 0.14
-rw-r--r-- | AUTHORS | 9 | ||||
-rw-r--r-- | MIT-LICENSE.txt | 19 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | NEWS | 9 | ||||
-rw-r--r-- | README | 11 | ||||
-rw-r--r-- | TODO | 48 | ||||
-rw-r--r-- | nhrp/admin.c | 10 | ||||
-rw-r--r-- | nhrp/afnum.h | 10 | ||||
-rw-r--r-- | nhrp/list.h | 10 | ||||
-rw-r--r-- | nhrp/nhrp_address.c | 10 | ||||
-rw-r--r-- | nhrp/nhrp_address.h | 10 | ||||
-rw-r--r-- | nhrp/nhrp_common.h | 10 | ||||
-rw-r--r-- | nhrp/nhrp_defines.h | 10 | ||||
-rw-r--r-- | nhrp/nhrp_interface.c | 10 | ||||
-rw-r--r-- | nhrp/nhrp_interface.h | 10 | ||||
-rw-r--r-- | nhrp/nhrp_packet.c | 21 | ||||
-rw-r--r-- | nhrp/nhrp_packet.h | 10 | ||||
-rw-r--r-- | nhrp/nhrp_peer.c | 50 | ||||
-rw-r--r-- | nhrp/nhrp_peer.h | 10 | ||||
-rw-r--r-- | nhrp/nhrp_protocol.h | 10 | ||||
-rw-r--r-- | nhrp/nhrp_server.c | 10 | ||||
-rw-r--r-- | nhrp/opennhrp.c | 10 | ||||
-rw-r--r-- | nhrp/opennhrpctl.c | 10 | ||||
-rw-r--r-- | nhrp/sysdep_netlink.c | 10 | ||||
-rw-r--r-- | nhrp/sysdep_pfpacket.c | 52 | ||||
-rw-r--r-- | nhrp/sysdep_syslog.c | 10 |
26 files changed, 223 insertions, 168 deletions
@@ -1,7 +1,10 @@ Author: Timo Teräs <timo.teras@iki.fi> -Patches from: -Steffen Schmidt +Patches, or ideas from (in alphabetical order): +David Ward +Doug Kehn +Halil Goektepe Natanael Copa -Halil Goektepe (Deutsche Telekom DTAG Laboratories) +Robin Hammond +Steffen Schmidt diff --git a/MIT-LICENSE.txt b/MIT-LICENSE.txt new file mode 100644 index 0000000..2793183 --- /dev/null +++ b/MIT-LICENSE.txt @@ -0,0 +1,19 @@ +Copyright (c) 2007-2012 Timo Teräs + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. @@ -2,7 +2,7 @@ # Building opennhrp PACKAGE := opennhrp -VERSION := 0.13.1 +VERSION := 0.14 ## # Default directories @@ -6,6 +6,15 @@ Detailed changelog is available via Git history via web: http://opennhrp.git.sf.net/git/gitweb.cgi?p=opennhrp;a=blob;f=NEWS;hb=HEAD ----------------------------------------------------------------------------- + opennhrp 0.14 - released 12/Dec/2012 +----------------------------------------------------------------------------- + - licensing terms changed to MIT License + - fix: do not lock up if there's routing loop for protocol address + - fix: handle low holding time for resolved entries properly + - fix: dynamically allocate packet filter code to accomodate large + routing tables + +----------------------------------------------------------------------------- opennhrp 0.13.1 - released 22/Jun/2012 ----------------------------------------------------------------------------- - fix: make "local-nbma" selector work properly if there are multiple gre @@ -8,6 +8,17 @@ Project homepage: http://sourceforge.net/projects/opennhrp Git repository: git://opennhrp.git.sourceforge.net/gitroot/opennhrp + LICENSE + +OpenNHRP is licensed under the MIT License. See MIT-LICENSE.txt for +additional details. + +OpenNHRP embeds libev. libev is dual licensed with 2-clause BSD and +GPLv2+ licenses. See libev/LICENSE for additional details. + +OpenNHRP links to c-ares. c-ares is licensed under the MIT License. + + KERNEL REQUIREMENTS You need a kernel with ip_gre patched to support sending and receiving @@ -1,4 +1,40 @@ -Open items that need work on OpenNHRP: +Ideas, and some definite tasks to do, in no particular order: + +- hash lookup for peers based on protocol address; cache route lookups + for incomplete entries + +- Create some logic to detect if NBMA and public IPs are mixed up in + the "map" directive. Issue on warning about this. + +- if direct connection not possible, take closest known NHS + from ResolutionReply Forward NHS list, so we choose directly + connected NHS as our relay + +- get rid of replaced flag, mtu specific script call backs done properly + e.g. when nbma changes (delete old route, add new); convert the state + machine to renew instead of have "new" entry replacing old ones + +- when core has no other core links up yet, it should not negative cache + anything; instead it should give more time for those links to come up + +- main vpnc has shortcut-target /16, with delegation of + contained subnet /24 to secondary vpnc; indication gets + ignored due to shortcut already being there + +- clean up the internal nhrp_packet_send_* API + +- send purge on bgp nexthop change + +- NHS should not forward Resolution Request to NHC; it + should instead reply itself based on registered leases + +- IPv6-over-IPv4 support + +- IPv[46]-over-IPv6 support, see: http://patchwork.ozlabs.org/patch/173904/ + +- opennhrp to drop capabilities and run as non-root, libcap-ng + +- opennhrp-script: setup bgp weight based on RTT - interface-up, nhs-up, nhs-down need to be serialized for quagga management. alternatively, the script could return some special @@ -18,6 +54,9 @@ Open items that need work on OpenNHRP: local IP addresses. When receiving multi CIE next-hop, balance traffic or for shortcut routes, create a multi nexthop route. +- instead of keeping track of local routes for shortcuts, we could use + per-packet kernel lookup for off-nbma destinations. + - Create some logic to detect if NBMA and public IPs are mixed up in the "map" directive. Issue on warning about this. @@ -25,3 +64,10 @@ Open items that need work on OpenNHRP: - Clean shutdown: send purge request to registration servers, dynamic clients and possibly track resolution requests and purge those too. + +- talk zserv to quagga for shortcut routes + +- non-blocking admin port writes (needs enumeration code to be + interruptible and resumable) + +- IGMP snooping and multicast relaying optimizations diff --git a/nhrp/admin.c b/nhrp/admin.c index d89fa87..6e0a5e2 100644 --- a/nhrp/admin.c +++ b/nhrp/admin.c @@ -1,13 +1,9 @@ /* admin.c - OpenNHRP administrative interface implementation * - * Copyright (C) 2007-2009 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #include <ctype.h> diff --git a/nhrp/afnum.h b/nhrp/afnum.h index 2dc3d68..0505c5b 100644 --- a/nhrp/afnum.h +++ b/nhrp/afnum.h @@ -1,14 +1,10 @@ /* afnum.h - RFC 1700 Address Family Number and * ethernet protocol number definitions * - * Copyright (C) 2007 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #ifndef AFNUM_H diff --git a/nhrp/list.h b/nhrp/list.h index 4387970..caa22e4 100644 --- a/nhrp/list.h +++ b/nhrp/list.h @@ -1,13 +1,9 @@ /* list.h - Single and double linked list macros * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * See http://www.gnu.org/ for details. - * - * This is more or less based on the code in the linux kernel. There are - * minor differences and this is only a subset of the kernel version. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #ifndef LIST_H diff --git a/nhrp/nhrp_address.c b/nhrp/nhrp_address.c index 13164e1..808edf1 100644 --- a/nhrp/nhrp_address.c +++ b/nhrp/nhrp_address.c @@ -1,13 +1,9 @@ /* nhrp_address.c - NHRP address conversion functions * - * Copyright (C) 2007-2009 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #include <stdio.h> diff --git a/nhrp/nhrp_address.h b/nhrp/nhrp_address.h index e479631..8ec2b41 100644 --- a/nhrp/nhrp_address.h +++ b/nhrp/nhrp_address.h @@ -1,13 +1,9 @@ /* nhrp_address.h - NHRP address structures and helpers * - * Copyright (C) 2007 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #ifndef NHRP_ADDRESS_H diff --git a/nhrp/nhrp_common.h b/nhrp/nhrp_common.h index 6730e74..9422382 100644 --- a/nhrp/nhrp_common.h +++ b/nhrp/nhrp_common.h @@ -1,13 +1,9 @@ /* nhrp_common.h - Generic helper functions * - * Copyright (C) 2007-2009 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #ifndef NHRP_COMMON_H diff --git a/nhrp/nhrp_defines.h b/nhrp/nhrp_defines.h index 2812a13..37e4715 100644 --- a/nhrp/nhrp_defines.h +++ b/nhrp/nhrp_defines.h @@ -1,13 +1,9 @@ /* nhrp_defines.h - NHRP definitions * - * Copyright (C) 2007 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #ifndef NHRP_DEFINES_H diff --git a/nhrp/nhrp_interface.c b/nhrp/nhrp_interface.c index 05f0e80..f07e5d4 100644 --- a/nhrp/nhrp_interface.c +++ b/nhrp/nhrp_interface.c @@ -1,13 +1,9 @@ /* nhrp_interface.c - NHRP configuration per interface * - * Copyright (C) 2007 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #include <stdio.h> diff --git a/nhrp/nhrp_interface.h b/nhrp/nhrp_interface.h index 8e3e8df..5fade69 100644 --- a/nhrp/nhrp_interface.h +++ b/nhrp/nhrp_interface.h @@ -1,13 +1,9 @@ /* nhrp_interface.h - NHRP configuration per interface definitions * - * Copyright (C) 2007 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #ifndef NHRP_INTERFACE_H diff --git a/nhrp/nhrp_packet.c b/nhrp/nhrp_packet.c index f46b481..4edf392 100644 --- a/nhrp/nhrp_packet.c +++ b/nhrp/nhrp_packet.c @@ -1,13 +1,9 @@ /* nhrp_packet.c - NHRP packet marshalling and tranceiving * - * Copyright (C) 2007-2009 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #include <malloc.h> @@ -979,7 +975,7 @@ int nhrp_packet_route(struct nhrp_packet *packet) struct nhrp_payload *payload; struct nhrp_peer *peer; char tmp[64]; - int r; + int i, r; if (packet->dst_iface == NULL) { nhrp_error("nhrp_packet_route called without destination interface"); @@ -1005,7 +1001,7 @@ int nhrp_packet_route(struct nhrp_packet *packet) proto_nexthop = packet->dst_peer->next_hop_address; } else { proto_nexthop = *dst; - do { + for (i = 0; i < 4; i++) { peer = nhrp_peer_route_full( packet->dst_iface, &proto_nexthop, 0, NHRP_PEER_TYPEMASK_ROUTE_VIA_NHS, src, cielist); @@ -1020,7 +1016,12 @@ int nhrp_packet_route(struct nhrp_packet *packet) if (peer->next_hop_address.type == AF_UNSPEC) break; proto_nexthop = peer->next_hop_address; - } while (1); + } + if (i >= 4) { + nhrp_error("Recursive routing for protocol address %s", + nhrp_address_format(dst, sizeof(tmp), tmp)); + return FALSE; + } packet->dst_peer = nhrp_peer_get(peer); } diff --git a/nhrp/nhrp_packet.h b/nhrp/nhrp_packet.h index 3f435c8..c427957 100644 --- a/nhrp/nhrp_packet.h +++ b/nhrp/nhrp_packet.h @@ -1,13 +1,9 @@ /* nhrp_packet.h - In-memory NHRP packet definitions * - * Copyright (C) 2007-2009 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #ifndef NHRP_PACKET_H diff --git a/nhrp/nhrp_peer.c b/nhrp/nhrp_peer.c index 7bd1a79..94ba984 100644 --- a/nhrp/nhrp_peer.c +++ b/nhrp/nhrp_peer.c @@ -1,13 +1,9 @@ /* nhrp_peer.c - NHRP peer cache implementation * - * Copyright (C) 2007-2009 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #include <stdio.h> @@ -25,9 +21,6 @@ #define NHRP_SCRIPT_TIMEOUT (2*60) #define NHRP_NEGATIVE_CACHE_TIME (3*60) -#define NHRP_EXPIRY_TIME (5*60) - -#define NHRP_HOLDING_TIME_DIVISOR 3 /* See RFC-2332 5.2.3 */ #define NHRP_RETRY_REGISTER_TIME (30 + random()/(RAND_MAX/60)) #define NHRP_RETRY_ERROR_TIME (60 + random()/(RAND_MAX/120)) @@ -50,6 +43,25 @@ const char * const nhrp_peer_type[] = { static int nhrp_peer_num_total = 0; static struct list_head local_peer_list = LIST_INITIALIZER(local_peer_list); +static inline +int holding_time_to_reregister_time(int holding_time) +{ + /* RFC-2332 5.2.3 recommends one third of holding time as + * reregistration interval. */ + return holding_time / 3 + 1; +} + +static inline +int holding_time_to_expiry_time(int holding_time, int offset_time) +{ + /* Reresolution interval */ + int expire; + expire = 2 * holding_time / 3 - offset_time; + if (expire < 0) + expire = 0; + return expire + 1; +} + /* Peer entrys life, pending callbacks and their call order are listed * here. * @@ -495,8 +507,10 @@ static void nhrp_peer_script_route_up_done(union nhrp_peer_event e, int revents) sizeof(tmp), tmp)); peer->flags |= NHRP_PEER_FLAG_UP; - nhrp_peer_schedule(peer, peer->expire_time - NHRP_EXPIRY_TIME - - 10 - ev_now(), nhrp_peer_expire_cb); + nhrp_peer_schedule( + peer, + holding_time_to_expiry_time(peer->expire_time - ev_now(), 10), + nhrp_peer_expire_cb); } else { nhrp_info("[%s] Route up script: %s; " "adding negative cached entry", @@ -681,15 +695,15 @@ static void nhrp_peer_is_up(struct nhrp_peer *peer) case NHRP_PEER_TYPE_CACHED: nhrp_peer_schedule( peer, - peer->expire_time - NHRP_EXPIRY_TIME - ev_now(), + holding_time_to_expiry_time(peer->expire_time - ev_now(), 0), nhrp_peer_expire_cb); break; case NHRP_PEER_TYPE_STATIC: case NHRP_PEER_TYPE_DYNAMIC_NHS: if (peer->flags & NHRP_PEER_FLAG_REGISTER) { nhrp_peer_schedule( - peer, iface->holding_time / - NHRP_HOLDING_TIME_DIVISOR + 1, + peer, + holding_time_to_reregister_time(iface->holding_time), nhrp_peer_send_register_cb); } break; @@ -1595,8 +1609,10 @@ static void nhrp_peer_insert_cb(struct ev_timer *w, int revents) nhrp_peer_run_script(peer, "route-up", nhrp_peer_script_route_up_done); else - nhrp_peer_schedule(peer, peer->expire_time - NHRP_EXPIRY_TIME - - 10 - ev_now(), nhrp_peer_expire_cb); + nhrp_peer_schedule( + peer, + holding_time_to_expiry_time(peer->expire_time - ev_now(), 10), + nhrp_peer_expire_cb); break; case NHRP_PEER_TYPE_NEGATIVE: peer->expire_time = ev_now() + NHRP_NEGATIVE_CACHE_TIME; diff --git a/nhrp/nhrp_peer.h b/nhrp/nhrp_peer.h index 1df5fa9..9f0dd20 100644 --- a/nhrp/nhrp_peer.h +++ b/nhrp/nhrp_peer.h @@ -1,13 +1,9 @@ /* nhrp_peer.h - NHRP peer cache definitions * - * Copyright (C) 2007-2009 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #ifndef NHRP_PEER_H diff --git a/nhrp/nhrp_protocol.h b/nhrp/nhrp_protocol.h index 8cf213b..6d34e95 100644 --- a/nhrp/nhrp_protocol.h +++ b/nhrp/nhrp_protocol.h @@ -1,13 +1,9 @@ /* nhrp_protocol.h - NHRP protocol definitions * - * Copyright (C) 2007 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #ifndef NHRP_PROTOCOL_H diff --git a/nhrp/nhrp_server.c b/nhrp/nhrp_server.c index b41e4b8..8c35e1c 100644 --- a/nhrp/nhrp_server.c +++ b/nhrp/nhrp_server.c @@ -1,13 +1,9 @@ /* nhrp_server.c - NHRP request handling * - * Copyright (C) 2007-2009 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #include <string.h> diff --git a/nhrp/opennhrp.c b/nhrp/opennhrp.c index 8ba870d..4ed27a8 100644 --- a/nhrp/opennhrp.c +++ b/nhrp/opennhrp.c @@ -1,13 +1,9 @@ /* opennhrp.c - OpenNHRP main routines * - * Copyright (C) 2007-2009 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #include <ctype.h> diff --git a/nhrp/opennhrpctl.c b/nhrp/opennhrpctl.c index 92fb5b5..60bd161 100644 --- a/nhrp/opennhrpctl.c +++ b/nhrp/opennhrpctl.c @@ -1,13 +1,9 @@ /* opennhrpctl.c - OpenNHRP command line control utility * - * Copyright (C) 2007 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #include <errno.h> diff --git a/nhrp/sysdep_netlink.c b/nhrp/sysdep_netlink.c index 0dce865..be529d8 100644 --- a/nhrp/sysdep_netlink.c +++ b/nhrp/sysdep_netlink.c @@ -1,13 +1,9 @@ /* sysdep_netlink.c - Linux netlink glue * - * Copyright (C) 2007-2009 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #include <time.h> diff --git a/nhrp/sysdep_pfpacket.c b/nhrp/sysdep_pfpacket.c index 514b848..527b866 100644 --- a/nhrp/sysdep_pfpacket.c +++ b/nhrp/sysdep_pfpacket.c @@ -1,13 +1,9 @@ /* sysdep_pfpacket.c - Tracing of forwarded packets using PF_PACKET * - * Copyright (C) 2007-2009 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #include <errno.h> @@ -30,8 +26,6 @@ #include "nhrp_interface.h" #include "nhrp_peer.h" -#define MAX_OPCODES 100 - struct multicast_packet { struct nhrp_interface *iface; struct sockaddr_ll lladdr; @@ -61,13 +55,35 @@ enum { struct filter { int pos[NUM_LABELS]; - int numops; - struct sock_filter code[MAX_OPCODES]; + int numops, numalloc; + struct sock_filter *code; }; +static int checkfilter(struct filter *f) +{ + if (f->numops < f->numalloc) + return 1; + + if (f->numalloc < 0) + return 0; + + if (f->numalloc) + f->numalloc *= 2; + else + f->numalloc = 128; + + f->code = realloc(f->code, f->numalloc * sizeof(struct sock_filter)); + if (f->code == NULL) { + f->numalloc = -1; + return 0; + } + + return 1; +} + static void emit_stmt(struct filter *f, __u16 code, __u32 k) { - if (f->numops < MAX_OPCODES) { + if (checkfilter(f)) { f->code[f->numops].code = code; f->code[f->numops].jt = 0; f->code[f->numops].jf = 0; @@ -78,7 +94,7 @@ static void emit_stmt(struct filter *f, __u16 code, __u32 k) static void emit_jump(struct filter *f, __u16 code, __u32 k, __u8 jt, __u8 jf) { - if (f->numops < MAX_OPCODES) { + if (checkfilter(f)) { f->code[f->numops].code = code; f->code[f->numops].jt = jt; f->code[f->numops].jf = jf; @@ -196,8 +212,8 @@ static void install_filter_cb(struct ev_timer *w, int revents) emit_stmt(&f, BPF_RET|BPF_K, 0); /* All ok so far? */ - if (f.numops >= MAX_OPCODES) { - nhrp_error("Filter code buffer too small (code actual length %d)", + if (f.numalloc < 0) { + nhrp_error("Unable to construct filter code: out of memory (code actual length %d)", f.numops); return; } @@ -217,9 +233,11 @@ static void install_filter_cb(struct ev_timer *w, int revents) prog.filter = f.code; if (setsockopt(packet_io.fd, SOL_SOCKET, SO_ATTACH_FILTER, &prog, sizeof(prog))) - return; + nhrp_perror("Failed to install filter code"); + else + nhrp_info("Filter code installed (%d opcodes)", f.numops); - nhrp_info("Filter code installed (%d opcodes)", f.numops); + free(f.code); } int forward_local_addresses_changed(void) diff --git a/nhrp/sysdep_syslog.c b/nhrp/sysdep_syslog.c index c8f9f7e..3004be8 100644 --- a/nhrp/sysdep_syslog.c +++ b/nhrp/sysdep_syslog.c @@ -1,13 +1,9 @@ /* sysdep_syslog.c - Logging via syslog * - * Copyright (C) 2007 Timo Teräs <timo.teras@iki.fi> - * All rights reserved. + * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or later as - * published by the Free Software Foundation. - * - * See http://www.gnu.org/ for details. + * This software is licensed under the MIT License. + * See MIT-LICENSE.txt for additional details. */ #include <errno.h> |