hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ppp/pptp.c
....@@ -1,13 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Point-to-Point Tunneling Protocol for Linux
34 *
45 * 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
- *
116 */
127
138 #include <linux/string.h>
....@@ -29,6 +24,7 @@
2924 #include <linux/in.h>
3025 #include <linux/ip.h>
3126 #include <linux/rcupdate.h>
27
+#include <linux/security.h>
3228 #include <linux/spinlock.h>
3329
3430 #include <net/sock.h>
....@@ -133,6 +129,23 @@
133129 spin_unlock(&chan_lock);
134130 }
135131
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
+
136149 static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
137150 {
138151 struct sock *sk = (struct sock *) chan->private;
....@@ -156,11 +169,7 @@
156169 if (sk_pppox(po)->sk_state & PPPOX_DEAD)
157170 goto tx_error;
158171
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);
164173 if (IS_ERR(rt))
165174 goto tx_error;
166175
....@@ -243,7 +252,7 @@
243252 skb_dst_drop(skb);
244253 skb_dst_set(skb, &rt->dst);
245254
246
- nf_reset(skb);
255
+ nf_reset_ct(skb);
247256
248257 skb->ip_summed = CHECKSUM_NONE;
249258 ip_select_ident(net, skb, NULL);
....@@ -363,7 +372,7 @@
363372 po = lookup_chan(htons(header->call_id), iph->saddr);
364373 if (po) {
365374 skb_dst_drop(skb);
366
- nf_reset(skb);
375
+ nf_reset_ct(skb);
367376 return sk_receive_skb(sk_pppox(po), skb, 0);
368377 }
369378 drop:
....@@ -445,11 +454,7 @@
445454 po->chan.private = sk;
446455 po->chan.ops = &pptp_chan_ops;
447456
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);
453458 if (IS_ERR(rt)) {
454459 error = -EHOSTUNREACH;
455460 goto end;
....@@ -622,8 +627,6 @@
622627 .getname = pptp_getname,
623628 .listen = sock_no_listen,
624629 .shutdown = sock_no_shutdown,
625
- .setsockopt = sock_no_setsockopt,
626
- .getsockopt = sock_no_getsockopt,
627630 .sendmsg = sock_no_sendmsg,
628631 .recvmsg = sock_no_recvmsg,
629632 .mmap = sock_no_mmap,