Skip to content

Commit c948b46

Browse files
committed
Merge branch 'tipc-next'
Menglong Dong says: ==================== net: tipc: fix FB_MTU eat two pages and do some code cleanup In the first patch, FB_MTU is redefined to make sure data size will not exceed PAGE_SIZE. Besides, I removed the alignment for buf_size in tipc_buf_acquire, because skb_alloc_fclone will do the alignment job. In the second patch, I removed align() in msg.c and replace it with ALIGN(). Changes since V5: - remove blank line after Fixes in commit log in the first patch Changes since V4: - remove ONE_PAGE_SKB_SZ and replace it with one_page_mtu in the first patch. - fix some code style problems for the second patch. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 1b077ce + d4cfb7f commit c948b46

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

net/tipc/bcast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ int tipc_bcast_init(struct net *net)
699699
spin_lock_init(&tipc_net(net)->bclock);
700700

701701
if (!tipc_link_bc_create(net, 0, 0, NULL,
702-
FB_MTU,
702+
one_page_mtu,
703703
BCLINK_WIN_DEFAULT,
704704
BCLINK_WIN_DEFAULT,
705705
0,

net/tipc/msg.c

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,18 @@
4141
#include "name_table.h"
4242
#include "crypto.h"
4343

44+
#define BUF_ALIGN(x) ALIGN(x, 4)
4445
#define MAX_FORWARD_SIZE 1024
4546
#ifdef CONFIG_TIPC_CRYPTO
4647
#define BUF_HEADROOM ALIGN(((LL_MAX_HEADER + 48) + EHDR_MAX_SIZE), 16)
47-
#define BUF_TAILROOM (TIPC_AES_GCM_TAG_SIZE)
48+
#define BUF_OVERHEAD (BUF_HEADROOM + TIPC_AES_GCM_TAG_SIZE)
4849
#else
4950
#define BUF_HEADROOM (LL_MAX_HEADER + 48)
50-
#define BUF_TAILROOM 16
51+
#define BUF_OVERHEAD BUF_HEADROOM
5152
#endif
5253

53-
static unsigned int align(unsigned int i)
54-
{
55-
return (i + 3) & ~3u;
56-
}
54+
const int one_page_mtu = PAGE_SIZE - SKB_DATA_ALIGN(BUF_OVERHEAD) -
55+
SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
5756

5857
/**
5958
* tipc_buf_acquire - creates a TIPC message buffer
@@ -69,13 +68,8 @@ static unsigned int align(unsigned int i)
6968
struct sk_buff *tipc_buf_acquire(u32 size, gfp_t gfp)
7069
{
7170
struct sk_buff *skb;
72-
#ifdef CONFIG_TIPC_CRYPTO
73-
unsigned int buf_size = (BUF_HEADROOM + size + BUF_TAILROOM + 3) & ~3u;
74-
#else
75-
unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u;
76-
#endif
7771

78-
skb = alloc_skb_fclone(buf_size, gfp);
72+
skb = alloc_skb_fclone(BUF_OVERHEAD + size, gfp);
7973
if (skb) {
8074
skb_reserve(skb, BUF_HEADROOM);
8175
skb_put(skb, size);
@@ -395,7 +389,8 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, int offset,
395389
if (unlikely(!skb)) {
396390
if (pktmax != MAX_MSG_SIZE)
397391
return -ENOMEM;
398-
rc = tipc_msg_build(mhdr, m, offset, dsz, FB_MTU, list);
392+
rc = tipc_msg_build(mhdr, m, offset, dsz,
393+
one_page_mtu, list);
399394
if (rc != dsz)
400395
return rc;
401396
if (tipc_msg_assemble(list))
@@ -490,7 +485,7 @@ static bool tipc_msg_bundle(struct sk_buff *bskb, struct tipc_msg *msg,
490485

491486
msz = msg_size(msg);
492487
bsz = msg_size(bmsg);
493-
offset = align(bsz);
488+
offset = BUF_ALIGN(bsz);
494489
pad = offset - bsz;
495490

496491
if (unlikely(skb_tailroom(bskb) < (pad + msz)))
@@ -547,7 +542,7 @@ bool tipc_msg_try_bundle(struct sk_buff *tskb, struct sk_buff **skb, u32 mss,
547542

548543
/* Make a new bundle of the two messages if possible */
549544
tsz = msg_size(buf_msg(tskb));
550-
if (unlikely(mss < align(INT_H_SIZE + tsz) + msg_size(msg)))
545+
if (unlikely(mss < BUF_ALIGN(INT_H_SIZE + tsz) + msg_size(msg)))
551546
return true;
552547
if (unlikely(pskb_expand_head(tskb, INT_H_SIZE, mss - tsz - INT_H_SIZE,
553548
GFP_ATOMIC)))
@@ -606,7 +601,7 @@ bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos)
606601
if (unlikely(!tipc_msg_validate(iskb)))
607602
goto none;
608603

609-
*pos += align(imsz);
604+
*pos += BUF_ALIGN(imsz);
610605
return true;
611606
none:
612607
kfree_skb(skb);

net/tipc/msg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ struct plist;
9999
#define MAX_H_SIZE 60 /* Largest possible TIPC header size */
100100

101101
#define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE)
102-
#define FB_MTU 3744
103102
#define TIPC_MEDIA_INFO_OFFSET 5
104103

104+
extern const int one_page_mtu;
105+
105106
struct tipc_skb_cb {
106107
union {
107108
struct {

0 commit comments

Comments
 (0)