-/* $OpenBSD: ospf6ctl.c,v 1.48 2018/06/06 05:51:43 remi Exp $ */
+/* $OpenBSD: ospf6ctl.c,v 1.49 2018/07/12 13:45:03 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
struct parse_result *res;
struct imsg imsg;
unsigned int ifidx = 0;
- int ctl_sock;
+ int ctl_sock, r;
int done = 0, verbose = 0;
int n;
int ch;
char *sockname;
- sockname = OSPF6D_SOCKET;
+ r = getrtable();
+ if (asprintf(&sockname, "%s.%d", OSPF6D_SOCKET, r) == -1)
+ err(1, "asprintf");
+
while ((ch = getopt(argc, argv, "s:")) != -1) {
switch (ch) {
case 's':
-/* $OpenBSD: interface.c,v 1.23 2018/03/11 13:17:35 claudio Exp $ */
+/* $OpenBSD: interface.c,v 1.24 2018/07/12 13:45:03 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
void
if_update(struct iface *iface, int mtu, int flags, u_int8_t type,
- u_int8_t state, u_int64_t rate)
+ u_int8_t state, u_int64_t rate, u_int32_t rdomain)
{
iface->mtu = mtu;
iface->flags = flags;
iface->if_type = type;
iface->linkstate = state;
iface->baudrate = rate;
+ iface->rdomain = rdomain;
/* set type */
if (flags & IFF_POINTOPOINT)
-/* $OpenBSD: kroute.c,v 1.57 2018/07/12 12:19:05 remi Exp $ */
+/* $OpenBSD: kroute.c,v 1.58 2018/07/12 13:45:03 remi Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
int fib_sync;
int fd;
struct event ev;
+ u_int rdomain;
} kr_state;
struct kroute_node {
RB_GENERATE(kroute_tree, kroute_node, entry, kroute_compare)
int
-kr_init(int fs)
+kr_init(int fs, u_int rdomain)
{
int opt = 0, rcvbuf, default_rcvbuf;
socklen_t optlen;
kr_state.fib_sync = fs;
+ kr_state.rdomain = rdomain;
if ((kr_state.fd = socket(AF_ROUTE,
SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, AF_INET6)) == -1) {
}
if_update(iface, ifd->ifi_mtu, flags, ifd->ifi_type,
- ifd->ifi_link_state, ifd->ifi_baudrate);
+ ifd->ifi_link_state, ifd->ifi_baudrate, ifd->ifi_rdomain);
return (iface);
}
hdr.rtm_version = RTM_VERSION;
hdr.rtm_type = action;
hdr.rtm_priority = RTP_OSPF;
+ hdr.rtm_tableid = kr_state.rdomain; /* rtableid */
if (action == RTM_CHANGE)
hdr.rtm_fmask = RTF_REJECT|RTF_BLACKHOLE;
else
mib[3] = AF_INET6;
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");
sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
- if (rtm->rtm_tableid != 0)
+ if (rtm->rtm_tableid != kr_state.rdomain)
continue;
if (rtm->rtm_pid == kr_state.pid) /* caused by us */
-/* $OpenBSD: ospf6d.c,v 1.37 2018/07/12 12:19:05 remi Exp $ */
+/* $OpenBSD: ospf6d.c,v 1.38 2018/07/12 13:45:03 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
int ipforwarding;
int mib[4];
size_t len;
- char *sockname;
+ char *sockname = NULL;
conffile = CONF_FILE;
ospfd_process = PROC_MAIN;
- sockname = OSPF6D_SOCKET;
log_init(1, LOG_DAEMON); /* log to stderr until daemonized */
log_procinit(log_procnames[ospfd_process]);
/* parse config file */
if ((ospfd_conf = parse_config(conffile, opts)) == NULL )
exit(1);
+
+ if (sockname == NULL) {
+ if (asprintf(&sockname, "%s.%d", OSPF6D_SOCKET,
+ ospfd_conf->rdomain) == -1)
+ err(1, "asprintf");
+ }
+
ospfd_conf->csock = sockname;
if (ospfd_conf->opts & OSPFD_OPT_NOACTION) {
iev_rde->handler, iev_rde);
event_add(&iev_rde->ev, NULL);
- if (kr_init(!(ospfd_conf->flags & OSPFD_FLAG_NO_FIB_UPDATE)) == -1)
+ if (kr_init(!(ospfd_conf->flags & OSPFD_FLAG_NO_FIB_UPDATE),
+ ospfd_conf->rdomain) == -1)
fatalx("kr_init failed");
event_dispatch();
-.\" $OpenBSD: ospf6d.conf.5,v 1.15 2018/07/12 12:19:05 remi Exp $
+.\" $OpenBSD: ospf6d.conf.5,v 1.16 2018/07/12 13:45:03 remi Exp $
.\"
.\" Copyright (c) 2005 Esben Norby <norby@openbsd.org>
.\" Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
.Ic stub Ic router
option to ensure that no traffic tries to transit via this router.
.Pp
+.It Ic rdomain Ar tableid
+Specifies the routing table
+.Xr ospfd 8
+should modify.
+Table 0 is the default table.
+.Pp
.It Xo
.Op Ic no
.Ic redistribute
-/* $OpenBSD: ospf6d.h,v 1.36 2018/07/12 12:19:05 remi Exp $ */
+/* $OpenBSD: ospf6d.h,v 1.37 2018/07/12 13:45:03 remi Exp $ */
/*
* Copyright (c) 2004, 2007 Esben Norby <norby@openbsd.org>
u_int32_t ls_ack_cnt;
time_t uptime;
unsigned int ifindex;
+ u_int rdomain;
int fd;
int state;
int mtu;
int flags;
u_int8_t border;
u_int8_t redistribute;
+ u_int rdomain;
char *csock;
};
struct iface *if_findname(char *);
struct iface *if_new(u_short, char *);
void if_update(struct iface *, int, int, u_int8_t, u_int8_t,
- u_int64_t);
+ u_int64_t, u_int32_t);
/* in_cksum.c */
u_int16_t in_cksum(void *, size_t);
u_int16_t iso_cksum(void *, u_int16_t, u_int16_t);
/* kroute.c */
-int kr_init(int);
+int kr_init(int, u_int);
int kr_change(struct kroute *, int);
int kr_delete(struct kroute *);
void kr_shutdown(void);
-/* $OpenBSD: ospfe.c,v 1.53 2018/07/12 12:19:05 remi Exp $ */
+/* $OpenBSD: ospfe.c,v 1.54 2018/07/12 13:45:03 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
LINK_STATE_IS_UP(iface->linkstate);
if_update(iface, ifp->mtu, ifp->flags, ifp->if_type,
- ifp->linkstate, ifp->baudrate);
+ ifp->linkstate, ifp->baudrate, ifp->rdomain);
isvalid = (iface->flags & IFF_UP) &&
LINK_STATE_IS_UP(iface->linkstate);
-/* $OpenBSD: parse.y,v 1.37 2018/07/12 12:19:05 remi Exp $ */
+/* $OpenBSD: parse.y,v 1.38 2018/07/12 13:45:03 remi Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
struct config_defaults *defs;
struct area *conf_get_area(struct in_addr);
+int conf_check_rdomain(u_int);
typedef struct {
union {
%}
-%token AREA INTERFACE ROUTERID FIBUPDATE REDISTRIBUTE RTLABEL
+%token AREA INTERFACE ROUTERID FIBUPDATE REDISTRIBUTE RTLABEL RDOMAIN
%token STUB ROUTER SPFDELAY SPFHOLDTIME EXTTAG
%token METRIC PASSIVE
%token HELLOINTERVAL TRANSMITDELAY
rtlabel_tag(rtlabel_name2id($2), $4);
free($2);
}
+ | RDOMAIN NUMBER {
+ if ($2 < 0 || $2 > RT_TABLEID_MAX) {
+ yyerror("invalid rdomain");
+ YYERROR;
+ }
+ conf->rdomain = $2;
+ }
| SPFDELAY NUMBER {
if ($2 < MIN_SPF_DELAY || $2 > MAX_SPF_DELAY) {
yyerror("spf-delay out of range "
{"no", NO},
{"on", ON},
{"passive", PASSIVE},
+ {"rdomain", RDOMAIN},
{"redistribute", REDISTRIBUTE},
{"retransmit-interval", RETRANSMITINTERVAL},
{"router", ROUTER},
}
}
+ /* check that all interfaces belong to the configured rdomain */
+ errors += conf_check_rdomain(conf->rdomain);
+
if (errors) {
clear_config(conf);
return (NULL);
return (a);
}
+int
+conf_check_rdomain(u_int rdomain)
+{
+ struct area *a;
+ struct iface *i;
+ int errs = 0;
+
+ LIST_FOREACH(a, &conf->area_list, entry)
+ LIST_FOREACH(i, &a->iface_list, entry)
+ if (i->rdomain != rdomain) {
+ logit(LOG_CRIT,
+ "interface %s not in rdomain %u",
+ i->name, rdomain);
+ errs++;
+ }
+
+ return (errs);
+}
+
void
clear_config(struct ospfd_conf *xconf)
{
-/* $OpenBSD: printconf.c,v 1.6 2018/07/12 12:19:05 remi Exp $ */
+/* $OpenBSD: printconf.c,v 1.7 2018/07/12 13:45:03 remi Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
else
printf("fib-update yes\n");
+ if (conf->rdomain)
+ printf("rdomain %d\n", conf->rdomain);
+
if (conf->flags & OSPFD_FLAG_STUB_ROUTER)
printf("stub router yes\n");
-/* $OpenBSD: rde.c,v 1.78 2018/07/12 12:19:05 remi Exp $ */
+/* $OpenBSD: rde.c,v 1.79 2018/07/12 13:45:03 remi Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
LINK_STATE_IS_UP(iface->linkstate);
if_update(iface, ifp->mtu, ifp->flags, ifp->if_type,
- ifp->linkstate, ifp->baudrate);
+ ifp->linkstate, ifp->baudrate, ifp->rdomain);
/* Resend LSAs if interface state changes. */
link_ok = (iface->flags & IFF_UP) &&