summaryrefslogtreecommitdiffstats
path: root/lib/routemap.c
diff options
context:
space:
mode:
authorChris Hall <GMCH@hestia.halldom.com>2010-03-16 01:35:19 +0000
committerChris Hall <GMCH@hestia.halldom.com>2010-03-16 01:35:19 +0000
commitd87a9d74eab06082ea49313083ffa0aa41f666f9 (patch)
tree7c6f7ae0be39683b7c90ea298454ec28d49406cb /lib/routemap.c
parent05fb7fd0421b395c089bb08dd0e0d78d3746b8cf (diff)
downloadquagga-d87a9d74eab06082ea49313083ffa0aa41f666f9.tar.bz2
quagga-d87a9d74eab06082ea49313083ffa0aa41f666f9.tar.xz
Major update
bgpd/bgp_advertise.c bgpd/bgp_advertise.h The adj_in and adj_out objects are now put on a list based on the peer to whom the route belongs. The adj_in and adj_out objects also now point to the bgp_node which they are routes for. This substantially reduces the work needed to shut down a peer. bgpd/bgp_damp.c Changes to adj_in and adj_out forced small change to macros used in bgp_damp.c to manage its lists. bgpd/bgp_debug.c Replaced direct access to vty->node by the required vty_get_node(). bgpd/bgp_dump.c Changes to the names of fields in bgp_info structures. bgpd/bgp_engine.h Modified the debug and trace functions. bgpd/bgp_fsm.c Make use of sockunion2str() consistent with common usage. Improved some documentation. bgpd/bgp_main.c Use the newly extended qpn_add_hook_function() facility. bgpd/bgp_mplsvpn.c Changes to the names of fields in bgp_info structures. bgpd/bgp_msg_read.c Bug fix: correct handling of capability code length. Improvement: better casting in calculation of message length. bgpd/bgp_msg_write.c Bug fix: correct byte ordering of bgp_id in open message. bgpd/bgp_network.c Bug fix: correct handling of incoming connections. Takes advantage of improvements in sockunion.c. bgpd/bgp_nexthop.c Changes to the names of fields in bgp_info structures. bgpd/bgp_open_state.c Remove mistaken #include of memtypes.h bgpd/bgp_packet.c Improvements to handling of withdrawing routes for peers. bgpd/bgp_peer.c Tidying up the state of peers as they are enabled and disabled. Improvements to handling of withdrawing routes for peers. bgpd/bgp_peer.h Adding list bases for lists of routes originated by the peer. bgpd/bgp_peer_index.c Bug fix: correct freeing of peer indexes. bgpd/bgp_route.c Implement lists of bgp_info based in the owning peer. Adjust for name changes to bgp_info fields. Reimplemented all the clearing functions to use the lists of items that belong to the peer -- rather than searching route tables for stuff to withdraw. Changed work queue handling for added/changed routes, so that queues run through existing items, rather than having queues of auxiliary items -- lower memory overhead. bgpd/bgp_route.h Added fields to bgp_info to allow all bgp_info originated by each peer to live on lists based in the peer. And changed the name of existing fields to avoid confusion. bgpd/bgp_routemap.c Removing redundant code and fixing a memory leak. bgpd/bgp_table.h Based work queue for added/changed routes directly in the table, rather than having auxiliary structures. bgpd/bgp_vty.c Use vty_get_node() and vty_set_node() rather than direct access to the vty field. bgpd/bgpd.c Implement changes to route clearing. bgpd/bgpd.h Changes to work queue handling. lib/buffer.c Changes to allow embedded buffer structures. lib/buffer.h Moved struct buffer here so that could have embedded buffer structurs. lib/command.c Substantial tidy up and document exercise. Restructured the top level command processing and finding of descriptions and command completion. Removal of unpleasant messing around with the insides of vector structures. Movement of some command actions to vty.c. Uses uty.h to pick up the "private" functions from vty.c et al. lib/command.h Moved the "node" values to node_type.h, so that can use an enum node_type in places where cannot include command.h. lib/command_queue.c Updated to cope with the called command changing the node value. Improved handling of revoked commands, so the the command line handler does not get stuck waiting for a command to complete which has been revoked ! lib/command_queue.h Improved message format. lib/if.c Use vty_set_node(). lib/keychain.c Use vty_set_node(). new lib/keystroke.c new lib/keystroke.h New code to implement a keystroke FIFO. This moves some complexity out of the command handler. The handling of mixtures of escapes and Telnet IACs is tightened up. It would be possible to extend this to, say, UTF-8. Regularises the "stealing" of keystrokes for the "--more--" output handling... which was a bit hit and miss. new lib/list_util.c new lib/list_util.h New code to implement various forms of linked list, where the list pointers are embedded in structures. lib/log.c Changed the handling of log messages, so that all types of log output (except syslog) use the same message buffer scheme, and the message is constructed once and once only. Changes to the handling of VTY_LOCK() etc. Uses uty.h to pick up the "private" functions from vty.c et al. lib/log.h Changes to the buffering of log messages. new lib/mem_tracker.c New code to track memory allocation/deallocation, for debug purposes. lib/memory.c lib/memory.h Updated to allow the use of the mem_tracker. lib/memtypes.awk Made the memtypes into a named enum MTYPE. lib/memtypes.c Various new memory types. lib/mqueue.c lib/mqueue.h Add mqueue_finish function for close-down. lib/network.c lib/network.h Added non-blocking read_nb() and write_nb(). new lib/node_type.h As above. lib/plist.c Remove vty_puts() which wasn't a good idea. lib/qlib_init.c Added qps_init() to first stage and mqueue_finish to finish. lib/qpnexus.c lib/qpnexus.h More flexible hooks for in_thread_init and in_thread_final. lib/qpselect.c lib/qpselect.h Added qps_start_up() to build the required maps once and for all. Added qdebug to control the debug checks and validation. Improved validation and test functions. new lib/qstring.c new lib/qstring.h New code for limited flexible string handling. lib/qtimers.c Added qdebug to control the debug checks and validation. lib/routemap.c Use vty_set_node(). lib/sockunion.c lib/sockunion.h Tidied up and regularised the handling of sin_len and sin6_len. Created common function for setting port into socket. Created common function for initialisation/allocation of new sockunion. Reduced various functions by using common sub-functions. Rationalised some code. Added sockunion_listen() and sockunion_new_sockaddr(). Renamed sockunion_new() to sockunion_new_prefix(). Improved some logging messages. Added documentation. new lib/uty.h Functions etc. used only by vty/command/log/vty_io and vty_cli. lib/vector.c lib/vector.h Added vector_t type. Removed VECTOR_INDEX, vector_only_wrapper_free() and vector_only_index_free() -- following improvement of code in command.c. Added vector_set_min_length(), vector_set_new_min_length() and vector_length() functions. new lib/vio_fifo.c new lib/vio_fifo.h New code to manage simple FIFO of indefinite length. lib/vty.c lib/vty.h Reworked. Broken into vty.c, vty_io.c and vty_cli.c. new lib/vty_cli.c new lib/vty_cli.h CLI handling parts of the vty family. new lib/vty_io.c new lib/vty_io.h I/O parts of the vty family. lib/workqueue.h Introduced tyedefs for the various call-back entries. new tests/test-list_util.c Tests for the list-util stuff. vtysh/vtysh.c Small change to interface for cmd_execute_command()
Diffstat (limited to 'lib/routemap.c')
-rw-r--r--lib/routemap.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/lib/routemap.c b/lib/routemap.c
index 2dfa5a46..b142e99c 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -28,7 +28,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "command.h"
#include "vty.h"
#include "log.h"
-
+
/* Vector for route match rules. */
static vector route_match_vec;
@@ -60,7 +60,7 @@ struct route_map_list
void (*add_hook) (const char *);
void (*delete_hook) (const char *);
- void (*event_hook) (route_map_event_t, const char *);
+ void (*event_hook) (route_map_event_t, const char *);
};
/* Master list of route map. */
@@ -72,7 +72,7 @@ route_map_rule_delete (struct route_map_rule_list *,
static void
route_map_index_delete (struct route_map_index *, int);
-
+
/* New route map allocation. Please note route map's name must be
specified. */
static struct route_map *
@@ -94,7 +94,7 @@ route_map_add (const char *name)
map = route_map_new (name);
list = &route_map_master;
-
+
map->next = NULL;
map->prev = list->tail;
if (list->tail)
@@ -117,7 +117,7 @@ route_map_delete (struct route_map *map)
struct route_map_list *list;
struct route_map_index *index;
char *name;
-
+
while ((index = map->head) != NULL)
route_map_index_delete (index, 0);
@@ -220,23 +220,23 @@ vty_show_route_map_entry (struct vty *vty, struct route_map *map)
if (index->description)
vty_out (vty, " Description:%s %s%s", VTY_NEWLINE,
index->description, VTY_NEWLINE);
-
+
/* Match clauses */
vty_out (vty, " Match clauses:%s", VTY_NEWLINE);
for (rule = index->match_list.head; rule; rule = rule->next)
- vty_out (vty, " %s %s%s",
+ vty_out (vty, " %s %s%s",
rule->cmd->str, rule->rule_str, VTY_NEWLINE);
-
+
vty_out (vty, " Set clauses:%s", VTY_NEWLINE);
for (rule = index->set_list.head; rule; rule = rule->next)
vty_out (vty, " %s %s%s",
rule->cmd->str, rule->rule_str, VTY_NEWLINE);
-
+
/* Call clause */
vty_out (vty, " Call clause:%s", VTY_NEWLINE);
if (index->nextrm)
vty_out (vty, " Call %s%s", index->nextrm, VTY_NEWLINE);
-
+
/* Exit Policy */
vty_out (vty, " Action:%s", VTY_NEWLINE);
if (index->exitpolicy == RMAP_GOTO)
@@ -353,7 +353,7 @@ route_map_index_add (struct route_map *map, enum route_map_type type,
index->map = map;
index->type = type;
index->pref = pref;
-
+
/* Compare preference. */
for (point = map->head; point; point = point->next)
if (point->pref >= pref)
@@ -394,7 +394,7 @@ route_map_index_add (struct route_map *map, enum route_map_type type,
/* Get route map index. */
static struct route_map_index *
-route_map_index_get (struct route_map *map, enum route_map_type type,
+route_map_index_get (struct route_map *map, enum route_map_type type,
int pref)
{
struct route_map_index *index;
@@ -420,7 +420,7 @@ route_map_rule_new (void)
new = XCALLOC (MTYPE_ROUTE_MAP_RULE, sizeof (struct route_map_rule));
return new;
}
-
+
/* Install rule command to the match list. */
void
route_map_install_match (struct route_map_rule_cmd *cmd)
@@ -552,7 +552,7 @@ route_map_add_match (struct route_map_index *index, const char *match_name,
{
next = rule->next;
if (rule->cmd == cmd)
- {
+ {
route_map_rule_delete (&index->match_list, rule);
replaced = 1;
}
@@ -591,9 +591,9 @@ route_map_delete_match (struct route_map_index *index, const char *match_name,
cmd = route_map_lookup_match (match_name);
if (cmd == NULL)
return 1;
-
+
for (rule = index->match_list.head; rule; rule = rule->next)
- if (rule->cmd == cmd &&
+ if (rule->cmd == cmd &&
(rulecmp (rule->rule_str, match_arg) == 0 || match_arg == NULL))
{
route_map_rule_delete (&index->match_list, rule);
@@ -677,7 +677,7 @@ route_map_delete_set (struct route_map_index *index, const char *set_name,
cmd = route_map_lookup_set (set_name);
if (cmd == NULL)
return 1;
-
+
for (rule = index->set_list.head; rule; rule = rule->next)
if ((rule->cmd == cmd) &&
(rulecmp (rule->rule_str, set_arg) == 0 || set_arg == NULL))
@@ -698,7 +698,7 @@ route_map_delete_set (struct route_map_index *index, const char *set_name,
The matrix for a route-map looks like this:
(note, this includes the description for the "NEXT"
and "GOTO" frobs now
-
+
Match | No Match
|
permit action | cont
@@ -707,7 +707,7 @@ route_map_delete_set (struct route_map_index *index, const char *set_name,
|
deny deny | cont
|
-
+
action)
-Apply Set statements, accept route
-If Call statement is present jump to the specified route-map, if it
@@ -719,10 +719,10 @@ route_map_delete_set (struct route_map_index *index, const char *set_name,
-Route is denied by route-map.
cont)
-Goto Next index
-
+
If we get no matches after we've processed all updates, then the route
is dropped too.
-
+
Some notes on the new "CALL", "NEXT" and "GOTO"
call WORD - If this clause is matched, then the set statements
are executed and then we jump to route-map 'WORD'. If
@@ -735,7 +735,7 @@ route_map_delete_set (struct route_map_index *index, const char *set_name,
first clause greater than this. In order to ensure
route-maps *always* exit, you cannot jump backwards.
Sorry ;)
-
+
We need to make sure our route-map processing matches the above
*/
@@ -757,7 +757,7 @@ route_map_apply_match (struct route_map_rule_list *match_list,
for (match = match_list->head; match; match = match->next)
{
/* Try each match statement in turn, If any do not return
- RMAP_MATCH, return, otherwise continue on to next match
+ RMAP_MATCH, return, otherwise continue on to next match
statement. All match statements must match for end-result
to be a match. */
ret = (*match->cmd->func_apply) (match->value, prefix,
@@ -827,7 +827,7 @@ route_map_apply (struct route_map *map, struct prefix *prefix,
if (ret == RMAP_DENYMATCH)
return ret;
}
-
+
switch (index->exitpolicy)
{
case RMAP_EXIT:
@@ -898,7 +898,7 @@ route_map_finish (void)
vector_free (route_set_vec);
route_set_vec = NULL;
}
-
+
/* VTY related functions. */
DEFUN (route_map,
route_map_cmd,
@@ -945,7 +945,7 @@ DEFUN (route_map,
index = route_map_index_get (map, permit, pref);
vty->index = index;
- vty->node = RMAP_NODE;
+ vty_set_node(vty, RMAP_NODE) ;
return CMD_SUCCESS;
}
@@ -1025,7 +1025,7 @@ DEFUN (no_route_map,
index = route_map_index_lookup (map, permit, pref);
if (index == NULL)
{
- vty_out (vty, "%% Could not find route-map entry %s %s%s",
+ vty_out (vty, "%% Could not find route-map entry %s %s%s",
argv[0], argv[2], VTY_NEWLINE);
return CMD_WARNING;
}
@@ -1066,7 +1066,7 @@ DEFUN (no_rmap_onmatch_next,
struct route_map_index *index;
index = vty->index;
-
+
if (index)
index->exitpolicy = RMAP_EXIT;
@@ -1089,11 +1089,11 @@ DEFUN (rmap_onmatch_goto,
VTY_GET_INTEGER_RANGE("route-map index", d, argv[0], 1, 65536);
else
d = index->pref + 1;
-
+
if (d <= index->pref)
{
/* Can't allow you to do that, Dave */
- vty_out (vty, "can't jump backwards in route-maps%s",
+ vty_out (vty, "can't jump backwards in route-maps%s",
VTY_NEWLINE);
return CMD_WARNING;
}
@@ -1119,7 +1119,7 @@ DEFUN (no_rmap_onmatch_goto,
if (index)
index->exitpolicy = RMAP_EXIT;
-
+
return CMD_SUCCESS;
}
@@ -1259,7 +1259,7 @@ route_map_config_write (struct vty *vty)
else
first = 0;
- vty_out (vty, "route-map %s %s %d%s",
+ vty_out (vty, "route-map %s %s %d%s",
map->name,
route_map_type_str (index->type),
index->pref, VTY_NEWLINE);
@@ -1268,7 +1268,7 @@ route_map_config_write (struct vty *vty)
vty_out (vty, " description %s%s", index->description, VTY_NEWLINE);
for (rule = index->match_list.head; rule; rule = rule->next)
- vty_out (vty, " match %s %s%s", rule->cmd->str,
+ vty_out (vty, " match %s %s%s", rule->cmd->str,
rule->rule_str ? rule->rule_str : "",
VTY_NEWLINE);
@@ -1282,7 +1282,7 @@ route_map_config_write (struct vty *vty)
vty_out (vty, " on-match goto %d%s", index->nextpref, VTY_NEWLINE);
if (index->exitpolicy == RMAP_NEXT)
vty_out (vty," on-match next%s", VTY_NEWLINE);
-
+
write++;
}
return write;
@@ -1315,12 +1315,12 @@ route_map_init_vty (void)
install_element (RMAP_NODE, &no_rmap_onmatch_next_cmd);
install_element (RMAP_NODE, &rmap_onmatch_goto_cmd);
install_element (RMAP_NODE, &no_rmap_onmatch_goto_cmd);
-
+
/* Install the continue stuff (ALIAS of on-match). */
install_element (RMAP_NODE, &rmap_continue_cmd);
install_element (RMAP_NODE, &no_rmap_continue_cmd);
install_element (RMAP_NODE, &rmap_continue_index_cmd);
-
+
/* Install the call stuff. */
install_element (RMAP_NODE, &rmap_call_cmd);
install_element (RMAP_NODE, &no_rmap_call_cmd);
@@ -1328,7 +1328,7 @@ route_map_init_vty (void)
/* Install description commands. */
install_element (RMAP_NODE, &rmap_description_cmd);
install_element (RMAP_NODE, &no_rmap_description_cmd);
-
+
/* Install show command */
install_element (ENABLE_NODE, &rmap_show_name_cmd);
}