@@ -1172,14 +1172,16 @@ tfw_http_msg_setup_transform_pool(TfwHttpTransIter *mit, TfwMsgIter *it,
1172
1172
1173
1173
/*
1174
1174
* Move body to @nskb if body located in current skb.
1175
+ * Return -errno in case of error, 0 if body was not
1176
+ * moved and 1 if body was moved.
1175
1177
*/
1176
1178
static inline int
1177
- __tfw_http_msg_move_body (TfwHttpResp * resp , struct sk_buff * nskb )
1179
+ __tfw_http_msg_move_body (TfwHttpResp * resp , struct sk_buff * nskb , int * frag )
1178
1180
{
1179
1181
TfwMsgIter * it = & resp -> iter ;
1180
1182
struct sk_buff * * body ;
1181
- int r , frag ;
1182
1183
char * p ;
1184
+ int r ;
1183
1185
1184
1186
if (test_bit (TFW_HTTP_B_CHUNKED , resp -> flags )) {
1185
1187
p = resp -> body_start_data ;
@@ -1192,15 +1194,15 @@ __tfw_http_msg_move_body(TfwHttpResp *resp, struct sk_buff *nskb)
1192
1194
if (* body != it -> skb )
1193
1195
return 0 ;
1194
1196
1195
- if ((r = ss_skb_find_frag_by_offset (* body , p , & frag )))
1197
+ if ((r = ss_skb_find_frag_by_offset (* body , p , frag )))
1196
1198
return r ;
1197
1199
1198
1200
/* Move body to the next skb. */
1199
- ss_skb_move_frags (it -> skb , nskb , frag ,
1200
- skb_shinfo (it -> skb )-> nr_frags - frag );
1201
+ ss_skb_move_frags (it -> skb , nskb , * frag ,
1202
+ skb_shinfo (it -> skb )-> nr_frags - * frag );
1201
1203
* body = nskb ;
1202
1204
1203
- return 0 ;
1205
+ return 1 ;
1204
1206
}
1205
1207
1206
1208
/*
@@ -1215,12 +1217,12 @@ __tfw_http_msg_expand_from_pool(TfwHttpMsg *hm, const TfwStr *str,
1215
1217
unsigned int * copied ,
1216
1218
void cpy (void * dest , const void * src , size_t n ))
1217
1219
{
1218
- int r ;
1219
- void * addr ;
1220
1220
const TfwStr * c , * end ;
1221
1221
unsigned int room , skb_room , n_copy , rlen , off , acc = 0 ;
1222
1222
TfwMsgIter * it = & hm -> iter ;
1223
1223
TfwPool * pool = hm -> pool ;
1224
+ void * addr ;
1225
+ int r ;
1224
1226
1225
1227
BUG_ON (it -> skb -> len > SS_SKB_MAX_DATA_LEN );
1226
1228
@@ -1246,32 +1248,36 @@ __tfw_http_msg_expand_from_pool(TfwHttpMsg *hm, const TfwStr *str,
1246
1248
{
1247
1249
struct sk_buff * nskb = ss_skb_alloc (0 );
1248
1250
TfwHttpResp * resp = (TfwHttpResp * )hm ;
1251
+ bool body_was_moved = false;
1252
+ int frag ;
1249
1253
1250
1254
if (!nskb )
1251
1255
return - ENOMEM ;
1252
1256
1253
1257
if (hm -> body .len > 0 ) {
1254
- r = __tfw_http_msg_move_body (resp ,
1255
- nskb );
1256
- if (unlikely (r )) {
1258
+ r = __tfw_http_msg_move_body (resp , nskb ,
1259
+ & frag );
1260
+ if (unlikely (r < 0 )) {
1257
1261
T_WARN ("Error during moving body" );
1258
1262
return r ;
1259
1263
}
1264
+ body_was_moved = !!r ;
1260
1265
}
1261
1266
1262
1267
skb_shinfo (nskb )-> tx_flags =
1263
1268
skb_shinfo (it -> skb )-> tx_flags ;
1264
1269
ss_skb_insert_after (it -> skb , nskb );
1265
1270
/*
1266
- * If body is located in the zero fragment and
1267
- * takes all SS_SKB_MAX_DATA_LEN bytes, we move
1268
- * it to the next skb and continue use current
1269
- * skb.
1271
+ * If body was moved to the new allocated skb
1272
+ * we should use current skb.
1270
1273
*/
1271
- if (likely (nskb -> len < SS_SKB_MAX_DATA_LEN ))
1274
+ if (likely (! body_was_moved )) {
1272
1275
it -> skb = nskb ;
1276
+ it -> frag = -1 ;
1277
+ } else {
1278
+ it -> frag = frag - 1 ;
1279
+ }
1273
1280
1274
- it -> frag = -1 ;
1275
1281
skb_room = SS_SKB_MAX_DATA_LEN - it -> skb -> len ;
1276
1282
}
1277
1283
0 commit comments