diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ldpd/interface.c | 3 | ||||
-rw-r--r-- | usr.sbin/ldpd/kroute.c | 15 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.c | 11 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.conf.5 | 10 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.h | 7 | ||||
-rw-r--r-- | usr.sbin/ldpd/parse.y | 34 | ||||
-rw-r--r-- | usr.sbin/ldpd/printconf.c | 3 |
7 files changed, 67 insertions, 16 deletions
diff --git a/usr.sbin/ldpd/interface.c b/usr.sbin/ldpd/interface.c index 7988448bd68..eb928356256 100644 --- a/usr.sbin/ldpd/interface.c +++ b/usr.sbin/ldpd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.48 2016/09/03 16:07:08 renato Exp $ */ +/* $OpenBSD: interface.c,v 1.49 2017/03/03 23:36:06 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -61,6 +61,7 @@ if_new(struct kif *kif) /* get index and flags */ LIST_INIT(&iface->addr_list); iface->ifindex = kif->ifindex; + iface->rdomain = kif->rdomain; iface->flags = kif->flags; iface->linkstate = kif->link_state; iface->if_type = kif->if_type; 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 && diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c index c8c888bcc38..901df833a91 100644 --- a/usr.sbin/ldpd/ldpd.c +++ b/usr.sbin/ldpd/ldpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.c,v 1.61 2017/03/03 23:30:57 renato Exp $ */ +/* $OpenBSD: ldpd.c,v 1.62 2017/03/03 23:36:06 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -255,12 +255,13 @@ main(int argc, char *argv[]) fatal("could not establish imsg links"); main_imsg_send_config(ldpd_conf); + if (kr_init(!(ldpd_conf->flags & F_LDPD_NO_FIB_UPDATE), + ldpd_conf->rdomain) == -1) + fatalx("kr_init failed"); + /* notify ldpe about existing interfaces and addresses */ kif_redistribute(NULL); - if (kr_init(!(ldpd_conf->flags & F_LDPD_NO_FIB_UPDATE)) == -1) - fatalx("kr_init failed"); - if (ldpd_conf->ipv4.flags & F_LDPD_AF_ENABLED) main_imsg_send_net_sockets(AF_INET); if (ldpd_conf->ipv6.flags & F_LDPD_AF_ENABLED) @@ -772,6 +773,8 @@ merge_global(struct ldpd_conf *conf, struct ldpd_conf *xconf) conf->rtr_id = xconf->rtr_id; } + conf->rdomain= xconf->rdomain; + if (conf->trans_pref != xconf->trans_pref) { if (ldpd_process == PROC_LDP_ENGINE) ldpe_reset_ds_nbrs(); diff --git a/usr.sbin/ldpd/ldpd.conf.5 b/usr.sbin/ldpd/ldpd.conf.5 index a5e95e8675f..1f8e85fd8f0 100644 --- a/usr.sbin/ldpd/ldpd.conf.5 +++ b/usr.sbin/ldpd/ldpd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ldpd.conf.5,v 1.33 2016/07/07 19:56:27 rzalamena Exp $ +.\" $OpenBSD: ldpd.conf.5,v 1.34 2017/03/03 23:36:06 renato Exp $ .\" .\" Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> .\" Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -19,7 +19,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: July 7 2016 $ +.Dd $Mdocdate: March 3 2017 $ .Dt LDPD.CONF 5 .Os .Sh NAME @@ -108,6 +108,12 @@ table. The default is .Ic yes . .Pp +.It Ic rdomain Ar tableid +Specifies the routing table +.Xr ldpd 8 +should modify. +Table 0 is the default table. +.Pp .It Ic router-id Ar address Set the router ID; in combination with labelspace it forms the LSR-ID. If not specified, the numerically lowest IP address of the router will be used. diff --git a/usr.sbin/ldpd/ldpd.h b/usr.sbin/ldpd/ldpd.h index 94346b966c8..f5b2a96cac1 100644 --- a/usr.sbin/ldpd/ldpd.h +++ b/usr.sbin/ldpd/ldpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.h,v 1.82 2017/03/03 23:30:57 renato Exp $ */ +/* $OpenBSD: ldpd.h,v 1.83 2017/03/03 23:36:06 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -258,6 +258,7 @@ struct iface { LIST_ENTRY(iface) entry; char name[IF_NAMESIZE]; unsigned int ifindex; + unsigned int rdomain; struct if_addr_head addr_list; struct in6_addr linklocal; enum iface_type type; @@ -388,6 +389,7 @@ struct ldpd_af_conf { struct ldpd_conf { struct in_addr rtr_id; + unsigned int rdomain; struct ldpd_af_conf ipv4; struct ldpd_af_conf ipv6; LIST_HEAD(, iface) iface_list; @@ -460,6 +462,7 @@ struct kif { int flags; uint8_t link_state; int mtu; + unsigned int rdomain; uint8_t if_type; uint64_t baudrate; }; @@ -533,7 +536,7 @@ int cmdline_symset(char *); /* kroute.c */ int kif_init(void); -int kr_init(int); +int kr_init(int, unsigned int); void kif_redistribute(const char *); int kr_change(struct kroute *); int kr_delete(struct kroute *); diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y index 593058acf97..aa34df21666 100644 --- a/usr.sbin/ldpd/parse.y +++ b/usr.sbin/ldpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.59 2017/01/05 13:53:09 krw Exp $ */ +/* $OpenBSD: parse.y,v 1.60 2017/03/03 23:36:06 renato Exp $ */ /* * Copyright (c) 2013, 2015, 2016 Renato Westphal <renato@openbsd.org> @@ -99,6 +99,7 @@ static struct nbr_params *conf_get_nbrp(struct in_addr); static struct l2vpn *conf_get_l2vpn(char *); static struct l2vpn_if *conf_get_l2vpn_if(struct l2vpn *, struct kif *); static struct l2vpn_pw *conf_get_l2vpn_pw(struct l2vpn *, struct kif *); +int conf_check_rdomain(unsigned int); static void clear_config(struct ldpd_conf *xconf); static uint32_t get_rtr_id(void); static int get_address(const char *, union ldpd_addr *); @@ -133,7 +134,7 @@ static int pushback_index; %} -%token INTERFACE TNEIGHBOR ROUTERID FIBUPDATE EXPNULL +%token INTERFACE TNEIGHBOR ROUTERID FIBUPDATE RDOMAIN EXPNULL %token LHELLOHOLDTIME LHELLOINTERVAL %token THELLOHOLDTIME THELLOINTERVAL %token THELLOACCEPT AF IPV4 IPV6 GTSMENABLE GTSMHOPS @@ -243,6 +244,13 @@ conf_main : ROUTERID STRING { else conf->flags &= ~F_LDPD_NO_FIB_UPDATE; } + | RDOMAIN NUMBER { + if ($2 < 0 || $2 > RT_TABLEID_MAX) { + yyerror("invalid rdomain"); + YYERROR; + } + conf->rdomain = $2; + } | TRANSPREFERENCE ldp_af { conf->trans_pref = $2; @@ -842,6 +850,7 @@ lookup(char *s) {"pseudowire", PSEUDOWIRE}, {"pw-id", PWID}, {"pw-type", PWTYPE}, + {"rdomain", RDOMAIN}, {"router-id", ROUTERID}, {"status-tlv", STATUSTLV}, {"targeted-hello-accept", THELLOACCEPT}, @@ -1174,6 +1183,7 @@ parse_config(char *filename) struct sym *sym, *next; conf = config_new_empty(); + conf->rdomain = 0; conf->trans_pref = DUAL_STACK_LDPOV6; defs = &globaldefs; @@ -1208,6 +1218,9 @@ parse_config(char *filename) } } + /* check that all interfaces belong to the configured rdomain */ + errors += conf_check_rdomain(conf->rdomain); + /* free global config defaults */ if (errors) { clear_config(conf); @@ -1438,6 +1451,23 @@ conf_get_l2vpn_pw(struct l2vpn *l, struct kif *kif) return (p); } +int +conf_check_rdomain(unsigned int rdomain) +{ + struct iface *i; + int errs = 0; + + LIST_FOREACH(i, &conf->iface_list, entry) { + if (i->rdomain != rdomain) { + logit(LOG_CRIT, "interface %s not in rdomain %u", + i->name, rdomain); + errs++; + } + } + + return (errs); +} + static void clear_config(struct ldpd_conf *xconf) { diff --git a/usr.sbin/ldpd/printconf.c b/usr.sbin/ldpd/printconf.c index 32db88109df..e39b43f8336 100644 --- a/usr.sbin/ldpd/printconf.c +++ b/usr.sbin/ldpd/printconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printconf.c,v 1.26 2016/07/01 23:14:31 renato Exp $ */ +/* $OpenBSD: printconf.c,v 1.27 2017/03/03 23:36:06 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -44,6 +44,7 @@ print_mainconf(struct ldpd_conf *conf) else printf("fib-update yes\n"); + printf("rdomain %u\n", conf->rdomain); if (conf->trans_pref == DUAL_STACK_LDPOV4) printf("transport-preference ipv4\n"); else if (conf->trans_pref == DUAL_STACK_LDPOV6) |