Don't allow a remote encapsulation port change during the

SCTP restart procedure.

MFC after: 3 days
This commit is contained in:
Michael Tuexen 2016-01-30 12:58:38 +00:00
parent 3753ce3c75
commit ca83f93c09
3 changed files with 41 additions and 20 deletions

View File

@ -85,7 +85,7 @@ static void
sctp_handle_init(struct mbuf *m, int iphlen, int offset, sctp_handle_init(struct mbuf *m, int iphlen, int offset,
struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh,
struct sctp_init_chunk *cp, struct sctp_inpcb *inp, struct sctp_init_chunk *cp, struct sctp_inpcb *inp,
struct sctp_tcb *stcb, int *abort_no_unlock, struct sctp_tcb *stcb, struct sctp_nets *net, int *abort_no_unlock,
uint8_t mflowtype, uint32_t mflowid, uint8_t mflowtype, uint32_t mflowid,
uint32_t vrf_id, uint16_t port) uint32_t vrf_id, uint16_t port)
{ {
@ -198,8 +198,8 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset,
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_CONTROL_PROC, SCTP_SO_NOT_LOCKED); sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_CONTROL_PROC, SCTP_SO_NOT_LOCKED);
} else { } else {
SCTPDBG(SCTP_DEBUG_INPUT3, "sctp_handle_init: sending INIT-ACK\n"); SCTPDBG(SCTP_DEBUG_INPUT3, "sctp_handle_init: sending INIT-ACK\n");
sctp_send_initiate_ack(inp, stcb, m, iphlen, offset, src, dst, sctp_send_initiate_ack(inp, stcb, net, m, iphlen, offset,
sh, cp, src, dst, sh, cp,
mflowtype, mflowid, mflowtype, mflowid,
vrf_id, port, vrf_id, port,
((stcb == NULL) ? SCTP_HOLDS_LOCK : SCTP_NOT_LOCKED)); ((stcb == NULL) ? SCTP_HOLDS_LOCK : SCTP_NOT_LOCKED));
@ -4840,7 +4840,7 @@ process_control_chunks:
} }
sctp_handle_init(m, iphlen, *offset, src, dst, sh, sctp_handle_init(m, iphlen, *offset, src, dst, sh,
(struct sctp_init_chunk *)ch, inp, (struct sctp_init_chunk *)ch, inp,
stcb, &abort_no_unlock, stcb, *netp, &abort_no_unlock,
mflowtype, mflowid, mflowtype, mflowid,
vrf_id, port); vrf_id, port);
*offset = length; *offset = length;

View File

@ -5484,7 +5484,8 @@ sctp_are_there_new_addresses(struct sctp_association *asoc,
*/ */
void void
sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
struct mbuf *init_pkt, int iphlen, int offset, struct sctp_nets *src_net, struct mbuf *init_pkt,
int iphlen, int offset,
struct sockaddr *src, struct sockaddr *dst, struct sockaddr *src, struct sockaddr *dst,
struct sctphdr *sh, struct sctp_init_chunk *init_chk, struct sctphdr *sh, struct sctp_init_chunk *init_chk,
uint8_t mflowtype, uint32_t mflowid, uint8_t mflowtype, uint32_t mflowid,
@ -5528,13 +5529,15 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
asoc = NULL; asoc = NULL;
} }
if ((asoc != NULL) && if ((asoc != NULL) &&
(SCTP_GET_STATE(asoc) != SCTP_STATE_COOKIE_WAIT) && (SCTP_GET_STATE(asoc) != SCTP_STATE_COOKIE_WAIT)) {
(sctp_are_there_new_addresses(asoc, init_pkt, offset, src))) { if (sctp_are_there_new_addresses(asoc, init_pkt, offset, src)) {
/* new addresses, out of here in non-cookie-wait states */
/* /*
* Send a ABORT, we don't add the new address error clause * new addresses, out of here in non-cookie-wait
* though we even set the T bit and copy in the 0 tag.. this * states
* looks no different than if no listener was present. *
* Send an ABORT, without the new address error cause.
* This looks no different than if no listener was
* present.
*/ */
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
"Address added"); "Address added");
@ -5543,6 +5546,23 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
vrf_id, port); vrf_id, port);
return; return;
} }
if (src_net != NULL && (src_net->port != port)) {
/*
* change of remote encapsulation port, out of here
* in non-cookie-wait states
*
* Send an ABORT, without an specific error cause. This
* looks no different than if no listener was
* present.
*/
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
"Remote encapsulation port changed");
sctp_send_abort(init_pkt, iphlen, src, dst, sh, 0, op_err,
mflowtype, mflowid, inp->fibnum,
vrf_id, port);
return;
}
}
abort_flag = 0; abort_flag = 0;
op_err = sctp_arethere_unrecognized_parameters(init_pkt, op_err = sctp_arethere_unrecognized_parameters(init_pkt,
(offset + sizeof(struct sctp_init_chunk)), (offset + sizeof(struct sctp_init_chunk)),

View File

@ -80,7 +80,8 @@ sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int
); );
void void
sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *, struct mbuf *, sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *,
struct sctp_nets *, struct mbuf *,
int, int, int, int,
struct sockaddr *, struct sockaddr *, struct sockaddr *, struct sockaddr *,
struct sctphdr *, struct sctp_init_chunk *, struct sctphdr *, struct sctp_init_chunk *,