summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ospfd/interface.c
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2010-02-16 18:20:37 +0000
committerclaudio <claudio@openbsd.org>2010-02-16 18:20:37 +0000
commit45daa23a55c3cc384cb6e9f4768d1cec6d6a8885 (patch)
tree3717fe212f8c359643d262d8acfefdea5583ee40 /usr.sbin/ospfd/interface.c
parentOnly merge interfaces that have the same address and netmask. Fixes a bug (diff)
downloadwireguard-openbsd-45daa23a55c3cc384cb6e9f4768d1cec6d6a8885.tar.xz
wireguard-openbsd-45daa23a55c3cc384cb6e9f4768d1cec6d6a8885.zip
When taking an interface down just try to do the cleanup. In cases where
the interface was removed or when the address changed leaving the multicast groups will fail because that already happend. Fix if_leave_group() to remove the refcount before doing the ioctl() so that the reference is correctly removed. OK dlg@, sthen@
Diffstat (limited to 'usr.sbin/ospfd/interface.c')
-rw-r--r--usr.sbin/ospfd/interface.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/usr.sbin/ospfd/interface.c b/usr.sbin/ospfd/interface.c
index 92a9e6f1ee2..9ffdadbc24f 100644
--- a/usr.sbin/ospfd/interface.c
+++ b/usr.sbin/ospfd/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.67 2010/02/16 08:39:05 dlg Exp $ */
+/* $OpenBSD: interface.c,v 1.68 2010/02/16 18:20:37 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -551,18 +551,12 @@ if_act_reset(struct iface *iface)
switch (iface->type) {
case IF_TYPE_POINTOPOINT:
case IF_TYPE_BROADCAST:
+ /* try to cleanup */
inet_aton(AllSPFRouters, &addr);
- if (if_leave_group(iface, &addr)) {
- log_warnx("if_act_reset: error leaving group %s, "
- "interface %s", inet_ntoa(addr), iface->name);
- }
+ if_leave_group(iface, &addr);
if (iface->state & IF_STA_DRORBDR) {
inet_aton(AllDRouters, &addr);
- if (if_leave_group(iface, &addr)) {
- log_warnx("if_act_reset: "
- "error leaving group %s, interface %s",
- inet_ntoa(addr), iface->name);
- }
+ if_leave_group(iface, &addr);
}
break;
case IF_TYPE_VIRTUALLINK:
@@ -781,9 +775,14 @@ if_leave_group(struct iface *iface, struct in_addr *addr)
break;
/* if interface is not found just try to drop membership */
- if (ifg && --ifg->count != 0)
- /* others still joined */
- return (0);
+ if (ifg) {
+ if (--ifg->count != 0)
+ /* others still joined */
+ return (0);
+
+ LIST_REMOVE(ifg, entry);
+ free(ifg);
+ }
mreq.imr_multiaddr.s_addr = addr->s_addr;
mreq.imr_interface.s_addr = iface->addr.s_addr;
@@ -795,11 +794,6 @@ if_leave_group(struct iface *iface, struct in_addr *addr)
inet_ntoa(*addr));
return (-1);
}
-
- if (ifg) {
- LIST_REMOVE(ifg, entry);
- free(ifg);
- }
break;
case IF_TYPE_POINTOMULTIPOINT:
case IF_TYPE_VIRTUALLINK:
@@ -822,7 +816,7 @@ if_set_mcast(struct iface *iface)
case IF_TYPE_BROADCAST:
if (setsockopt(iface->fd, IPPROTO_IP, IP_MULTICAST_IF,
&iface->addr.s_addr, sizeof(iface->addr.s_addr)) < 0) {
- log_debug("if_set_mcast: error setting "
+ log_warn("if_set_mcast: error setting "
"IP_MULTICAST_IF, interface %s", iface->name);
return (-1);
}