mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-17 16:48:43 +00:00
Implements proper setting of 'gw' route attribute.
Thanks to Sergey Popovich for the bugreport.
This commit is contained in:
parent
f8e8fcfabe
commit
00192d5ab8
@ -1169,7 +1169,7 @@ undefined value is regarded as empty clist for most purposes.
|
|||||||
Preference of the route. Valid values are 0-65535. (See the chapter about routing tables.)
|
Preference of the route. Valid values are 0-65535. (See the chapter about routing tables.)
|
||||||
|
|
||||||
<tag><m/ip/ from</tag>
|
<tag><m/ip/ from</tag>
|
||||||
The router which the route has originated from. Read-only.
|
The router which the route has originated from.
|
||||||
|
|
||||||
<tag><m/ip/ gw</tag>
|
<tag><m/ip/ gw</tag>
|
||||||
Next hop packets routed using this route should be forwarded to.
|
Next hop packets routed using this route should be forwarded to.
|
||||||
|
@ -681,7 +681,6 @@ symbol:
|
|||||||
|
|
||||||
static_attr:
|
static_attr:
|
||||||
FROM { $$ = f_new_inst(); $$->aux = T_IP; $$->a2.i = OFFSETOF(struct rta, from); $$->a1.i = 1; }
|
FROM { $$ = f_new_inst(); $$->aux = T_IP; $$->a2.i = OFFSETOF(struct rta, from); $$->a1.i = 1; }
|
||||||
|
|
||||||
| GW { $$ = f_new_inst(); $$->aux = T_IP; $$->a2.i = OFFSETOF(struct rta, gw); $$->a1.i = 1; }
|
| GW { $$ = f_new_inst(); $$->aux = T_IP; $$->a2.i = OFFSETOF(struct rta, gw); $$->a1.i = 1; }
|
||||||
| NET { $$ = f_new_inst(); $$->aux = T_PREFIX; $$->a2.i = 0x12345678; /* This is actually ok - T_PREFIX is special-cased. */ }
|
| NET { $$ = f_new_inst(); $$->aux = T_PREFIX; $$->a2.i = 0x12345678; /* This is actually ok - T_PREFIX is special-cased. */ }
|
||||||
| PROTO { $$ = f_new_inst(); $$->aux = T_STRING; $$->a2.i = 0x12345678; /* T_STRING is also special-cased. */ }
|
| PROTO { $$ = f_new_inst(); $$->aux = T_STRING; $$->a2.i = 0x12345678; /* T_STRING is also special-cased. */ }
|
||||||
|
@ -853,10 +853,29 @@ interpret(struct f_inst *what)
|
|||||||
f_rta_cow();
|
f_rta_cow();
|
||||||
{
|
{
|
||||||
struct rta *rta = (*f_rte)->attrs;
|
struct rta *rta = (*f_rte)->attrs;
|
||||||
|
ip_addr ip;
|
||||||
|
|
||||||
switch (what->aux) {
|
switch (what->aux) {
|
||||||
|
|
||||||
case T_IP:
|
case T_IP:
|
||||||
* (ip_addr *) ((char *) rta + what->a2.i) = v1.val.px.ip;
|
ip = v1.val.px.ip;
|
||||||
|
|
||||||
|
/* "gw" attribute? */
|
||||||
|
if (what->a2.i == OFFSETOF(struct rta, gw))
|
||||||
|
{
|
||||||
|
neighbor *n = neigh_find(rta->proto, &ip, 0);
|
||||||
|
if (!n || (n->scope == SCOPE_HOST))
|
||||||
|
runtime( "Invalid gw address" );
|
||||||
|
|
||||||
|
rta->dest = RTD_ROUTER;
|
||||||
|
rta->gw = ip;
|
||||||
|
rta->iface = n->iface;
|
||||||
|
rta->nexthops = NULL;
|
||||||
|
rta->hostentry = NULL;
|
||||||
|
}
|
||||||
|
else /* or "from" attribute? */
|
||||||
|
rta->from = ip;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_ENUM_SCOPE:
|
case T_ENUM_SCOPE:
|
||||||
@ -867,10 +886,12 @@ interpret(struct f_inst *what)
|
|||||||
i = v1.val.i;
|
i = v1.val.i;
|
||||||
if ((i != RTD_BLACKHOLE) && (i != RTD_UNREACHABLE) && (i != RTD_PROHIBIT))
|
if ((i != RTD_BLACKHOLE) && (i != RTD_UNREACHABLE) && (i != RTD_PROHIBIT))
|
||||||
runtime( "Destination can be changed only to blackhole, unreachable or prohibit" );
|
runtime( "Destination can be changed only to blackhole, unreachable or prohibit" );
|
||||||
|
|
||||||
rta->dest = i;
|
rta->dest = i;
|
||||||
rta->gw = IPA_NONE;
|
rta->gw = IPA_NONE;
|
||||||
rta->iface = NULL;
|
rta->iface = NULL;
|
||||||
rta->nexthops = NULL;
|
rta->nexthops = NULL;
|
||||||
|
rta->hostentry = NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user