aboutsummaryrefslogtreecommitdiffstats
path: root/net/l2tp
diff options
context:
space:
mode:
Diffstat (limited to 'net/l2tp')
-rw-r--r--net/l2tp/l2tp_core.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index aedaa2cd4237..b076e8309bc2 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -115,6 +115,11 @@ struct l2tp_net {
115static void l2tp_session_set_header_len(struct l2tp_session *session, int version); 115static void l2tp_session_set_header_len(struct l2tp_session *session, int version);
116static void l2tp_tunnel_free(struct l2tp_tunnel *tunnel); 116static void l2tp_tunnel_free(struct l2tp_tunnel *tunnel);
117 117
118static inline struct l2tp_tunnel *l2tp_tunnel(struct sock *sk)
119{
120 return sk->sk_user_data;
121}
122
118static inline struct l2tp_net *l2tp_pernet(struct net *net) 123static inline struct l2tp_net *l2tp_pernet(struct net *net)
119{ 124{
120 BUG_ON(!net); 125 BUG_ON(!net);
@@ -496,7 +501,6 @@ out:
496static inline int l2tp_verify_udp_checksum(struct sock *sk, 501static inline int l2tp_verify_udp_checksum(struct sock *sk,
497 struct sk_buff *skb) 502 struct sk_buff *skb)
498{ 503{
499 struct l2tp_tunnel *tunnel = (struct l2tp_tunnel *)sk->sk_user_data;
500 struct udphdr *uh = udp_hdr(skb); 504 struct udphdr *uh = udp_hdr(skb);
501 u16 ulen = ntohs(uh->len); 505 u16 ulen = ntohs(uh->len);
502 __wsum psum; 506 __wsum psum;
@@ -505,7 +509,7 @@ static inline int l2tp_verify_udp_checksum(struct sock *sk,
505 return 0; 509 return 0;
506 510
507#if IS_ENABLED(CONFIG_IPV6) 511#if IS_ENABLED(CONFIG_IPV6)
508 if (sk->sk_family == PF_INET6 && !tunnel->v4mapped) { 512 if (sk->sk_family == PF_INET6 && !l2tp_tunnel(sk)->v4mapped) {
509 if (!uh->check) { 513 if (!uh->check) {
510 LIMIT_NETDEBUG(KERN_INFO "L2TP: IPv6: checksum is 0\n"); 514 LIMIT_NETDEBUG(KERN_INFO "L2TP: IPv6: checksum is 0\n");
511 return 1; 515 return 1;
@@ -1305,10 +1309,9 @@ EXPORT_SYMBOL_GPL(l2tp_xmit_skb);
1305 */ 1309 */
1306static void l2tp_tunnel_destruct(struct sock *sk) 1310static void l2tp_tunnel_destruct(struct sock *sk)
1307{ 1311{
1308 struct l2tp_tunnel *tunnel; 1312 struct l2tp_tunnel *tunnel = l2tp_tunnel(sk);
1309 struct l2tp_net *pn; 1313 struct l2tp_net *pn;
1310 1314
1311 tunnel = sk->sk_user_data;
1312 if (tunnel == NULL) 1315 if (tunnel == NULL)
1313 goto end; 1316 goto end;
1314 1317
@@ -1676,7 +1679,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
1676 } 1679 }
1677 1680
1678 /* Check if this socket has already been prepped */ 1681 /* Check if this socket has already been prepped */
1679 tunnel = (struct l2tp_tunnel *)sk->sk_user_data; 1682 tunnel = l2tp_tunnel(sk);
1680 if (tunnel != NULL) { 1683 if (tunnel != NULL) {
1681 /* This socket has already been prepped */ 1684 /* This socket has already been prepped */
1682 err = -EBUSY; 1685 err = -EBUSY;