diff options
author | Martin Mares <mj@ucw.cz> | 2000-03-07 21:49:48 +0100 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2000-03-07 21:49:48 +0100 |
commit | 96d8e3bff242d5c9d0eb75fa04a21f6c09d8dbcf (patch) | |
tree | f24438e8463e414eb0f5c27b19994ef3b2f52ce4 /nest/config.Y | |
parent | c801e1fbabee49838287a9e96814d3d0bf84ffa2 (diff) | |
download | bird-96d8e3bff242d5c9d0eb75fa04a21f6c09d8dbcf.tar bird-96d8e3bff242d5c9d0eb75fa04a21f6c09d8dbcf.zip |
Added protocol debugging flags (protocol.h: D_xxx), parsing of them
in configuration files and commands for manipulating them.
Current debug message policy:
o D_STATES, D_ROUTES and D_FILTERS are handled in generic code.
o Other debug flags should be handled in the protocols and whenever
the flag is set, the corresponding messages should be printed
using calls to log(L_TRACE, ...), each message prefixed with
the name of the protocol instance. These messages should cover
the whole normal operation of the protocol and should be useful
for an administrator trying to understand what does the protocol
behave on his network or who is attempting to diagnose network
problems. If your messages don't fit to the categories I've defined,
feel free to add your own ones (by adding them to protocol.h
and on two places in nest/config.Y), but please try to keep the
categories as general as possible (i.e., not tied to your protocol).
o Internal debug messages not interesting even to an experienced
user should be printed by calling DBG() which is either void or
a call to debug() depending on setting of the LOCAL_DEBUG symbol
at the top of your source.
o Dump functions (proto->dump etc.) should call debug() to print
their messages.
o If you are doing any internal consistency checks, use ASSERT
or bug().
o Nobody shall ever call printf() or any other stdio functions.
Also please try to log any protocol errors you encounter and tag them
with the appropriate message category (usually L_REMOTE or L_AUTH). Always
carefully check contents of any message field you receive and verify all
IP addresses you work with (by calling ipa_classify() or by using the
neighbour cache if you want to check direct connectedness as well).
Diffstat (limited to 'nest/config.Y')
-rw-r--r-- | nest/config.Y | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/nest/config.Y b/nest/config.Y index 3911076..9fce23a 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -18,8 +18,8 @@ static struct iface_patt *this_ipatt; CF_DECLS CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT) -CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE) -CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID) +CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS) +CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS) CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT, RIP, RIP_EXT, OSPF, OSPF_EXT, OSPF_IA, OSPF_BOUNDARY, BGP, PIPE) @@ -30,7 +30,7 @@ CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIREC %type <p> password_list password_begin %type <s> optsym %type <ra> r_args -%type <i> echo_mask echo_size +%type <i> echo_mask echo_size debug_mask debug_list debug_flag %type <t> proto_patt CF_GRAMMAR @@ -91,9 +91,7 @@ proto_item: this_proto->preference = $2; } | DISABLED { this_proto->disabled = 1; } - | DEBUG expr { this_proto->debug = $2; } - | DEBUG ALL { this_proto->debug = ~0; } - | DEBUG OFF { this_proto->debug = 0; } + | DEBUG debug_mask { this_proto->debug = $2; } | IMPORT imexport { this_proto->in_filter = $2; } | EXPORT imexport { this_proto->out_filter = $2; } | TABLE rtable { this_proto->table = $2; } @@ -156,6 +154,27 @@ dev_iface_list: | dev_iface_list ',' dev_iface_entry ; +/* Debug flags */ + +debug_mask: + ALL { $$ = ~0; } + | OFF { $$ = 0; } + | '{' debug_list '}' { $$ = $2; } + ; + +debug_list: + debug_flag + | debug_list ',' debug_flag { $$ = $1 | $3; } + ; + +debug_flag: + STATES { $$ = D_STATES; } + | ROUTES { $$ = D_ROUTES; } + | FILTERS { $$ = D_FILTERS; } + | EVENTS { $$ = D_EVENTS; } + | PACKETS { $$ = D_PACKETS; } + ; + /* Password lists */ password_begin: @@ -251,20 +270,20 @@ r_args: CF_CLI(SHOW SYMBOLS, optsym, [<symbol>], [[Show all known symbolic names]]) { cmd_show_symbols($3); } ; -CF_CLI_HELP(DEBUG, ..., [[Show debugging information]]) -CF_CLI(DEBUG RESOURCES,,, [[Show all allocated resource]]) +CF_CLI_HELP(DUMP, ..., [[Dump debugging information]]) +CF_CLI(DUMP RESOURCES,,, [[Dump all allocated resource]]) { rdump(&root_pool); cli_msg(0, ""); } ; -CF_CLI(DEBUG SOCKETS,,, [[Show open sockets]]) +CF_CLI(DUMP SOCKETS,,, [[Dump open sockets]]) { sk_dump_all(); cli_msg(0, ""); } ; -CF_CLI(DEBUG INTERFACES,,, [[Show interface information]]) +CF_CLI(DUMP INTERFACES,,, [[Dump interface information]]) { if_dump_all(); cli_msg(0, ""); } ; -CF_CLI(DEBUG NEIGHBORS,,, [[Show neighbor cache]]) +CF_CLI(DUMP NEIGHBORS,,, [[Dump neighbor cache]]) { neigh_dump_all(); cli_msg(0, ""); } ; -CF_CLI(DEBUG ATTRIBUTES,,, [[Show attribute cache]]) +CF_CLI(DUMP ATTRIBUTES,,, [[Dump attribute cache]]) { rta_dump_all(); cli_msg(0, ""); } ; -CF_CLI(DEBUG ROUTES,,, [[Show routing table]]) +CF_CLI(DUMP ROUTES,,, [[Dump routing table]]) { rt_dump_all(); cli_msg(0, ""); } ; -CF_CLI(DEBUG PROTOCOLS,,, [[Show protocol information]]) +CF_CLI(DUMP PROTOCOLS,,, [[Dump protocol information]]) { protos_dump_all(); cli_msg(0, ""); } ; CF_CLI(ECHO, echo_mask echo_size, [all | off | <mask>] [<buffer-size>], [[Configure echoing of log messages]]) { @@ -293,6 +312,10 @@ CF_CLI(ENABLE, proto_patt, <protocol> | <pattern> | all, [[Enable protocol]]) CF_CLI(RESTART, proto_patt, <protocol> | <pattern> | all, [[Restart protocol]]) { proto_xxable($2, 2); } ; +CF_CLI_HELP(DEBUG, ..., [[Control protocol debugging]]) +CF_CLI(DEBUG, proto_patt debug_mask, (<protocol> | <pattern> | all) (all | off | { states | routes | filters | events | packets }), [[Control protocol debugging]]) +{ proto_debug($2, $3); } + proto_patt: SYM { $$ = $1->name; } | ALL { $$ = "*"; } |