sctp: add refcnt support for sh_key
With refcnt support for sh_key, chunks auth sh_keys can be decided before enqueuing it. Changing the active key later will not affect the chunks already enqueued. Furthermore, this is necessary when adding the support for authinfo for sendmsg in next patch. Note that struct sctp_chunk can't be grown due to that performance drop issue on slow cpu, so it just reuses head_skb memory for shkey in sctp_chunk. Signed-off-by: Xin Long <lucien.xin@gmail.com> Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
c469012729
commit
1b1e0bc994
@@ -241,10 +241,13 @@ static enum sctp_xmit sctp_packet_bundle_auth(struct sctp_packet *pkt,
|
||||
if (!chunk->auth)
|
||||
return retval;
|
||||
|
||||
auth = sctp_make_auth(asoc);
|
||||
auth = sctp_make_auth(asoc, chunk->shkey->key_id);
|
||||
if (!auth)
|
||||
return retval;
|
||||
|
||||
auth->shkey = chunk->shkey;
|
||||
sctp_auth_shkey_hold(auth->shkey);
|
||||
|
||||
retval = __sctp_packet_append_chunk(pkt, auth);
|
||||
|
||||
if (retval != SCTP_XMIT_OK)
|
||||
@@ -490,7 +493,8 @@ merge:
|
||||
}
|
||||
|
||||
if (auth) {
|
||||
sctp_auth_calculate_hmac(tp->asoc, nskb, auth, gfp);
|
||||
sctp_auth_calculate_hmac(tp->asoc, nskb, auth,
|
||||
packet->auth->shkey, gfp);
|
||||
/* free auth if no more chunks, or add it back */
|
||||
if (list_empty(&packet->chunk_list))
|
||||
sctp_chunk_free(packet->auth);
|
||||
@@ -770,6 +774,16 @@ static enum sctp_xmit sctp_packet_will_fit(struct sctp_packet *packet,
|
||||
enum sctp_xmit retval = SCTP_XMIT_OK;
|
||||
size_t psize, pmtu, maxsize;
|
||||
|
||||
/* Don't bundle in this packet if this chunk's auth key doesn't
|
||||
* match other chunks already enqueued on this packet. Also,
|
||||
* don't bundle the chunk with auth key if other chunks in this
|
||||
* packet don't have auth key.
|
||||
*/
|
||||
if ((packet->auth && chunk->shkey != packet->auth->shkey) ||
|
||||
(!packet->auth && chunk->shkey &&
|
||||
chunk->chunk_hdr->type != SCTP_CID_AUTH))
|
||||
return SCTP_XMIT_PMTU_FULL;
|
||||
|
||||
psize = packet->size;
|
||||
if (packet->transport->asoc)
|
||||
pmtu = packet->transport->asoc->pathmtu;
|
||||
|
||||
Reference in New Issue
Block a user