]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Merge commit 'origin/bfd'
authorOndrej Zajicek <santiago@crfreenet.org>
Fri, 22 Nov 2013 01:43:41 +0000 (02:43 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Fri, 22 Nov 2013 01:48:44 +0000 (02:48 +0100)
14 files changed:
1  2 
doc/bird.sgml
filter/filter.c
filter/filter.h
filter/test.conf
filter/tree.c
filter/trie.c
lib/birdlib.h
nest/proto.c
proto/bgp/bgp.h
proto/bgp/config.Y
proto/ospf/config.Y
proto/ospf/hello.c
sysdep/unix/io.c
sysdep/unix/main.c

diff --cc doc/bird.sgml
index 638900310574c79f0865a51746089fed9649423f,3bc0e4538876ee53fbc0b1ac569a56ac3a497e55..46d2e026fa566e03100fca56771e4ab185a1fcc1
@@@ -144,7 -144,7 +144,10 @@@ options. The most important ones are
        nonzero if there are some errors.
  
        <tag>-s <m/name of communication socket/</tag>
--      use given filename for a  socket for communications with the client, default is <it/prefix/<file>/var/run/bird.ctl</file>.
++      use given filename for a socket for communications with the client, default is <it/prefix/<file>/var/run/bird.ctl</file>.
++
++      <tag>-P <m/name of PID file/</tag>
++      create a PID file with given filename</file>.
  
        <tag>-u <m/user/</tag>
        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).
  
  <descrip>
--      <tag/bool/ This is a boolean type, it can have only two values, <cf/true/ and
--        <cf/false/. Boolean is the only type you can use in <cf/if/
--        statements.
--
--      <tag/int/ This is a general integer type, you can expect it to store signed values from -2000000000
--        to +2000000000. Overflows are not checked. You can use <cf/0x1234/ syntax to write hexadecimal values.
--
--      <tag/pair/ This is a pair of two short integers. Each component can have values from 0 to
--        65535. Literals of this type are written as <cf/(1234,5678)/. The same syntax can also be
--        used to construct a pair from two arbitrary integer expressions (for example <cf/(1+2,a)/).
--
--      <tag/quad/ This is a dotted quad of numbers used to represent
--        router IDs (and others).  Each component can have a value
--        from 0 to 255. Literals of this type are written like IPv4
--        addresses.
--
-       <tag/string/ This is a string of characters. There are no ways
-         to modify strings in filters. You can pass them between
-         functions, assign them to variables of type <cf/string/,
-         print such variables, use standard string comparison
-         operations (e.g. <cf/=, !=, &lt;, &gt;, &lt;=, &gt;=/), but
-         you can't concatenate two strings. String literals are
-         written as <cf/"This is a string constant"/. Additionaly
-         matching <cf/&tilde;/ operator could be used to match a
-         string value against a shell pattern (represented also as a
-         string).
 -      <tag/string/ This is a string of characters. There are no ways to modify strings in
 -        filters. You can pass them between functions, assign them to variables of type <cf/string/, print
 -        such variables, but you can't concatenate two strings. String literals
 -        are written as <cf/"This is a string constant"/.
--
--      <tag/ip/ This type can hold a single IP address. Depending on the compile-time configuration of BIRD you are using, it
--        is either an IPv4 or IPv6 address. IP addresses are written in the standard notation (<cf/10.20.30.40/ or <cf/fec0:3:4::1/). You can apply special operator <cf>.mask(<M>num</M>)</cf>
--        on values of type ip. It masks out all but first <cf><M>num</M></cf> bits from the IP
--        address. So <cf/1.2.3.4.mask(8) = 1.0.0.0/ is true.
--
--      <tag/prefix/ This type can hold a network prefix consisting of IP address and prefix length. Prefix literals are written as
--        <cf><M>ipaddress</M>/<M>pxlen</M></cf>, or
++      <tag/bool/ This is a boolean type, it can have only two values,
++        <cf/true/ and <cf/false/. Boolean is the only type you can use in
++        <cf/if/ statements.
++
++      <tag/int/ This is a general integer type, you can expect it to store
++        signed values from -2000000000 to +2000000000. Overflows are not
++        checked. You can use <cf/0x1234/ syntax to write hexadecimal values.
++
++      <tag/pair/ This is a pair of two short integers. Each component can have
++        values from 0 to 65535. Literals of this type are written as
++        <cf/(1234,5678)/. The same syntax can also be used to construct a pair
++        from two arbitrary integer expressions (for example <cf/(1+2,a)/).
++
++      <tag/quad/ This is a dotted quad of numbers used to represent router IDs
++        (and others).  Each component can have a value from 0 to 255. Literals
++        of this type are written like IPv4 addresses.
++
++      <tag/string/ This is a string of characters. There are no ways to modify
++        strings in filters. You can pass them between functions, assign them
++        to variables of type <cf/string/, print such variables, use standard
++        string comparison operations (e.g. <cf/=, !=, &lt;, &gt;, &lt;=,
++        &gt;=/), but you can't concatenate two strings. String literals are
++        written as <cf/"This is a string constant"/. Additionaly matching
++        <cf/&tilde;/ operator could be used to match a string value against a
++        shell pattern (represented also as a string).
++
++      <tag/ip/ This type can hold a single IP address. Depending on the
++        compile-time configuration of BIRD you are using, it is either an IPv4
++        or IPv6 address. IP addresses are written in the standard notation
++        (<cf/10.20.30.40/ or <cf/fec0:3:4::1/). You can apply special
++        operator <cf>.mask(<M>num</M>)</cf> on values of type ip. It masks out
++        all but first <cf><M>num</M></cf> bits from the IP address. So
++        <cf/1.2.3.4.mask(8) = 1.0.0.0/ is true.
++
++      <tag/prefix/ This type can hold a network prefix consisting of IP
++        address and prefix length. Prefix literals are written
++        as <cf><M>ipaddress</M>/<M>pxlen</M></cf>, or
          <cf><m>ipaddress</m>/<m>netmask</m></cf>. There are two special
--        operators on prefixes:
--        <cf/.ip/ which extracts the IP address from the pair, and <cf/.len/, which separates prefix
--        length from the pair. So <cf>1.2.0.0/16.pxlen = 16</cf> is true.
--
--      <tag/ec/ This is a specialized type used to represent BGP
--        extended community values. It is essentially a 64bit value,
--        literals of this type are usually written as <cf>(<m/kind/,
--        <m/key/, <m/value/)</cf>, where <cf/kind/ is a kind of
--        extended community (e.g. <cf/rt/ / <cf/ro/ for a route
--        target / route origin communities), the format and possible
--        values of <cf/key/ and <cf/value/ are usually integers, but
++        operators on prefixes: <cf/.ip/ which extracts the IP address from the
++        pair, and <cf/.len/, which separates prefix length from the
++        pair. So <cf>1.2.0.0/16.pxlen = 16</cf> is true.
++
++      <tag/ec/ This is a specialized type used to represent BGP extended
++        community values. It is essentially a 64bit value, literals of this
++        type are usually written as <cf>(<m/kind/, <m/key/, <m/value/)</cf>,
++        where <cf/kind/ is a kind of extended community (e.g. <cf/rt/ /
++        <cf/ro/ for a route target / route origin communities), the format and
++        possible values of <cf/key/ and <cf/value/ are usually integers, but
          it depends on the used kind. Similarly to pairs, ECs can be
--        constructed using expressions for <cf/key/ and
--        <cf/value/ parts, (e.g. <cf/(ro, myas, 3*10)/, where
--        <cf/myas/ is an integer variable).
++        constructed using expressions for <cf/key/ and <cf/value/ parts,
++        (e.g. <cf/(ro, myas, 3*10)/, where <cf/myas/ is an integer variable).
   
--      <tag/int|pair|quad|ip|prefix|ec|enum set/
--        Filters recognize four types of sets. Sets are similar to strings: you can pass them around
--        but you can't modify them. Literals of type <cf>int set</cf> look like <cf>
--        [ 1, 2, 5..7 ]</cf>. As you can see, both simple values and ranges are permitted in
--        sets.
++      <tag/int|pair|quad|ip|prefix|ec|enum set/ Filters recognize four types
++        of sets. Sets are similar to strings: you can pass them around but you
++        can't modify them. Literals of type <cf>int set</cf> look like <cf> [
++        1, 2, 5..7 ]</cf>. As you can see, both simple values and ranges are
++        permitted in sets.
  
          For pair sets, expressions like <cf/(123,*)/ can be used to denote ranges (in
          that case <cf/(123,0)..(123,65535)/). You can also use <cf/(123,5..100)/ for range
diff --cc filter/filter.c
index a28de5df590085b4342c57e210be311162939b94,ff4000e83d7e031f3d64d37bb7e53c8b47d374f6..e0451aa157d6b98d1e6e82480d6ca8ff46b84199
@@@ -58,60 -58,73 +58,54 @@@ adata_empty(struct linpool *pool, int l
    return res;
  }
  
 -static int
 -pm_path_compare(struct f_path_mask *m1, struct f_path_mask *m2)
 -{
 -  while (1) {
 -    if ((!m1) || (!m2))
 -      return !((!m1) && (!m2));
 -
 -    /* FIXME: buggy, should return -1, 0, 1; but it doesn't matter */
 -    if ((m1->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 5570a8a32de43f74c04238aec2463a871d8edddf,0cef9f36e5aa7ec6257010028dd3563e509dab53..07a4c9e47ad3d5967ee291bf1463b09baaa480eb
@@@ -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
Simple merge
diff --cc filter/tree.c
Simple merge
diff --cc filter/trie.c
index f42afb84871a5aa882c2bf3539b5ef033a6a3ecc,52b1ed47d953ebc046915aa32b7ef831d616b814..217d72c3d749a4b9c99f75dbfe93c9dd00a77b42
@@@ -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 7e6e85267bf49f8caaad7404f1f48c3899677960,a542495899a4c11188f70fe2e2b753db9f5f3db3..b7a5a6a6352fcb48e9a53edb632e1cfaae4715a0
  #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 nest/proto.c
Simple merge
diff --cc proto/bgp/bgp.h
Simple merge
index f4b2c5fe67fb61b5bee994ecd44534e7349aa308,0292c234536f8046a495cb5f5bccc4209970a7d3..185b1bda5189d3445f98c3f653c1ce3a70b43d9d
@@@ -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
Simple merge
index 68c345f4dd85ecce3570a714eb32ffc2431cfb85,bac2a58912e179d2ca4e720b44138b876dfabf52..b6b1100453443d8dd87dc7c879537bc143f2f540
@@@ -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));
Simple merge
index 165dab2b10467d55e31dd8c76c176b6e2992f364,ecf67b6539925aeaa9da7a4c55e0c48b70b338a7..7a945826298997d3c1050511326c6264c1e9e18a
@@@ -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