Commit 13c196a4 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
parent 6e9309bd
...@@ -2187,8 +2187,13 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, ...@@ -2187,8 +2187,13 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
*value = (uint32_t)size; *value = (uint32_t)size;
*optsize = sizeof(uint32_t); *optsize = sizeof(uint32_t);
} else { } else {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTCONN); if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
error = ENOTCONN; ((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; break;
} }
...@@ -2262,9 +2267,14 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, ...@@ -2262,9 +2267,14 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} }
SCTP_TCB_UNLOCK(stcb); SCTP_TCB_UNLOCK(stcb);
} else { } else {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT); if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
(saddr->sget_assoc_id <= SCTP_ALL_ASSOC)) {
error = EINVAL;
} else {
error = ENOENT; error = ENOENT;
} }
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error);
}
break; break;
} }
case SCTP_GET_LOCAL_ADDRESSES: case SCTP_GET_LOCAL_ADDRESSES:
...@@ -2275,12 +2285,18 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, ...@@ -2275,12 +2285,18 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
SCTP_CHECK_AND_CAST(saddr, optval, struct sctp_getaddresses, *optsize); SCTP_CHECK_AND_CAST(saddr, optval, struct sctp_getaddresses, *optsize);
SCTP_FIND_STCB(inp, stcb, saddr->sget_assoc_id); SCTP_FIND_STCB(inp, stcb, saddr->sget_assoc_id);
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); limit = *optsize - offsetof(struct sctp_getaddresses, addr);
actual = sctp_fill_up_addresses(inp, stcb, limit, &saddr->addr[0].sa); actual = sctp_fill_up_addresses(inp, stcb, limit, &saddr->addr[0].sa);
*optsize = offsetof(struct sctp_getaddresses, addr) + actual;
}
if (stcb != NULL) { if (stcb != NULL) {
SCTP_TCB_UNLOCK(stcb); SCTP_TCB_UNLOCK(stcb);
} }
*optsize = offsetof(struct sctp_getaddresses, addr) + actual;
break; break;
} }
case SCTP_PEER_ADDR_PARAMS: 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