summaryrefslogtreecommitdiff
path: root/usr.sbin/eigrpd
diff options
context:
space:
mode:
authorRenato Westphal <renato@cvs.openbsd.org>2017-02-22 14:24:51 +0000
committerRenato Westphal <renato@cvs.openbsd.org>2017-02-22 14:24:51 +0000
commit53e576d6a7654dcaf7fd9114aea1349df9447773 (patch)
tree7c692640fa43a102b16e7962003f7c4960f1f444 /usr.sbin/eigrpd
parent04b9e1b5fd06f054e918d307176c342c041a65f7 (diff)
No need to use SIOCGIFRDOMAIN anymore.
Diffstat (limited to 'usr.sbin/eigrpd')
-rw-r--r--usr.sbin/eigrpd/eigrpd.h4
-rw-r--r--usr.sbin/eigrpd/eigrpe.h3
-rw-r--r--usr.sbin/eigrpd/interface.c23
-rw-r--r--usr.sbin/eigrpd/kroute.c3
-rw-r--r--usr.sbin/eigrpd/parse.y23
5 files changed, 30 insertions, 26 deletions
diff --git a/usr.sbin/eigrpd/eigrpd.h b/usr.sbin/eigrpd/eigrpd.h
index f5b2a94375b..406365907ba 100644
--- a/usr.sbin/eigrpd/eigrpd.h
+++ b/usr.sbin/eigrpd/eigrpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: eigrpd.h,v 1.22 2016/09/02 17:59:58 benno Exp $ */
+/* $OpenBSD: eigrpd.h,v 1.23 2017/02/22 14:24:50 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -164,6 +164,7 @@ struct iface {
TAILQ_ENTRY(iface) entry;
TAILQ_HEAD(, eigrp_iface) ei_list;
unsigned int ifindex;
+ unsigned int rdomain;
char name[IF_NAMESIZE];
struct if_addr_head addr_list;
struct in6_addr linklocal;
@@ -368,6 +369,7 @@ struct kif {
int flags;
uint8_t link_state;
int mtu;
+ unsigned int rdomain;
uint8_t if_type;
uint64_t baudrate;
uint8_t nh_reachable; /* for nexthop verification */
diff --git a/usr.sbin/eigrpd/eigrpe.h b/usr.sbin/eigrpd/eigrpe.h
index 06ca905780f..f2825d37ca5 100644
--- a/usr.sbin/eigrpd/eigrpe.h
+++ b/usr.sbin/eigrpd/eigrpe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: eigrpe.h,v 1.15 2016/09/02 16:46:29 renato Exp $ */
+/* $OpenBSD: eigrpe.h,v 1.16 2017/02/22 14:24:50 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -91,7 +91,6 @@ void eigrpe_stats_ctl(struct ctl_conn *);
/* interface.c */
struct iface *if_lookup(struct eigrpd_conf *, unsigned int);
-void if_init(struct eigrpd_conf *, struct iface *);
void if_addr_new(struct iface *, struct kaddr *);
void if_addr_del(struct iface *, struct kaddr *);
in_addr_t if_primary_addr(struct iface *);
diff --git a/usr.sbin/eigrpd/interface.c b/usr.sbin/eigrpd/interface.c
index 73077233be2..6075cc93cad 100644
--- a/usr.sbin/eigrpd/interface.c
+++ b/usr.sbin/eigrpd/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.23 2016/09/02 16:44:33 renato Exp $ */
+/* $OpenBSD: interface.c,v 1.24 2017/02/22 14:24:50 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -82,6 +82,7 @@ if_new(struct eigrpd_conf *xconf, struct kif *kif)
/* get index and flags */
iface->mtu = kif->mtu;
iface->ifindex = kif->ifindex;
+ iface->rdomain = kif->rdomain;
iface->flags = kif->flags;
iface->linkstate = kif->link_state;
iface->if_type = kif->if_type;
@@ -121,26 +122,6 @@ if_lookup(struct eigrpd_conf *xconf, unsigned int ifindex)
}
void
-if_init(struct eigrpd_conf *xconf, struct iface *iface)
-{
- struct ifreq ifr;
- unsigned int rdomain;
-
- /* set rdomain */
- strlcpy(ifr.ifr_name, iface->name, sizeof(ifr.ifr_name));
- if (ioctl(global.eigrp_socket_v4, SIOCGIFRDOMAIN, (caddr_t)&ifr) == -1)
- rdomain = 0;
- else {
- rdomain = ifr.ifr_rdomainid;
- if (setsockopt(global.eigrp_socket_v4, SOL_SOCKET, SO_RTABLE,
- &rdomain, sizeof(rdomain)) == -1)
- fatal("failed to set rdomain");
- }
- if (rdomain != xconf->rdomain)
- fatalx("interface rdomain mismatch");
-}
-
-void
if_addr_new(struct iface *iface, struct kaddr *ka)
{
struct if_addr *if_addr;
diff --git a/usr.sbin/eigrpd/kroute.c b/usr.sbin/eigrpd/kroute.c
index d7602f37909..fb7511937dc 100644
--- a/usr.sbin/eigrpd/kroute.c
+++ b/usr.sbin/eigrpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.16 2016/09/02 16:44:33 renato Exp $ */
+/* $OpenBSD: kroute.c,v 1.17 2017/02/22 14:24:50 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -737,6 +737,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))
diff --git a/usr.sbin/eigrpd/parse.y b/usr.sbin/eigrpd/parse.y
index 270f266d0ff..ea9e5b18163 100644
--- a/usr.sbin/eigrpd/parse.y
+++ b/usr.sbin/eigrpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.21 2017/01/05 13:53:09 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.22 2017/02/22 14:24:50 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -102,6 +102,7 @@ static int symset(const char *, const char *, int);
static char *symget(const char *);
static struct eigrp *conf_get_instance(uint16_t);
static struct eigrp_iface *conf_get_if(struct kif *);
+int conf_check_rdomain(unsigned int);
static void clear_config(struct eigrpd_conf *xconf);
static uint32_t get_rtr_id(void);
static int get_prefix(const char *, union eigrpd_addr *, uint8_t *);
@@ -1000,6 +1001,9 @@ parse_config(char *filename)
}
}
+ /* check that all interfaces belong to the configured rdomain */
+ errors += conf_check_rdomain(conf->rdomain);
+
if (errors) {
clear_config(conf);
return (NULL);
@@ -1144,6 +1148,23 @@ conf_get_if(struct kif *kif)
return (e);
}
+int
+conf_check_rdomain(unsigned int rdomain)
+{
+ struct iface *iface;
+ int errs = 0;
+
+ TAILQ_FOREACH(iface, &conf->iface_list, entry) {
+ if (iface->rdomain != rdomain) {
+ logit(LOG_CRIT, "interface %s not in rdomain %u",
+ iface->name, rdomain);
+ errs++;
+ }
+ }
+
+ return (errs);
+}
+
static void
clear_config(struct eigrpd_conf *xconf)
{