summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/bgpd/bgpd.h5
-rw-r--r--usr.sbin/bgpd/kroute.c18
2 files changed, 21 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index 39615654dc2..89e6259eeb5 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.69 2004/01/17 18:05:46 henning Exp $ */
+/* $OpenBSD: bgpd.h,v 1.70 2004/01/17 18:27:19 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -19,9 +19,11 @@
#define __BGPD_H__
#include <sys/types.h>
+#include <sys/socket.h>
#include <sys/queue.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <net/if.h>
#include <poll.h>
#include <stdarg.h>
@@ -230,6 +232,7 @@ struct kroute_nexthop {
struct kif {
u_short ifindex;
int flags;
+ char ifname[IFNAMSIZ];
};
struct session_up {
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c
index e561a0c2c8f..105ab83edd4 100644
--- a/usr.sbin/bgpd/kroute.c
+++ b/usr.sbin/bgpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.71 2004/01/17 18:05:46 henning Exp $ */
+/* $OpenBSD: kroute.c,v 1.72 2004/01/17 18:27:19 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -24,6 +24,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
+#include <net/if_dl.h>
#include <net/route.h>
#include <err.h>
#include <errno.h>
@@ -852,6 +853,7 @@ if_announce(void *msg)
}
kif->k.ifindex = ifan->ifan_index;
+ strlcpy(kif->k.ifname, ifan->ifan_name, sizeof(kif->k.ifname));
kif_insert(kif);
break;
case IFAN_DEPARTURE:
@@ -1028,6 +1030,8 @@ fetchifs(int ifindex)
char *buf, *next, *lim;
struct if_msghdr *ifm;
struct kif_node *kif;
+ struct sockaddr *sa, *rti_info[RTAX_MAX];
+ struct sockaddr_dl *sdl;
mib[0] = CTL_NET;
mib[1] = AF_ROUTE;
@@ -1052,6 +1056,9 @@ fetchifs(int ifindex)
lim = buf + len;
for (next = buf; next < lim; next += ifm->ifm_msglen) {
ifm = (struct if_msghdr *)next;
+ sa = (struct sockaddr *)(ifm + 1);
+ get_rtaddrs(ifm->ifm_addrs, sa, rti_info);
+
if (ifm->ifm_type != RTM_IFINFO)
continue;
@@ -1062,6 +1069,15 @@ fetchifs(int ifindex)
kif->k.ifindex = ifm->ifm_index;
kif->k.flags = ifm->ifm_flags;
+
+ if ((sa = rti_info[RTAX_IFP]) != NULL)
+ if (sa->sa_family == AF_LINK) {
+ sdl = (struct sockaddr_dl *)sa;
+ if (sdl->sdl_nlen > 0)
+ strlcpy(kif->k.ifname, sdl->sdl_data,
+ sizeof(kif->k.ifname));
+ }
+
kif_insert(kif);
}
return (0);