Commit 70d91ea0 authored by Michael Tuexen's avatar Michael Tuexen
Browse files

sctp: improve handling of assoc ids in socket options

For socket options related to local and remote addresses providing
generic association ids does not make sense. Report EINVAL in this
case.

MFC after:	1 week

(cherry picked from commit 13c196a4)
parent 4749d55f
......@@ -2192,8 +2192,13 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
*value = (uint32_t)size;
*optsize = sizeof(uint32_t);
} else {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTCONN);
error = ENOTCONN;
if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
((sctp_assoc_t)*value <= SCTP_ALL_ASSOC)) {
error = EINVAL;
} else {
error = ENOENT;
}
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error);
}
break;
}
......@@ -2267,8 +2272,13 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
}
SCTP_TCB_UNLOCK(stcb);
} else {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT);
error = ENOENT;
if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
(saddr->sget_assoc_id <= SCTP_ALL_ASSOC)) {
error = EINVAL;
} else {
error = ENOENT;
}
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error);
}
break;
}
......@@ -2280,12 +2290,18 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
SCTP_CHECK_AND_CAST(saddr, optval, struct sctp_getaddresses, *optsize);
SCTP_FIND_STCB(inp, stcb, saddr->sget_assoc_id);
limit = *optsize - offsetof(struct sctp_getaddresses, addr);
actual = sctp_fill_up_addresses(inp, stcb, limit, &saddr->addr[0].sa);
if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
((saddr->sget_assoc_id == SCTP_CURRENT_ASSOC) ||
(saddr->sget_assoc_id == SCTP_ALL_ASSOC))) {
error = EINVAL;
} else {
limit = *optsize - offsetof(struct sctp_getaddresses, addr);
actual = sctp_fill_up_addresses(inp, stcb, limit, &saddr->addr[0].sa);
*optsize = offsetof(struct sctp_getaddresses, addr) + actual;
}
if (stcb != NULL) {
SCTP_TCB_UNLOCK(stcb);
}
*optsize = offsetof(struct sctp_getaddresses, addr) + actual;
break;
}
case SCTP_PEER_ADDR_PARAMS:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment