summaryrefslogtreecommitdiff
path: root/sys/net/rtsock.c
diff options
context:
space:
mode:
authorPeter Hessler <phessler@cvs.openbsd.org>2017-01-19 23:18:30 +0000
committerPeter Hessler <phessler@cvs.openbsd.org>2017-01-19 23:18:30 +0000
commita946d7032236cadd7387a4bbdf7b0d1df6bd5a0f (patch)
tree8b5e7c22a54449628d8c2e28d3a3d31875e90ff4 /sys/net/rtsock.c
parent1309bbf159e50db75ae5f992927c9bedaee6bd59 (diff)
add hooks so we can query the current state of a BFD session
bfd session details are visible with "route -n get 192.0.2.1 -bfd" OK mpi@ deraadt@ claudio@
Diffstat (limited to 'sys/net/rtsock.c')
-rw-r--r--sys/net/rtsock.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index d56a8f5cbea..7e6c0132bea 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.212 2016/12/20 18:33:43 bluhm Exp $ */
+/* $OpenBSD: rtsock.c,v 1.213 2017/01/19 23:18:29 phessler Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -472,6 +472,9 @@ route_output(struct mbuf *m, ...)
struct rawcb *rp = NULL;
struct sockaddr_rtlabel sa_rl;
struct sockaddr_in6 sa_mask;
+#ifdef BFD
+ struct sockaddr_bfd sa_bfd;
+#endif
#ifdef MPLS
struct sockaddr_mpls sa_mpls, *psa_mpls;
#endif
@@ -705,6 +708,10 @@ report:
rt_plen2mask(rt, &sa_mask);
info.rti_info[RTAX_LABEL] =
rtlabel_id2sa(rt->rt_labelid, &sa_rl);
+#ifdef BFD
+ if (rt->rt_flags & RTF_BFD)
+ info.rti_info[RTAX_BFD] = bfd2sa(rt, &sa_bfd);
+#endif
#ifdef MPLS
if (rt->rt_flags & RTF_MPLS) {
bzero(&sa_mpls, sizeof(sa_mpls));
@@ -1355,6 +1362,7 @@ void
rt_bfdmsg(struct bfd_config *bfd)
{
struct bfd_msghdr *bfdm;
+ struct sockaddr_bfd sa_bfd;
struct mbuf *m;
struct rt_addrinfo info;
@@ -1368,26 +1376,12 @@ rt_bfdmsg(struct bfd_config *bfd)
if (m == NULL)
return;
bfdm = mtod(m, struct bfd_msghdr *);
+ bfdm->bm_addrs = info.rti_addrs;
- bfdm->bm_mode = bfd->bc_mode;
- bfdm->bm_mintx = bfd->bc_mintx;
- bfdm->bm_minrx = bfd->bc_minrx;
- bfdm->bm_minecho = bfd->bc_minecho;
- bfdm->bm_multiplier = bfd->bc_multiplier;
-
- bfdm->bm_uptime = bfd->bc_time->tv_sec;
- bfdm->bm_lastuptime = bfd->bc_lastuptime;
- bfdm->bm_state = bfd->bc_state;
- bfdm->bm_remotestate = bfd->bc_neighbor->bn_rstate;
- bfdm->bm_laststate = bfd->bc_laststate;
- bfdm->bm_error = bfd->bc_error;
-
- bfdm->bm_localdiscr = bfd->bc_neighbor->bn_ldiscr;
- bfdm->bm_localdiag = bfd->bc_neighbor->bn_ldiag;
- bfdm->bm_remotediscr = bfd->bc_neighbor->bn_rdiscr;
- bfdm->bm_remotediag = bfd->bc_neighbor->bn_rdiag;
+ bfd2sa(bfd->bc_rt, &sa_bfd);
+ memcpy(&bfdm->bm_sa, &sa_bfd, sizeof(sa_bfd));
- route_proto.sp_protocol = 0;
+ route_proto.sp_protocol = info.rti_info[RTAX_DST]->sa_family;
route_input(m, &route_proto, &route_src, &route_dst);
}
#endif /* BFD */
@@ -1402,6 +1396,9 @@ sysctl_dumpentry(struct rtentry *rt, void *v, unsigned int id)
int error = 0, size;
struct rt_addrinfo info;
struct ifnet *ifp;
+#ifdef BFD
+ struct sockaddr_bfd sa_bfd;
+#endif
#ifdef MPLS
struct sockaddr_mpls sa_mpls;
#endif
@@ -1436,6 +1433,10 @@ sysctl_dumpentry(struct rtentry *rt, void *v, unsigned int id)
}
if_put(ifp);
info.rti_info[RTAX_LABEL] = rtlabel_id2sa(rt->rt_labelid, &sa_rl);
+#ifdef BFD
+ if (rt->rt_flags & RTF_BFD)
+ info.rti_info[RTAX_BFD] = bfd2sa(rt, &sa_bfd);
+#endif
#ifdef MPLS
if (rt->rt_flags & RTF_MPLS) {
bzero(&sa_mpls, sizeof(sa_mpls));