Commit 69fddac0 authored by Jan Moskyto Matejka's avatar Jan Moskyto Matejka
Browse files

Merge branch 'int-new' of gitlab.labs.nic.cz:labs/bird into int-new

parents 93a3661c b2949999
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ include ^{WHITE}*include{WHITE}*\".*\"{WHITE}*;
}

{DIGIT}+:{DIGIT}+ {
  unsigned long int l, len1, len2;
  unsigned long int l, len1 UNUSED, len2;
  char *e;

  errno = 0;
+18 −39
Original line number Diff line number Diff line
@@ -924,13 +924,10 @@ 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><label id="cli-show-route">show route [[for] <m/prefix/|<m/IP/] [table (<m/t/ | all)] [filter <m/f/|where <m/c/] [(export|preexport|noexport) <m/p/] [protocol <m/p/] [(stats|count) [by table]] [<m/options/]</tag>
	<tag><label id="cli-show-route">show route [[for] <m/prefix/|<m/IP/] [table (<m/t/ | all)] [filter <m/f/|where <m/c/] [(export|preexport|noexport) <m/p/] [protocol <m/p/] [(stats|count)] [<m/options/]</tag>
	Show contents of specified routing tables, that is routes, their metrics
	and (in case the <cf/all/ switch is given) all their attributes.

	<p>More tables can be specified by repeating the <cf>table <m/t/></cf> clause.
	To cycle over all tables, specify <cf>table all</cf>.

	<p>You can specify a <m/prefix/ if you want to print routes for a
	specific network. If you use <cf>for <m/prefix or IP/</cf>, you'll get
	the entry which will be used for forwarding of packets to the given
@@ -938,57 +935,39 @@ This argument can be omitted if there exists only a single instance.
	the selected one at the top, unless <cf/primary/ is given in which case
	only the selected route is shown.

	<p>The <cf/show route/ command can process one or multiple routing
	tables. The set of selected tables is determined on three levels: First,
	tables can be explicitly selected by <cf/table/ switch, which could be
	used multiple times, all tables are specified by <cf/table all/. Second,
	tables can be implicitly selected by channels or protocols that are
	arguments of several other switches (e.g., <cf/export/, <cf/protocol/).
	Last, the set of default tables is used: <cf/master4/, <cf/master6/ and
	each first table of any other network type.

	<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/, <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
	printing of routes that are exported to the specified protocol or
	channel. With <cf/preexport/, the export filter of the channel is
	skipped. With <cf/noexport/, routes rejected by the export filter are
	printed instead. Note that routes not exported for other reasons
	(e.g. secondary routes or routes imported from that protocol) are not
	printed even with <cf/noexport/. These switches magically cycle over
	all tables connected to the protocol.
	printed even with <cf/noexport/. These switches also imply that
	associated routing tables are selected instead of default ones.

	<p>You can also select just routes added by a specific protocol.
	<cf>protocol <m/p/</cf>. This switch also magically cycles over
	all tables connected to the protocol.
	<cf>protocol <m/p/</cf>. This switch also implies that associated
	routing tables are selected instead of default ones.

	<p>If BIRD is configured to keep filtered routes (see <cf/import keep
	filtered/ option), you can show them instead of routes by using
	<cf/filtered/ switch.

	<p>If no table is specified in any way (<cf/table/, <cf/export/, <cf/preexport/, <cf/noexport/, <cf/protocol/),
	the default tables are listed: <cf/master4/, <cf/master6/
	and first declared table of any other net type.

	<p>The <cf/stats/ switch requests showing of route statistics (the
	number of networks, number of routes before and after filtering). If
	you use <cf/count/ instead, only the statistics will be printed.
	If you use <cf/stats by table/ or <cf/count by table/, the statistics
	will be printed also per-table.

	<tag><label id="cli-show-roa">show roa [<m/prefix/ | in <m/prefix/ | for <m/prefix/] [as <m/num/] [table <m/t/]</tag>
	Show contents of a ROA table (by default of the first one). You can
	specify a <m/prefix/ to print ROA entries for a specific network. If you
	use <cf>for <m/prefix/</cf>, you'll get all entries relevant for route
	validation of the network prefix; i.e., ROA entries whose prefixes cover
	the network prefix. Or you can use <cf>in <m/prefix/</cf> to get ROA
	entries covered by the network prefix. You could also use <cf/as/ option
	to show just entries for given AS.

	<tag><label id="cli-add-roa">add roa <m/prefix/ max <m/num/ as <m/num/ [table <m/t/]</tag>
	Add a new ROA entry to a ROA table. Such entry is called <it/dynamic/
	compared to <it/static/ entries specified in the config file. These
	dynamic entries survive reconfiguration.

	<tag><label id="cli-delete-roa">delete roa <m/prefix/ max <m/num/ as <m/num/ [table <m/t/]</tag>
	Delete the specified ROA entry from a ROA table. Only dynamic ROA
	entries (i.e., the ones added by <cf/add roa/ command) can be deleted.

	<tag><label id="cli-flush-roa">flush roa [table <m/t/]</tag>
	Remove all dynamic ROA entries from a ROA table.

	<tag><label id="cli-configure">configure [soft] ["<m/config file/"] [timeout [<m/num/]]</tag>
	Reload configuration from a given file. BIRD will smoothly switch itself
+1 −3
Original line number Diff line number Diff line
@@ -1693,15 +1693,13 @@ i_same(struct f_inst *f1, struct f_inst *f2)
  case P('a','f'):
  case P('a','l'):
  case P('a','L'): ONEARG; break;
#if 0
  case P('R','C'):
    TWOARGS;
    /* Does not really make sense - ROA check resuls may change anyway */
    /* Does not really make sense - ROA check results may change anyway */
    if (strcmp(((struct f_inst_roa_check *) f1)->rtc->name,
	       ((struct f_inst_roa_check *) f2)->rtc->name))
      return 0;
    break;
#endif
  default:
    bug( "Unknown instruction %d in same (%c)", f1->code, f1->code & 0xff);
  }
+15 −19
Original line number Diff line number Diff line
@@ -177,33 +177,29 @@ net_hash(const net_addr *n)
  case NET_ROA6: return NET_HASH(n, roa6);
  case NET_FLOW4: return NET_HASH(n, flow4);
  case NET_FLOW6: return NET_HASH(n, flow6);
  case NET_MPLS: return NET_HASH(n, mpls);
  default: bug("invalid type");
  }
}


#define NET_VALIDATE(a,t) net_validate_##t((const net_addr_##t *) a)

int
net_validate(const net_addr *N)
net_validate(const net_addr *n)
{
  switch (N->type)
  switch (n->type)
  {
  case NET_IP4:
  case NET_VPN4:
  case NET_ROA4:
  case NET_FLOW4:
    return net_validate_ip4((net_addr_ip4 *) N);

  case NET_IP6:
  case NET_VPN6:
  case NET_ROA6:
  case NET_FLOW6:
    return net_validate_ip6((net_addr_ip6 *) N);

  case NET_MPLS:
    return net_validate_mpls((net_addr_mpls *) N);

  default:
    return 0;
  case NET_IP4: return NET_VALIDATE(n, ip4);
  case NET_IP6: return NET_VALIDATE(n, ip6);
  case NET_VPN4: return NET_VALIDATE(n, vpn4);
  case NET_VPN6: return NET_VALIDATE(n, vpn6);
  case NET_ROA4: return NET_VALIDATE(n, roa4);
  case NET_ROA6: return NET_VALIDATE(n, roa6);
  case NET_FLOW4: return NET_VALIDATE(n, flow4);
  case NET_FLOW6: return NET_VALIDATE(n, flow6);
  case NET_MPLS: return NET_VALIDATE(n, mpls);
  default: return 0;
  }
}

+37 −7
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#define NB_IP		(NB_IP4 | NB_IP6)
#define NB_VPN		(NB_VPN4 | NB_VPN6)
#define NB_FLOW		(NB_FLOW4 | NB_FLOW6)
#define NB_DEST		(NB_IP | NB_VPN | NB_MPLS)
#define NB_ANY		0xffffffff


@@ -457,23 +458,52 @@ static inline u32 net_hash_mpls(const net_addr_mpls *n)
u32 net_hash(const net_addr *a);


static inline int net_validate_ip4(const net_addr_ip4 *n)
static inline int net_validate_px4(const ip4_addr prefix, uint pxlen)
{
  return (pxlen <= IP4_MAX_PREFIX_LENGTH) &&
    ip4_zero(ip4_and(prefix, ip4_not(ip4_mkmask(pxlen))));
}

static inline int net_validate_px6(const ip6_addr prefix, uint pxlen)
{
  return (n->pxlen <= IP4_MAX_PREFIX_LENGTH) &&
    ip4_zero(ip4_and(n->prefix, ip4_not(ip4_mkmask(n->pxlen))));
  return (pxlen <= IP6_MAX_PREFIX_LENGTH) &&
    ip6_zero(ip6_and(prefix, ip6_not(ip6_mkmask(pxlen))));
}

static inline int net_validate_ip4(const net_addr_ip4 *n)
{ return net_validate_px4(n->prefix, n->pxlen); }

static inline int net_validate_ip6(const net_addr_ip6 *n)
{ return net_validate_px6(n->prefix, n->pxlen); }

static inline int net_validate_vpn4(const net_addr_vpn4 *n)
{ return net_validate_px4(n->prefix, n->pxlen); }

static inline int net_validate_vpn6(const net_addr_vpn6 *n)
{ return  net_validate_px6(n->prefix, n->pxlen); }

static inline int net_validate_roa4(const net_addr_roa4 *n)
{
  return (n->pxlen <= IP6_MAX_PREFIX_LENGTH) &&
    ip6_zero(ip6_and(n->prefix, ip6_not(ip6_mkmask(n->pxlen))));
  return net_validate_px4(n->prefix, n->pxlen) &&
     (n->pxlen <= n->max_pxlen) && (n->max_pxlen <= IP4_MAX_PREFIX_LENGTH);
}

static inline int net_validate_mpls(const net_addr_mpls *n)
static inline int net_validate_roa6(const net_addr_roa6 *n)
{
  return n->label < (1 << 20);
  return net_validate_px6(n->prefix, n->pxlen) &&
    (n->pxlen <= n->max_pxlen) && (n->max_pxlen <= IP6_MAX_PREFIX_LENGTH);
}

// FIXME: Better check, call flow_validate?
static inline int net_validate_flow4(const net_addr_flow4 *n)
{ return net_validate_px4(n->prefix, n->pxlen); }

static inline int net_validate_flow6(const net_addr_flow6 *n)
{ return net_validate_px6(n->prefix, n->pxlen); }

static inline int net_validate_mpls(const net_addr_mpls *n)
{ return n->label < (1 << 20); }

int net_validate(const net_addr *N);


Loading