From 9637c7c0acbc56bbf6fedc44d89f921386843992 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 24 Mar 2014 13:33:15 +0100 Subject: [PATCH 01/11] Minor fixes in documentation. --- doc/bird.sgml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/bird.sgml b/doc/bird.sgml index a7f70df5..02773dd4 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -160,7 +160,7 @@ BIRD executable by configuring out routing protocols you don't use, and default is /var/run/bird.ctl. -P - create a PID file with given filename. + create a PID file with given filename. -u drop privileges and use that user ID, see the next section for details. @@ -2683,7 +2683,7 @@ network. This attribute is read-only. Default is Example - +

protocol ospf MyOSPF { rfc1583compat yes; tick 2; From 4e7c974d22ee5d938d8d8e7018f0a63f609d630b Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 24 Mar 2014 19:22:19 +0100 Subject: [PATCH 02/11] Fixes a bug in graceful restart. --- proto/bgp/packets.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index 2d4da8c9..808afaa9 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -1201,7 +1201,7 @@ bgp_do_rx_update(struct bgp_conn *conn, return; /* Check for End-of-RIB marker */ - if ((attr_len < 8) && !withdrawn_len && !attr_len && + if ((attr_len < 8) && !withdrawn_len && !nlri_len && !p->mp_reach_len && (p->mp_unreach_len == 3) && (get_u16(p->mp_unreach_start) == BGP_AF_IPV6)) { bgp_rx_end_mark(p); From 0c3d9dacafdb807d2101c67610969707353f434a Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Tue, 25 Mar 2014 14:58:00 +0100 Subject: [PATCH 03/11] Fixes file descriptor leak when parser ends with error. Thanks to MrBr for the bugreport. --- conf/cf-lex.l | 33 ++++++++++++++++++++++++++++----- conf/conf.c | 1 + conf/conf.h | 2 ++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/conf/cf-lex.l b/conf/cf-lex.l index b1bbeae2..99785057 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -275,9 +275,6 @@ cf_hash(byte *c) * match - these do not have fd and flex buffer yet). * * FIXME: Most of these ifs and include functions are really sysdep/unix. - * - * FIXME: Resources (fd, flex buffers and glob data) in IFS stack - * are not freed when cf_error() is called. */ static struct include_file_stack * @@ -316,13 +313,36 @@ enter_ifs(struct include_file_stack *new) yy_switch_to_buffer(new->buffer); } +/** + * cf_lex_unwind - unwind lexer state during error + * + * cf_lex_unwind() frees the internal state on IFS stack when the lexical + * analyzer is terminated by cf_error(). + */ +void +cf_lex_unwind(void) +{ + struct include_file_stack *n; + + for (n = ifs; n != ifs_head; n = n->prev) + { + /* Memory is freed automatically */ + if (n->buffer) + yy_delete_buffer(n->buffer); + if (n->fd) + close(n->fd); + } + + ifs = ifs_head; +} + static void cf_include(char *arg, int alen) { struct include_file_stack *base_ifs = ifs; int new_depth, rv, i; char *patt; - glob_t g; + glob_t g = {}; new_depth = ifs->depth + 1; if (new_depth > MAX_INCLUDE_DEPTH) @@ -370,7 +390,10 @@ cf_include(char *arg, int alen) struct stat fs; if (stat(fname, &fs) < 0) - cf_error("Unable to stat included file %s: %m", fname); + { + globfree(&g); + cf_error("Unable to stat included file %s: %m", fname); + } if (fs.st_mode & S_IFDIR) continue; diff --git a/conf/conf.c b/conf/conf.c index 67b027ce..a907402d 100644 --- a/conf/conf.c +++ b/conf/conf.c @@ -502,6 +502,7 @@ cf_error(char *msg, ...) new_config->err_msg = cfg_strdup(buf); new_config->err_lino = ifs->lino; new_config->err_file_name = ifs->file_name; + cf_lex_unwind(); longjmp(conf_jmpbuf, 1); } diff --git a/conf/conf.h b/conf/conf.h index a8bba7e8..fa14d7b5 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -139,6 +139,8 @@ extern struct include_file_stack *ifs; int cf_lex(void); void cf_lex_init(int is_cli, struct config *c); +void cf_lex_unwind(void); + struct symbol *cf_find_symbol(byte *c); struct symbol *cf_default_name(char *template, int *counter); struct symbol *cf_define_symbol(struct symbol *symbol, int type, void *def); From d7c0628591b802e202903b63fce53b6a422a3db2 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 31 Mar 2014 00:56:44 +0200 Subject: [PATCH 04/11] Check validity of interface definitions. Thanks to Aleksey Berezin for the bugreport. --- doc/bird.sgml | 37 ++++++++++++++++++++++--------------- nest/config.Y | 14 ++++++++++++++ proto/bfd/config.Y | 2 +- proto/ospf/config.Y | 6 +++++- proto/radv/config.Y | 2 +- proto/rip/config.Y | 2 +- 6 files changed, 44 insertions(+), 19 deletions(-) diff --git a/doc/bird.sgml b/doc/bird.sgml index 02773dd4..f991bad0 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -393,7 +393,7 @@ protocol rip { Set BIRD's router ID based on an IP address of an interface specified by an interface pattern. The option is applicable for IPv4 version only. See section for detailed - description of interface patterns. + description of interface patterns with extended clauses. listen bgp [address This option allows to specify address and port where BGP protocol should @@ -569,23 +569,26 @@ agreement"). given interface-specific options. A set of interfaces specified by one interface option is described using an interface pattern. The interface pattern consists of a sequence of clauses (separated by commas), each - clause may contain a mask, a prefix, or both of them. An interface - matches the clause if its name matches the mask (if specified) and its - address matches the prefix (if specified). Mask is specified as - shell-like pattern. For IPv6, the prefix part of a clause is generally - ignored and interfaces are matched just by their name. + clause is a mask specified as a shell-like pattern. Interfaces are + matched by their name. An interface matches the pattern if it matches any of its clauses. If the clause begins with interface By default, the Direct protocol will generate device routes for all the interfaces available. If you want to restrict it to some subset of - interfaces (for example if you're using multiple routing tables for - policy routing and some of the policy domains don't contain all - interfaces), just use this clause. + interfaces or addresses (e.g. if you're using multiple routing tables + for policy routing and some of the policy domains don't contain all + interfaces), just use this clause. See + common option for detailed description. The Direct protocol uses + extended interface clauses.

Direct device routes don't contain any specific attributes. @@ -2468,9 +2473,11 @@ protocol ospf <name> { interface pattern [instance Defines that the specified interfaces belong to the area being defined. See common option for detailed - description. In OSPFv3, you can specify instance ID for that interface - description, so it is possible to have several instances of that - interface with different options or even in different areas. + description. In OSPFv2, extended interface clauses are used, because + OSPFv2 handles each network prefix as a separate virtual interface. In + OSPFv3, you can specify instance ID for that interface description, so + it is possible to have several instances of that interface with + different options or even in different areas. virtual link id [instance Virtual link to router with the router id. Virtual link acts as a diff --git a/nest/config.Y b/nest/config.Y index 59d354b8..5b544e59 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -24,6 +24,17 @@ static list *this_p_list; static struct password_item *this_p_item; static int password_id; +static void +iface_patt_check(void) +{ + struct iface_patt_node *pn; + + WALK_LIST(pn, this_ipatt->ipn_list) + if (!pn->pattern || pn->pxlen) + cf_error("Interface name/mask expected, not IP prefix"); +} + + static inline void reset_passwords(void) { @@ -272,6 +283,9 @@ iface_patt_list: | iface_patt_list ',' iface_patt_node ; +/* For name/mask-only iface patterns */ +iface_patt_list_nopx: iface_patt_list { iface_patt_check(); } + iface_patt_init: { /* Generic this_ipatt init */ this_ipatt = cfg_allocz(sizeof(struct iface_patt)); diff --git a/proto/bfd/config.Y b/proto/bfd/config.Y index 1bf8764f..67a4983b 100644 --- a/proto/bfd/config.Y +++ b/proto/bfd/config.Y @@ -89,7 +89,7 @@ bfd_iface_opt_list: | '{' bfd_iface_opts '}' ; -bfd_iface: bfd_iface_start iface_patt_list bfd_iface_opt_list +bfd_iface: bfd_iface_start iface_patt_list_nopx bfd_iface_opt_list { add_tail(&BFD_CFG->patt_list, NODE this_ipatt); }; bfd_multihop: bfd_iface_start bfd_iface_opt_list diff --git a/proto/ospf/config.Y b/proto/ospf/config.Y index f894f134..90f289d0 100644 --- a/proto/ospf/config.Y +++ b/proto/ospf/config.Y @@ -386,6 +386,10 @@ ospf_instance_id: | INSTANCE expr { set_instance_id($2); } ; +ospf_iface_patt_list: + iface_patt_list { if (OSPF_VERSION == 3) iface_patt_check(); } ospf_instance_id + ; + ospf_iface_opts: /* empty */ | ospf_iface_opts ospf_iface_item ';' @@ -397,7 +401,7 @@ ospf_iface_opt_list: ; ospf_iface: - ospf_iface_start iface_patt_list ospf_instance_id ospf_iface_opt_list { ospf_iface_finish(); } + ospf_iface_start ospf_iface_patt_list ospf_iface_opt_list { ospf_iface_finish(); } ; opttext: diff --git a/proto/radv/config.Y b/proto/radv/config.Y index ff70a2f7..88a9e298 100644 --- a/proto/radv/config.Y +++ b/proto/radv/config.Y @@ -138,7 +138,7 @@ radv_iface_opt_list: ; radv_iface: - radv_iface_start iface_patt_list radv_iface_opt_list radv_iface_finish; + radv_iface_start iface_patt_list_nopx radv_iface_opt_list radv_iface_finish; radv_prefix_start: prefix diff --git a/proto/rip/config.Y b/proto/rip/config.Y index 791c43a2..76397520 100644 --- a/proto/rip/config.Y +++ b/proto/rip/config.Y @@ -110,7 +110,7 @@ rip_iface_init: } ; -rip_iface: +rip_iface: /* TODO: switch to iface_patt_list_nopx */ rip_iface_init iface_patt_list rip_iface_opt_list ; From 43eb8f610f7796375419dc8d72df7a41c01c82af Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 31 Mar 2014 12:02:20 +0200 Subject: [PATCH 05/11] Removes conflicting definition. This function is a part of Readline interface for a long time (with a different type). --- client/birdc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/client/birdc.c b/client/birdc.c index bbe18331..6d4c86a9 100644 --- a/client/birdc.c +++ b/client/birdc.c @@ -29,7 +29,6 @@ static int prompt_active; /* HACK: libreadline internals we need to access */ extern int _rl_vis_botlin; extern void _rl_move_vert(int); -extern Function *rl_last_func; static void add_history_dedup(char *cmd) From eb5ea6bdd6fa45f03425ea38b8d1b16fd5ff7469 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 31 Mar 2014 13:21:13 +0200 Subject: [PATCH 06/11] Fixes build on some old systems. --- sysdep/linux/sysio.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sysdep/linux/sysio.h b/sysdep/linux/sysio.h index 56c3387d..dc807392 100644 --- a/sysdep/linux/sysio.h +++ b/sysdep/linux/sysio.h @@ -122,6 +122,8 @@ sysio_leave_group(sock *s, ip_addr maddr) #define TCP_MD5SIG 14 #define TCP_MD5SIG_MAXKEYLEN 80 +#include + struct tcp_md5sig { struct sockaddr_storage tcpm_addr; /* address associated */ __u16 __tcpm_pad1; /* zero */ From d96ec7f6e0d26546d9a27064fd13591618258894 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 31 Mar 2014 18:51:16 +0200 Subject: [PATCH 07/11] Updates BFD documentation. --- doc/bird.sgml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/bird.sgml b/doc/bird.sgml index f991bad0..07e75588 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -1378,6 +1378,11 @@ RFC 5882. development, expect some rough edges and possible UI and configuration changes in the future. Also note that we currently support at most one protocol instance. +

BFD packets are sent with a dynamic source port number. Linux systems use by +default a bit different dynamic port range than the IANA approved one +(49152-65535). If you experience problems with compatibility, please adjust +/proc/sys/net/ipv4/ip_local_port_range + Configuration

BFD configuration consists mainly of multiple definitions of interfaces. From 60442b1698563ebc5837454d89dbe4afa037882d Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 31 Mar 2014 18:51:51 +0200 Subject: [PATCH 08/11] NEWS and version update. --- NEWS | 8 ++++++++ misc/bird.spec | 2 +- sysdep/config.h | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 4e3349c3..0d84b2fc 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +Version 1.4.1 (2014-03-31) + o BGP add-path support (RFC draft). + o BGP graceful restart (RFC 4724). + o OSPF: many changes in socket layer. + o OSPF: support for secondary addresses in BSD. + o OSPF: names for vlink pseudointerfaces (vlinkX). + o Several bugfixes. + Version 1.4.0 (2013-11-25) o BFD protocol (RFC 5880). o BFD support for OSPF and BGP. diff --git a/misc/bird.spec b/misc/bird.spec index 162dac55..434e8be0 100644 --- a/misc/bird.spec +++ b/misc/bird.spec @@ -1,6 +1,6 @@ Summary: BIRD Internet Routing Daemon Name: bird -Version: 1.4.0 +Version: 1.4.1 Release: 1 Copyright: GPL Group: Networking/Daemons diff --git a/sysdep/config.h b/sysdep/config.h index eb5606ac..399dba6e 100644 --- a/sysdep/config.h +++ b/sysdep/config.h @@ -7,7 +7,7 @@ #define _BIRD_CONFIG_H_ /* BIRD version */ -#define BIRD_VERSION "1.4.0" +#define BIRD_VERSION "1.4.1" /* Include parameters determined by configure script */ #include "sysdep/autoconf.h" From 864f52a5f4c47ac8dc44a8808beb7f038cbf9899 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Wed, 2 Apr 2014 19:58:23 +0200 Subject: [PATCH 09/11] Fixes nasty bug in BFD. When a BFD session is removed while being scheduled for notification, the session stays in notify list and is removed twice, which leads to a strange crash after a while. --- proto/bfd/bfd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/proto/bfd/bfd.c b/proto/bfd/bfd.c index 315d132b..7bbe8c21 100644 --- a/proto/bfd/bfd.c +++ b/proto/bfd/bfd.c @@ -477,8 +477,15 @@ bfd_remove_session(struct bfd_proto *p, struct bfd_session *s) { ip_addr ip = s->addr; + /* Caller should ensure that request list is empty */ + birdloop_enter(p->loop); + /* Remove session from notify list if scheduled for notification */ + /* No need for bfd_lock_sessions(), we are already protected by birdloop_enter() */ + if (NODE_VALID(&s->n)) + rem_node(&s->n); + bfd_free_iface(s->ifa); rfree(s->tx_timer); From 2750b2484f256686a38ef6b89db7e2afe9b7999a Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Wed, 2 Apr 2014 20:09:37 +0200 Subject: [PATCH 10/11] Fixes missing line in BFD context help. --- proto/bfd/config.Y | 1 + 1 file changed, 1 insertion(+) diff --git a/proto/bfd/config.Y b/proto/bfd/config.Y index 67a4983b..948079df 100644 --- a/proto/bfd/config.Y +++ b/proto/bfd/config.Y @@ -130,6 +130,7 @@ bfd_neighbor: ipa bfd_neigh_iface bfd_neigh_local bfd_neigh_multihop }; +CF_CLI_HELP(SHOW BFD, ..., [[Show information about BFD protocol]]); CF_CLI(SHOW BFD SESSIONS, optsym, [], [[Show information about BFD sessions]]) { bfd_show_sessions(proto_get_named($4, &proto_bfd)); }; From 538fec7b1b7dd729eadf1c933e27f59080cd3576 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Wed, 2 Apr 2014 23:00:10 +0200 Subject: [PATCH 11/11] NEWS and version update. --- NEWS | 3 +++ misc/bird.spec | 2 +- sysdep/config.h | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 0d84b2fc..614cc7e4 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +Version 1.4.2 (2014-04-02) + o Important bugfix in BFD. + Version 1.4.1 (2014-03-31) o BGP add-path support (RFC draft). o BGP graceful restart (RFC 4724). diff --git a/misc/bird.spec b/misc/bird.spec index 434e8be0..69f2dc78 100644 --- a/misc/bird.spec +++ b/misc/bird.spec @@ -1,6 +1,6 @@ Summary: BIRD Internet Routing Daemon Name: bird -Version: 1.4.1 +Version: 1.4.2 Release: 1 Copyright: GPL Group: Networking/Daemons diff --git a/sysdep/config.h b/sysdep/config.h index 399dba6e..b4aa7528 100644 --- a/sysdep/config.h +++ b/sysdep/config.h @@ -7,7 +7,7 @@ #define _BIRD_CONFIG_H_ /* BIRD version */ -#define BIRD_VERSION "1.4.1" +#define BIRD_VERSION "1.4.2" /* Include parameters determined by configure script */ #include "sysdep/autoconf.h"