| .. | .. |
|---|
| 24 | 24 | #include <linux/in.h> |
|---|
| 25 | 25 | #include <linux/ip.h> |
|---|
| 26 | 26 | #include <linux/rcupdate.h> |
|---|
| 27 | +#include <linux/security.h> |
|---|
| 27 | 28 | #include <linux/spinlock.h> |
|---|
| 28 | 29 | |
|---|
| 29 | 30 | #include <net/sock.h> |
|---|
| .. | .. |
|---|
| 128 | 129 | spin_unlock(&chan_lock); |
|---|
| 129 | 130 | } |
|---|
| 130 | 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 | + |
|---|
| 131 | 149 | static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb) |
|---|
| 132 | 150 | { |
|---|
| 133 | 151 | struct sock *sk = (struct sock *) chan->private; |
|---|
| .. | .. |
|---|
| 151 | 169 | if (sk_pppox(po)->sk_state & PPPOX_DEAD) |
|---|
| 152 | 170 | goto tx_error; |
|---|
| 153 | 171 | |
|---|
| 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); |
|---|
| 159 | 173 | if (IS_ERR(rt)) |
|---|
| 160 | 174 | goto tx_error; |
|---|
| 161 | 175 | |
|---|
| .. | .. |
|---|
| 440 | 454 | po->chan.private = sk; |
|---|
| 441 | 455 | po->chan.ops = &pptp_chan_ops; |
|---|
| 442 | 456 | |
|---|
| 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); |
|---|
| 449 | 458 | if (IS_ERR(rt)) { |
|---|
| 450 | 459 | error = -EHOSTUNREACH; |
|---|
| 451 | 460 | goto end; |
|---|