summaryrefslogtreecommitdiff
path: root/usr.sbin/ospfd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2005-03-15 22:03:57 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2005-03-15 22:03:57 +0000
commit6c43ce0a87e4135c87e825ee6010fe73e1fedd90 (patch)
treed561d6a23be0181530a8c904582f0273ec618e1e /usr.sbin/ospfd
parentca2b4fe95174a634c722406dcf18371f0e4c4f2b (diff)
Add control messages for the show fib commands.
OK norby@ deraadt@
Diffstat (limited to 'usr.sbin/ospfd')
-rw-r--r--usr.sbin/ospfd/control.c9
-rw-r--r--usr.sbin/ospfd/kroute.c43
-rw-r--r--usr.sbin/ospfd/ospfd.c12
-rw-r--r--usr.sbin/ospfd/ospfd.h5
-rw-r--r--usr.sbin/ospfd/ospfe.c6
5 files changed, 65 insertions, 10 deletions
diff --git a/usr.sbin/ospfd/control.c b/usr.sbin/ospfd/control.c
index a566aed0895..ce9a9e9d6ee 100644
--- a/usr.sbin/ospfd/control.c
+++ b/usr.sbin/ospfd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.7 2005/03/15 16:59:45 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.8 2005/03/15 22:03:56 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -226,6 +226,13 @@ control_dispatch_imsg(int fd, short event, void *bula)
case IMSG_CTL_RELOAD:
ospfe_imsg_compose_parent(imsg.hdr.type, 0, NULL, 0);
break;
+ case IMSG_CTL_KROUTE:
+ case IMSG_CTL_KROUTE_ADDR:
+ c->ibuf.pid = imsg.hdr.pid;
+ ospfe_imsg_compose_parent(imsg.hdr.type,
+ imsg.hdr.pid, imsg.data,
+ imsg.hdr.len - IMSG_HEADER_SIZE);
+ break;
case IMSG_CTL_SHOW_INTERFACE:
if (imsg.hdr.len == IMSG_HEADER_SIZE +
sizeof(ifidx)) {
diff --git a/usr.sbin/ospfd/kroute.c b/usr.sbin/ospfd/kroute.c
index ceb25605f9c..47c2f68d63a 100644
--- a/usr.sbin/ospfd/kroute.c
+++ b/usr.sbin/ospfd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.5 2005/03/07 10:28:14 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.6 2005/03/15 22:03:56 claudio Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -270,7 +270,36 @@ kr_dispatch_msg(int fd, short event, void *bula)
void
kr_show_route(struct imsg *imsg)
{
+ struct kroute_node *kr;
+ int flags;
+ struct in_addr addr;
+
switch (imsg->hdr.type) {
+ case IMSG_CTL_KROUTE:
+ if (imsg->hdr.len != IMSG_HEADER_SIZE + sizeof(flags)) {
+ log_warnx("kr_show_route: wrong imsg len");
+ return;
+ }
+ memcpy(&flags, imsg->data, sizeof(flags));
+ RB_FOREACH(kr, kroute_tree, &krt)
+ if (!flags || kr->r.flags & flags) {
+ main_imsg_compose_ospfe(IMSG_CTL_KROUTE,
+ imsg->hdr.pid, &kr->r, sizeof(kr->r));
+ }
+ break;
+ case IMSG_CTL_KROUTE_ADDR:
+ if (imsg->hdr.len != IMSG_HEADER_SIZE +
+ sizeof(struct in_addr)) {
+ log_warnx("kr_show_route: wrong imsg len");
+ return;
+ }
+ memcpy(&addr, imsg->data, sizeof(addr));
+ kr = NULL;
+ kr = kroute_match(addr.s_addr);
+ if (kr != NULL)
+ main_imsg_compose_ospfe(IMSG_CTL_KROUTE, imsg->hdr.pid,
+ &kr->r, sizeof(kr->r));
+ break;
default:
log_debug("kr_show_route: error handling imsg");
break;
@@ -286,7 +315,7 @@ kr_ifinfo(char *ifname)
RB_FOREACH(kif, kif_tree, &kit)
if (!strcmp(ifname, kif->k.ifname)) {
- main_imsg_compose_ospfe(IMSG_IFINFO, 0,
+ main_imsg_compose_ospfe(IMSG_CTL_IFINFO, 0,
&kif->k, sizeof(kif->k));
return;
}
@@ -775,7 +804,8 @@ fetchtable(void)
return (-1);
}
- kr->r.flags = F_KERNEL;
+ if (!(rtm->rtm_flags & RTF_PROTO1))
+ kr->r.flags = F_KERNEL;
switch (sa->sa_family) {
case AF_INET:
@@ -796,7 +826,6 @@ fetchtable(void)
default:
free(kr);
continue;
- /* not reached */
}
if ((sa = rti_info[RTAX_GATEWAY]) != NULL)
@@ -811,7 +840,11 @@ fetchtable(void)
break;
}
- kroute_insert(kr);
+ if (rtm->rtm_flags & RTF_PROTO2) {
+ send_rtmsg(kr_state.fd, RTM_DELETE, &kr->r);
+ free(kr);
+ } else
+ kroute_insert(kr);
}
free(buf);
diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c
index 0cf43983da7..1a965e2bcc9 100644
--- a/usr.sbin/ospfd/ospfd.c
+++ b/usr.sbin/ospfd/ospfd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.c,v 1.8 2005/03/08 20:12:18 norby Exp $ */
+/* $OpenBSD: ospfd.c,v 1.9 2005/03/15 22:03:56 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -329,6 +329,16 @@ main_dispatch_ospfe(int fd, short event, void *bula)
case IMSG_CTL_FIB_DECOUPLE:
kr_fib_decouple();
break;
+ case IMSG_CTL_KROUTE:
+ case IMSG_CTL_KROUTE_ADDR:
+ kr_show_route(&imsg);
+ break;
+ case IMSG_CTL_IFINFO:
+ if (imsg.hdr.len != IMSG_HEADER_SIZE + IFNAMSIZ)
+ log_warnx("IFINFO request with wrong len");
+ else
+ kr_ifinfo(imsg.data);
+ break;
default:
log_debug("main_dispatch_ospfe: error handling imsg %d",
imsg.hdr.type);
diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h
index 3a2773fbeb1..e8d6ee337c8 100644
--- a/usr.sbin/ospfd/ospfd.h
+++ b/usr.sbin/ospfd/ospfd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.h,v 1.15 2005/03/14 18:21:29 norby Exp $ */
+/* $OpenBSD: ospfd.h,v 1.16 2005/03/15 22:03:56 claudio Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -97,6 +97,9 @@ enum imsg_type {
IMSG_CTL_FIB_COUPLE,
IMSG_CTL_FIB_DECOUPLE,
IMSG_CTL_AREA,
+ IMSG_CTL_KROUTE,
+ IMSG_CTL_KROUTE_ADDR,
+ IMSG_CTL_IFINFO,
IMSG_CTL_END,
IMSG_KROUTE_CHANGE,
IMSG_KROUTE_DELETE,
diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c
index 2adff85a0e5..e334e279303 100644
--- a/usr.sbin/ospfd/ospfe.c
+++ b/usr.sbin/ospfd/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.12 2005/03/14 18:21:29 norby Exp $ */
+/* $OpenBSD: ospfe.c,v 1.13 2005/03/15 22:03:56 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -269,8 +269,10 @@ ospfe_dispatch_main(int fd, short event, void *bula)
}
}
break;
+ case IMSG_CTL_KROUTE:
+ case IMSG_CTL_KROUTE_ADDR:
+ case IMSG_CTL_IFINFO:
case IMSG_CTL_END:
- log_debug("ospfe_dispatch_main: IMSG_CTL_END");
control_imsg_relay(&imsg);
break;
default: