| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Point-to-Point Tunneling Protocol for Linux |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Authors: Dmitry Kozlov <xeb@mail.ru> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or |
|---|
| 7 | | - * modify it under the terms of the GNU General Public License |
|---|
| 8 | | - * as published by the Free Software Foundation; either version |
|---|
| 9 | | - * 2 of the License, or (at your option) any later version. |
|---|
| 10 | | - * |
|---|
| 11 | 6 | */ |
|---|
| 12 | 7 | |
|---|
| 13 | 8 | #include <linux/string.h> |
|---|
| .. | .. |
|---|
| 29 | 24 | #include <linux/in.h> |
|---|
| 30 | 25 | #include <linux/ip.h> |
|---|
| 31 | 26 | #include <linux/rcupdate.h> |
|---|
| 27 | +#include <linux/security.h> |
|---|
| 32 | 28 | #include <linux/spinlock.h> |
|---|
| 33 | 29 | |
|---|
| 34 | 30 | #include <net/sock.h> |
|---|
| .. | .. |
|---|
| 133 | 129 | spin_unlock(&chan_lock); |
|---|
| 134 | 130 | } |
|---|
| 135 | 131 | |
|---|
| 132 | +static struct rtable *pptp_route_output(struct pppox_sock *po, |
|---|
| 133 | + struct flowi4 *fl4) |
|---|
| 134 | +{ |
|---|
| 135 | + struct sock *sk = &po->sk; |
|---|
| 136 | + struct net *net; |
|---|
| 137 | + |
|---|
| 138 | + net = sock_net(sk); |
|---|
| 139 | + flowi4_init_output(fl4, sk->sk_bound_dev_if, sk->sk_mark, 0, |
|---|
| 140 | + RT_SCOPE_UNIVERSE, IPPROTO_GRE, 0, |
|---|
| 141 | + po->proto.pptp.dst_addr.sin_addr.s_addr, |
|---|
| 142 | + po->proto.pptp.src_addr.sin_addr.s_addr, |
|---|
| 143 | + 0, 0, sock_net_uid(net, sk)); |
|---|
| 144 | + security_sk_classify_flow(sk, flowi4_to_flowi_common(fl4)); |
|---|
| 145 | + |
|---|
| 146 | + return ip_route_output_flow(net, fl4, sk); |
|---|
| 147 | +} |
|---|
| 148 | + |
|---|
| 136 | 149 | static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb) |
|---|
| 137 | 150 | { |
|---|
| 138 | 151 | struct sock *sk = (struct sock *) chan->private; |
|---|
| .. | .. |
|---|
| 156 | 169 | if (sk_pppox(po)->sk_state & PPPOX_DEAD) |
|---|
| 157 | 170 | goto tx_error; |
|---|
| 158 | 171 | |
|---|
| 159 | | - rt = ip_route_output_ports(net, &fl4, NULL, |
|---|
| 160 | | - opt->dst_addr.sin_addr.s_addr, |
|---|
| 161 | | - opt->src_addr.sin_addr.s_addr, |
|---|
| 162 | | - 0, 0, IPPROTO_GRE, |
|---|
| 163 | | - RT_TOS(0), 0); |
|---|
| 172 | + rt = pptp_route_output(po, &fl4); |
|---|
| 164 | 173 | if (IS_ERR(rt)) |
|---|
| 165 | 174 | goto tx_error; |
|---|
| 166 | 175 | |
|---|
| .. | .. |
|---|
| 243 | 252 | skb_dst_drop(skb); |
|---|
| 244 | 253 | skb_dst_set(skb, &rt->dst); |
|---|
| 245 | 254 | |
|---|
| 246 | | - nf_reset(skb); |
|---|
| 255 | + nf_reset_ct(skb); |
|---|
| 247 | 256 | |
|---|
| 248 | 257 | skb->ip_summed = CHECKSUM_NONE; |
|---|
| 249 | 258 | ip_select_ident(net, skb, NULL); |
|---|
| .. | .. |
|---|
| 363 | 372 | po = lookup_chan(htons(header->call_id), iph->saddr); |
|---|
| 364 | 373 | if (po) { |
|---|
| 365 | 374 | skb_dst_drop(skb); |
|---|
| 366 | | - nf_reset(skb); |
|---|
| 375 | + nf_reset_ct(skb); |
|---|
| 367 | 376 | return sk_receive_skb(sk_pppox(po), skb, 0); |
|---|
| 368 | 377 | } |
|---|
| 369 | 378 | drop: |
|---|
| .. | .. |
|---|
| 445 | 454 | po->chan.private = sk; |
|---|
| 446 | 455 | po->chan.ops = &pptp_chan_ops; |
|---|
| 447 | 456 | |
|---|
| 448 | | - rt = ip_route_output_ports(sock_net(sk), &fl4, sk, |
|---|
| 449 | | - opt->dst_addr.sin_addr.s_addr, |
|---|
| 450 | | - opt->src_addr.sin_addr.s_addr, |
|---|
| 451 | | - 0, 0, |
|---|
| 452 | | - IPPROTO_GRE, RT_CONN_FLAGS(sk), 0); |
|---|
| 457 | + rt = pptp_route_output(po, &fl4); |
|---|
| 453 | 458 | if (IS_ERR(rt)) { |
|---|
| 454 | 459 | error = -EHOSTUNREACH; |
|---|
| 455 | 460 | goto end; |
|---|
| .. | .. |
|---|
| 622 | 627 | .getname = pptp_getname, |
|---|
| 623 | 628 | .listen = sock_no_listen, |
|---|
| 624 | 629 | .shutdown = sock_no_shutdown, |
|---|
| 625 | | - .setsockopt = sock_no_setsockopt, |
|---|
| 626 | | - .getsockopt = sock_no_getsockopt, |
|---|
| 627 | 630 | .sendmsg = sock_no_sendmsg, |
|---|
| 628 | 631 | .recvmsg = sock_no_recvmsg, |
|---|
| 629 | 632 | .mmap = sock_no_mmap, |
|---|