Commit 6a9f28b0 authored by Martin Mareš's avatar Martin Mareš

Added tracing of interface events.

parent b0a47440
Core Core
~~~~ ~~~~
- debug: interfaces
- debug: static - debug: static
- debug: pipe - debug: pipe
- debug: krt - debug: krt
......
...@@ -19,7 +19,7 @@ CF_DECLS ...@@ -19,7 +19,7 @@ CF_DECLS
CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT) CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS) CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS)
CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS) CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT, 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) RIP, RIP_EXT, OSPF, OSPF_EXT, OSPF_IA, OSPF_BOUNDARY, BGP, PIPE)
...@@ -177,6 +177,7 @@ debug_flag: ...@@ -177,6 +177,7 @@ debug_flag:
STATES { $$ = D_STATES; } STATES { $$ = D_STATES; }
| ROUTES { $$ = D_ROUTES; } | ROUTES { $$ = D_ROUTES; }
| FILTERS { $$ = D_FILTERS; } | FILTERS { $$ = D_FILTERS; }
| INTERFACES { $$ = D_IFACES; }
| EVENTS { $$ = D_EVENTS; } | EVENTS { $$ = D_EVENTS; }
| PACKETS { $$ = D_PACKETS; } | PACKETS { $$ = D_PACKETS; }
; ;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Can be freely distributed and used under the terms of the GNU GPL. * Can be freely distributed and used under the terms of the GNU GPL.
*/ */
#define LOCAL_DEBUG #undef LOCAL_DEBUG
#include "nest/bird.h" #include "nest/bird.h"
#include "nest/iface.h" #include "nest/iface.h"
...@@ -99,15 +99,44 @@ if_copy(struct iface *to, struct iface *from) ...@@ -99,15 +99,44 @@ if_copy(struct iface *to, struct iface *from)
to->mtu = from->mtu; to->mtu = from->mtu;
} }
static inline void
ifa_send_notify(struct proto *p, unsigned c, struct ifa *a)
{
if (p->ifa_notify)
{
if (p->debug & D_IFACES)
log(L_TRACE "%s < %s address %I/%d on interface %s %s",
p->name, (a->flags & IA_PRIMARY) ? "primary" : "secondary",
a->prefix, a->pxlen, a->iface->name,
(c & IF_CHANGE_UP) ? "added" : "removed");
p->ifa_notify(p, c, a);
}
}
static void static void
ifa_notify_change(unsigned c, struct ifa *a) ifa_notify_change(unsigned c, struct ifa *a)
{ {
struct proto *p; struct proto *p;
debug("IFA change notification (%x) for %s:%I\n", c, a->iface->name, a->ip); DBG("IFA change notification (%x) for %s:%I\n", c, a->iface->name, a->ip);
WALK_LIST(p, active_proto_list) WALK_LIST(p, active_proto_list)
if (p->ifa_notify) ifa_send_notify(p, c, a);
p->ifa_notify(p, c, a); }
static inline void
if_send_notify(struct proto *p, unsigned c, struct iface *i)
{
if (p->if_notify)
{
if (p->debug & D_IFACES)
log(L_TRACE "%s < interface %s %s", p->name, i->name,
(c & IF_CHANGE_UP) ? "goes up" :
(c & IF_CHANGE_DOWN) ? "goes down" :
(c & IF_CHANGE_MTU) ? "changes MTU" :
(c & IF_CHANGE_CREATE) ? "created" :
"sends unknown event");
p->if_notify(p, c, i);
}
} }
static void static void
...@@ -122,7 +151,7 @@ if_notify_change(unsigned c, struct iface *i) ...@@ -122,7 +151,7 @@ if_notify_change(unsigned c, struct iface *i)
c |= IF_CHANGE_CREATE | IF_CHANGE_MTU; c |= IF_CHANGE_CREATE | IF_CHANGE_MTU;
} }
debug("Interface change notification (%x) for %s\n", c, i->name); DBG("Interface change notification (%x) for %s\n", c, i->name);
if_dump(i); if_dump(i);
if (c & IF_CHANGE_UP) if (c & IF_CHANGE_UP)
...@@ -135,8 +164,7 @@ if_notify_change(unsigned c, struct iface *i) ...@@ -135,8 +164,7 @@ if_notify_change(unsigned c, struct iface *i)
} }
WALK_LIST(p, active_proto_list) WALK_LIST(p, active_proto_list)
if (p->if_notify) if_send_notify(p, c, i);
p->if_notify(p, c, i);
if (c & IF_CHANGE_UP) if (c & IF_CHANGE_UP)
WALK_LIST(a, i->addrs) WALK_LIST(a, i->addrs)
...@@ -261,16 +289,15 @@ if_feed_baby(struct proto *p) ...@@ -261,16 +289,15 @@ if_feed_baby(struct proto *p)
struct iface *i; struct iface *i;
struct ifa *a; struct ifa *a;
if (!p->if_notify && !p->ifa_notify) if (!p->if_notify && !p->ifa_notify) /* shortcut */
return; return;
debug("Announcing interfaces to new protocol %s\n", p->name); DBG("Announcing interfaces to new protocol %s\n", p->name);
WALK_LIST(i, iface_list) WALK_LIST(i, iface_list)
{ {
if (p->if_notify) if_send_notify(p, IF_CHANGE_CREATE | ((i->flags & IF_UP) ? IF_CHANGE_UP : 0), i);
p->if_notify(p, IF_CHANGE_CREATE | ((i->flags & IF_UP) ? IF_CHANGE_UP : 0), i); if (i->flags & IF_UP)
if (p->ifa_notify && (i->flags & IF_UP))
WALK_LIST(a, i->addrs) WALK_LIST(a, i->addrs)
p->ifa_notify(p, IF_CHANGE_CREATE | IF_CHANGE_UP, a); ifa_send_notify(p, IF_CHANGE_CREATE | IF_CHANGE_UP, a);
} }
} }
...@@ -399,7 +426,7 @@ auto_router_id(void) ...@@ -399,7 +426,7 @@ auto_router_id(void)
j = i; j = i;
if (!j) if (!j)
die("Cannot determine router ID (no suitable network interface found), please configure it manually"); die("Cannot determine router ID (no suitable network interface found), please configure it manually");
debug("Guessed router ID %I (%s)\n", j->addr->ip, j->name); log(L_INFO, "Guessed router ID %I according to interface %s", j->addr->ip, j->name);
config->router_id = ipa_to_u32(j->addr->ip); config->router_id = ipa_to_u32(j->addr->ip);
#endif #endif
} }
......
...@@ -240,9 +240,10 @@ void proto_notify_state(struct proto *p, unsigned state); ...@@ -240,9 +240,10 @@ void proto_notify_state(struct proto *p, unsigned state);
#define D_STATES 1 /* [core] State transitions */ #define D_STATES 1 /* [core] State transitions */
#define D_ROUTES 2 /* [core] Routes passed by the filters */ #define D_ROUTES 2 /* [core] Routes passed by the filters */
#define D_FILTERS 4 /* [core] Filtering of routes */ #define D_FILTERS 4 /* [core] Routes rejected by the filters */
#define D_EVENTS 8 /* Protocol events */ #define D_IFACES 8 /* [core] Interface events */
#define D_PACKETS 16 /* Packets sent/received */ #define D_EVENTS 16 /* Protocol events */
#define D_PACKETS 32 /* Packets sent/received */
/* /*
* Known unique protocol instances as referenced by config routines * Known unique protocol instances as referenced by config routines
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment