Protect against deranged fabric nameservers that spit out 10000 identical
port numbers.
This commit is contained in:
parent
8f0b837cd4
commit
5522109c39
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: isp.c,v 1.81 2001/10/06 20:34:49 mjacob Exp $ */
|
||||
/* $NetBSD: isp.c,v 1.82 2001/10/20 18:37:54 mjacob Exp $ */
|
||||
/*
|
||||
* This driver, which is contained in NetBSD in the files:
|
||||
*
|
||||
|
@ -2291,11 +2291,11 @@ static int
|
|||
isp_scan_fabric(struct ispsoftc *isp)
|
||||
{
|
||||
fcparam *fcp = isp->isp_param;
|
||||
u_int32_t portid, first_portid;
|
||||
u_int32_t portid, first_portid, last_portid;
|
||||
sns_screq_t *reqp;
|
||||
sns_scrsp_t *resp;
|
||||
mbreg_t mbs;
|
||||
int hicap, first_portid_seen;
|
||||
int hicap, first_portid_seen, last_port_same;
|
||||
|
||||
if (fcp->isp_onfabric == 0) {
|
||||
fcp->isp_loopstate = LOOP_FSCAN_DONE;
|
||||
|
@ -2308,6 +2308,8 @@ isp_scan_fabric(struct ispsoftc *isp)
|
|||
* Since Port IDs are 24 bits, we can check against having seen
|
||||
* anything yet with this value.
|
||||
*/
|
||||
last_port_same = 0;
|
||||
last_portid = 0xffffffff; /* not a port */
|
||||
first_portid = portid = fcp->isp_portid;
|
||||
fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
|
||||
|
||||
|
@ -2386,9 +2388,20 @@ isp_scan_fabric(struct ispsoftc *isp)
|
|||
fcp->isp_loopstate = LOOP_FSCAN_DONE;
|
||||
return (0);
|
||||
}
|
||||
if (portid == last_portid) {
|
||||
if (last_port_same++ > 20) {
|
||||
isp_prt(isp, ISP_LOGWARN,
|
||||
"tangled fabric database detected");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
last_portid = portid;
|
||||
}
|
||||
}
|
||||
|
||||
isp_prt(isp, ISP_LOGWARN, "broken fabric nameserver...*wheeze*...");
|
||||
if (hicap >= 65535) {
|
||||
isp_prt(isp, ISP_LOGWARN, "fabric too big (> 65535)");
|
||||
}
|
||||
|
||||
/*
|
||||
* We either have a broken name server or a huge fabric if we get here.
|
||||
|
|
Loading…
Reference in New Issue