summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorremi <remi@openbsd.org>2019-11-19 09:55:55 +0000
committerremi <remi@openbsd.org>2019-11-19 09:55:55 +0000
commitef209401b48f7dc21574553bf315697ddc93c292 (patch)
tree751d70d4fe9577c2cd48b788a057504a85d38535
parenttypo (result was bootblocks from / always installed into media); from miod (diff)
downloadwireguard-openbsd-ef209401b48f7dc21574553bf315697ddc93c292.tar.xz
wireguard-openbsd-ef209401b48f7dc21574553bf315697ddc93c292.zip
Add point-to-point support for broadcast interfaces.
tested by Kapetanakis Giannis ok claudio@
-rw-r--r--usr.sbin/ospfd/hello.c6
-rw-r--r--usr.sbin/ospfd/lsupdate.c4
-rw-r--r--usr.sbin/ospfd/neighbor.c3
-rw-r--r--usr.sbin/ospfd/ospfd.c11
-rw-r--r--usr.sbin/ospfd/ospfd.conf.57
-rw-r--r--usr.sbin/ospfd/ospfd.h4
-rw-r--r--usr.sbin/ospfd/parse.y9
-rw-r--r--usr.sbin/ospfd/printconf.c5
-rw-r--r--usr.sbin/ospfd/rde.c14
-rw-r--r--usr.sbin/ospfd/rde.h3
-rw-r--r--usr.sbin/ospfd/rde_spf.c15
11 files changed, 63 insertions, 18 deletions
diff --git a/usr.sbin/ospfd/hello.c b/usr.sbin/ospfd/hello.c
index 9ae07cd4f91..7267a56529b 100644
--- a/usr.sbin/ospfd/hello.c
+++ b/usr.sbin/ospfd/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.24 2019/08/12 20:21:58 remi Exp $ */
+/* $OpenBSD: hello.c,v 1.25 2019/11/19 09:55:55 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -191,12 +191,16 @@ recv_hello(struct iface *iface, struct in_addr src, u_int32_t rtr_id, char *buf,
nbr->priority = hello.rtr_priority;
/* XXX neighbor address shouldn't be stored on virtual links */
nbr->addr.s_addr = src.s_addr;
+ ospfe_imsg_compose_rde(IMSG_NEIGHBOR_ADDR, nbr->peerid, 0,
+ &src, sizeof(src));
}
if (nbr->addr.s_addr != src.s_addr) {
log_warnx("%s: neighbor ID %s changed its IP address",
__func__, inet_ntoa(nbr->id));
nbr->addr.s_addr = src.s_addr;
+ ospfe_imsg_compose_rde(IMSG_NEIGHBOR_ADDR, nbr->peerid, 0,
+ &src, sizeof(src));
}
nbr->options = hello.opts;
diff --git a/usr.sbin/ospfd/lsupdate.c b/usr.sbin/ospfd/lsupdate.c
index 2bd4e60ce01..953a070563e 100644
--- a/usr.sbin/ospfd/lsupdate.c
+++ b/usr.sbin/ospfd/lsupdate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lsupdate.c,v 1.46 2019/07/15 18:26:39 remi Exp $ */
+/* $OpenBSD: lsupdate.c,v 1.47 2019/11/19 09:55:55 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -470,7 +470,7 @@ ls_retrans_timer(int fd, short event, void *bula)
/* ls_retrans_list_free retriggers the timer */
return;
} else if (nbr->iface->type == IF_TYPE_POINTOPOINT)
- memcpy(&addr, &nbr->iface->dst, sizeof(addr));
+ memcpy(&addr, &nbr->addr, sizeof(addr));
else
inet_aton(AllDRouters, &addr);
} else
diff --git a/usr.sbin/ospfd/neighbor.c b/usr.sbin/ospfd/neighbor.c
index 587dfd1ab8a..b2c1df65bcb 100644
--- a/usr.sbin/ospfd/neighbor.c
+++ b/usr.sbin/ospfd/neighbor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: neighbor.c,v 1.48 2018/02/09 02:14:03 claudio Exp $ */
+/* $OpenBSD: neighbor.c,v 1.49 2019/11/19 09:55:55 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -312,6 +312,7 @@ nbr_new(u_int32_t nbr_id, struct iface *iface, int self)
bzero(&rn, sizeof(rn));
rn.id.s_addr = nbr->id.s_addr;
rn.area_id.s_addr = nbr->iface->area->id.s_addr;
+ rn.addr.s_addr = nbr->addr.s_addr;
rn.ifindex = nbr->iface->ifindex;
rn.state = nbr->state;
rn.self = self;
diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c
index fb933af6a33..e18834498fe 100644
--- a/usr.sbin/ospfd/ospfd.c
+++ b/usr.sbin/ospfd/ospfd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.c,v 1.108 2019/05/16 05:49:22 denis Exp $ */
+/* $OpenBSD: ospfd.c,v 1.109 2019/11/19 09:55:55 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -911,6 +911,15 @@ merge_interfaces(struct area *a, struct area *xa)
if_fsm(i, IF_EVT_UP);
}
+ if (i->p2p != xi->p2p) {
+ /* restart interface to enable or disable DR election */
+ if (ospfd_process == PROC_OSPF_ENGINE)
+ if_fsm(i, IF_EVT_DOWN);
+ i->p2p = xi->p2p;
+ if (ospfd_process == PROC_OSPF_ENGINE)
+ if_fsm(i, IF_EVT_UP);
+ }
+
strlcpy(i->dependon, xi->dependon,
sizeof(i->dependon));
i->depend_ok = xi->depend_ok;
diff --git a/usr.sbin/ospfd/ospfd.conf.5 b/usr.sbin/ospfd/ospfd.conf.5
index 1e88260acfb..1e9d3c6828f 100644
--- a/usr.sbin/ospfd/ospfd.conf.5
+++ b/usr.sbin/ospfd/ospfd.conf.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ospfd.conf.5,v 1.57 2019/06/10 06:07:15 jmc Exp $
+.\" $OpenBSD: ospfd.conf.5,v 1.58 2019/11/19 09:55:55 remi Exp $
.\"
.\" Copyright (c) 2005 Esben Norby <norby@openbsd.org>
.\" Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -17,7 +17,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: June 10 2019 $
+.Dd $Mdocdate: November 19 2019 $
.Dt OSPFD.CONF 5
.Os
.Sh NAME
@@ -419,6 +419,9 @@ Router.
.It Ic transmit-delay Ar seconds
Set the transmit delay.
The default value is 1; valid range is 1\-3600 seconds.
+.It Ic type p2p
+Set the interface type to point to point.
+This disables the election of a DR and BDR for the given interface.
.El
.Sh FILES
.Bl -tag -width "/etc/ospfd.conf" -compact
diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h
index 0088a788b53..27236a6c70b 100644
--- a/usr.sbin/ospfd/ospfd.h
+++ b/usr.sbin/ospfd/ospfd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.h,v 1.104 2019/05/16 05:49:22 denis Exp $ */
+/* $OpenBSD: ospfd.h,v 1.105 2019/11/19 09:55:55 remi Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -107,6 +107,7 @@ enum imsg_type {
IMSG_IFINFO,
IMSG_NEIGHBOR_UP,
IMSG_NEIGHBOR_DOWN,
+ IMSG_NEIGHBOR_ADDR,
IMSG_NEIGHBOR_CHANGE,
IMSG_NEIGHBOR_CAPA,
IMSG_NETWORK_ADD,
@@ -363,6 +364,7 @@ struct iface {
u_int8_t linkstate;
u_int8_t priority;
u_int8_t passive;
+ u_int8_t p2p;
};
struct ifaddrchange {
diff --git a/usr.sbin/ospfd/parse.y b/usr.sbin/ospfd/parse.y
index 7d83c531017..6e4092d3f36 100644
--- a/usr.sbin/ospfd/parse.y
+++ b/usr.sbin/ospfd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.98 2019/06/07 04:57:45 dlg Exp $ */
+/* $OpenBSD: parse.y,v 1.99 2019/11/19 09:55:55 remi Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -129,7 +129,7 @@ typedef struct {
%token AREA INTERFACE ROUTERID FIBPRIORITY FIBUPDATE REDISTRIBUTE RTLABEL
%token RDOMAIN RFC1583COMPAT STUB ROUTER SPFDELAY SPFHOLDTIME EXTTAG
%token AUTHKEY AUTHTYPE AUTHMD AUTHMDKEYID
-%token METRIC PASSIVE
+%token METRIC P2P PASSIVE
%token HELLOINTERVAL FASTHELLOINTERVAL TRANSMITDELAY
%token RETRANSMITINTERVAL ROUTERDEADTIME ROUTERPRIORITY
%token SET TYPE
@@ -743,6 +743,10 @@ interfaceopts_l : interfaceopts_l interfaceoptsl nl
;
interfaceoptsl : PASSIVE { iface->passive = 1; }
+ | TYPE P2P {
+ iface->p2p = 1;
+ iface->type = IF_TYPE_POINTOPOINT;
+ }
| DEMOTE STRING {
if (strlcpy(iface->demote_group, $2,
sizeof(iface->demote_group)) >=
@@ -833,6 +837,7 @@ lookup(char *s)
{"msec", MSEC},
{"no", NO},
{"on", ON},
+ {"p2p", P2P},
{"passive", PASSIVE},
{"rdomain", RDOMAIN},
{"redistribute", REDISTRIBUTE},
diff --git a/usr.sbin/ospfd/printconf.c b/usr.sbin/ospfd/printconf.c
index 93ed4e68e4b..6c8635e4940 100644
--- a/usr.sbin/ospfd/printconf.c
+++ b/usr.sbin/ospfd/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.20 2018/12/28 19:25:10 remi Exp $ */
+/* $OpenBSD: printconf.c,v 1.21 2019/11/19 09:55:55 remi Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -149,6 +149,9 @@ print_iface(struct iface *iface)
printf("\t\trouter-priority %d\n", iface->priority);
printf("\t\ttransmit-delay %d\n", iface->transmit_delay);
+ if (iface->p2p)
+ printf("\t\ttype p2p\n");
+
printf("\t\tauth-type %s\n", if_auth_name(iface->auth_type));
switch (iface->auth_type) {
case AUTH_TYPE_NONE:
diff --git a/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c
index 6ff3edc9183..040ba4545a9 100644
--- a/usr.sbin/ospfd/rde.c
+++ b/usr.sbin/ospfd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.109 2018/02/05 12:11:28 remi Exp $ */
+/* $OpenBSD: rde.c,v 1.110 2019/11/19 09:55:55 remi Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -257,6 +257,7 @@ rde_dispatch_imsg(int fd, short event, void *bula)
struct timespec tp;
struct lsa *lsa;
struct area *area;
+ struct in_addr addr;
struct vertex *v;
char *buf;
ssize_t n;
@@ -301,6 +302,17 @@ rde_dispatch_imsg(int fd, short event, void *bula)
case IMSG_NEIGHBOR_DOWN:
rde_nbr_del(rde_nbr_find(imsg.hdr.peerid));
break;
+ case IMSG_NEIGHBOR_ADDR:
+ if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(addr))
+ fatalx("invalid size of OE request");
+ memcpy(&addr, imsg.data, sizeof(addr));
+
+ nbr = rde_nbr_find(imsg.hdr.peerid);
+ if (nbr == NULL)
+ break;
+
+ nbr->addr.s_addr = addr.s_addr;
+ break;
case IMSG_NEIGHBOR_CHANGE:
if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(state))
fatalx("invalid size of OE request");
diff --git a/usr.sbin/ospfd/rde.h b/usr.sbin/ospfd/rde.h
index 63c27699196..9cc8e216f1f 100644
--- a/usr.sbin/ospfd/rde.h
+++ b/usr.sbin/ospfd/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.39 2015/03/14 02:22:09 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.40 2019/11/19 09:55:55 remi Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -66,6 +66,7 @@ struct rde_nbr {
LIST_ENTRY(rde_nbr) entry, hash;
struct in_addr id;
struct in_addr area_id;
+ struct in_addr addr;
TAILQ_HEAD(, rde_req_entry) req_list;
struct area *area;
struct iface *iface;
diff --git a/usr.sbin/ospfd/rde_spf.c b/usr.sbin/ospfd/rde_spf.c
index 874cdc345cd..c4da6e4fc02 100644
--- a/usr.sbin/ospfd/rde_spf.c
+++ b/usr.sbin/ospfd/rde_spf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_spf.c,v 1.77 2019/04/04 19:57:08 remi Exp $ */
+/* $OpenBSD: rde_spf.c,v 1.78 2019/11/19 09:55:55 remi Exp $ */
/*
* Copyright (c) 2005 Esben Norby <norby@openbsd.org>
@@ -373,6 +373,7 @@ calc_nexthop(struct vertex *dst, struct vertex *parent,
{
struct v_nexthop *vn;
struct iface *iface;
+ struct rde_nbr *nbr;
int i;
/* case 1 */
@@ -382,10 +383,14 @@ calc_nexthop(struct vertex *dst, struct vertex *parent,
if (rtr_link->type != LINK_TYPE_POINTTOPOINT)
fatalx("inconsistent SPF tree");
LIST_FOREACH(iface, &area->iface_list, entry) {
- if (rtr_link->data == iface->addr.s_addr) {
- vertex_nexthop_add(dst, parent,
- iface->dst.s_addr);
- return;
+ if (rtr_link->data != iface->addr.s_addr)
+ continue;
+ LIST_FOREACH(nbr, &area->nbr_list, entry) {
+ if (nbr->ifindex == iface->ifindex) {
+ vertex_nexthop_add(dst, parent,
+ nbr->addr.s_addr);
+ return;
+ }
}
}
fatalx("no interface found for interface");