diff options
author | Renato Westphal <renato@cvs.openbsd.org> | 2017-03-03 23:36:07 +0000 |
---|---|---|
committer | Renato Westphal <renato@cvs.openbsd.org> | 2017-03-03 23:36:07 +0000 |
commit | 8953d78820bbfc32d60cf2bd8fdaf56c09a26169 (patch) | |
tree | 7789fdfa98ba1853278a4a92dc5b69fbcfa86b81 /usr.sbin/ldpd/kroute.c | |
parent | 0019a22123f7c0dc97d4cbec810e849674afe0b9 (diff) |
Allow to run on a non-default rdomain.
OK claudio@
Diffstat (limited to 'usr.sbin/ldpd/kroute.c')
-rw-r--r-- | usr.sbin/ldpd/kroute.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.sbin/ldpd/kroute.c b/usr.sbin/ldpd/kroute.c index fefc57af341..a65e039fa8e 100644 --- a/usr.sbin/ldpd/kroute.c +++ b/usr.sbin/ldpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.62 2017/01/20 12:19:18 benno Exp $ */ +/* $OpenBSD: kroute.c,v 1.63 2017/03/03 23:36:06 renato Exp $ */ /* * Copyright (c) 2015, 2016 Renato Westphal <renato@openbsd.org> @@ -43,6 +43,7 @@ struct { int fd; int ioctl_fd; struct event ev; + unsigned int rdomain; } kr_state; struct kroute_node { @@ -143,13 +144,14 @@ kif_init(void) } int -kr_init(int fs) +kr_init(int fs, unsigned int rdomain) { int opt = 0, rcvbuf, default_rcvbuf; socklen_t optlen; unsigned int rtfilter; kr_state.fib_sync = fs; + kr_state.rdomain = rdomain; if ((kr_state.fd = socket(AF_ROUTE, SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) == -1) { @@ -211,6 +213,9 @@ kif_redistribute(const char *ifname) struct kif_addr *ka; RB_FOREACH(kif, kif_tree, &kit) { + if (kif->k.rdomain != kr_state.rdomain) + continue; + if (ifname && strcmp(kif->k.ifname, ifname) != 0) continue; @@ -871,6 +876,7 @@ kif_update(unsigned short ifindex, int flags, struct if_data *ifd, kif->k.if_type = ifd->ifi_type; kif->k.baudrate = ifd->ifi_baudrate; kif->k.mtu = ifd->ifi_mtu; + kif->k.rdomain = ifd->ifi_rdomain; if (sdl && sdl->sdl_family == AF_LINK) { if (sdl->sdl_nlen >= sizeof(kif->k.ifname)) @@ -1194,6 +1200,7 @@ send_rtmsg_v4(int fd, int action, struct kroute *kr, int family) hdr.rtm_msglen = sizeof(hdr); hdr.rtm_hdrlen = sizeof(struct rt_msghdr); hdr.rtm_priority = kr->priority; + hdr.rtm_tableid = kr_state.rdomain; /* rtableid */ /* adjust iovec */ iov[iovcnt].iov_base = &hdr; iov[iovcnt++].iov_len = sizeof(hdr); @@ -1318,7 +1325,7 @@ fetchtable(void) mib[3] = 0; mib[4] = NET_RT_DUMP; mib[5] = 0; - mib[6] = 0; /* rtableid */ + mib[6] = kr_state.rdomain; /* rtableid */ if (sysctl(mib, 7, NULL, &len, NULL, 0) == -1) { log_warn("sysctl"); @@ -1426,7 +1433,7 @@ rtmsg_process(char *buf, size_t len) if (rtm->rtm_errno) /* failed attempts... */ continue; - if (rtm->rtm_tableid != 0) + if (rtm->rtm_tableid != kr_state.rdomain) continue; if (rtm->rtm_type == RTM_GET && |