summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/ospfd/interface.c17
-rw-r--r--usr.sbin/ospfd/kroute.c11
-rw-r--r--usr.sbin/ospfd/ospfd.c5
-rw-r--r--usr.sbin/ospfd/ospfd.h5
-rw-r--r--usr.sbin/ospfd/parse.y12
5 files changed, 39 insertions, 11 deletions
diff --git a/usr.sbin/ospfd/interface.c b/usr.sbin/ospfd/interface.c
index f48fc97b767..5e212044d6b 100644
--- a/usr.sbin/ospfd/interface.c
+++ b/usr.sbin/ospfd/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.62 2009/04/26 12:48:06 sthen Exp $ */
+/* $OpenBSD: interface.c,v 1.63 2009/06/05 04:12:52 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -238,6 +238,9 @@ if_del(struct iface *iface)
void
if_init(struct ospfd_conf *xconf, struct iface *iface)
{
+ struct ifreq ifr;
+ u_int rdomain;
+
/* init the dummy local neighbor */
iface->self = nbr_new(ospfe_router_id(), iface, 1);
@@ -248,6 +251,18 @@ if_init(struct ospfd_conf *xconf, struct iface *iface)
iface->fd = xconf->ospf_socket;
+ strlcpy(ifr.ifr_name, iface->name, sizeof(ifr.ifr_name));
+ if (ioctl(iface->fd, SIOCGIFRTABLEID, (caddr_t)&ifr) == -1)
+ rdomain = 0;
+ else {
+ rdomain = ifr.ifr_rdomainid;
+ if (setsockopt(iface->fd, IPPROTO_IP, SO_RDOMAIN,
+ &rdomain, sizeof(rdomain)) == -1)
+ fatal("failed to set rdomain");
+ }
+ if (rdomain != xconf->rdomain)
+ fatalx("interface rdomain mismatch");
+
ospfe_demote_iface(iface, 0);
}
diff --git a/usr.sbin/ospfd/kroute.c b/usr.sbin/ospfd/kroute.c
index 18838ea3d1b..4e5776a07d2 100644
--- a/usr.sbin/ospfd/kroute.c
+++ b/usr.sbin/ospfd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.69 2009/06/02 20:16:59 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.70 2009/06/05 04:12:52 claudio Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -46,6 +46,7 @@ struct {
int fib_sync;
int fd;
struct event ev;
+ u_int rdomain;
} kr_state;
struct kroute_node {
@@ -120,12 +121,13 @@ kif_init(void)
}
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, 0)) == -1) {
log_warn("kr_init: socket");
@@ -1042,6 +1044,7 @@ send_rtmsg(int fd, int action, struct kroute *kroute)
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
@@ -1155,7 +1158,7 @@ fetchtable(void)
mib[3] = AF_INET;
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");
@@ -1364,7 +1367,7 @@ dispatch_rtmsg(void)
sa = (struct sockaddr *)(rtm + 1);
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 */
diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c
index 656cd82c9f1..4f48d846c85 100644
--- a/usr.sbin/ospfd/ospfd.c
+++ b/usr.sbin/ospfd/ospfd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.c,v 1.67 2009/05/31 18:46:01 jacekm Exp $ */
+/* $OpenBSD: ospfd.c,v 1.68 2009/06/05 04:12:52 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -287,7 +287,8 @@ main(int argc, char *argv[])
ibuf_rde->handler, ibuf_rde);
event_add(&ibuf_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");
/* remove unneded stuff from config */
diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h
index 5e12dc38e78..0734913ad79 100644
--- a/usr.sbin/ospfd/ospfd.h
+++ b/usr.sbin/ospfd/ospfd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.h,v 1.79 2009/06/05 01:19:09 pyr Exp $ */
+/* $OpenBSD: ospfd.h,v 1.80 2009/06/05 04:12:52 claudio Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -410,6 +410,7 @@ struct ospfd_conf {
u_int8_t rfc1583compat;
u_int8_t border;
u_int8_t redistribute;
+ u_int rdomain;
char *csock;
};
@@ -603,7 +604,7 @@ u_int16_t iso_cksum(void *, u_int16_t, u_int16_t);
/* kroute.c */
int kif_init(void);
-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);
diff --git a/usr.sbin/ospfd/parse.y b/usr.sbin/ospfd/parse.y
index a586260dd7b..9d97031d35c 100644
--- a/usr.sbin/ospfd/parse.y
+++ b/usr.sbin/ospfd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.66 2009/03/31 21:03:49 tobias Exp $ */
+/* $OpenBSD: parse.y,v 1.67 2009/06/05 04:12:52 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -115,7 +115,7 @@ typedef struct {
%}
-%token AREA INTERFACE ROUTERID FIBUPDATE REDISTRIBUTE RTLABEL
+%token AREA INTERFACE ROUTERID FIBUPDATE REDISTRIBUTE RTLABEL RDOMAIN
%token RFC1583COMPAT STUB ROUTER SPFDELAY SPFHOLDTIME EXTTAG
%token AUTHKEY AUTHTYPE AUTHMD AUTHMDKEYID
%token METRIC PASSIVE
@@ -199,6 +199,13 @@ conf_main : ROUTERID STRING {
rtlabel_tag(rtlabel_name2id($2), $4);
free($2);
}
+ | RDOMAIN NUMBER {
+ if ($2 < 0 || $2 > RT_TABLEID_MAX) {
+ yyerror("invalid rdomain");
+ YYERROR;
+ }
+ conf->rdomain = $2;
+ }
| RFC1583COMPAT yesno {
conf->rfc1583compat = $2;
}
@@ -671,6 +678,7 @@ lookup(char *s)
{"metric", METRIC},
{"no", NO},
{"passive", PASSIVE},
+ {"rdomain", RDOMAIN},
{"redistribute", REDISTRIBUTE},
{"retransmit-interval", RETRANSMITINTERVAL},
{"rfc1583compat", RFC1583COMPAT},