hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ppp/pptp.c
....@@ -24,6 +24,7 @@
2424 #include <linux/in.h>
2525 #include <linux/ip.h>
2626 #include <linux/rcupdate.h>
27
+#include <linux/security.h>
2728 #include <linux/spinlock.h>
2829
2930 #include <net/sock.h>
....@@ -128,6 +129,23 @@
128129 spin_unlock(&chan_lock);
129130 }
130131
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
+
131149 static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
132150 {
133151 struct sock *sk = (struct sock *) chan->private;
....@@ -151,11 +169,7 @@
151169 if (sk_pppox(po)->sk_state & PPPOX_DEAD)
152170 goto tx_error;
153171
154
- rt = ip_route_output_ports(net, &fl4, NULL,
155
- opt->dst_addr.sin_addr.s_addr,
156
- opt->src_addr.sin_addr.s_addr,
157
- 0, 0, IPPROTO_GRE,
158
- RT_TOS(0), sk->sk_bound_dev_if);
172
+ rt = pptp_route_output(po, &fl4);
159173 if (IS_ERR(rt))
160174 goto tx_error;
161175
....@@ -440,12 +454,7 @@
440454 po->chan.private = sk;
441455 po->chan.ops = &pptp_chan_ops;
442456
443
- rt = ip_route_output_ports(sock_net(sk), &fl4, sk,
444
- opt->dst_addr.sin_addr.s_addr,
445
- opt->src_addr.sin_addr.s_addr,
446
- 0, 0,
447
- IPPROTO_GRE, RT_CONN_FLAGS(sk),
448
- sk->sk_bound_dev_if);
457
+ rt = pptp_route_output(po, &fl4);
449458 if (IS_ERR(rt)) {
450459 error = -EHOSTUNREACH;
451460 goto end;