]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Terminology cleanup: The import_control hook is now called preexport.
authorJan Maria Matejka <mq@ucw.cz>
Wed, 14 Feb 2018 12:42:53 +0000 (13:42 +0100)
committerJan Maria Matejka <mq@ucw.cz>
Tue, 4 Dec 2018 09:53:01 +0000 (10:53 +0100)
Once upon a time, far far away, there were the old Bird developers
discussing what direction of route flow shall be called import and
export. They decided to say "import to protocol" and "export to table"
when speaking about a protocol. When speaking about a table, they
spoke about "importing to table" and "exporting to protocol".

The latter terminology was adopted in configuration, then also the
bird CLI in commit ea2ae6dd0 started to use it (in year 2009). Now
it's 2018 and the terminology is the latter. Import is from protocol to
table, export is from table to protocol. Anyway, there was still an
import_control hook which executed right before route export.

One thing is funny. There are two commits in April 1999 with just two
minutes between them. The older announces the final settlement
on config terminology, the newer uses the other definition. Let's see
their commit messages as the git-log tool shows them (the newer first):

    commit 9e0e485e50ea74c4f1c5cb65bdfe6ce819c2cee2
    Author: Martin Mares <mj@ucw.cz>
    Date:   Mon Apr 5 20:17:59 1999 +0000

Added some new protocol hooks (look at the comments for better explanation):

make_tmp_attrs          Convert inline attributes to ea_list
store_tmp_attrs         Convert ea_list to inline attributes
import_control          Pre-import decisions

    commit 5056c559c4eb253a4eee10cf35b694faec5265eb
    Author: Martin Mares <mj@ucw.cz>
    Date:   Mon Apr 5 20:15:31 1999 +0000

Changed syntax of attaching filters to protocols to hopefully the final
version:

EXPORT <filter-spec>    for outbound routes (i.e., those announced
by BIRD to the rest of the world).
IMPORT <filter-spec>    for inbound routes (i.e., those imported
by BIRD from the rest of the world).

where <filter-spec> is one of:

ALL                     pass all routes
NONE                    drop all routes
FILTER <name>           use named filter
FILTER { <filter> }     use explicitly defined filter

For all protocols, the default is IMPORT ALL, EXPORT NONE. This includes
the kernel protocol, so that you need to add EXPORT ALL to get the previous
configuration of kernel syncer (as usually, see doc/bird.conf.example for
a bird.conf example :)).

Let's say RIP to this almost 19-years-old inconsistency. For now, if you
import a route, it is always from protocol to table. If you export a
route, it is always from table to protocol.

And they lived happily ever after.

13 files changed:
nest/proto-hooks.c
nest/protocol.h
nest/route.h
nest/rt-show.c
nest/rt-table.c
proto/babel/babel.c
proto/bgp/attrs.c
proto/bgp/bgp.c
proto/bgp/bgp.h
proto/ospf/ospf.c
proto/pipe/pipe.c
proto/radv/radv.c
sysdep/unix/krt.c

index 71cddd64c64c47e735db2d7c75a0c380d03134d9..bc88b4b4d3a201946995aa7cf22f768252e99905 100644 (file)
@@ -258,16 +258,16 @@ void store_tmp_attrs(rte *e, ea_list *attrs)
 { DUMMY; }
 
 /**
- * import_control - pre-filtering decisions on route import
- * @p: protocol instance the route is going to be imported to
+ * preexport - pre-filtering decisions before route export
+ * @p: protocol instance the route is going to be exported to
  * @e: the route in question
  * @attrs: extended attributes of the route
  * @pool: linear pool for allocation of all temporary data
  *
- * The import_control() hook is called as the first step of a exporting
+ * The preexport() hook is called as the first step of a exporting
  * a route from a routing table to the protocol instance. It can modify
- * route attributes and force acceptance or rejection of the route regardless
- * of user-specified filters. See rte_announce() for a complete description
+ * route attributes and force acceptance or rejection of the route before
+ * the user-specified filters are run. See rte_announce() for a complete description
  * of the route distribution process.
  *
  * The standard use of this hook is to reject routes having originated
@@ -276,7 +276,7 @@ void store_tmp_attrs(rte *e, ea_list *attrs)
  * Result: 1 if the route has to be accepted, -1 if rejected and 0 if it
  * should be passed to the filters.
  */
-int import_control(struct proto *p, rte **e, ea_list **attrs, struct linpool *pool)
+int preexport(struct proto *p, rte **e, ea_list **attrs, struct linpool *pool)
 { DUMMY; }
 
 /**
index 61160c0a49b1af00d6d559447c95ec4eea29e181..3008087bbf5f11b30018d67ab375981f42421822 100644 (file)
@@ -191,12 +191,12 @@ struct proto {
    *      ifa_notify   Notify protocol about interface address changes.
    *      rt_notify    Notify protocol about routing table updates.
    *      neigh_notify Notify protocol about neighbor cache events.
-   *      make_tmp_attrs  Construct ea_list from private attrs stored in rte.
+   *      make_tmp_attrs  Construct ea_list from private attrs stored in rta.
    *      store_tmp_attrs Store private attrs back to rta. The route MUST NOT be cached.
-   *      import_control  Called as the first step of the route importing process.
+   *      preexport  Called as the first step of the route exporting process.
    *                   It can construct a new rte, add private attributes and
-   *                   decide whether the route shall be imported: 1=yes, -1=no,
-   *                   0=process it through the import filter set by the user.
+   *                   decide whether the route shall be exported: 1=yes, -1=no,
+   *                   0=process it through the export filter set by the user.
    *      reload_routes   Request channel to reload all its routes to the core
    *                   (using rte_update()). Returns: 0=reload cannot be done,
    *                   1= reload is scheduled and will happen (asynchronously).
@@ -210,7 +210,7 @@ struct proto {
   void (*neigh_notify)(struct neighbor *neigh);
   struct ea_list *(*make_tmp_attrs)(struct rte *rt, struct linpool *pool);
   void (*store_tmp_attrs)(struct rte *rt);
-  int (*import_control)(struct proto *, struct rte **rt, struct linpool *pool);
+  int (*preexport)(struct proto *, struct rte **rt, struct linpool *pool);
   void (*reload_routes)(struct channel *);
   void (*feed_begin)(struct channel *, int initial);
   void (*feed_end)(struct channel *);
index 60650763883235c630e1cf6d0212a93c13596c07..080bbf583cffe324e81445ce9176992e61df20a4 100644 (file)
@@ -271,7 +271,7 @@ static inline int rte_is_filtered(rte *r) { return !!(r->flags & REF_FILTERED);
 #define RA_ANY         3               /* Announcement of any route change */
 #define RA_MERGED      4               /* Announcement of optimal route merged with next ones */
 
-/* Return value of import_control() callback */
+/* Return value of preexport() callback */
 #define RIC_ACCEPT     1               /* Accepted by protocol */
 #define RIC_PROCESS    0               /* Process it through import filter */
 #define RIC_REJECT     -1              /* Rejected by protocol */
index 90165c57d2d14f9216e6cc676f8c6104a2a44bfc..c7bcdf2f6c98546cfd8705817389920513ff81ac 100644 (file)
@@ -133,7 +133,7 @@ rt_show_net(struct cli *c, net *n, struct rt_show_data *d)
       else if (d->export_mode)
        {
          struct proto *ep = ec->proto;
-         int ic = ep->import_control ? ep->import_control(ep, &e, c->show_pool) : 0;
+         int ic = ep->preexport ? ep->preexport(ep, &e, c->show_pool) : 0;
 
          if (ec->ra_mode == RA_OPTIMAL || ec->ra_mode == RA_MERGED)
            pass = 1;
index e47e03a9b13279c3d18e9cd8e2953c0a6ce0afcf..21b6622e7c99bbe8cd589e9b7629bc0d3ab953bd 100644 (file)
@@ -407,7 +407,7 @@ export_filter_(struct channel *c, rte *rt0, rte **rt_free, linpool *pool, int si
 
   rte_make_tmp_attrs(&rt, pool);
 
-  v = p->import_control ? p->import_control(p, &rt, pool) : 0;
+  v = p->preexport ? p->preexport(p, &rt, pool) : 0;
   if (v < 0)
     {
       if (silent)
@@ -873,7 +873,7 @@ rt_notify_merged(struct channel *c, net *net, rte *new_changed, rte *old_changed
  * routing table @tab) changes In that case @old stores the old route
  * from the same protocol.
  *
- * For each appropriate protocol, we first call its import_control()
+ * For each appropriate protocol, we first call its preexport()
  * hook which performs basic checks on the route (each protocol has a
  * right to veto or force accept of the route before any filter is
  * asked) and adds default values of attributes specific to the new
@@ -1473,7 +1473,7 @@ rt_examine(rtable *t, net_addr *a, struct proto *p, struct filter *filter)
 
   /* Rest is stripped down export_filter() */
   rte_make_tmp_attrs(&rt, rte_update_pool);
-  int v = p->import_control ? p->import_control(p, &rt, rte_update_pool) : 0;
+  int v = p->preexport ? p->preexport(p, &rt, rte_update_pool) : 0;
   if (v == RIC_PROCESS)
     v = (f_run(filter, &rt, rte_update_pool, FF_SILENT) <= F_ACCEPT);
 
index b4e42a9aa167b87d810dfc94d9d263a9a6f8d130..d321f1d82b0380b33dee4c04e1253019b486c23f 100644 (file)
@@ -2104,7 +2104,7 @@ babel_prepare_attrs(struct linpool *pool, ea_list *next, uint metric, u64 router
 
 
 static int
-babel_import_control(struct proto *P, struct rte **new, struct linpool *pool UNUSED)
+babel_preexport(struct proto *P, struct rte **new, struct linpool *pool UNUSED)
 {
   struct rta *a = (*new)->attrs;
 
@@ -2228,7 +2228,7 @@ babel_init(struct proto_config *CF)
 
   P->if_notify = babel_if_notify;
   P->rt_notify = babel_rt_notify;
-  P->import_control = babel_import_control;
+  P->preexport = babel_preexport;
   P->make_tmp_attrs = babel_make_tmp_attrs;
   P->store_tmp_attrs = babel_store_tmp_attrs;
   P->rte_better = babel_rte_better;
index dcc4a27383fac0f5437851b9d14c40545264a6c6..572adff85c436276c87a8b8298d9fa5ca652dfbf 100644 (file)
@@ -1371,7 +1371,7 @@ bgp_free_prefix(struct bgp_channel *c, struct bgp_prefix *px)
  */
 
 int
-bgp_import_control(struct proto *P, rte **new, struct linpool *pool UNUSED)
+bgp_preexport(struct proto *P, rte **new, struct linpool *pool UNUSED)
 {
   rte *e = *new;
   struct proto *SRC = e->attrs->src->proto;
index 7f2eb4d09c19fab7a49d61a3e69d1b69df48a21e..496393ab05969e19f9ac95441aae6acfba99be1a 100644 (file)
@@ -1533,7 +1533,7 @@ bgp_init(struct proto_config *CF)
   struct bgp_config *cf = (struct bgp_config *) CF;
 
   P->rt_notify = bgp_rt_notify;
-  P->import_control = bgp_import_control;
+  P->preexport = bgp_preexport;
   P->neigh_notify = bgp_neigh_notify;
   P->reload_routes = bgp_reload_routes;
   P->feed_begin = bgp_feed_begin;
index 2729780c0654b8e46e0bf9974f674457b02ec8ee..e1ff013a76d8e11e4cff21f87e61ee1d22936b14 100644 (file)
@@ -533,7 +533,7 @@ int bgp_rte_mergable(rte *pri, rte *sec);
 int bgp_rte_recalculate(rtable *table, net *net, rte *new, rte *old, rte *old_best);
 struct rte *bgp_rte_modify_stale(struct rte *r, struct linpool *pool);
 void bgp_rt_notify(struct proto *P, struct channel *C, net *n, rte *new, rte *old);
-int bgp_import_control(struct proto *, struct rte **, struct linpool *);
+int bgp_preexport(struct proto *, struct rte **, struct linpool *);
 int bgp_get_attr(struct eattr *e, byte *buf, int buflen);
 void bgp_get_route_info(struct rte *, byte *buf);
 
index 4faad3609d71d139dc9f86132732fee7dc54049e..dbae585d85bbdbf8e419770ecf24d6d56a118351 100644 (file)
 #include <stdlib.h>
 #include "ospf.h"
 
-static int ospf_import_control(struct proto *P, rte **new, struct linpool *pool);
+static int ospf_preexport(struct proto *P, rte **new, struct linpool *pool);
 static struct ea_list *ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool);
 static void ospf_store_tmp_attrs(struct rte *rt);
 static void ospf_reload_routes(struct channel *C);
@@ -315,7 +315,7 @@ ospf_init(struct proto_config *CF)
   P->rt_notify = ospf_rt_notify;
   P->if_notify = ospf_if_notify;
   P->ifa_notify = cf->ospf2 ? ospf_ifa_notify2 : ospf_ifa_notify3;
-  P->import_control = ospf_import_control;
+  P->preexport = ospf_preexport;
   P->reload_routes = ospf_reload_routes;
   P->make_tmp_attrs = ospf_make_tmp_attrs;
   P->store_tmp_attrs = ospf_store_tmp_attrs;
@@ -434,7 +434,7 @@ ospf_disp(timer * timer)
 
 
 /**
- * ospf_import_control - accept or reject new route from nest's routing table
+ * ospf_preexport - accept or reject new route from nest's routing table
  * @P: OSPF protocol instance
  * @new: the new route
  * @attrs: list of attributes
@@ -444,7 +444,7 @@ ospf_disp(timer * timer)
  * import to the filters.
  */
 static int
-ospf_import_control(struct proto *P, rte **new, struct linpool *pool UNUSED)
+ospf_preexport(struct proto *P, rte **new, struct linpool *pool UNUSED)
 {
   struct ospf_proto *p = (struct ospf_proto *) P;
   struct ospf_area *oa = ospf_main_area(p);
index 82ccf38a38bf55941ecc66dd45c49c126a170e31..efb992cab7315924e59f0016116f39e99085d417 100644 (file)
@@ -98,7 +98,7 @@ pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *o
 }
 
 static int
-pipe_import_control(struct proto *P, rte **ee, struct linpool *p UNUSED)
+pipe_preexport(struct proto *P, rte **ee, struct linpool *p UNUSED)
 {
   struct proto *pp = (*ee)->sender->proto;
 
@@ -179,7 +179,7 @@ pipe_init(struct proto_config *CF)
   struct pipe_config *cf = (void *) CF;
 
   P->rt_notify = pipe_rt_notify;
-  P->import_control = pipe_import_control;
+  P->preexport = pipe_preexport;
   P->reload_routes = pipe_reload_routes;
 
   pipe_configure_channels(p, cf);
index 12d908239524714d10e139e93c53b671a49ee680..990b602494540fbadb8f30632573c612e6494edb 100644 (file)
@@ -28,7 +28,7 @@
  * processes asynchronous events (specified by RA_EV_* codes), and radv_timer(),
  * which triggers sending RAs and computes the next timeout.
  *
- * The RAdv protocol could receive routes (through radv_import_control() and
+ * The RAdv protocol could receive routes (through radv_preexport() and
  * radv_rt_notify()), but only the configured trigger route is tracked (in
  * &active var).  When a radv protocol is reconfigured, the connected routing
  * table is examined (in radv_check_active()) to have proper &active value in
@@ -396,7 +396,7 @@ radv_net_match_trigger(struct radv_config *cf, net *n)
 }
 
 int
-radv_import_control(struct proto *P, rte **new, struct linpool *pool UNUSED)
+radv_preexport(struct proto *P, rte **new, struct linpool *pool UNUSED)
 {
   // struct radv_proto *p = (struct radv_proto *) P;
   struct radv_config *cf = (struct radv_config *) (P->cf);
@@ -580,7 +580,7 @@ radv_init(struct proto_config *CF)
 
   P->main_channel = proto_add_channel(P, proto_cf_main_channel(CF));
 
-  P->import_control = radv_import_control;
+  P->preexport = radv_preexport;
   P->rt_notify = radv_rt_notify;
   P->if_notify = radv_if_notify;
   P->ifa_notify = radv_ifa_notify;
index 794ebcd014b47e3a5890fb7cbdbd12fd720cecd5..ded5dfe4526c2d3193d9a5216e9eb61e27328a24 100644 (file)
@@ -579,7 +579,7 @@ krt_export_net(struct krt_proto *p, net *net, rte **rt_free)
 
   rte_make_tmp_attrs(&rt, krt_filter_lp);
 
-  /* We could run krt_import_control() here, but it is already handled by KRF_INSTALLED */
+  /* We could run krt_preexport() here, but it is already handled by KRF_INSTALLED */
 
   if (filter == FILTER_ACCEPT)
     goto accept;
@@ -940,7 +940,7 @@ krt_store_tmp_attrs(rte *rt)
 }
 
 static int
-krt_import_control(struct proto *P, rte **new, struct linpool *pool UNUSED)
+krt_preexport(struct proto *P, rte **new, struct linpool *pool UNUSED)
 {
   // struct krt_proto *p = (struct krt_proto *) P;
   rte *e = *new;
@@ -1085,7 +1085,7 @@ krt_init(struct proto_config *CF)
 
   p->p.main_channel = proto_add_channel(&p->p, proto_cf_main_channel(CF));
 
-  p->p.import_control = krt_import_control;
+  p->p.preexport = krt_preexport;
   p->p.rt_notify = krt_rt_notify;
   p->p.if_notify = krt_if_notify;
   p->p.reload_routes = krt_reload_routes;