-/* $OpenBSD: session.c,v 1.363 2017/05/28 20:10:59 claudio Exp $ */
+/* $OpenBSD: session.c,v 1.364 2017/05/29 14:22:51 benno Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
void session_up(struct peer *);
void session_down(struct peer *);
void session_demote(struct peer *, int);
+int session_link_state_is_up(int, int, int);
int la_cmp(struct listen_addr *, struct listen_addr *);
struct peer *getpeerbyip(struct sockaddr *);
sizeof(struct kif))
fatalx("IFINFO imsg with wrong len");
kif = imsg.data;
- depend_ok = (kif->flags & IFF_UP) &&
- LINK_STATE_IS_UP(kif->link_state);
+ depend_ok = session_link_state_is_up(kif->flags,
+ kif->if_type, kif->link_state);
for (p = peers; p != NULL; p = p->next)
if (!strcmp(p->conf.if_depend, kif->ifname)) {
}
bgp_fsm(peer, EVNT_STOP);
}
+
+/*
+ * return 1 when the interface is up
+ * and the link state is up or unknwown
+ * except when this is a carp interface, then
+ * return 1 only when link state is up
+ */
+int
+session_link_state_is_up(int flags, int type, int link_state)
+{
+ if (!(flags & IFF_UP))
+ return (0);
+
+ if (type == IFT_CARP &&
+ link_state == LINK_STATE_UNKNOWN)
+ return (0);
+
+ return LINK_STATE_IS_UP(link_state);
+}