Skip to content

Commit ad95903

Browse files
Paolo Abenidavem330
Paolo Abeni
authored andcommitted
net/sock: add an explicit sk argument for ip_cmsg_recv_offset()
So that we can use it even after orphaining the skbuff. Suggested-by: Eric Dumazet <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cd2c0f4 commit ad95903

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

include/net/ip.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,8 @@ int ip_options_rcv_srr(struct sk_buff *skb);
579579
*/
580580

581581
void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb);
582-
void ip_cmsg_recv_offset(struct msghdr *msg, struct sk_buff *skb, int tlen, int offset);
582+
void ip_cmsg_recv_offset(struct msghdr *msg, struct sock *sk,
583+
struct sk_buff *skb, int tlen, int offset);
583584
int ip_cmsg_send(struct sock *sk, struct msghdr *msg,
584585
struct ipcm_cookie *ipc, bool allow_ipv6);
585586
int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
@@ -601,7 +602,7 @@ void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport,
601602

602603
static inline void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb)
603604
{
604-
ip_cmsg_recv_offset(msg, skb, 0, 0);
605+
ip_cmsg_recv_offset(msg, skb->sk, skb, 0, 0);
605606
}
606607

607608
bool icmp_global_allow(void);

net/ipv4/ip_sockglue.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ static void ip_cmsg_recv_dstaddr(struct msghdr *msg, struct sk_buff *skb)
164164
put_cmsg(msg, SOL_IP, IP_ORIGDSTADDR, sizeof(sin), &sin);
165165
}
166166

167-
void ip_cmsg_recv_offset(struct msghdr *msg, struct sk_buff *skb,
168-
int tlen, int offset)
167+
void ip_cmsg_recv_offset(struct msghdr *msg, struct sock *sk,
168+
struct sk_buff *skb, int tlen, int offset)
169169
{
170-
struct inet_sock *inet = inet_sk(skb->sk);
170+
struct inet_sock *inet = inet_sk(sk);
171171
unsigned int flags = inet->cmsg_flags;
172172

173173
/* Ordered by supposed usage frequency */

net/ipv4/udp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
14211421
*addr_len = sizeof(*sin);
14221422
}
14231423
if (inet->cmsg_flags)
1424-
ip_cmsg_recv_offset(msg, skb, sizeof(struct udphdr), off);
1424+
ip_cmsg_recv_offset(msg, sk, skb, sizeof(struct udphdr), off);
14251425

14261426
err = copied;
14271427
if (flags & MSG_TRUNC)

net/ipv6/udp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
425425

426426
if (is_udp4) {
427427
if (inet->cmsg_flags)
428-
ip_cmsg_recv_offset(msg, skb,
428+
ip_cmsg_recv_offset(msg, sk, skb,
429429
sizeof(struct udphdr), off);
430430
} else {
431431
if (np->rxopt.all)

0 commit comments

Comments
 (0)