diff options
author | 2015-07-20 23:45:39 +0000 | |
---|---|---|
committer | 2015-07-20 23:45:39 +0000 | |
commit | 3a9b53d2524d2bb3ddb52bb33f72d95cdc1c2507 (patch) | |
tree | fa44291c83fa6225e8722e3238f0c91155acb342 | |
parent | Use the kernel socket interface (sosend(9) etc) instead of shoving (diff) | |
download | wireguard-openbsd-3a9b53d2524d2bb3ddb52bb33f72d95cdc1c2507.tar.xz wireguard-openbsd-3a9b53d2524d2bb3ddb52bb33f72d95cdc1c2507.zip |
Fix a segfault at startup when if_change() ist called before
imsg_init() exposed by the second part of this diff which makes
carp(4) interfaces be recognized to be in "backup" mode on start-up.
Problem analyzed and fix provided by Johan Ymerson, thanks!
ok claudio@, mpi@
-rw-r--r-- | usr.sbin/ospfd/interface.c | 8 | ||||
-rw-r--r-- | usr.sbin/ospfd/kroute.c | 8 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfd.c | 8 |
3 files changed, 14 insertions, 10 deletions
diff --git a/usr.sbin/ospfd/interface.c b/usr.sbin/ospfd/interface.c index 4afaa2074b4..8c0849ebc2a 100644 --- a/usr.sbin/ospfd/interface.c +++ b/usr.sbin/ospfd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.77 2015/07/19 01:59:32 benno Exp $ */ +/* $OpenBSD: interface.c,v 1.78 2015/07/20 23:45:39 benno Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -338,8 +338,10 @@ if_act_start(struct iface *iface) struct in_addr addr; struct timeval now; - if (!((iface->flags & IFF_UP) && - LINK_STATE_IS_UP(iface->linkstate))) + if (!(iface->flags & IFF_UP) || + (!LINK_STATE_IS_UP(iface->linkstate) && + !(iface->media_type == IFT_CARP && + iface->linkstate == LINK_STATE_DOWN))) return (0); if (iface->media_type == IFT_CARP && iface->passive == 0) { diff --git a/usr.sbin/ospfd/kroute.c b/usr.sbin/ospfd/kroute.c index a200d994206..101d6ca53c3 100644 --- a/usr.sbin/ospfd/kroute.c +++ b/usr.sbin/ospfd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.101 2015/07/19 01:59:32 benno Exp $ */ +/* $OpenBSD: kroute.c,v 1.102 2015/07/20 23:45:39 benno Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -1019,6 +1019,9 @@ if_change(u_short ifindex, int flags, struct if_data *ifd, return; } + /* notify ospfe about interface link state */ + main_imsg_compose_ospfe(IMSG_IFINFO, 0, kif, sizeof(struct kif)); + reachable = (kif->flags & IFF_UP) && LINK_STATE_IS_UP(kif->link_state); @@ -1027,9 +1030,6 @@ if_change(u_short ifindex, int flags, struct if_data *ifd, kif->nh_reachable = reachable; - /* notify ospfe about interface link state */ - main_imsg_compose_ospfe(IMSG_IFINFO, 0, kif, sizeof(struct kif)); - /* update redistribute list */ RB_FOREACH(kr, kroute_tree, &krt) { for (tkr = kr; tkr != NULL; tkr = tkr->next) { diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c index 48707cc752f..7fdf9327826 100644 --- a/usr.sbin/ospfd/ospfd.c +++ b/usr.sbin/ospfd/ospfd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.c,v 1.84 2015/03/14 02:22:09 claudio Exp $ */ +/* $OpenBSD: ospfd.c,v 1.85 2015/07/20 23:45:39 benno Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -511,13 +511,15 @@ main_dispatch_rde(int fd, short event, void *bula) void main_imsg_compose_ospfe(int type, pid_t pid, void *data, u_int16_t datalen) { - imsg_compose_event(iev_ospfe, type, 0, pid, -1, data, datalen); + if (iev_ospfe) + imsg_compose_event(iev_ospfe, type, 0, pid, -1, data, datalen); } void main_imsg_compose_rde(int type, pid_t pid, void *data, u_int16_t datalen) { - imsg_compose_event(iev_rde, type, 0, pid, -1, data, datalen); + if (iev_rde) + imsg_compose_event(iev_rde, type, 0, pid, -1, data, datalen); } void |