]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Implements show route noexport option.
authorOndrej Zajicek <santiago@crfreenet.org>
Thu, 2 Oct 2014 10:46:26 +0000 (12:46 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Thu, 2 Oct 2014 10:52:50 +0000 (12:52 +0200)
Shows routes that would be exported to the protocol but are rejected by
the export filter.

doc/bird.sgml
nest/config.Y
nest/route.h
nest/rt-table.c

index 8f2e69351817b7e495214c8f5676f53030a1d110..97d22625c1d4fddcb6dc9528faf6899e154b4aaa 100644 (file)
@@ -735,7 +735,7 @@ This argument can be omitted if there exists only a single instance.
        Show the list of symbols defined in the configuration (names of
        protocols, routing tables etc.).
 
-       <tag>show route [[for] <m/prefix/|<m/IP/] [table <m/sym/] [filter <m/f/|where <m/c/] [(export|preexport) <m/p/] [protocol <m/p/] [<m/options/]</tag>
+       <tag>show route [[for] <m/prefix/|<m/IP/] [table <m/sym/] [filter <m/f/|where <m/c/] [(export|preexport|noexport) <m/p/] [protocol <m/p/] [<m/options/]</tag>
        Show contents of a routing table (by default of the main one or the
        table attached to a respective protocol), that is routes, their metrics
        and (in case the <cf/all/ switch is given) all their attributes.
@@ -750,9 +750,14 @@ This argument can be omitted if there exists only a single instance.
        <p>You can also ask for printing only routes processed and accepted by
        a given filter (<cf>filter <m/name/</cf> or <cf>filter { <m/filter/ }
        </cf> or matching a given condition (<cf>where <m/condition/</cf>).
-       The <cf/export/ and <cf/preexport/ switches ask for printing of entries
-       that are exported to the specified protocol. With <cf/preexport/, the
-       export filter of the protocol is skipped.
+
+       The <cf/export/, <cf/preexport/ and <cf/noexport/ switches ask for
+       printing of routes that are exported to the specified protocol.
+       With <cf/preexport/, the export filter of the protocol is skipped.
+       With <cf/noexport/, routes rejected by the export filter are printed
+       instead. Note that routes not exported to the protocol for other reasons
+       (e.g. secondary routes or routes imported from that protocol) are not
+       printed even with <cf/noexport/.
 
        <p>You can also select just routes added by a specific protocol.
        <cf>protocol <m/p/</cf>.
index eef7422cd71cb6871b521f43ae0dc573abcec5c7..59a776bfdd275f5a40cf4de6820c723c98527b00 100644 (file)
@@ -57,10 +57,10 @@ CF_KEYWORDS(ROUTER, ID, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OF
 CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS)
 CF_KEYWORDS(RECEIVE, LIMIT, ACTION, WARN, BLOCK, RESTART, DISABLE, KEEP, FILTERED)
 CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
-CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS, PREEXPORT, GENERATE, ROA, MAX, FLUSH, AS)
+CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS, PREEXPORT, NOEXPORT, GENERATE, ROA)
 CF_KEYWORDS(LISTEN, BGP, V6ONLY, DUAL, ADDRESS, PORT, PASSWORDS, DESCRIPTION, SORTED)
 CF_KEYWORDS(RELOAD, IN, OUT, MRTDUMP, MESSAGES, RESTRICT, MEMORY, IGP_METRIC, CLASS, DSCP)
-CF_KEYWORDS(GRACEFUL, RESTART, WAIT)
+CF_KEYWORDS(GRACEFUL, RESTART, WAIT, MAX, FLUSH, AS)
 
 CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
        RIP, OSPF, OSPF_IA, OSPF_EXT1, OSPF_EXT2, BGP, PIPE)
@@ -77,7 +77,7 @@ CF_ENUM(T_ENUM_ROA, ROA_, UNKNOWN, VALID, INVALID)
 %type <ro> roa_args
 %type <rot> roa_table_arg
 %type <sd> sym_args
-%type <i> proto_start echo_mask echo_size debug_mask debug_list debug_flag mrtdump_mask mrtdump_list mrtdump_flag export_or_preexport roa_mode limit_action tab_sorted tos
+%type <i> proto_start echo_mask echo_size debug_mask debug_list debug_flag mrtdump_mask mrtdump_list mrtdump_flag export_mode roa_mode limit_action tab_sorted tos
 %type <ps> proto_patt proto_patt2
 %type <g> limit_spec
 
@@ -443,7 +443,7 @@ CF_CLI(SHOW INTERFACES SUMMARY,,, [[Show summary of network interfaces]])
 { if_show_summary(); } ;
 
 CF_CLI_HELP(SHOW ROUTE, ..., [[Show routing table]])
-CF_CLI(SHOW ROUTE, r_args, [[[<prefix>|for <prefix>|for <ip>] [table <t>] [filter <f>|where <cond>] [all] [primary] [filtered] [(export|preexport) <p>] [protocol <p>] [stats|count]]], [[Show routing table]])
+CF_CLI(SHOW ROUTE, r_args, [[[<prefix>|for <prefix>|for <ip>] [table <t>] [filter <f>|where <cond>] [all] [primary] [filtered] [(export|preexport|noexport) <p>] [protocol <p>] [stats|count]]], [[Show routing table]])
 { rt_show($3); } ;
 
 r_args:
@@ -492,7 +492,7 @@ r_args:
      $$ = $1;
      $$->filtered = 1;
    }
- | r_args export_or_preexport SYM {
+ | r_args export_mode SYM {
      struct proto_config *c = (struct proto_config *) $3->def;
      $$ = $1;
      if ($$->export_mode) cf_error("Protocol specified twice");
@@ -519,9 +519,10 @@ r_args:
    }
  ;
 
-export_or_preexport:
-   PREEXPORT { $$ = 1; }
- | EXPORT { $$ = 2; }
+export_mode:
+   PREEXPORT   { $$ = RSEM_PREEXPORT; }
+ | EXPORT      { $$ = RSEM_EXPORT; }
+ | NOEXPORT    { $$ = RSEM_NOEXPORT; }
  ;
 
 
index 82d9e2025617735df3b1860861fd18b53d33d33e..5ee04a3082ee50ae121890cfbba7508e8cc77a86 100644 (file)
@@ -301,6 +301,12 @@ struct rt_show_data {
 };
 void rt_show(struct rt_show_data *);
 
+/* Value of export_mode in struct rt_show_data */
+#define RSEM_NONE      0               /* Export mode not used */
+#define RSEM_PREEXPORT 1               /* Routes ready for export, before filtering */
+#define RSEM_EXPORT    2               /* Routes accepted by export filter */
+#define RSEM_NOEXPORT  3               /* Routes rejected by export filter */
+
 /*
  *     Route Attributes
  *
index 37dbb33dc0e36feda761e0d2b7b9ae601ad24b28..59fd07116685291999e55b0a2c4301e1c2b04ad2 100644 (file)
@@ -2255,6 +2255,9 @@ rt_show_net(struct cli *c, net *n, struct rt_show_data *d)
 
   if (d->export_mode)
     {
+      if (! d->export_protocol->rt_notify)
+       return;
+
       a = proto_find_announce_hook(d->export_protocol, d->table);
       if (!a)
        return;
@@ -2287,18 +2290,20 @@ rt_show_net(struct cli *c, net *n, struct rt_show_data *d)
          if (ic < 0)
            goto skip;
 
-         if (d->export_mode > 1)
+         if (d->export_mode > RSEM_PREEXPORT)
            {
              /*
               * FIXME - This shows what should be exported according to current
               * filters, but not what was really exported. 'configure soft'
               * command may change the export filter and do not update routes.
               */
+             int do_export = (ic > 0) ||
+               (f_run(a->out_filter, &e, &tmpa, rte_update_pool, FF_FORCE_TMPATTR) <= F_ACCEPT);
 
-             if (!ic && (f_run(a->out_filter, &e, &tmpa, rte_update_pool, FF_FORCE_TMPATTR) > F_ACCEPT))
+             if (do_export != (d->export_mode == RSEM_EXPORT))
                goto skip;
 
-             if (ep->accept_ra_types == RA_ACCEPTED)
+             if ((d->export_mode == RSEM_EXPORT) && (ep->accept_ra_types == RA_ACCEPTED))
                pass = 1;
            }
        }