Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0270e91 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

ipv4: add a sock pointer to ip_queue_xmit()



ip_queue_xmit() assumes the skb it has to transmit is attached to an
inet socket. Commit 31c70d59 ("l2tp: keep original skb ownership")
changed l2tp to not change skb ownership and thus broke this assumption.

One fix is to add a new 'struct sock *sk' parameter to ip_queue_xmit(),
so that we do not assume skb->sk points to the socket used by l2tp
tunnel.

Fixes: 31c70d59 ("l2tp: keep original skb ownership")
Reported-by: default avatarZhan Jianyu <nasa4836@gmail.com>
Tested-by: default avatarZhan Jianyu <nasa4836@gmail.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1dd333f4
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -40,7 +40,7 @@ void inet6_csk_reqsk_queue_hash_add(struct sock *sk, struct request_sock *req,


void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr);
void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr);


int inet6_csk_xmit(struct sk_buff *skb, struct flowi *fl);
int inet6_csk_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl);


struct dst_entry *inet6_csk_update_pmtu(struct sock *sk, u32 mtu);
struct dst_entry *inet6_csk_update_pmtu(struct sock *sk, u32 mtu);
#endif /* _INET6_CONNECTION_SOCK_H */
#endif /* _INET6_CONNECTION_SOCK_H */
+1 −1
Original line number Original line Diff line number Diff line
@@ -36,7 +36,7 @@ struct tcp_congestion_ops;
 * (i.e. things that depend on the address family)
 * (i.e. things that depend on the address family)
 */
 */
struct inet_connection_sock_af_ops {
struct inet_connection_sock_af_ops {
	int	    (*queue_xmit)(struct sk_buff *skb, struct flowi *fl);
	int	    (*queue_xmit)(struct sock *sk, struct sk_buff *skb, struct flowi *fl);
	void	    (*send_check)(struct sock *sk, struct sk_buff *skb);
	void	    (*send_check)(struct sock *sk, struct sk_buff *skb);
	int	    (*rebuild_header)(struct sock *sk);
	int	    (*rebuild_header)(struct sock *sk);
	void	    (*sk_rx_dst_set)(struct sock *sk, const struct sk_buff *skb);
	void	    (*sk_rx_dst_set)(struct sock *sk, const struct sk_buff *skb);
+1 −1
Original line number Original line Diff line number Diff line
@@ -111,7 +111,7 @@ int ip_do_nat(struct sk_buff *skb);
void ip_send_check(struct iphdr *ip);
void ip_send_check(struct iphdr *ip);
int __ip_local_out(struct sk_buff *skb);
int __ip_local_out(struct sk_buff *skb);
int ip_local_out(struct sk_buff *skb);
int ip_local_out(struct sk_buff *skb);
int ip_queue_xmit(struct sk_buff *skb, struct flowi *fl);
int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl);
void ip_init(void);
void ip_init(void);
int ip_append_data(struct sock *sk, struct flowi4 *fl4,
int ip_append_data(struct sock *sk, struct flowi4 *fl4,
		   int getfrag(void *from, char *to, int offset, int len,
		   int getfrag(void *from, char *to, int offset, int len,
+1 −1
Original line number Original line Diff line number Diff line
@@ -138,7 +138,7 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)


		DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
		DCCP_INC_STATS(DCCP_MIB_OUTSEGS);


		err = icsk->icsk_af_ops->queue_xmit(skb, &inet->cork.fl);
		err = icsk->icsk_af_ops->queue_xmit(sk, skb, &inet->cork.fl);
		return net_xmit_eval(err);
		return net_xmit_eval(err);
	}
	}
	return -ENOBUFS;
	return -ENOBUFS;
+3 −2
Original line number Original line Diff line number Diff line
@@ -315,9 +315,9 @@ static void ip_copy_addrs(struct iphdr *iph, const struct flowi4 *fl4)
	       sizeof(fl4->saddr) + sizeof(fl4->daddr));
	       sizeof(fl4->saddr) + sizeof(fl4->daddr));
}
}


int ip_queue_xmit(struct sk_buff *skb, struct flowi *fl)
/* Note: skb->sk can be different from sk, in case of tunnels */
int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
{
{
	struct sock *sk = skb->sk;
	struct inet_sock *inet = inet_sk(sk);
	struct inet_sock *inet = inet_sk(sk);
	struct ip_options_rcu *inet_opt;
	struct ip_options_rcu *inet_opt;
	struct flowi4 *fl4;
	struct flowi4 *fl4;
@@ -389,6 +389,7 @@ int ip_queue_xmit(struct sk_buff *skb, struct flowi *fl)
	ip_select_ident_more(skb, &rt->dst, sk,
	ip_select_ident_more(skb, &rt->dst, sk,
			     (skb_shinfo(skb)->gso_segs ?: 1) - 1);
			     (skb_shinfo(skb)->gso_segs ?: 1) - 1);


	/* TODO : should we use skb->sk here instead of sk ? */
	skb->priority = sk->sk_priority;
	skb->priority = sk->sk_priority;
	skb->mark = sk->sk_mark;
	skb->mark = sk->sk_mark;


Loading