Protect ipx_pexseq with the IPX PCB list mutex.
When processing socket options against IPX PCBs, generally protect PCB fields using the IPX PCB mutex. Where possible, use unlocked reads on integer values to avoid locking overhead. MFC after: 3 weeks
This commit is contained in:
parent
056eceb470
commit
1845f530cb
@ -95,7 +95,7 @@ struct ipxpcbhead ipxrawpcb_list;
|
||||
static int ipxqmaxlen = IFQ_MAXLEN;
|
||||
static struct ifqueue ipxintrq;
|
||||
|
||||
long ipx_pexseq;
|
||||
long ipx_pexseq; /* Locked with ipxpcb_list_mtx. */
|
||||
|
||||
static int ipx_do_route(struct ipx_addr *src, struct route *ro);
|
||||
static void ipx_undo_route(struct route *ro);
|
||||
|
@ -325,6 +325,7 @@ ipx_ctloutput(so, sopt)
|
||||
int mask, error, optval;
|
||||
short soptval;
|
||||
struct ipx ioptval;
|
||||
long seq;
|
||||
|
||||
error = 0;
|
||||
if (ipxp == NULL)
|
||||
@ -348,6 +349,7 @@ ipx_ctloutput(so, sopt)
|
||||
case SO_HEADERS_ON_OUTPUT:
|
||||
mask = IPXP_RAWOUT;
|
||||
get_flags:
|
||||
/* Unlocked read. */
|
||||
soptval = ipxp->ipxp_flags & mask;
|
||||
error = sooptcopyout(sopt, &soptval, sizeof soptval);
|
||||
break;
|
||||
@ -356,16 +358,20 @@ ipx_ctloutput(so, sopt)
|
||||
ioptval.ipx_len = 0;
|
||||
ioptval.ipx_sum = 0;
|
||||
ioptval.ipx_tc = 0;
|
||||
IPX_LOCK(ipxp);
|
||||
ioptval.ipx_pt = ipxp->ipxp_dpt;
|
||||
ioptval.ipx_dna = ipxp->ipxp_faddr;
|
||||
ioptval.ipx_sna = ipxp->ipxp_laddr;
|
||||
IPX_UNLOCK(ipxp);
|
||||
error = sooptcopyout(sopt, &soptval, sizeof soptval);
|
||||
break;
|
||||
|
||||
case SO_SEQNO:
|
||||
error = sooptcopyout(sopt, &ipx_pexseq,
|
||||
sizeof ipx_pexseq);
|
||||
IPX_LIST_LOCK();
|
||||
seq = ipx_pexseq;
|
||||
ipx_pexseq++;
|
||||
IPX_LIST_UNLOCK();
|
||||
error = sooptcopyout(sopt, &seq, sizeof seq);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -393,10 +399,12 @@ ipx_ctloutput(so, sopt)
|
||||
sizeof optval);
|
||||
if (error)
|
||||
break;
|
||||
IPX_LOCK(ipxp);
|
||||
if (optval)
|
||||
ipxp->ipxp_flags |= mask;
|
||||
else
|
||||
ipxp->ipxp_flags &= ~mask;
|
||||
IPX_UNLOCK(ipxp);
|
||||
break;
|
||||
|
||||
case SO_DEFAULT_HEADERS:
|
||||
@ -404,6 +412,7 @@ ipx_ctloutput(so, sopt)
|
||||
sizeof ioptval);
|
||||
if (error)
|
||||
break;
|
||||
/* Unlocked write. */
|
||||
ipxp->ipxp_dpt = ioptval.ipx_pt;
|
||||
break;
|
||||
#ifdef IPXIP
|
||||
|
Loading…
Reference in New Issue
Block a user