Skip to content

Commit f2d1c72

Browse files
edumazetdavem330
authored andcommitted
inet: frags: get rid of nf_ct_frag6_skb_cb/NFCT_FRAG6_CB
nf_ct_frag6_queue() uses skb->cb[] to store the fragment offset, meaning that we could use two cache lines per skb when finding the insertion point, if for some reason inet6_skb_parm size is increased in the future. By using skb->ip_defrag_offset instead of skb->cb[] we pack all the fields in a single cache line, matching what we did for IPv4. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 219badf commit f2d1c72

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

net/ipv6/netfilter/nf_conntrack_reasm.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,6 @@
5252

5353
static const char nf_frags_cache_name[] = "nf-frags";
5454

55-
struct nf_ct_frag6_skb_cb
56-
{
57-
struct inet6_skb_parm h;
58-
int offset;
59-
};
60-
61-
#define NFCT_FRAG6_CB(skb) ((struct nf_ct_frag6_skb_cb *)((skb)->cb))
62-
6355
static struct inet_frags nf_frags;
6456

6557
#ifdef CONFIG_SYSCTL
@@ -270,13 +262,13 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
270262
* this fragment, right?
271263
*/
272264
prev = fq->q.fragments_tail;
273-
if (!prev || NFCT_FRAG6_CB(prev)->offset < offset) {
265+
if (!prev || prev->ip_defrag_offset < offset) {
274266
next = NULL;
275267
goto found;
276268
}
277269
prev = NULL;
278270
for (next = fq->q.fragments; next != NULL; next = next->next) {
279-
if (NFCT_FRAG6_CB(next)->offset >= offset)
271+
if (next->ip_defrag_offset >= offset)
280272
break; /* bingo! */
281273
prev = next;
282274
}
@@ -292,14 +284,19 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
292284

293285
/* Check for overlap with preceding fragment. */
294286
if (prev &&
295-
(NFCT_FRAG6_CB(prev)->offset + prev->len) > offset)
287+
(prev->ip_defrag_offset + prev->len) > offset)
296288
goto discard_fq;
297289

298290
/* Look for overlap with succeeding segment. */
299-
if (next && NFCT_FRAG6_CB(next)->offset < end)
291+
if (next && next->ip_defrag_offset < end)
300292
goto discard_fq;
301293

302-
NFCT_FRAG6_CB(skb)->offset = offset;
294+
/* Note : skb->ip_defrag_offset and skb->dev share the same location */
295+
if (skb->dev)
296+
fq->iif = skb->dev->ifindex;
297+
/* Makes sure compiler wont do silly aliasing games */
298+
barrier();
299+
skb->ip_defrag_offset = offset;
303300

304301
/* Insert this fragment in the chain of fragments. */
305302
skb->next = next;
@@ -310,10 +307,6 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
310307
else
311308
fq->q.fragments = skb;
312309

313-
if (skb->dev) {
314-
fq->iif = skb->dev->ifindex;
315-
skb->dev = NULL;
316-
}
317310
fq->q.stamp = skb->tstamp;
318311
fq->q.meat += skb->len;
319312
fq->ecn |= ecn;
@@ -357,7 +350,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct sk_buff *prev, struct net_devic
357350
inet_frag_kill(&fq->q);
358351

359352
WARN_ON(head == NULL);
360-
WARN_ON(NFCT_FRAG6_CB(head)->offset != 0);
353+
WARN_ON(head->ip_defrag_offset != 0);
361354

362355
ecn = ip_frag_ecn_table[fq->ecn];
363356
if (unlikely(ecn == 0xff))

0 commit comments

Comments
 (0)