net: ipv6: add net argument to ip6_dst_lookup_flow
authorSabrina Dubroca <sd@queasysnail.net>
Wed, 4 Dec 2019 14:35:52 +0000 (15:35 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 May 2020 06:11:36 +0000 (08:11 +0200)
commit c4e85f73afb6384123e5ef1bba3315b2e3ad031e upstream.

This will be used in the conversion of ipv6_stub to ip6_dst_lookup_flow,
as some modules currently pass a net argument without a socket to
ip6_dst_lookup. This is equivalent to commit 343d60aada5a ("ipv6: change
ipv6_stub_impl.ipv6_dst_lookup to take net argument").

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 4.4: adjust context]
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/net/ipv6.h
net/dccp/ipv6.c
net/ipv6/af_inet6.c
net/ipv6/datagram.c
net/ipv6/inet6_connection_sock.c
net/ipv6/ip6_output.c
net/ipv6/raw.c
net/ipv6/syncookies.c
net/ipv6/tcp_ipv6.c
net/l2tp/l2tp_ip6.c
net/sctp/ipv6.c

index c07cf9596b6fb003c7deb4cf7bf5c340e9d981f2..6258264a0bf73d76a7a63832c669d85c611b88a4 100644 (file)
@@ -853,7 +853,7 @@ static inline struct sk_buff *ip6_finish_skb(struct sock *sk)
 
 int ip6_dst_lookup(struct net *net, struct sock *sk, struct dst_entry **dst,
                   struct flowi6 *fl6);
-struct dst_entry *ip6_dst_lookup_flow(const struct sock *sk, struct flowi6 *fl6,
+struct dst_entry *ip6_dst_lookup_flow(struct net *net, const struct sock *sk, struct flowi6 *fl6,
                                      const struct in6_addr *final_dst);
 struct dst_entry *ip6_sk_dst_lookup_flow(struct sock *sk, struct flowi6 *fl6,
                                         const struct in6_addr *final_dst);
index 10eabd1a60aa73a273cb938ae41f2700a517e183..736cc95b520116e920b7a3ca4357e67745ba32ec 100644 (file)
@@ -209,7 +209,7 @@ static int dccp_v6_send_response(const struct sock *sk, struct request_sock *req
        final_p = fl6_update_dst(&fl6, rcu_dereference(np->opt), &final);
        rcu_read_unlock();
 
-       dst = ip6_dst_lookup_flow(sk, &fl6, final_p);
+       dst = ip6_dst_lookup_flow(sock_net(sk), sk, &fl6, final_p);
        if (IS_ERR(dst)) {
                err = PTR_ERR(dst);
                dst = NULL;
@@ -276,7 +276,7 @@ static void dccp_v6_ctl_send_reset(const struct sock *sk, struct sk_buff *rxskb)
        security_skb_classify_flow(rxskb, flowi6_to_flowi(&fl6));
 
        /* sk = NULL, but it is safe for now. RST socket required. */
-       dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL);
+       dst = ip6_dst_lookup_flow(sock_net(ctl_sk), ctl_sk, &fl6, NULL);
        if (!IS_ERR(dst)) {
                skb_dst_set(skb, dst);
                ip6_xmit(ctl_sk, skb, &fl6, NULL, 0);
@@ -879,7 +879,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
        opt = rcu_dereference_protected(np->opt, sock_owned_by_user(sk));
        final_p = fl6_update_dst(&fl6, opt, &final);
 
-       dst = ip6_dst_lookup_flow(sk, &fl6, final_p);
+       dst = ip6_dst_lookup_flow(sock_net(sk), sk, &fl6, final_p);
        if (IS_ERR(dst)) {
                err = PTR_ERR(dst);
                goto failure;
index 46bf78a2843acfee41b96c1961d85ecde6fd5ae3..9d04393e87019bde6345bb8e88722646048a6e52 100644 (file)
@@ -683,7 +683,7 @@ int inet6_sk_rebuild_header(struct sock *sk)
                                         &final);
                rcu_read_unlock();
 
-               dst = ip6_dst_lookup_flow(sk, &fl6, final_p);
+               dst = ip6_dst_lookup_flow(sock_net(sk), sk, &fl6, final_p);
                if (IS_ERR(dst)) {
                        sk->sk_route_caps = 0;
                        sk->sk_err_soft = -PTR_ERR(dst);
index 27cdf543c53902bf5e69c80ac7c235d2023e92cd..f33154365b643c425ab6131aed9c680f64a4d9d7 100644 (file)
@@ -179,7 +179,7 @@ ipv4_connected:
        final_p = fl6_update_dst(&fl6, opt, &final);
        rcu_read_unlock();
 
-       dst = ip6_dst_lookup_flow(sk, &fl6, final_p);
+       dst = ip6_dst_lookup_flow(sock_net(sk), sk, &fl6, final_p);
        err = 0;
        if (IS_ERR(dst)) {
                err = PTR_ERR(dst);
index a7ca2cde2ecbcff85c9a6151b4770e3897d16314..b31ab511c7671e3e39c53c17b4c452ad180e9dc5 100644 (file)
@@ -88,7 +88,7 @@ struct dst_entry *inet6_csk_route_req(const struct sock *sk,
        fl6->fl6_sport = htons(ireq->ir_num);
        security_req_classify_flow(req, flowi6_to_flowi(fl6));
 
-       dst = ip6_dst_lookup_flow(sk, fl6, final_p);
+       dst = ip6_dst_lookup_flow(sock_net(sk), sk, fl6, final_p);
        if (IS_ERR(dst))
                return NULL;
 
@@ -142,7 +142,7 @@ static struct dst_entry *inet6_csk_route_socket(struct sock *sk,
 
        dst = __inet6_csk_dst_check(sk, np->dst_cookie);
        if (!dst) {
-               dst = ip6_dst_lookup_flow(sk, fl6, final_p);
+               dst = ip6_dst_lookup_flow(sock_net(sk), sk, fl6, final_p);
 
                if (!IS_ERR(dst))
                        ip6_dst_store(sk, dst, NULL, NULL);
index e39dc94486b2c7bcecb7969a8634ecb6522da233..1e2b8d33d303b85b3ba807e36bfd973c16582f3c 100644 (file)
@@ -1057,13 +1057,13 @@ EXPORT_SYMBOL_GPL(ip6_dst_lookup);
  *     It returns a valid dst pointer on success, or a pointer encoded
  *     error code.
  */
-struct dst_entry *ip6_dst_lookup_flow(const struct sock *sk, struct flowi6 *fl6,
+struct dst_entry *ip6_dst_lookup_flow(struct net *net, const struct sock *sk, struct flowi6 *fl6,
                                      const struct in6_addr *final_dst)
 {
        struct dst_entry *dst = NULL;
        int err;
 
-       err = ip6_dst_lookup_tail(sock_net(sk), sk, &dst, fl6);
+       err = ip6_dst_lookup_tail(net, sk, &dst, fl6);
        if (err)
                return ERR_PTR(err);
        if (final_dst)
@@ -1071,7 +1071,7 @@ struct dst_entry *ip6_dst_lookup_flow(const struct sock *sk, struct flowi6 *fl6,
        if (!fl6->flowi6_oif)
                fl6->flowi6_oif = l3mdev_fib_oif(dst->dev);
 
-       return xfrm_lookup_route(sock_net(sk), dst, flowi6_to_flowi(fl6), sk, 0);
+       return xfrm_lookup_route(net, dst, flowi6_to_flowi(fl6), sk, 0);
 }
 EXPORT_SYMBOL_GPL(ip6_dst_lookup_flow);
 
@@ -1096,7 +1096,7 @@ struct dst_entry *ip6_sk_dst_lookup_flow(struct sock *sk, struct flowi6 *fl6,
 
        dst = ip6_sk_dst_check(sk, dst, fl6);
        if (!dst)
-               dst = ip6_dst_lookup_flow(sk, fl6, final_dst);
+               dst = ip6_dst_lookup_flow(sock_net(sk), sk, fl6, final_dst);
 
        return dst;
 }
index 86c75e97cfec3abd716268819b03a0646aa13766..67cdcd3d644fa0b33ac8a257c0d4ad9006e71918 100644 (file)
@@ -889,7 +889,7 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
        if (hdrincl)
                fl6.flowi6_flags |= FLOWI_FLAG_KNOWN_NH;
 
-       dst = ip6_dst_lookup_flow(sk, &fl6, final_p);
+       dst = ip6_dst_lookup_flow(sock_net(sk), sk, &fl6, final_p);
        if (IS_ERR(dst)) {
                err = PTR_ERR(dst);
                goto out;
index aee87282d3521508fcf4de8331bf1894c3e1f557..fb3ba2a511196b25223a7c76d708fcfba40722f3 100644 (file)
@@ -231,7 +231,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
                fl6.fl6_sport = inet_sk(sk)->inet_sport;
                security_req_classify_flow(req, flowi6_to_flowi(&fl6));
 
-               dst = ip6_dst_lookup_flow(sk, &fl6, final_p);
+               dst = ip6_dst_lookup_flow(sock_net(sk), sk, &fl6, final_p);
                if (IS_ERR(dst))
                        goto out_free;
        }
index 6a36fcc5c4e1185d071fa71c2dc6736c18c3b00a..b4ffcec732b49ea4f12bb7cfa08ec1ac9f1d85d3 100644 (file)
@@ -245,7 +245,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
 
        security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
 
-       dst = ip6_dst_lookup_flow(sk, &fl6, final_p);
+       dst = ip6_dst_lookup_flow(sock_net(sk), sk, &fl6, final_p);
        if (IS_ERR(dst)) {
                err = PTR_ERR(dst);
                goto failure;
@@ -831,7 +831,7 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32
         * Underlying function will use this to retrieve the network
         * namespace
         */
-       dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL);
+       dst = ip6_dst_lookup_flow(sock_net(ctl_sk), ctl_sk, &fl6, NULL);
        if (!IS_ERR(dst)) {
                skb_dst_set(buff, dst);
                ip6_xmit(ctl_sk, buff, &fl6, NULL, tclass);
index af04a8a68269724b41b3d0a4f2dea47149547c9d..2b5230ef8536a0d6f4f6b7dce7b09f5ec43d979f 100644 (file)
@@ -619,7 +619,7 @@ static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 
        security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
 
-       dst = ip6_dst_lookup_flow(sk, &fl6, final_p);
+       dst = ip6_dst_lookup_flow(sock_net(sk), sk, &fl6, final_p);
        if (IS_ERR(dst)) {
                err = PTR_ERR(dst);
                goto out;
index dd097e065f39db1e393cc33917d131b2c9862b15..1a6849add0e347dcd4e86618254af39437ea220c 100644 (file)
@@ -268,7 +268,7 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
        final_p = fl6_update_dst(fl6, rcu_dereference(np->opt), &final);
        rcu_read_unlock();
 
-       dst = ip6_dst_lookup_flow(sk, fl6, final_p);
+       dst = ip6_dst_lookup_flow(sock_net(sk), sk, fl6, final_p);
        if (!asoc || saddr) {
                t->dst = dst;
                memcpy(fl, &_fl, sizeof(_fl));
@@ -326,7 +326,7 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
                fl6->saddr = laddr->a.v6.sin6_addr;
                fl6->fl6_sport = laddr->a.v6.sin6_port;
                final_p = fl6_update_dst(fl6, rcu_dereference(np->opt), &final);
-               bdst = ip6_dst_lookup_flow(sk, fl6, final_p);
+               bdst = ip6_dst_lookup_flow(sock_net(sk), sk, fl6, final_p);
 
                if (IS_ERR(bdst))
                        continue;