Commit fe9f1a6d authored by Ondrej Zajicek (work)'s avatar Ondrej Zajicek (work)
Browse files

Initial commit on integrated BIRD

New data types net_addr and variants (in lib/net.h) describing
network addresses (prefix/pxlen). Modifications of FIB structures
to handle these data types and changing everything to use these
data types instead of prefix/pxlen pairs where possible.

The commit is WiP, some protocols are not yet updated (BGP, Kernel),
and the code contains some temporary scaffolding.

Comments are welcome.
parent 8eb8e546
Loading
Loading
Loading
Loading
+5 −17
Original line number Diff line number Diff line
@@ -123,27 +123,15 @@ include ^{WHITE}*include{WHITE}*\".*\"{WHITE}*;
}

{DIGIT}+\.{DIGIT}+\.{DIGIT}+\.{DIGIT}+ {
  ip4_addr a;
  if (!ip4_pton(yytext, &a))
  if (!ip4_pton(yytext, &cf_lval.ip4))
    cf_error("Invalid IPv4 address %s", yytext);

#ifdef IPV6
  cf_lval.i32 = ip4_to_u32(a);
  return RTRID;
#else
  cf_lval.a = ipa_from_ip4(a);
  return IPA;
#endif
  return IP4;
}

({XIGIT}*::|({XIGIT}*:){3,})({XIGIT}*|{DIGIT}+\.{DIGIT}+\.{DIGIT}+\.{DIGIT}+) {
#ifdef IPV6
  if (ipa_pton(yytext, &cf_lval.a))
    return IPA;
  if (!ip6_pton(yytext, &cf_lval.ip6))
    cf_error("Invalid IPv6 address %s", yytext);
#else
  cf_error("This is an IPv4 router, therefore IPv6 addresses are not supported");
#endif
  return IP6;
}

0x{XIGIT}+ {
+3 −3
Original line number Diff line number Diff line
@@ -133,10 +133,10 @@ config_parse(struct config *c)
  protos_postconfig(c);
  if (EMPTY_LIST(c->protos))
    cf_error("No protocol is specified in the config file");
#ifdef IPV6
  /* XXXX */
  if (!c->router_id)
    cf_error("Router ID must be configured manually on IPv6 routers");
#endif
    cf_error("Router ID must be configured manually");

  return 1;
}

+18 −4
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ CF_DECLS
  int i;
  u32 i32;
  ip_addr a;
  ip4_addr ip4;
  ip6_addr ip6;
  struct symbol *s;
  char *t;
  struct rtable_config *r;
@@ -66,8 +68,8 @@ CF_DECLS
%token GEQ LEQ NEQ AND OR
%token PO PC
%token <i> NUM ENUM
%token <i32> RTRID
%token <a> IPA
%token <ip4> IP4
%token <ip6> IP6
%token <s> SYM
%token <t> TEXT
%type <iface> ipa_scope
@@ -75,10 +77,11 @@ CF_DECLS
%type <i> expr bool pxlen
%type <i32> expr_us
%type <time> datetime
%type <a> ipa
%type <a> ipa ipa_raw
%type <px> prefix prefix_or_ipa
%type <t> text
%type <t> text_or_none
%type <t> opttext

%nonassoc PREFIX_DUMMY
%left AND OR
@@ -148,8 +151,13 @@ bool:

/* Addresses, prefixes and netmasks */

ipa_raw:
   IP4 { $$ = ipa_from_ip4($1); }
 | IP6 { $$ = ipa_from_ip6($1); }
 ;

ipa:
   IPA
   ipa_raw
 | SYM {
     if ($1->class != (SYM_CONSTANT | T_IP)) cf_error("IP address expected");
     $$ = SYM_VAL($1).px.ip;
@@ -205,6 +213,12 @@ text_or_none:
 |      { $$ = NULL; }
 ;

opttext:
    TEXT
 | /* empty */ { $$ = NULL; }
 ;


CF_CODE

CF_END
+1 −1
Original line number Diff line number Diff line
@@ -205,7 +205,7 @@ fi

AC_SUBST(iproutedir)

all_protocols="$proto_bfd bgp ospf pipe $proto_radv rip static"
all_protocols="$proto_bfd ospf pipe $proto_radv rip static"
all_protocols=`echo $all_protocols | sed 's/ /,/g'`

if test "$with_protocols" = all ; then
+2 −5
Original line number Diff line number Diff line
@@ -477,7 +477,7 @@ block:
 * Complex types, their bison value is struct f_val
 */
fipa:
   IPA %prec PREFIX_DUMMY { $$.type = T_IP; $$.val.px.ip = $1; }
   ipa_raw %prec PREFIX_DUMMY { $$.type = T_IP; $$.val.px.ip = $1; }
 ;


@@ -491,7 +491,6 @@ fipa:

set_atom:
   NUM   { $$.type = T_INT; $$.val.i = $1; }
 | RTRID { $$.type = T_QUAD; $$.val.i = $1; }
 | fipa  { $$ = $1; }
 | ENUM  { $$.type = pair_a($1); $$.val.i = pair_b($1); }
 | '(' term ')' {
@@ -508,7 +507,6 @@ set_atom:
switch_atom:
   NUM   { $$.type = T_INT; $$.val.i = $1; }
 | '(' term ')' { $$.type = T_INT; $$.val.i = f_eval_int($2); }
 | RTRID { $$.type = T_QUAD; $$.val.i = $1; }
 | fipa  { $$ = $1; }
 | ENUM  { $$.type = pair_a($1); $$.val.i = pair_b($1); }
 ;
@@ -575,7 +573,7 @@ switch_items:
 ;

fprefix_s:
   IPA '/' NUM %prec '/' {
   ipa_raw '/' NUM %prec '/' {
     if (($3 < 0) || ($3 > MAX_PREFIX_LENGTH) || !ip_is_prefix($1, $3)) cf_error("Invalid network prefix: %I/%d.", $1, $3);
     $$.type = T_PREFIX; $$.val.px.ip = $1; $$.val.px.len = $3;
   }
@@ -646,7 +644,6 @@ constant:
 | TEXT   { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_STRING; $$->a2.p = $1; }
 | fipa	   { NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
 | fprefix_s {NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
 | RTRID  { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_QUAD;  $$->a2.i = $1; }
 | '[' set_items ']' { DBG( "We've got a set here..." ); $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_SET; $$->a2.p = build_tree($2); DBG( "ook\n" ); }
 | '[' fprefix_set ']' { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_PREFIX_SET;  $$->a2.p = $2; }
 | ENUM	  { $$ = f_new_inst(); $$->code = 'c'; $$->aux = $1 >> 16; $$->a2.i = $1 & 0xffff; }
Loading