chunk.c (58e16d792a6a8c6b750f637a4649967fcac853dc) chunk.c (b6e6b5f1da7e8d092f86a4351802c27c0170c5a5)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/* SCTP kernel implementation
3 * (C) Copyright IBM Corp. 2003, 2004
4 *
5 * This file is part of the SCTP kernel implementation
6 *
7 * This file contains the code relating the chunk abstraction.
8 *

--- 61 unchanged lines hidden (view full) ---

70
71/* Final destructruction of datamsg memory. */
72static void sctp_datamsg_destroy(struct sctp_datamsg *msg)
73{
74 struct sctp_association *asoc = NULL;
75 struct list_head *pos, *temp;
76 struct sctp_chunk *chunk;
77 struct sctp_ulpevent *ev;
1// SPDX-License-Identifier: GPL-2.0-or-later
2/* SCTP kernel implementation
3 * (C) Copyright IBM Corp. 2003, 2004
4 *
5 * This file is part of the SCTP kernel implementation
6 *
7 * This file contains the code relating the chunk abstraction.
8 *

--- 61 unchanged lines hidden (view full) ---

70
71/* Final destructruction of datamsg memory. */
72static void sctp_datamsg_destroy(struct sctp_datamsg *msg)
73{
74 struct sctp_association *asoc = NULL;
75 struct list_head *pos, *temp;
76 struct sctp_chunk *chunk;
77 struct sctp_ulpevent *ev;
78 int error = 0, notify;
78 int error, sent;
79
79
80 /* If we failed, we may need to notify. */
81 notify = msg->send_failed ? -1 : 0;
82
83 /* Release all references. */
84 list_for_each_safe(pos, temp, &msg->chunks) {
85 list_del_init(pos);
86 chunk = list_entry(pos, struct sctp_chunk, frag_list);
80 /* Release all references. */
81 list_for_each_safe(pos, temp, &msg->chunks) {
82 list_del_init(pos);
83 chunk = list_entry(pos, struct sctp_chunk, frag_list);
87 /* Check whether we _really_ need to notify. */
88 if (notify < 0) {
89 asoc = chunk->asoc;
90 if (msg->send_error)
91 error = msg->send_error;
92 else
93 error = asoc->outqueue.error;
94
84
95 notify = sctp_ulpevent_type_enabled(asoc->subscribe,
96 SCTP_SEND_FAILED);
85 if (!msg->send_failed) {
86 sctp_chunk_put(chunk);
87 continue;
97 }
98
88 }
89
99 /* Generate a SEND FAILED event only if enabled. */
100 if (notify > 0) {
101 int sent;
102 if (chunk->has_tsn)
103 sent = SCTP_DATA_SENT;
104 else
105 sent = SCTP_DATA_UNSENT;
90 asoc = chunk->asoc;
91 error = msg->send_error ?: asoc->outqueue.error;
92 sent = chunk->has_tsn ? SCTP_DATA_SENT : SCTP_DATA_UNSENT;
106
93
94 if (sctp_ulpevent_type_enabled(asoc->subscribe,
95 SCTP_SEND_FAILED)) {
107 ev = sctp_ulpevent_make_send_failed(asoc, chunk, sent,
108 error, GFP_ATOMIC);
109 if (ev)
110 asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
111 }
112
96 ev = sctp_ulpevent_make_send_failed(asoc, chunk, sent,
97 error, GFP_ATOMIC);
98 if (ev)
99 asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
100 }
101
102 if (sctp_ulpevent_type_enabled(asoc->subscribe,
103 SCTP_SEND_FAILED_EVENT)) {
104 ev = sctp_ulpevent_make_send_failed_event(asoc, chunk,
105 sent, error,
106 GFP_ATOMIC);
107 if (ev)
108 asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
109 }
110
113 sctp_chunk_put(chunk);
114 }
115
116 SCTP_DBG_OBJCNT_DEC(datamsg);
117 kfree(msg);
118}
119
120/* Hold a reference. */

--- 235 unchanged lines hidden ---
111 sctp_chunk_put(chunk);
112 }
113
114 SCTP_DBG_OBJCNT_DEC(datamsg);
115 kfree(msg);
116}
117
118/* Hold a reference. */

--- 235 unchanged lines hidden ---