Skip to content

Commit 1cd7884

Browse files
wdebruijdavem330
authored andcommitted
udp: expose inet cork to udp
UDP segmentation offload needs access to inet_cork in the udp layer. Pass the struct to ip(6)_make_skb instead of allocating it on the stack in that function itself. This patch is a noop otherwise. Signed-off-by: Willem de Bruijn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a9537c9 commit 1cd7884

File tree

6 files changed

+25
-22
lines changed

6 files changed

+25
-22
lines changed

include/net/ip.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ struct sk_buff *ip_make_skb(struct sock *sk, struct flowi4 *fl4,
171171
int len, int odd, struct sk_buff *skb),
172172
void *from, int length, int transhdrlen,
173173
struct ipcm_cookie *ipc, struct rtable **rtp,
174-
unsigned int flags);
174+
struct inet_cork *cork, unsigned int flags);
175175

176176
static inline struct sk_buff *ip_finish_skb(struct sock *sk, struct flowi4 *fl4)
177177
{

include/net/ipv6.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ struct sk_buff *ip6_make_skb(struct sock *sk,
950950
void *from, int length, int transhdrlen,
951951
struct ipcm6_cookie *ipc6, struct flowi6 *fl6,
952952
struct rt6_info *rt, unsigned int flags,
953+
struct inet_cork_full *cork,
953954
const struct sockcm_cookie *sockc);
954955

955956
static inline struct sk_buff *ip6_finish_skb(struct sock *sk)

net/ipv4/ip_output.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,9 +1470,8 @@ struct sk_buff *ip_make_skb(struct sock *sk,
14701470
int len, int odd, struct sk_buff *skb),
14711471
void *from, int length, int transhdrlen,
14721472
struct ipcm_cookie *ipc, struct rtable **rtp,
1473-
unsigned int flags)
1473+
struct inet_cork *cork, unsigned int flags)
14741474
{
1475-
struct inet_cork cork;
14761475
struct sk_buff_head queue;
14771476
int err;
14781477

@@ -1481,22 +1480,22 @@ struct sk_buff *ip_make_skb(struct sock *sk,
14811480

14821481
__skb_queue_head_init(&queue);
14831482

1484-
cork.flags = 0;
1485-
cork.addr = 0;
1486-
cork.opt = NULL;
1487-
err = ip_setup_cork(sk, &cork, ipc, rtp);
1483+
cork->flags = 0;
1484+
cork->addr = 0;
1485+
cork->opt = NULL;
1486+
err = ip_setup_cork(sk, cork, ipc, rtp);
14881487
if (err)
14891488
return ERR_PTR(err);
14901489

1491-
err = __ip_append_data(sk, fl4, &queue, &cork,
1490+
err = __ip_append_data(sk, fl4, &queue, cork,
14921491
&current->task_frag, getfrag,
14931492
from, length, transhdrlen, flags);
14941493
if (err) {
1495-
__ip_flush_pending_frames(sk, &queue, &cork);
1494+
__ip_flush_pending_frames(sk, &queue, cork);
14961495
return ERR_PTR(err);
14971496
}
14981497

1499-
return __ip_make_skb(sk, fl4, &queue, &cork);
1498+
return __ip_make_skb(sk, fl4, &queue, cork);
15001499
}
15011500

15021501
/*

net/ipv4/udp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,9 +1030,11 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
10301030

10311031
/* Lockless fast path for the non-corking case. */
10321032
if (!corkreq) {
1033+
struct inet_cork cork;
1034+
10331035
skb = ip_make_skb(sk, fl4, getfrag, msg, ulen,
10341036
sizeof(struct udphdr), &ipc, &rt,
1035-
msg->msg_flags);
1037+
&cork, msg->msg_flags);
10361038
err = PTR_ERR(skb);
10371039
if (!IS_ERR_OR_NULL(skb))
10381040
err = udp_send_skb(skb, fl4);

net/ipv6/ip6_output.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,9 +1755,9 @@ struct sk_buff *ip6_make_skb(struct sock *sk,
17551755
void *from, int length, int transhdrlen,
17561756
struct ipcm6_cookie *ipc6, struct flowi6 *fl6,
17571757
struct rt6_info *rt, unsigned int flags,
1758+
struct inet_cork_full *cork,
17581759
const struct sockcm_cookie *sockc)
17591760
{
1760-
struct inet_cork_full cork;
17611761
struct inet6_cork v6_cork;
17621762
struct sk_buff_head queue;
17631763
int exthdrlen = (ipc6->opt ? ipc6->opt->opt_flen : 0);
@@ -1768,27 +1768,27 @@ struct sk_buff *ip6_make_skb(struct sock *sk,
17681768

17691769
__skb_queue_head_init(&queue);
17701770

1771-
cork.base.flags = 0;
1772-
cork.base.addr = 0;
1773-
cork.base.opt = NULL;
1774-
cork.base.dst = NULL;
1771+
cork->base.flags = 0;
1772+
cork->base.addr = 0;
1773+
cork->base.opt = NULL;
1774+
cork->base.dst = NULL;
17751775
v6_cork.opt = NULL;
1776-
err = ip6_setup_cork(sk, &cork, &v6_cork, ipc6, rt, fl6);
1776+
err = ip6_setup_cork(sk, cork, &v6_cork, ipc6, rt, fl6);
17771777
if (err) {
1778-
ip6_cork_release(&cork, &v6_cork);
1778+
ip6_cork_release(cork, &v6_cork);
17791779
return ERR_PTR(err);
17801780
}
17811781
if (ipc6->dontfrag < 0)
17821782
ipc6->dontfrag = inet6_sk(sk)->dontfrag;
17831783

1784-
err = __ip6_append_data(sk, fl6, &queue, &cork.base, &v6_cork,
1784+
err = __ip6_append_data(sk, fl6, &queue, &cork->base, &v6_cork,
17851785
&current->task_frag, getfrag, from,
17861786
length + exthdrlen, transhdrlen + exthdrlen,
17871787
flags, ipc6, sockc);
17881788
if (err) {
1789-
__ip6_flush_pending_frames(sk, &queue, &cork, &v6_cork);
1789+
__ip6_flush_pending_frames(sk, &queue, cork, &v6_cork);
17901790
return ERR_PTR(err);
17911791
}
17921792

1793-
return __ip6_make_skb(sk, &queue, &cork, &v6_cork);
1793+
return __ip6_make_skb(sk, &queue, cork, &v6_cork);
17941794
}

net/ipv6/udp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1324,12 +1324,13 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
13241324

13251325
/* Lockless fast path for the non-corking case */
13261326
if (!corkreq) {
1327+
struct inet_cork_full cork;
13271328
struct sk_buff *skb;
13281329

13291330
skb = ip6_make_skb(sk, getfrag, msg, ulen,
13301331
sizeof(struct udphdr), &ipc6,
13311332
&fl6, (struct rt6_info *)dst,
1332-
msg->msg_flags, &sockc);
1333+
msg->msg_flags, &cork, &sockc);
13331334
err = PTR_ERR(skb);
13341335
if (!IS_ERR_OR_NULL(skb))
13351336
err = udp_v6_send_skb(skb, &fl6);

0 commit comments

Comments
 (0)