summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2014-03-31 00:56:44 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2014-03-31 01:52:28 +0200
commitd7c0628591b802e202903b63fce53b6a422a3db2 (patch)
tree2202050e07a73c435785565b6e74e0116f8fad39
parent0c3d9dacafdb807d2101c67610969707353f434a (diff)
Check validity of interface definitions.
Thanks to Aleksey Berezin for the bugreport.
-rw-r--r--doc/bird.sgml37
-rw-r--r--nest/config.Y14
-rw-r--r--proto/bfd/config.Y2
-rw-r--r--proto/ospf/config.Y6
-rw-r--r--proto/radv/config.Y2
-rw-r--r--proto/rip/config.Y2
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 <ref id="dsc-iface" name="interface"> section for detailed
- description of interface patterns.
+ description of interface patterns with extended clauses.
<tag>listen bgp [address <m/address/] [port <m/port/] [dual]</tag>
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 <cf/-/, matching interfaces are excluded. Patterns
- are parsed left-to-right, thus <cf/interface "eth0", -"eth*", "*";/
+ are processed left-to-right, thus <cf/interface "eth0", -"eth*", "*";/
means eth0 and all non-ethernets.
+ Some protocols (namely OSPFv2 and Direct) support extended clauses that
+ may contain a mask, a prefix, or both of them. An interface matches such
+ clause if its name matches the mask (if specified) and its address
+ matches the prefix (if specified). Extended clauses are used when the
+ protocol handles multiple addresses on an interface independently.
+
An interface option can be used more times with different interface-specific
options, in that case for given interface the first matching interface
option is used.
- This option is allowed in Direct, OSPF, RIP and RAdv protocols, but in
- OSPF protocol it is used in <cf/area/ subsection.
+ This option is allowed in BFD, Direct, OSPF, RAdv and RIP protocols, but
+ in OSPF protocol it is used in the <cf/area/ subsection.
Default: none.
@@ -2094,9 +2097,11 @@ on Linux systems BIRD cannot change non-BIRD route in the kernel routing table.
<tag>interface <m/pattern [, ...]/</tag>
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 <ref id="dsc-iface" name="interface">
+ common option for detailed description. The Direct protocol uses
+ extended interface clauses.
</descrip>
<p>Direct device routes don't contain any specific attributes.
@@ -2468,9 +2473,11 @@ protocol ospf &lt;name&gt; {
<tag>interface <M>pattern</M> [instance <m/num/]</tag>
Defines that the specified interfaces belong to the area being defined.
See <ref id="dsc-iface" name="interface"> 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.
<tag>virtual link <M>id</M> [instance <m/num/]</tag>
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
;