2003-07-15 Paul Jakma <paul@dishone.st>

* lib/version.h: add ZEBRA_URL (unused for now)
        * lib/vty.c: CMD_ERR_NOTHING_TODO when reading conf file should not
          be fatal. slight reformating.
        * ospfd/ospf_zebra.c: ignore reject/blackhole routes if zebra sends
          these type of routes. probably should be a new type of route to
          allow daemons to more easily choose whether to redistribute them
          - rathen than just a flag (eg for reject/blackhole).
          reorder the is_prefix_default test for ZEBRA_IPV4_ROUTE_DELETE to
          avoid the inverted test - slightly more readable.
        * redhat/zebra.spec.in: Add ospfapi port to services file, if
          with_ospfapi.
        * zebra/rib.h: Change nexthop types to an enum.
        * zebra/rt_netlink.c: run it through indent -nut.
          Add nexthop_types_desc[] descriptive array for nexthop types.
          (netlink_route_multipath) debug statements indicate which branch
          they are in and print out nexthop type.
        * zebra/zebra_rib.c: slight reformatting.
        * zebra/zebra_vty.c: Pass ZEBRA_FLAG_BLACKHOLE flag to
          static_add_ipv4() if Null0 route is configured. print out Null0 if
          STATIC_IPV4_BLACKHOLE route, and ignore flags (shouldnt be
          possible to set flags from vty) for config and show route.
This commit is contained in:
paul 2003-07-15 12:52:22 +00:00
parent 8fc0f64b14
commit 7021c425a9
8 changed files with 669 additions and 603 deletions

View File

@ -22,10 +22,12 @@
#ifndef _ZEBRA_VERSION_H
#define _ZEBRA_VERSION_H
#define ZEBRA_VERSION "0.93b"
#define ZEBRA_VERSION "0.94"
#define ZEBRA_BUG_ADDRESS "bug-zebra@gnu.org"
#define ZEBRA_URL "http://zebra.dishone.st"
extern char *host_name;
void print_version(char *);

View File

@ -2115,17 +2115,17 @@ vty_read_file (FILE *confp)
/* Execute configuration file */
ret = config_from_file (vty, confp);
if (ret != CMD_SUCCESS)
if ( !((ret == CMD_SUCCESS) || (ret == CMD_ERR_NOTHING_TODO)) )
{
switch (ret)
{
case CMD_ERR_AMBIGUOUS:
fprintf (stderr, "Ambiguous command.\n");
break;
case CMD_ERR_NO_MATCH:
fprintf (stderr, "There is no such command.\n");
break;
}
{
case CMD_ERR_AMBIGUOUS:
fprintf (stderr, "Ambiguous command.\n");
break;
case CMD_ERR_NO_MATCH:
fprintf (stderr, "There is no such command.\n");
break;
}
fprintf (stderr, "Error occured during reading below line.\n%s\n",
vty->buf);
vty_close (vty);

View File

@ -809,6 +809,15 @@ ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
if (command == ZEBRA_IPV4_ROUTE_ADD)
{
/* XXX|HACK|TODO|FIXME:
* ignore reject/blackhole routes
* need a better generalised solution for these types
* really.
*/
if ( CHECK_FLAG (api.flags, ZEBRA_FLAG_BLACKHOLE)
|| CHECK_FLAG (api.flags, ZEBRA_FLAG_REJECT))
return 0;
ei = ospf_external_info_add (api.type, p, ifindex, nexthop);
if (ospf->router_id.s_addr == 0)
@ -841,10 +850,10 @@ ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
else /* if (command == ZEBRA_IPV4_ROUTE_DELETE) */
{
ospf_external_info_delete (api.type, p);
if (!is_prefix_default (&p))
ospf_external_lsa_flush (ospf, api.type, &p, ifindex, nexthop);
else
if (is_prefix_default (&p))
ospf_external_lsa_refresh_default (ospf);
else
ospf_external_lsa_flush (ospf, api.type, &p, ifindex, nexthop);
}
return 0;

View File

@ -191,6 +191,9 @@ zebra_spec_add_service bgpd 2605/tcp "BGPd vty"
%if %with_ipv6
zebra_spec_add_service ospf6d 2606/tcp "OSPF6d vty"
%endif
%if %with_ospfapi
zebra_spec_add_service ospfapi 2607/tcp "OSPF-API"
%endif
/sbin/chkconfig --add zebra
/sbin/chkconfig --add ripd

View File

@ -123,22 +123,26 @@ struct static_ipv6
};
#endif /* HAVE_IPV6 */
enum nexthop_types_t
{
NEXTHOP_TYPE_IFINDEX = 1, /* Directly connected. */
NEXTHOP_TYPE_IFNAME, /* Interface route. */
NEXTHOP_TYPE_IPV4, /* IPv4 nexthop. */
NEXTHOP_TYPE_IPV4_IFINDEX, /* IPv4 nexthop with ifindex. */
NEXTHOP_TYPE_IPV4_IFNAME, /* IPv4 nexthop with ifname. */
NEXTHOP_TYPE_IPV6, /* IPv6 nexthop. */
NEXTHOP_TYPE_IPV6_IFINDEX, /* IPv6 nexthop with ifindex. */
NEXTHOP_TYPE_IPV6_IFNAME, /* IPv6 nexthop with ifname. */
NEXTHOP_TYPE_BLACKHOLE, /* Null0 nexthop. */
};
/* Nexthop structure. */
struct nexthop
{
struct nexthop *next;
struct nexthop *prev;
u_char type;
#define NEXTHOP_TYPE_IFINDEX 1 /* Directly connected. */
#define NEXTHOP_TYPE_IFNAME 2 /* Interface route. */
#define NEXTHOP_TYPE_IPV4 3 /* IPv4 nexthop. */
#define NEXTHOP_TYPE_IPV4_IFINDEX 4 /* IPv4 nexthop with ifindex. */
#define NEXTHOP_TYPE_IPV4_IFNAME 5 /* IPv4 nexthop with ifname. */
#define NEXTHOP_TYPE_IPV6 6 /* IPv6 nexthop. */
#define NEXTHOP_TYPE_IPV6_IFINDEX 7 /* IPv6 nexthop with ifindex. */
#define NEXTHOP_TYPE_IPV6_IFNAME 8 /* IPv6 nexthop with ifname. */
#define NEXTHOP_TYPE_BLACKHOLE 9 /* Null0 nexthop. */
enum nexthop_types_t type;
u_char flags;
#define NEXTHOP_FLAG_ACTIVE (1 << 0) /* This nexthop is alive. */

File diff suppressed because it is too large Load Diff

View File

@ -863,20 +863,20 @@ rib_process (struct route_node *rn, struct rib *del)
/* Currently installed rib. */
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
fib = rib;
fib = rib;
/* Skip unreachable nexthop. */
if (! nexthop_active_update (rn, rib, 0))
continue;
continue;
/* Infinit distance. */
if (rib->distance == DISTANCE_INFINITY)
continue;
continue;
/* Newly selected rib. */
if (! select || rib->distance < select->distance
|| rib->type == ZEBRA_ROUTE_CONNECT)
select = rib;
|| rib->type == ZEBRA_ROUTE_CONNECT)
select = rib;
}
/* Deleted route check. */
@ -1300,19 +1300,18 @@ static_install_ipv4 (struct prefix *p, struct static_ipv4 *si)
nexthop. */
rib_uninstall (rn, rib);
route_unlock_node (rn);
switch (si->type)
{
case STATIC_IPV4_GATEWAY:
nexthop_ipv4_add (rib, &si->gate.ipv4);
break;
case STATIC_IPV4_IFNAME:
nexthop_ifname_add (rib, si->gate.ifname);
break;
case STATIC_IPV4_BLACKHOLE:
nexthop_blackhole_add (rib);
break;
}
{
case STATIC_IPV4_GATEWAY:
nexthop_ipv4_add (rib, &si->gate.ipv4);
break;
case STATIC_IPV4_IFNAME:
nexthop_ifname_add (rib, si->gate.ifname);
break;
case STATIC_IPV4_BLACKHOLE:
nexthop_blackhole_add (rib);
break;
}
rib_process (rn, NULL);
}
else
@ -1327,17 +1326,17 @@ static_install_ipv4 (struct prefix *p, struct static_ipv4 *si)
rib->nexthop_num = 0;
switch (si->type)
{
case STATIC_IPV4_GATEWAY:
nexthop_ipv4_add (rib, &si->gate.ipv4);
break;
case STATIC_IPV4_IFNAME:
nexthop_ifname_add (rib, si->gate.ifname);
break;
case STATIC_IPV4_BLACKHOLE:
nexthop_blackhole_add (rib);
break;
}
{
case STATIC_IPV4_GATEWAY:
nexthop_ipv4_add (rib, &si->gate.ipv4);
break;
case STATIC_IPV4_IFNAME:
nexthop_ifname_add (rib, si->gate.ifname);
break;
case STATIC_IPV4_BLACKHOLE:
nexthop_blackhole_add (rib);
break;
}
/* Save the flags of this static routes (reject, blackhole) */
rib->flags = si->flags;

View File

@ -136,7 +136,7 @@ zebra_static_ipv4 (struct vty *vty, int add_cmd,
return CMD_WARNING;
}
if (add_cmd)
static_add_ipv4 (&p, NULL, NULL, 0, distance, 0);
static_add_ipv4 (&p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, 0);
else
static_delete_ipv4 (&p, NULL, NULL, distance, 0);
return CMD_SUCCESS;
@ -603,11 +603,9 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
vty_out (vty, " directly connected, %s", nexthop->ifname);
break;
case NEXTHOP_TYPE_BLACKHOLE:
vty_out (vty, " directly connected");
if (!rib->flags)
vty_out (vty, ", Null0");
vty_out (vty, " directly connected, Null0");
break;
default:
default:
break;
}
if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
@ -688,11 +686,9 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
vty_out (vty, " is directly connected, %s", nexthop->ifname);
break;
case NEXTHOP_TYPE_BLACKHOLE:
vty_out (vty, " is directly connected");
if (!rib->flags)
vty_out (vty, ", Null0");
vty_out (vty, " is directly connected, Null0");
break;
default:
default:
break;
}
if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
@ -1070,34 +1066,38 @@ static_config_ipv4 (struct vty *vty)
for (rn = route_top (stable); rn; rn = route_next (rn))
for (si = rn->info; si; si = si->next)
{
vty_out (vty, "ip route %s/%d", inet_ntoa (rn->p.u.prefix4),
rn->p.prefixlen);
vty_out (vty, "ip route %s/%d", inet_ntoa (rn->p.u.prefix4),
rn->p.prefixlen);
switch (si->type)
{
case STATIC_IPV4_GATEWAY:
vty_out (vty, " %s", inet_ntoa (si->gate.ipv4));
break;
case STATIC_IPV4_IFNAME:
vty_out (vty, " %s", si->gate.ifname);
break;
case STATIC_IPV4_BLACKHOLE:
if (!si->flags)
vty_out (vty, " Null0");
break;
}
switch (si->type)
{
case STATIC_IPV4_GATEWAY:
vty_out (vty, " %s", inet_ntoa (si->gate.ipv4));
break;
case STATIC_IPV4_IFNAME:
vty_out (vty, " %s", si->gate.ifname);
break;
case STATIC_IPV4_BLACKHOLE:
vty_out (vty, " Null0");
break;
}
/* flags are incompatible with STATIC_IPV4_BLACKHOLE */
if (si->type != STATIC_IPV4_BLACKHOLE)
{
if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
vty_out (vty, " %s", "reject");
if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
vty_out (vty, " %s", "reject");
if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
vty_out (vty, " %s", "blackhole");
}
if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
vty_out (vty, " %s", "blackhole");
if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
vty_out (vty, " %d", si->distance);
if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
vty_out (vty, " %d", si->distance);
vty_out (vty, "%s", VTY_NEWLINE);
vty_out (vty, "%s", VTY_NEWLINE);
write = 1;
write = 1;
}
return write;
}