summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2006-11-28 19:21:15 +0000
committerreyk <reyk@openbsd.org>2006-11-28 19:21:15 +0000
commit307627386806be0bc5eb7752d727b7ee499ed0a7 (patch)
tree9f8c64c381831baefec1b2e0e88a0893c9706702
parentSupport "trace /p <pid>" to show the stack trace of any process. (diff)
downloadwireguard-openbsd-307627386806be0bc5eb7752d727b7ee499ed0a7.tar.xz
wireguard-openbsd-307627386806be0bc5eb7752d727b7ee499ed0a7.zip
add additional link states to report the half duplex / full duplex
state, if known by the driver. this is required to check the full duplex state without depending on the ifmedia ioctl which can't be called in the kernel without process context. ok henning@, brad@
-rw-r--r--sbin/route/route.c6
-rw-r--r--sys/dev/mii/mii_physubr.c13
-rw-r--r--sys/net/if.h5
-rw-r--r--usr.bin/systat/if.c4
-rw-r--r--usr.sbin/bgpctl/bgpctl.c6
-rw-r--r--usr.sbin/bgpd/session.c4
-rw-r--r--usr.sbin/dvmrpctl/dvmrpctl.c6
-rw-r--r--usr.sbin/dvmrpd/kroute.c4
-rw-r--r--usr.sbin/ospfctl/ospfctl.c6
-rw-r--r--usr.sbin/ospfd/interface.c4
-rw-r--r--usr.sbin/ospfd/kroute.c6
-rw-r--r--usr.sbin/ospfd/ospfe.c6
-rw-r--r--usr.sbin/ripctl/ripctl.c6
-rw-r--r--usr.sbin/ripd/interface.c4
-rw-r--r--usr.sbin/ripd/kroute.c6
-rw-r--r--usr.sbin/ripd/ripe.c4
-rw-r--r--usr.sbin/sasyncd/carp.c4
17 files changed, 58 insertions, 36 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index 52de6ed65be..b75cfa2550a 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.103 2006/11/28 16:48:13 henning Exp $ */
+/* $OpenBSD: route.c,v 1.104 2006/11/28 19:21:15 reyk Exp $ */
/* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */
/*
@@ -1112,7 +1112,9 @@ get_linkstate(int mt, int link_state)
if (p->ifms_type != media_type ||
p->ifms_valid != ifm_status_valid_list[i])
continue;
- return (p->ifms_string[link_state == LINK_STATE_UP]);
+ if (LINK_STATE_IS_UP(link_state))
+ return (p->ifms_string[1]);
+ return (p->ifms_string[0]);
}
}
diff --git a/sys/dev/mii/mii_physubr.c b/sys/dev/mii/mii_physubr.c
index 7819763afe3..b243abb64af 100644
--- a/sys/dev/mii/mii_physubr.c
+++ b/sys/dev/mii/mii_physubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mii_physubr.c,v 1.27 2005/11/06 21:46:18 brad Exp $ */
+/* $OpenBSD: mii_physubr.c,v 1.28 2006/11/28 19:21:15 reyk Exp $ */
/* $NetBSD: mii_physubr.c,v 1.20 2001/04/13 23:30:09 thorpej Exp $ */
/*-
@@ -350,9 +350,14 @@ mii_phy_statusmsg(struct mii_softc *sc)
int baudrate, link_state, announce = 0;
if (mii->mii_media_status & IFM_AVALID) {
- if (mii->mii_media_status & IFM_ACTIVE)
- link_state = LINK_STATE_UP;
- else
+ if (mii->mii_media_status & IFM_ACTIVE) {
+ if (mii->mii_media_status & IFM_FDX)
+ link_state = LINK_STATE_FULL_DUPLEX;
+ else if (mii->mii_media_status & IFM_HDX)
+ link_state = LINK_STATE_HALF_DUPLEX;
+ else
+ link_state = LINK_STATE_UP;
+ } else
link_state = LINK_STATE_DOWN;
} else
link_state = LINK_STATE_UNKNOWN;
diff --git a/sys/net/if.h b/sys/net/if.h
index ddc6f8d76a8..5c6026faba0 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.h,v 1.84 2006/11/16 13:09:27 henning Exp $ */
+/* $OpenBSD: if.h,v 1.85 2006/11/28 19:21:15 reyk Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
@@ -150,6 +150,9 @@ struct ifqueue {
#define LINK_STATE_UNKNOWN 0 /* link invalid/unknown */
#define LINK_STATE_DOWN 1 /* link is down */
#define LINK_STATE_UP 2 /* link is up */
+#define LINK_STATE_HALF_DUPLEX 3 /* link is up and half duplex */
+#define LINK_STATE_FULL_DUPLEX 4 /* link is up and full duplex */
+#define LINK_STATE_IS_UP(_s) ((_s) >= LINK_STATE_UP)
/*
* Structure defining a queue for a network interface.
diff --git a/usr.bin/systat/if.c b/usr.bin/systat/if.c
index 59980b2d40e..886a959e32e 100644
--- a/usr.bin/systat/if.c
+++ b/usr.bin/systat/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.7 2006/06/02 08:16:51 claudio Exp $ */
+/* $OpenBSD: if.c,v 1.8 2006/11/28 19:21:15 reyk Exp $ */
/*
* Copyright (c) 2004 Markus Friedl <markus@openbsd.org>
*
@@ -206,6 +206,8 @@ showlinkstate(int state)
{
switch (state) {
case LINK_STATE_UP:
+ case LINK_STATE_HALF_DUPLEX:
+ case LINK_STATE_FULL_DUPLEX:
return (":U");
case LINK_STATE_DOWN:
return (":D");
diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c
index 1e6c68424e1..00e4e0fe45f 100644
--- a/usr.sbin/bgpctl/bgpctl.c
+++ b/usr.sbin/bgpctl/bgpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpctl.c,v 1.111 2006/11/10 14:46:46 henning Exp $ */
+/* $OpenBSD: bgpctl.c,v 1.112 2006/11/28 19:21:15 reyk Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -905,7 +905,9 @@ get_linkstate(int media_type, int link_state)
if (p->ifms_type != media_type ||
p->ifms_valid != ifm_status_valid_list[i])
continue;
- return (p->ifms_string[link_state == LINK_STATE_UP]);
+ if (LINK_STATE_IS_UP(link_state))
+ return (p->ifms_string[1]);
+ return (p->ifms_string[0]);
}
return ("unknown link state");
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index d039d227406..bab50fa616f 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.264 2006/11/06 14:07:35 henning Exp $ */
+/* $OpenBSD: session.c,v 1.265 2006/11/28 19:21:15 reyk Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -2322,7 +2322,7 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx, u_int *listener_cnt)
fatalx("IFINFO imsg with wrong len");
kif = imsg.data;
depend_ok = (kif->flags & IFF_UP) &&
- (kif->link_state == LINK_STATE_UP ||
+ (LINK_STATE_IS_UP(kif->link_state) ||
(kif->link_state == LINK_STATE_UNKNOWN &&
kif->media_type != IFT_CARP));
diff --git a/usr.sbin/dvmrpctl/dvmrpctl.c b/usr.sbin/dvmrpctl/dvmrpctl.c
index 6d75de6f2fa..1940e9d55ef 100644
--- a/usr.sbin/dvmrpctl/dvmrpctl.c
+++ b/usr.sbin/dvmrpctl/dvmrpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dvmrpctl.c,v 1.1 2006/06/01 14:21:28 norby Exp $ */
+/* $OpenBSD: dvmrpctl.c,v 1.2 2006/11/28 19:21:15 reyk Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -680,7 +680,9 @@ get_linkstate(int media_type, int link_state)
if (p->ifms_type != media_type ||
p->ifms_valid != ifm_status_valid_list[i])
continue;
- return (p->ifms_string[link_state == LINK_STATE_UP]);
+ if (LINK_STATE_IS_UP(link_state))
+ return (p->ifms_string[1]);
+ return (p->ifms_string[0]);
}
return ("unknown link state");
diff --git a/usr.sbin/dvmrpd/kroute.c b/usr.sbin/dvmrpd/kroute.c
index 3abc6102151..a8f61960ab2 100644
--- a/usr.sbin/dvmrpd/kroute.c
+++ b/usr.sbin/dvmrpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.3 2006/06/17 11:39:52 norby Exp $ */
+/* $OpenBSD: kroute.c,v 1.4 2006/11/28 19:21:15 reyk Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -347,7 +347,7 @@ fetchifs(int ifindex)
kif->k.baudrate = ifm.ifm_data.ifi_baudrate;
kif->k.mtu = ifm.ifm_data.ifi_mtu;
kif->k.nh_reachable = (kif->k.flags & IFF_UP) &&
- (ifm.ifm_data.ifi_link_state == LINK_STATE_UP ||
+ (LINK_STATE_IS_UP(ifm.ifm_data.ifi_link_state) ||
(ifm.ifm_data.ifi_link_state == LINK_STATE_UNKNOWN &&
ifm.ifm_data.ifi_type != IFT_CARP));
if ((sa = rti_info[RTAX_IFP]) != NULL)
diff --git a/usr.sbin/ospfctl/ospfctl.c b/usr.sbin/ospfctl/ospfctl.c
index 47777fe638d..f8bfaaf3b2e 100644
--- a/usr.sbin/ospfctl/ospfctl.c
+++ b/usr.sbin/ospfctl/ospfctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfctl.c,v 1.35 2006/08/23 08:26:03 claudio Exp $ */
+/* $OpenBSD: ospfctl.c,v 1.36 2006/11/28 19:21:15 reyk Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -1198,7 +1198,9 @@ get_linkstate(int media_type, int link_state)
if (p->ifms_type != media_type ||
p->ifms_valid != ifm_status_valid_list[i])
continue;
- return (p->ifms_string[link_state == LINK_STATE_UP]);
+ if (LINK_STATE_IS_UP(link_state))
+ return (p->ifms_string[1]);
+ return (p->ifms_string[0]);
}
return ("unknown");
diff --git a/usr.sbin/ospfd/interface.c b/usr.sbin/ospfd/interface.c
index f2e952e137a..30662c5164d 100644
--- a/usr.sbin/ospfd/interface.c
+++ b/usr.sbin/ospfd/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.54 2006/11/17 08:55:31 claudio Exp $ */
+/* $OpenBSD: interface.c,v 1.55 2006/11/28 19:21:15 reyk Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -301,7 +301,7 @@ if_act_start(struct iface *iface)
struct timeval now;
if (!((iface->flags & IFF_UP) &&
- (iface->linkstate == LINK_STATE_UP ||
+ (LINK_STATE_IS_UP(iface->linkstate) ||
(iface->linkstate == LINK_STATE_UNKNOWN &&
iface->media_type != IFT_CARP)))) {
log_debug("if_act_start: interface %s link down",
diff --git a/usr.sbin/ospfd/kroute.c b/usr.sbin/ospfd/kroute.c
index cb74def38fc..ee0ae0d9a9d 100644
--- a/usr.sbin/ospfd/kroute.c
+++ b/usr.sbin/ospfd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.36 2006/11/28 16:36:58 henning Exp $ */
+/* $OpenBSD: kroute.c,v 1.37 2006/11/28 19:21:15 reyk Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -674,7 +674,7 @@ if_change(u_short ifindex, int flags, struct if_data *ifd)
kif->k.baudrate = ifd->ifi_baudrate;
if ((reachable = (flags & IFF_UP) &&
- (ifd->ifi_link_state == LINK_STATE_UP ||
+ (LINK_STATE_IS_UP(ifd->ifi_link_state) ||
(ifd->ifi_link_state == LINK_STATE_UNKNOWN &&
ifd->ifi_type != IFT_CARP))) == kif->k.nh_reachable)
return; /* nothing changed wrt nexthop validity */
@@ -967,7 +967,7 @@ fetchifs(int ifindex)
kif->k.baudrate = ifm->ifm_data.ifi_baudrate;
kif->k.mtu = ifm->ifm_data.ifi_mtu;
kif->k.nh_reachable = (kif->k.flags & IFF_UP) &&
- (ifm->ifm_data.ifi_link_state == LINK_STATE_UP ||
+ (LINK_STATE_IS_UP(ifm->ifm_data.ifi_link_state) ||
(ifm->ifm_data.ifi_link_state ==
LINK_STATE_UNKNOWN &&
ifm->ifm_data.ifi_type != IFT_CARP));
diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c
index 471ccf60870..0059741af55 100644
--- a/usr.sbin/ospfd/ospfe.c
+++ b/usr.sbin/ospfd/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.49 2006/11/17 08:55:31 claudio Exp $ */
+/* $OpenBSD: ospfe.c,v 1.50 2006/11/28 19:21:15 reyk Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -280,7 +280,7 @@ ospfe_dispatch_main(int fd, short event, void *bula)
fatalx("IFINFO imsg with wrong len");
kif = imsg.data;
link_ok = (kif->flags & IFF_UP) &&
- (kif->link_state == LINK_STATE_UP ||
+ (LINK_STATE_IS_UP(kif->link_state) ||
(kif->link_state == LINK_STATE_UNKNOWN &&
kif->media_type != IFT_CARP));
@@ -735,7 +735,7 @@ orig_rtr_lsa(struct area *area)
if ((iface->flags & IFF_UP) == 0 ||
iface->linkstate == LINK_STATE_DOWN ||
- (iface->linkstate != LINK_STATE_UP &&
+ (!LINK_STATE_IS_UP(iface->linkstate) &&
iface->media_type == IFT_CARP))
continue;
diff --git a/usr.sbin/ripctl/ripctl.c b/usr.sbin/ripctl/ripctl.c
index d4ce6d45aa2..01eb123166a 100644
--- a/usr.sbin/ripctl/ripctl.c
+++ b/usr.sbin/ripctl/ripctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ripctl.c,v 1.1 2006/10/18 16:15:25 norby Exp $
+/* $OpenBSD: ripctl.c,v 1.2 2006/11/28 19:21:15 reyk Exp $
*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -519,7 +519,9 @@ get_linkstate(int media_type, int link_state)
if (p->ifms_type != media_type ||
p->ifms_valid != ifm_status_valid_list[i])
continue;
- return (p->ifms_string[link_state == LINK_STATE_UP]);
+ if (LINK_STATE_IS_UP(link_state))
+ return (p->ifms_string[1]);
+ return (p->ifms_string[0]);
}
return ("unknown link state");
diff --git a/usr.sbin/ripd/interface.c b/usr.sbin/ripd/interface.c
index be9917361ad..f5ecc524102 100644
--- a/usr.sbin/ripd/interface.c
+++ b/usr.sbin/ripd/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.1 2006/10/18 16:11:58 norby Exp $ */
+/* $OpenBSD: interface.c,v 1.2 2006/11/28 19:21:15 reyk Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -159,7 +159,7 @@ if_act_start(struct iface *iface)
}
if (!((iface->flags & IFF_UP) &&
- (iface->linkstate == LINK_STATE_UP ||
+ (LINK_STATE_IS_UP(iface->linkstate) ||
(iface->linkstate == LINK_STATE_UNKNOWN &&
iface->media_type != IFT_CARP)))) {
log_debug("if_act_start: interface %s link down",
diff --git a/usr.sbin/ripd/kroute.c b/usr.sbin/ripd/kroute.c
index f333186697c..a67848b4c22 100644
--- a/usr.sbin/ripd/kroute.c
+++ b/usr.sbin/ripd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.4 2006/11/28 16:36:58 henning Exp $ */
+/* $OpenBSD: kroute.c,v 1.5 2006/11/28 19:21:15 reyk Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -649,7 +649,7 @@ if_change(u_short ifindex, int flags, struct if_data *ifd)
kif->k.baudrate = ifd->ifi_baudrate;
if ((reachable = (flags & IFF_UP) &&
- (ifd->ifi_link_state == LINK_STATE_UP ||
+ (LINK_STATE_IS_UP(ifd->ifi_link_state) ||
(ifd->ifi_link_state == LINK_STATE_UNKNOWN &&
ifd->ifi_type != IFT_CARP))) == kif->k.nh_reachable)
return; /* nothing changed wrt nexthop validity */
@@ -942,7 +942,7 @@ fetchifs(int ifindex)
kif->k.baudrate = ifm.ifm_data.ifi_baudrate;
kif->k.mtu = ifm.ifm_data.ifi_mtu;
kif->k.nh_reachable = (kif->k.flags & IFF_UP) &&
- (ifm.ifm_data.ifi_link_state == LINK_STATE_UP ||
+ (LINK_STATE_IS_UP(ifm.ifm_data.ifi_link_state) ||
(ifm.ifm_data.ifi_link_state == LINK_STATE_UNKNOWN &&
ifm.ifm_data.ifi_type != IFT_CARP));
if ((sa = rti_info[RTAX_IFP]) != NULL)
diff --git a/usr.sbin/ripd/ripe.c b/usr.sbin/ripd/ripe.c
index 1d760bb263a..4abbb4040c2 100644
--- a/usr.sbin/ripd/ripe.c
+++ b/usr.sbin/ripd/ripe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ripe.c,v 1.3 2006/10/31 23:43:11 michele Exp $ */
+/* $OpenBSD: ripe.c,v 1.4 2006/11/28 19:21:16 reyk Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -250,7 +250,7 @@ ripe_dispatch_main(int fd, short event, void *bula)
fatalx("IFINFO imsg with wrong len");
kif = imsg.data;
link_ok = (kif->flags & IFF_UP) &&
- (kif->link_state == LINK_STATE_UP ||
+ (LINK_STATE_IS_UP(kif->link_state) ||
(kif->link_state == LINK_STATE_UNKNOWN &&
kif->media_type != IFT_CARP));
diff --git a/usr.sbin/sasyncd/carp.c b/usr.sbin/sasyncd/carp.c
index 974ea923dff..de876c0ea6f 100644
--- a/usr.sbin/sasyncd/carp.c
+++ b/usr.sbin/sasyncd/carp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: carp.c,v 1.7 2006/09/16 11:35:18 mpf Exp $ */
+/* $OpenBSD: carp.c,v 1.8 2006/11/28 19:21:15 reyk Exp $ */
/*
* Copyright (c) 2005 Håkan Olsson. All rights reserved.
@@ -53,6 +53,8 @@ carp_map_state(u_char link_state)
switch(link_state) {
case LINK_STATE_UP:
+ case LINK_STATE_HALF_DUPLEX:
+ case LINK_STATE_FULL_DUPLEX:
state = MASTER;
break;
case LINK_STATE_DOWN: