From: Ondrej Zajicek Date: Fri, 22 Nov 2013 01:43:41 +0000 (+0100) Subject: Merge commit 'origin/bfd' X-Git-Tag: v1.4.0~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0aeac9cb7f9887374ce0258c8653f9518529bf08;p=thirdparty%2Fbird.git Merge commit 'origin/bfd' --- 0aeac9cb7f9887374ce0258c8653f9518529bf08 diff --cc doc/bird.sgml index 638900310,3bc0e4538..46d2e026f --- a/doc/bird.sgml +++ b/doc/bird.sgml @@@ -144,7 -144,7 +144,10 @@@ options. The most important ones are nonzero if there are some errors. -s -- use given filename for a socket for communications with the client, default is /var/run/bird.ctl. ++ use given filename for a socket for communications with the client, default is /var/run/bird.ctl. ++ ++ -P ++ create a PID file with given filename. -u drop privileges and use that user ID, see the next section for details. @@@ -915,62 -912,56 +918,63 @@@ bird incompatible with each other (that is to prevent you from shooting in the foot). -- .mask(num) -- on values of type ip. It masks out all but first num bits from the IP -- address. So ipaddress/pxlen, or ++ .mask(num) on values of type ip. It masks out ++ all but first num bits from the IP address. So ++ ipaddress/pxlen, or ipaddress/netmask. There are two special -- operators on prefixes: -- 1.2.0.0/16.pxlen = 16 is true. -- -- (, where 1.2.0.0/16.pxlen = 16 is true. ++ ++ (, ++ where int set look like -- [ 1, 2, 5..7 ]. As you can see, both simple values and ranges are permitted in -- sets. ++ int set look like [ ++ 1, 2, 5..7 ]. As you can see, both simple values and ranges are ++ permitted in sets. For pair sets, expressions like kind != m2->kind) || (m1->val != m2->val)) return 1; - m1 = m1->next; - m2 = m2->next; - } -} - -u32 f_eval_asn(struct f_inst *expr); - static void - pm_format(struct f_path_mask *p, byte *buf, unsigned int size) + pm_format(struct f_path_mask *p, buffer *buf) { - byte *end = buf + size - 16; + buffer_puts(buf, "[= "); while (p) + { + switch(p->kind) { - if (buf > end) - { - strcpy(buf, " ..."); - return; - } - - switch(p->kind) - { - case PM_ASN: - buf += bsprintf(buf, " %u", p->val); - break; - - case PM_QUESTION: - buf += bsprintf(buf, " ?"); - break; + case PM_ASN: + buffer_print(buf, "%u ", p->val); + break; - case PM_ASTERISK: - buf += bsprintf(buf, " *"); - break; + case PM_QUESTION: + buffer_puts(buf, "? "); + break; - case PM_ASN_EXPR: - buf += bsprintf(buf, " %u", f_eval_asn((struct f_inst *) p->val)); - break; - } + case PM_ASTERISK: + buffer_puts(buf, "* "); + break; - p = p->next; + case PM_ASN_EXPR: + buffer_print(buf, "%u ", f_eval_asn((struct f_inst *) p->val)); + break; } - *buf = 0; + p = p->next; + } + + buffer_puts(buf, "=]"); } -static inline int int_cmp(int i1, int i2) +static inline int +int_cmp(int i1, int i2) { - if (i1 == i2) return 0; - if (i1 < i2) return -1; - else return 1; + return (i1 > i2) - (i1 < i2); } -static inline int uint_cmp(uint i1, uint i2) +static inline int - uint_cmp(unsigned int i1, unsigned int i2) ++uint_cmp(uint i1, uint i2) { - if (i1 == i2) return 0; - if (i1 < i2) return -1; - else return 1; + return (int)(i1 > i2) - (int)(i1 < i2); } -static inline int u64_cmp(u64 i1, u64 i2) +static inline int +u64_cmp(u64 i1, u64 i2) { - if (i1 == i2) return 0; - if (i1 < i2) return -1; - else return 1; + return (int)(i1 > i2) - (int)(i1 < i2); } /** diff --cc filter/filter.h index 5570a8a32,0cef9f36e..07a4c9e47 --- a/filter/filter.h +++ b/filter/filter.h @@@ -116,9 -117,10 +117,10 @@@ int filter_same(struct filter *new, str int i_same(struct f_inst *f1, struct f_inst *f2); int val_compare(struct f_val v1, struct f_val v2); -int tree_compare(const void *p1, const void *p2); +int val_same(struct f_val v1, struct f_val v2); - void val_print(struct f_val v); + void val_format(struct f_val v, buffer *buf); + #define F_NOP 0 #define F_NONL 1 diff --cc filter/trie.c index f42afb848,52b1ed47d..217d72c3d --- a/filter/trie.c +++ b/filter/trie.c @@@ -281,21 -278,24 +278,24 @@@ trie_node_format(struct f_trie_node *t } /** - * trie_print - * @t: trie to be printed + * trie_format + * @t: trie to be formatted + * @buf: destination buffer * - * Prints the trie to the log buffer. + * Prints the trie to the supplied buffer. */ void - trie_print(struct f_trie *t) + trie_format(struct f_trie *t, buffer *buf) { - char *sep = ""; - logn("["); + buffer_puts(buf, "["); + if (t->zero) - { - logn("%I/%d", IPA_NONE, 0); - sep = ", "; - } - trie_node_print(&t->root, &sep); - logn("]"); - buffer_print(buf, "0.0.0.0/0, "); ++ buffer_print(buf, "%I/%d", IPA_NONE, 0); + trie_node_format(&t->root, buf); + + /* Undo last separator */ + if (buf->pos[-1] != '[') + buf->pos -= 2; + + buffer_puts(buf, "]"); } diff --cc lib/birdlib.h index 7e6e85267,a54249589..b7a5a6a63 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@@ -34,12 -37,7 +37,13 @@@ #define NULL ((void *) 0) #endif +#ifndef IPV6 +#define IP_VERSION 4 +#else +#define IP_VERSION 6 +#endif + + /* Macros for gcc attributes */ #define NORET __attribute__((noreturn)) diff --cc proto/bgp/config.Y index f4b2c5fe6,0292c2345..185b1bda5 --- a/proto/bgp/config.Y +++ b/proto/bgp/config.Y @@@ -26,7 -26,7 +26,7 @@@ CF_KEYWORDS(BGP, LOCAL, NEIGHBOR, AS, H PREFER, OLDER, MISSING, LLADDR, DROP, IGNORE, ROUTE, REFRESH, INTERPRET, COMMUNITIES, BGP_ORIGINATOR_ID, BGP_CLUSTER_LIST, IGP, TABLE, GATEWAY, DIRECT, RECURSIVE, MED, TTL, SECURITY, DETERMINISTIC, - SECONDARY, ALLOW) - SECONDARY, BFD) ++ SECONDARY, ALLOW, BFD) CF_GRAMMAR @@@ -108,10 -108,9 +108,11 @@@ bgp_proto | bgp_proto PASSIVE bool ';' { BGP_CFG->passive = $3; } | bgp_proto INTERPRET COMMUNITIES bool ';' { BGP_CFG->interpret_communities = $4; } | bgp_proto SECONDARY bool ';' { BGP_CFG->secondary = $3; } + | bgp_proto ALLOW LOCAL AS ';' { BGP_CFG->allow_local_as = -1; } + | bgp_proto ALLOW LOCAL AS expr ';' { BGP_CFG->allow_local_as = $5; } | bgp_proto IGP TABLE rtable ';' { BGP_CFG->igp_table = $4; } | bgp_proto TTL SECURITY bool ';' { BGP_CFG->ttl_security = $4; } + | bgp_proto BFD bool ';' { BGP_CFG->bfd = $3; cf_check_bfd($3); } ; CF_ADDTO(dynamic_attr, BGP_ORIGIN diff --cc proto/ospf/hello.c index 68c345f4d,bac2a5891..b6b110045 --- a/proto/ospf/hello.c +++ b/proto/ospf/hello.c @@@ -151,15 -140,10 +151,18 @@@ ospf_hello_receive(struct ospf_packet * #ifdef OSPFv3 n->iface_id = ntohl(ps->iface_id); #endif + + if (n->ifa->cf->bfd) + ospf_neigh_update_bfd(n, n->ifa->bfd); } +#ifdef OSPFv3 /* NOTE: this could also be relevant for OSPFv2 on PtP ifaces */ + else if (!ipa_equal(faddr, n->ip)) + { + OSPF_TRACE(D_EVENTS, "Neighbor address changed from %I to %I", n->ip, faddr); + n->ip = faddr; + } +#endif + ospf_neigh_sm(n, INM_HELLOREC); pnrid = (u32 *) ((struct ospf_hello_packet *) (ps + 1)); diff --cc sysdep/unix/main.c index 165dab2b1,ecf67b653..7a9458262 --- a/sysdep/unix/main.c +++ b/sysdep/unix/main.c @@@ -796,10 -734,10 +797,12 @@@ main(int argc, char **argv dup2(0, 2); } + write_pid_file(); + signal_init(); + config_commit(conf, RECONFIG_HARD, 0); + #ifdef LOCAL_DEBUG async_dump_flag = 1; #endif